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
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.
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"
46 class nsAbsoluteFrame
;
47 class nsPlaceholderFrame
;
48 struct nsStyleDisplay
;
49 struct nsStylePosition
;
50 struct nsHTMLReflowMetrics
;
51 struct nsHTMLReflowState
;
54 // Some macros for container classes to do sanity checking on
55 // width/height/x/y values computed during reflow.
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))
66 class nsDisplayTextDecoration
;
68 // Base class for html container frames that provides common
70 class nsHTMLContainerFrame
: public nsContainerFrame
{
72 NS_DECL_FRAMEARENA_HELPERS
75 * Helper method to wrap views around frames. Used by containers
76 * under special circumstances (can be used by leaf frames as well)
78 static nsresult
CreateViewForFrame(nsIFrame
* aFrame
,
81 static nsresult
ReparentFrameView(nsPresContext
* aPresContext
,
82 nsIFrame
* aChildFrame
,
83 nsIFrame
* aOldParentFrame
,
84 nsIFrame
* aNewParentFrame
);
86 static nsresult
ReparentFrameViewList(nsPresContext
* aPresContext
,
87 const nsFrameList
& aChildFrameList
,
88 nsIFrame
* aOldParentFrame
,
89 nsIFrame
* aNewParentFrame
);
92 * Helper method to create next-in-flows if necessary. If aFrame
93 * already has a next-in-flow then this method does
94 * nothing. Otherwise, a new continuation frame is created and
95 * linked into the flow. In addition, the new frame is inserted
96 * into the principal child list after aFrame.
97 * @note calling this method on a block frame is illegal. Use
98 * nsBlockFrame::CreateContinuationFor() instead.
99 * @param aNextInFlowResult will contain the next-in-flow
100 * <b>if and only if</b> one is created. If a next-in-flow already
101 * exists aNextInFlowResult is set to nsnull.
102 * @return NS_OK if a next-in-flow already exists or is successfully created.
104 nsresult
CreateNextInFlow(nsPresContext
* aPresContext
,
106 nsIFrame
*& aNextInFlowResult
);
109 * Displays the standard border, background and outline for the frame
110 * and calls DisplayTextDecorationsAndChildren. This is suitable for
111 * inline frames or frames that behave like inlines.
113 NS_IMETHOD
BuildDisplayList(nsDisplayListBuilder
* aBuilder
,
114 const nsRect
& aDirtyRect
,
115 const nsDisplayListSet
& aLists
);
117 nsresult
DisplayTextDecorations(nsDisplayListBuilder
* aBuilder
,
118 nsDisplayList
* aBelowTextDecorations
,
119 nsDisplayList
* aAboveTextDecorations
,
123 nsHTMLContainerFrame(nsStyleContext
*aContext
) : nsContainerFrame(aContext
) {}
126 * Displays the below-children decorations, then the children, then
127 * the above-children decorations, with the decorations going in the
128 * Content() list. This is suitable for inline elements and elements
129 * that behave like inline elements (e.g. MathML containers).
131 nsresult
DisplayTextDecorationsAndChildren(nsDisplayListBuilder
* aBuilder
,
132 const nsRect
& aDirtyRect
,
133 const nsDisplayListSet
& aLists
);
136 * Fetch the text decorations for this frame.
137 * @param aIsBlock whether |this| is a block frame or no.
138 * @param aDecorations mask with all decorations.
139 * See bug 1777 and 20163 to understand how a
140 * frame can end up with several decorations.
141 * @param aUnderColor The color of underline if the appropriate bit
142 * in aDecoration is set. It is undefined otherwise.
143 * @param aOverColor The color of overline if the appropriate bit
144 * in aDecoration is set. It is undefined otherwise.
145 * @param aStrikeColor The color of strike-through if the appropriate bit
146 * in aDecoration is set. It is undefined otherwise.
147 * NOTE: This function assigns NS_STYLE_TEXT_DECORATION_NONE to
148 * aDecorations for text-less frames. See bug 20163 for
151 void GetTextDecorations(nsPresContext
* aPresContext
,
153 PRUint8
& aDecorations
,
154 nscolor
& aUnderColor
,
156 nscolor
& aStrikeColor
);
159 * Function that does the actual drawing of the textdecoration.
161 * @param aCtx the Thebes graphics context to draw on
162 * @param aLine the line, or nsnull if this is an inline frame
163 * @param aColor the color of the text-decoration
164 * @param aAscent ascent of the font from which the
165 * text-decoration was derived.
166 * @param aOffset distance *above* baseline where the
167 * text-decoration should be drawn,
168 * i.e. negative offsets draws *below*
170 * @param aSize the thickness of the line
171 * @param aDecoration which line will be painted
172 * i.e., NS_STYLE_TEXT_DECORATION_UNDERLINE or
173 * NS_STYLE_TEXT_DECORATION_OVERLINE or
174 * NS_STYLE_TEXT_DECORATION_LINE_THROUGH.
176 virtual void PaintTextDecorationLine(gfxContext
* aCtx
,
183 const PRUint8 aDecoration
);
185 virtual void AdjustForTextIndent(const nsLineBox
* aLine
,
189 friend class nsDisplayTextDecoration
;
190 friend class nsDisplayTextShadow
;
193 #endif /* nsHTMLContainerFrame_h___ */