1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 #ifndef nsILineIterator_h___
6 #define nsILineIterator_h___
14 // Line Flags (see GetLine below)
16 // This bit is set when the line is wrapping up a block frame. When
17 // clear, it means that the line contains inline elements.
18 #define NS_LINE_FLAG_IS_BLOCK 0x1
20 // This bit is set when the line ends in some sort of break.
21 #define NS_LINE_FLAG_ENDS_IN_BREAK 0x4
26 * Lines are numbered from 0 to N, where 0 is the top line and N is
29 * Obtain this interface from frames via nsIFrame::GetLineIterator.
30 * When you are finished using the iterator, call DisposeLineIterator()
31 * to destroy the iterator if appropriate.
36 ~nsILineIterator() { }
39 virtual void DisposeLineIterator() = 0;
42 * The number of lines in the block
44 virtual int32_t GetNumLines() = 0;
47 * The prevailing direction of lines.
49 * @return true if the CSS direction property for the block is
50 * "rtl", otherwise false
52 virtual bool GetDirection() = 0;
54 // Return structural information about a line. aFirstFrameOnLine is
55 // the first frame on the line and aNumFramesOnLine is the number of
56 // frames that are on the line. If the line-number is invalid then
57 // aFirstFrameOnLine will be nullptr and aNumFramesOnLine will be
60 // For valid line numbers, aLineBounds is set to the bounding box of
61 // the line (which is based on the in-flow position of the frames on
62 // the line; if a frame was moved because of relative positioning
63 // then its coordinates may be outside the line bounds).
65 // In addition, aLineFlags will contain flag information about the
67 NS_IMETHOD
GetLine(int32_t aLineNumber
,
68 nsIFrame
** aFirstFrameOnLine
,
69 int32_t* aNumFramesOnLine
,
71 uint32_t* aLineFlags
) = 0;
74 * Given a frame that's a child of the block, find which line its on
75 * and return that line index, as long as it's at least as big as
76 * aStartLine. Returns -1 if the frame cannot be found on lines
77 * starting with aStartLine.
79 virtual int32_t FindLineContaining(nsIFrame
* aFrame
,
80 int32_t aStartLine
= 0) = 0;
82 // Given a line number and an X coordinate, find the frame on the
83 // line that is nearest to the X coordinate. The
84 // aXIsBeforeFirstFrame and aXIsAfterLastFrame flags are updated
86 NS_IMETHOD
FindFrameAt(int32_t aLineNumber
,
88 nsIFrame
** aFrameFound
,
89 bool* aXIsBeforeFirstFrame
,
90 bool* aXIsAfterLastFrame
) = 0;
92 // Give the line iterator implementor a chance todo something more complicated than
93 // nsIFrame::GetNextSibling()
94 NS_IMETHOD
GetNextSiblingOnLine(nsIFrame
*& aFrame
, int32_t aLineNumber
) = 0;
97 // Check whether visual and logical order of frames within a line are identical.
98 // If not, return the first and last visual frames
99 NS_IMETHOD
CheckLineOrder(int32_t aLine
,
101 nsIFrame
**aFirstVisual
,
102 nsIFrame
**aLastVisual
) = 0;
106 class nsAutoLineIterator
109 nsAutoLineIterator() : mRawPtr(nullptr) { }
110 nsAutoLineIterator(nsILineIterator
*i
) : mRawPtr(i
) { }
112 ~nsAutoLineIterator() {
114 mRawPtr
->DisposeLineIterator();
117 operator nsILineIterator
*() { return mRawPtr
; }
118 nsILineIterator
* operator->() { return mRawPtr
; }
120 nsILineIterator
* operator=(nsILineIterator
* i
) {
125 mRawPtr
->DisposeLineIterator();
132 nsILineIterator
* mRawPtr
;
135 #endif /* nsILineIterator_h___ */