]>
git.saurik.com Git - iphone-api.git/blob - WebCore/RenderBoxModelObject.h
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * Copyright (C) 2003, 2006, 2007, 2009 Apple Inc. All rights reserved.
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public License
17 * along with this library; see the file COPYING.LIB. If not, write to
18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
23 #ifndef RenderBoxModelObject_h
24 #define RenderBoxModelObject_h
26 #include "RenderObject.h"
30 // Values for vertical alignment.
31 const int PositionTop
= -0x7fffffff;
32 const int PositionBottom
= 0x7fffffff;
33 const int PositionUndefined
= 0x80000000;
35 // This class is the base for all objects that adhere to the CSS box model as described
36 // at http://www.w3.org/TR/CSS21/box.html
38 class RenderBoxModelObject
: public RenderObject
{
40 RenderBoxModelObject(Node
*);
41 virtual ~RenderBoxModelObject();
43 virtual void destroy();
45 int relativePositionOffsetX() const;
46 int relativePositionOffsetY() const;
47 IntSize
relativePositionOffset() const { return IntSize(relativePositionOffsetX(), relativePositionOffsetY()); }
49 // IE extensions. Used to calculate offsetWidth/Height. Overridden by inlines (RenderFlow)
50 // to return the remaining width on a given line (and the height of a single line).
51 virtual int offsetLeft() const;
52 virtual int offsetTop() const;
53 virtual int offsetWidth() const = 0;
54 virtual int offsetHeight() const = 0;
56 virtual void styleWillChange(StyleDifference
, const RenderStyle
* newStyle
);
57 virtual void styleDidChange(StyleDifference
, const RenderStyle
* oldStyle
);
58 virtual void updateBoxModelInfoFromStyle();
60 bool hasSelfPaintingLayer() const;
61 RenderLayer
* layer() const { return m_layer
; }
62 virtual bool requiresLayer() const { return isRoot() || isPositioned() || isRelPositioned() || isTransparent() || hasOverflowClip() || hasTransform() || hasMask() || hasReflection(); }
64 // This will work on inlines to return the bounding box of all of the lines' border boxes.
65 virtual IntRect
borderBoundingBox() const = 0;
67 // Virtual since table cells override
68 virtual int paddingTop(bool includeIntrinsicPadding
= true) const;
69 virtual int paddingBottom(bool includeIntrinsicPadding
= true) const;
70 virtual int paddingLeft(bool includeIntrinsicPadding
= true) const;
71 virtual int paddingRight(bool includeIntrinsicPadding
= true) const;
73 virtual int borderTop() const { return style()->borderTopWidth(); }
74 virtual int borderBottom() const { return style()->borderBottomWidth(); }
75 virtual int borderLeft() const { return style()->borderLeftWidth(); }
76 virtual int borderRight() const { return style()->borderRightWidth(); }
78 virtual int marginTop() const = 0;
79 virtual int marginBottom() const = 0;
80 virtual int marginLeft() const = 0;
81 virtual int marginRight() const = 0;
83 bool hasHorizontalBordersPaddingOrMargin() const { return hasHorizontalBordersOrPadding() || marginLeft() != 0 || marginRight() != 0; }
84 bool hasHorizontalBordersOrPadding() const { return borderLeft() != 0 || borderRight() != 0 || paddingLeft() != 0 || paddingRight() != 0; }
86 virtual int containingBlockWidthForContent() const;
88 virtual void childBecameNonInline(RenderObject
* /*child*/) { }
90 void paintBorder(GraphicsContext
*, int tx
, int ty
, int w
, int h
, const RenderStyle
*, bool begin
= true, bool end
= true);
91 bool paintNinePieceImage(GraphicsContext
*, int tx
, int ty
, int w
, int h
, const RenderStyle
*, const NinePieceImage
&, CompositeOperator
= CompositeSourceOver
);
92 void paintBoxShadow(GraphicsContext
*, int tx
, int ty
, int w
, int h
, const RenderStyle
*, bool begin
= true, bool end
= true);
93 virtual void paintFillLayerExtended(const PaintInfo
&, const Color
&, const FillLayer
*, int clipY
, int clipHeight
,
94 int tx
, int ty
, int width
, int height
, InlineFlowBox
* = 0, CompositeOperator
= CompositeSourceOver
);
96 // The difference between this inline's baseline position and the line's baseline position.
97 int verticalPosition(bool firstLine
) const;
100 void calculateBackgroundImageGeometry(const FillLayer
*, int tx
, int ty
, int w
, int h
, IntRect
& destRect
, IntPoint
& phase
, IntSize
& tileSize
);
101 IntSize
calculateBackgroundSize(const FillLayer
*, int scaledWidth
, int scaledHeight
) const;
104 virtual bool isBoxModelObject() const { return true; }
105 friend class RenderView
;
107 RenderLayer
* m_layer
;
109 // Used to store state between styleWillChange and styleDidChange
110 static bool s_wasFloating
;
113 inline RenderBoxModelObject
* toRenderBoxModelObject(RenderObject
* o
)
115 ASSERT(!o
|| o
->isBoxModelObject());
116 return static_cast<RenderBoxModelObject
*>(o
);
119 inline const RenderBoxModelObject
* toRenderBoxModelObject(const RenderObject
* o
)
121 ASSERT(!o
|| o
->isBoxModelObject());
122 return static_cast<const RenderBoxModelObject
*>(o
);
125 // This will catch anyone doing an unnecessary cast.
126 void toRenderBoxModelObject(const RenderBox
*);
128 } // namespace WebCore
130 #endif // RenderBoxModelObject_h