LCOV - app.info - layout/generic/nsILineIterator.h

LCOV - code coverage report
| Current view: | directory - layout/generic - nsILineIterator.h (source / functions) |  | Found | Hit | Coverage |
| Test: | app.info | Lines: | 17 | 0 | 0.0 %
| Date: | 2012-07-07 | Functions: | 8 | 0 | 0.0 %

           1                 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
           2                 : /* ***** BEGIN LICENSE BLOCK *****
           3                 :  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
           4                 :  *
           5                 :  * The contents of this file are subject to the Mozilla Public License Version
           6                 :  * 1.1 (the "License"); you may not use this file except in compliance with
           7                 :  * the License. You may obtain a copy of the License at
           8                 :  * http://www.mozilla.org/MPL/
           9                 :  *
          10                 :  * Software distributed under the License is distributed on an "AS IS" basis,
          11                 :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
          12                 :  * for the specific language governing rights and limitations under the
          13                 :  * License.
          14                 :  *
          15                 :  * The Original Code is Mozilla Communicator client code.
          16                 :  *
          17                 :  * The Initial Developer of the Original Code is
          18                 :  * Netscape Communications Corporation.
          19                 :  * Portions created by the Initial Developer are Copyright (C) 1998
          20                 :  * the Initial Developer. All Rights Reserved.
          21                 :  *
          22                 :  * Contributor(s):
          23                 :  *
          24                 :  * Alternatively, the contents of this file may be used under the terms of
          25                 :  * either of the GNU General Public License Version 2 or later (the "GPL"),
          26                 :  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
          27                 :  * in which case the provisions of the GPL or the LGPL are applicable instead
          28                 :  * of those above. If you wish to allow use of your version of this file only
          29                 :  * under the terms of either the GPL or the LGPL, and not to allow others to
          30                 :  * use your version of this file under the terms of the MPL, indicate your
          31                 :  * decision by deleting the provisions above and replace them with the notice
          32                 :  * and other provisions required by the GPL or the LGPL. If you do not delete
          33                 :  * the provisions above, a recipient may use your version of this file under
          34                 :  * the terms of any one of the MPL, the GPL or the LGPL.
          35                 :  *
          36                 :  * ***** END LICENSE BLOCK ***** */
          37                 : #ifndef nsILineIterator_h___
          38                 : #define nsILineIterator_h___
          39                 :
          40                 : #include "nscore.h"
          41                 : #include "nsCoord.h"
          42                 :
          43                 : class nsIFrame;
          44                 : struct nsRect;
          45                 :
          46                 : // Line Flags (see GetLine below)
          47                 :
          48                 : // This bit is set when the line is wrapping up a block frame. When
          49                 : // clear, it means that the line contains inline elements.
          50                 : #define NS_LINE_FLAG_IS_BLOCK           0x1
          51                 :
          52                 : // This bit is set when the line ends in some sort of break.
          53                 : #define NS_LINE_FLAG_ENDS_IN_BREAK      0x4
          54                 :
          55                 : /**
          56                 :  * Line iterator API.
          57                 :  *
          58                 :  * Lines are numbered from 0 to N, where 0 is the top line and N is
          59                 :  * the bottom line.
          60                 :  *
          61                 :  * Obtain this interface from frames via nsIFrame::GetLineIterator.
          62                 :  * When you are finished using the iterator, call DisposeLineIterator()
          63                 :  * to destroy the iterator if appropriate.
          64                 :  */
          65                 : class nsILineIterator
          66               0 : {
          67                 : protected:
          68               0 :   ~nsILineIterator() { }
          69                 :
          70                 : public:
          71                 :   virtual void DisposeLineIterator() = 0;
          72                 :
          73                 :   /**
          74                 :    * The number of lines in the block
          75                 :    */
          76                 :   virtual PRInt32 GetNumLines() = 0;
          77                 :
          78                 :   /**
          79                 :    * The prevailing direction of lines.
          80                 :    *
          81                 :    * @return true if the CSS direction property for the block is
          82                 :    *         "rtl", otherwise false
          83                 :    */
          84                 :   virtual bool GetDirection() = 0;
          85                 :
          86                 :   // Return structural information about a line. aFirstFrameOnLine is
          87                 :   // the first frame on the line and aNumFramesOnLine is the number of
          88                 :   // frames that are on the line. If the line-number is invalid then
          89                 :   // aFirstFrameOnLine will be nsnull and aNumFramesOnLine will be
          90                 :   // zero.
          91                 :   //
          92                 :   // For valid line numbers, aLineBounds is set to the bounding box of
          93                 :   // the line (which is based on the in-flow position of the frames on
          94                 :   // the line; if a frame was moved because of relative positioning
          95                 :   // then its coordinates may be outside the line bounds).
          96                 :   //
          97                 :   // In addition, aLineFlags will contain flag information about the
          98                 :   // line.
          99                 :   NS_IMETHOD GetLine(PRInt32 aLineNumber,
         100                 :                      nsIFrame** aFirstFrameOnLine,
         101                 :                      PRInt32* aNumFramesOnLine,
         102                 :                      nsRect& aLineBounds,
         103                 :                      PRUint32* aLineFlags) = 0;
         104                 :
         105                 :   /**
         106                 :    * Given a frame that's a child of the block, find which line its on
         107                 :    * and return that line index, as long as it's at least as big as
         108                 :    * aStartLine.  Returns -1 if the frame cannot be found on lines
         109                 :    * starting with aStartLine.
         110                 :    */
         111                 :   virtual PRInt32 FindLineContaining(nsIFrame* aFrame,
         112                 :                                      PRInt32 aStartLine = 0) = 0;
         113                 :
         114                 :   // Given a line number and an X coordinate, find the frame on the
         115                 :   // line that is nearest to the X coordinate. The
         116                 :   // aXIsBeforeFirstFrame and aXIsAfterLastFrame flags are updated
         117                 :   // appropriately.
         118                 :   NS_IMETHOD FindFrameAt(PRInt32 aLineNumber,
         119                 :                          nscoord aX,
         120                 :                          nsIFrame** aFrameFound,
         121                 :                          bool* aXIsBeforeFirstFrame,
         122                 :                          bool* aXIsAfterLastFrame) = 0;
         123                 :
         124                 :   // Give the line iterator implementor a chance todo something more complicated than
         125                 :   // nsIFrame::GetNextSibling()
         126                 :   NS_IMETHOD GetNextSiblingOnLine(nsIFrame*& aFrame, PRInt32 aLineNumber) = 0;
         127                 :
         128                 : #ifdef IBMBIDI
         129                 :   // Check whether visual and logical order of frames within a line are identical.
         130                 :   //  If not, return the first and last visual frames
         131                 :   NS_IMETHOD CheckLineOrder(PRInt32                  aLine,
         132                 :                             bool                     *aIsReordered,
         133                 :                             nsIFrame                 **aFirstVisual,
         134                 :                             nsIFrame                 **aLastVisual) = 0;
         135                 : #endif
         136                 : };
         137                 :
         138                 : class nsAutoLineIterator
         139                 : {
         140                 : public:
         141               0 :   nsAutoLineIterator() : mRawPtr(nsnull) { }
         142               0 :   nsAutoLineIterator(nsILineIterator *i) : mRawPtr(i) { }
         143                 :
         144               0 :   ~nsAutoLineIterator() {
         145               0 :     if (mRawPtr)
         146               0 :       mRawPtr->DisposeLineIterator();
         147               0 :   }
         148                 :
         149               0 :   operator nsILineIterator*() { return mRawPtr; }
         150               0 :   nsILineIterator* operator->() { return mRawPtr; }
         151                 :
         152               0 :   nsILineIterator* operator=(nsILineIterator* i) {
         153               0 :     if (i == mRawPtr)
         154               0 :       return i;
         155                 :
         156               0 :     if (mRawPtr)
         157               0 :       mRawPtr->DisposeLineIterator();
         158                 :
         159               0 :     mRawPtr = i;
         160               0 :     return i;
         161                 :   }
         162                 :
         163                 : private:
         164                 :   nsILineIterator* mRawPtr;
         165                 : };
         166                 :
         167                 : #endif /* nsILineIterator_h___ */

Generated by: LCOV version 1.7