Back to index

lightning-sunbird  0.9+nobinonly
nsILineIterator.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is Mozilla Communicator client code.
00016  *
00017  * The Initial Developer of the Original Code is
00018  * Netscape Communications Corporation.
00019  * Portions created by the Initial Developer are Copyright (C) 1998
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *
00024  * Alternatively, the contents of this file may be used under the terms of
00025  * either of the GNU General Public License Version 2 or later (the "GPL"),
00026  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00027  * in which case the provisions of the GPL or the LGPL are applicable instead
00028  * of those above. If you wish to allow use of your version of this file only
00029  * under the terms of either the GPL or the LGPL, and not to allow others to
00030  * use your version of this file under the terms of the MPL, indicate your
00031  * decision by deleting the provisions above and replace them with the notice
00032  * and other provisions required by the GPL or the LGPL. If you do not delete
00033  * the provisions above, a recipient may use your version of this file under
00034  * the terms of any one of the MPL, the GPL or the LGPL.
00035  *
00036  * ***** END LICENSE BLOCK ***** */
00037 #ifndef nsILineIterator_h___
00038 #define nsILineIterator_h___
00039 
00040 #include "nsISupports.h"
00041 
00042 /* a6cf90ff-15b3-11d2-932e-00805f8add32 */
00043 #define NS_ILINE_ITERATOR_IID \
00044  { 0xa6cf90ff, 0x15b3, 0x11d2,{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32}}
00045 
00046 /* {80AA3D7A-E0BF-4e18-8A82-2110397D7BC4}*/
00047 #define NS_ILINE_ITERATOR_NAV_IID \
00048  { 0x80aa3d7a, 0xe0bf, 0x4e18,{0x8a, 0x82, 0x21, 0x10, 0x39, 0x7d, 0x7b, 0xc4}}
00049 
00050 // Line iterator API.
00051 //
00052 // Lines are numbered from 0 to N, where 0 is the top line and N is
00053 // the bottom line.
00054 //
00055 // NOTE: while you can get this interface by doing a slezy hacky
00056 // QueryInterface on block frames, it isn't like a normal com
00057 // interface: its not reflexive (you can't query back to the block
00058 // frame) and unlike other frames, it *IS* reference counted so don't
00059 // forget to NS_RELEASE it when you are done with it!
00060 
00061 // Line Flags (see GetLine below)
00062 
00063 // This bit is set when the line is wrapping up a block frame. When
00064 // clear, it means that the line contains inline elements.
00065 #define NS_LINE_FLAG_IS_BLOCK           0x1
00066 
00067 // This bit is set when the line ends in some sort of break.
00068 #define NS_LINE_FLAG_ENDS_IN_BREAK      0x4
00069 
00070 class nsILineIterator : public nsISupports {
00071 public:
00072   NS_DEFINE_STATIC_IID_ACCESSOR(NS_ILINE_ITERATOR_IID)
00073 
00074   // Return the number of lines in the block.
00075   NS_IMETHOD GetNumLines(PRInt32* aResult) = 0;
00076 
00077   // Return the prevailing direction for the line. aIsRightToLeft will
00078   // be set to PR_TRUE if the CSS direction property for the block is
00079   // "rtl", otherwise aIsRightToLeft will be set to PR_FALSE.
00080   NS_IMETHOD GetDirection(PRBool* aIsRightToLeft) = 0;
00081 
00082   // Return structural information about a line. aFirstFrameOnLine is
00083   // the first frame on the line and aNumFramesOnLine is the number of
00084   // frames that are on the line. If the line-number is invalid then
00085   // aFirstFrameOnLine will be nsnull and aNumFramesOnLine will be
00086   // zero.
00087   //
00088   // For valid line numbers, aLineBounds is set to the bounding box of
00089   // the line (which is based on the in-flow position of the frames on
00090   // the line; if a frame was moved because of relative positioning
00091   // then its coordinates may be outside the line bounds).
00092   //
00093   // In addition, aLineFlags will contain flag information about the
00094   // line.
00095   NS_IMETHOD GetLine(PRInt32 aLineNumber,
00096                      nsIFrame** aFirstFrameOnLine,
00097                      PRInt32* aNumFramesOnLine,
00098                      nsRect& aLineBounds,
00099                      PRUint32* aLineFlags) = 0;
00100 
00101   // Given a frame thats a child of the block, find which line its on
00102   // and return that line index into aIndexResult. aIndexResult will
00103   // be set to -1 if the frame cannot be found.
00104   NS_IMETHOD FindLineContaining(nsIFrame* aFrame,
00105                                 PRInt32* aLineNumberResult) = 0;
00106 
00107   // Given a Y coordinate relative to the block that provided this
00108   // line iterator, find the line that contains the Y
00109   // coordinate. Returns -1 in aLineNumberResult if the Y coordinate
00110   // is above the first line. Returns N (where N is the number of
00111   // lines) if the Y coordinate is below the last line.
00112   NS_IMETHOD FindLineAt(nscoord aY,
00113                         PRInt32* aLineNumberResult) = 0;
00114 
00115   // Given a line number and an X coordinate, find the frame on the
00116   // line that is nearest to the X coordinate. The
00117   // aXIsBeforeFirstFrame and aXIsAfterLastFrame flags are updated
00118   // appropriately.
00119   NS_IMETHOD FindFrameAt(PRInt32 aLineNumber,
00120                          nscoord aX,
00121                          nsIFrame** aFrameFound,
00122                          PRBool* aXIsBeforeFirstFrame,
00123                          PRBool* aXIsAfterLastFrame) = 0;
00124 
00125   // Give the line iterator implementor a chance todo something more complicated than
00126   // nsIFrame::GetNextSibling()
00127   NS_IMETHOD GetNextSiblingOnLine(nsIFrame*& aFrame, PRInt32 aLineNumber) = 0;
00128 
00129 #ifdef IBMBIDI
00130   // Check whether visual and logical order of frames within a line are identical.
00131   //  If not, return the first and last visual frames
00132   NS_IMETHOD CheckLineOrder(PRInt32                  aLine,
00133                             PRBool                   *aIsReordered,
00134                             nsIFrame                 **aFirstVisual,
00135                             nsIFrame                 **aLastVisual) = 0;
00136 #endif
00137 };
00138 
00139 //special line iterator for keyboard navigation
00140 class nsILineIteratorNavigator : public nsILineIterator {
00141 public:
00142   NS_DEFINE_STATIC_IID_ACCESSOR(NS_ILINE_ITERATOR_NAV_IID)
00143 
00144 };
00145 #endif /* nsILineIterator_h___ */