Bug 449371 Firefox/Thunderbird crashes at exit [@ gdk_display_x11_finalize], p=Brian...
[wine-gecko.git] / layout / generic / nsInlineFrame.h
blobaa7836ecf91fa9766e0f12f19e8500b6c4db2894
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
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/
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.
15 * The Original Code is Mozilla Communicator client code.
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.
22 * Contributor(s):
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.
36 * ***** END LICENSE BLOCK ***** */
38 /* rendering object for CSS display:inline objects */
40 #ifndef nsInlineFrame_h___
41 #define nsInlineFrame_h___
43 #include "nsHTMLContainerFrame.h"
44 #include "nsAbsoluteContainingBlock.h"
45 #include "nsLineLayout.h"
47 class nsAnonymousBlockFrame;
49 #define NS_INLINE_FRAME_CID \
50 { 0x88b298af, 0x8b0e, 0x4592,{0x9e, 0xc6, 0xea, 0x4c, 0x4b, 0x3f, 0xf7, 0xa4}}
52 #define nsInlineFrameSuper nsHTMLContainerFrame
54 // NS_INLINE_FRAME_HARD_TEXT_OFFSETS is used for access keys, where what
55 // would normally be 1 text frame is split into 3 sets of an inline parent
56 // and text child (the pre access key text, the underlined key text, and
57 // the post access key text). The offsets of the 3 text frame children
58 // are set in nsCSSFrameConstructor
60 #define NS_INLINE_FRAME_HARD_TEXT_OFFSETS 0x00100000
62 /** In Bidi left (or right) margin/padding/border should be applied to left
63 * (or right) most frame (or a continuation frame).
64 * This state value shows if this frame is left (or right) most continuation
65 * or not.
67 #define NS_INLINE_FRAME_BIDI_VISUAL_STATE_IS_SET 0x00200000
69 #define NS_INLINE_FRAME_BIDI_VISUAL_IS_LEFT_MOST 0x00400000
71 #define NS_INLINE_FRAME_BIDI_VISUAL_IS_RIGHT_MOST 0x00800000
73 /**
74 * Inline frame class.
76 * This class manages a list of child frames that are inline frames. Working with
77 * nsLineLayout, the class will reflow and place inline frames on a line.
79 class nsInlineFrame : public nsInlineFrameSuper
81 public:
82 friend nsIFrame* NS_NewInlineFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
84 // nsISupports overrides
85 NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr);
87 // nsIFrame overrides
88 NS_IMETHOD BuildDisplayList(nsDisplayListBuilder* aBuilder,
89 const nsRect& aDirtyRect,
90 const nsDisplayListSet& aLists);
92 #ifdef ACCESSIBILITY
93 NS_IMETHODIMP GetAccessible(nsIAccessible** aAccessible);
94 #endif
96 #ifdef DEBUG
97 NS_IMETHOD GetFrameName(nsAString& aResult) const;
98 #endif
99 virtual nsIAtom* GetType() const;
101 virtual PRBool IsFrameOfType(PRUint32 aFlags) const
103 return nsInlineFrameSuper::IsFrameOfType(aFlags &
104 ~(nsIFrame::eBidiInlineContainer | nsIFrame::eLineParticipant));
107 virtual PRBool IsEmpty();
108 virtual PRBool IsSelfEmpty();
110 virtual PRBool PeekOffsetCharacter(PRBool aForward, PRInt32* aOffset);
112 // nsIHTMLReflow overrides
113 virtual void AddInlineMinWidth(nsIRenderingContext *aRenderingContext,
114 InlineMinWidthData *aData);
115 virtual void AddInlinePrefWidth(nsIRenderingContext *aRenderingContext,
116 InlinePrefWidthData *aData);
117 virtual nsSize ComputeSize(nsIRenderingContext *aRenderingContext,
118 nsSize aCBSize, nscoord aAvailableWidth,
119 nsSize aMargin, nsSize aBorder, nsSize aPadding,
120 PRBool aShrinkWrap);
121 virtual nsRect ComputeTightBounds(gfxContext* aContext) const;
122 NS_IMETHOD Reflow(nsPresContext* aPresContext,
123 nsHTMLReflowMetrics& aDesiredSize,
124 const nsHTMLReflowState& aReflowState,
125 nsReflowStatus& aStatus);
127 virtual PRBool CanContinueTextRun() const;
129 // Take all of the frames away from this frame. The caller is
130 // presumed to keep them alive.
131 void StealAllFrames() {
132 mFrames.SetFrames(nsnull);
136 * Return true if the frame is leftmost frame or continuation.
138 PRBool IsLeftMost() const {
139 // If the frame's bidi visual state is set, return is-leftmost state
140 // else return true if it's the first continuation.
141 return (GetStateBits() & NS_INLINE_FRAME_BIDI_VISUAL_STATE_IS_SET)
142 ? !!(GetStateBits() & NS_INLINE_FRAME_BIDI_VISUAL_IS_LEFT_MOST)
143 : (!GetPrevInFlow());
147 * Return true if the frame is rightmost frame or continuation.
149 PRBool IsRightMost() const {
150 // If the frame's bidi visual state is set, return is-rightmost state
151 // else return true if it's the last continuation.
152 return (GetStateBits() & NS_INLINE_FRAME_BIDI_VISUAL_STATE_IS_SET)
153 ? !!(GetStateBits() & NS_INLINE_FRAME_BIDI_VISUAL_IS_RIGHT_MOST)
154 : (!GetNextInFlow());
157 protected:
158 // Additional reflow state used during our reflow methods
159 struct InlineReflowState {
160 nsIFrame* mPrevFrame;
161 nsInlineFrame* mNextInFlow;
162 nsIFrame* mLineContainer;
163 PRPackedBool mSetParentPointer; // when reflowing child frame first set its
164 // parent frame pointer
166 InlineReflowState() {
167 mPrevFrame = nsnull;
168 mNextInFlow = nsnull;
169 mLineContainer = nsnull;
170 mSetParentPointer = PR_FALSE;
174 nsInlineFrame(nsStyleContext* aContext) : nsInlineFrameSuper(aContext) {}
176 virtual PRIntn GetSkipSides() const;
178 nsresult ReflowFrames(nsPresContext* aPresContext,
179 const nsHTMLReflowState& aReflowState,
180 InlineReflowState& rs,
181 nsHTMLReflowMetrics& aMetrics,
182 nsReflowStatus& aStatus);
184 nsresult ReflowInlineFrame(nsPresContext* aPresContext,
185 const nsHTMLReflowState& aReflowState,
186 InlineReflowState& rs,
187 nsIFrame* aFrame,
188 nsReflowStatus& aStatus);
191 * Reparent floats whose placeholders are inline descendants of aFrame from
192 * whatever block they're currently parented by to aOurBlock.
193 * @param aReparentSiblings if this is true, we follow aFrame's
194 * GetNextSibling chain reparenting them all
196 void ReparentFloatsForInlineChild(nsIFrame* aOurBlock, nsIFrame* aFrame,
197 PRBool aReparentSiblings);
199 virtual nsIFrame* PullOneFrame(nsPresContext* aPresContext,
200 InlineReflowState& rs,
201 PRBool* aIsComplete);
203 virtual void PushFrames(nsPresContext* aPresContext,
204 nsIFrame* aFromChild,
205 nsIFrame* aPrevSibling);
209 //----------------------------------------------------------------------
212 * Variation on inline-frame used to manage lines for line layout in
213 * special situations (:first-line style in particular).
215 class nsFirstLineFrame : public nsInlineFrame {
216 public:
217 friend nsIFrame* NS_NewFirstLineFrame(nsIPresShell* aPresShell, nsStyleContext* aContext);
219 #ifdef DEBUG
220 NS_IMETHOD GetFrameName(nsAString& aResult) const;
221 #endif
222 virtual nsIAtom* GetType() const;
223 NS_IMETHOD Reflow(nsPresContext* aPresContext,
224 nsHTMLReflowMetrics& aDesiredSize,
225 const nsHTMLReflowState& aReflowState,
226 nsReflowStatus& aStatus);
228 // Take frames starting at aFrame until the end of the frame-list
229 // away from this frame. The caller is presumed to keep them alive.
230 void StealFramesFrom(nsIFrame* aFrame);
232 protected:
233 nsFirstLineFrame(nsStyleContext* aContext) : nsInlineFrame(aContext) {}
235 virtual nsIFrame* PullOneFrame(nsPresContext* aPresContext,
236 InlineReflowState& rs,
237 PRBool* aIsComplete);
240 //----------------------------------------------------------------------
242 // Derived class created for relatively positioned inline-level elements
243 // that acts as a containing block for child absolutely positioned
244 // elements
246 class nsPositionedInlineFrame : public nsInlineFrame
248 public:
249 nsPositionedInlineFrame(nsStyleContext* aContext)
250 : nsInlineFrame(aContext)
251 , mAbsoluteContainer(nsGkAtoms::absoluteList)
254 virtual ~nsPositionedInlineFrame() { } // useful for debugging
256 virtual void Destroy();
258 NS_IMETHOD SetInitialChildList(nsIAtom* aListName,
259 nsIFrame* aChildList);
260 NS_IMETHOD AppendFrames(nsIAtom* aListName,
261 nsIFrame* aFrameList);
262 NS_IMETHOD InsertFrames(nsIAtom* aListName,
263 nsIFrame* aPrevFrame,
264 nsIFrame* aFrameList);
265 NS_IMETHOD RemoveFrame(nsIAtom* aListName,
266 nsIFrame* aOldFrame);
268 NS_IMETHOD BuildDisplayList(nsDisplayListBuilder* aBuilder,
269 const nsRect& aDirtyRect,
270 const nsDisplayListSet& aLists);
272 virtual nsIAtom* GetAdditionalChildListName(PRInt32 aIndex) const;
274 virtual nsIFrame* GetFirstChild(nsIAtom* aListName) const;
276 NS_IMETHOD Reflow(nsPresContext* aPresContext,
277 nsHTMLReflowMetrics& aDesiredSize,
278 const nsHTMLReflowState& aReflowState,
279 nsReflowStatus& aStatus);
281 virtual nsIAtom* GetType() const;
283 virtual PRBool NeedsView() { return PR_TRUE; }
285 protected:
286 nsAbsoluteContainingBlock mAbsoluteContainer;
289 #endif /* nsInlineFrame_h___ */