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"
45
class nsAbsoluteFrame;
46
class nsPlaceholderFrame;
47
struct nsStyleDisplay;
48
struct nsStylePosition;
49
struct nsHTMLReflowMetrics;
50
struct nsHTMLReflowState;
53
// Some macros for container classes to do sanity checking on
54
// width/height/x/y values computed during reflow.
56
#define CRAZY_W 500000
58
// 100000 lines, approximately. Assumes p2t is 15 and 15 pixels per line
59
#define CRAZY_H 22500000
61
#define CRAZY_WIDTH(_x) (((_x) < -CRAZY_W) || ((_x) > CRAZY_W))
62
#define CRAZY_HEIGHT(_y) (((_y) < -CRAZY_H) || ((_y) > CRAZY_H))
65
class nsDisplayTextDecoration;
67
// Base class for html container frames that provides common
69
class nsHTMLContainerFrame : public nsContainerFrame {
73
* Helper method to create next-in-flows if necessary. If aFrame
74
* already has a next-in-flow then this method does
75
* nothing. Otherwise, a new continuation frame is created and
76
* linked into the flow. In addition, the new frame becomes the
77
* next-sibling of aFrame. If aPlaceholderResult is not null and
78
* aFrame is a float or positioned, then *aPlaceholderResult holds
81
static nsresult CreateNextInFlow(nsPresContext* aPresContext,
82
nsIFrame* aOuterFrame,
84
nsIFrame*& aNextInFlowResult);
87
* Helper method to wrap views around frames. Used by containers
88
* under special circumstances (can be used by leaf frames as well)
89
* @param aContentParentFrame
90
* if non-null, this is the frame
91
* which would have held aFrame except that aFrame was reparented
92
* to an alternative geometric parent. This is necessary
93
* so that aFrame can remember to get its Z-order from
94
* aContentParentFrame.
96
static nsresult CreateViewForFrame(nsIFrame* aFrame,
97
nsIFrame* aContentParentFrame,
100
static nsresult ReparentFrameView(nsPresContext* aPresContext,
101
nsIFrame* aChildFrame,
102
nsIFrame* aOldParentFrame,
103
nsIFrame* aNewParentFrame);
105
static nsresult ReparentFrameViewList(nsPresContext* aPresContext,
106
nsIFrame* aChildFrameList,
107
nsIFrame* aOldParentFrame,
108
nsIFrame* aNewParentFrame);
111
* Displays the standard border, background and outline for the frame
112
* and calls DisplayTextDecorationsAndChildren. This is suitable for
113
* inline frames or frames that behave like inlines.
115
NS_IMETHOD BuildDisplayList(nsDisplayListBuilder* aBuilder,
116
const nsRect& aDirtyRect,
117
const nsDisplayListSet& aLists);
119
nsresult DisplayTextDecorations(nsDisplayListBuilder* aBuilder,
120
nsDisplayList* aBelowTextDecorations,
121
nsDisplayList* aAboveTextDecorations,
125
nsHTMLContainerFrame(nsStyleContext *aContext) : nsContainerFrame(aContext) {}
128
* Displays the below-children decorations, then the children, then
129
* the above-children decorations, with the decorations going in the
130
* Content() list. This is suitable for inline elements and elements
131
* that behave like inline elements (e.g. MathML containers).
133
nsresult DisplayTextDecorationsAndChildren(nsDisplayListBuilder* aBuilder,
134
const nsRect& aDirtyRect,
135
const nsDisplayListSet& aLists);
138
* Fetch the text decorations for this frame.
139
* @param aIsBlock whether |this| is a block frame or no.
140
* @param aDecorations mask with all decorations.
141
* See bug 1777 and 20163 to understand how a
142
* frame can end up with several decorations.
143
* @param aUnderColor The color of underline if the appropriate bit
144
* in aDecoration is set. It is undefined otherwise.
145
* @param aOverColor The color of overline if the appropriate bit
146
* in aDecoration is set. It is undefined otherwise.
147
* @param aStrikeColor The color of strike-through if the appropriate bit
148
* in aDecoration is set. It is undefined otherwise.
149
* NOTE: This function assigns NS_STYLE_TEXT_DECORATION_NONE to
150
* aDecorations for text-less frames. See bug 20163 for
153
void GetTextDecorations(nsPresContext* aPresContext,
155
PRUint8& aDecorations,
156
nscolor& aUnderColor,
158
nscolor& aStrikeColor);
161
* Function that does the actual drawing of the textdecoration.
163
* @param aRenderingContext
164
* @param aLine the line, or nsnull if this is an inline frame
165
* @param aColor the color of the text-decoration
166
* @param aAscent ascent of the font from which the
167
* text-decoration was derived.
168
* @param aOffset distance *above* baseline where the
169
* text-decoration should be drawn,
170
* i.e. negative offsets draws *below*
172
* @param aSize the thickness of the line
173
* @param aDecoration which line will be painted
174
* i.e., NS_STYLE_TEXT_DECORATION_UNDERLINE or
175
* NS_STYLE_TEXT_DECORATION_OVERLINE or
176
* NS_STYLE_TEXT_DECORATION_LINE_THROUGH.
178
virtual void PaintTextDecorationLine(nsIRenderingContext& aRenderingContext,
185
const PRUint8 aDecoration);
187
friend class nsDisplayTextDecoration;
190
#endif /* nsHTMLContainerFrame_h___ */