Bug 983971 - Do not use gralloc for small size on ICS gonk. r=nical, a=1.4+
[gecko.git] / layout / generic / nsILineIterator.h
blob15222825440d5a84793720e683337b22053006d4
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___
8 #include "nscore.h"
9 #include "nsCoord.h"
11 class nsIFrame;
12 struct nsRect;
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
23 /**
24 * Line iterator API.
26 * Lines are numbered from 0 to N, where 0 is the top line and N is
27 * the bottom line.
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.
33 class nsILineIterator
35 protected:
36 ~nsILineIterator() { }
38 public:
39 virtual void DisposeLineIterator() = 0;
41 /**
42 * The number of lines in the block
44 virtual int32_t GetNumLines() = 0;
46 /**
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
58 // zero.
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
66 // line.
67 NS_IMETHOD GetLine(int32_t aLineNumber,
68 nsIFrame** aFirstFrameOnLine,
69 int32_t* aNumFramesOnLine,
70 nsRect& aLineBounds,
71 uint32_t* aLineFlags) = 0;
73 /**
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
85 // appropriately.
86 NS_IMETHOD FindFrameAt(int32_t aLineNumber,
87 nscoord aX,
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;
96 #ifdef IBMBIDI
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,
100 bool *aIsReordered,
101 nsIFrame **aFirstVisual,
102 nsIFrame **aLastVisual) = 0;
103 #endif
106 class nsAutoLineIterator
108 public:
109 nsAutoLineIterator() : mRawPtr(nullptr) { }
110 nsAutoLineIterator(nsILineIterator *i) : mRawPtr(i) { }
112 ~nsAutoLineIterator() {
113 if (mRawPtr)
114 mRawPtr->DisposeLineIterator();
117 operator nsILineIterator*() { return mRawPtr; }
118 nsILineIterator* operator->() { return mRawPtr; }
120 nsILineIterator* operator=(nsILineIterator* i) {
121 if (i == mRawPtr)
122 return i;
124 if (mRawPtr)
125 mRawPtr->DisposeLineIterator();
127 mRawPtr = i;
128 return i;
131 private:
132 nsILineIterator* mRawPtr;
135 #endif /* nsILineIterator_h___ */