Bug 449371 Firefox/Thunderbird crashes at exit [@ gdk_display_x11_finalize], p=Brian...
[wine-gecko.git] / layout / generic / nsHTMLContainerFrame.h
blobb084fdb80bdda3d1c4aaf1196247eb818e90e0c7
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.org 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 /* base class #2 for rendering objects that have child lists */
40 #ifndef nsHTMLContainerFrame_h___
41 #define nsHTMLContainerFrame_h___
43 #include "nsContainerFrame.h"
44 #include "gfxPoint.h"
45 class nsString;
46 class nsAbsoluteFrame;
47 class nsPlaceholderFrame;
48 struct nsStyleDisplay;
49 struct nsStylePosition;
50 struct nsHTMLReflowMetrics;
51 struct nsHTMLReflowState;
52 class nsLineBox;
54 // Some macros for container classes to do sanity checking on
55 // width/height/x/y values computed during reflow.
56 #ifdef DEBUG
57 #define CRAZY_W 500000
59 // 100000 lines, approximately. Assumes p2t is 15 and 15 pixels per line
60 #define CRAZY_H 22500000
62 #define CRAZY_WIDTH(_x) (((_x) < -CRAZY_W) || ((_x) > CRAZY_W))
63 #define CRAZY_HEIGHT(_y) (((_y) < -CRAZY_H) || ((_y) > CRAZY_H))
64 #endif
66 class nsDisplayTextDecoration;
68 // Base class for html container frames that provides common
69 // functionality.
70 class nsHTMLContainerFrame : public nsContainerFrame {
71 public:
73 /**
74 * Helper method to create next-in-flows if necessary. If aFrame
75 * already has a next-in-flow then this method does
76 * nothing. Otherwise, a new continuation frame is created and
77 * linked into the flow. In addition, the new frame becomes the
78 * next-sibling of aFrame. If aPlaceholderResult is not null and
79 * aFrame is a float or positioned, then *aPlaceholderResult holds
80 * a placeholder.
82 static nsresult CreateNextInFlow(nsPresContext* aPresContext,
83 nsIFrame* aOuterFrame,
84 nsIFrame* aFrame,
85 nsIFrame*& aNextInFlowResult);
87 /**
88 * Helper method to wrap views around frames. Used by containers
89 * under special circumstances (can be used by leaf frames as well)
90 * @param aContentParentFrame
91 * if non-null, this is the frame
92 * which would have held aFrame except that aFrame was reparented
93 * to an alternative geometric parent. This is necessary
94 * so that aFrame can remember to get its Z-order from
95 * aContentParentFrame.
97 static nsresult CreateViewForFrame(nsIFrame* aFrame,
98 nsIFrame* aContentParentFrame,
99 PRBool aForce);
101 static nsresult ReparentFrameView(nsPresContext* aPresContext,
102 nsIFrame* aChildFrame,
103 nsIFrame* aOldParentFrame,
104 nsIFrame* aNewParentFrame);
106 static nsresult ReparentFrameViewList(nsPresContext* aPresContext,
107 nsIFrame* aChildFrameList,
108 nsIFrame* aOldParentFrame,
109 nsIFrame* aNewParentFrame);
112 * Displays the standard border, background and outline for the frame
113 * and calls DisplayTextDecorationsAndChildren. This is suitable for
114 * inline frames or frames that behave like inlines.
116 NS_IMETHOD BuildDisplayList(nsDisplayListBuilder* aBuilder,
117 const nsRect& aDirtyRect,
118 const nsDisplayListSet& aLists);
120 nsresult DisplayTextDecorations(nsDisplayListBuilder* aBuilder,
121 nsDisplayList* aBelowTextDecorations,
122 nsDisplayList* aAboveTextDecorations,
123 nsLineBox* aLine);
125 protected:
126 nsHTMLContainerFrame(nsStyleContext *aContext) : nsContainerFrame(aContext) {}
129 * Displays the below-children decorations, then the children, then
130 * the above-children decorations, with the decorations going in the
131 * Content() list. This is suitable for inline elements and elements
132 * that behave like inline elements (e.g. MathML containers).
134 nsresult DisplayTextDecorationsAndChildren(nsDisplayListBuilder* aBuilder,
135 const nsRect& aDirtyRect,
136 const nsDisplayListSet& aLists);
139 * Fetch the text decorations for this frame.
140 * @param aIsBlock whether |this| is a block frame or no.
141 * @param aDecorations mask with all decorations.
142 * See bug 1777 and 20163 to understand how a
143 * frame can end up with several decorations.
144 * @param aUnderColor The color of underline if the appropriate bit
145 * in aDecoration is set. It is undefined otherwise.
146 * @param aOverColor The color of overline if the appropriate bit
147 * in aDecoration is set. It is undefined otherwise.
148 * @param aStrikeColor The color of strike-through if the appropriate bit
149 * in aDecoration is set. It is undefined otherwise.
150 * NOTE: This function assigns NS_STYLE_TEXT_DECORATION_NONE to
151 * aDecorations for text-less frames. See bug 20163 for
152 * details.
154 void GetTextDecorations(nsPresContext* aPresContext,
155 PRBool aIsBlock,
156 PRUint8& aDecorations,
157 nscolor& aUnderColor,
158 nscolor& aOverColor,
159 nscolor& aStrikeColor);
161 /**
162 * Function that does the actual drawing of the textdecoration.
163 * input:
164 * @param aCtx the Thebes graphics context to draw on
165 * @param aLine the line, or nsnull if this is an inline frame
166 * @param aColor the color of the text-decoration
167 * @param aAscent ascent of the font from which the
168 * text-decoration was derived.
169 * @param aOffset distance *above* baseline where the
170 * text-decoration should be drawn,
171 * i.e. negative offsets draws *below*
172 * the baseline.
173 * @param aSize the thickness of the line
174 * @param aDecoration which line will be painted
175 * i.e., NS_STYLE_TEXT_DECORATION_UNDERLINE or
176 * NS_STYLE_TEXT_DECORATION_OVERLINE or
177 * NS_STYLE_TEXT_DECORATION_LINE_THROUGH.
179 virtual void PaintTextDecorationLine(gfxContext* aCtx,
180 const nsPoint& aPt,
181 nsLineBox* aLine,
182 nscolor aColor,
183 gfxFloat aOffset,
184 gfxFloat aAscent,
185 gfxFloat aSize,
186 const PRUint8 aDecoration);
188 friend class nsDisplayTextDecoration;
189 friend class nsDisplayTextShadow;
192 #endif /* nsHTMLContainerFrame_h___ */