OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
4 * Copyright (C) 2003, 2006, 2007, 2009 Apple Inc. All rights reserved. | 4 * Copyright (C) 2003, 2006, 2007, 2009 Apple Inc. All rights reserved. |
5 * Copyright (C) 2010 Google Inc. All rights reserved. | 5 * Copyright (C) 2010 Google Inc. All rights reserved. |
6 * | 6 * |
7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
11 * | 11 * |
12 * This library is distributed in the hope that it will be useful, | 12 * This library is distributed in the hope that it will be useful, |
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 * Library General Public License for more details. | 15 * Library General Public License for more details. |
16 * | 16 * |
17 * You should have received a copy of the GNU Library General Public License | 17 * You should have received a copy of the GNU Library General Public License |
18 * along with this library; see the file COPYING.LIB. If not, write to | 18 * along with this library; see the file COPYING.LIB. If not, write to |
19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
20 * Boston, MA 02110-1301, USA. | 20 * Boston, MA 02110-1301, USA. |
21 * | 21 * |
22 */ | 22 */ |
23 | 23 |
24 #ifndef LayoutBoxModelObject_h | 24 #ifndef LayoutBoxModelObject_h |
25 #define LayoutBoxModelObject_h | 25 #define LayoutBoxModelObject_h |
26 | 26 |
27 #include "core/layout/LayoutLayerModelObject.h" | 27 #include "core/layout/LayoutObject.h" |
28 #include "core/layout/style/ShadowData.h" | 28 #include "core/layout/style/ShadowData.h" |
29 #include "platform/geometry/LayoutRect.h" | 29 #include "platform/geometry/LayoutRect.h" |
30 | 30 |
31 namespace blink { | 31 namespace blink { |
32 | 32 |
| 33 class Layer; |
| 34 class LayerScrollableArea; |
| 35 |
| 36 enum LayerType { |
| 37 NoLayer, |
| 38 NormalLayer, |
| 39 // A forced or overflow clip layer is required for bookkeeping purposes, |
| 40 // but does not force a layer to be self painting. |
| 41 OverflowClipLayer, |
| 42 ForcedLayer |
| 43 }; |
| 44 |
33 // Modes for some of the line-related functions. | 45 // Modes for some of the line-related functions. |
34 enum LinePositionMode { PositionOnContainingLine, PositionOfInteriorLineBoxes }; | 46 enum LinePositionMode { PositionOnContainingLine, PositionOfInteriorLineBoxes }; |
35 enum LineDirectionMode { HorizontalLine, VerticalLine }; | 47 enum LineDirectionMode { HorizontalLine, VerticalLine }; |
36 typedef unsigned BorderEdgeFlags; | 48 typedef unsigned BorderEdgeFlags; |
37 | 49 |
38 enum BackgroundBleedAvoidance { | 50 enum BackgroundBleedAvoidance { |
39 BackgroundBleedNone, | 51 BackgroundBleedNone, |
40 BackgroundBleedShrinkBackground, | 52 BackgroundBleedShrinkBackground, |
41 BackgroundBleedClipBackground, | 53 BackgroundBleedClipBackground, |
42 BackgroundBleedBackgroundOverBorder, | 54 BackgroundBleedBackgroundOverBorder, |
43 }; | 55 }; |
44 | 56 |
45 enum ContentChangeType { | 57 enum ContentChangeType { |
46 ImageChanged, | 58 ImageChanged, |
47 CanvasChanged, | 59 CanvasChanged, |
48 CanvasContextChanged | 60 CanvasContextChanged |
49 }; | 61 }; |
50 | 62 |
51 class InlineFlowBox; | 63 class InlineFlowBox; |
52 | 64 |
53 // This class is the base for all objects that adhere to the CSS box model as de
scribed | 65 // This class is the base for all objects that adhere to the CSS box model as de
scribed |
54 // at http://www.w3.org/TR/CSS21/box.html | 66 // at http://www.w3.org/TR/CSS21/box.html |
55 | 67 |
56 class LayoutBoxModelObject : public LayoutLayerModelObject { | 68 class LayoutBoxModelObject : public LayoutObject { |
57 public: | 69 public: |
58 LayoutBoxModelObject(ContainerNode*); | 70 LayoutBoxModelObject(ContainerNode*); |
59 virtual ~LayoutBoxModelObject(); | 71 virtual ~LayoutBoxModelObject(); |
60 | 72 |
| 73 // This is the only way layers should ever be destroyed. |
| 74 void destroyLayer(); |
| 75 |
61 LayoutSize relativePositionOffset() const; | 76 LayoutSize relativePositionOffset() const; |
62 LayoutSize relativePositionLogicalOffset() const { return style()->isHorizon
talWritingMode() ? relativePositionOffset() : relativePositionOffset().transpose
dSize(); } | 77 LayoutSize relativePositionLogicalOffset() const { return style()->isHorizon
talWritingMode() ? relativePositionOffset() : relativePositionOffset().transpose
dSize(); } |
63 | 78 |
64 LayoutSize offsetForInFlowPosition() const; | 79 LayoutSize offsetForInFlowPosition() const; |
65 | 80 |
66 // IE extensions. Used to calculate offsetWidth/Height. Overridden by inlin
es (RenderFlow) | 81 // IE extensions. Used to calculate offsetWidth/Height. Overridden by inlin
es (RenderFlow) |
67 // to return the remaining width on a given line (and the height of a single
line). | 82 // to return the remaining width on a given line (and the height of a single
line). |
68 virtual LayoutUnit offsetLeft() const; | 83 virtual LayoutUnit offsetLeft() const; |
69 virtual LayoutUnit offsetTop() const; | 84 virtual LayoutUnit offsetTop() const; |
70 virtual LayoutUnit offsetWidth() const = 0; | 85 virtual LayoutUnit offsetWidth() const = 0; |
71 virtual LayoutUnit offsetHeight() const = 0; | 86 virtual LayoutUnit offsetHeight() const = 0; |
72 | 87 |
73 int pixelSnappedOffsetLeft() const { return roundToInt(offsetLeft()); } | 88 int pixelSnappedOffsetLeft() const { return roundToInt(offsetLeft()); } |
74 int pixelSnappedOffsetTop() const { return roundToInt(offsetTop()); } | 89 int pixelSnappedOffsetTop() const { return roundToInt(offsetTop()); } |
75 virtual int pixelSnappedOffsetWidth() const; | 90 virtual int pixelSnappedOffsetWidth() const; |
76 virtual int pixelSnappedOffsetHeight() const; | 91 virtual int pixelSnappedOffsetHeight() const; |
77 | 92 |
78 virtual void updateFromStyle() override; | 93 bool hasSelfPaintingLayer() const; |
| 94 Layer* layer() const { return m_layer.get(); } |
| 95 LayerScrollableArea* scrollableArea() const; |
| 96 |
| 97 virtual void updateFromStyle(); |
| 98 |
| 99 virtual LayerType layerTypeRequired() const = 0; |
79 | 100 |
80 // This will work on inlines to return the bounding box of all of the lines'
border boxes. | 101 // This will work on inlines to return the bounding box of all of the lines'
border boxes. |
81 virtual IntRect borderBoundingBox() const = 0; | 102 virtual IntRect borderBoundingBox() const = 0; |
82 | 103 |
83 // These return the CSS computed padding values. | 104 // These return the CSS computed padding values. |
84 LayoutUnit computedCSSPaddingTop() const { return computedCSSPadding(style()
->paddingTop()); } | 105 LayoutUnit computedCSSPaddingTop() const { return computedCSSPadding(style()
->paddingTop()); } |
85 LayoutUnit computedCSSPaddingBottom() const { return computedCSSPadding(styl
e()->paddingBottom()); } | 106 LayoutUnit computedCSSPaddingBottom() const { return computedCSSPadding(styl
e()->paddingBottom()); } |
86 LayoutUnit computedCSSPaddingLeft() const { return computedCSSPadding(style(
)->paddingLeft()); } | 107 LayoutUnit computedCSSPaddingLeft() const { return computedCSSPadding(style(
)->paddingLeft()); } |
87 LayoutUnit computedCSSPaddingRight() const { return computedCSSPadding(style
()->paddingRight()); } | 108 LayoutUnit computedCSSPaddingRight() const { return computedCSSPadding(style
()->paddingRight()); } |
88 LayoutUnit computedCSSPaddingBefore() const { return computedCSSPadding(styl
e()->paddingBefore()); } | 109 LayoutUnit computedCSSPaddingBefore() const { return computedCSSPadding(styl
e()->paddingBefore()); } |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 | 173 |
153 virtual void childBecameNonInline(LayoutObject* /*child*/) { } | 174 virtual void childBecameNonInline(LayoutObject* /*child*/) { } |
154 | 175 |
155 virtual bool boxShadowShouldBeAppliedToBackground(BackgroundBleedAvoidance,
InlineFlowBox* = 0) const; | 176 virtual bool boxShadowShouldBeAppliedToBackground(BackgroundBleedAvoidance,
InlineFlowBox* = 0) const; |
156 | 177 |
157 // Overridden by subclasses to determine line height and baseline position. | 178 // Overridden by subclasses to determine line height and baseline position. |
158 virtual LayoutUnit lineHeight(bool firstLine, LineDirectionMode, LinePositio
nMode = PositionOnContainingLine) const = 0; | 179 virtual LayoutUnit lineHeight(bool firstLine, LineDirectionMode, LinePositio
nMode = PositionOnContainingLine) const = 0; |
159 virtual int baselinePosition(FontBaseline, bool firstLine, LineDirectionMode
, LinePositionMode = PositionOnContainingLine) const = 0; | 180 virtual int baselinePosition(FontBaseline, bool firstLine, LineDirectionMode
, LinePositionMode = PositionOnContainingLine) const = 0; |
160 | 181 |
161 virtual void mapAbsoluteToLocalPoint(MapCoordinatesFlags, TransformState&) c
onst override; | 182 virtual void mapAbsoluteToLocalPoint(MapCoordinatesFlags, TransformState&) c
onst override; |
162 virtual const LayoutObject* pushMappingToContainer(const LayoutLayerModelObj
ect* ancestorToStopAt, LayoutGeometryMap&) const override; | 183 virtual const LayoutObject* pushMappingToContainer(const LayoutBoxModelObjec
t* ancestorToStopAt, LayoutGeometryMap&) const override; |
163 | 184 |
164 virtual void setSelectionState(SelectionState) override; | 185 virtual void setSelectionState(SelectionState) override; |
165 | 186 |
166 void contentChanged(ContentChangeType); | 187 void contentChanged(ContentChangeType); |
167 bool hasAcceleratedCompositing() const; | 188 bool hasAcceleratedCompositing() const; |
168 | 189 |
169 virtual void computeLayerHitTestRects(LayerHitTestRects&) const override; | 190 virtual void computeLayerHitTestRects(LayerHitTestRects&) const override; |
170 | 191 |
| 192 // Returns true if the background is painted opaque in the given rect. |
| 193 // The query rect is given in local coordinate system. |
| 194 virtual bool backgroundIsKnownToBeOpaqueInRect(const LayoutRect&) const { re
turn false; } |
| 195 |
| 196 virtual void invalidateTreeIfNeeded(const PaintInvalidationState&) override; |
| 197 |
| 198 // Indicate that the contents of this renderer need to be repainted. Only ha
s an effect if compositing is being used, |
| 199 void setBackingNeedsPaintInvalidationInRect(const LayoutRect&, PaintInvalida
tionReason) const; // r is in the coordinate space of this render object |
| 200 |
171 protected: | 201 protected: |
172 virtual void willBeDestroyed() override; | 202 virtual void willBeDestroyed() override; |
173 | 203 |
174 LayoutPoint adjustedPositionRelativeToOffsetParent(const LayoutPoint&) const
; | 204 LayoutPoint adjustedPositionRelativeToOffsetParent(const LayoutPoint&) const
; |
175 | 205 |
176 bool calculateHasBoxDecorations() const; | 206 bool calculateHasBoxDecorations() const; |
177 | 207 |
178 LayoutBoxModelObject* continuation() const; | 208 LayoutBoxModelObject* continuation() const; |
179 void setContinuation(LayoutBoxModelObject*); | 209 void setContinuation(LayoutBoxModelObject*); |
180 | 210 |
181 LayoutRect localCaretRectForEmptyElement(LayoutUnit width, LayoutUnit textIn
dentOffset); | 211 LayoutRect localCaretRectForEmptyElement(LayoutUnit width, LayoutUnit textIn
dentOffset); |
182 | 212 |
183 bool hasAutoHeightOrContainingBlockWithAutoHeight() const; | 213 bool hasAutoHeightOrContainingBlockWithAutoHeight() const; |
184 RenderBlock* containingBlockForAutoHeightDetection(Length logicalHeight) con
st; | 214 RenderBlock* containingBlockForAutoHeightDetection(Length logicalHeight) con
st; |
185 | 215 |
| 216 void addChildFocusRingRects(Vector<LayoutRect>&, const LayoutPoint& addition
alOffset) const; |
| 217 |
| 218 virtual void addLayerHitTestRects(LayerHitTestRects&, const Layer*, const La
youtPoint&, const LayoutRect&) const override; |
| 219 |
| 220 void styleWillChange(StyleDifference, const LayoutStyle& newStyle) override; |
| 221 void styleDidChange(StyleDifference, const LayoutStyle* oldStyle) override; |
| 222 |
186 public: | 223 public: |
187 // These functions are only used internally to manipulate the render tree st
ructure via remove/insert/appendChildNode. | 224 // These functions are only used internally to manipulate the render tree st
ructure via remove/insert/appendChildNode. |
188 // Since they are typically called only to move objects around within anonym
ous blocks (which only have layers in | 225 // Since they are typically called only to move objects around within anonym
ous blocks (which only have layers in |
189 // the case of column spans), the default for fullRemoveInsert is false rath
er than true. | 226 // the case of column spans), the default for fullRemoveInsert is false rath
er than true. |
190 void moveChildTo(LayoutBoxModelObject* toBoxModelObject, LayoutObject* child
, LayoutObject* beforeChild, bool fullRemoveInsert = false); | 227 void moveChildTo(LayoutBoxModelObject* toBoxModelObject, LayoutObject* child
, LayoutObject* beforeChild, bool fullRemoveInsert = false); |
191 void moveChildTo(LayoutBoxModelObject* toBoxModelObject, LayoutObject* child
, bool fullRemoveInsert = false) | 228 void moveChildTo(LayoutBoxModelObject* toBoxModelObject, LayoutObject* child
, bool fullRemoveInsert = false) |
192 { | 229 { |
193 moveChildTo(toBoxModelObject, child, 0, fullRemoveInsert); | 230 moveChildTo(toBoxModelObject, child, 0, fullRemoveInsert); |
194 } | 231 } |
195 void moveAllChildrenTo(LayoutBoxModelObject* toBoxModelObject, bool fullRemo
veInsert = false) | 232 void moveAllChildrenTo(LayoutBoxModelObject* toBoxModelObject, bool fullRemo
veInsert = false) |
196 { | 233 { |
197 moveAllChildrenTo(toBoxModelObject, 0, fullRemoveInsert); | 234 moveAllChildrenTo(toBoxModelObject, 0, fullRemoveInsert); |
198 } | 235 } |
199 void moveAllChildrenTo(LayoutBoxModelObject* toBoxModelObject, LayoutObject*
beforeChild, bool fullRemoveInsert = false) | 236 void moveAllChildrenTo(LayoutBoxModelObject* toBoxModelObject, LayoutObject*
beforeChild, bool fullRemoveInsert = false) |
200 { | 237 { |
201 moveChildrenTo(toBoxModelObject, slowFirstChild(), 0, beforeChild, fullR
emoveInsert); | 238 moveChildrenTo(toBoxModelObject, slowFirstChild(), 0, beforeChild, fullR
emoveInsert); |
202 } | 239 } |
203 // Move all of the kids from |startChild| up to but excluding |endChild|. 0
can be passed as the |endChild| to denote | 240 // Move all of the kids from |startChild| up to but excluding |endChild|. 0
can be passed as the |endChild| to denote |
204 // that all the kids from |startChild| onwards should be moved. | 241 // that all the kids from |startChild| onwards should be moved. |
205 void moveChildrenTo(LayoutBoxModelObject* toBoxModelObject, LayoutObject* st
artChild, LayoutObject* endChild, bool fullRemoveInsert = false) | 242 void moveChildrenTo(LayoutBoxModelObject* toBoxModelObject, LayoutObject* st
artChild, LayoutObject* endChild, bool fullRemoveInsert = false) |
206 { | 243 { |
207 moveChildrenTo(toBoxModelObject, startChild, endChild, 0, fullRemoveInse
rt); | 244 moveChildrenTo(toBoxModelObject, startChild, endChild, 0, fullRemoveInse
rt); |
208 } | 245 } |
209 virtual void moveChildrenTo(LayoutBoxModelObject* toBoxModelObject, LayoutOb
ject* startChild, LayoutObject* endChild, LayoutObject* beforeChild, bool fullRe
moveInsert = false); | 246 virtual void moveChildrenTo(LayoutBoxModelObject* toBoxModelObject, LayoutOb
ject* startChild, LayoutObject* endChild, LayoutObject* beforeChild, bool fullRe
moveInsert = false); |
210 | 247 |
211 enum ScaleByEffectiveZoomOrNot { ScaleByEffectiveZoom, DoNotScaleByEffective
Zoom }; | 248 enum ScaleByEffectiveZoomOrNot { ScaleByEffectiveZoom, DoNotScaleByEffective
Zoom }; |
212 IntSize calculateImageIntrinsicDimensions(StyleImage*, const IntSize& scaled
PositioningAreaSize, ScaleByEffectiveZoomOrNot) const; | 249 IntSize calculateImageIntrinsicDimensions(StyleImage*, const IntSize& scaled
PositioningAreaSize, ScaleByEffectiveZoomOrNot) const; |
213 | 250 |
214 private: | 251 private: |
| 252 void createLayer(LayerType); |
| 253 |
215 LayoutUnit computedCSSPadding(const Length&) const; | 254 LayoutUnit computedCSSPadding(const Length&) const; |
216 virtual bool isBoxModelObject() const override final { return true; } | 255 virtual bool isBoxModelObject() const override final { return true; } |
| 256 |
| 257 virtual bool isLayoutBoxModelObject() const override final { return true; } |
| 258 |
| 259 OwnPtr<Layer> m_layer; |
| 260 |
| 261 // Used to store state between styleWillChange and styleDidChange |
| 262 static bool s_wasFloating; |
217 }; | 263 }; |
218 | 264 |
219 DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutBoxModelObject, isBoxModelObject()); | 265 DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutBoxModelObject, isBoxModelObject()); |
220 | 266 |
221 } // namespace blink | 267 } // namespace blink |
222 | 268 |
223 #endif // LayoutBoxModelObject_h | 269 #endif // LayoutBoxModelObject_h |
OLD | NEW |