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 * (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com) | 4 * (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com) |
5 * (C) 2005, 2006 Samuel Weinig (sam.weinig@gmail.com) | 5 * (C) 2005, 2006 Samuel Weinig (sam.weinig@gmail.com) |
6 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserv
ed. | 6 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserv
ed. |
7 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. | 7 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. |
8 * | 8 * |
9 * This library is free software; you can redistribute it and/or | 9 * This library is free software; you can redistribute it and/or |
10 * modify it under the terms of the GNU Library General Public | 10 * modify it under the terms of the GNU Library General Public |
11 * License as published by the Free Software Foundation; either | 11 * License as published by the Free Software Foundation; either |
12 * version 2 of the License, or (at your option) any later version. | 12 * version 2 of the License, or (at your option) any later version. |
13 * | 13 * |
14 * This library is distributed in the hope that it will be useful, | 14 * This library is distributed in the hope that it will be useful, |
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
17 * Library General Public License for more details. | 17 * Library General Public License for more details. |
18 * | 18 * |
19 * You should have received a copy of the GNU Library General Public License | 19 * You should have received a copy of the GNU Library General Public License |
20 * along with this library; see the file COPYING.LIB. If not, write to | 20 * along with this library; see the file COPYING.LIB. If not, write to |
21 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 21 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
22 * Boston, MA 02110-1301, USA. | 22 * Boston, MA 02110-1301, USA. |
23 * | 23 * |
24 */ | 24 */ |
25 | 25 |
26 #include "config.h" | 26 #include "config.h" |
27 #include "core/rendering/RenderBox.h" | 27 #include "core/layout/LayoutBox.h" |
28 | 28 |
29 #include "core/HTMLNames.h" | 29 #include "core/HTMLNames.h" |
30 #include "core/dom/Document.h" | 30 #include "core/dom/Document.h" |
31 #include "core/editing/htmlediting.h" | 31 #include "core/editing/htmlediting.h" |
32 #include "core/frame/FrameHost.h" | 32 #include "core/frame/FrameHost.h" |
33 #include "core/frame/FrameView.h" | 33 #include "core/frame/FrameView.h" |
34 #include "core/frame/LocalFrame.h" | 34 #include "core/frame/LocalFrame.h" |
35 #include "core/frame/PinchViewport.h" | 35 #include "core/frame/PinchViewport.h" |
36 #include "core/frame/Settings.h" | 36 #include "core/frame/Settings.h" |
37 #include "core/html/HTMLElement.h" | 37 #include "core/html/HTMLElement.h" |
(...skipping 26 matching lines...) Expand all Loading... |
64 #include "platform/geometry/TransformState.h" | 64 #include "platform/geometry/TransformState.h" |
65 #include "platform/graphics/paint/DisplayItemList.h" | 65 #include "platform/graphics/paint/DisplayItemList.h" |
66 #include <algorithm> | 66 #include <algorithm> |
67 #include <math.h> | 67 #include <math.h> |
68 | 68 |
69 namespace blink { | 69 namespace blink { |
70 | 70 |
71 using namespace HTMLNames; | 71 using namespace HTMLNames; |
72 | 72 |
73 // Used by flexible boxes when flexing this element and by table cells. | 73 // Used by flexible boxes when flexing this element and by table cells. |
74 typedef WTF::HashMap<const RenderBox*, LayoutUnit> OverrideSizeMap; | 74 typedef WTF::HashMap<const LayoutBox*, LayoutUnit> OverrideSizeMap; |
75 | 75 |
76 // Used by grid elements to properly size their grid items. | 76 // Used by grid elements to properly size their grid items. |
77 // FIXME: Move these into RenderBoxRareData. | 77 // FIXME: Move these into LayoutBoxRareData. |
78 static OverrideSizeMap* gOverrideContainingBlockLogicalHeightMap = 0; | 78 static OverrideSizeMap* gOverrideContainingBlockLogicalHeightMap = 0; |
79 static OverrideSizeMap* gOverrideContainingBlockLogicalWidthMap = 0; | 79 static OverrideSizeMap* gOverrideContainingBlockLogicalWidthMap = 0; |
80 static OverrideSizeMap* gExtraInlineOffsetMap = 0; | 80 static OverrideSizeMap* gExtraInlineOffsetMap = 0; |
81 static OverrideSizeMap* gExtraBlockOffsetMap = 0; | 81 static OverrideSizeMap* gExtraBlockOffsetMap = 0; |
82 | 82 |
83 | 83 |
84 // Size of border belt for autoscroll. When mouse pointer in border belt, | 84 // Size of border belt for autoscroll. When mouse pointer in border belt, |
85 // autoscroll is started. | 85 // autoscroll is started. |
86 static const int autoscrollBeltSize = 20; | 86 static const int autoscrollBeltSize = 20; |
87 static const unsigned backgroundObscurationTestMaxDepth = 4; | 87 static const unsigned backgroundObscurationTestMaxDepth = 4; |
88 | 88 |
89 static bool skipBodyBackground(const RenderBox* bodyElementRenderer) | 89 static bool skipBodyBackground(const LayoutBox* bodyElementRenderer) |
90 { | 90 { |
91 ASSERT(bodyElementRenderer->isBody()); | 91 ASSERT(bodyElementRenderer->isBody()); |
92 // The <body> only paints its background if the root element has defined a b
ackground independent of the body, | 92 // The <body> only paints its background if the root element has defined a b
ackground independent of the body, |
93 // or if the <body>'s parent is not the document element's renderer (e.g. in
side SVG foreignObject). | 93 // or if the <body>'s parent is not the document element's renderer (e.g. in
side SVG foreignObject). |
94 LayoutObject* documentElementRenderer = bodyElementRenderer->document().docu
mentElement()->renderer(); | 94 LayoutObject* documentElementRenderer = bodyElementRenderer->document().docu
mentElement()->renderer(); |
95 return documentElementRenderer | 95 return documentElementRenderer |
96 && !documentElementRenderer->hasBackground() | 96 && !documentElementRenderer->hasBackground() |
97 && (documentElementRenderer == bodyElementRenderer->parent()); | 97 && (documentElementRenderer == bodyElementRenderer->parent()); |
98 } | 98 } |
99 | 99 |
100 RenderBox::RenderBox(ContainerNode* node) | 100 LayoutBox::LayoutBox(ContainerNode* node) |
101 : LayoutBoxModelObject(node) | 101 : LayoutBoxModelObject(node) |
102 , m_intrinsicContentLogicalHeight(-1) | 102 , m_intrinsicContentLogicalHeight(-1) |
103 , m_minPreferredLogicalWidth(-1) | 103 , m_minPreferredLogicalWidth(-1) |
104 , m_maxPreferredLogicalWidth(-1) | 104 , m_maxPreferredLogicalWidth(-1) |
105 { | 105 { |
106 setIsBox(); | 106 setIsBox(); |
107 } | 107 } |
108 | 108 |
109 LayerType RenderBox::layerTypeRequired() const | 109 LayerType LayoutBox::layerTypeRequired() const |
110 { | 110 { |
111 // hasAutoZIndex only returns true if the element is positioned or a flex-it
em since | 111 // hasAutoZIndex only returns true if the element is positioned or a flex-it
em since |
112 // position:static elements that are not flex-items get their z-index coerce
d to auto. | 112 // position:static elements that are not flex-items get their z-index coerce
d to auto. |
113 if (isPositioned() || createsGroup() || hasClipPath() || hasTransformRelated
Property() | 113 if (isPositioned() || createsGroup() || hasClipPath() || hasTransformRelated
Property() |
114 || hasHiddenBackface() || hasReflection() || style()->specifiesColumns() | 114 || hasHiddenBackface() || hasReflection() || style()->specifiesColumns() |
115 || !style()->hasAutoZIndex() || style()->shouldCompositeForCurrentAnimat
ions()) | 115 || !style()->hasAutoZIndex() || style()->shouldCompositeForCurrentAnimat
ions()) |
116 return NormalLayer; | 116 return NormalLayer; |
117 | 117 |
118 // Ensure that explicit use of scroll-blocks-on creates a Layer (since we mi
ght need | 118 // Ensure that explicit use of scroll-blocks-on creates a Layer (since we mi
ght need |
119 // it to be composited). | 119 // it to be composited). |
120 if (style()->hasScrollBlocksOn()) { | 120 if (style()->hasScrollBlocksOn()) { |
121 if (isDocumentElement()) { | 121 if (isDocumentElement()) { |
122 ASSERT(style()->scrollBlocksOn() == view()->style()->scrollBlocksOn(
)); | 122 ASSERT(style()->scrollBlocksOn() == view()->style()->scrollBlocksOn(
)); |
123 return NoLayer; | 123 return NoLayer; |
124 } | 124 } |
125 return NormalLayer; | 125 return NormalLayer; |
126 } | 126 } |
127 if (hasOverflowClip()) | 127 if (hasOverflowClip()) |
128 return OverflowClipLayer; | 128 return OverflowClipLayer; |
129 | 129 |
130 return NoLayer; | 130 return NoLayer; |
131 } | 131 } |
132 | 132 |
133 void RenderBox::willBeDestroyed() | 133 void LayoutBox::willBeDestroyed() |
134 { | 134 { |
135 clearOverrideSize(); | 135 clearOverrideSize(); |
136 clearContainingBlockOverrideSize(); | 136 clearContainingBlockOverrideSize(); |
137 clearExtraInlineAndBlockOffests(); | 137 clearExtraInlineAndBlockOffests(); |
138 | 138 |
139 RenderBlock::removePercentHeightDescendantIfNeeded(this); | 139 RenderBlock::removePercentHeightDescendantIfNeeded(this); |
140 | 140 |
141 ShapeOutsideInfo::removeInfo(*this); | 141 ShapeOutsideInfo::removeInfo(*this); |
142 | 142 |
143 LayoutBoxModelObject::willBeDestroyed(); | 143 LayoutBoxModelObject::willBeDestroyed(); |
144 } | 144 } |
145 | 145 |
146 void RenderBox::removeFloatingOrPositionedChildFromBlockLists() | 146 void LayoutBox::removeFloatingOrPositionedChildFromBlockLists() |
147 { | 147 { |
148 ASSERT(isFloatingOrOutOfFlowPositioned()); | 148 ASSERT(isFloatingOrOutOfFlowPositioned()); |
149 | 149 |
150 if (documentBeingDestroyed()) | 150 if (documentBeingDestroyed()) |
151 return; | 151 return; |
152 | 152 |
153 if (isFloating()) { | 153 if (isFloating()) { |
154 RenderBlockFlow* parentBlockFlow = 0; | 154 RenderBlockFlow* parentBlockFlow = 0; |
155 for (LayoutObject* curr = parent(); curr && !curr->isRenderView(); curr
= curr->parent()) { | 155 for (LayoutObject* curr = parent(); curr && !curr->isRenderView(); curr
= curr->parent()) { |
156 if (curr->isRenderBlockFlow()) { | 156 if (curr->isRenderBlockFlow()) { |
157 RenderBlockFlow* currBlockFlow = toRenderBlockFlow(curr); | 157 RenderBlockFlow* currBlockFlow = toRenderBlockFlow(curr); |
158 if (!parentBlockFlow || currBlockFlow->containsFloat(this)) | 158 if (!parentBlockFlow || currBlockFlow->containsFloat(this)) |
159 parentBlockFlow = currBlockFlow; | 159 parentBlockFlow = currBlockFlow; |
160 } | 160 } |
161 } | 161 } |
162 | 162 |
163 if (parentBlockFlow) { | 163 if (parentBlockFlow) { |
164 parentBlockFlow->markSiblingsWithFloatsForLayout(this); | 164 parentBlockFlow->markSiblingsWithFloatsForLayout(this); |
165 parentBlockFlow->markAllDescendantsWithFloatsForLayout(this, false); | 165 parentBlockFlow->markAllDescendantsWithFloatsForLayout(this, false); |
166 } | 166 } |
167 } | 167 } |
168 | 168 |
169 if (isOutOfFlowPositioned()) | 169 if (isOutOfFlowPositioned()) |
170 RenderBlock::removePositionedObject(this); | 170 RenderBlock::removePositionedObject(this); |
171 } | 171 } |
172 | 172 |
173 void RenderBox::styleWillChange(StyleDifference diff, const LayoutStyle& newStyl
e) | 173 void LayoutBox::styleWillChange(StyleDifference diff, const LayoutStyle& newStyl
e) |
174 { | 174 { |
175 const LayoutStyle* oldStyle = style(); | 175 const LayoutStyle* oldStyle = style(); |
176 if (oldStyle) { | 176 if (oldStyle) { |
177 // The background of the root element or the body element could propagat
e up to | 177 // The background of the root element or the body element could propagat
e up to |
178 // the canvas. Just dirty the entire canvas when our style changes subst
antially. | 178 // the canvas. Just dirty the entire canvas when our style changes subst
antially. |
179 if ((diff.needsPaintInvalidation() || diff.needsLayout()) && node() | 179 if ((diff.needsPaintInvalidation() || diff.needsLayout()) && node() |
180 && (isHTMLHtmlElement(*node()) || isHTMLBodyElement(*node()))) { | 180 && (isHTMLHtmlElement(*node()) || isHTMLBodyElement(*node()))) { |
181 view()->setShouldDoFullPaintInvalidation(); | 181 view()->setShouldDoFullPaintInvalidation(); |
182 | 182 |
183 if (oldStyle->hasEntirelyFixedBackground() != newStyle.hasEntirelyFi
xedBackground()) | 183 if (oldStyle->hasEntirelyFixedBackground() != newStyle.hasEntirelyFi
xedBackground()) |
(...skipping 13 matching lines...) Expand all Loading... |
197 } | 197 } |
198 // FIXME: This branch runs when !oldStyle, which means that layout was never
called | 198 // FIXME: This branch runs when !oldStyle, which means that layout was never
called |
199 // so what's the point in invalidating the whole view that we never painted? | 199 // so what's the point in invalidating the whole view that we never painted? |
200 } else if (isBody()) { | 200 } else if (isBody()) { |
201 view()->setShouldDoFullPaintInvalidation(); | 201 view()->setShouldDoFullPaintInvalidation(); |
202 } | 202 } |
203 | 203 |
204 LayoutBoxModelObject::styleWillChange(diff, newStyle); | 204 LayoutBoxModelObject::styleWillChange(diff, newStyle); |
205 } | 205 } |
206 | 206 |
207 void RenderBox::styleDidChange(StyleDifference diff, const LayoutStyle* oldStyle
) | 207 void LayoutBox::styleDidChange(StyleDifference diff, const LayoutStyle* oldStyle
) |
208 { | 208 { |
209 // Horizontal writing mode definition is updated in LayoutBoxModelObject::up
dateFromStyle, | 209 // Horizontal writing mode definition is updated in LayoutBoxModelObject::up
dateFromStyle, |
210 // (as part of the LayoutBoxModelObject::styleDidChange call below). So, we
can safely cache the horizontal | 210 // (as part of the LayoutBoxModelObject::styleDidChange call below). So, we
can safely cache the horizontal |
211 // writing mode value before style change here. | 211 // writing mode value before style change here. |
212 bool oldHorizontalWritingMode = isHorizontalWritingMode(); | 212 bool oldHorizontalWritingMode = isHorizontalWritingMode(); |
213 | 213 |
214 LayoutBoxModelObject::styleDidChange(diff, oldStyle); | 214 LayoutBoxModelObject::styleDidChange(diff, oldStyle); |
215 | 215 |
216 const LayoutStyle& newStyle = styleRef(); | 216 const LayoutStyle& newStyle = styleRef(); |
217 if (needsLayout() && oldStyle) | 217 if (needsLayout() && oldStyle) |
(...skipping 29 matching lines...) Expand all Loading... |
247 document().view()->recalculateScrollbarOverlayStyle(); | 247 document().view()->recalculateScrollbarOverlayStyle(); |
248 document().view()->recalculateCustomScrollbarStyle(); | 248 document().view()->recalculateCustomScrollbarStyle(); |
249 } | 249 } |
250 updateShapeOutsideInfoAfterStyleChange(*style(), oldStyle); | 250 updateShapeOutsideInfoAfterStyleChange(*style(), oldStyle); |
251 updateGridPositionAfterStyleChange(oldStyle); | 251 updateGridPositionAfterStyleChange(oldStyle); |
252 | 252 |
253 if (LayoutMultiColumnSpannerPlaceholder* placeholder = this->spannerPlacehol
der()) | 253 if (LayoutMultiColumnSpannerPlaceholder* placeholder = this->spannerPlacehol
der()) |
254 placeholder->updateMarginProperties(); | 254 placeholder->updateMarginProperties(); |
255 } | 255 } |
256 | 256 |
257 void RenderBox::updateShapeOutsideInfoAfterStyleChange(const LayoutStyle& style,
const LayoutStyle* oldStyle) | 257 void LayoutBox::updateShapeOutsideInfoAfterStyleChange(const LayoutStyle& style,
const LayoutStyle* oldStyle) |
258 { | 258 { |
259 const ShapeValue* shapeOutside = style.shapeOutside(); | 259 const ShapeValue* shapeOutside = style.shapeOutside(); |
260 const ShapeValue* oldShapeOutside = oldStyle ? oldStyle->shapeOutside() : La
youtStyle::initialShapeOutside(); | 260 const ShapeValue* oldShapeOutside = oldStyle ? oldStyle->shapeOutside() : La
youtStyle::initialShapeOutside(); |
261 | 261 |
262 Length shapeMargin = style.shapeMargin(); | 262 Length shapeMargin = style.shapeMargin(); |
263 Length oldShapeMargin = oldStyle ? oldStyle->shapeMargin() : LayoutStyle::in
itialShapeMargin(); | 263 Length oldShapeMargin = oldStyle ? oldStyle->shapeMargin() : LayoutStyle::in
itialShapeMargin(); |
264 | 264 |
265 float shapeImageThreshold = style.shapeImageThreshold(); | 265 float shapeImageThreshold = style.shapeImageThreshold(); |
266 float oldShapeImageThreshold = oldStyle ? oldStyle->shapeImageThreshold() :
LayoutStyle::initialShapeImageThreshold(); | 266 float oldShapeImageThreshold = oldStyle ? oldStyle->shapeImageThreshold() :
LayoutStyle::initialShapeImageThreshold(); |
267 | 267 |
268 // FIXME: A future optimization would do a deep comparison for equality. (bu
g 100811) | 268 // FIXME: A future optimization would do a deep comparison for equality. (bu
g 100811) |
269 if (shapeOutside == oldShapeOutside && shapeMargin == oldShapeMargin && shap
eImageThreshold == oldShapeImageThreshold) | 269 if (shapeOutside == oldShapeOutside && shapeMargin == oldShapeMargin && shap
eImageThreshold == oldShapeImageThreshold) |
270 return; | 270 return; |
271 | 271 |
272 if (!shapeOutside) | 272 if (!shapeOutside) |
273 ShapeOutsideInfo::removeInfo(*this); | 273 ShapeOutsideInfo::removeInfo(*this); |
274 else | 274 else |
275 ShapeOutsideInfo::ensureInfo(*this).markShapeAsDirty(); | 275 ShapeOutsideInfo::ensureInfo(*this).markShapeAsDirty(); |
276 | 276 |
277 if (shapeOutside || shapeOutside != oldShapeOutside) | 277 if (shapeOutside || shapeOutside != oldShapeOutside) |
278 markShapeOutsideDependentsForLayout(); | 278 markShapeOutsideDependentsForLayout(); |
279 } | 279 } |
280 | 280 |
281 void RenderBox::updateGridPositionAfterStyleChange(const LayoutStyle* oldStyle) | 281 void LayoutBox::updateGridPositionAfterStyleChange(const LayoutStyle* oldStyle) |
282 { | 282 { |
283 if (!oldStyle || !parent() || !parent()->isRenderGrid()) | 283 if (!oldStyle || !parent() || !parent()->isRenderGrid()) |
284 return; | 284 return; |
285 | 285 |
286 if (oldStyle->gridColumnStart() == style()->gridColumnStart() | 286 if (oldStyle->gridColumnStart() == style()->gridColumnStart() |
287 && oldStyle->gridColumnEnd() == style()->gridColumnEnd() | 287 && oldStyle->gridColumnEnd() == style()->gridColumnEnd() |
288 && oldStyle->gridRowStart() == style()->gridRowStart() | 288 && oldStyle->gridRowStart() == style()->gridRowStart() |
289 && oldStyle->gridRowEnd() == style()->gridRowEnd() | 289 && oldStyle->gridRowEnd() == style()->gridRowEnd() |
290 && oldStyle->order() == style()->order() | 290 && oldStyle->order() == style()->order() |
291 && oldStyle->hasOutOfFlowPosition() == style()->hasOutOfFlowPosition()) | 291 && oldStyle->hasOutOfFlowPosition() == style()->hasOutOfFlowPosition()) |
292 return; | 292 return; |
293 | 293 |
294 // It should be possible to not dirty the grid in some cases (like moving an
explicitly placed grid item). | 294 // It should be possible to not dirty the grid in some cases (like moving an
explicitly placed grid item). |
295 // For now, it's more simple to just always recompute the grid. | 295 // For now, it's more simple to just always recompute the grid. |
296 toRenderGrid(parent())->dirtyGrid(); | 296 toRenderGrid(parent())->dirtyGrid(); |
297 } | 297 } |
298 | 298 |
299 void RenderBox::updateFromStyle() | 299 void LayoutBox::updateFromStyle() |
300 { | 300 { |
301 LayoutBoxModelObject::updateFromStyle(); | 301 LayoutBoxModelObject::updateFromStyle(); |
302 | 302 |
303 const LayoutStyle& styleToUse = styleRef(); | 303 const LayoutStyle& styleToUse = styleRef(); |
304 bool isRootObject = isDocumentElement(); | 304 bool isRootObject = isDocumentElement(); |
305 bool isViewObject = isRenderView(); | 305 bool isViewObject = isRenderView(); |
306 bool rootLayerScrolls = document().settings() && document().settings()->root
LayerScrolls(); | 306 bool rootLayerScrolls = document().settings() && document().settings()->root
LayerScrolls(); |
307 | 307 |
308 // The root and the RenderView always paint their backgrounds/borders. | 308 // The root and the RenderView always paint their backgrounds/borders. |
309 if (isRootObject || isViewObject) | 309 if (isRootObject || isViewObject) |
(...skipping 14 matching lines...) Expand all Loading... |
324 for (LayoutObject* child = slowFirstChild(); child; child = child->nextS
ibling()) | 324 for (LayoutObject* child = slowFirstChild(); child; child = child->nextS
ibling()) |
325 child->setMayNeedPaintInvalidation(); | 325 child->setMayNeedPaintInvalidation(); |
326 } | 326 } |
327 | 327 |
328 setHasOverflowClip(boxHasOverflowClip); | 328 setHasOverflowClip(boxHasOverflowClip); |
329 | 329 |
330 setHasTransformRelatedProperty(styleToUse.hasTransformRelatedProperty()); | 330 setHasTransformRelatedProperty(styleToUse.hasTransformRelatedProperty()); |
331 setHasReflection(styleToUse.boxReflect()); | 331 setHasReflection(styleToUse.boxReflect()); |
332 } | 332 } |
333 | 333 |
334 void RenderBox::layout() | 334 void LayoutBox::layout() |
335 { | 335 { |
336 ASSERT(needsLayout()); | 336 ASSERT(needsLayout()); |
337 | 337 |
338 LayoutObject* child = slowFirstChild(); | 338 LayoutObject* child = slowFirstChild(); |
339 if (!child) { | 339 if (!child) { |
340 clearNeedsLayout(); | 340 clearNeedsLayout(); |
341 return; | 341 return; |
342 } | 342 } |
343 | 343 |
344 LayoutState state(*this, locationOffset()); | 344 LayoutState state(*this, locationOffset()); |
345 while (child) { | 345 while (child) { |
346 child->layoutIfNeeded(); | 346 child->layoutIfNeeded(); |
347 ASSERT(!child->needsLayout()); | 347 ASSERT(!child->needsLayout()); |
348 child = child->nextSibling(); | 348 child = child->nextSibling(); |
349 } | 349 } |
350 invalidateBackgroundObscurationStatus(); | 350 invalidateBackgroundObscurationStatus(); |
351 clearNeedsLayout(); | 351 clearNeedsLayout(); |
352 } | 352 } |
353 | 353 |
354 // More IE extensions. clientWidth and clientHeight represent the interior of a
n object | 354 // More IE extensions. clientWidth and clientHeight represent the interior of a
n object |
355 // excluding border and scrollbar. | 355 // excluding border and scrollbar. |
356 LayoutUnit RenderBox::clientWidth() const | 356 LayoutUnit LayoutBox::clientWidth() const |
357 { | 357 { |
358 return m_frameRect.width() - borderLeft() - borderRight() - verticalScrollba
rWidth(); | 358 return m_frameRect.width() - borderLeft() - borderRight() - verticalScrollba
rWidth(); |
359 } | 359 } |
360 | 360 |
361 LayoutUnit RenderBox::clientHeight() const | 361 LayoutUnit LayoutBox::clientHeight() const |
362 { | 362 { |
363 return m_frameRect.height() - borderTop() - borderBottom() - horizontalScrol
lbarHeight(); | 363 return m_frameRect.height() - borderTop() - borderBottom() - horizontalScrol
lbarHeight(); |
364 } | 364 } |
365 | 365 |
366 int RenderBox::pixelSnappedClientWidth() const | 366 int LayoutBox::pixelSnappedClientWidth() const |
367 { | 367 { |
368 return snapSizeToPixel(clientWidth(), location().x() + clientLeft()); | 368 return snapSizeToPixel(clientWidth(), location().x() + clientLeft()); |
369 } | 369 } |
370 | 370 |
371 int RenderBox::pixelSnappedClientHeight() const | 371 int LayoutBox::pixelSnappedClientHeight() const |
372 { | 372 { |
373 return snapSizeToPixel(clientHeight(), location().y() + clientTop()); | 373 return snapSizeToPixel(clientHeight(), location().y() + clientTop()); |
374 } | 374 } |
375 | 375 |
376 int RenderBox::pixelSnappedOffsetWidth() const | 376 int LayoutBox::pixelSnappedOffsetWidth() const |
377 { | 377 { |
378 return snapSizeToPixel(offsetWidth(), location().x() + clientLeft()); | 378 return snapSizeToPixel(offsetWidth(), location().x() + clientLeft()); |
379 } | 379 } |
380 | 380 |
381 int RenderBox::pixelSnappedOffsetHeight() const | 381 int LayoutBox::pixelSnappedOffsetHeight() const |
382 { | 382 { |
383 return snapSizeToPixel(offsetHeight(), location().y() + clientTop()); | 383 return snapSizeToPixel(offsetHeight(), location().y() + clientTop()); |
384 } | 384 } |
385 | 385 |
386 LayoutUnit RenderBox::scrollWidth() const | 386 LayoutUnit LayoutBox::scrollWidth() const |
387 { | 387 { |
388 if (hasOverflowClip()) | 388 if (hasOverflowClip()) |
389 return layer()->scrollableArea()->scrollWidth(); | 389 return layer()->scrollableArea()->scrollWidth(); |
390 // For objects with visible overflow, this matches IE. | 390 // For objects with visible overflow, this matches IE. |
391 // FIXME: Need to work right with writing modes. | 391 // FIXME: Need to work right with writing modes. |
392 if (style()->isLeftToRightDirection()) | 392 if (style()->isLeftToRightDirection()) |
393 return std::max(clientWidth(), layoutOverflowRect().maxX() - borderLeft(
)); | 393 return std::max(clientWidth(), layoutOverflowRect().maxX() - borderLeft(
)); |
394 return clientWidth() - std::min(LayoutUnit(), layoutOverflowRect().x() - bor
derLeft()); | 394 return clientWidth() - std::min(LayoutUnit(), layoutOverflowRect().x() - bor
derLeft()); |
395 } | 395 } |
396 | 396 |
397 LayoutUnit RenderBox::scrollHeight() const | 397 LayoutUnit LayoutBox::scrollHeight() const |
398 { | 398 { |
399 if (hasOverflowClip()) | 399 if (hasOverflowClip()) |
400 return layer()->scrollableArea()->scrollHeight(); | 400 return layer()->scrollableArea()->scrollHeight(); |
401 // For objects with visible overflow, this matches IE. | 401 // For objects with visible overflow, this matches IE. |
402 // FIXME: Need to work right with writing modes. | 402 // FIXME: Need to work right with writing modes. |
403 return std::max(clientHeight(), layoutOverflowRect().maxY() - borderTop()); | 403 return std::max(clientHeight(), layoutOverflowRect().maxY() - borderTop()); |
404 } | 404 } |
405 | 405 |
406 LayoutUnit RenderBox::scrollLeft() const | 406 LayoutUnit LayoutBox::scrollLeft() const |
407 { | 407 { |
408 return hasOverflowClip() ? layer()->scrollableArea()->scrollXOffset() : 0; | 408 return hasOverflowClip() ? layer()->scrollableArea()->scrollXOffset() : 0; |
409 } | 409 } |
410 | 410 |
411 LayoutUnit RenderBox::scrollTop() const | 411 LayoutUnit LayoutBox::scrollTop() const |
412 { | 412 { |
413 return hasOverflowClip() ? layer()->scrollableArea()->scrollYOffset() : 0; | 413 return hasOverflowClip() ? layer()->scrollableArea()->scrollYOffset() : 0; |
414 } | 414 } |
415 | 415 |
416 int RenderBox::pixelSnappedScrollWidth() const | 416 int LayoutBox::pixelSnappedScrollWidth() const |
417 { | 417 { |
418 return snapSizeToPixel(scrollWidth(), location().x() + clientLeft()); | 418 return snapSizeToPixel(scrollWidth(), location().x() + clientLeft()); |
419 } | 419 } |
420 | 420 |
421 int RenderBox::pixelSnappedScrollHeight() const | 421 int LayoutBox::pixelSnappedScrollHeight() const |
422 { | 422 { |
423 if (hasOverflowClip()) | 423 if (hasOverflowClip()) |
424 return layer()->scrollableArea()->scrollHeight(); | 424 return layer()->scrollableArea()->scrollHeight(); |
425 // For objects with visible overflow, this matches IE. | 425 // For objects with visible overflow, this matches IE. |
426 // FIXME: Need to work right with writing modes. | 426 // FIXME: Need to work right with writing modes. |
427 return snapSizeToPixel(scrollHeight(), location().y() + clientTop()); | 427 return snapSizeToPixel(scrollHeight(), location().y() + clientTop()); |
428 } | 428 } |
429 | 429 |
430 void RenderBox::setScrollLeft(LayoutUnit newLeft) | 430 void LayoutBox::setScrollLeft(LayoutUnit newLeft) |
431 { | 431 { |
432 // This doesn't hit in any tests, but since the equivalent code in setScroll
Top | 432 // This doesn't hit in any tests, but since the equivalent code in setScroll
Top |
433 // does, presumably this code does as well. | 433 // does, presumably this code does as well. |
434 DisableCompositingQueryAsserts disabler; | 434 DisableCompositingQueryAsserts disabler; |
435 | 435 |
436 if (hasOverflowClip()) | 436 if (hasOverflowClip()) |
437 layer()->scrollableArea()->scrollToXOffset(newLeft, ScrollOffsetClamped,
ScrollBehaviorAuto); | 437 layer()->scrollableArea()->scrollToXOffset(newLeft, ScrollOffsetClamped,
ScrollBehaviorAuto); |
438 } | 438 } |
439 | 439 |
440 void RenderBox::setScrollTop(LayoutUnit newTop) | 440 void LayoutBox::setScrollTop(LayoutUnit newTop) |
441 { | 441 { |
442 // Hits in compositing/overflow/do-not-assert-on-invisible-composited-layers
.html | 442 // Hits in compositing/overflow/do-not-assert-on-invisible-composited-layers
.html |
443 DisableCompositingQueryAsserts disabler; | 443 DisableCompositingQueryAsserts disabler; |
444 | 444 |
445 if (hasOverflowClip()) | 445 if (hasOverflowClip()) |
446 layer()->scrollableArea()->scrollToYOffset(newTop, ScrollOffsetClamped,
ScrollBehaviorAuto); | 446 layer()->scrollableArea()->scrollToYOffset(newTop, ScrollOffsetClamped,
ScrollBehaviorAuto); |
447 } | 447 } |
448 | 448 |
449 void RenderBox::scrollToOffset(const DoubleSize& offset, ScrollBehavior scrollBe
havior) | 449 void LayoutBox::scrollToOffset(const DoubleSize& offset, ScrollBehavior scrollBe
havior) |
450 { | 450 { |
451 // This doesn't hit in any tests, but since the equivalent code in setScroll
Top | 451 // This doesn't hit in any tests, but since the equivalent code in setScroll
Top |
452 // does, presumably this code does as well. | 452 // does, presumably this code does as well. |
453 DisableCompositingQueryAsserts disabler; | 453 DisableCompositingQueryAsserts disabler; |
454 | 454 |
455 if (hasOverflowClip()) | 455 if (hasOverflowClip()) |
456 layer()->scrollableArea()->scrollToOffset(offset, ScrollOffsetClamped, s
crollBehavior); | 456 layer()->scrollableArea()->scrollToOffset(offset, ScrollOffsetClamped, s
crollBehavior); |
457 } | 457 } |
458 | 458 |
459 static inline bool frameElementAndViewPermitScroll(HTMLFrameElementBase* frameEl
ementBase, FrameView* frameView) | 459 static inline bool frameElementAndViewPermitScroll(HTMLFrameElementBase* frameEl
ementBase, FrameView* frameView) |
460 { | 460 { |
461 // If scrollbars aren't explicitly forbidden, permit scrolling. | 461 // If scrollbars aren't explicitly forbidden, permit scrolling. |
462 if (frameElementBase && frameElementBase->scrollingMode() != ScrollbarAlways
Off) | 462 if (frameElementBase && frameElementBase->scrollingMode() != ScrollbarAlways
Off) |
463 return true; | 463 return true; |
464 | 464 |
465 // If scrollbars are forbidden, user initiated scrolls should obviously be i
gnored. | 465 // If scrollbars are forbidden, user initiated scrolls should obviously be i
gnored. |
466 if (frameView->wasScrolledByUser()) | 466 if (frameView->wasScrolledByUser()) |
467 return false; | 467 return false; |
468 | 468 |
469 // Forbid autoscrolls when scrollbars are off, but permits other programmati
c scrolls, | 469 // Forbid autoscrolls when scrollbars are off, but permits other programmati
c scrolls, |
470 // like navigation to an anchor. | 470 // like navigation to an anchor. |
471 Page* page = frameView->frame().page(); | 471 Page* page = frameView->frame().page(); |
472 if (!page) | 472 if (!page) |
473 return false; | 473 return false; |
474 return !page->autoscrollController().autoscrollInProgress(); | 474 return !page->autoscrollController().autoscrollInProgress(); |
475 } | 475 } |
476 | 476 |
477 void RenderBox::scrollRectToVisible(const LayoutRect& rect, const ScrollAlignmen
t& alignX, const ScrollAlignment& alignY) | 477 void LayoutBox::scrollRectToVisible(const LayoutRect& rect, const ScrollAlignmen
t& alignX, const ScrollAlignment& alignY) |
478 { | 478 { |
479 // Presumably the same issue as in setScrollTop. See crbug.com/343132. | 479 // Presumably the same issue as in setScrollTop. See crbug.com/343132. |
480 DisableCompositingQueryAsserts disabler; | 480 DisableCompositingQueryAsserts disabler; |
481 | 481 |
482 RenderBox* parentBox = 0; | 482 LayoutBox* parentBox = 0; |
483 LayoutRect newRect = rect; | 483 LayoutRect newRect = rect; |
484 | 484 |
485 bool restrictedByLineClamp = false; | 485 bool restrictedByLineClamp = false; |
486 if (parent()) { | 486 if (parent()) { |
487 parentBox = parent()->enclosingBox(); | 487 parentBox = parent()->enclosingBox(); |
488 restrictedByLineClamp = !parent()->style()->lineClamp().isNone(); | 488 restrictedByLineClamp = !parent()->style()->lineClamp().isNone(); |
489 } | 489 } |
490 | 490 |
491 if (hasOverflowClip() && !restrictedByLineClamp) { | 491 if (hasOverflowClip() && !restrictedByLineClamp) { |
492 // Don't scroll to reveal an overflow layer that is restricted by the -w
ebkit-line-clamp property. | 492 // Don't scroll to reveal an overflow layer that is restricted by the -w
ebkit-line-clamp property. |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
546 } | 546 } |
547 } | 547 } |
548 | 548 |
549 if (frame()->page()->autoscrollController().autoscrollInProgress()) | 549 if (frame()->page()->autoscrollController().autoscrollInProgress()) |
550 parentBox = enclosingScrollableBox(); | 550 parentBox = enclosingScrollableBox(); |
551 | 551 |
552 if (parentBox) | 552 if (parentBox) |
553 parentBox->scrollRectToVisible(newRect, alignX, alignY); | 553 parentBox->scrollRectToVisible(newRect, alignX, alignY); |
554 } | 554 } |
555 | 555 |
556 void RenderBox::absoluteRects(Vector<IntRect>& rects, const LayoutPoint& accumul
atedOffset) const | 556 void LayoutBox::absoluteRects(Vector<IntRect>& rects, const LayoutPoint& accumul
atedOffset) const |
557 { | 557 { |
558 rects.append(pixelSnappedIntRect(accumulatedOffset, size())); | 558 rects.append(pixelSnappedIntRect(accumulatedOffset, size())); |
559 } | 559 } |
560 | 560 |
561 void RenderBox::absoluteQuads(Vector<FloatQuad>& quads, bool* wasFixed) const | 561 void LayoutBox::absoluteQuads(Vector<FloatQuad>& quads, bool* wasFixed) const |
562 { | 562 { |
563 quads.append(localToAbsoluteQuad(FloatRect(0, 0, m_frameRect.width().toFloat
(), m_frameRect.height().toFloat()), 0 /* mode */, wasFixed)); | 563 quads.append(localToAbsoluteQuad(FloatRect(0, 0, m_frameRect.width().toFloat
(), m_frameRect.height().toFloat()), 0 /* mode */, wasFixed)); |
564 } | 564 } |
565 | 565 |
566 void RenderBox::updateLayerTransformAfterLayout() | 566 void LayoutBox::updateLayerTransformAfterLayout() |
567 { | 567 { |
568 // Transform-origin depends on box size, so we need to update the layer tran
sform after layout. | 568 // Transform-origin depends on box size, so we need to update the layer tran
sform after layout. |
569 if (hasLayer()) | 569 if (hasLayer()) |
570 layer()->updateTransformationMatrix(); | 570 layer()->updateTransformationMatrix(); |
571 } | 571 } |
572 | 572 |
573 LayoutUnit RenderBox::constrainLogicalWidthByMinMax(LayoutUnit logicalWidth, Lay
outUnit availableWidth, RenderBlock* cb) const | 573 LayoutUnit LayoutBox::constrainLogicalWidthByMinMax(LayoutUnit logicalWidth, Lay
outUnit availableWidth, RenderBlock* cb) const |
574 { | 574 { |
575 const LayoutStyle& styleToUse = styleRef(); | 575 const LayoutStyle& styleToUse = styleRef(); |
576 if (!styleToUse.logicalMaxWidth().isMaxSizeNone()) | 576 if (!styleToUse.logicalMaxWidth().isMaxSizeNone()) |
577 logicalWidth = std::min(logicalWidth, computeLogicalWidthUsing(MaxSize,
styleToUse.logicalMaxWidth(), availableWidth, cb)); | 577 logicalWidth = std::min(logicalWidth, computeLogicalWidthUsing(MaxSize,
styleToUse.logicalMaxWidth(), availableWidth, cb)); |
578 return std::max(logicalWidth, computeLogicalWidthUsing(MinSize, styleToUse.l
ogicalMinWidth(), availableWidth, cb)); | 578 return std::max(logicalWidth, computeLogicalWidthUsing(MinSize, styleToUse.l
ogicalMinWidth(), availableWidth, cb)); |
579 } | 579 } |
580 | 580 |
581 LayoutUnit RenderBox::constrainLogicalHeightByMinMax(LayoutUnit logicalHeight, L
ayoutUnit intrinsicContentHeight) const | 581 LayoutUnit LayoutBox::constrainLogicalHeightByMinMax(LayoutUnit logicalHeight, L
ayoutUnit intrinsicContentHeight) const |
582 { | 582 { |
583 const LayoutStyle& styleToUse = styleRef(); | 583 const LayoutStyle& styleToUse = styleRef(); |
584 if (!styleToUse.logicalMaxHeight().isMaxSizeNone()) { | 584 if (!styleToUse.logicalMaxHeight().isMaxSizeNone()) { |
585 LayoutUnit maxH = computeLogicalHeightUsing(styleToUse.logicalMaxHeight(
), intrinsicContentHeight); | 585 LayoutUnit maxH = computeLogicalHeightUsing(styleToUse.logicalMaxHeight(
), intrinsicContentHeight); |
586 if (maxH != -1) | 586 if (maxH != -1) |
587 logicalHeight = std::min(logicalHeight, maxH); | 587 logicalHeight = std::min(logicalHeight, maxH); |
588 } | 588 } |
589 return std::max(logicalHeight, computeLogicalHeightUsing(styleToUse.logicalM
inHeight(), intrinsicContentHeight)); | 589 return std::max(logicalHeight, computeLogicalHeightUsing(styleToUse.logicalM
inHeight(), intrinsicContentHeight)); |
590 } | 590 } |
591 | 591 |
592 LayoutUnit RenderBox::constrainContentBoxLogicalHeightByMinMax(LayoutUnit logica
lHeight, LayoutUnit intrinsicContentHeight) const | 592 LayoutUnit LayoutBox::constrainContentBoxLogicalHeightByMinMax(LayoutUnit logica
lHeight, LayoutUnit intrinsicContentHeight) const |
593 { | 593 { |
594 const LayoutStyle& styleToUse = styleRef(); | 594 const LayoutStyle& styleToUse = styleRef(); |
595 if (!styleToUse.logicalMaxHeight().isMaxSizeNone()) { | 595 if (!styleToUse.logicalMaxHeight().isMaxSizeNone()) { |
596 LayoutUnit maxH = computeContentLogicalHeight(styleToUse.logicalMaxHeigh
t(), intrinsicContentHeight); | 596 LayoutUnit maxH = computeContentLogicalHeight(styleToUse.logicalMaxHeigh
t(), intrinsicContentHeight); |
597 if (maxH != -1) | 597 if (maxH != -1) |
598 logicalHeight = std::min(logicalHeight, maxH); | 598 logicalHeight = std::min(logicalHeight, maxH); |
599 } | 599 } |
600 return std::max(logicalHeight, computeContentLogicalHeight(styleToUse.logica
lMinHeight(), intrinsicContentHeight)); | 600 return std::max(logicalHeight, computeContentLogicalHeight(styleToUse.logica
lMinHeight(), intrinsicContentHeight)); |
601 } | 601 } |
602 | 602 |
603 IntRect RenderBox::absoluteContentBox() const | 603 IntRect LayoutBox::absoluteContentBox() const |
604 { | 604 { |
605 // This is wrong with transforms and flipped writing modes. | 605 // This is wrong with transforms and flipped writing modes. |
606 IntRect rect = pixelSnappedIntRect(contentBoxRect()); | 606 IntRect rect = pixelSnappedIntRect(contentBoxRect()); |
607 FloatPoint absPos = localToAbsolute(); | 607 FloatPoint absPos = localToAbsolute(); |
608 rect.move(absPos.x(), absPos.y()); | 608 rect.move(absPos.x(), absPos.y()); |
609 return rect; | 609 return rect; |
610 } | 610 } |
611 | 611 |
612 IntSize RenderBox::absoluteContentBoxOffset() const | 612 IntSize LayoutBox::absoluteContentBoxOffset() const |
613 { | 613 { |
614 IntPoint offset = roundedIntPoint(contentBoxOffset()); | 614 IntPoint offset = roundedIntPoint(contentBoxOffset()); |
615 FloatPoint absPos = localToAbsolute(); | 615 FloatPoint absPos = localToAbsolute(); |
616 offset.move(absPos.x(), absPos.y()); | 616 offset.move(absPos.x(), absPos.y()); |
617 return toIntSize(offset); | 617 return toIntSize(offset); |
618 } | 618 } |
619 | 619 |
620 FloatQuad RenderBox::absoluteContentQuad() const | 620 FloatQuad LayoutBox::absoluteContentQuad() const |
621 { | 621 { |
622 LayoutRect rect = contentBoxRect(); | 622 LayoutRect rect = contentBoxRect(); |
623 return localToAbsoluteQuad(FloatRect(rect)); | 623 return localToAbsoluteQuad(FloatRect(rect)); |
624 } | 624 } |
625 | 625 |
626 void RenderBox::addFocusRingRects(Vector<LayoutRect>& rects, const LayoutPoint&
additionalOffset) const | 626 void LayoutBox::addFocusRingRects(Vector<LayoutRect>& rects, const LayoutPoint&
additionalOffset) const |
627 { | 627 { |
628 if (!size().isEmpty()) | 628 if (!size().isEmpty()) |
629 rects.append(LayoutRect(additionalOffset, size())); | 629 rects.append(LayoutRect(additionalOffset, size())); |
630 } | 630 } |
631 | 631 |
632 bool RenderBox::canResize() const | 632 bool LayoutBox::canResize() const |
633 { | 633 { |
634 // We need a special case for <iframe> because they never have | 634 // We need a special case for <iframe> because they never have |
635 // hasOverflowClip(). However, they do "implicitly" clip their contents, so | 635 // hasOverflowClip(). However, they do "implicitly" clip their contents, so |
636 // we want to allow resizing them also. | 636 // we want to allow resizing them also. |
637 return (hasOverflowClip() || isLayoutIFrame()) && style()->resize() != RESIZ
E_NONE; | 637 return (hasOverflowClip() || isLayoutIFrame()) && style()->resize() != RESIZ
E_NONE; |
638 } | 638 } |
639 | 639 |
640 void RenderBox::addLayerHitTestRects(LayerHitTestRects& layerRects, const Layer*
currentLayer, const LayoutPoint& layerOffset, const LayoutRect& containerRect)
const | 640 void LayoutBox::addLayerHitTestRects(LayerHitTestRects& layerRects, const Layer*
currentLayer, const LayoutPoint& layerOffset, const LayoutRect& containerRect)
const |
641 { | 641 { |
642 LayoutPoint adjustedLayerOffset = layerOffset + locationOffset(); | 642 LayoutPoint adjustedLayerOffset = layerOffset + locationOffset(); |
643 LayoutBoxModelObject::addLayerHitTestRects(layerRects, currentLayer, adjuste
dLayerOffset, containerRect); | 643 LayoutBoxModelObject::addLayerHitTestRects(layerRects, currentLayer, adjuste
dLayerOffset, containerRect); |
644 } | 644 } |
645 | 645 |
646 void RenderBox::computeSelfHitTestRects(Vector<LayoutRect>& rects, const LayoutP
oint& layerOffset) const | 646 void LayoutBox::computeSelfHitTestRects(Vector<LayoutRect>& rects, const LayoutP
oint& layerOffset) const |
647 { | 647 { |
648 if (!size().isEmpty()) | 648 if (!size().isEmpty()) |
649 rects.append(LayoutRect(layerOffset, size())); | 649 rects.append(LayoutRect(layerOffset, size())); |
650 } | 650 } |
651 | 651 |
652 int RenderBox::reflectionOffset() const | 652 int LayoutBox::reflectionOffset() const |
653 { | 653 { |
654 if (!style()->boxReflect()) | 654 if (!style()->boxReflect()) |
655 return 0; | 655 return 0; |
656 if (style()->boxReflect()->direction() == ReflectionLeft || style()->boxRefl
ect()->direction() == ReflectionRight) | 656 if (style()->boxReflect()->direction() == ReflectionLeft || style()->boxRefl
ect()->direction() == ReflectionRight) |
657 return valueForLength(style()->boxReflect()->offset(), borderBoxRect().w
idth()); | 657 return valueForLength(style()->boxReflect()->offset(), borderBoxRect().w
idth()); |
658 return valueForLength(style()->boxReflect()->offset(), borderBoxRect().heigh
t()); | 658 return valueForLength(style()->boxReflect()->offset(), borderBoxRect().heigh
t()); |
659 } | 659 } |
660 | 660 |
661 LayoutRect RenderBox::reflectedRect(const LayoutRect& r) const | 661 LayoutRect LayoutBox::reflectedRect(const LayoutRect& r) const |
662 { | 662 { |
663 if (!style()->boxReflect()) | 663 if (!style()->boxReflect()) |
664 return LayoutRect(); | 664 return LayoutRect(); |
665 | 665 |
666 LayoutRect box = borderBoxRect(); | 666 LayoutRect box = borderBoxRect(); |
667 LayoutRect result = r; | 667 LayoutRect result = r; |
668 switch (style()->boxReflect()->direction()) { | 668 switch (style()->boxReflect()->direction()) { |
669 case ReflectionBelow: | 669 case ReflectionBelow: |
670 result.setY(box.maxY() + reflectionOffset() + (box.maxY() - r.maxY()
)); | 670 result.setY(box.maxY() + reflectionOffset() + (box.maxY() - r.maxY())); |
671 break; | 671 break; |
672 case ReflectionAbove: | 672 case ReflectionAbove: |
673 result.setY(box.y() - reflectionOffset() - box.height() + (box.maxY(
) - r.maxY())); | 673 result.setY(box.y() - reflectionOffset() - box.height() + (box.maxY() -
r.maxY())); |
674 break; | 674 break; |
675 case ReflectionLeft: | 675 case ReflectionLeft: |
676 result.setX(box.x() - reflectionOffset() - box.width() + (box.maxX()
- r.maxX())); | 676 result.setX(box.x() - reflectionOffset() - box.width() + (box.maxX() - r
.maxX())); |
677 break; | 677 break; |
678 case ReflectionRight: | 678 case ReflectionRight: |
679 result.setX(box.maxX() + reflectionOffset() + (box.maxX() - r.maxX()
)); | 679 result.setX(box.maxX() + reflectionOffset() + (box.maxX() - r.maxX())); |
680 break; | 680 break; |
681 } | 681 } |
682 return result; | 682 return result; |
683 } | 683 } |
684 | 684 |
685 int RenderBox::verticalScrollbarWidth() const | 685 int LayoutBox::verticalScrollbarWidth() const |
686 { | 686 { |
687 if (!hasOverflowClip() || style()->overflowY() == OOVERLAY) | 687 if (!hasOverflowClip() || style()->overflowY() == OOVERLAY) |
688 return 0; | 688 return 0; |
689 | 689 |
690 return layer()->scrollableArea()->verticalScrollbarWidth(); | 690 return layer()->scrollableArea()->verticalScrollbarWidth(); |
691 } | 691 } |
692 | 692 |
693 int RenderBox::horizontalScrollbarHeight() const | 693 int LayoutBox::horizontalScrollbarHeight() const |
694 { | 694 { |
695 if (!hasOverflowClip() || style()->overflowX() == OOVERLAY) | 695 if (!hasOverflowClip() || style()->overflowX() == OOVERLAY) |
696 return 0; | 696 return 0; |
697 | 697 |
698 return layer()->scrollableArea()->horizontalScrollbarHeight(); | 698 return layer()->scrollableArea()->horizontalScrollbarHeight(); |
699 } | 699 } |
700 | 700 |
701 int RenderBox::intrinsicScrollbarLogicalWidth() const | 701 int LayoutBox::intrinsicScrollbarLogicalWidth() const |
702 { | 702 { |
703 if (!hasOverflowClip()) | 703 if (!hasOverflowClip()) |
704 return 0; | 704 return 0; |
705 | 705 |
706 if (isHorizontalWritingMode() && style()->overflowY() == OSCROLL) { | 706 if (isHorizontalWritingMode() && style()->overflowY() == OSCROLL) { |
707 ASSERT(layer()->scrollableArea() && layer()->scrollableArea()->hasVertic
alScrollbar()); | 707 ASSERT(layer()->scrollableArea() && layer()->scrollableArea()->hasVertic
alScrollbar()); |
708 return verticalScrollbarWidth(); | 708 return verticalScrollbarWidth(); |
709 } | 709 } |
710 | 710 |
711 if (!isHorizontalWritingMode() && style()->overflowX() == OSCROLL) { | 711 if (!isHorizontalWritingMode() && style()->overflowX() == OSCROLL) { |
712 ASSERT(layer()->scrollableArea() && layer()->scrollableArea()->hasHorizo
ntalScrollbar()); | 712 ASSERT(layer()->scrollableArea() && layer()->scrollableArea()->hasHorizo
ntalScrollbar()); |
713 return horizontalScrollbarHeight(); | 713 return horizontalScrollbarHeight(); |
714 } | 714 } |
715 | 715 |
716 return 0; | 716 return 0; |
717 } | 717 } |
718 | 718 |
719 bool RenderBox::scroll(ScrollDirection direction, ScrollGranularity granularity,
float delta) | 719 bool LayoutBox::scroll(ScrollDirection direction, ScrollGranularity granularity,
float delta) |
720 { | 720 { |
721 // Presumably the same issue as in setScrollTop. See crbug.com/343132. | 721 // Presumably the same issue as in setScrollTop. See crbug.com/343132. |
722 DisableCompositingQueryAsserts disabler; | 722 DisableCompositingQueryAsserts disabler; |
723 | 723 |
724 // Logical scroll is a higher level concept, all directions by here must be
physical | 724 // Logical scroll is a higher level concept, all directions by here must be
physical |
725 ASSERT(!isLogical(direction)); | 725 ASSERT(!isLogical(direction)); |
726 | 726 |
727 if (!layer() || !layer()->scrollableArea()) | 727 if (!layer() || !layer()->scrollableArea()) |
728 return false; | 728 return false; |
729 | 729 |
730 return layer()->scrollableArea()->scroll(direction, granularity, delta); | 730 return layer()->scrollableArea()->scroll(direction, granularity, delta); |
731 } | 731 } |
732 | 732 |
733 bool RenderBox::canBeScrolledAndHasScrollableArea() const | 733 bool LayoutBox::canBeScrolledAndHasScrollableArea() const |
734 { | 734 { |
735 return canBeProgramaticallyScrolled() && (pixelSnappedScrollHeight() != pixe
lSnappedClientHeight() || pixelSnappedScrollWidth() != pixelSnappedClientWidth()
); | 735 return canBeProgramaticallyScrolled() && (pixelSnappedScrollHeight() != pixe
lSnappedClientHeight() || pixelSnappedScrollWidth() != pixelSnappedClientWidth()
); |
736 } | 736 } |
737 | 737 |
738 bool RenderBox::canBeProgramaticallyScrolled() const | 738 bool LayoutBox::canBeProgramaticallyScrolled() const |
739 { | 739 { |
740 Node* node = this->node(); | 740 Node* node = this->node(); |
741 if (node && node->isDocumentNode()) | 741 if (node && node->isDocumentNode()) |
742 return true; | 742 return true; |
743 | 743 |
744 if (!hasOverflowClip()) | 744 if (!hasOverflowClip()) |
745 return false; | 745 return false; |
746 | 746 |
747 bool hasScrollableOverflow = hasScrollableOverflowX() || hasScrollableOverfl
owY(); | 747 bool hasScrollableOverflow = hasScrollableOverflowX() || hasScrollableOverfl
owY(); |
748 if (scrollsOverflow() && hasScrollableOverflow) | 748 if (scrollsOverflow() && hasScrollableOverflow) |
749 return true; | 749 return true; |
750 | 750 |
751 return node && node->hasEditableStyle(); | 751 return node && node->hasEditableStyle(); |
752 } | 752 } |
753 | 753 |
754 bool RenderBox::usesCompositedScrolling() const | 754 bool LayoutBox::usesCompositedScrolling() const |
755 { | 755 { |
756 return hasOverflowClip() && hasLayer() && layer()->scrollableArea()->usesCom
positedScrolling(); | 756 return hasOverflowClip() && hasLayer() && layer()->scrollableArea()->usesCom
positedScrolling(); |
757 } | 757 } |
758 | 758 |
759 void RenderBox::autoscroll(const IntPoint& position) | 759 void LayoutBox::autoscroll(const IntPoint& position) |
760 { | 760 { |
761 LocalFrame* frame = this->frame(); | 761 LocalFrame* frame = this->frame(); |
762 if (!frame) | 762 if (!frame) |
763 return; | 763 return; |
764 | 764 |
765 FrameView* frameView = frame->view(); | 765 FrameView* frameView = frame->view(); |
766 if (!frameView) | 766 if (!frameView) |
767 return; | 767 return; |
768 | 768 |
769 IntPoint currentDocumentPosition = frameView->windowToContents(position); | 769 IntPoint currentDocumentPosition = frameView->windowToContents(position); |
770 scrollRectToVisible(LayoutRect(currentDocumentPosition, LayoutSize(1, 1)), S
crollAlignment::alignToEdgeIfNeeded, ScrollAlignment::alignToEdgeIfNeeded); | 770 scrollRectToVisible(LayoutRect(currentDocumentPosition, LayoutSize(1, 1)), S
crollAlignment::alignToEdgeIfNeeded, ScrollAlignment::alignToEdgeIfNeeded); |
771 } | 771 } |
772 | 772 |
773 // There are two kinds of renderer that can autoscroll. | 773 // There are two kinds of renderer that can autoscroll. |
774 bool RenderBox::canAutoscroll() const | 774 bool LayoutBox::canAutoscroll() const |
775 { | 775 { |
776 if (node() && node()->isDocumentNode()) | 776 if (node() && node()->isDocumentNode()) |
777 return view()->frameView()->isScrollable(); | 777 return view()->frameView()->isScrollable(); |
778 | 778 |
779 // Check for a box that can be scrolled in its own right. | 779 // Check for a box that can be scrolled in its own right. |
780 return canBeScrolledAndHasScrollableArea(); | 780 return canBeScrolledAndHasScrollableArea(); |
781 } | 781 } |
782 | 782 |
783 // If specified point is in border belt, returned offset denotes direction of | 783 // If specified point is in border belt, returned offset denotes direction of |
784 // scrolling. | 784 // scrolling. |
785 IntSize RenderBox::calculateAutoscrollDirection(const IntPoint& windowPoint) con
st | 785 IntSize LayoutBox::calculateAutoscrollDirection(const IntPoint& windowPoint) con
st |
786 { | 786 { |
787 if (!frame()) | 787 if (!frame()) |
788 return IntSize(); | 788 return IntSize(); |
789 | 789 |
790 FrameView* frameView = frame()->view(); | 790 FrameView* frameView = frame()->view(); |
791 if (!frameView) | 791 if (!frameView) |
792 return IntSize(); | 792 return IntSize(); |
793 | 793 |
794 IntRect box(absoluteBoundingBoxRect()); | 794 IntRect box(absoluteBoundingBoxRect()); |
795 box.move(view()->frameView()->scrollOffset()); | 795 box.move(view()->frameView()->scrollOffset()); |
796 IntRect windowBox = view()->frameView()->contentsToWindow(box); | 796 IntRect windowBox = view()->frameView()->contentsToWindow(box); |
797 | 797 |
798 IntPoint windowAutoscrollPoint = windowPoint; | 798 IntPoint windowAutoscrollPoint = windowPoint; |
799 | 799 |
800 if (windowAutoscrollPoint.x() < windowBox.x() + autoscrollBeltSize) | 800 if (windowAutoscrollPoint.x() < windowBox.x() + autoscrollBeltSize) |
801 windowAutoscrollPoint.move(-autoscrollBeltSize, 0); | 801 windowAutoscrollPoint.move(-autoscrollBeltSize, 0); |
802 else if (windowAutoscrollPoint.x() > windowBox.maxX() - autoscrollBeltSize) | 802 else if (windowAutoscrollPoint.x() > windowBox.maxX() - autoscrollBeltSize) |
803 windowAutoscrollPoint.move(autoscrollBeltSize, 0); | 803 windowAutoscrollPoint.move(autoscrollBeltSize, 0); |
804 | 804 |
805 if (windowAutoscrollPoint.y() < windowBox.y() + autoscrollBeltSize) | 805 if (windowAutoscrollPoint.y() < windowBox.y() + autoscrollBeltSize) |
806 windowAutoscrollPoint.move(0, -autoscrollBeltSize); | 806 windowAutoscrollPoint.move(0, -autoscrollBeltSize); |
807 else if (windowAutoscrollPoint.y() > windowBox.maxY() - autoscrollBeltSize) | 807 else if (windowAutoscrollPoint.y() > windowBox.maxY() - autoscrollBeltSize) |
808 windowAutoscrollPoint.move(0, autoscrollBeltSize); | 808 windowAutoscrollPoint.move(0, autoscrollBeltSize); |
809 | 809 |
810 return windowAutoscrollPoint - windowPoint; | 810 return windowAutoscrollPoint - windowPoint; |
811 } | 811 } |
812 | 812 |
813 RenderBox* RenderBox::findAutoscrollable(LayoutObject* renderer) | 813 LayoutBox* LayoutBox::findAutoscrollable(LayoutObject* renderer) |
814 { | 814 { |
815 while (renderer && !(renderer->isBox() && toRenderBox(renderer)->canAutoscro
ll())) { | 815 while (renderer && !(renderer->isBox() && toLayoutBox(renderer)->canAutoscro
ll())) { |
816 if (!renderer->parent() && renderer->node() == renderer->document() && r
enderer->document().ownerElement()) | 816 if (!renderer->parent() && renderer->node() == renderer->document() && r
enderer->document().ownerElement()) |
817 renderer = renderer->document().ownerElement()->renderer(); | 817 renderer = renderer->document().ownerElement()->renderer(); |
818 else | 818 else |
819 renderer = renderer->parent(); | 819 renderer = renderer->parent(); |
820 } | 820 } |
821 | 821 |
822 return renderer && renderer->isBox() ? toRenderBox(renderer) : 0; | 822 return renderer && renderer->isBox() ? toLayoutBox(renderer) : 0; |
823 } | 823 } |
824 | 824 |
825 static inline int adjustedScrollDelta(int beginningDelta) | 825 static inline int adjustedScrollDelta(int beginningDelta) |
826 { | 826 { |
827 // This implemention matches Firefox's. | 827 // This implemention matches Firefox's. |
828 // http://mxr.mozilla.org/firefox/source/toolkit/content/widgets/browser.xml
#856. | 828 // http://mxr.mozilla.org/firefox/source/toolkit/content/widgets/browser.xml
#856. |
829 const int speedReducer = 12; | 829 const int speedReducer = 12; |
830 | 830 |
831 int adjustedDelta = beginningDelta / speedReducer; | 831 int adjustedDelta = beginningDelta / speedReducer; |
832 if (adjustedDelta > 1) | 832 if (adjustedDelta > 1) |
833 adjustedDelta = static_cast<int>(adjustedDelta * sqrt(static_cast<double
>(adjustedDelta))) - 1; | 833 adjustedDelta = static_cast<int>(adjustedDelta * sqrt(static_cast<double
>(adjustedDelta))) - 1; |
834 else if (adjustedDelta < -1) | 834 else if (adjustedDelta < -1) |
835 adjustedDelta = static_cast<int>(adjustedDelta * sqrt(static_cast<double
>(-adjustedDelta))) + 1; | 835 adjustedDelta = static_cast<int>(adjustedDelta * sqrt(static_cast<double
>(-adjustedDelta))) + 1; |
836 | 836 |
837 return adjustedDelta; | 837 return adjustedDelta; |
838 } | 838 } |
839 | 839 |
840 static inline IntSize adjustedScrollDelta(const IntSize& delta) | 840 static inline IntSize adjustedScrollDelta(const IntSize& delta) |
841 { | 841 { |
842 return IntSize(adjustedScrollDelta(delta.width()), adjustedScrollDelta(delta
.height())); | 842 return IntSize(adjustedScrollDelta(delta.width()), adjustedScrollDelta(delta
.height())); |
843 } | 843 } |
844 | 844 |
845 void RenderBox::panScroll(const IntPoint& sourcePoint) | 845 void LayoutBox::panScroll(const IntPoint& sourcePoint) |
846 { | 846 { |
847 LocalFrame* frame = this->frame(); | 847 LocalFrame* frame = this->frame(); |
848 if (!frame) | 848 if (!frame) |
849 return; | 849 return; |
850 | 850 |
851 IntPoint lastKnownMousePosition = frame->eventHandler().lastKnownMousePositi
on(); | 851 IntPoint lastKnownMousePosition = frame->eventHandler().lastKnownMousePositi
on(); |
852 | 852 |
853 // We need to check if the last known mouse position is out of the window. W
hen the mouse is out of the window, the position is incoherent | 853 // We need to check if the last known mouse position is out of the window. W
hen the mouse is out of the window, the position is incoherent |
854 static IntPoint previousMousePosition; | 854 static IntPoint previousMousePosition; |
855 if (lastKnownMousePosition.x() < 0 || lastKnownMousePosition.y() < 0) | 855 if (lastKnownMousePosition.x() < 0 || lastKnownMousePosition.y() < 0) |
856 lastKnownMousePosition = previousMousePosition; | 856 lastKnownMousePosition = previousMousePosition; |
857 else | 857 else |
858 previousMousePosition = lastKnownMousePosition; | 858 previousMousePosition = lastKnownMousePosition; |
859 | 859 |
860 IntSize delta = lastKnownMousePosition - sourcePoint; | 860 IntSize delta = lastKnownMousePosition - sourcePoint; |
861 | 861 |
862 if (abs(delta.width()) <= FrameView::noPanScrollRadius) // at the center we
let the space for the icon | 862 if (abs(delta.width()) <= FrameView::noPanScrollRadius) // at the center we
let the space for the icon |
863 delta.setWidth(0); | 863 delta.setWidth(0); |
864 if (abs(delta.height()) <= FrameView::noPanScrollRadius) | 864 if (abs(delta.height()) <= FrameView::noPanScrollRadius) |
865 delta.setHeight(0); | 865 delta.setHeight(0); |
866 scrollByRecursively(adjustedScrollDelta(delta), ScrollOffsetClamped); | 866 scrollByRecursively(adjustedScrollDelta(delta), ScrollOffsetClamped); |
867 } | 867 } |
868 | 868 |
869 void RenderBox::scrollByRecursively(const DoubleSize& delta, ScrollOffsetClampin
g clamp) | 869 void LayoutBox::scrollByRecursively(const DoubleSize& delta, ScrollOffsetClampin
g clamp) |
870 { | 870 { |
871 if (delta.isZero()) | 871 if (delta.isZero()) |
872 return; | 872 return; |
873 | 873 |
874 bool restrictedByLineClamp = false; | 874 bool restrictedByLineClamp = false; |
875 if (parent()) | 875 if (parent()) |
876 restrictedByLineClamp = !parent()->style()->lineClamp().isNone(); | 876 restrictedByLineClamp = !parent()->style()->lineClamp().isNone(); |
877 | 877 |
878 if (hasOverflowClip() && !restrictedByLineClamp) { | 878 if (hasOverflowClip() && !restrictedByLineClamp) { |
879 DoubleSize newScrollOffset = layer()->scrollableArea()->adjustedScrollOf
fset() + delta; | 879 DoubleSize newScrollOffset = layer()->scrollableArea()->adjustedScrollOf
fset() + delta; |
880 layer()->scrollableArea()->scrollToOffset(newScrollOffset, clamp); | 880 layer()->scrollableArea()->scrollToOffset(newScrollOffset, clamp); |
881 | 881 |
882 // If this layer can't do the scroll we ask the next layer up that can s
croll to try | 882 // If this layer can't do the scroll we ask the next layer up that can s
croll to try |
883 DoubleSize remainingScrollOffset = newScrollOffset - layer()->scrollable
Area()->adjustedScrollOffset(); | 883 DoubleSize remainingScrollOffset = newScrollOffset - layer()->scrollable
Area()->adjustedScrollOffset(); |
884 if (!remainingScrollOffset.isZero() && parent()) { | 884 if (!remainingScrollOffset.isZero() && parent()) { |
885 if (RenderBox* scrollableBox = enclosingScrollableBox()) | 885 if (LayoutBox* scrollableBox = enclosingScrollableBox()) |
886 scrollableBox->scrollByRecursively(remainingScrollOffset, clamp)
; | 886 scrollableBox->scrollByRecursively(remainingScrollOffset, clamp)
; |
887 | 887 |
888 LocalFrame* frame = this->frame(); | 888 LocalFrame* frame = this->frame(); |
889 if (frame && frame->page()) | 889 if (frame && frame->page()) |
890 frame->page()->autoscrollController().updateAutoscrollRenderer()
; | 890 frame->page()->autoscrollController().updateAutoscrollRenderer()
; |
891 } | 891 } |
892 } else if (view()->frameView()) { | 892 } else if (view()->frameView()) { |
893 // If we are here, we were called on a renderer that can be programmatic
ally scrolled, but doesn't | 893 // If we are here, we were called on a renderer that can be programmatic
ally scrolled, but doesn't |
894 // have an overflow clip. Which means that it is a document node that ca
n be scrolled. | 894 // have an overflow clip. Which means that it is a document node that ca
n be scrolled. |
895 // FIXME: Pass in DoubleSize. crbug.com/414283. | 895 // FIXME: Pass in DoubleSize. crbug.com/414283. |
896 view()->frameView()->scrollBy(flooredIntSize(delta)); | 896 view()->frameView()->scrollBy(flooredIntSize(delta)); |
897 | 897 |
898 // FIXME: If we didn't scroll the whole way, do we want to try looking a
t the frames ownerElement? | 898 // FIXME: If we didn't scroll the whole way, do we want to try looking a
t the frames ownerElement? |
899 // https://bugs.webkit.org/show_bug.cgi?id=28237 | 899 // https://bugs.webkit.org/show_bug.cgi?id=28237 |
900 } | 900 } |
901 } | 901 } |
902 | 902 |
903 bool RenderBox::needsPreferredWidthsRecalculation() const | 903 bool LayoutBox::needsPreferredWidthsRecalculation() const |
904 { | 904 { |
905 return style()->paddingStart().isPercent() || style()->paddingEnd().isPercen
t(); | 905 return style()->paddingStart().isPercent() || style()->paddingEnd().isPercen
t(); |
906 } | 906 } |
907 | 907 |
908 IntSize RenderBox::scrolledContentOffset() const | 908 IntSize LayoutBox::scrolledContentOffset() const |
909 { | 909 { |
910 ASSERT(hasOverflowClip()); | 910 ASSERT(hasOverflowClip()); |
911 ASSERT(hasLayer()); | 911 ASSERT(hasLayer()); |
912 // FIXME: Return DoubleSize here. crbug.com/414283. | 912 // FIXME: Return DoubleSize here. crbug.com/414283. |
913 return flooredIntSize(layer()->scrollableArea()->scrollOffset()); | 913 return flooredIntSize(layer()->scrollableArea()->scrollOffset()); |
914 } | 914 } |
915 | 915 |
916 void RenderBox::applyCachedClipAndScrollOffsetForPaintInvalidation(LayoutRect& p
aintRect) const | 916 void LayoutBox::applyCachedClipAndScrollOffsetForPaintInvalidation(LayoutRect& p
aintRect) const |
917 { | 917 { |
918 ASSERT(hasLayer()); | 918 ASSERT(hasLayer()); |
919 ASSERT(hasOverflowClip()); | 919 ASSERT(hasOverflowClip()); |
920 | 920 |
921 flipForWritingMode(paintRect); | 921 flipForWritingMode(paintRect); |
922 paintRect.move(-scrolledContentOffset()); // For overflow:auto/scroll/hidden
. | 922 paintRect.move(-scrolledContentOffset()); // For overflow:auto/scroll/hidden
. |
923 | 923 |
924 // Do not clip scroll layer contents because the compositor expects the whol
e layer | 924 // Do not clip scroll layer contents because the compositor expects the whol
e layer |
925 // to be always invalidated in-time. | 925 // to be always invalidated in-time. |
926 if (usesCompositedScrolling()) { | 926 if (usesCompositedScrolling()) { |
927 flipForWritingMode(paintRect); | 927 flipForWritingMode(paintRect); |
928 return; | 928 return; |
929 } | 929 } |
930 | 930 |
931 // size() is inaccurate if we're in the middle of a layout of this RenderBox
, so use the | 931 // size() is inaccurate if we're in the middle of a layout of this LayoutBox
, so use the |
932 // layer's size instead. Even if the layer's size is wrong, the layer itself
will issue paint invalidations | 932 // layer's size instead. Even if the layer's size is wrong, the layer itself
will issue paint invalidations |
933 // anyway if its size does change. | 933 // anyway if its size does change. |
934 LayoutRect clipRect(LayoutPoint(), LayoutSize(layer()->size())); | 934 LayoutRect clipRect(LayoutPoint(), LayoutSize(layer()->size())); |
935 paintRect = intersection(paintRect, clipRect); | 935 paintRect = intersection(paintRect, clipRect); |
936 flipForWritingMode(paintRect); | 936 flipForWritingMode(paintRect); |
937 } | 937 } |
938 | 938 |
939 void RenderBox::computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, Layou
tUnit& maxLogicalWidth) const | 939 void LayoutBox::computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, Layou
tUnit& maxLogicalWidth) const |
940 { | 940 { |
941 minLogicalWidth = minPreferredLogicalWidth() - borderAndPaddingLogicalWidth(
); | 941 minLogicalWidth = minPreferredLogicalWidth() - borderAndPaddingLogicalWidth(
); |
942 maxLogicalWidth = maxPreferredLogicalWidth() - borderAndPaddingLogicalWidth(
); | 942 maxLogicalWidth = maxPreferredLogicalWidth() - borderAndPaddingLogicalWidth(
); |
943 } | 943 } |
944 | 944 |
945 LayoutUnit RenderBox::minPreferredLogicalWidth() const | 945 LayoutUnit LayoutBox::minPreferredLogicalWidth() const |
946 { | 946 { |
947 if (preferredLogicalWidthsDirty()) { | 947 if (preferredLogicalWidthsDirty()) { |
948 #if ENABLE(ASSERT) | 948 #if ENABLE(ASSERT) |
949 SetLayoutNeededForbiddenScope layoutForbiddenScope(const_cast<RenderBox&
>(*this)); | 949 SetLayoutNeededForbiddenScope layoutForbiddenScope(const_cast<LayoutBox&
>(*this)); |
950 #endif | 950 #endif |
951 const_cast<RenderBox*>(this)->computePreferredLogicalWidths(); | 951 const_cast<LayoutBox*>(this)->computePreferredLogicalWidths(); |
952 } | 952 } |
953 | 953 |
954 return m_minPreferredLogicalWidth; | 954 return m_minPreferredLogicalWidth; |
955 } | 955 } |
956 | 956 |
957 LayoutUnit RenderBox::maxPreferredLogicalWidth() const | 957 LayoutUnit LayoutBox::maxPreferredLogicalWidth() const |
958 { | 958 { |
959 if (preferredLogicalWidthsDirty()) { | 959 if (preferredLogicalWidthsDirty()) { |
960 #if ENABLE(ASSERT) | 960 #if ENABLE(ASSERT) |
961 SetLayoutNeededForbiddenScope layoutForbiddenScope(const_cast<RenderBox&
>(*this)); | 961 SetLayoutNeededForbiddenScope layoutForbiddenScope(const_cast<LayoutBox&
>(*this)); |
962 #endif | 962 #endif |
963 const_cast<RenderBox*>(this)->computePreferredLogicalWidths(); | 963 const_cast<LayoutBox*>(this)->computePreferredLogicalWidths(); |
964 } | 964 } |
965 | 965 |
966 return m_maxPreferredLogicalWidth; | 966 return m_maxPreferredLogicalWidth; |
967 } | 967 } |
968 | 968 |
969 bool RenderBox::hasOverrideHeight() const | 969 bool LayoutBox::hasOverrideHeight() const |
970 { | 970 { |
971 return m_rareData && m_rareData->m_overrideLogicalContentHeight != -1; | 971 return m_rareData && m_rareData->m_overrideLogicalContentHeight != -1; |
972 } | 972 } |
973 | 973 |
974 bool RenderBox::hasOverrideWidth() const | 974 bool LayoutBox::hasOverrideWidth() const |
975 { | 975 { |
976 return m_rareData && m_rareData->m_overrideLogicalContentWidth != -1; | 976 return m_rareData && m_rareData->m_overrideLogicalContentWidth != -1; |
977 } | 977 } |
978 | 978 |
979 void RenderBox::setOverrideLogicalContentHeight(LayoutUnit height) | 979 void LayoutBox::setOverrideLogicalContentHeight(LayoutUnit height) |
980 { | 980 { |
981 ASSERT(height >= 0); | 981 ASSERT(height >= 0); |
982 ensureRareData().m_overrideLogicalContentHeight = height; | 982 ensureRareData().m_overrideLogicalContentHeight = height; |
983 } | 983 } |
984 | 984 |
985 void RenderBox::setOverrideLogicalContentWidth(LayoutUnit width) | 985 void LayoutBox::setOverrideLogicalContentWidth(LayoutUnit width) |
986 { | 986 { |
987 ASSERT(width >= 0); | 987 ASSERT(width >= 0); |
988 ensureRareData().m_overrideLogicalContentWidth = width; | 988 ensureRareData().m_overrideLogicalContentWidth = width; |
989 } | 989 } |
990 | 990 |
991 void RenderBox::clearOverrideLogicalContentHeight() | 991 void LayoutBox::clearOverrideLogicalContentHeight() |
992 { | 992 { |
993 if (m_rareData) | 993 if (m_rareData) |
994 m_rareData->m_overrideLogicalContentHeight = -1; | 994 m_rareData->m_overrideLogicalContentHeight = -1; |
995 } | 995 } |
996 | 996 |
997 void RenderBox::clearOverrideLogicalContentWidth() | 997 void LayoutBox::clearOverrideLogicalContentWidth() |
998 { | 998 { |
999 if (m_rareData) | 999 if (m_rareData) |
1000 m_rareData->m_overrideLogicalContentWidth = -1; | 1000 m_rareData->m_overrideLogicalContentWidth = -1; |
1001 } | 1001 } |
1002 | 1002 |
1003 void RenderBox::clearOverrideSize() | 1003 void LayoutBox::clearOverrideSize() |
1004 { | 1004 { |
1005 clearOverrideLogicalContentHeight(); | 1005 clearOverrideLogicalContentHeight(); |
1006 clearOverrideLogicalContentWidth(); | 1006 clearOverrideLogicalContentWidth(); |
1007 } | 1007 } |
1008 | 1008 |
1009 LayoutUnit RenderBox::overrideLogicalContentWidth() const | 1009 LayoutUnit LayoutBox::overrideLogicalContentWidth() const |
1010 { | 1010 { |
1011 ASSERT(hasOverrideWidth()); | 1011 ASSERT(hasOverrideWidth()); |
1012 return m_rareData->m_overrideLogicalContentWidth; | 1012 return m_rareData->m_overrideLogicalContentWidth; |
1013 } | 1013 } |
1014 | 1014 |
1015 LayoutUnit RenderBox::overrideLogicalContentHeight() const | 1015 LayoutUnit LayoutBox::overrideLogicalContentHeight() const |
1016 { | 1016 { |
1017 ASSERT(hasOverrideHeight()); | 1017 ASSERT(hasOverrideHeight()); |
1018 return m_rareData->m_overrideLogicalContentHeight; | 1018 return m_rareData->m_overrideLogicalContentHeight; |
1019 } | 1019 } |
1020 | 1020 |
1021 LayoutUnit RenderBox::overrideContainingBlockContentLogicalWidth() const | 1021 LayoutUnit LayoutBox::overrideContainingBlockContentLogicalWidth() const |
1022 { | 1022 { |
1023 ASSERT(hasOverrideContainingBlockLogicalWidth()); | 1023 ASSERT(hasOverrideContainingBlockLogicalWidth()); |
1024 return gOverrideContainingBlockLogicalWidthMap->get(this); | 1024 return gOverrideContainingBlockLogicalWidthMap->get(this); |
1025 } | 1025 } |
1026 | 1026 |
1027 LayoutUnit RenderBox::overrideContainingBlockContentLogicalHeight() const | 1027 LayoutUnit LayoutBox::overrideContainingBlockContentLogicalHeight() const |
1028 { | 1028 { |
1029 ASSERT(hasOverrideContainingBlockLogicalHeight()); | 1029 ASSERT(hasOverrideContainingBlockLogicalHeight()); |
1030 return gOverrideContainingBlockLogicalHeightMap->get(this); | 1030 return gOverrideContainingBlockLogicalHeightMap->get(this); |
1031 } | 1031 } |
1032 | 1032 |
1033 bool RenderBox::hasOverrideContainingBlockLogicalWidth() const | 1033 bool LayoutBox::hasOverrideContainingBlockLogicalWidth() const |
1034 { | 1034 { |
1035 return gOverrideContainingBlockLogicalWidthMap && gOverrideContainingBlockLo
gicalWidthMap->contains(this); | 1035 return gOverrideContainingBlockLogicalWidthMap && gOverrideContainingBlockLo
gicalWidthMap->contains(this); |
1036 } | 1036 } |
1037 | 1037 |
1038 bool RenderBox::hasOverrideContainingBlockLogicalHeight() const | 1038 bool LayoutBox::hasOverrideContainingBlockLogicalHeight() const |
1039 { | 1039 { |
1040 return gOverrideContainingBlockLogicalHeightMap && gOverrideContainingBlockL
ogicalHeightMap->contains(this); | 1040 return gOverrideContainingBlockLogicalHeightMap && gOverrideContainingBlockL
ogicalHeightMap->contains(this); |
1041 } | 1041 } |
1042 | 1042 |
1043 void RenderBox::setOverrideContainingBlockContentLogicalWidth(LayoutUnit logical
Width) | 1043 void LayoutBox::setOverrideContainingBlockContentLogicalWidth(LayoutUnit logical
Width) |
1044 { | 1044 { |
1045 if (!gOverrideContainingBlockLogicalWidthMap) | 1045 if (!gOverrideContainingBlockLogicalWidthMap) |
1046 gOverrideContainingBlockLogicalWidthMap = new OverrideSizeMap; | 1046 gOverrideContainingBlockLogicalWidthMap = new OverrideSizeMap; |
1047 gOverrideContainingBlockLogicalWidthMap->set(this, logicalWidth); | 1047 gOverrideContainingBlockLogicalWidthMap->set(this, logicalWidth); |
1048 } | 1048 } |
1049 | 1049 |
1050 void RenderBox::setOverrideContainingBlockContentLogicalHeight(LayoutUnit logica
lHeight) | 1050 void LayoutBox::setOverrideContainingBlockContentLogicalHeight(LayoutUnit logica
lHeight) |
1051 { | 1051 { |
1052 if (!gOverrideContainingBlockLogicalHeightMap) | 1052 if (!gOverrideContainingBlockLogicalHeightMap) |
1053 gOverrideContainingBlockLogicalHeightMap = new OverrideSizeMap; | 1053 gOverrideContainingBlockLogicalHeightMap = new OverrideSizeMap; |
1054 gOverrideContainingBlockLogicalHeightMap->set(this, logicalHeight); | 1054 gOverrideContainingBlockLogicalHeightMap->set(this, logicalHeight); |
1055 } | 1055 } |
1056 | 1056 |
1057 void RenderBox::clearContainingBlockOverrideSize() | 1057 void LayoutBox::clearContainingBlockOverrideSize() |
1058 { | 1058 { |
1059 if (gOverrideContainingBlockLogicalWidthMap) | 1059 if (gOverrideContainingBlockLogicalWidthMap) |
1060 gOverrideContainingBlockLogicalWidthMap->remove(this); | 1060 gOverrideContainingBlockLogicalWidthMap->remove(this); |
1061 clearOverrideContainingBlockContentLogicalHeight(); | 1061 clearOverrideContainingBlockContentLogicalHeight(); |
1062 } | 1062 } |
1063 | 1063 |
1064 void RenderBox::clearOverrideContainingBlockContentLogicalHeight() | 1064 void LayoutBox::clearOverrideContainingBlockContentLogicalHeight() |
1065 { | 1065 { |
1066 if (gOverrideContainingBlockLogicalHeightMap) | 1066 if (gOverrideContainingBlockLogicalHeightMap) |
1067 gOverrideContainingBlockLogicalHeightMap->remove(this); | 1067 gOverrideContainingBlockLogicalHeightMap->remove(this); |
1068 } | 1068 } |
1069 | 1069 |
1070 LayoutUnit RenderBox::extraInlineOffset() const | 1070 LayoutUnit LayoutBox::extraInlineOffset() const |
1071 { | 1071 { |
1072 return gExtraInlineOffsetMap ? gExtraInlineOffsetMap->get(this) : LayoutUnit
(); | 1072 return gExtraInlineOffsetMap ? gExtraInlineOffsetMap->get(this) : LayoutUnit
(); |
1073 } | 1073 } |
1074 | 1074 |
1075 LayoutUnit RenderBox::extraBlockOffset() const | 1075 LayoutUnit LayoutBox::extraBlockOffset() const |
1076 { | 1076 { |
1077 return gExtraBlockOffsetMap ? gExtraBlockOffsetMap->get(this) : LayoutUnit()
; | 1077 return gExtraBlockOffsetMap ? gExtraBlockOffsetMap->get(this) : LayoutUnit()
; |
1078 } | 1078 } |
1079 | 1079 |
1080 void RenderBox::setExtraInlineOffset(LayoutUnit inlineOffest) | 1080 void LayoutBox::setExtraInlineOffset(LayoutUnit inlineOffest) |
1081 { | 1081 { |
1082 if (!gExtraInlineOffsetMap) | 1082 if (!gExtraInlineOffsetMap) |
1083 gExtraInlineOffsetMap = new OverrideSizeMap; | 1083 gExtraInlineOffsetMap = new OverrideSizeMap; |
1084 gExtraInlineOffsetMap->set(this, inlineOffest); | 1084 gExtraInlineOffsetMap->set(this, inlineOffest); |
1085 } | 1085 } |
1086 | 1086 |
1087 void RenderBox::setExtraBlockOffset(LayoutUnit blockOffest) | 1087 void LayoutBox::setExtraBlockOffset(LayoutUnit blockOffest) |
1088 { | 1088 { |
1089 if (!gExtraBlockOffsetMap) | 1089 if (!gExtraBlockOffsetMap) |
1090 gExtraBlockOffsetMap = new OverrideSizeMap; | 1090 gExtraBlockOffsetMap = new OverrideSizeMap; |
1091 gExtraBlockOffsetMap->set(this, blockOffest); | 1091 gExtraBlockOffsetMap->set(this, blockOffest); |
1092 } | 1092 } |
1093 | 1093 |
1094 void RenderBox::clearExtraInlineAndBlockOffests() | 1094 void LayoutBox::clearExtraInlineAndBlockOffests() |
1095 { | 1095 { |
1096 if (gExtraInlineOffsetMap) | 1096 if (gExtraInlineOffsetMap) |
1097 gExtraInlineOffsetMap->remove(this); | 1097 gExtraInlineOffsetMap->remove(this); |
1098 if (gExtraBlockOffsetMap) | 1098 if (gExtraBlockOffsetMap) |
1099 gExtraBlockOffsetMap->remove(this); | 1099 gExtraBlockOffsetMap->remove(this); |
1100 } | 1100 } |
1101 | 1101 |
1102 LayoutUnit RenderBox::adjustBorderBoxLogicalWidthForBoxSizing(LayoutUnit width)
const | 1102 LayoutUnit LayoutBox::adjustBorderBoxLogicalWidthForBoxSizing(LayoutUnit width)
const |
1103 { | 1103 { |
1104 LayoutUnit bordersPlusPadding = borderAndPaddingLogicalWidth(); | 1104 LayoutUnit bordersPlusPadding = borderAndPaddingLogicalWidth(); |
1105 if (style()->boxSizing() == CONTENT_BOX) | 1105 if (style()->boxSizing() == CONTENT_BOX) |
1106 return width + bordersPlusPadding; | 1106 return width + bordersPlusPadding; |
1107 return std::max(width, bordersPlusPadding); | 1107 return std::max(width, bordersPlusPadding); |
1108 } | 1108 } |
1109 | 1109 |
1110 LayoutUnit RenderBox::adjustBorderBoxLogicalHeightForBoxSizing(LayoutUnit height
) const | 1110 LayoutUnit LayoutBox::adjustBorderBoxLogicalHeightForBoxSizing(LayoutUnit height
) const |
1111 { | 1111 { |
1112 LayoutUnit bordersPlusPadding = borderAndPaddingLogicalHeight(); | 1112 LayoutUnit bordersPlusPadding = borderAndPaddingLogicalHeight(); |
1113 if (style()->boxSizing() == CONTENT_BOX) | 1113 if (style()->boxSizing() == CONTENT_BOX) |
1114 return height + bordersPlusPadding; | 1114 return height + bordersPlusPadding; |
1115 return std::max(height, bordersPlusPadding); | 1115 return std::max(height, bordersPlusPadding); |
1116 } | 1116 } |
1117 | 1117 |
1118 LayoutUnit RenderBox::adjustContentBoxLogicalWidthForBoxSizing(LayoutUnit width)
const | 1118 LayoutUnit LayoutBox::adjustContentBoxLogicalWidthForBoxSizing(LayoutUnit width)
const |
1119 { | 1119 { |
1120 if (style()->boxSizing() == BORDER_BOX) | 1120 if (style()->boxSizing() == BORDER_BOX) |
1121 width -= borderAndPaddingLogicalWidth(); | 1121 width -= borderAndPaddingLogicalWidth(); |
1122 return std::max(LayoutUnit(), width); | 1122 return std::max(LayoutUnit(), width); |
1123 } | 1123 } |
1124 | 1124 |
1125 LayoutUnit RenderBox::adjustContentBoxLogicalHeightForBoxSizing(LayoutUnit heigh
t) const | 1125 LayoutUnit LayoutBox::adjustContentBoxLogicalHeightForBoxSizing(LayoutUnit heigh
t) const |
1126 { | 1126 { |
1127 if (style()->boxSizing() == BORDER_BOX) | 1127 if (style()->boxSizing() == BORDER_BOX) |
1128 height -= borderAndPaddingLogicalHeight(); | 1128 height -= borderAndPaddingLogicalHeight(); |
1129 return std::max(LayoutUnit(), height); | 1129 return std::max(LayoutUnit(), height); |
1130 } | 1130 } |
1131 | 1131 |
1132 // Hit Testing | 1132 // Hit Testing |
1133 bool RenderBox::nodeAtPoint(const HitTestRequest& request, HitTestResult& result
, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffs
et, HitTestAction action) | 1133 bool LayoutBox::nodeAtPoint(const HitTestRequest& request, HitTestResult& result
, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffs
et, HitTestAction action) |
1134 { | 1134 { |
1135 LayoutPoint adjustedLocation = accumulatedOffset + location(); | 1135 LayoutPoint adjustedLocation = accumulatedOffset + location(); |
1136 | 1136 |
1137 // Check kids first. | 1137 // Check kids first. |
1138 for (LayoutObject* child = slowLastChild(); child; child = child->previousSi
bling()) { | 1138 for (LayoutObject* child = slowLastChild(); child; child = child->previousSi
bling()) { |
1139 if ((!child->hasLayer() || !toLayoutBoxModelObject(child)->layer()->isSe
lfPaintingLayer()) && child->nodeAtPoint(request, result, locationInContainer, a
djustedLocation, action)) { | 1139 if ((!child->hasLayer() || !toLayoutBoxModelObject(child)->layer()->isSe
lfPaintingLayer()) && child->nodeAtPoint(request, result, locationInContainer, a
djustedLocation, action)) { |
1140 updateHitTestResult(result, locationInContainer.point() - toLayoutSi
ze(adjustedLocation)); | 1140 updateHitTestResult(result, locationInContainer.point() - toLayoutSi
ze(adjustedLocation)); |
1141 return true; | 1141 return true; |
1142 } | 1142 } |
1143 } | 1143 } |
1144 | 1144 |
1145 // Check our bounds next. For this purpose always assume that we can only be
hit in the | 1145 // Check our bounds next. For this purpose always assume that we can only be
hit in the |
1146 // foreground phase (which is true for replaced elements like images). | 1146 // foreground phase (which is true for replaced elements like images). |
1147 LayoutRect boundsRect = borderBoxRect(); | 1147 LayoutRect boundsRect = borderBoxRect(); |
1148 boundsRect.moveBy(adjustedLocation); | 1148 boundsRect.moveBy(adjustedLocation); |
1149 if (visibleToHitTestRequest(request) && action == HitTestForeground && locat
ionInContainer.intersects(boundsRect)) { | 1149 if (visibleToHitTestRequest(request) && action == HitTestForeground && locat
ionInContainer.intersects(boundsRect)) { |
1150 updateHitTestResult(result, locationInContainer.point() - toLayoutSize(a
djustedLocation)); | 1150 updateHitTestResult(result, locationInContainer.point() - toLayoutSize(a
djustedLocation)); |
1151 if (!result.addNodeToListBasedTestResult(node(), request, locationInCont
ainer, boundsRect)) | 1151 if (!result.addNodeToListBasedTestResult(node(), request, locationInCont
ainer, boundsRect)) |
1152 return true; | 1152 return true; |
1153 } | 1153 } |
1154 | 1154 |
1155 return false; | 1155 return false; |
1156 } | 1156 } |
1157 | 1157 |
1158 void RenderBox::paint(const PaintInfo& paintInfo, const LayoutPoint& paintOffset
) | 1158 void LayoutBox::paint(const PaintInfo& paintInfo, const LayoutPoint& paintOffset
) |
1159 { | 1159 { |
1160 BoxPainter(*this).paint(paintInfo, paintOffset); | 1160 BoxPainter(*this).paint(paintInfo, paintOffset); |
1161 } | 1161 } |
1162 | 1162 |
1163 | 1163 |
1164 void RenderBox::paintBoxDecorationBackground(const PaintInfo& paintInfo, const L
ayoutPoint& paintOffset) | 1164 void LayoutBox::paintBoxDecorationBackground(const PaintInfo& paintInfo, const L
ayoutPoint& paintOffset) |
1165 { | 1165 { |
1166 BoxPainter(*this).paintBoxDecorationBackground(paintInfo, paintOffset); | 1166 BoxPainter(*this).paintBoxDecorationBackground(paintInfo, paintOffset); |
1167 } | 1167 } |
1168 | 1168 |
1169 | 1169 |
1170 bool RenderBox::getBackgroundPaintedExtent(LayoutRect& paintedExtent) | 1170 bool LayoutBox::getBackgroundPaintedExtent(LayoutRect& paintedExtent) |
1171 { | 1171 { |
1172 ASSERT(hasBackground()); | 1172 ASSERT(hasBackground()); |
1173 LayoutRect backgroundRect = pixelSnappedIntRect(borderBoxRect()); | 1173 LayoutRect backgroundRect = pixelSnappedIntRect(borderBoxRect()); |
1174 | 1174 |
1175 Color backgroundColor = resolveColor(CSSPropertyBackgroundColor); | 1175 Color backgroundColor = resolveColor(CSSPropertyBackgroundColor); |
1176 if (backgroundColor.alpha()) { | 1176 if (backgroundColor.alpha()) { |
1177 paintedExtent = backgroundRect; | 1177 paintedExtent = backgroundRect; |
1178 return true; | 1178 return true; |
1179 } | 1179 } |
1180 | 1180 |
1181 if (!style()->backgroundLayers().image() || style()->backgroundLayers().next
()) { | 1181 if (!style()->backgroundLayers().image() || style()->backgroundLayers().next
()) { |
1182 paintedExtent = backgroundRect; | 1182 paintedExtent = backgroundRect; |
1183 return true; | 1183 return true; |
1184 } | 1184 } |
1185 | 1185 |
1186 BackgroundImageGeometry geometry; | 1186 BackgroundImageGeometry geometry; |
1187 BoxPainter::calculateBackgroundImageGeometry(*this, 0, style()->backgroundLa
yers(), backgroundRect, geometry); | 1187 BoxPainter::calculateBackgroundImageGeometry(*this, 0, style()->backgroundLa
yers(), backgroundRect, geometry); |
1188 if (geometry.hasNonLocalGeometry()) | 1188 if (geometry.hasNonLocalGeometry()) |
1189 return false; | 1189 return false; |
1190 paintedExtent = geometry.destRect(); | 1190 paintedExtent = geometry.destRect(); |
1191 return true; | 1191 return true; |
1192 } | 1192 } |
1193 | 1193 |
1194 bool RenderBox::backgroundIsKnownToBeOpaqueInRect(const LayoutRect& localRect) c
onst | 1194 bool LayoutBox::backgroundIsKnownToBeOpaqueInRect(const LayoutRect& localRect) c
onst |
1195 { | 1195 { |
1196 if (isBody() && skipBodyBackground(this)) | 1196 if (isBody() && skipBodyBackground(this)) |
1197 return false; | 1197 return false; |
1198 | 1198 |
1199 Color backgroundColor = resolveColor(CSSPropertyBackgroundColor); | 1199 Color backgroundColor = resolveColor(CSSPropertyBackgroundColor); |
1200 if (backgroundColor.hasAlpha()) | 1200 if (backgroundColor.hasAlpha()) |
1201 return false; | 1201 return false; |
1202 | 1202 |
1203 // If the element has appearance, it might be painted by theme. | 1203 // If the element has appearance, it might be painted by theme. |
1204 // We cannot be sure if theme paints the background opaque. | 1204 // We cannot be sure if theme paints the background opaque. |
(...skipping 19 matching lines...) Expand all Loading... |
1224 break; | 1224 break; |
1225 case ContentFillBox: | 1225 case ContentFillBox: |
1226 backgroundRect = contentBoxRect(); | 1226 backgroundRect = contentBoxRect(); |
1227 break; | 1227 break; |
1228 default: | 1228 default: |
1229 break; | 1229 break; |
1230 } | 1230 } |
1231 return backgroundRect.contains(localRect); | 1231 return backgroundRect.contains(localRect); |
1232 } | 1232 } |
1233 | 1233 |
1234 static bool isCandidateForOpaquenessTest(const RenderBox& childBox) | 1234 static bool isCandidateForOpaquenessTest(const LayoutBox& childBox) |
1235 { | 1235 { |
1236 const LayoutStyle& childStyle = childBox.styleRef(); | 1236 const LayoutStyle& childStyle = childBox.styleRef(); |
1237 if (childStyle.position() != StaticPosition && childBox.containingBlock() !=
childBox.parent()) | 1237 if (childStyle.position() != StaticPosition && childBox.containingBlock() !=
childBox.parent()) |
1238 return false; | 1238 return false; |
1239 if (childStyle.visibility() != VISIBLE || childStyle.shapeOutside()) | 1239 if (childStyle.visibility() != VISIBLE || childStyle.shapeOutside()) |
1240 return false; | 1240 return false; |
1241 if (childBox.size().isZero()) | 1241 if (childBox.size().isZero()) |
1242 return false; | 1242 return false; |
1243 if (Layer* childLayer = childBox.layer()) { | 1243 if (Layer* childLayer = childBox.layer()) { |
1244 // FIXME: perhaps this could be less conservative? | 1244 // FIXME: perhaps this could be less conservative? |
1245 if (childLayer->compositingState() != NotComposited) | 1245 if (childLayer->compositingState() != NotComposited) |
1246 return false; | 1246 return false; |
1247 // FIXME: Deal with z-index. | 1247 // FIXME: Deal with z-index. |
1248 if (!childStyle.hasAutoZIndex()) | 1248 if (!childStyle.hasAutoZIndex()) |
1249 return false; | 1249 return false; |
1250 if (childLayer->hasTransformRelatedProperty() || childLayer->isTranspare
nt() || childLayer->hasFilter()) | 1250 if (childLayer->hasTransformRelatedProperty() || childLayer->isTranspare
nt() || childLayer->hasFilter()) |
1251 return false; | 1251 return false; |
1252 if (childBox.hasOverflowClip() && childStyle.hasBorderRadius()) | 1252 if (childBox.hasOverflowClip() && childStyle.hasBorderRadius()) |
1253 return false; | 1253 return false; |
1254 } | 1254 } |
1255 return true; | 1255 return true; |
1256 } | 1256 } |
1257 | 1257 |
1258 bool RenderBox::foregroundIsKnownToBeOpaqueInRect(const LayoutRect& localRect, u
nsigned maxDepthToTest) const | 1258 bool LayoutBox::foregroundIsKnownToBeOpaqueInRect(const LayoutRect& localRect, u
nsigned maxDepthToTest) const |
1259 { | 1259 { |
1260 if (!maxDepthToTest) | 1260 if (!maxDepthToTest) |
1261 return false; | 1261 return false; |
1262 for (LayoutObject* child = slowFirstChild(); child; child = child->nextSibli
ng()) { | 1262 for (LayoutObject* child = slowFirstChild(); child; child = child->nextSibli
ng()) { |
1263 if (!child->isBox()) | 1263 if (!child->isBox()) |
1264 continue; | 1264 continue; |
1265 RenderBox* childBox = toRenderBox(child); | 1265 LayoutBox* childBox = toLayoutBox(child); |
1266 if (!isCandidateForOpaquenessTest(*childBox)) | 1266 if (!isCandidateForOpaquenessTest(*childBox)) |
1267 continue; | 1267 continue; |
1268 LayoutPoint childLocation = childBox->location(); | 1268 LayoutPoint childLocation = childBox->location(); |
1269 if (childBox->isRelPositioned()) | 1269 if (childBox->isRelPositioned()) |
1270 childLocation.move(childBox->relativePositionOffset()); | 1270 childLocation.move(childBox->relativePositionOffset()); |
1271 LayoutRect childLocalRect = localRect; | 1271 LayoutRect childLocalRect = localRect; |
1272 childLocalRect.moveBy(-childLocation); | 1272 childLocalRect.moveBy(-childLocation); |
1273 if (childLocalRect.y() < 0 || childLocalRect.x() < 0) { | 1273 if (childLocalRect.y() < 0 || childLocalRect.x() < 0) { |
1274 // If there is unobscured area above/left of a static positioned box
then the rect is probably not covered. | 1274 // If there is unobscured area above/left of a static positioned box
then the rect is probably not covered. |
1275 if (childBox->style()->position() == StaticPosition) | 1275 if (childBox->style()->position() == StaticPosition) |
1276 return false; | 1276 return false; |
1277 continue; | 1277 continue; |
1278 } | 1278 } |
1279 if (childLocalRect.maxY() > childBox->size().height() || childLocalRect.
maxX() > childBox->size().width()) | 1279 if (childLocalRect.maxY() > childBox->size().height() || childLocalRect.
maxX() > childBox->size().width()) |
1280 continue; | 1280 continue; |
1281 if (childBox->backgroundIsKnownToBeOpaqueInRect(childLocalRect)) | 1281 if (childBox->backgroundIsKnownToBeOpaqueInRect(childLocalRect)) |
1282 return true; | 1282 return true; |
1283 if (childBox->foregroundIsKnownToBeOpaqueInRect(childLocalRect, maxDepth
ToTest - 1)) | 1283 if (childBox->foregroundIsKnownToBeOpaqueInRect(childLocalRect, maxDepth
ToTest - 1)) |
1284 return true; | 1284 return true; |
1285 } | 1285 } |
1286 return false; | 1286 return false; |
1287 } | 1287 } |
1288 | 1288 |
1289 bool RenderBox::computeBackgroundIsKnownToBeObscured() | 1289 bool LayoutBox::computeBackgroundIsKnownToBeObscured() |
1290 { | 1290 { |
1291 // Test to see if the children trivially obscure the background. | 1291 // Test to see if the children trivially obscure the background. |
1292 // FIXME: This test can be much more comprehensive. | 1292 // FIXME: This test can be much more comprehensive. |
1293 if (!hasBackground()) | 1293 if (!hasBackground()) |
1294 return false; | 1294 return false; |
1295 // Table and root background painting is special. | 1295 // Table and root background painting is special. |
1296 if (isTable() || isDocumentElement()) | 1296 if (isTable() || isDocumentElement()) |
1297 return false; | 1297 return false; |
1298 // FIXME: box-shadow is painted while background painting. | 1298 // FIXME: box-shadow is painted while background painting. |
1299 if (style()->boxShadow()) | 1299 if (style()->boxShadow()) |
1300 return false; | 1300 return false; |
1301 LayoutRect backgroundRect; | 1301 LayoutRect backgroundRect; |
1302 if (!getBackgroundPaintedExtent(backgroundRect)) | 1302 if (!getBackgroundPaintedExtent(backgroundRect)) |
1303 return false; | 1303 return false; |
1304 return foregroundIsKnownToBeOpaqueInRect(backgroundRect, backgroundObscurati
onTestMaxDepth); | 1304 return foregroundIsKnownToBeOpaqueInRect(backgroundRect, backgroundObscurati
onTestMaxDepth); |
1305 } | 1305 } |
1306 | 1306 |
1307 bool RenderBox::backgroundHasOpaqueTopLayer() const | 1307 bool LayoutBox::backgroundHasOpaqueTopLayer() const |
1308 { | 1308 { |
1309 const FillLayer& fillLayer = style()->backgroundLayers(); | 1309 const FillLayer& fillLayer = style()->backgroundLayers(); |
1310 if (fillLayer.clip() != BorderFillBox) | 1310 if (fillLayer.clip() != BorderFillBox) |
1311 return false; | 1311 return false; |
1312 | 1312 |
1313 // Clipped with local scrolling | 1313 // Clipped with local scrolling |
1314 if (hasOverflowClip() && fillLayer.attachment() == LocalBackgroundAttachment
) | 1314 if (hasOverflowClip() && fillLayer.attachment() == LocalBackgroundAttachment
) |
1315 return false; | 1315 return false; |
1316 | 1316 |
1317 if (fillLayer.hasOpaqueImage(this) && fillLayer.hasRepeatXY() && fillLayer.i
mage()->canRender(*this, style()->effectiveZoom())) | 1317 if (fillLayer.hasOpaqueImage(this) && fillLayer.hasRepeatXY() && fillLayer.i
mage()->canRender(*this, style()->effectiveZoom())) |
1318 return true; | 1318 return true; |
1319 | 1319 |
1320 // If there is only one layer and no image, check whether the background col
or is opaque | 1320 // If there is only one layer and no image, check whether the background col
or is opaque |
1321 if (!fillLayer.next() && !fillLayer.hasImage()) { | 1321 if (!fillLayer.next() && !fillLayer.hasImage()) { |
1322 Color bgColor = resolveColor(CSSPropertyBackgroundColor); | 1322 Color bgColor = resolveColor(CSSPropertyBackgroundColor); |
1323 if (bgColor.alpha() == 255) | 1323 if (bgColor.alpha() == 255) |
1324 return true; | 1324 return true; |
1325 } | 1325 } |
1326 | 1326 |
1327 return false; | 1327 return false; |
1328 } | 1328 } |
1329 | 1329 |
1330 void RenderBox::paintMask(const PaintInfo& paintInfo, const LayoutPoint& paintOf
fset) | 1330 void LayoutBox::paintMask(const PaintInfo& paintInfo, const LayoutPoint& paintOf
fset) |
1331 { | 1331 { |
1332 BoxPainter(*this).paintMask(paintInfo, paintOffset); | 1332 BoxPainter(*this).paintMask(paintInfo, paintOffset); |
1333 } | 1333 } |
1334 | 1334 |
1335 void RenderBox::paintClippingMask(const PaintInfo& paintInfo, const LayoutPoint&
paintOffset) | 1335 void LayoutBox::paintClippingMask(const PaintInfo& paintInfo, const LayoutPoint&
paintOffset) |
1336 { | 1336 { |
1337 BoxPainter(*this).paintClippingMask(paintInfo, paintOffset); | 1337 BoxPainter(*this).paintClippingMask(paintInfo, paintOffset); |
1338 } | 1338 } |
1339 | 1339 |
1340 void RenderBox::imageChanged(WrappedImagePtr image, const IntRect*) | 1340 void LayoutBox::imageChanged(WrappedImagePtr image, const IntRect*) |
1341 { | 1341 { |
1342 if (!parent()) | 1342 if (!parent()) |
1343 return; | 1343 return; |
1344 | 1344 |
1345 if ((style()->borderImage().image() && style()->borderImage().image()->data(
) == image) || | 1345 if ((style()->borderImage().image() && style()->borderImage().image()->data(
) == image) |
1346 (style()->maskBoxImage().image() && style()->maskBoxImage().image()->dat
a() == image)) { | 1346 || (style()->maskBoxImage().image() && style()->maskBoxImage().image()->
data() == image)) { |
1347 setShouldDoFullPaintInvalidation(); | 1347 setShouldDoFullPaintInvalidation(); |
1348 return; | 1348 return; |
1349 } | 1349 } |
1350 | 1350 |
1351 ShapeValue* shapeOutsideValue = style()->shapeOutside(); | 1351 ShapeValue* shapeOutsideValue = style()->shapeOutside(); |
1352 if (!frameView()->isInPerformLayout() && isFloating() && shapeOutsideValue &
& shapeOutsideValue->image() && shapeOutsideValue->image()->data() == image) { | 1352 if (!frameView()->isInPerformLayout() && isFloating() && shapeOutsideValue &
& shapeOutsideValue->image() && shapeOutsideValue->image()->data() == image) { |
1353 ShapeOutsideInfo& info = ShapeOutsideInfo::ensureInfo(*this); | 1353 ShapeOutsideInfo& info = ShapeOutsideInfo::ensureInfo(*this); |
1354 if (!info.isComputingShape()) { | 1354 if (!info.isComputingShape()) { |
1355 info.markShapeAsDirty(); | 1355 info.markShapeAsDirty(); |
1356 markShapeOutsideDependentsForLayout(); | 1356 markShapeOutsideDependentsForLayout(); |
1357 } | 1357 } |
1358 } | 1358 } |
1359 | 1359 |
1360 if (!paintInvalidationLayerRectsForImage(image, style()->backgroundLayers(),
true)) | 1360 if (!paintInvalidationLayerRectsForImage(image, style()->backgroundLayers(),
true)) |
1361 paintInvalidationLayerRectsForImage(image, style()->maskLayers(), false)
; | 1361 paintInvalidationLayerRectsForImage(image, style()->maskLayers(), false)
; |
1362 } | 1362 } |
1363 | 1363 |
1364 bool RenderBox::paintInvalidationLayerRectsForImage(WrappedImagePtr image, const
FillLayer& layers, bool drawingBackground) | 1364 bool LayoutBox::paintInvalidationLayerRectsForImage(WrappedImagePtr image, const
FillLayer& layers, bool drawingBackground) |
1365 { | 1365 { |
1366 Vector<LayoutObject*> layerRenderers; | 1366 Vector<LayoutObject*> layerRenderers; |
1367 | 1367 |
1368 // A background of the body or document must extend to the total visible siz
e of the document. This means the union of the | 1368 // A background of the body or document must extend to the total visible siz
e of the document. This means the union of the |
1369 // view and document bounds, since it can be the case that the view is large
r than the document and vice-versa. | 1369 // view and document bounds, since it can be the case that the view is large
r than the document and vice-versa. |
1370 // http://dev.w3.org/csswg/css-backgrounds/#the-background | 1370 // http://dev.w3.org/csswg/css-backgrounds/#the-background |
1371 if (drawingBackground && (isDocumentElement() || (isBody() && !document().do
cumentElement()->renderer()->hasBackground()))) { | 1371 if (drawingBackground && (isDocumentElement() || (isBody() && !document().do
cumentElement()->renderer()->hasBackground()))) { |
1372 layerRenderers.append(document().documentElement()->renderer()); | 1372 layerRenderers.append(document().documentElement()->renderer()); |
1373 layerRenderers.append(view()); | 1373 layerRenderers.append(view()); |
1374 if (view()->frameView()) | 1374 if (view()->frameView()) |
1375 view()->frameView()->setNeedsFullPaintInvalidation(); | 1375 view()->frameView()->setNeedsFullPaintInvalidation(); |
1376 } else { | 1376 } else { |
1377 layerRenderers.append(this); | 1377 layerRenderers.append(this); |
1378 } | 1378 } |
1379 for (const FillLayer* curLayer = &layers; curLayer; curLayer = curLayer->nex
t()) { | 1379 for (const FillLayer* curLayer = &layers; curLayer; curLayer = curLayer->nex
t()) { |
1380 if (curLayer->image() && image == curLayer->image()->data() && curLayer-
>image()->canRender(*this, style()->effectiveZoom())) { | 1380 if (curLayer->image() && image == curLayer->image()->data() && curLayer-
>image()->canRender(*this, style()->effectiveZoom())) { |
1381 for (LayoutObject* layerRenderer : layerRenderers) | 1381 for (LayoutObject* layerRenderer : layerRenderers) |
1382 layerRenderer->setShouldDoFullPaintInvalidation(); | 1382 layerRenderer->setShouldDoFullPaintInvalidation(); |
1383 return true; | 1383 return true; |
1384 } | 1384 } |
1385 } | 1385 } |
1386 return false; | 1386 return false; |
1387 } | 1387 } |
1388 | 1388 |
1389 PaintInvalidationReason RenderBox::invalidatePaintIfNeeded(const PaintInvalidati
onState& paintInvalidationState, const LayoutBoxModelObject& newPaintInvalidatio
nContainer) | 1389 PaintInvalidationReason LayoutBox::invalidatePaintIfNeeded(const PaintInvalidati
onState& paintInvalidationState, const LayoutBoxModelObject& newPaintInvalidatio
nContainer) |
1390 { | 1390 { |
1391 PaintInvalidationReason reason = LayoutBoxModelObject::invalidatePaintIfNeed
ed(paintInvalidationState, newPaintInvalidationContainer); | 1391 PaintInvalidationReason reason = LayoutBoxModelObject::invalidatePaintIfNeed
ed(paintInvalidationState, newPaintInvalidationContainer); |
1392 | 1392 |
1393 // If we are set to do a full paint invalidation that means the RenderView w
ill be | 1393 // If we are set to do a full paint invalidation that means the RenderView w
ill be |
1394 // issue paint invalidations. We can then skip issuing of paint invalidation
s for the child | 1394 // issue paint invalidations. We can then skip issuing of paint invalidation
s for the child |
1395 // renderers as they'll be covered by the RenderView. | 1395 // renderers as they'll be covered by the RenderView. |
1396 if (!view()->doingFullPaintInvalidation() && !isFullPaintInvalidationReason(
reason)) { | 1396 if (!view()->doingFullPaintInvalidation() && !isFullPaintInvalidationReason(
reason)) { |
1397 invalidatePaintForOverflowIfNeeded(); | 1397 invalidatePaintForOverflowIfNeeded(); |
1398 | 1398 |
1399 // Issue paint invalidations for any scrollbars if there is a scrollable
area for this renderer. | 1399 // Issue paint invalidations for any scrollbars if there is a scrollable
area for this renderer. |
1400 if (ScrollableArea* area = scrollableArea()) { | 1400 if (ScrollableArea* area = scrollableArea()) { |
1401 if (area->hasVerticalBarDamage()) | 1401 if (area->hasVerticalBarDamage()) |
1402 invalidatePaintRectangle(area->verticalBarDamage()); | 1402 invalidatePaintRectangle(area->verticalBarDamage()); |
1403 if (area->hasHorizontalBarDamage()) | 1403 if (area->hasHorizontalBarDamage()) |
1404 invalidatePaintRectangle(area->horizontalBarDamage()); | 1404 invalidatePaintRectangle(area->horizontalBarDamage()); |
1405 } | 1405 } |
1406 } | 1406 } |
1407 | 1407 |
1408 // This is for the next invalidatePaintIfNeeded so must be at the end. | 1408 // This is for the next invalidatePaintIfNeeded so must be at the end. |
1409 savePreviousBorderBoxSizeIfNeeded(); | 1409 savePreviousBorderBoxSizeIfNeeded(); |
1410 return reason; | 1410 return reason; |
1411 } | 1411 } |
1412 | 1412 |
1413 void RenderBox::clearPaintInvalidationState(const PaintInvalidationState& paintI
nvalidationState) | 1413 void LayoutBox::clearPaintInvalidationState(const PaintInvalidationState& paintI
nvalidationState) |
1414 { | 1414 { |
1415 LayoutBoxModelObject::clearPaintInvalidationState(paintInvalidationState); | 1415 LayoutBoxModelObject::clearPaintInvalidationState(paintInvalidationState); |
1416 | 1416 |
1417 if (ScrollableArea* area = scrollableArea()) | 1417 if (ScrollableArea* area = scrollableArea()) |
1418 area->resetScrollbarDamage(); | 1418 area->resetScrollbarDamage(); |
1419 } | 1419 } |
1420 | 1420 |
1421 #if ENABLE(ASSERT) | 1421 #if ENABLE(ASSERT) |
1422 bool RenderBox::paintInvalidationStateIsDirty() const | 1422 bool LayoutBox::paintInvalidationStateIsDirty() const |
1423 { | 1423 { |
1424 if (ScrollableArea* area = scrollableArea()) { | 1424 if (ScrollableArea* area = scrollableArea()) { |
1425 if (area->hasVerticalBarDamage() || area->hasHorizontalBarDamage()) | 1425 if (area->hasVerticalBarDamage() || area->hasHorizontalBarDamage()) |
1426 return true; | 1426 return true; |
1427 } | 1427 } |
1428 return LayoutBoxModelObject::paintInvalidationStateIsDirty(); | 1428 return LayoutBoxModelObject::paintInvalidationStateIsDirty(); |
1429 } | 1429 } |
1430 #endif | 1430 #endif |
1431 | 1431 |
1432 LayoutRect RenderBox::overflowClipRect(const LayoutPoint& location, OverlayScrol
lbarSizeRelevancy relevancy) | 1432 LayoutRect LayoutBox::overflowClipRect(const LayoutPoint& location, OverlayScrol
lbarSizeRelevancy relevancy) |
1433 { | 1433 { |
1434 // FIXME: When overflow-clip (CSS3) is implemented, we'll obtain the propert
y | 1434 // FIXME: When overflow-clip (CSS3) is implemented, we'll obtain the propert
y |
1435 // here. | 1435 // here. |
1436 LayoutRect clipRect = borderBoxRect(); | 1436 LayoutRect clipRect = borderBoxRect(); |
1437 clipRect.setLocation(location + clipRect.location() + LayoutSize(borderLeft(
), borderTop())); | 1437 clipRect.setLocation(location + clipRect.location() + LayoutSize(borderLeft(
), borderTop())); |
1438 clipRect.setSize(clipRect.size() - LayoutSize(borderLeft() + borderRight(),
borderTop() + borderBottom())); | 1438 clipRect.setSize(clipRect.size() - LayoutSize(borderLeft() + borderRight(),
borderTop() + borderBottom())); |
1439 | 1439 |
1440 if (!hasOverflowClip()) | 1440 if (!hasOverflowClip()) |
1441 return clipRect; | 1441 return clipRect; |
1442 | 1442 |
1443 // Subtract out scrollbars if we have them. | 1443 // Subtract out scrollbars if we have them. |
1444 if (style()->shouldPlaceBlockDirectionScrollbarOnLogicalLeft()) | 1444 if (style()->shouldPlaceBlockDirectionScrollbarOnLogicalLeft()) |
1445 clipRect.move(layer()->scrollableArea()->verticalScrollbarWidth(relevanc
y), 0); | 1445 clipRect.move(layer()->scrollableArea()->verticalScrollbarWidth(relevanc
y), 0); |
1446 clipRect.contract(layer()->scrollableArea()->verticalScrollbarWidth(relevanc
y), layer()->scrollableArea()->horizontalScrollbarHeight(relevancy)); | 1446 clipRect.contract(layer()->scrollableArea()->verticalScrollbarWidth(relevanc
y), layer()->scrollableArea()->horizontalScrollbarHeight(relevancy)); |
1447 | 1447 |
1448 return clipRect; | 1448 return clipRect; |
1449 } | 1449 } |
1450 | 1450 |
1451 LayoutRect RenderBox::clipRect(const LayoutPoint& location) | 1451 LayoutRect LayoutBox::clipRect(const LayoutPoint& location) |
1452 { | 1452 { |
1453 LayoutRect borderBoxRect = this->borderBoxRect(); | 1453 LayoutRect borderBoxRect = this->borderBoxRect(); |
1454 LayoutRect clipRect = LayoutRect(borderBoxRect.location() + location, border
BoxRect.size()); | 1454 LayoutRect clipRect = LayoutRect(borderBoxRect.location() + location, border
BoxRect.size()); |
1455 | 1455 |
1456 if (!style()->clipLeft().isAuto()) { | 1456 if (!style()->clipLeft().isAuto()) { |
1457 LayoutUnit c = valueForLength(style()->clipLeft(), borderBoxRect.width()
); | 1457 LayoutUnit c = valueForLength(style()->clipLeft(), borderBoxRect.width()
); |
1458 clipRect.move(c, 0); | 1458 clipRect.move(c, 0); |
1459 clipRect.contract(c, 0); | 1459 clipRect.contract(c, 0); |
1460 } | 1460 } |
1461 | 1461 |
(...skipping 15 matching lines...) Expand all Loading... |
1477 static LayoutUnit portionOfMarginNotConsumedByFloat(LayoutUnit childMargin, Layo
utUnit contentSide, LayoutUnit offset) | 1477 static LayoutUnit portionOfMarginNotConsumedByFloat(LayoutUnit childMargin, Layo
utUnit contentSide, LayoutUnit offset) |
1478 { | 1478 { |
1479 if (childMargin <= 0) | 1479 if (childMargin <= 0) |
1480 return LayoutUnit(); | 1480 return LayoutUnit(); |
1481 LayoutUnit contentSideWithMargin = contentSide + childMargin; | 1481 LayoutUnit contentSideWithMargin = contentSide + childMargin; |
1482 if (offset > contentSideWithMargin) | 1482 if (offset > contentSideWithMargin) |
1483 return childMargin; | 1483 return childMargin; |
1484 return offset - contentSide; | 1484 return offset - contentSide; |
1485 } | 1485 } |
1486 | 1486 |
1487 LayoutUnit RenderBox::shrinkLogicalWidthToAvoidFloats(LayoutUnit childMarginStar
t, LayoutUnit childMarginEnd, const RenderBlockFlow* cb) const | 1487 LayoutUnit LayoutBox::shrinkLogicalWidthToAvoidFloats(LayoutUnit childMarginStar
t, LayoutUnit childMarginEnd, const RenderBlockFlow* cb) const |
1488 { | 1488 { |
1489 LayoutUnit logicalTopPosition = logicalTop(); | 1489 LayoutUnit logicalTopPosition = logicalTop(); |
1490 LayoutUnit startOffsetForContent = cb->startOffsetForContent(); | 1490 LayoutUnit startOffsetForContent = cb->startOffsetForContent(); |
1491 LayoutUnit endOffsetForContent = cb->endOffsetForContent(); | 1491 LayoutUnit endOffsetForContent = cb->endOffsetForContent(); |
1492 LayoutUnit logicalHeight = cb->logicalHeightForChild(*this); | 1492 LayoutUnit logicalHeight = cb->logicalHeightForChild(*this); |
1493 LayoutUnit startOffsetForLine = cb->startOffsetForLine(logicalTopPosition, f
alse, logicalHeight); | 1493 LayoutUnit startOffsetForLine = cb->startOffsetForLine(logicalTopPosition, f
alse, logicalHeight); |
1494 LayoutUnit endOffsetForLine = cb->endOffsetForLine(logicalTopPosition, false
, logicalHeight); | 1494 LayoutUnit endOffsetForLine = cb->endOffsetForLine(logicalTopPosition, false
, logicalHeight); |
1495 | 1495 |
1496 // If there aren't any floats constraining us then allow the margins to shri
nk/expand the width as much as they want. | 1496 // If there aren't any floats constraining us then allow the margins to shri
nk/expand the width as much as they want. |
1497 if (startOffsetForContent == startOffsetForLine && endOffsetForContent == en
dOffsetForLine) | 1497 if (startOffsetForContent == startOffsetForLine && endOffsetForContent == en
dOffsetForLine) |
1498 return cb->availableLogicalWidthForLine(logicalTopPosition, false, logic
alHeight) - childMarginStart - childMarginEnd; | 1498 return cb->availableLogicalWidthForLine(logicalTopPosition, false, logic
alHeight) - childMarginStart - childMarginEnd; |
1499 | 1499 |
1500 LayoutUnit width = cb->availableLogicalWidthForLine(logicalTopPosition, fals
e, logicalHeight) - std::max(LayoutUnit(), childMarginStart) - std::max(LayoutUn
it(), childMarginEnd); | 1500 LayoutUnit width = cb->availableLogicalWidthForLine(logicalTopPosition, fals
e, logicalHeight) - std::max(LayoutUnit(), childMarginStart) - std::max(LayoutUn
it(), childMarginEnd); |
1501 // We need to see if margins on either the start side or the end side can co
ntain the floats in question. If they can, | 1501 // We need to see if margins on either the start side or the end side can co
ntain the floats in question. If they can, |
1502 // then just using the line width is inaccurate. In the case where a float c
ompletely fits, we don't need to use the line | 1502 // then just using the line width is inaccurate. In the case where a float c
ompletely fits, we don't need to use the line |
1503 // offset at all, but can instead push all the way to the content edge of th
e containing block. In the case where the float | 1503 // offset at all, but can instead push all the way to the content edge of th
e containing block. In the case where the float |
1504 // doesn't fit, we can use the line offset, but we need to grow it by the ma
rgin to reflect the fact that the margin was | 1504 // doesn't fit, we can use the line offset, but we need to grow it by the ma
rgin to reflect the fact that the margin was |
1505 // "consumed" by the float. Negative margins aren't consumed by the float, a
nd so we ignore them. | 1505 // "consumed" by the float. Negative margins aren't consumed by the float, a
nd so we ignore them. |
1506 width += portionOfMarginNotConsumedByFloat(childMarginStart, startOffsetForC
ontent, startOffsetForLine); | 1506 width += portionOfMarginNotConsumedByFloat(childMarginStart, startOffsetForC
ontent, startOffsetForLine); |
1507 width += portionOfMarginNotConsumedByFloat(childMarginEnd, endOffsetForConte
nt, endOffsetForLine); | 1507 width += portionOfMarginNotConsumedByFloat(childMarginEnd, endOffsetForConte
nt, endOffsetForLine); |
1508 return width; | 1508 return width; |
1509 } | 1509 } |
1510 | 1510 |
1511 LayoutUnit RenderBox::containingBlockLogicalWidthForContent() const | 1511 LayoutUnit LayoutBox::containingBlockLogicalWidthForContent() const |
1512 { | 1512 { |
1513 if (hasOverrideContainingBlockLogicalWidth()) | 1513 if (hasOverrideContainingBlockLogicalWidth()) |
1514 return overrideContainingBlockContentLogicalWidth(); | 1514 return overrideContainingBlockContentLogicalWidth(); |
1515 | 1515 |
1516 RenderBlock* cb = containingBlock(); | 1516 RenderBlock* cb = containingBlock(); |
1517 return cb->availableLogicalWidth(); | 1517 return cb->availableLogicalWidth(); |
1518 } | 1518 } |
1519 | 1519 |
1520 LayoutUnit RenderBox::containingBlockLogicalHeightForContent(AvailableLogicalHei
ghtType heightType) const | 1520 LayoutUnit LayoutBox::containingBlockLogicalHeightForContent(AvailableLogicalHei
ghtType heightType) const |
1521 { | 1521 { |
1522 if (hasOverrideContainingBlockLogicalHeight()) | 1522 if (hasOverrideContainingBlockLogicalHeight()) |
1523 return overrideContainingBlockContentLogicalHeight(); | 1523 return overrideContainingBlockContentLogicalHeight(); |
1524 | 1524 |
1525 RenderBlock* cb = containingBlock(); | 1525 RenderBlock* cb = containingBlock(); |
1526 return cb->availableLogicalHeight(heightType); | 1526 return cb->availableLogicalHeight(heightType); |
1527 } | 1527 } |
1528 | 1528 |
1529 LayoutUnit RenderBox::containingBlockAvailableLineWidth() const | 1529 LayoutUnit LayoutBox::containingBlockAvailableLineWidth() const |
1530 { | 1530 { |
1531 RenderBlock* cb = containingBlock(); | 1531 RenderBlock* cb = containingBlock(); |
1532 if (cb->isRenderBlockFlow()) | 1532 if (cb->isRenderBlockFlow()) |
1533 return toRenderBlockFlow(cb)->availableLogicalWidthForLine(logicalTop(),
false, availableLogicalHeight(IncludeMarginBorderPadding)); | 1533 return toRenderBlockFlow(cb)->availableLogicalWidthForLine(logicalTop(),
false, availableLogicalHeight(IncludeMarginBorderPadding)); |
1534 return LayoutUnit(); | 1534 return LayoutUnit(); |
1535 } | 1535 } |
1536 | 1536 |
1537 LayoutUnit RenderBox::perpendicularContainingBlockLogicalHeight() const | 1537 LayoutUnit LayoutBox::perpendicularContainingBlockLogicalHeight() const |
1538 { | 1538 { |
1539 if (hasOverrideContainingBlockLogicalHeight()) | 1539 if (hasOverrideContainingBlockLogicalHeight()) |
1540 return overrideContainingBlockContentLogicalHeight(); | 1540 return overrideContainingBlockContentLogicalHeight(); |
1541 | 1541 |
1542 RenderBlock* cb = containingBlock(); | 1542 RenderBlock* cb = containingBlock(); |
1543 if (cb->hasOverrideHeight()) | 1543 if (cb->hasOverrideHeight()) |
1544 return cb->overrideLogicalContentHeight(); | 1544 return cb->overrideLogicalContentHeight(); |
1545 | 1545 |
1546 const LayoutStyle& containingBlockStyle = cb->styleRef(); | 1546 const LayoutStyle& containingBlockStyle = cb->styleRef(); |
1547 Length logicalHeightLength = containingBlockStyle.logicalHeight(); | 1547 Length logicalHeightLength = containingBlockStyle.logicalHeight(); |
1548 | 1548 |
1549 // FIXME: For now just support fixed heights. Eventually should support per
centage heights as well. | 1549 // FIXME: For now just support fixed heights. Eventually should support per
centage heights as well. |
1550 if (!logicalHeightLength.isFixed()) { | 1550 if (!logicalHeightLength.isFixed()) { |
1551 LayoutUnit fillFallbackExtent = containingBlockStyle.isHorizontalWriting
Mode() | 1551 LayoutUnit fillFallbackExtent = containingBlockStyle.isHorizontalWriting
Mode() |
1552 ? view()->frameView()->unscaledVisibleContentSize().height() | 1552 ? view()->frameView()->unscaledVisibleContentSize().height() |
1553 : view()->frameView()->unscaledVisibleContentSize().width(); | 1553 : view()->frameView()->unscaledVisibleContentSize().width(); |
1554 LayoutUnit fillAvailableExtent = containingBlock()->availableLogicalHeig
ht(ExcludeMarginBorderPadding); | 1554 LayoutUnit fillAvailableExtent = containingBlock()->availableLogicalHeig
ht(ExcludeMarginBorderPadding); |
1555 return std::min(fillAvailableExtent, fillFallbackExtent); | 1555 return std::min(fillAvailableExtent, fillFallbackExtent); |
1556 } | 1556 } |
1557 | 1557 |
1558 // Use the content box logical height as specified by the style. | 1558 // Use the content box logical height as specified by the style. |
1559 return cb->adjustContentBoxLogicalHeightForBoxSizing(logicalHeightLength.val
ue()); | 1559 return cb->adjustContentBoxLogicalHeightForBoxSizing(logicalHeightLength.val
ue()); |
1560 } | 1560 } |
1561 | 1561 |
1562 void RenderBox::mapLocalToContainer(const LayoutBoxModelObject* paintInvalidatio
nContainer, TransformState& transformState, MapCoordinatesFlags mode, bool* wasF
ixed, const PaintInvalidationState* paintInvalidationState) const | 1562 void LayoutBox::mapLocalToContainer(const LayoutBoxModelObject* paintInvalidatio
nContainer, TransformState& transformState, MapCoordinatesFlags mode, bool* wasF
ixed, const PaintInvalidationState* paintInvalidationState) const |
1563 { | 1563 { |
1564 if (paintInvalidationContainer == this) | 1564 if (paintInvalidationContainer == this) |
1565 return; | 1565 return; |
1566 | 1566 |
1567 if (paintInvalidationState && paintInvalidationState->canMapToContainer(pain
tInvalidationContainer)) { | 1567 if (paintInvalidationState && paintInvalidationState->canMapToContainer(pain
tInvalidationContainer)) { |
1568 LayoutSize offset = paintInvalidationState->paintOffset() + locationOffs
et(); | 1568 LayoutSize offset = paintInvalidationState->paintOffset() + locationOffs
et(); |
1569 if (style()->hasInFlowPosition() && layer()) | 1569 if (style()->hasInFlowPosition() && layer()) |
1570 offset += layer()->offsetForInFlowPosition(); | 1570 offset += layer()->offsetForInFlowPosition(); |
1571 transformState.move(offset); | 1571 transformState.move(offset); |
1572 return; | 1572 return; |
(...skipping 16 matching lines...) Expand all Loading... |
1589 if (wasFixed) | 1589 if (wasFixed) |
1590 *wasFixed = mode & IsFixed; | 1590 *wasFixed = mode & IsFixed; |
1591 | 1591 |
1592 LayoutSize containerOffset = offsetFromContainer(o, roundedLayoutPoint(trans
formState.mappedPoint())); | 1592 LayoutSize containerOffset = offsetFromContainer(o, roundedLayoutPoint(trans
formState.mappedPoint())); |
1593 | 1593 |
1594 bool preserve3D = mode & UseTransforms && (o->style()->preserves3D() || styl
e()->preserves3D()); | 1594 bool preserve3D = mode & UseTransforms && (o->style()->preserves3D() || styl
e()->preserves3D()); |
1595 if (mode & UseTransforms && shouldUseTransformFromContainer(o)) { | 1595 if (mode & UseTransforms && shouldUseTransformFromContainer(o)) { |
1596 TransformationMatrix t; | 1596 TransformationMatrix t; |
1597 getTransformFromContainer(o, containerOffset, t); | 1597 getTransformFromContainer(o, containerOffset, t); |
1598 transformState.applyTransform(t, preserve3D ? TransformState::Accumulate
Transform : TransformState::FlattenTransform); | 1598 transformState.applyTransform(t, preserve3D ? TransformState::Accumulate
Transform : TransformState::FlattenTransform); |
1599 } else | 1599 } else { |
1600 transformState.move(containerOffset.width(), containerOffset.height(), p
reserve3D ? TransformState::AccumulateTransform : TransformState::FlattenTransfo
rm); | 1600 transformState.move(containerOffset.width(), containerOffset.height(), p
reserve3D ? TransformState::AccumulateTransform : TransformState::FlattenTransfo
rm); |
| 1601 } |
1601 | 1602 |
1602 if (containerSkipped) { | 1603 if (containerSkipped) { |
1603 // There can't be a transform between paintInvalidationContainer and o,
because transforms create containers, so it should be safe | 1604 // There can't be a transform between paintInvalidationContainer and o,
because transforms create containers, so it should be safe |
1604 // to just subtract the delta between the paintInvalidationContainer and
o. | 1605 // to just subtract the delta between the paintInvalidationContainer and
o. |
1605 LayoutSize containerOffset = paintInvalidationContainer->offsetFromAnces
torContainer(o); | 1606 LayoutSize containerOffset = paintInvalidationContainer->offsetFromAnces
torContainer(o); |
1606 transformState.move(-containerOffset.width(), -containerOffset.height(),
preserve3D ? TransformState::AccumulateTransform : TransformState::FlattenTrans
form); | 1607 transformState.move(-containerOffset.width(), -containerOffset.height(),
preserve3D ? TransformState::AccumulateTransform : TransformState::FlattenTrans
form); |
1607 return; | 1608 return; |
1608 } | 1609 } |
1609 | 1610 |
1610 mode &= ~ApplyContainerFlip; | 1611 mode &= ~ApplyContainerFlip; |
1611 | 1612 |
1612 o->mapLocalToContainer(paintInvalidationContainer, transformState, mode, was
Fixed); | 1613 o->mapLocalToContainer(paintInvalidationContainer, transformState, mode, was
Fixed); |
1613 } | 1614 } |
1614 | 1615 |
1615 void RenderBox::mapAbsoluteToLocalPoint(MapCoordinatesFlags mode, TransformState
& transformState) const | 1616 void LayoutBox::mapAbsoluteToLocalPoint(MapCoordinatesFlags mode, TransformState
& transformState) const |
1616 { | 1617 { |
1617 bool isFixedPos = style()->position() == FixedPosition; | 1618 bool isFixedPos = style()->position() == FixedPosition; |
1618 bool hasTransform = hasLayer() && layer()->transform(); | 1619 bool hasTransform = hasLayer() && layer()->transform(); |
1619 if (hasTransform && !isFixedPos) { | 1620 if (hasTransform && !isFixedPos) { |
1620 // If this box has a transform, it acts as a fixed position container fo
r fixed descendants, | 1621 // If this box has a transform, it acts as a fixed position container fo
r fixed descendants, |
1621 // and may itself also be fixed position. So propagate 'fixed' up only i
f this box is fixed position. | 1622 // and may itself also be fixed position. So propagate 'fixed' up only i
f this box is fixed position. |
1622 mode &= ~IsFixed; | 1623 mode &= ~IsFixed; |
1623 } else if (isFixedPos) | 1624 } else if (isFixedPos) { |
1624 mode |= IsFixed; | 1625 mode |= IsFixed; |
| 1626 } |
1625 | 1627 |
1626 LayoutBoxModelObject::mapAbsoluteToLocalPoint(mode, transformState); | 1628 LayoutBoxModelObject::mapAbsoluteToLocalPoint(mode, transformState); |
1627 } | 1629 } |
1628 | 1630 |
1629 LayoutSize RenderBox::offsetFromContainer(const LayoutObject* o, const LayoutPoi
nt& point, bool* offsetDependsOnPoint) const | 1631 LayoutSize LayoutBox::offsetFromContainer(const LayoutObject* o, const LayoutPoi
nt& point, bool* offsetDependsOnPoint) const |
1630 { | 1632 { |
1631 ASSERT(o == container()); | 1633 ASSERT(o == container()); |
1632 | 1634 |
1633 LayoutSize offset; | 1635 LayoutSize offset; |
1634 if (isRelPositioned()) | 1636 if (isRelPositioned()) |
1635 offset += offsetForInFlowPosition(); | 1637 offset += offsetForInFlowPosition(); |
1636 | 1638 |
1637 if (!isInline() || isReplaced()) { | 1639 if (!isInline() || isReplaced()) { |
1638 if (!style()->hasOutOfFlowPosition() && o->hasColumns()) { | 1640 if (!style()->hasOutOfFlowPosition() && o->hasColumns()) { |
1639 const RenderBlock* block = toRenderBlock(o); | 1641 const RenderBlock* block = toRenderBlock(o); |
(...skipping 15 matching lines...) Expand all Loading... |
1655 // visual point now. | 1657 // visual point now. |
1656 LayoutPoint pointInContainer = point + offset; | 1658 LayoutPoint pointInContainer = point + offset; |
1657 offset += o->columnOffset(pointInContainer); | 1659 offset += o->columnOffset(pointInContainer); |
1658 if (offsetDependsOnPoint) | 1660 if (offsetDependsOnPoint) |
1659 *offsetDependsOnPoint = true; | 1661 *offsetDependsOnPoint = true; |
1660 } | 1662 } |
1661 } | 1663 } |
1662 } | 1664 } |
1663 | 1665 |
1664 if (o->hasOverflowClip()) | 1666 if (o->hasOverflowClip()) |
1665 offset -= toRenderBox(o)->scrolledContentOffset(); | 1667 offset -= toLayoutBox(o)->scrolledContentOffset(); |
1666 | 1668 |
1667 if (style()->position() == AbsolutePosition && o->isRelPositioned() && o->is
RenderInline()) | 1669 if (style()->position() == AbsolutePosition && o->isRelPositioned() && o->is
RenderInline()) |
1668 offset += toRenderInline(o)->offsetForInFlowPositionedInline(*this); | 1670 offset += toRenderInline(o)->offsetForInFlowPositionedInline(*this); |
1669 | 1671 |
1670 return offset; | 1672 return offset; |
1671 } | 1673 } |
1672 | 1674 |
1673 InlineBox* RenderBox::createInlineBox() | 1675 InlineBox* LayoutBox::createInlineBox() |
1674 { | 1676 { |
1675 return new InlineBox(*this); | 1677 return new InlineBox(*this); |
1676 } | 1678 } |
1677 | 1679 |
1678 void RenderBox::dirtyLineBoxes(bool fullLayout) | 1680 void LayoutBox::dirtyLineBoxes(bool fullLayout) |
1679 { | 1681 { |
1680 if (inlineBoxWrapper()) { | 1682 if (inlineBoxWrapper()) { |
1681 if (fullLayout) { | 1683 if (fullLayout) { |
1682 inlineBoxWrapper()->destroy(); | 1684 inlineBoxWrapper()->destroy(); |
1683 ASSERT(m_rareData); | 1685 ASSERT(m_rareData); |
1684 m_rareData->m_inlineBoxWrapper = 0; | 1686 m_rareData->m_inlineBoxWrapper = 0; |
1685 } else { | 1687 } else { |
1686 inlineBoxWrapper()->dirtyLineBoxes(); | 1688 inlineBoxWrapper()->dirtyLineBoxes(); |
1687 } | 1689 } |
1688 } | 1690 } |
1689 } | 1691 } |
1690 | 1692 |
1691 void RenderBox::positionLineBox(InlineBox* box) | 1693 void LayoutBox::positionLineBox(InlineBox* box) |
1692 { | 1694 { |
1693 if (isOutOfFlowPositioned()) { | 1695 if (isOutOfFlowPositioned()) { |
1694 // Cache the x position only if we were an INLINE type originally. | 1696 // Cache the x position only if we were an INLINE type originally. |
1695 bool originallyInline = style()->isOriginalDisplayInlineType(); | 1697 bool originallyInline = style()->isOriginalDisplayInlineType(); |
1696 if (originallyInline) { | 1698 if (originallyInline) { |
1697 // The value is cached in the xPos of the box. We only need this va
lue if | 1699 // The value is cached in the xPos of the box. We only need this va
lue if |
1698 // our object was inline originally, since otherwise it would have e
nded up underneath | 1700 // our object was inline originally, since otherwise it would have e
nded up underneath |
1699 // the inlines. | 1701 // the inlines. |
1700 RootInlineBox& root = box->root(); | 1702 RootInlineBox& root = box->root(); |
1701 root.block().setStaticInlinePositionForChild(*this, LayoutUnit::from
FloatRound(box->logicalLeft())); | 1703 root.block().setStaticInlinePositionForChild(*this, LayoutUnit::from
FloatRound(box->logicalLeft())); |
(...skipping 13 matching lines...) Expand all Loading... |
1715 box->remove(DontMarkLineBoxes); | 1717 box->remove(DontMarkLineBoxes); |
1716 box->destroy(); | 1718 box->destroy(); |
1717 } else if (isReplaced()) { | 1719 } else if (isReplaced()) { |
1718 // FIXME: the call to roundedLayoutPoint() below is temporary and should
be removed once | 1720 // FIXME: the call to roundedLayoutPoint() below is temporary and should
be removed once |
1719 // the transition to LayoutUnit-based types is complete (crbug.com/32123
7) | 1721 // the transition to LayoutUnit-based types is complete (crbug.com/32123
7) |
1720 setLocation(box->topLeft().roundedLayoutPoint()); | 1722 setLocation(box->topLeft().roundedLayoutPoint()); |
1721 setInlineBoxWrapper(box); | 1723 setInlineBoxWrapper(box); |
1722 } | 1724 } |
1723 } | 1725 } |
1724 | 1726 |
1725 void RenderBox::markStaticPositionedBoxForLayout(bool isHorizontal, bool isInlin
e) | 1727 void LayoutBox::markStaticPositionedBoxForLayout(bool isHorizontal, bool isInlin
e) |
1726 { | 1728 { |
1727 ASSERT(isOutOfFlowPositioned()); | 1729 ASSERT(isOutOfFlowPositioned()); |
1728 if (normalChildNeedsLayout()) | 1730 if (normalChildNeedsLayout()) |
1729 return; | 1731 return; |
1730 if (isInline ? style()->hasStaticInlinePosition(isHorizontal) : style()->has
StaticBlockPosition(isHorizontal)) | 1732 if (isInline ? style()->hasStaticInlinePosition(isHorizontal) : style()->has
StaticBlockPosition(isHorizontal)) |
1731 setChildNeedsLayout(MarkOnlyThis); | 1733 setChildNeedsLayout(MarkOnlyThis); |
1732 } | 1734 } |
1733 | 1735 |
1734 void RenderBox::moveWithEdgeOfInlineContainerIfNecessary(bool isHorizontal) | 1736 void LayoutBox::moveWithEdgeOfInlineContainerIfNecessary(bool isHorizontal) |
1735 { | 1737 { |
1736 ASSERT(isOutOfFlowPositioned() && container()->isRenderInline() && container
()->isRelPositioned()); | 1738 ASSERT(isOutOfFlowPositioned() && container()->isRenderInline() && container
()->isRelPositioned()); |
1737 // If this object is inside a relative positioned inline and its inline posi
tion is an explicit offset from the edge of its container | 1739 // If this object is inside a relative positioned inline and its inline posi
tion is an explicit offset from the edge of its container |
1738 // then it will need to move if its inline container has changed width. We d
o not track if the width has changed | 1740 // then it will need to move if its inline container has changed width. We d
o not track if the width has changed |
1739 // but if we are here then we are laying out lines inside it, so it probably
has - mark our object for layout so that it can | 1741 // but if we are here then we are laying out lines inside it, so it probably
has - mark our object for layout so that it can |
1740 // move to the new offset created by the new width. | 1742 // move to the new offset created by the new width. |
1741 if (!normalChildNeedsLayout() && !style()->hasStaticInlinePosition(isHorizon
tal)) | 1743 if (!normalChildNeedsLayout() && !style()->hasStaticInlinePosition(isHorizon
tal)) |
1742 setChildNeedsLayout(MarkOnlyThis); | 1744 setChildNeedsLayout(MarkOnlyThis); |
1743 } | 1745 } |
1744 | 1746 |
1745 void RenderBox::deleteLineBoxWrapper() | 1747 void LayoutBox::deleteLineBoxWrapper() |
1746 { | 1748 { |
1747 if (inlineBoxWrapper()) { | 1749 if (inlineBoxWrapper()) { |
1748 if (!documentBeingDestroyed()) | 1750 if (!documentBeingDestroyed()) |
1749 inlineBoxWrapper()->remove(); | 1751 inlineBoxWrapper()->remove(); |
1750 inlineBoxWrapper()->destroy(); | 1752 inlineBoxWrapper()->destroy(); |
1751 ASSERT(m_rareData); | 1753 ASSERT(m_rareData); |
1752 m_rareData->m_inlineBoxWrapper = 0; | 1754 m_rareData->m_inlineBoxWrapper = 0; |
1753 } | 1755 } |
1754 } | 1756 } |
1755 | 1757 |
1756 void RenderBox::setSpannerPlaceholder(LayoutMultiColumnSpannerPlaceholder& place
holder) | 1758 void LayoutBox::setSpannerPlaceholder(LayoutMultiColumnSpannerPlaceholder& place
holder) |
1757 { | 1759 { |
1758 RELEASE_ASSERT(!m_rareData || !m_rareData->m_spannerPlaceholder); // not exp
ected to change directly from one spanner to another. | 1760 RELEASE_ASSERT(!m_rareData || !m_rareData->m_spannerPlaceholder); // not exp
ected to change directly from one spanner to another. |
1759 ensureRareData().m_spannerPlaceholder = &placeholder; | 1761 ensureRareData().m_spannerPlaceholder = &placeholder; |
1760 } | 1762 } |
1761 | 1763 |
1762 void RenderBox::clearSpannerPlaceholder() | 1764 void LayoutBox::clearSpannerPlaceholder() |
1763 { | 1765 { |
1764 if (!m_rareData) | 1766 if (!m_rareData) |
1765 return; | 1767 return; |
1766 m_rareData->m_spannerPlaceholder = 0; | 1768 m_rareData->m_spannerPlaceholder = 0; |
1767 } | 1769 } |
1768 | 1770 |
1769 LayoutRect RenderBox::clippedOverflowRectForPaintInvalidation(const LayoutBoxMod
elObject* paintInvalidationContainer, const PaintInvalidationState* paintInvalid
ationState) const | 1771 LayoutRect LayoutBox::clippedOverflowRectForPaintInvalidation(const LayoutBoxMod
elObject* paintInvalidationContainer, const PaintInvalidationState* paintInvalid
ationState) const |
1770 { | 1772 { |
1771 if (style()->visibility() != VISIBLE) { | 1773 if (style()->visibility() != VISIBLE) { |
1772 Layer* layer = enclosingLayer(); | 1774 Layer* layer = enclosingLayer(); |
1773 layer->updateDescendantDependentFlags(); | 1775 layer->updateDescendantDependentFlags(); |
1774 if (layer->subtreeIsInvisible()) | 1776 if (layer->subtreeIsInvisible()) |
1775 return LayoutRect(); | 1777 return LayoutRect(); |
1776 } | 1778 } |
1777 | 1779 |
1778 LayoutRect r = visualOverflowRect(); | 1780 LayoutRect r = visualOverflowRect(); |
1779 mapRectToPaintInvalidationBacking(paintInvalidationContainer, r, paintInvali
dationState); | 1781 mapRectToPaintInvalidationBacking(paintInvalidationContainer, r, paintInvali
dationState); |
1780 return r; | 1782 return r; |
1781 } | 1783 } |
1782 | 1784 |
1783 void RenderBox::mapRectToPaintInvalidationBacking(const LayoutBoxModelObject* pa
intInvalidationContainer, LayoutRect& rect, const PaintInvalidationState* paintI
nvalidationState) const | 1785 void LayoutBox::mapRectToPaintInvalidationBacking(const LayoutBoxModelObject* pa
intInvalidationContainer, LayoutRect& rect, const PaintInvalidationState* paintI
nvalidationState) const |
1784 { | 1786 { |
1785 // The rect we compute at each step is shifted by our x/y offset in the pare
nt container's coordinate space. | 1787 // The rect we compute at each step is shifted by our x/y offset in the pare
nt container's coordinate space. |
1786 // Only when we cross a writing mode boundary will we have to possibly flipF
orWritingMode (to convert into a more appropriate | 1788 // Only when we cross a writing mode boundary will we have to possibly flipF
orWritingMode (to convert into a more appropriate |
1787 // offset corner for the enclosing container). This allows for a fully RL or
BT document to issue paint invalidations | 1789 // offset corner for the enclosing container). This allows for a fully RL or
BT document to issue paint invalidations |
1788 // properly even during layout, since the rect remains flipped all the way u
ntil the end. | 1790 // properly even during layout, since the rect remains flipped all the way u
ntil the end. |
1789 // | 1791 // |
1790 // RenderView::computeRectForPaintInvalidation then converts the rect to phy
sical coordinates. We also convert to | 1792 // RenderView::computeRectForPaintInvalidation then converts the rect to phy
sical coordinates. We also convert to |
1791 // physical when we hit a paintInvalidationContainer boundary. Therefore the
final rect returned is always in the | 1793 // physical when we hit a paintInvalidationContainer boundary. Therefore the
final rect returned is always in the |
1792 // physical coordinate space of the paintInvalidationContainer. | 1794 // physical coordinate space of the paintInvalidationContainer. |
1793 const LayoutStyle& styleToUse = styleRef(); | 1795 const LayoutStyle& styleToUse = styleRef(); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1853 LayoutRect paintInvalidationRect(topLeft, rect.size()); | 1855 LayoutRect paintInvalidationRect(topLeft, rect.size()); |
1854 toRenderBlock(o)->adjustRectForColumns(paintInvalidationRect); | 1856 toRenderBlock(o)->adjustRectForColumns(paintInvalidationRect); |
1855 topLeft = paintInvalidationRect.location(); | 1857 topLeft = paintInvalidationRect.location(); |
1856 rect = paintInvalidationRect; | 1858 rect = paintInvalidationRect; |
1857 } | 1859 } |
1858 | 1860 |
1859 // FIXME: We ignore the lightweight clipping rect that controls use, since i
f |o| is in mid-layout, | 1861 // FIXME: We ignore the lightweight clipping rect that controls use, since i
f |o| is in mid-layout, |
1860 // its controlClipRect will be wrong. For overflow clip we use the values ca
ched by the layer. | 1862 // its controlClipRect will be wrong. For overflow clip we use the values ca
ched by the layer. |
1861 rect.setLocation(topLeft); | 1863 rect.setLocation(topLeft); |
1862 if (o->hasOverflowClip()) { | 1864 if (o->hasOverflowClip()) { |
1863 RenderBox* containerBox = toRenderBox(o); | 1865 LayoutBox* containerBox = toLayoutBox(o); |
1864 containerBox->applyCachedClipAndScrollOffsetForPaintInvalidation(rect); | 1866 containerBox->applyCachedClipAndScrollOffsetForPaintInvalidation(rect); |
1865 if (rect.isEmpty()) | 1867 if (rect.isEmpty()) |
1866 return; | 1868 return; |
1867 } | 1869 } |
1868 | 1870 |
1869 if (containerSkipped) { | 1871 if (containerSkipped) { |
1870 // If the paintInvalidationContainer is below o, then we need to map the
rect into paintInvalidationContainer's coordinates. | 1872 // If the paintInvalidationContainer is below o, then we need to map the
rect into paintInvalidationContainer's coordinates. |
1871 LayoutSize containerOffset = paintInvalidationContainer->offsetFromAnces
torContainer(o); | 1873 LayoutSize containerOffset = paintInvalidationContainer->offsetFromAnces
torContainer(o); |
1872 rect.move(-containerOffset); | 1874 rect.move(-containerOffset); |
1873 // If the paintInvalidationContainer is fixed, then the rect is already
in its coordinates so doesn't need viewport-adjusting. | 1875 // If the paintInvalidationContainer is fixed, then the rect is already
in its coordinates so doesn't need viewport-adjusting. |
1874 if (paintInvalidationContainer->style()->position() != FixedPosition &&
o->isRenderView()) | 1876 if (paintInvalidationContainer->style()->position() != FixedPosition &&
o->isRenderView()) |
1875 toRenderView(o)->adjustViewportConstrainedOffset(rect, RenderView::v
iewportConstrainedPosition(position)); | 1877 toRenderView(o)->adjustViewportConstrainedOffset(rect, RenderView::v
iewportConstrainedPosition(position)); |
1876 return; | 1878 return; |
1877 } | 1879 } |
1878 | 1880 |
1879 if (o->isRenderView()) | 1881 if (o->isRenderView()) |
1880 toRenderView(o)->mapRectToPaintInvalidationBacking(paintInvalidationCont
ainer, rect, RenderView::viewportConstrainedPosition(position), paintInvalidatio
nState); | 1882 toRenderView(o)->mapRectToPaintInvalidationBacking(paintInvalidationCont
ainer, rect, RenderView::viewportConstrainedPosition(position), paintInvalidatio
nState); |
1881 else | 1883 else |
1882 o->mapRectToPaintInvalidationBacking(paintInvalidationContainer, rect, p
aintInvalidationState); | 1884 o->mapRectToPaintInvalidationBacking(paintInvalidationContainer, rect, p
aintInvalidationState); |
1883 } | 1885 } |
1884 | 1886 |
1885 void RenderBox::inflatePaintInvalidationRectForReflectionAndFilter(LayoutRect& p
aintInvalidationRect) const | 1887 void LayoutBox::inflatePaintInvalidationRectForReflectionAndFilter(LayoutRect& p
aintInvalidationRect) const |
1886 { | 1888 { |
1887 if (hasReflection()) | 1889 if (hasReflection()) |
1888 paintInvalidationRect.unite(reflectedRect(paintInvalidationRect)); | 1890 paintInvalidationRect.unite(reflectedRect(paintInvalidationRect)); |
1889 | 1891 |
1890 if (style()->hasFilter()) | 1892 if (style()->hasFilter()) |
1891 paintInvalidationRect.expand(style()->filterOutsets()); | 1893 paintInvalidationRect.expand(style()->filterOutsets()); |
1892 } | 1894 } |
1893 | 1895 |
1894 void RenderBox::invalidatePaintForOverhangingFloats(bool) | 1896 void LayoutBox::invalidatePaintForOverhangingFloats(bool) |
1895 { | 1897 { |
1896 } | 1898 } |
1897 | 1899 |
1898 void RenderBox::updateLogicalWidth() | 1900 void LayoutBox::updateLogicalWidth() |
1899 { | 1901 { |
1900 LogicalExtentComputedValues computedValues; | 1902 LogicalExtentComputedValues computedValues; |
1901 computeLogicalWidth(computedValues); | 1903 computeLogicalWidth(computedValues); |
1902 | 1904 |
1903 setLogicalWidth(computedValues.m_extent); | 1905 setLogicalWidth(computedValues.m_extent); |
1904 setLogicalLeft(computedValues.m_position); | 1906 setLogicalLeft(computedValues.m_position); |
1905 setMarginStart(computedValues.m_margins.m_start); | 1907 setMarginStart(computedValues.m_margins.m_start); |
1906 setMarginEnd(computedValues.m_margins.m_end); | 1908 setMarginEnd(computedValues.m_margins.m_end); |
1907 } | 1909 } |
1908 | 1910 |
1909 static float getMaxWidthListMarker(const RenderBox* renderer) | 1911 static float getMaxWidthListMarker(const LayoutBox* renderer) |
1910 { | 1912 { |
1911 #if ENABLE(ASSERT) | 1913 #if ENABLE(ASSERT) |
1912 ASSERT(renderer); | 1914 ASSERT(renderer); |
1913 Node* parentNode = renderer->generatingNode(); | 1915 Node* parentNode = renderer->generatingNode(); |
1914 ASSERT(parentNode); | 1916 ASSERT(parentNode); |
1915 ASSERT(isHTMLOListElement(parentNode) || isHTMLUListElement(parentNode)); | 1917 ASSERT(isHTMLOListElement(parentNode) || isHTMLUListElement(parentNode)); |
1916 ASSERT(renderer->style()->textAutosizingMultiplier() != 1); | 1918 ASSERT(renderer->style()->textAutosizingMultiplier() != 1); |
1917 #endif | 1919 #endif |
1918 float maxWidth = 0; | 1920 float maxWidth = 0; |
1919 for (LayoutObject* child = renderer->slowFirstChild(); child; child = child-
>nextSibling()) { | 1921 for (LayoutObject* child = renderer->slowFirstChild(); child; child = child-
>nextSibling()) { |
1920 if (!child->isListItem()) | 1922 if (!child->isListItem()) |
1921 continue; | 1923 continue; |
1922 | 1924 |
1923 RenderBox* listItem = toRenderBox(child); | 1925 LayoutBox* listItem = toLayoutBox(child); |
1924 for (LayoutObject* itemChild = listItem->slowFirstChild(); itemChild; it
emChild = itemChild->nextSibling()) { | 1926 for (LayoutObject* itemChild = listItem->slowFirstChild(); itemChild; it
emChild = itemChild->nextSibling()) { |
1925 if (!itemChild->isListMarker()) | 1927 if (!itemChild->isListMarker()) |
1926 continue; | 1928 continue; |
1927 RenderBox* itemMarker = toRenderBox(itemChild); | 1929 LayoutBox* itemMarker = toLayoutBox(itemChild); |
1928 // Make sure to compute the autosized width. | 1930 // Make sure to compute the autosized width. |
1929 if (itemMarker->needsLayout()) | 1931 if (itemMarker->needsLayout()) |
1930 itemMarker->layout(); | 1932 itemMarker->layout(); |
1931 maxWidth = std::max<float>(maxWidth, toLayoutListMarker(itemMarker)-
>logicalWidth().toFloat()); | 1933 maxWidth = std::max<float>(maxWidth, toLayoutListMarker(itemMarker)-
>logicalWidth().toFloat()); |
1932 break; | 1934 break; |
1933 } | 1935 } |
1934 } | 1936 } |
1935 return maxWidth; | 1937 return maxWidth; |
1936 } | 1938 } |
1937 | 1939 |
1938 void RenderBox::computeLogicalWidth(LogicalExtentComputedValues& computedValues)
const | 1940 void LayoutBox::computeLogicalWidth(LogicalExtentComputedValues& computedValues)
const |
1939 { | 1941 { |
1940 computedValues.m_extent = logicalWidth(); | 1942 computedValues.m_extent = logicalWidth(); |
1941 computedValues.m_position = logicalLeft(); | 1943 computedValues.m_position = logicalLeft(); |
1942 computedValues.m_margins.m_start = marginStart(); | 1944 computedValues.m_margins.m_start = marginStart(); |
1943 computedValues.m_margins.m_end = marginEnd(); | 1945 computedValues.m_margins.m_end = marginEnd(); |
1944 | 1946 |
1945 if (isOutOfFlowPositioned()) { | 1947 if (isOutOfFlowPositioned()) { |
1946 computePositionedLogicalWidth(computedValues); | 1948 computePositionedLogicalWidth(computedValues); |
1947 return; | 1949 return; |
1948 } | 1950 } |
(...skipping 27 matching lines...) Expand all Loading... |
1976 if (isInline() && !isInlineBlockOrInlineTable()) { | 1978 if (isInline() && !isInlineBlockOrInlineTable()) { |
1977 // just calculate margins | 1979 // just calculate margins |
1978 computedValues.m_margins.m_start = minimumValueForLength(styleToUse.marg
inStart(), containerLogicalWidth); | 1980 computedValues.m_margins.m_start = minimumValueForLength(styleToUse.marg
inStart(), containerLogicalWidth); |
1979 computedValues.m_margins.m_end = minimumValueForLength(styleToUse.margin
End(), containerLogicalWidth); | 1981 computedValues.m_margins.m_end = minimumValueForLength(styleToUse.margin
End(), containerLogicalWidth); |
1980 if (treatAsReplaced) | 1982 if (treatAsReplaced) |
1981 computedValues.m_extent = std::max<LayoutUnit>(floatValueForLength(l
ogicalWidthLength, 0) + borderAndPaddingLogicalWidth(), minPreferredLogicalWidth
()); | 1983 computedValues.m_extent = std::max<LayoutUnit>(floatValueForLength(l
ogicalWidthLength, 0) + borderAndPaddingLogicalWidth(), minPreferredLogicalWidth
()); |
1982 return; | 1984 return; |
1983 } | 1985 } |
1984 | 1986 |
1985 // Width calculations | 1987 // Width calculations |
1986 if (treatAsReplaced) | 1988 if (treatAsReplaced) { |
1987 computedValues.m_extent = logicalWidthLength.value() + borderAndPaddingL
ogicalWidth(); | 1989 computedValues.m_extent = logicalWidthLength.value() + borderAndPaddingL
ogicalWidth(); |
1988 else { | 1990 } else { |
1989 LayoutUnit containerWidthInInlineDirection = containerLogicalWidth; | 1991 LayoutUnit containerWidthInInlineDirection = containerLogicalWidth; |
1990 if (hasPerpendicularContainingBlock) | 1992 if (hasPerpendicularContainingBlock) |
1991 containerWidthInInlineDirection = perpendicularContainingBlockLogica
lHeight(); | 1993 containerWidthInInlineDirection = perpendicularContainingBlockLogica
lHeight(); |
1992 LayoutUnit preferredWidth = computeLogicalWidthUsing(MainOrPreferredSize
, styleToUse.logicalWidth(), containerWidthInInlineDirection, cb); | 1994 LayoutUnit preferredWidth = computeLogicalWidthUsing(MainOrPreferredSize
, styleToUse.logicalWidth(), containerWidthInInlineDirection, cb); |
1993 computedValues.m_extent = constrainLogicalWidthByMinMax(preferredWidth,
containerWidthInInlineDirection, cb); | 1995 computedValues.m_extent = constrainLogicalWidthByMinMax(preferredWidth,
containerWidthInInlineDirection, cb); |
1994 } | 1996 } |
1995 | 1997 |
1996 // Margin calculations. | 1998 // Margin calculations. |
1997 computeMarginsForDirection(InlineDirection, cb, containerLogicalWidth, compu
tedValues.m_extent, computedValues.m_margins.m_start, | 1999 computeMarginsForDirection(InlineDirection, cb, containerLogicalWidth, compu
tedValues.m_extent, computedValues.m_margins.m_start, |
1998 computedValues.m_margins.m_end, style()->marginStart(), style()->marginE
nd()); | 2000 computedValues.m_margins.m_end, style()->marginStart(), style()->marginE
nd()); |
(...skipping 15 matching lines...) Expand all Loading... |
2014 const float adjustedMargin = (1 - 1.0 / styleToUse.textAutosizingMul
tiplier()) * getMaxWidthListMarker(this); | 2016 const float adjustedMargin = (1 - 1.0 / styleToUse.textAutosizingMul
tiplier()) * getMaxWidthListMarker(this); |
2015 bool hasInvertedDirection = cb->style()->isLeftToRightDirection() !=
style()->isLeftToRightDirection(); | 2017 bool hasInvertedDirection = cb->style()->isLeftToRightDirection() !=
style()->isLeftToRightDirection(); |
2016 if (hasInvertedDirection) | 2018 if (hasInvertedDirection) |
2017 computedValues.m_margins.m_end += adjustedMargin; | 2019 computedValues.m_margins.m_end += adjustedMargin; |
2018 else | 2020 else |
2019 computedValues.m_margins.m_start += adjustedMargin; | 2021 computedValues.m_margins.m_start += adjustedMargin; |
2020 } | 2022 } |
2021 } | 2023 } |
2022 } | 2024 } |
2023 | 2025 |
2024 LayoutUnit RenderBox::fillAvailableMeasure(LayoutUnit availableLogicalWidth) con
st | 2026 LayoutUnit LayoutBox::fillAvailableMeasure(LayoutUnit availableLogicalWidth) con
st |
2025 { | 2027 { |
2026 LayoutUnit marginStart = 0; | 2028 LayoutUnit marginStart = 0; |
2027 LayoutUnit marginEnd = 0; | 2029 LayoutUnit marginEnd = 0; |
2028 return fillAvailableMeasure(availableLogicalWidth, marginStart, marginEnd); | 2030 return fillAvailableMeasure(availableLogicalWidth, marginStart, marginEnd); |
2029 } | 2031 } |
2030 | 2032 |
2031 LayoutUnit RenderBox::fillAvailableMeasure(LayoutUnit availableLogicalWidth, Lay
outUnit& marginStart, LayoutUnit& marginEnd) const | 2033 LayoutUnit LayoutBox::fillAvailableMeasure(LayoutUnit availableLogicalWidth, Lay
outUnit& marginStart, LayoutUnit& marginEnd) const |
2032 { | 2034 { |
2033 marginStart = minimumValueForLength(style()->marginStart(), availableLogical
Width); | 2035 marginStart = minimumValueForLength(style()->marginStart(), availableLogical
Width); |
2034 marginEnd = minimumValueForLength(style()->marginEnd(), availableLogicalWidt
h); | 2036 marginEnd = minimumValueForLength(style()->marginEnd(), availableLogicalWidt
h); |
2035 return availableLogicalWidth - marginStart - marginEnd; | 2037 return availableLogicalWidth - marginStart - marginEnd; |
2036 } | 2038 } |
2037 | 2039 |
2038 LayoutUnit RenderBox::computeIntrinsicLogicalWidthUsing(const Length& logicalWid
thLength, LayoutUnit availableLogicalWidth, LayoutUnit borderAndPadding) const | 2040 LayoutUnit LayoutBox::computeIntrinsicLogicalWidthUsing(const Length& logicalWid
thLength, LayoutUnit availableLogicalWidth, LayoutUnit borderAndPadding) const |
2039 { | 2041 { |
2040 if (logicalWidthLength.type() == FillAvailable) | 2042 if (logicalWidthLength.type() == FillAvailable) |
2041 return fillAvailableMeasure(availableLogicalWidth); | 2043 return fillAvailableMeasure(availableLogicalWidth); |
2042 | 2044 |
2043 LayoutUnit minLogicalWidth = 0; | 2045 LayoutUnit minLogicalWidth = 0; |
2044 LayoutUnit maxLogicalWidth = 0; | 2046 LayoutUnit maxLogicalWidth = 0; |
2045 computeIntrinsicLogicalWidths(minLogicalWidth, maxLogicalWidth); | 2047 computeIntrinsicLogicalWidths(minLogicalWidth, maxLogicalWidth); |
2046 | 2048 |
2047 if (logicalWidthLength.type() == MinContent) | 2049 if (logicalWidthLength.type() == MinContent) |
2048 return minLogicalWidth + borderAndPadding; | 2050 return minLogicalWidth + borderAndPadding; |
2049 | 2051 |
2050 if (logicalWidthLength.type() == MaxContent) | 2052 if (logicalWidthLength.type() == MaxContent) |
2051 return maxLogicalWidth + borderAndPadding; | 2053 return maxLogicalWidth + borderAndPadding; |
2052 | 2054 |
2053 if (logicalWidthLength.type() == FitContent) { | 2055 if (logicalWidthLength.type() == FitContent) { |
2054 minLogicalWidth += borderAndPadding; | 2056 minLogicalWidth += borderAndPadding; |
2055 maxLogicalWidth += borderAndPadding; | 2057 maxLogicalWidth += borderAndPadding; |
2056 return std::max(minLogicalWidth, std::min(maxLogicalWidth, fillAvailable
Measure(availableLogicalWidth))); | 2058 return std::max(minLogicalWidth, std::min(maxLogicalWidth, fillAvailable
Measure(availableLogicalWidth))); |
2057 } | 2059 } |
2058 | 2060 |
2059 ASSERT_NOT_REACHED(); | 2061 ASSERT_NOT_REACHED(); |
2060 return 0; | 2062 return 0; |
2061 } | 2063 } |
2062 | 2064 |
2063 LayoutUnit RenderBox::computeLogicalWidthUsing(SizeType widthType, const Length&
logicalWidth, LayoutUnit availableLogicalWidth, const RenderBlock* cb) const | 2065 LayoutUnit LayoutBox::computeLogicalWidthUsing(SizeType widthType, const Length&
logicalWidth, LayoutUnit availableLogicalWidth, const RenderBlock* cb) const |
2064 { | 2066 { |
2065 if (!logicalWidth.isIntrinsicOrAuto()) { | 2067 if (!logicalWidth.isIntrinsicOrAuto()) { |
2066 // FIXME: If the containing block flow is perpendicular to our direction
we need to use the available logical height instead. | 2068 // FIXME: If the containing block flow is perpendicular to our direction
we need to use the available logical height instead. |
2067 return adjustBorderBoxLogicalWidthForBoxSizing(valueForLength(logicalWid
th, availableLogicalWidth)); | 2069 return adjustBorderBoxLogicalWidthForBoxSizing(valueForLength(logicalWid
th, availableLogicalWidth)); |
2068 } | 2070 } |
2069 | 2071 |
2070 if (logicalWidth.isIntrinsic()) | 2072 if (logicalWidth.isIntrinsic()) |
2071 return computeIntrinsicLogicalWidthUsing(logicalWidth, availableLogicalW
idth, borderAndPaddingLogicalWidth()); | 2073 return computeIntrinsicLogicalWidthUsing(logicalWidth, availableLogicalW
idth, borderAndPaddingLogicalWidth()); |
2072 | 2074 |
2073 LayoutUnit marginStart = 0; | 2075 LayoutUnit marginStart = 0; |
(...skipping 24 matching lines...) Expand all Loading... |
2098 LayoutObject* parent = flexitem->parent(); | 2100 LayoutObject* parent = flexitem->parent(); |
2099 if (parent->isDeprecatedFlexibleBox() && parent->style()->boxOrient() == VER
TICAL && parent->style()->boxAlign() == BSTRETCH) | 2101 if (parent->isDeprecatedFlexibleBox() && parent->style()->boxOrient() == VER
TICAL && parent->style()->boxAlign() == BSTRETCH) |
2100 return true; | 2102 return true; |
2101 | 2103 |
2102 // We don't stretch multiline flexboxes because they need to apply line spac
ing (align-content) first. | 2104 // We don't stretch multiline flexboxes because they need to apply line spac
ing (align-content) first. |
2103 if (parent->isFlexibleBox() && parent->style()->flexWrap() == FlexNoWrap &&
parent->style()->isColumnFlexDirection() && columnFlexItemHasStretchAlignment(fl
exitem)) | 2105 if (parent->isFlexibleBox() && parent->style()->flexWrap() == FlexNoWrap &&
parent->style()->isColumnFlexDirection() && columnFlexItemHasStretchAlignment(fl
exitem)) |
2104 return true; | 2106 return true; |
2105 return false; | 2107 return false; |
2106 } | 2108 } |
2107 | 2109 |
2108 bool RenderBox::sizesLogicalWidthToFitContent(const Length& logicalWidth) const | 2110 bool LayoutBox::sizesLogicalWidthToFitContent(const Length& logicalWidth) const |
2109 { | 2111 { |
2110 if (isFloating() || isInlineBlockOrInlineTable()) | 2112 if (isFloating() || isInlineBlockOrInlineTable()) |
2111 return true; | 2113 return true; |
2112 | 2114 |
2113 if (logicalWidth.type() == Intrinsic) | 2115 if (logicalWidth.type() == Intrinsic) |
2114 return true; | 2116 return true; |
2115 | 2117 |
2116 // Flexible box items should shrink wrap, so we lay them out at their intrin
sic widths. | 2118 // Flexible box items should shrink wrap, so we lay them out at their intrin
sic widths. |
2117 // In the case of columns that have a stretch alignment, we go ahead and lay
out at the | 2119 // In the case of columns that have a stretch alignment, we go ahead and lay
out at the |
2118 // stretched size to avoid an extra layout when applying alignment. | 2120 // stretched size to avoid an extra layout when applying alignment. |
(...skipping 18 matching lines...) Expand all Loading... |
2137 // https://bugs.webkit.org/show_bug.cgi?id=46473 | 2139 // https://bugs.webkit.org/show_bug.cgi?id=46473 |
2138 if (logicalWidth.isAuto() && !isStretchingColumnFlexItem(this) && autoWidthS
houldFitContent()) | 2140 if (logicalWidth.isAuto() && !isStretchingColumnFlexItem(this) && autoWidthS
houldFitContent()) |
2139 return true; | 2141 return true; |
2140 | 2142 |
2141 if (isHorizontalWritingMode() != containingBlock()->isHorizontalWritingMode(
)) | 2143 if (isHorizontalWritingMode() != containingBlock()->isHorizontalWritingMode(
)) |
2142 return true; | 2144 return true; |
2143 | 2145 |
2144 return false; | 2146 return false; |
2145 } | 2147 } |
2146 | 2148 |
2147 bool RenderBox::autoWidthShouldFitContent() const | 2149 bool LayoutBox::autoWidthShouldFitContent() const |
2148 { | 2150 { |
2149 return node() && (isHTMLInputElement(*node()) || isHTMLSelectElement(*node()
) || isHTMLButtonElement(*node()) | 2151 return node() && (isHTMLInputElement(*node()) || isHTMLSelectElement(*node()
) || isHTMLButtonElement(*node()) |
2150 || isHTMLTextAreaElement(*node()) || (isHTMLLegendElement(*node()) && !s
tyle()->hasOutOfFlowPosition())); | 2152 || isHTMLTextAreaElement(*node()) || (isHTMLLegendElement(*node()) && !s
tyle()->hasOutOfFlowPosition())); |
2151 } | 2153 } |
2152 | 2154 |
2153 void RenderBox::computeMarginsForDirection(MarginDirection flowDirection, const
RenderBlock* containingBlock, LayoutUnit containerWidth, LayoutUnit childWidth,
LayoutUnit& marginStart, LayoutUnit& marginEnd, Length marginStartLength, Length
marginEndLength) const | 2155 void LayoutBox::computeMarginsForDirection(MarginDirection flowDirection, const
RenderBlock* containingBlock, LayoutUnit containerWidth, LayoutUnit childWidth,
LayoutUnit& marginStart, LayoutUnit& marginEnd, Length marginStartLength, Length
marginEndLength) const |
2154 { | 2156 { |
2155 if (flowDirection == BlockDirection || isFloating() || isInline()) { | 2157 if (flowDirection == BlockDirection || isFloating() || isInline()) { |
2156 if (isTableCell() && flowDirection == BlockDirection) { | 2158 if (isTableCell() && flowDirection == BlockDirection) { |
2157 // FIXME: Not right if we allow cells to have different directionali
ty than the table. If we do allow this, though, | 2159 // FIXME: Not right if we allow cells to have different directionali
ty than the table. If we do allow this, though, |
2158 // we may just do it with an extra anonymous block inside the cell. | 2160 // we may just do it with an extra anonymous block inside the cell. |
2159 marginStart = 0; | 2161 marginStart = 0; |
2160 marginEnd = 0; | 2162 marginEnd = 0; |
2161 return; | 2163 return; |
2162 } | 2164 } |
2163 | 2165 |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2233 marginStart = availableWidth - childWidth - marginEnd; | 2235 marginStart = availableWidth - childWidth - marginEnd; |
2234 return; | 2236 return; |
2235 } | 2237 } |
2236 } | 2238 } |
2237 | 2239 |
2238 // Either no auto margins, or our margin box width is >= the container width
, auto margins will just turn into 0. | 2240 // Either no auto margins, or our margin box width is >= the container width
, auto margins will just turn into 0. |
2239 marginStart = marginStartWidth; | 2241 marginStart = marginStartWidth; |
2240 marginEnd = marginEndWidth; | 2242 marginEnd = marginEndWidth; |
2241 } | 2243 } |
2242 | 2244 |
2243 void RenderBox::updateLogicalHeight() | 2245 void LayoutBox::updateLogicalHeight() |
2244 { | 2246 { |
2245 m_intrinsicContentLogicalHeight = contentLogicalHeight(); | 2247 m_intrinsicContentLogicalHeight = contentLogicalHeight(); |
2246 | 2248 |
2247 LogicalExtentComputedValues computedValues; | 2249 LogicalExtentComputedValues computedValues; |
2248 computeLogicalHeight(logicalHeight(), logicalTop(), computedValues); | 2250 computeLogicalHeight(logicalHeight(), logicalTop(), computedValues); |
2249 | 2251 |
2250 setLogicalHeight(computedValues.m_extent); | 2252 setLogicalHeight(computedValues.m_extent); |
2251 setLogicalTop(computedValues.m_position); | 2253 setLogicalTop(computedValues.m_position); |
2252 setMarginBefore(computedValues.m_margins.m_before); | 2254 setMarginBefore(computedValues.m_margins.m_before); |
2253 setMarginAfter(computedValues.m_margins.m_after); | 2255 setMarginAfter(computedValues.m_margins.m_after); |
2254 } | 2256 } |
2255 | 2257 |
2256 void RenderBox::computeLogicalHeight(LayoutUnit logicalHeight, LayoutUnit logica
lTop, LogicalExtentComputedValues& computedValues) const | 2258 void LayoutBox::computeLogicalHeight(LayoutUnit logicalHeight, LayoutUnit logica
lTop, LogicalExtentComputedValues& computedValues) const |
2257 { | 2259 { |
2258 computedValues.m_extent = logicalHeight; | 2260 computedValues.m_extent = logicalHeight; |
2259 computedValues.m_position = logicalTop; | 2261 computedValues.m_position = logicalTop; |
2260 | 2262 |
2261 // Cell height is managed by the table and inline non-replaced elements do n
ot support a height property. | 2263 // Cell height is managed by the table and inline non-replaced elements do n
ot support a height property. |
2262 if (isTableCell() || (isInline() && !isReplaced())) | 2264 if (isTableCell() || (isInline() && !isReplaced())) |
2263 return; | 2265 return; |
2264 | 2266 |
2265 Length h; | 2267 Length h; |
2266 if (isOutOfFlowPositioned()) | 2268 if (isOutOfFlowPositioned()) { |
2267 computePositionedLogicalHeight(computedValues); | 2269 computePositionedLogicalHeight(computedValues); |
2268 else { | 2270 } else { |
2269 RenderBlock* cb = containingBlock(); | 2271 RenderBlock* cb = containingBlock(); |
2270 | 2272 |
2271 // If we are perpendicular to our containing block then we need to resol
ve our block-start and block-end margins so that if they | 2273 // If we are perpendicular to our containing block then we need to resol
ve our block-start and block-end margins so that if they |
2272 // are 'auto' we are centred or aligned within the inline flow containin
g block: this is done by computing the margins as though they are inline. | 2274 // are 'auto' we are centred or aligned within the inline flow containin
g block: this is done by computing the margins as though they are inline. |
2273 // Note that as this is the 'sizing phase' we are using our own writing
mode rather than the containing block's. We use the containing block's | 2275 // Note that as this is the 'sizing phase' we are using our own writing
mode rather than the containing block's. We use the containing block's |
2274 // writing mode when figuring out the block-direction margins for positi
oning in |computeAndSetBlockDirectionMargins| (i.e. margin collapsing etc.). | 2276 // writing mode when figuring out the block-direction margins for positi
oning in |computeAndSetBlockDirectionMargins| (i.e. margin collapsing etc.). |
2275 // See http://www.w3.org/TR/2014/CR-css-writing-modes-3-20140320/#orthog
onal-flows | 2277 // See http://www.w3.org/TR/2014/CR-css-writing-modes-3-20140320/#orthog
onal-flows |
2276 MarginDirection flowDirection = isHorizontalWritingMode() != cb->isHoriz
ontalWritingMode() ? InlineDirection : BlockDirection; | 2278 MarginDirection flowDirection = isHorizontalWritingMode() != cb->isHoriz
ontalWritingMode() ? InlineDirection : BlockDirection; |
2277 | 2279 |
2278 // For tables, calculate margins only. | 2280 // For tables, calculate margins only. |
2279 if (isTable()) { | 2281 if (isTable()) { |
2280 computeMarginsForDirection(flowDirection, cb, containingBlockLogical
WidthForContent(), computedValues.m_extent, computedValues.m_margins.m_before, | 2282 computeMarginsForDirection(flowDirection, cb, containingBlockLogical
WidthForContent(), computedValues.m_extent, computedValues.m_margins.m_before, |
2281 computedValues.m_margins.m_after, style()->marginBefore(), style
()->marginAfter()); | 2283 computedValues.m_margins.m_after, style()->marginBefore(), style
()->marginAfter()); |
2282 return; | 2284 return; |
2283 } | 2285 } |
2284 | 2286 |
2285 // FIXME: Account for writing-mode in flexible boxes. | 2287 // FIXME: Account for writing-mode in flexible boxes. |
2286 // https://bugs.webkit.org/show_bug.cgi?id=46418 | 2288 // https://bugs.webkit.org/show_bug.cgi?id=46418 |
2287 bool inHorizontalBox = parent()->isDeprecatedFlexibleBox() && parent()->
style()->boxOrient() == HORIZONTAL; | 2289 bool inHorizontalBox = parent()->isDeprecatedFlexibleBox() && parent()->
style()->boxOrient() == HORIZONTAL; |
2288 bool stretching = parent()->style()->boxAlign() == BSTRETCH; | 2290 bool stretching = parent()->style()->boxAlign() == BSTRETCH; |
2289 bool treatAsReplaced = shouldComputeSizeAsReplaced() && (!inHorizontalBo
x || !stretching); | 2291 bool treatAsReplaced = shouldComputeSizeAsReplaced() && (!inHorizontalBo
x || !stretching); |
2290 bool checkMinMaxHeight = false; | 2292 bool checkMinMaxHeight = false; |
2291 | 2293 |
2292 // The parent box is flexing us, so it has increased or decreased our he
ight. We have to | 2294 // The parent box is flexing us, so it has increased or decreased our he
ight. We have to |
2293 // grab our cached flexible height. | 2295 // grab our cached flexible height. |
2294 // FIXME: Account for writing-mode in flexible boxes. | 2296 // FIXME: Account for writing-mode in flexible boxes. |
2295 // https://bugs.webkit.org/show_bug.cgi?id=46418 | 2297 // https://bugs.webkit.org/show_bug.cgi?id=46418 |
2296 if (hasOverrideHeight() && (parent()->isFlexibleBoxIncludingDeprecated()
|| parent()->isRenderGrid())) | 2298 if (hasOverrideHeight() && (parent()->isFlexibleBoxIncludingDeprecated()
|| parent()->isRenderGrid())) { |
2297 h = Length(overrideLogicalContentHeight(), Fixed); | 2299 h = Length(overrideLogicalContentHeight(), Fixed); |
2298 else if (treatAsReplaced) | 2300 } else if (treatAsReplaced) { |
2299 h = Length(computeReplacedLogicalHeight(), Fixed); | 2301 h = Length(computeReplacedLogicalHeight(), Fixed); |
2300 else { | 2302 } else { |
2301 h = style()->logicalHeight(); | 2303 h = style()->logicalHeight(); |
2302 checkMinMaxHeight = true; | 2304 checkMinMaxHeight = true; |
2303 } | 2305 } |
2304 | 2306 |
2305 // Block children of horizontal flexible boxes fill the height of the bo
x. | 2307 // Block children of horizontal flexible boxes fill the height of the bo
x. |
2306 // FIXME: Account for writing-mode in flexible boxes. | 2308 // FIXME: Account for writing-mode in flexible boxes. |
2307 // https://bugs.webkit.org/show_bug.cgi?id=46418 | 2309 // https://bugs.webkit.org/show_bug.cgi?id=46418 |
2308 if (h.isAuto() && inHorizontalBox && toRenderDeprecatedFlexibleBox(paren
t())->isStretchingChildren()) { | 2310 if (h.isAuto() && inHorizontalBox && toRenderDeprecatedFlexibleBox(paren
t())->isStretchingChildren()) { |
2309 h = Length(parentBox()->contentLogicalHeight() - marginBefore() - ma
rginAfter() - borderAndPaddingLogicalHeight(), Fixed); | 2311 h = Length(parentBox()->contentLogicalHeight() - marginBefore() - ma
rginAfter() - borderAndPaddingLogicalHeight(), Fixed); |
2310 checkMinMaxHeight = false; | 2312 checkMinMaxHeight = false; |
(...skipping 21 matching lines...) Expand all Loading... |
2332 // WinIE quirk: The <html> block always fills the entire canvas in quirks mo
de. The <body> always fills the | 2334 // WinIE quirk: The <html> block always fills the entire canvas in quirks mo
de. The <body> always fills the |
2333 // <html> block in quirks mode. Only apply this quirk if the block is norma
l flow and no height | 2335 // <html> block in quirks mode. Only apply this quirk if the block is norma
l flow and no height |
2334 // is specified. When we're printing, we also need this quirk if the body or
root has a percentage | 2336 // is specified. When we're printing, we also need this quirk if the body or
root has a percentage |
2335 // height since we don't set a height in RenderView when we're printing. So
without this quirk, the | 2337 // height since we don't set a height in RenderView when we're printing. So
without this quirk, the |
2336 // height has nothing to be a percentage of, and it ends up being 0. That is
bad. | 2338 // height has nothing to be a percentage of, and it ends up being 0. That is
bad. |
2337 bool paginatedContentNeedsBaseHeight = document().printing() && h.isPercent(
) | 2339 bool paginatedContentNeedsBaseHeight = document().printing() && h.isPercent(
) |
2338 && (isDocumentElement() || (isBody() && document().documentElement()->re
nderer()->style()->logicalHeight().isPercent())) && !isInline(); | 2340 && (isDocumentElement() || (isBody() && document().documentElement()->re
nderer()->style()->logicalHeight().isPercent())) && !isInline(); |
2339 if (stretchesToViewport() || paginatedContentNeedsBaseHeight) { | 2341 if (stretchesToViewport() || paginatedContentNeedsBaseHeight) { |
2340 LayoutUnit margins = collapsedMarginBefore() + collapsedMarginAfter(); | 2342 LayoutUnit margins = collapsedMarginBefore() + collapsedMarginAfter(); |
2341 LayoutUnit visibleHeight = view()->viewLogicalHeightForPercentages(); | 2343 LayoutUnit visibleHeight = view()->viewLogicalHeightForPercentages(); |
2342 if (isDocumentElement()) | 2344 if (isDocumentElement()) { |
2343 computedValues.m_extent = std::max(computedValues.m_extent, visibleH
eight - margins); | 2345 computedValues.m_extent = std::max(computedValues.m_extent, visibleH
eight - margins); |
2344 else { | 2346 } else { |
2345 LayoutUnit marginsBordersPadding = margins + parentBox()->marginBefo
re() + parentBox()->marginAfter() + parentBox()->borderAndPaddingLogicalHeight()
; | 2347 LayoutUnit marginsBordersPadding = margins + parentBox()->marginBefo
re() + parentBox()->marginAfter() + parentBox()->borderAndPaddingLogicalHeight()
; |
2346 computedValues.m_extent = std::max(computedValues.m_extent, visibleH
eight - marginsBordersPadding); | 2348 computedValues.m_extent = std::max(computedValues.m_extent, visibleH
eight - marginsBordersPadding); |
2347 } | 2349 } |
2348 } | 2350 } |
2349 } | 2351 } |
2350 | 2352 |
2351 LayoutUnit RenderBox::computeLogicalHeightUsing(const Length& height, LayoutUnit
intrinsicContentHeight) const | 2353 LayoutUnit LayoutBox::computeLogicalHeightUsing(const Length& height, LayoutUnit
intrinsicContentHeight) const |
2352 { | 2354 { |
2353 LayoutUnit logicalHeight = computeContentAndScrollbarLogicalHeightUsing(heig
ht, intrinsicContentHeight); | 2355 LayoutUnit logicalHeight = computeContentAndScrollbarLogicalHeightUsing(heig
ht, intrinsicContentHeight); |
2354 if (logicalHeight != -1) | 2356 if (logicalHeight != -1) |
2355 logicalHeight = adjustBorderBoxLogicalHeightForBoxSizing(logicalHeight); | 2357 logicalHeight = adjustBorderBoxLogicalHeightForBoxSizing(logicalHeight); |
2356 return logicalHeight; | 2358 return logicalHeight; |
2357 } | 2359 } |
2358 | 2360 |
2359 LayoutUnit RenderBox::computeContentLogicalHeight(const Length& height, LayoutUn
it intrinsicContentHeight) const | 2361 LayoutUnit LayoutBox::computeContentLogicalHeight(const Length& height, LayoutUn
it intrinsicContentHeight) const |
2360 { | 2362 { |
2361 LayoutUnit heightIncludingScrollbar = computeContentAndScrollbarLogicalHeigh
tUsing(height, intrinsicContentHeight); | 2363 LayoutUnit heightIncludingScrollbar = computeContentAndScrollbarLogicalHeigh
tUsing(height, intrinsicContentHeight); |
2362 if (heightIncludingScrollbar == -1) | 2364 if (heightIncludingScrollbar == -1) |
2363 return -1; | 2365 return -1; |
2364 return std::max(LayoutUnit(), adjustContentBoxLogicalHeightForBoxSizing(heig
htIncludingScrollbar) - scrollbarLogicalHeight()); | 2366 return std::max(LayoutUnit(), adjustContentBoxLogicalHeightForBoxSizing(heig
htIncludingScrollbar) - scrollbarLogicalHeight()); |
2365 } | 2367 } |
2366 | 2368 |
2367 LayoutUnit RenderBox::computeIntrinsicLogicalContentHeightUsing(const Length& lo
gicalHeightLength, LayoutUnit intrinsicContentHeight, LayoutUnit borderAndPaddin
g) const | 2369 LayoutUnit LayoutBox::computeIntrinsicLogicalContentHeightUsing(const Length& lo
gicalHeightLength, LayoutUnit intrinsicContentHeight, LayoutUnit borderAndPaddin
g) const |
2368 { | 2370 { |
2369 // FIXME(cbiesinger): The css-sizing spec is considering changing what min-c
ontent/max-content should resolve to. | 2371 // FIXME(cbiesinger): The css-sizing spec is considering changing what min-c
ontent/max-content should resolve to. |
2370 // If that happens, this code will have to change. | 2372 // If that happens, this code will have to change. |
2371 if (logicalHeightLength.isMinContent() || logicalHeightLength.isMaxContent()
|| logicalHeightLength.isFitContent()) { | 2373 if (logicalHeightLength.isMinContent() || logicalHeightLength.isMaxContent()
|| logicalHeightLength.isFitContent()) { |
2372 if (isReplaced()) | 2374 if (isReplaced()) |
2373 return intrinsicSize().height(); | 2375 return intrinsicSize().height(); |
2374 if (m_intrinsicContentLogicalHeight != -1) | 2376 if (m_intrinsicContentLogicalHeight != -1) |
2375 return m_intrinsicContentLogicalHeight; | 2377 return m_intrinsicContentLogicalHeight; |
2376 return intrinsicContentHeight; | 2378 return intrinsicContentHeight; |
2377 } | 2379 } |
2378 if (logicalHeightLength.isFillAvailable()) | 2380 if (logicalHeightLength.isFillAvailable()) |
2379 return containingBlock()->availableLogicalHeight(ExcludeMarginBorderPadd
ing) - borderAndPadding; | 2381 return containingBlock()->availableLogicalHeight(ExcludeMarginBorderPadd
ing) - borderAndPadding; |
2380 ASSERT_NOT_REACHED(); | 2382 ASSERT_NOT_REACHED(); |
2381 return 0; | 2383 return 0; |
2382 } | 2384 } |
2383 | 2385 |
2384 LayoutUnit RenderBox::computeContentAndScrollbarLogicalHeightUsing(const Length&
height, LayoutUnit intrinsicContentHeight) const | 2386 LayoutUnit LayoutBox::computeContentAndScrollbarLogicalHeightUsing(const Length&
height, LayoutUnit intrinsicContentHeight) const |
2385 { | 2387 { |
2386 // FIXME(cbiesinger): The css-sizing spec is considering changing what min-c
ontent/max-content should resolve to. | 2388 // FIXME(cbiesinger): The css-sizing spec is considering changing what min-c
ontent/max-content should resolve to. |
2387 // If that happens, this code will have to change. | 2389 // If that happens, this code will have to change. |
2388 if (height.isIntrinsic()) { | 2390 if (height.isIntrinsic()) { |
2389 if (intrinsicContentHeight == -1) | 2391 if (intrinsicContentHeight == -1) |
2390 return -1; // Intrinsic height isn't available. | 2392 return -1; // Intrinsic height isn't available. |
2391 return computeIntrinsicLogicalContentHeightUsing(height, intrinsicConten
tHeight, borderAndPaddingLogicalHeight()); | 2393 return computeIntrinsicLogicalContentHeightUsing(height, intrinsicConten
tHeight, borderAndPaddingLogicalHeight()); |
2392 } | 2394 } |
2393 if (height.isFixed()) | 2395 if (height.isFixed()) |
2394 return height.value(); | 2396 return height.value(); |
2395 if (height.isPercent()) | 2397 if (height.isPercent()) |
2396 return computePercentageLogicalHeight(height); | 2398 return computePercentageLogicalHeight(height); |
2397 return -1; | 2399 return -1; |
2398 } | 2400 } |
2399 | 2401 |
2400 bool RenderBox::skipContainingBlockForPercentHeightCalculation(const RenderBox*
containingBlock) const | 2402 bool LayoutBox::skipContainingBlockForPercentHeightCalculation(const LayoutBox*
containingBlock) const |
2401 { | 2403 { |
2402 // If the writing mode of the containing block is orthogonal to ours, it mea
ns that we shouldn't | 2404 // If the writing mode of the containing block is orthogonal to ours, it mea
ns that we shouldn't |
2403 // skip anything, since we're going to resolve the percentage height against
a containing block *width*. | 2405 // skip anything, since we're going to resolve the percentage height against
a containing block *width*. |
2404 if (isHorizontalWritingMode() != containingBlock->isHorizontalWritingMode()) | 2406 if (isHorizontalWritingMode() != containingBlock->isHorizontalWritingMode()) |
2405 return false; | 2407 return false; |
2406 | 2408 |
2407 // Flow threads for multicol or paged overflow should be skipped. They are i
nvisible to the DOM, | 2409 // Flow threads for multicol or paged overflow should be skipped. They are i
nvisible to the DOM, |
2408 // and percent heights of children should be resolved against the multicol o
r paged container. | 2410 // and percent heights of children should be resolved against the multicol o
r paged container. |
2409 if (containingBlock->isLayoutFlowThread()) | 2411 if (containingBlock->isLayoutFlowThread()) |
2410 return true; | 2412 return true; |
2411 | 2413 |
2412 // For quirks mode and anonymous blocks, we skip auto-height containingBlock
s when computing percentages. | 2414 // For quirks mode and anonymous blocks, we skip auto-height containingBlock
s when computing percentages. |
2413 // For standards mode, we treat the percentage as auto if it has an auto-hei
ght containing block. | 2415 // For standards mode, we treat the percentage as auto if it has an auto-hei
ght containing block. |
2414 if (!document().inQuirksMode() && !containingBlock->isAnonymousBlock()) | 2416 if (!document().inQuirksMode() && !containingBlock->isAnonymousBlock()) |
2415 return false; | 2417 return false; |
2416 | 2418 |
2417 return !containingBlock->isTableCell() && !containingBlock->isOutOfFlowPosit
ioned() && containingBlock->style()->logicalHeight().isAuto(); | 2419 return !containingBlock->isTableCell() && !containingBlock->isOutOfFlowPosit
ioned() && containingBlock->style()->logicalHeight().isAuto(); |
2418 } | 2420 } |
2419 | 2421 |
2420 LayoutUnit RenderBox::computePercentageLogicalHeight(const Length& height) const | 2422 LayoutUnit LayoutBox::computePercentageLogicalHeight(const Length& height) const |
2421 { | 2423 { |
2422 LayoutUnit availableHeight = -1; | 2424 LayoutUnit availableHeight = -1; |
2423 | 2425 |
2424 bool skippedAutoHeightContainingBlock = false; | 2426 bool skippedAutoHeightContainingBlock = false; |
2425 RenderBlock* cb = containingBlock(); | 2427 RenderBlock* cb = containingBlock(); |
2426 const RenderBox* containingBlockChild = this; | 2428 const LayoutBox* containingBlockChild = this; |
2427 LayoutUnit rootMarginBorderPaddingHeight = 0; | 2429 LayoutUnit rootMarginBorderPaddingHeight = 0; |
2428 while (!cb->isRenderView() && skipContainingBlockForPercentHeightCalculation
(cb)) { | 2430 while (!cb->isRenderView() && skipContainingBlockForPercentHeightCalculation
(cb)) { |
2429 if (cb->isBody() || cb->isDocumentElement()) | 2431 if (cb->isBody() || cb->isDocumentElement()) |
2430 rootMarginBorderPaddingHeight += cb->marginBefore() + cb->marginAfte
r() + cb->borderAndPaddingLogicalHeight(); | 2432 rootMarginBorderPaddingHeight += cb->marginBefore() + cb->marginAfte
r() + cb->borderAndPaddingLogicalHeight(); |
2431 skippedAutoHeightContainingBlock = true; | 2433 skippedAutoHeightContainingBlock = true; |
2432 containingBlockChild = cb; | 2434 containingBlockChild = cb; |
2433 cb = cb->containingBlock(); | 2435 cb = cb->containingBlock(); |
2434 } | 2436 } |
2435 cb->addPercentHeightDescendant(const_cast<RenderBox*>(this)); | 2437 cb->addPercentHeightDescendant(const_cast<LayoutBox*>(this)); |
2436 | 2438 |
2437 const LayoutStyle& cbstyle = cb->styleRef(); | 2439 const LayoutStyle& cbstyle = cb->styleRef(); |
2438 | 2440 |
2439 // A positioned element that specified both top/bottom or that specifies hei
ght should be treated as though it has a height | 2441 // A positioned element that specified both top/bottom or that specifies hei
ght should be treated as though it has a height |
2440 // explicitly specified that can be used for any percentage computations. | 2442 // explicitly specified that can be used for any percentage computations. |
2441 bool isOutOfFlowPositionedWithSpecifiedHeight = cb->isOutOfFlowPositioned()
&& (!cbstyle.logicalHeight().isAuto() || (!cbstyle.logicalTop().isAuto() && !cbs
tyle.logicalBottom().isAuto())); | 2443 bool isOutOfFlowPositionedWithSpecifiedHeight = cb->isOutOfFlowPositioned()
&& (!cbstyle.logicalHeight().isAuto() || (!cbstyle.logicalTop().isAuto() && !cbs
tyle.logicalBottom().isAuto())); |
2442 | 2444 |
2443 bool includeBorderPadding = isTable(); | 2445 bool includeBorderPadding = isTable(); |
2444 | 2446 |
2445 if (isHorizontalWritingMode() != cb->isHorizontalWritingMode()) | 2447 if (isHorizontalWritingMode() != cb->isHorizontalWritingMode()) { |
2446 availableHeight = containingBlockChild->containingBlockLogicalWidthForCo
ntent(); | 2448 availableHeight = containingBlockChild->containingBlockLogicalWidthForCo
ntent(); |
2447 else if (hasOverrideContainingBlockLogicalHeight()) | 2449 } else if (hasOverrideContainingBlockLogicalHeight()) { |
2448 availableHeight = overrideContainingBlockContentLogicalHeight(); | 2450 availableHeight = overrideContainingBlockContentLogicalHeight(); |
2449 else if (cb->isTableCell()) { | 2451 } else if (cb->isTableCell()) { |
2450 if (!skippedAutoHeightContainingBlock) { | 2452 if (!skippedAutoHeightContainingBlock) { |
2451 // Table cells violate what the CSS spec says to do with heights. Ba
sically we | 2453 // Table cells violate what the CSS spec says to do with heights. Ba
sically we |
2452 // don't care if the cell specified a height or not. We just always
make ourselves | 2454 // don't care if the cell specified a height or not. We just always
make ourselves |
2453 // be a percentage of the cell's current content height. | 2455 // be a percentage of the cell's current content height. |
2454 if (!cb->hasOverrideHeight()) { | 2456 if (!cb->hasOverrideHeight()) { |
2455 // Normally we would let the cell size intrinsically, but scroll
ing overflow has to be | 2457 // Normally we would let the cell size intrinsically, but scroll
ing overflow has to be |
2456 // treated differently, since WinIE lets scrolled overflow regio
ns shrink as needed. | 2458 // treated differently, since WinIE lets scrolled overflow regio
ns shrink as needed. |
2457 // While we can't get all cases right, we can at least detect wh
en the cell has a specified | 2459 // While we can't get all cases right, we can at least detect wh
en the cell has a specified |
2458 // height or when the table has a specified height. In these cas
es we want to initially have | 2460 // height or when the table has a specified height. In these cas
es we want to initially have |
2459 // no size and allow the flexing of the table or the cell to its
specified height to cause us | 2461 // no size and allow the flexing of the table or the cell to its
specified height to cause us |
(...skipping 21 matching lines...) Expand all Loading... |
2481 // yet. | 2483 // yet. |
2482 LayoutUnit contentBoxHeight = cb->constrainContentBoxLogicalHeightBy
MinMax(contentBoxHeightWithScrollbar - cb->scrollbarLogicalHeight(), -1); | 2484 LayoutUnit contentBoxHeight = cb->constrainContentBoxLogicalHeightBy
MinMax(contentBoxHeightWithScrollbar - cb->scrollbarLogicalHeight(), -1); |
2483 availableHeight = std::max(LayoutUnit(), contentBoxHeight); | 2485 availableHeight = std::max(LayoutUnit(), contentBoxHeight); |
2484 } | 2486 } |
2485 } else if (isOutOfFlowPositionedWithSpecifiedHeight) { | 2487 } else if (isOutOfFlowPositionedWithSpecifiedHeight) { |
2486 // Don't allow this to affect the block' size() member variable, since t
his | 2488 // Don't allow this to affect the block' size() member variable, since t
his |
2487 // can get called while the block is still laying out its kids. | 2489 // can get called while the block is still laying out its kids. |
2488 LogicalExtentComputedValues computedValues; | 2490 LogicalExtentComputedValues computedValues; |
2489 cb->computeLogicalHeight(cb->logicalHeight(), 0, computedValues); | 2491 cb->computeLogicalHeight(cb->logicalHeight(), 0, computedValues); |
2490 availableHeight = computedValues.m_extent - cb->borderAndPaddingLogicalH
eight() - cb->scrollbarLogicalHeight(); | 2492 availableHeight = computedValues.m_extent - cb->borderAndPaddingLogicalH
eight() - cb->scrollbarLogicalHeight(); |
2491 } else if (cb->isRenderView()) | 2493 } else if (cb->isRenderView()) { |
2492 availableHeight = view()->viewLogicalHeightForPercentages(); | 2494 availableHeight = view()->viewLogicalHeightForPercentages(); |
| 2495 } |
2493 | 2496 |
2494 if (availableHeight == -1) | 2497 if (availableHeight == -1) |
2495 return availableHeight; | 2498 return availableHeight; |
2496 | 2499 |
2497 availableHeight -= rootMarginBorderPaddingHeight; | 2500 availableHeight -= rootMarginBorderPaddingHeight; |
2498 | 2501 |
2499 if (isTable() && isOutOfFlowPositioned()) | 2502 if (isTable() && isOutOfFlowPositioned()) |
2500 availableHeight += cb->paddingLogicalHeight(); | 2503 availableHeight += cb->paddingLogicalHeight(); |
2501 | 2504 |
2502 LayoutUnit result = valueForLength(height, availableHeight); | 2505 LayoutUnit result = valueForLength(height, availableHeight); |
2503 if (includeBorderPadding) { | 2506 if (includeBorderPadding) { |
2504 // FIXME: Table cells should default to box-sizing: border-box so we can
avoid this hack. | 2507 // FIXME: Table cells should default to box-sizing: border-box so we can
avoid this hack. |
2505 // It is necessary to use the border-box to match WinIE's broken | 2508 // It is necessary to use the border-box to match WinIE's broken |
2506 // box model. This is essential for sizing inside | 2509 // box model. This is essential for sizing inside |
2507 // table cells using percentage heights. | 2510 // table cells using percentage heights. |
2508 result -= borderAndPaddingLogicalHeight(); | 2511 result -= borderAndPaddingLogicalHeight(); |
2509 return std::max(LayoutUnit(), result); | 2512 return std::max(LayoutUnit(), result); |
2510 } | 2513 } |
2511 return result; | 2514 return result; |
2512 } | 2515 } |
2513 | 2516 |
2514 LayoutUnit RenderBox::computeReplacedLogicalWidth(ShouldComputePreferred shouldC
omputePreferred) const | 2517 LayoutUnit LayoutBox::computeReplacedLogicalWidth(ShouldComputePreferred shouldC
omputePreferred) const |
2515 { | 2518 { |
2516 return computeReplacedLogicalWidthRespectingMinMaxWidth(computeReplacedLogic
alWidthUsing(style()->logicalWidth()), shouldComputePreferred); | 2519 return computeReplacedLogicalWidthRespectingMinMaxWidth(computeReplacedLogic
alWidthUsing(style()->logicalWidth()), shouldComputePreferred); |
2517 } | 2520 } |
2518 | 2521 |
2519 LayoutUnit RenderBox::computeReplacedLogicalWidthRespectingMinMaxWidth(LayoutUni
t logicalWidth, ShouldComputePreferred shouldComputePreferred) const | 2522 LayoutUnit LayoutBox::computeReplacedLogicalWidthRespectingMinMaxWidth(LayoutUni
t logicalWidth, ShouldComputePreferred shouldComputePreferred) const |
2520 { | 2523 { |
2521 LayoutUnit minLogicalWidth = (shouldComputePreferred == ComputePreferred &&
style()->logicalMinWidth().isPercent()) || style()->logicalMinWidth().isMaxSizeN
one() ? logicalWidth : computeReplacedLogicalWidthUsing(style()->logicalMinWidth
()); | 2524 LayoutUnit minLogicalWidth = (shouldComputePreferred == ComputePreferred &&
style()->logicalMinWidth().isPercent()) || style()->logicalMinWidth().isMaxSizeN
one() ? logicalWidth : computeReplacedLogicalWidthUsing(style()->logicalMinWidth
()); |
2522 LayoutUnit maxLogicalWidth = (shouldComputePreferred == ComputePreferred &&
style()->logicalMaxWidth().isPercent()) || style()->logicalMaxWidth().isMaxSizeN
one() ? logicalWidth : computeReplacedLogicalWidthUsing(style()->logicalMaxWidth
()); | 2525 LayoutUnit maxLogicalWidth = (shouldComputePreferred == ComputePreferred &&
style()->logicalMaxWidth().isPercent()) || style()->logicalMaxWidth().isMaxSizeN
one() ? logicalWidth : computeReplacedLogicalWidthUsing(style()->logicalMaxWidth
()); |
2523 return std::max(minLogicalWidth, std::min(logicalWidth, maxLogicalWidth)); | 2526 return std::max(minLogicalWidth, std::min(logicalWidth, maxLogicalWidth)); |
2524 } | 2527 } |
2525 | 2528 |
2526 LayoutUnit RenderBox::computeReplacedLogicalWidthUsing(const Length& logicalWidt
h) const | 2529 LayoutUnit LayoutBox::computeReplacedLogicalWidthUsing(const Length& logicalWidt
h) const |
2527 { | 2530 { |
2528 switch (logicalWidth.type()) { | 2531 switch (logicalWidth.type()) { |
2529 case Fixed: | 2532 case Fixed: |
2530 return adjustContentBoxLogicalWidthForBoxSizing(logicalWidth.value()
); | 2533 return adjustContentBoxLogicalWidthForBoxSizing(logicalWidth.value()); |
2531 case MinContent: | 2534 case MinContent: |
2532 case MaxContent: { | 2535 case MaxContent: { |
2533 // MinContent/MaxContent don't need the availableLogicalWidth argume
nt. | 2536 // MinContent/MaxContent don't need the availableLogicalWidth argument. |
2534 LayoutUnit availableLogicalWidth = 0; | 2537 LayoutUnit availableLogicalWidth = 0; |
2535 return computeIntrinsicLogicalWidthUsing(logicalWidth, availableLogi
calWidth, borderAndPaddingLogicalWidth()) - borderAndPaddingLogicalWidth(); | 2538 return computeIntrinsicLogicalWidthUsing(logicalWidth, availableLogicalW
idth, borderAndPaddingLogicalWidth()) - borderAndPaddingLogicalWidth(); |
2536 } | 2539 } |
2537 case FitContent: | 2540 case FitContent: |
2538 case FillAvailable: | 2541 case FillAvailable: |
2539 case Percent: | 2542 case Percent: |
2540 case Calculated: { | 2543 case Calculated: { |
2541 // FIXME: containingBlockLogicalWidthForContent() is wrong if the re
placed element's writing-mode is perpendicular to the | 2544 // FIXME: containingBlockLogicalWidthForContent() is wrong if the replac
ed element's writing-mode is perpendicular to the |
2542 // containing block's writing-mode. | 2545 // containing block's writing-mode. |
2543 // https://bugs.webkit.org/show_bug.cgi?id=46496 | 2546 // https://bugs.webkit.org/show_bug.cgi?id=46496 |
2544 const LayoutUnit cw = isOutOfFlowPositioned() ? containingBlockLogic
alWidthForPositioned(toLayoutBoxModelObject(container())) : containingBlockLogic
alWidthForContent(); | 2547 const LayoutUnit cw = isOutOfFlowPositioned() ? containingBlockLogicalWi
dthForPositioned(toLayoutBoxModelObject(container())) : containingBlockLogicalWi
dthForContent(); |
2545 Length containerLogicalWidth = containingBlock()->style()->logicalWi
dth(); | 2548 Length containerLogicalWidth = containingBlock()->style()->logicalWidth(
); |
2546 // FIXME: Handle cases when containing block width is calculated or
viewport percent. | 2549 // FIXME: Handle cases when containing block width is calculated or view
port percent. |
2547 // https://bugs.webkit.org/show_bug.cgi?id=91071 | 2550 // https://bugs.webkit.org/show_bug.cgi?id=91071 |
2548 if (logicalWidth.isIntrinsic()) | 2551 if (logicalWidth.isIntrinsic()) |
2549 return computeIntrinsicLogicalWidthUsing(logicalWidth, cw, borde
rAndPaddingLogicalWidth()) - borderAndPaddingLogicalWidth(); | 2552 return computeIntrinsicLogicalWidthUsing(logicalWidth, cw, borderAnd
PaddingLogicalWidth()) - borderAndPaddingLogicalWidth(); |
2550 if (cw > 0 || (!cw && (containerLogicalWidth.isFixed() || containerL
ogicalWidth.isPercent()))) | 2553 if (cw > 0 || (!cw && (containerLogicalWidth.isFixed() || containerLogic
alWidth.isPercent()))) |
2551 return adjustContentBoxLogicalWidthForBoxSizing(minimumValueForL
ength(logicalWidth, cw)); | 2554 return adjustContentBoxLogicalWidthForBoxSizing(minimumValueForLengt
h(logicalWidth, cw)); |
2552 return LayoutUnit(); | 2555 return LayoutUnit(); |
2553 } | 2556 } |
2554 case Intrinsic: | 2557 case Intrinsic: |
2555 case MinIntrinsic: | 2558 case MinIntrinsic: |
2556 case Auto: | 2559 case Auto: |
2557 case MaxSizeNone: | 2560 case MaxSizeNone: |
2558 return intrinsicLogicalWidth(); | 2561 return intrinsicLogicalWidth(); |
2559 case ExtendToZoom: | 2562 case ExtendToZoom: |
2560 case DeviceWidth: | 2563 case DeviceWidth: |
2561 case DeviceHeight: | 2564 case DeviceHeight: |
2562 break; | 2565 break; |
2563 } | 2566 } |
2564 | 2567 |
2565 ASSERT_NOT_REACHED(); | 2568 ASSERT_NOT_REACHED(); |
2566 return 0; | 2569 return 0; |
2567 } | 2570 } |
2568 | 2571 |
2569 LayoutUnit RenderBox::computeReplacedLogicalHeight() const | 2572 LayoutUnit LayoutBox::computeReplacedLogicalHeight() const |
2570 { | 2573 { |
2571 return computeReplacedLogicalHeightRespectingMinMaxHeight(computeReplacedLog
icalHeightUsing(style()->logicalHeight())); | 2574 return computeReplacedLogicalHeightRespectingMinMaxHeight(computeReplacedLog
icalHeightUsing(style()->logicalHeight())); |
2572 } | 2575 } |
2573 | 2576 |
2574 bool RenderBox::logicalHeightComputesAsNone(SizeType sizeType) const | 2577 bool LayoutBox::logicalHeightComputesAsNone(SizeType sizeType) const |
2575 { | 2578 { |
2576 ASSERT(sizeType == MinSize || sizeType == MaxSize); | 2579 ASSERT(sizeType == MinSize || sizeType == MaxSize); |
2577 Length logicalHeight = sizeType == MinSize ? style()->logicalMinHeight() : s
tyle()->logicalMaxHeight(); | 2580 Length logicalHeight = sizeType == MinSize ? style()->logicalMinHeight() : s
tyle()->logicalMaxHeight(); |
2578 Length initialLogicalHeight = sizeType == MinSize ? LayoutStyle::initialMinS
ize() : LayoutStyle::initialMaxSize(); | 2581 Length initialLogicalHeight = sizeType == MinSize ? LayoutStyle::initialMinS
ize() : LayoutStyle::initialMaxSize(); |
2579 | 2582 |
2580 if (logicalHeight == initialLogicalHeight) | 2583 if (logicalHeight == initialLogicalHeight) |
2581 return true; | 2584 return true; |
2582 | 2585 |
2583 if (RenderBlock* cb = containingBlockForAutoHeightDetection(logicalHeight)) | 2586 if (RenderBlock* cb = containingBlockForAutoHeightDetection(logicalHeight)) |
2584 return cb->hasAutoHeightOrContainingBlockWithAutoHeight(); | 2587 return cb->hasAutoHeightOrContainingBlockWithAutoHeight(); |
2585 return false; | 2588 return false; |
2586 } | 2589 } |
2587 | 2590 |
2588 LayoutUnit RenderBox::computeReplacedLogicalHeightRespectingMinMaxHeight(LayoutU
nit logicalHeight) const | 2591 LayoutUnit LayoutBox::computeReplacedLogicalHeightRespectingMinMaxHeight(LayoutU
nit logicalHeight) const |
2589 { | 2592 { |
2590 // If the height of the containing block is not specified explicitly (i.e.,
it depends on content height), and this element is not absolutely positioned, | 2593 // If the height of the containing block is not specified explicitly (i.e.,
it depends on content height), and this element is not absolutely positioned, |
2591 // the percentage value is treated as '0' (for 'min-height') or 'none' (for
'max-height'). | 2594 // the percentage value is treated as '0' (for 'min-height') or 'none' (for
'max-height'). |
2592 LayoutUnit minLogicalHeight; | 2595 LayoutUnit minLogicalHeight; |
2593 if (!logicalHeightComputesAsNone(MinSize)) | 2596 if (!logicalHeightComputesAsNone(MinSize)) |
2594 minLogicalHeight = computeReplacedLogicalHeightUsing(style()->logicalMin
Height()); | 2597 minLogicalHeight = computeReplacedLogicalHeightUsing(style()->logicalMin
Height()); |
2595 LayoutUnit maxLogicalHeight = logicalHeight; | 2598 LayoutUnit maxLogicalHeight = logicalHeight; |
2596 if (!logicalHeightComputesAsNone(MaxSize)) | 2599 if (!logicalHeightComputesAsNone(MaxSize)) |
2597 maxLogicalHeight = computeReplacedLogicalHeightUsing(style()->logicalMa
xHeight()); | 2600 maxLogicalHeight = computeReplacedLogicalHeightUsing(style()->logicalMa
xHeight()); |
2598 return std::max(minLogicalHeight, std::min(logicalHeight, maxLogicalHeight))
; | 2601 return std::max(minLogicalHeight, std::min(logicalHeight, maxLogicalHeight))
; |
2599 } | 2602 } |
2600 | 2603 |
2601 LayoutUnit RenderBox::computeReplacedLogicalHeightUsing(const Length& logicalHei
ght) const | 2604 LayoutUnit LayoutBox::computeReplacedLogicalHeightUsing(const Length& logicalHei
ght) const |
2602 { | 2605 { |
2603 switch (logicalHeight.type()) { | 2606 switch (logicalHeight.type()) { |
2604 case Fixed: | 2607 case Fixed: |
2605 return adjustContentBoxLogicalHeightForBoxSizing(logicalHeight.value
()); | 2608 return adjustContentBoxLogicalHeightForBoxSizing(logicalHeight.value()); |
2606 case Percent: | 2609 case Percent: |
2607 case Calculated: | 2610 case Calculated: |
2608 { | 2611 { |
2609 LayoutObject* cb = isOutOfFlowPositioned() ? container() : containin
gBlock(); | 2612 LayoutObject* cb = isOutOfFlowPositioned() ? container() : containingBlo
ck(); |
2610 while (cb->isAnonymous()) | 2613 while (cb->isAnonymous()) |
| 2614 cb = cb->containingBlock(); |
| 2615 if (cb->isRenderBlock()) |
| 2616 toRenderBlock(cb)->addPercentHeightDescendant(const_cast<LayoutBox*>
(this)); |
| 2617 |
| 2618 if (cb->isOutOfFlowPositioned() && cb->style()->height().isAuto() && !(c
b->style()->top().isAuto() || cb->style()->bottom().isAuto())) { |
| 2619 ASSERT_WITH_SECURITY_IMPLICATION(cb->isRenderBlock()); |
| 2620 RenderBlock* block = toRenderBlock(cb); |
| 2621 LogicalExtentComputedValues computedValues; |
| 2622 block->computeLogicalHeight(block->logicalHeight(), 0, computedValue
s); |
| 2623 LayoutUnit newContentHeight = computedValues.m_extent - block->borde
rAndPaddingLogicalHeight() - block->scrollbarLogicalHeight(); |
| 2624 LayoutUnit newHeight = block->adjustContentBoxLogicalHeightForBoxSiz
ing(newContentHeight); |
| 2625 return adjustContentBoxLogicalHeightForBoxSizing(valueForLength(logi
calHeight, newHeight)); |
| 2626 } |
| 2627 |
| 2628 // FIXME: availableLogicalHeight() is wrong if the replaced element's wr
iting-mode is perpendicular to the |
| 2629 // containing block's writing-mode. |
| 2630 // https://bugs.webkit.org/show_bug.cgi?id=46496 |
| 2631 LayoutUnit availableHeight; |
| 2632 if (isOutOfFlowPositioned()) { |
| 2633 availableHeight = containingBlockLogicalHeightForPositioned(toLayout
BoxModelObject(cb)); |
| 2634 } else { |
| 2635 availableHeight = containingBlockLogicalHeightForContent(IncludeMarg
inBorderPadding); |
| 2636 // It is necessary to use the border-box to match WinIE's broken |
| 2637 // box model. This is essential for sizing inside |
| 2638 // table cells using percentage heights. |
| 2639 // FIXME: This needs to be made writing-mode-aware. If the cell and
image are perpendicular writing-modes, this isn't right. |
| 2640 // https://bugs.webkit.org/show_bug.cgi?id=46997 |
| 2641 while (cb && !cb->isRenderView() && (cb->style()->logicalHeight().is
Auto() || cb->style()->logicalHeight().isPercent())) { |
| 2642 if (cb->isTableCell()) { |
| 2643 // Don't let table cells squeeze percent-height replaced ele
ments |
| 2644 // <http://bugs.webkit.org/show_bug.cgi?id=15359> |
| 2645 availableHeight = std::max(availableHeight, intrinsicLogical
Height()); |
| 2646 return valueForLength(logicalHeight, availableHeight - borde
rAndPaddingLogicalHeight()); |
| 2647 } |
| 2648 toRenderBlock(cb)->addPercentHeightDescendant(const_cast<LayoutB
ox*>(this)); |
2611 cb = cb->containingBlock(); | 2649 cb = cb->containingBlock(); |
2612 if (cb->isRenderBlock()) | |
2613 toRenderBlock(cb)->addPercentHeightDescendant(const_cast<RenderB
ox*>(this)); | |
2614 | |
2615 if (cb->isOutOfFlowPositioned() && cb->style()->height().isAuto() &&
!(cb->style()->top().isAuto() || cb->style()->bottom().isAuto())) { | |
2616 ASSERT_WITH_SECURITY_IMPLICATION(cb->isRenderBlock()); | |
2617 RenderBlock* block = toRenderBlock(cb); | |
2618 LogicalExtentComputedValues computedValues; | |
2619 block->computeLogicalHeight(block->logicalHeight(), 0, computedV
alues); | |
2620 LayoutUnit newContentHeight = computedValues.m_extent - block->b
orderAndPaddingLogicalHeight() - block->scrollbarLogicalHeight(); | |
2621 LayoutUnit newHeight = block->adjustContentBoxLogicalHeightForBo
xSizing(newContentHeight); | |
2622 return adjustContentBoxLogicalHeightForBoxSizing(valueForLength(
logicalHeight, newHeight)); | |
2623 } | 2650 } |
2624 | |
2625 // FIXME: availableLogicalHeight() is wrong if the replaced element'
s writing-mode is perpendicular to the | |
2626 // containing block's writing-mode. | |
2627 // https://bugs.webkit.org/show_bug.cgi?id=46496 | |
2628 LayoutUnit availableHeight; | |
2629 if (isOutOfFlowPositioned()) | |
2630 availableHeight = containingBlockLogicalHeightForPositioned(toLa
youtBoxModelObject(cb)); | |
2631 else { | |
2632 availableHeight = containingBlockLogicalHeightForContent(Include
MarginBorderPadding); | |
2633 // It is necessary to use the border-box to match WinIE's broken | |
2634 // box model. This is essential for sizing inside | |
2635 // table cells using percentage heights. | |
2636 // FIXME: This needs to be made writing-mode-aware. If the cell
and image are perpendicular writing-modes, this isn't right. | |
2637 // https://bugs.webkit.org/show_bug.cgi?id=46997 | |
2638 while (cb && !cb->isRenderView() && (cb->style()->logicalHeight(
).isAuto() || cb->style()->logicalHeight().isPercent())) { | |
2639 if (cb->isTableCell()) { | |
2640 // Don't let table cells squeeze percent-height replaced
elements | |
2641 // <http://bugs.webkit.org/show_bug.cgi?id=15359> | |
2642 availableHeight = std::max(availableHeight, intrinsicLog
icalHeight()); | |
2643 return valueForLength(logicalHeight, availableHeight - b
orderAndPaddingLogicalHeight()); | |
2644 } | |
2645 toRenderBlock(cb)->addPercentHeightDescendant(const_cast<Ren
derBox*>(this)); | |
2646 cb = cb->containingBlock(); | |
2647 } | |
2648 } | |
2649 return adjustContentBoxLogicalHeightForBoxSizing(valueForLength(logi
calHeight, availableHeight)); | |
2650 } | 2651 } |
2651 case MinContent: | 2652 return adjustContentBoxLogicalHeightForBoxSizing(valueForLength(logicalH
eight, availableHeight)); |
2652 case MaxContent: | 2653 } |
2653 case FitContent: | 2654 case MinContent: |
2654 case FillAvailable: | 2655 case MaxContent: |
2655 return adjustContentBoxLogicalHeightForBoxSizing(computeIntrinsicLog
icalContentHeightUsing(logicalHeight, intrinsicLogicalHeight(), borderAndPadding
Height())); | 2656 case FitContent: |
2656 default: | 2657 case FillAvailable: |
2657 return intrinsicLogicalHeight(); | 2658 return adjustContentBoxLogicalHeightForBoxSizing(computeIntrinsicLogical
ContentHeightUsing(logicalHeight, intrinsicLogicalHeight(), borderAndPaddingHeig
ht())); |
| 2659 default: |
| 2660 return intrinsicLogicalHeight(); |
2658 } | 2661 } |
2659 } | 2662 } |
2660 | 2663 |
2661 LayoutUnit RenderBox::availableLogicalHeight(AvailableLogicalHeightType heightTy
pe) const | 2664 LayoutUnit LayoutBox::availableLogicalHeight(AvailableLogicalHeightType heightTy
pe) const |
2662 { | 2665 { |
2663 // http://www.w3.org/TR/CSS2/visudet.html#propdef-height - We are interested
in the content height. | 2666 // http://www.w3.org/TR/CSS2/visudet.html#propdef-height - We are interested
in the content height. |
2664 return constrainContentBoxLogicalHeightByMinMax(availableLogicalHeightUsing(
style()->logicalHeight(), heightType), -1); | 2667 return constrainContentBoxLogicalHeightByMinMax(availableLogicalHeightUsing(
style()->logicalHeight(), heightType), -1); |
2665 } | 2668 } |
2666 | 2669 |
2667 LayoutUnit RenderBox::availableLogicalHeightUsing(const Length& h, AvailableLogi
calHeightType heightType) const | 2670 LayoutUnit LayoutBox::availableLogicalHeightUsing(const Length& h, AvailableLogi
calHeightType heightType) const |
2668 { | 2671 { |
2669 if (isRenderView()) | 2672 if (isRenderView()) |
2670 return isHorizontalWritingMode() ? toRenderView(this)->frameView()->unsc
aledVisibleContentSize().height() : toRenderView(this)->frameView()->unscaledVis
ibleContentSize().width(); | 2673 return isHorizontalWritingMode() ? toRenderView(this)->frameView()->unsc
aledVisibleContentSize().height() : toRenderView(this)->frameView()->unscaledVis
ibleContentSize().width(); |
2671 | 2674 |
2672 // We need to stop here, since we don't want to increase the height of the t
able | 2675 // We need to stop here, since we don't want to increase the height of the t
able |
2673 // artificially. We're going to rely on this cell getting expanded to some
new | 2676 // artificially. We're going to rely on this cell getting expanded to some
new |
2674 // height, and then when we lay out again we'll use the calculation below. | 2677 // height, and then when we lay out again we'll use the calculation below. |
2675 if (isTableCell() && (h.isAuto() || h.isPercent())) { | 2678 if (isTableCell() && (h.isAuto() || h.isPercent())) { |
2676 if (hasOverrideHeight()) | 2679 if (hasOverrideHeight()) |
2677 return overrideLogicalContentHeight(); | 2680 return overrideLogicalContentHeight(); |
(...skipping 22 matching lines...) Expand all Loading... |
2700 | 2703 |
2701 // FIXME: This is wrong if the containingBlock has a perpendicular writing m
ode. | 2704 // FIXME: This is wrong if the containingBlock has a perpendicular writing m
ode. |
2702 LayoutUnit availableHeight = containingBlockLogicalHeightForContent(heightTy
pe); | 2705 LayoutUnit availableHeight = containingBlockLogicalHeightForContent(heightTy
pe); |
2703 if (heightType == ExcludeMarginBorderPadding) { | 2706 if (heightType == ExcludeMarginBorderPadding) { |
2704 // FIXME: Margin collapsing hasn't happened yet, so this incorrectly rem
oves collapsed margins. | 2707 // FIXME: Margin collapsing hasn't happened yet, so this incorrectly rem
oves collapsed margins. |
2705 availableHeight -= marginBefore() + marginAfter() + borderAndPaddingLogi
calHeight(); | 2708 availableHeight -= marginBefore() + marginAfter() + borderAndPaddingLogi
calHeight(); |
2706 } | 2709 } |
2707 return availableHeight; | 2710 return availableHeight; |
2708 } | 2711 } |
2709 | 2712 |
2710 void RenderBox::computeAndSetBlockDirectionMargins(const RenderBlock* containing
Block) | 2713 void LayoutBox::computeAndSetBlockDirectionMargins(const RenderBlock* containing
Block) |
2711 { | 2714 { |
2712 LayoutUnit marginBefore; | 2715 LayoutUnit marginBefore; |
2713 LayoutUnit marginAfter; | 2716 LayoutUnit marginAfter; |
2714 computeMarginsForDirection(BlockDirection, containingBlock, containingBlockL
ogicalWidthForContent(), logicalHeight(), marginBefore, marginAfter, | 2717 computeMarginsForDirection(BlockDirection, containingBlock, containingBlockL
ogicalWidthForContent(), logicalHeight(), marginBefore, marginAfter, |
2715 style()->marginBeforeUsing(containingBlock->style()), | 2718 style()->marginBeforeUsing(containingBlock->style()), |
2716 style()->marginAfterUsing(containingBlock->style())); | 2719 style()->marginAfterUsing(containingBlock->style())); |
2717 // Note that in this 'positioning phase' of the layout we are using the cont
aining block's writing mode rather than our own when calculating margins. | 2720 // Note that in this 'positioning phase' of the layout we are using the cont
aining block's writing mode rather than our own when calculating margins. |
2718 // See http://www.w3.org/TR/2014/CR-css-writing-modes-3-20140320/#orthogonal
-flows | 2721 // See http://www.w3.org/TR/2014/CR-css-writing-modes-3-20140320/#orthogonal
-flows |
2719 containingBlock->setMarginBeforeForChild(*this, marginBefore); | 2722 containingBlock->setMarginBeforeForChild(*this, marginBefore); |
2720 containingBlock->setMarginAfterForChild(*this, marginAfter); | 2723 containingBlock->setMarginAfterForChild(*this, marginAfter); |
2721 } | 2724 } |
2722 | 2725 |
2723 LayoutUnit RenderBox::containingBlockLogicalWidthForPositioned(const LayoutBoxMo
delObject* containingBlock, bool checkForPerpendicularWritingMode) const | 2726 LayoutUnit LayoutBox::containingBlockLogicalWidthForPositioned(const LayoutBoxMo
delObject* containingBlock, bool checkForPerpendicularWritingMode) const |
2724 { | 2727 { |
2725 if (checkForPerpendicularWritingMode && containingBlock->isHorizontalWriting
Mode() != isHorizontalWritingMode()) | 2728 if (checkForPerpendicularWritingMode && containingBlock->isHorizontalWriting
Mode() != isHorizontalWritingMode()) |
2726 return containingBlockLogicalHeightForPositioned(containingBlock, false)
; | 2729 return containingBlockLogicalHeightForPositioned(containingBlock, false)
; |
2727 | 2730 |
2728 // Use viewport as container for top-level fixed-position elements. | 2731 // Use viewport as container for top-level fixed-position elements. |
2729 if (style()->position() == FixedPosition && containingBlock->isRenderView())
{ | 2732 if (style()->position() == FixedPosition && containingBlock->isRenderView())
{ |
2730 const RenderView* view = toRenderView(containingBlock); | 2733 const RenderView* view = toRenderView(containingBlock); |
2731 if (FrameView* frameView = view->frameView()) { | 2734 if (FrameView* frameView = view->frameView()) { |
2732 LayoutRect viewportRect = frameView->viewportConstrainedVisibleConte
ntRect(); | 2735 LayoutRect viewportRect = frameView->viewportConstrainedVisibleConte
ntRect(); |
2733 return containingBlock->isHorizontalWritingMode() ? viewportRect.wid
th() : viewportRect.height(); | 2736 return containingBlock->isHorizontalWritingMode() ? viewportRect.wid
th() : viewportRect.height(); |
2734 } | 2737 } |
2735 } | 2738 } |
2736 | 2739 |
2737 if (hasOverrideContainingBlockLogicalWidth()) | 2740 if (hasOverrideContainingBlockLogicalWidth()) |
2738 return overrideContainingBlockContentLogicalWidth(); | 2741 return overrideContainingBlockContentLogicalWidth(); |
2739 | 2742 |
2740 if (containingBlock->isBox()) | 2743 if (containingBlock->isBox()) |
2741 return toRenderBox(containingBlock)->clientLogicalWidth(); | 2744 return toLayoutBox(containingBlock)->clientLogicalWidth(); |
2742 | 2745 |
2743 ASSERT(containingBlock->isRenderInline() && containingBlock->isRelPositioned
()); | 2746 ASSERT(containingBlock->isRenderInline() && containingBlock->isRelPositioned
()); |
2744 | 2747 |
2745 const RenderInline* flow = toRenderInline(containingBlock); | 2748 const RenderInline* flow = toRenderInline(containingBlock); |
2746 InlineFlowBox* first = flow->firstLineBox(); | 2749 InlineFlowBox* first = flow->firstLineBox(); |
2747 InlineFlowBox* last = flow->lastLineBox(); | 2750 InlineFlowBox* last = flow->lastLineBox(); |
2748 | 2751 |
2749 // If the containing block is empty, return a width of 0. | 2752 // If the containing block is empty, return a width of 0. |
2750 if (!first || !last) | 2753 if (!first || !last) |
2751 return LayoutUnit(); | 2754 return LayoutUnit(); |
2752 | 2755 |
2753 LayoutUnit fromLeft; | 2756 LayoutUnit fromLeft; |
2754 LayoutUnit fromRight; | 2757 LayoutUnit fromRight; |
2755 if (containingBlock->style()->isLeftToRightDirection()) { | 2758 if (containingBlock->style()->isLeftToRightDirection()) { |
2756 fromLeft = first->logicalLeft() + first->borderLogicalLeft(); | 2759 fromLeft = first->logicalLeft() + first->borderLogicalLeft(); |
2757 fromRight = last->logicalLeft() + last->logicalWidth() - last->borderLog
icalRight(); | 2760 fromRight = last->logicalLeft() + last->logicalWidth() - last->borderLog
icalRight(); |
2758 } else { | 2761 } else { |
2759 fromRight = first->logicalLeft() + first->logicalWidth() - first->border
LogicalRight(); | 2762 fromRight = first->logicalLeft() + first->logicalWidth() - first->border
LogicalRight(); |
2760 fromLeft = last->logicalLeft() + last->borderLogicalLeft(); | 2763 fromLeft = last->logicalLeft() + last->borderLogicalLeft(); |
2761 } | 2764 } |
2762 | 2765 |
2763 return std::max(LayoutUnit(), fromRight - fromLeft); | 2766 return std::max(LayoutUnit(), fromRight - fromLeft); |
2764 } | 2767 } |
2765 | 2768 |
2766 LayoutUnit RenderBox::containingBlockLogicalHeightForPositioned(const LayoutBoxM
odelObject* containingBlock, bool checkForPerpendicularWritingMode) const | 2769 LayoutUnit LayoutBox::containingBlockLogicalHeightForPositioned(const LayoutBoxM
odelObject* containingBlock, bool checkForPerpendicularWritingMode) const |
2767 { | 2770 { |
2768 if (checkForPerpendicularWritingMode && containingBlock->isHorizontalWriting
Mode() != isHorizontalWritingMode()) | 2771 if (checkForPerpendicularWritingMode && containingBlock->isHorizontalWriting
Mode() != isHorizontalWritingMode()) |
2769 return containingBlockLogicalWidthForPositioned(containingBlock, false); | 2772 return containingBlockLogicalWidthForPositioned(containingBlock, false); |
2770 | 2773 |
2771 // Use viewport as container for top-level fixed-position elements. | 2774 // Use viewport as container for top-level fixed-position elements. |
2772 if (style()->position() == FixedPosition && containingBlock->isRenderView())
{ | 2775 if (style()->position() == FixedPosition && containingBlock->isRenderView())
{ |
2773 const RenderView* view = toRenderView(containingBlock); | 2776 const RenderView* view = toRenderView(containingBlock); |
2774 if (FrameView* frameView = view->frameView()) { | 2777 if (FrameView* frameView = view->frameView()) { |
2775 LayoutRect viewportRect = frameView->viewportConstrainedVisibleConte
ntRect(); | 2778 LayoutRect viewportRect = frameView->viewportConstrainedVisibleConte
ntRect(); |
2776 return containingBlock->isHorizontalWritingMode() ? viewportRect.hei
ght() : viewportRect.width(); | 2779 return containingBlock->isHorizontalWritingMode() ? viewportRect.hei
ght() : viewportRect.width(); |
(...skipping 22 matching lines...) Expand all Loading... |
2799 LayoutUnit heightResult; | 2802 LayoutUnit heightResult; |
2800 LayoutRect boundingBox = flow->linesBoundingBox(); | 2803 LayoutRect boundingBox = flow->linesBoundingBox(); |
2801 if (containingBlock->isHorizontalWritingMode()) | 2804 if (containingBlock->isHorizontalWritingMode()) |
2802 heightResult = boundingBox.height(); | 2805 heightResult = boundingBox.height(); |
2803 else | 2806 else |
2804 heightResult = boundingBox.width(); | 2807 heightResult = boundingBox.width(); |
2805 heightResult -= (containingBlock->borderBefore() + containingBlock->borderAf
ter()); | 2808 heightResult -= (containingBlock->borderBefore() + containingBlock->borderAf
ter()); |
2806 return heightResult; | 2809 return heightResult; |
2807 } | 2810 } |
2808 | 2811 |
2809 static void computeInlineStaticDistance(Length& logicalLeft, Length& logicalRigh
t, const RenderBox* child, const LayoutBoxModelObject* containerBlock, LayoutUni
t containerLogicalWidth) | 2812 static void computeInlineStaticDistance(Length& logicalLeft, Length& logicalRigh
t, const LayoutBox* child, const LayoutBoxModelObject* containerBlock, LayoutUni
t containerLogicalWidth) |
2810 { | 2813 { |
2811 if (!logicalLeft.isAuto() || !logicalRight.isAuto()) | 2814 if (!logicalLeft.isAuto() || !logicalRight.isAuto()) |
2812 return; | 2815 return; |
2813 | 2816 |
2814 // FIXME: The static distance computation has not been patched for mixed wri
ting modes yet. | 2817 // FIXME: The static distance computation has not been patched for mixed wri
ting modes yet. |
2815 if (child->parent()->style()->direction() == LTR) { | 2818 if (child->parent()->style()->direction() == LTR) { |
2816 LayoutUnit staticPosition = child->layer()->staticInlinePosition() - con
tainerBlock->borderLogicalLeft(); | 2819 LayoutUnit staticPosition = child->layer()->staticInlinePosition() - con
tainerBlock->borderLogicalLeft(); |
2817 for (LayoutObject* curr = child->parent(); curr && curr != containerBloc
k; curr = curr->container()) { | 2820 for (LayoutObject* curr = child->parent(); curr && curr != containerBloc
k; curr = curr->container()) { |
2818 if (curr->isBox()) { | 2821 if (curr->isBox()) { |
2819 staticPosition += toRenderBox(curr)->logicalLeft(); | 2822 staticPosition += toLayoutBox(curr)->logicalLeft(); |
2820 if (toRenderBox(curr)->isRelPositioned()) | 2823 if (toLayoutBox(curr)->isRelPositioned()) |
2821 staticPosition += toRenderBox(curr)->relativePositionOffset(
).width(); | 2824 staticPosition += toLayoutBox(curr)->relativePositionOffset(
).width(); |
2822 } else if (curr->isInline()) { | 2825 } else if (curr->isInline()) { |
2823 if (curr->isRelPositioned()) { | 2826 if (curr->isRelPositioned()) { |
2824 if (!curr->style()->logicalLeft().isAuto()) | 2827 if (!curr->style()->logicalLeft().isAuto()) |
2825 staticPosition += valueForLength(curr->style()->logicalL
eft(), curr->containingBlock()->availableWidth()); | 2828 staticPosition += valueForLength(curr->style()->logicalL
eft(), curr->containingBlock()->availableWidth()); |
2826 else | 2829 else |
2827 staticPosition -= valueForLength(curr->style()->logicalR
ight(), curr->containingBlock()->availableWidth()); | 2830 staticPosition -= valueForLength(curr->style()->logicalR
ight(), curr->containingBlock()->availableWidth()); |
2828 } | 2831 } |
2829 } | 2832 } |
2830 } | 2833 } |
2831 logicalLeft.setValue(Fixed, staticPosition); | 2834 logicalLeft.setValue(Fixed, staticPosition); |
2832 } else { | 2835 } else { |
2833 RenderBox* enclosingBox = child->parent()->enclosingBox(); | 2836 LayoutBox* enclosingBox = child->parent()->enclosingBox(); |
2834 LayoutUnit staticPosition = child->layer()->staticInlinePosition() + con
tainerLogicalWidth + containerBlock->borderLogicalLeft(); | 2837 LayoutUnit staticPosition = child->layer()->staticInlinePosition() + con
tainerLogicalWidth + containerBlock->borderLogicalLeft(); |
2835 for (LayoutObject* curr = child->parent(); curr; curr = curr->container(
)) { | 2838 for (LayoutObject* curr = child->parent(); curr; curr = curr->container(
)) { |
2836 if (curr->isBox()) { | 2839 if (curr->isBox()) { |
2837 if (curr != containerBlock) { | 2840 if (curr != containerBlock) { |
2838 staticPosition -= toRenderBox(curr)->logicalLeft(); | 2841 staticPosition -= toLayoutBox(curr)->logicalLeft(); |
2839 if (toRenderBox(curr)->isRelPositioned()) | 2842 if (toLayoutBox(curr)->isRelPositioned()) |
2840 staticPosition -= toRenderBox(curr)->relativePositionOff
set().width(); | 2843 staticPosition -= toLayoutBox(curr)->relativePositionOff
set().width(); |
2841 } | 2844 } |
2842 if (curr == enclosingBox) | 2845 if (curr == enclosingBox) |
2843 staticPosition -= enclosingBox->logicalWidth(); | 2846 staticPosition -= enclosingBox->logicalWidth(); |
2844 } else if (curr->isInline()) { | 2847 } else if (curr->isInline()) { |
2845 if (curr->isRelPositioned()) { | 2848 if (curr->isRelPositioned()) { |
2846 if (!curr->style()->logicalLeft().isAuto()) | 2849 if (!curr->style()->logicalLeft().isAuto()) |
2847 staticPosition -= valueForLength(curr->style()->logicalL
eft(), curr->containingBlock()->availableWidth()); | 2850 staticPosition -= valueForLength(curr->style()->logicalL
eft(), curr->containingBlock()->availableWidth()); |
2848 else | 2851 else |
2849 staticPosition += valueForLength(curr->style()->logicalR
ight(), curr->containingBlock()->availableWidth()); | 2852 staticPosition += valueForLength(curr->style()->logicalR
ight(), curr->containingBlock()->availableWidth()); |
2850 } | 2853 } |
2851 } | 2854 } |
2852 if (curr == containerBlock) | 2855 if (curr == containerBlock) |
2853 break; | 2856 break; |
2854 } | 2857 } |
2855 logicalRight.setValue(Fixed, staticPosition); | 2858 logicalRight.setValue(Fixed, staticPosition); |
2856 } | 2859 } |
2857 } | 2860 } |
2858 | 2861 |
2859 void RenderBox::computePositionedLogicalWidth(LogicalExtentComputedValues& compu
tedValues) const | 2862 void LayoutBox::computePositionedLogicalWidth(LogicalExtentComputedValues& compu
tedValues) const |
2860 { | 2863 { |
2861 if (isReplaced()) { | 2864 if (isReplaced()) { |
2862 computePositionedLogicalWidthReplaced(computedValues); | 2865 computePositionedLogicalWidthReplaced(computedValues); |
2863 return; | 2866 return; |
2864 } | 2867 } |
2865 | 2868 |
2866 // QUESTIONS | 2869 // QUESTIONS |
2867 // FIXME 1: Should we still deal with these the cases of 'left' or 'right' h
aving | 2870 // FIXME 1: Should we still deal with these the cases of 'left' or 'right' h
aving |
2868 // the type 'static' in determining whether to calculate the static distance
? | 2871 // the type 'static' in determining whether to calculate the static distance
? |
2869 // NOTE: 'static' is not a legal value for 'left' or 'right' as of CSS 2.1. | 2872 // NOTE: 'static' is not a legal value for 'left' or 'right' as of CSS 2.1. |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2921 * viewport, and all scrollable boxes should be assumed to be scrolled to th
eir | 2924 * viewport, and all scrollable boxes should be assumed to be scrolled to th
eir |
2922 * origin. | 2925 * origin. |
2923 \*--------------------------------------------------------------------------
-*/ | 2926 \*--------------------------------------------------------------------------
-*/ |
2924 | 2927 |
2925 // see FIXME 1 | 2928 // see FIXME 1 |
2926 // Calculate the static distance if needed. | 2929 // Calculate the static distance if needed. |
2927 computeInlineStaticDistance(logicalLeftLength, logicalRightLength, this, con
tainerBlock, containerLogicalWidth); | 2930 computeInlineStaticDistance(logicalLeftLength, logicalRightLength, this, con
tainerBlock, containerLogicalWidth); |
2928 | 2931 |
2929 // Calculate constraint equation values for 'width' case. | 2932 // Calculate constraint equation values for 'width' case. |
2930 computePositionedLogicalWidthUsing(style()->logicalWidth(), containerBlock,
containerDirection, | 2933 computePositionedLogicalWidthUsing(style()->logicalWidth(), containerBlock,
containerDirection, |
2931 containerLogicalWidth, bordersPlusPadding
, | 2934 containerLogicalWidth, bordersPlusPadding, |
2932 logicalLeftLength, logicalRightLength, ma
rginLogicalLeft, marginLogicalRight, | 2935 logicalLeftLength, logicalRightLength, marginLogicalLeft, marginLogicalR
ight, |
2933 computedValues); | 2936 computedValues); |
2934 | 2937 |
2935 // Calculate constraint equation values for 'max-width' case. | 2938 // Calculate constraint equation values for 'max-width' case. |
2936 if (!style()->logicalMaxWidth().isMaxSizeNone()) { | 2939 if (!style()->logicalMaxWidth().isMaxSizeNone()) { |
2937 LogicalExtentComputedValues maxValues; | 2940 LogicalExtentComputedValues maxValues; |
2938 | 2941 |
2939 computePositionedLogicalWidthUsing(style()->logicalMaxWidth(), container
Block, containerDirection, | 2942 computePositionedLogicalWidthUsing(style()->logicalMaxWidth(), container
Block, containerDirection, |
2940 containerLogicalWidth, bordersPlusPad
ding, | 2943 containerLogicalWidth, bordersPlusPadding, |
2941 logicalLeftLength, logicalRightLength
, marginLogicalLeft, marginLogicalRight, | 2944 logicalLeftLength, logicalRightLength, marginLogicalLeft, marginLogi
calRight, |
2942 maxValues); | 2945 maxValues); |
2943 | 2946 |
2944 if (computedValues.m_extent > maxValues.m_extent) { | 2947 if (computedValues.m_extent > maxValues.m_extent) { |
2945 computedValues.m_extent = maxValues.m_extent; | 2948 computedValues.m_extent = maxValues.m_extent; |
2946 computedValues.m_position = maxValues.m_position; | 2949 computedValues.m_position = maxValues.m_position; |
2947 computedValues.m_margins.m_start = maxValues.m_margins.m_start; | 2950 computedValues.m_margins.m_start = maxValues.m_margins.m_start; |
2948 computedValues.m_margins.m_end = maxValues.m_margins.m_end; | 2951 computedValues.m_margins.m_end = maxValues.m_margins.m_end; |
2949 } | 2952 } |
2950 } | 2953 } |
2951 | 2954 |
2952 // Calculate constraint equation values for 'min-width' case. | 2955 // Calculate constraint equation values for 'min-width' case. |
2953 if (!style()->logicalMinWidth().isZero() || style()->logicalMinWidth().isInt
rinsic()) { | 2956 if (!style()->logicalMinWidth().isZero() || style()->logicalMinWidth().isInt
rinsic()) { |
2954 LogicalExtentComputedValues minValues; | 2957 LogicalExtentComputedValues minValues; |
2955 | 2958 |
2956 computePositionedLogicalWidthUsing(style()->logicalMinWidth(), container
Block, containerDirection, | 2959 computePositionedLogicalWidthUsing(style()->logicalMinWidth(), container
Block, containerDirection, |
2957 containerLogicalWidth, bordersPlusPad
ding, | 2960 containerLogicalWidth, bordersPlusPadding, |
2958 logicalLeftLength, logicalRightLength
, marginLogicalLeft, marginLogicalRight, | 2961 logicalLeftLength, logicalRightLength, marginLogicalLeft, marginLogi
calRight, |
2959 minValues); | 2962 minValues); |
2960 | 2963 |
2961 if (computedValues.m_extent < minValues.m_extent) { | 2964 if (computedValues.m_extent < minValues.m_extent) { |
2962 computedValues.m_extent = minValues.m_extent; | 2965 computedValues.m_extent = minValues.m_extent; |
2963 computedValues.m_position = minValues.m_position; | 2966 computedValues.m_position = minValues.m_position; |
2964 computedValues.m_margins.m_start = minValues.m_margins.m_start; | 2967 computedValues.m_margins.m_start = minValues.m_margins.m_start; |
2965 computedValues.m_margins.m_end = minValues.m_margins.m_end; | 2968 computedValues.m_margins.m_end = minValues.m_margins.m_end; |
2966 } | 2969 } |
2967 } | 2970 } |
2968 | 2971 |
2969 if (!style()->hasStaticInlinePosition(isHorizontal)) | 2972 if (!style()->hasStaticInlinePosition(isHorizontal)) |
2970 computedValues.m_position += extraInlineOffset(); | 2973 computedValues.m_position += extraInlineOffset(); |
2971 | 2974 |
2972 computedValues.m_extent += bordersPlusPadding; | 2975 computedValues.m_extent += bordersPlusPadding; |
2973 } | 2976 } |
2974 | 2977 |
2975 static void computeLogicalLeftPositionedOffset(LayoutUnit& logicalLeftPos, const
RenderBox* child, LayoutUnit logicalWidthValue, const LayoutBoxModelObject* con
tainerBlock, LayoutUnit containerLogicalWidth) | 2978 static void computeLogicalLeftPositionedOffset(LayoutUnit& logicalLeftPos, const
LayoutBox* child, LayoutUnit logicalWidthValue, const LayoutBoxModelObject* con
tainerBlock, LayoutUnit containerLogicalWidth) |
2976 { | 2979 { |
2977 // Deal with differing writing modes here. Our offset needs to be in the co
ntaining block's coordinate space. If the containing block is flipped | 2980 // Deal with differing writing modes here. Our offset needs to be in the co
ntaining block's coordinate space. If the containing block is flipped |
2978 // along this axis, then we need to flip the coordinate. This can only happ
en if the containing block is both a flipped mode and perpendicular to us. | 2981 // along this axis, then we need to flip the coordinate. This can only happ
en if the containing block is both a flipped mode and perpendicular to us. |
2979 if (containerBlock->isHorizontalWritingMode() != child->isHorizontalWritingM
ode() && containerBlock->style()->isFlippedBlocksWritingMode()) { | 2982 if (containerBlock->isHorizontalWritingMode() != child->isHorizontalWritingM
ode() && containerBlock->style()->isFlippedBlocksWritingMode()) { |
2980 logicalLeftPos = containerLogicalWidth - logicalWidthValue - logicalLeft
Pos; | 2983 logicalLeftPos = containerLogicalWidth - logicalWidthValue - logicalLeft
Pos; |
2981 logicalLeftPos += (child->isHorizontalWritingMode() ? containerBlock->bo
rderRight() : containerBlock->borderBottom()); | 2984 logicalLeftPos += (child->isHorizontalWritingMode() ? containerBlock->bo
rderRight() : containerBlock->borderBottom()); |
2982 } else { | 2985 } else { |
2983 logicalLeftPos += (child->isHorizontalWritingMode() ? containerBlock->bo
rderLeft() : containerBlock->borderTop()); | 2986 logicalLeftPos += (child->isHorizontalWritingMode() ? containerBlock->bo
rderLeft() : containerBlock->borderTop()); |
2984 } | 2987 } |
2985 } | 2988 } |
2986 | 2989 |
2987 LayoutUnit RenderBox::shrinkToFitLogicalWidth(LayoutUnit availableLogicalWidth,
LayoutUnit bordersPlusPadding) const | 2990 LayoutUnit LayoutBox::shrinkToFitLogicalWidth(LayoutUnit availableLogicalWidth,
LayoutUnit bordersPlusPadding) const |
2988 { | 2991 { |
2989 LayoutUnit preferredLogicalWidth = maxPreferredLogicalWidth() - bordersPlusP
adding; | 2992 LayoutUnit preferredLogicalWidth = maxPreferredLogicalWidth() - bordersPlusP
adding; |
2990 LayoutUnit preferredMinLogicalWidth = minPreferredLogicalWidth() - bordersPl
usPadding; | 2993 LayoutUnit preferredMinLogicalWidth = minPreferredLogicalWidth() - bordersPl
usPadding; |
2991 return std::min(std::max(preferredMinLogicalWidth, availableLogicalWidth), p
referredLogicalWidth); | 2994 return std::min(std::max(preferredMinLogicalWidth, availableLogicalWidth), p
referredLogicalWidth); |
2992 } | 2995 } |
2993 | 2996 |
2994 void RenderBox::computePositionedLogicalWidthUsing(Length logicalWidth, const La
youtBoxModelObject* containerBlock, TextDirection containerDirection, | 2997 void LayoutBox::computePositionedLogicalWidthUsing(Length logicalWidth, const La
youtBoxModelObject* containerBlock, TextDirection containerDirection, |
2995 LayoutUnit containerLogicalWi
dth, LayoutUnit bordersPlusPadding, | 2998 LayoutUnit containerLogicalWidth, LayoutUnit bordersPlusPadding, |
2996 const Length& logicalLeft, co
nst Length& logicalRight, const Length& marginLogicalLeft, | 2999 const Length& logicalLeft, const Length& logicalRight, const Length& marginL
ogicalLeft, |
2997 const Length& marginLogicalRi
ght, LogicalExtentComputedValues& computedValues) const | 3000 const Length& marginLogicalRight, LogicalExtentComputedValues& computedValue
s) const |
2998 { | 3001 { |
2999 if (logicalWidth.isIntrinsic()) | 3002 if (logicalWidth.isIntrinsic()) |
3000 logicalWidth = Length(computeIntrinsicLogicalWidthUsing(logicalWidth, co
ntainerLogicalWidth, bordersPlusPadding) - bordersPlusPadding, Fixed); | 3003 logicalWidth = Length(computeIntrinsicLogicalWidthUsing(logicalWidth, co
ntainerLogicalWidth, bordersPlusPadding) - bordersPlusPadding, Fixed); |
3001 | 3004 |
3002 // 'left' and 'right' cannot both be 'auto' because one would of been | 3005 // 'left' and 'right' cannot both be 'auto' because one would of been |
3003 // converted to the static position already | 3006 // converted to the static position already |
3004 ASSERT(!(logicalLeft.isAuto() && logicalRight.isAuto())); | 3007 ASSERT(!(logicalLeft.isAuto() && logicalRight.isAuto())); |
3005 | 3008 |
3006 // minimumValueForLength will convert 'auto' to 0 so that it doesn't impact
the available space computation below. | 3009 // minimumValueForLength will convert 'auto' to 0 so that it doesn't impact
the available space computation below. |
3007 LayoutUnit logicalLeftValue = minimumValueForLength(logicalLeft, containerLo
gicalWidth); | 3010 LayoutUnit logicalLeftValue = minimumValueForLength(logicalLeft, containerLo
gicalWidth); |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3151 if (containerBlock->isRenderInline() && !containerBlock->style()->isLeftToRi
ghtDirection()) { | 3154 if (containerBlock->isRenderInline() && !containerBlock->style()->isLeftToRi
ghtDirection()) { |
3152 const RenderInline* flow = toRenderInline(containerBlock); | 3155 const RenderInline* flow = toRenderInline(containerBlock); |
3153 InlineFlowBox* firstLine = flow->firstLineBox(); | 3156 InlineFlowBox* firstLine = flow->firstLineBox(); |
3154 InlineFlowBox* lastLine = flow->lastLineBox(); | 3157 InlineFlowBox* lastLine = flow->lastLineBox(); |
3155 if (firstLine && lastLine && firstLine != lastLine) { | 3158 if (firstLine && lastLine && firstLine != lastLine) { |
3156 computedValues.m_position = logicalLeftValue + marginLogicalLeftValu
e + lastLine->borderLogicalLeft() + (lastLine->logicalLeft() - firstLine->logica
lLeft()); | 3159 computedValues.m_position = logicalLeftValue + marginLogicalLeftValu
e + lastLine->borderLogicalLeft() + (lastLine->logicalLeft() - firstLine->logica
lLeft()); |
3157 return; | 3160 return; |
3158 } | 3161 } |
3159 } | 3162 } |
3160 | 3163 |
3161 if (containerBlock->isBox() && toRenderBox(containerBlock)->scrollsOverflowY
() && containerBlock->style()->shouldPlaceBlockDirectionScrollbarOnLogicalLeft()
) { | 3164 if (containerBlock->isBox() && toLayoutBox(containerBlock)->scrollsOverflowY
() && containerBlock->style()->shouldPlaceBlockDirectionScrollbarOnLogicalLeft()
) { |
3162 logicalLeftValue = logicalLeftValue + toRenderBox(containerBlock)->verti
calScrollbarWidth(); | 3165 logicalLeftValue = logicalLeftValue + toLayoutBox(containerBlock)->verti
calScrollbarWidth(); |
3163 } | 3166 } |
3164 | 3167 |
3165 computedValues.m_position = logicalLeftValue + marginLogicalLeftValue; | 3168 computedValues.m_position = logicalLeftValue + marginLogicalLeftValue; |
3166 computeLogicalLeftPositionedOffset(computedValues.m_position, this, computed
Values.m_extent, containerBlock, containerLogicalWidth); | 3169 computeLogicalLeftPositionedOffset(computedValues.m_position, this, computed
Values.m_extent, containerBlock, containerLogicalWidth); |
3167 } | 3170 } |
3168 | 3171 |
3169 static void computeBlockStaticDistance(Length& logicalTop, Length& logicalBottom
, const RenderBox* child, const LayoutBoxModelObject* containerBlock) | 3172 static void computeBlockStaticDistance(Length& logicalTop, Length& logicalBottom
, const LayoutBox* child, const LayoutBoxModelObject* containerBlock) |
3170 { | 3173 { |
3171 if (!logicalTop.isAuto() || !logicalBottom.isAuto()) | 3174 if (!logicalTop.isAuto() || !logicalBottom.isAuto()) |
3172 return; | 3175 return; |
3173 | 3176 |
3174 // FIXME: The static distance computation has not been patched for mixed wri
ting modes. | 3177 // FIXME: The static distance computation has not been patched for mixed wri
ting modes. |
3175 LayoutUnit staticLogicalTop = child->layer()->staticBlockPosition() - contai
nerBlock->borderBefore(); | 3178 LayoutUnit staticLogicalTop = child->layer()->staticBlockPosition() - contai
nerBlock->borderBefore(); |
3176 for (LayoutObject* curr = child->parent(); curr && curr != containerBlock; c
urr = curr->container()) { | 3179 for (LayoutObject* curr = child->parent(); curr && curr != containerBlock; c
urr = curr->container()) { |
3177 if (curr->isBox() && !curr->isTableRow()) | 3180 if (curr->isBox() && !curr->isTableRow()) |
3178 staticLogicalTop += toRenderBox(curr)->logicalTop(); | 3181 staticLogicalTop += toLayoutBox(curr)->logicalTop(); |
3179 } | 3182 } |
3180 logicalTop.setValue(Fixed, staticLogicalTop); | 3183 logicalTop.setValue(Fixed, staticLogicalTop); |
3181 } | 3184 } |
3182 | 3185 |
3183 void RenderBox::computePositionedLogicalHeight(LogicalExtentComputedValues& comp
utedValues) const | 3186 void LayoutBox::computePositionedLogicalHeight(LogicalExtentComputedValues& comp
utedValues) const |
3184 { | 3187 { |
3185 if (isReplaced()) { | 3188 if (isReplaced()) { |
3186 computePositionedLogicalHeightReplaced(computedValues); | 3189 computePositionedLogicalHeightReplaced(computedValues); |
3187 return; | 3190 return; |
3188 } | 3191 } |
3189 | 3192 |
3190 // The following is based off of the W3C Working Draft from April 11, 2006 o
f | 3193 // The following is based off of the W3C Working Draft from April 11, 2006 o
f |
3191 // CSS 2.1: Section 10.6.4 "Absolutely positioned, non-replaced elements" | 3194 // CSS 2.1: Section 10.6.4 "Absolutely positioned, non-replaced elements" |
3192 // <http://www.w3.org/TR/2005/WD-CSS21-20050613/visudet.html#abs-non-replace
d-height> | 3195 // <http://www.w3.org/TR/2005/WD-CSS21-20050613/visudet.html#abs-non-replace
d-height> |
3193 // (block-style-comments in this function and in computePositionedLogicalHei
ghtUsing() | 3196 // (block-style-comments in this function and in computePositionedLogicalHei
ghtUsing() |
(...skipping 29 matching lines...) Expand all Loading... |
3223 * the viewport. | 3226 * the viewport. |
3224 \*--------------------------------------------------------------------------
-*/ | 3227 \*--------------------------------------------------------------------------
-*/ |
3225 | 3228 |
3226 // see FIXME 1 | 3229 // see FIXME 1 |
3227 // Calculate the static distance if needed. | 3230 // Calculate the static distance if needed. |
3228 computeBlockStaticDistance(logicalTopLength, logicalBottomLength, this, cont
ainerBlock); | 3231 computeBlockStaticDistance(logicalTopLength, logicalBottomLength, this, cont
ainerBlock); |
3229 | 3232 |
3230 // Calculate constraint equation values for 'height' case. | 3233 // Calculate constraint equation values for 'height' case. |
3231 LayoutUnit logicalHeight = computedValues.m_extent; | 3234 LayoutUnit logicalHeight = computedValues.m_extent; |
3232 computePositionedLogicalHeightUsing(styleToUse.logicalHeight(), containerBlo
ck, containerLogicalHeight, bordersPlusPadding, logicalHeight, | 3235 computePositionedLogicalHeightUsing(styleToUse.logicalHeight(), containerBlo
ck, containerLogicalHeight, bordersPlusPadding, logicalHeight, |
3233 logicalTopLength, logicalBottomLength, m
arginBefore, marginAfter, | 3236 logicalTopLength, logicalBottomLength, marginBefore, marginAfter, |
3234 computedValues); | 3237 computedValues); |
3235 | 3238 |
3236 // Avoid doing any work in the common case (where the values of min-height a
nd max-height are their defaults). | 3239 // Avoid doing any work in the common case (where the values of min-height a
nd max-height are their defaults). |
3237 // see FIXME 2 | 3240 // see FIXME 2 |
3238 | 3241 |
3239 // Calculate constraint equation values for 'max-height' case. | 3242 // Calculate constraint equation values for 'max-height' case. |
3240 if (!styleToUse.logicalMaxHeight().isMaxSizeNone()) { | 3243 if (!styleToUse.logicalMaxHeight().isMaxSizeNone()) { |
3241 LogicalExtentComputedValues maxValues; | 3244 LogicalExtentComputedValues maxValues; |
3242 | 3245 |
3243 computePositionedLogicalHeightUsing(styleToUse.logicalMaxHeight(), conta
inerBlock, containerLogicalHeight, bordersPlusPadding, logicalHeight, | 3246 computePositionedLogicalHeightUsing(styleToUse.logicalMaxHeight(), conta
inerBlock, containerLogicalHeight, bordersPlusPadding, logicalHeight, |
3244 logicalTopLength, logicalBottomLengt
h, marginBefore, marginAfter, | 3247 logicalTopLength, logicalBottomLength, marginBefore, marginAfter, |
3245 maxValues); | 3248 maxValues); |
3246 | 3249 |
3247 if (computedValues.m_extent > maxValues.m_extent) { | 3250 if (computedValues.m_extent > maxValues.m_extent) { |
3248 computedValues.m_extent = maxValues.m_extent; | 3251 computedValues.m_extent = maxValues.m_extent; |
3249 computedValues.m_position = maxValues.m_position; | 3252 computedValues.m_position = maxValues.m_position; |
3250 computedValues.m_margins.m_before = maxValues.m_margins.m_before; | 3253 computedValues.m_margins.m_before = maxValues.m_margins.m_before; |
3251 computedValues.m_margins.m_after = maxValues.m_margins.m_after; | 3254 computedValues.m_margins.m_after = maxValues.m_margins.m_after; |
3252 } | 3255 } |
3253 } | 3256 } |
3254 | 3257 |
3255 // Calculate constraint equation values for 'min-height' case. | 3258 // Calculate constraint equation values for 'min-height' case. |
3256 if (!styleToUse.logicalMinHeight().isZero() || styleToUse.logicalMinHeight()
.isIntrinsic()) { | 3259 if (!styleToUse.logicalMinHeight().isZero() || styleToUse.logicalMinHeight()
.isIntrinsic()) { |
3257 LogicalExtentComputedValues minValues; | 3260 LogicalExtentComputedValues minValues; |
3258 | 3261 |
3259 computePositionedLogicalHeightUsing(styleToUse.logicalMinHeight(), conta
inerBlock, containerLogicalHeight, bordersPlusPadding, logicalHeight, | 3262 computePositionedLogicalHeightUsing(styleToUse.logicalMinHeight(), conta
inerBlock, containerLogicalHeight, bordersPlusPadding, logicalHeight, |
3260 logicalTopLength, logicalBottomLengt
h, marginBefore, marginAfter, | 3263 logicalTopLength, logicalBottomLength, marginBefore, marginAfter, |
3261 minValues); | 3264 minValues); |
3262 | 3265 |
3263 if (computedValues.m_extent < minValues.m_extent) { | 3266 if (computedValues.m_extent < minValues.m_extent) { |
3264 computedValues.m_extent = minValues.m_extent; | 3267 computedValues.m_extent = minValues.m_extent; |
3265 computedValues.m_position = minValues.m_position; | 3268 computedValues.m_position = minValues.m_position; |
3266 computedValues.m_margins.m_before = minValues.m_margins.m_before; | 3269 computedValues.m_margins.m_before = minValues.m_margins.m_before; |
3267 computedValues.m_margins.m_after = minValues.m_margins.m_after; | 3270 computedValues.m_margins.m_after = minValues.m_margins.m_after; |
3268 } | 3271 } |
3269 } | 3272 } |
3270 | 3273 |
3271 if (!style()->hasStaticBlockPosition(isHorizontalWritingMode())) | 3274 if (!style()->hasStaticBlockPosition(isHorizontalWritingMode())) |
3272 computedValues.m_position += extraBlockOffset(); | 3275 computedValues.m_position += extraBlockOffset(); |
3273 | 3276 |
3274 // Set final height value. | 3277 // Set final height value. |
3275 computedValues.m_extent += bordersPlusPadding; | 3278 computedValues.m_extent += bordersPlusPadding; |
3276 } | 3279 } |
3277 | 3280 |
3278 static void computeLogicalTopPositionedOffset(LayoutUnit& logicalTopPos, const R
enderBox* child, LayoutUnit logicalHeightValue, const LayoutBoxModelObject* cont
ainerBlock, LayoutUnit containerLogicalHeight) | 3281 static void computeLogicalTopPositionedOffset(LayoutUnit& logicalTopPos, const L
ayoutBox* child, LayoutUnit logicalHeightValue, const LayoutBoxModelObject* cont
ainerBlock, LayoutUnit containerLogicalHeight) |
3279 { | 3282 { |
3280 // Deal with differing writing modes here. Our offset needs to be in the co
ntaining block's coordinate space. If the containing block is flipped | 3283 // Deal with differing writing modes here. Our offset needs to be in the co
ntaining block's coordinate space. If the containing block is flipped |
3281 // along this axis, then we need to flip the coordinate. This can only happ
en if the containing block is both a flipped mode and perpendicular to us. | 3284 // along this axis, then we need to flip the coordinate. This can only happ
en if the containing block is both a flipped mode and perpendicular to us. |
3282 if ((child->style()->isFlippedBlocksWritingMode() && child->isHorizontalWrit
ingMode() != containerBlock->isHorizontalWritingMode()) | 3285 if ((child->style()->isFlippedBlocksWritingMode() && child->isHorizontalWrit
ingMode() != containerBlock->isHorizontalWritingMode()) |
3283 || (child->style()->isFlippedBlocksWritingMode() != containerBlock->styl
e()->isFlippedBlocksWritingMode() && child->isHorizontalWritingMode() == contain
erBlock->isHorizontalWritingMode())) | 3286 || (child->style()->isFlippedBlocksWritingMode() != containerBlock->styl
e()->isFlippedBlocksWritingMode() && child->isHorizontalWritingMode() == contain
erBlock->isHorizontalWritingMode())) |
3284 logicalTopPos = containerLogicalHeight - logicalHeightValue - logicalTop
Pos; | 3287 logicalTopPos = containerLogicalHeight - logicalHeightValue - logicalTop
Pos; |
3285 | 3288 |
3286 // Our offset is from the logical bottom edge in a flipped environment, e.g.
, right for vertical-rl and bottom for horizontal-bt. | 3289 // Our offset is from the logical bottom edge in a flipped environment, e.g.
, right for vertical-rl and bottom for horizontal-bt. |
3287 if (containerBlock->style()->isFlippedBlocksWritingMode() && child->isHorizo
ntalWritingMode() == containerBlock->isHorizontalWritingMode()) { | 3290 if (containerBlock->style()->isFlippedBlocksWritingMode() && child->isHorizo
ntalWritingMode() == containerBlock->isHorizontalWritingMode()) { |
3288 if (child->isHorizontalWritingMode()) | 3291 if (child->isHorizontalWritingMode()) |
3289 logicalTopPos += containerBlock->borderBottom(); | 3292 logicalTopPos += containerBlock->borderBottom(); |
3290 else | 3293 else |
3291 logicalTopPos += containerBlock->borderRight(); | 3294 logicalTopPos += containerBlock->borderRight(); |
3292 } else { | 3295 } else { |
3293 if (child->isHorizontalWritingMode()) | 3296 if (child->isHorizontalWritingMode()) |
3294 logicalTopPos += containerBlock->borderTop(); | 3297 logicalTopPos += containerBlock->borderTop(); |
3295 else | 3298 else |
3296 logicalTopPos += containerBlock->borderLeft(); | 3299 logicalTopPos += containerBlock->borderLeft(); |
3297 } | 3300 } |
3298 } | 3301 } |
3299 | 3302 |
3300 void RenderBox::computePositionedLogicalHeightUsing(Length logicalHeightLength,
const LayoutBoxModelObject* containerBlock, | 3303 void LayoutBox::computePositionedLogicalHeightUsing(Length logicalHeightLength,
const LayoutBoxModelObject* containerBlock, |
3301 LayoutUnit containerLogicalH
eight, LayoutUnit bordersPlusPadding, LayoutUnit logicalHeight, | 3304 LayoutUnit containerLogicalHeight, LayoutUnit bordersPlusPadding, LayoutUnit
logicalHeight, |
3302 const Length& logicalTop, co
nst Length& logicalBottom, const Length& marginBefore, | 3305 const Length& logicalTop, const Length& logicalBottom, const Length& marginB
efore, |
3303 const Length& marginAfter, L
ogicalExtentComputedValues& computedValues) const | 3306 const Length& marginAfter, LogicalExtentComputedValues& computedValues) cons
t |
3304 { | 3307 { |
3305 // 'top' and 'bottom' cannot both be 'auto' because 'top would of been | 3308 // 'top' and 'bottom' cannot both be 'auto' because 'top would of been |
3306 // converted to the static position in computePositionedLogicalHeight() | 3309 // converted to the static position in computePositionedLogicalHeight() |
3307 ASSERT(!(logicalTop.isAuto() && logicalBottom.isAuto())); | 3310 ASSERT(!(logicalTop.isAuto() && logicalBottom.isAuto())); |
3308 | 3311 |
3309 LayoutUnit logicalHeightValue; | 3312 LayoutUnit logicalHeightValue; |
3310 LayoutUnit contentLogicalHeight = logicalHeight - bordersPlusPadding; | 3313 LayoutUnit contentLogicalHeight = logicalHeight - bordersPlusPadding; |
3311 | 3314 |
3312 const LayoutUnit containerRelativeLogicalWidth = containingBlockLogicalWidth
ForPositioned(containerBlock, false); | 3315 const LayoutUnit containerRelativeLogicalWidth = containingBlockLogicalWidth
ForPositioned(containerBlock, false); |
3313 | 3316 |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3420 logicalTopValue = valueForLength(logicalTop, containerLogicalHeight)
; | 3423 logicalTopValue = valueForLength(logicalTop, containerLogicalHeight)
; |
3421 } | 3424 } |
3422 } | 3425 } |
3423 computedValues.m_extent = logicalHeightValue; | 3426 computedValues.m_extent = logicalHeightValue; |
3424 | 3427 |
3425 // Use computed values to calculate the vertical position. | 3428 // Use computed values to calculate the vertical position. |
3426 computedValues.m_position = logicalTopValue + computedValues.m_margins.m_bef
ore; | 3429 computedValues.m_position = logicalTopValue + computedValues.m_margins.m_bef
ore; |
3427 computeLogicalTopPositionedOffset(computedValues.m_position, this, logicalHe
ightValue, containerBlock, containerLogicalHeight); | 3430 computeLogicalTopPositionedOffset(computedValues.m_position, this, logicalHe
ightValue, containerBlock, containerLogicalHeight); |
3428 } | 3431 } |
3429 | 3432 |
3430 void RenderBox::computePositionedLogicalWidthReplaced(LogicalExtentComputedValue
s& computedValues) const | 3433 void LayoutBox::computePositionedLogicalWidthReplaced(LogicalExtentComputedValue
s& computedValues) const |
3431 { | 3434 { |
3432 // The following is based off of the W3C Working Draft from April 11, 2006 o
f | 3435 // The following is based off of the W3C Working Draft from April 11, 2006 o
f |
3433 // CSS 2.1: Section 10.3.8 "Absolutely positioned, replaced elements" | 3436 // CSS 2.1: Section 10.3.8 "Absolutely positioned, replaced elements" |
3434 // <http://www.w3.org/TR/2005/WD-CSS21-20050613/visudet.html#abs-replaced-wi
dth> | 3437 // <http://www.w3.org/TR/2005/WD-CSS21-20050613/visudet.html#abs-replaced-wi
dth> |
3435 // (block-style-comments in this function correspond to text from the spec a
nd | 3438 // (block-style-comments in this function correspond to text from the spec a
nd |
3436 // the numbers correspond to numbers in spec) | 3439 // the numbers correspond to numbers in spec) |
3437 | 3440 |
3438 // We don't use containingBlock(), since we may be positioned by an enclosin
g | 3441 // We don't use containingBlock(), since we may be positioned by an enclosin
g |
3439 // relative positioned inline. | 3442 // relative positioned inline. |
3440 const LayoutBoxModelObject* containerBlock = toLayoutBoxModelObject(containe
r()); | 3443 const LayoutBoxModelObject* containerBlock = toLayoutBoxModelObject(containe
r()); |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3589 computedValues.m_position = logicalLeftValue + marginLogicalLeftAlia
s + lastLine->borderLogicalLeft() + (lastLine->logicalLeft() - firstLine->logica
lLeft()); | 3592 computedValues.m_position = logicalLeftValue + marginLogicalLeftAlia
s + lastLine->borderLogicalLeft() + (lastLine->logicalLeft() - firstLine->logica
lLeft()); |
3590 return; | 3593 return; |
3591 } | 3594 } |
3592 } | 3595 } |
3593 | 3596 |
3594 LayoutUnit logicalLeftPos = logicalLeftValue + marginLogicalLeftAlias; | 3597 LayoutUnit logicalLeftPos = logicalLeftValue + marginLogicalLeftAlias; |
3595 computeLogicalLeftPositionedOffset(logicalLeftPos, this, computedValues.m_ex
tent, containerBlock, containerLogicalWidth); | 3598 computeLogicalLeftPositionedOffset(logicalLeftPos, this, computedValues.m_ex
tent, containerBlock, containerLogicalWidth); |
3596 computedValues.m_position = logicalLeftPos; | 3599 computedValues.m_position = logicalLeftPos; |
3597 } | 3600 } |
3598 | 3601 |
3599 void RenderBox::computePositionedLogicalHeightReplaced(LogicalExtentComputedValu
es& computedValues) const | 3602 void LayoutBox::computePositionedLogicalHeightReplaced(LogicalExtentComputedValu
es& computedValues) const |
3600 { | 3603 { |
3601 // The following is based off of the W3C Working Draft from April 11, 2006 o
f | 3604 // The following is based off of the W3C Working Draft from April 11, 2006 o
f |
3602 // CSS 2.1: Section 10.6.5 "Absolutely positioned, replaced elements" | 3605 // CSS 2.1: Section 10.6.5 "Absolutely positioned, replaced elements" |
3603 // <http://www.w3.org/TR/2005/WD-CSS21-20050613/visudet.html#abs-replaced-he
ight> | 3606 // <http://www.w3.org/TR/2005/WD-CSS21-20050613/visudet.html#abs-replaced-he
ight> |
3604 // (block-style-comments in this function correspond to text from the spec a
nd | 3607 // (block-style-comments in this function correspond to text from the spec a
nd |
3605 // the numbers correspond to numbers in spec) | 3608 // the numbers correspond to numbers in spec) |
3606 | 3609 |
3607 // We don't use containingBlock(), since we may be positioned by an enclosin
g relpositioned inline. | 3610 // We don't use containingBlock(), since we may be positioned by an enclosin
g relpositioned inline. |
3608 const LayoutBoxModelObject* containerBlock = toLayoutBoxModelObject(containe
r()); | 3611 const LayoutBoxModelObject* containerBlock = toLayoutBoxModelObject(containe
r()); |
3609 | 3612 |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3702 | 3705 |
3703 // Solve for 'margin-bottom' | 3706 // Solve for 'margin-bottom' |
3704 marginAfterAlias = availableSpace - (logicalTopValue + logicalBottomValu
e + marginBeforeAlias); | 3707 marginAfterAlias = availableSpace - (logicalTopValue + logicalBottomValu
e + marginBeforeAlias); |
3705 } else { | 3708 } else { |
3706 // Nothing is 'auto', just calculate the values. | 3709 // Nothing is 'auto', just calculate the values. |
3707 marginBeforeAlias = valueForLength(marginBefore, containerRelativeLogica
lWidth); | 3710 marginBeforeAlias = valueForLength(marginBefore, containerRelativeLogica
lWidth); |
3708 marginAfterAlias = valueForLength(marginAfter, containerRelativeLogicalW
idth); | 3711 marginAfterAlias = valueForLength(marginAfter, containerRelativeLogicalW
idth); |
3709 logicalTopValue = valueForLength(logicalTop, containerLogicalHeight); | 3712 logicalTopValue = valueForLength(logicalTop, containerLogicalHeight); |
3710 // NOTE: It is not necessary to solve for 'bottom' because we don't ever | 3713 // NOTE: It is not necessary to solve for 'bottom' because we don't ever |
3711 // use the value. | 3714 // use the value. |
3712 } | 3715 } |
3713 | 3716 |
3714 /*-----------------------------------------------------------------------*\ | 3717 /*-----------------------------------------------------------------------*\ |
3715 * 6. If at this point the values are over-constrained, ignore the value | 3718 * 6. If at this point the values are over-constrained, ignore the value |
3716 * for 'bottom' and solve for that value. | 3719 * for 'bottom' and solve for that value. |
3717 \*-----------------------------------------------------------------------*/ | 3720 \*-----------------------------------------------------------------------*/ |
3718 // NOTE: It is not necessary to do this step because we don't end up using | 3721 // NOTE: It is not necessary to do this step because we don't end up using |
3719 // the value of 'bottom' regardless of whether the values are over-constrain
ed | 3722 // the value of 'bottom' regardless of whether the values are over-constrain
ed |
3720 // or not. | 3723 // or not. |
3721 | 3724 |
3722 // Use computed values to calculate the vertical position. | 3725 // Use computed values to calculate the vertical position. |
3723 LayoutUnit logicalTopPos = logicalTopValue + marginBeforeAlias; | 3726 LayoutUnit logicalTopPos = logicalTopValue + marginBeforeAlias; |
3724 computeLogicalTopPositionedOffset(logicalTopPos, this, computedValues.m_exte
nt, containerBlock, containerLogicalHeight); | 3727 computeLogicalTopPositionedOffset(logicalTopPos, this, computedValues.m_exte
nt, containerBlock, containerLogicalHeight); |
3725 computedValues.m_position = logicalTopPos; | 3728 computedValues.m_position = logicalTopPos; |
3726 } | 3729 } |
3727 | 3730 |
3728 LayoutRect RenderBox::localCaretRect(InlineBox* box, int caretOffset, LayoutUnit
* extraWidthToEndOfLine) | 3731 LayoutRect LayoutBox::localCaretRect(InlineBox* box, int caretOffset, LayoutUnit
* extraWidthToEndOfLine) |
3729 { | 3732 { |
3730 // VisiblePositions at offsets inside containers either a) refer to the posi
tions before/after | 3733 // VisiblePositions at offsets inside containers either a) refer to the posi
tions before/after |
3731 // those containers (tables and select elements) or b) refer to the position
inside an empty block. | 3734 // those containers (tables and select elements) or b) refer to the position
inside an empty block. |
3732 // They never refer to children. | 3735 // They never refer to children. |
3733 // FIXME: Paint the carets inside empty blocks differently than the carets b
efore/after elements. | 3736 // FIXME: Paint the carets inside empty blocks differently than the carets b
efore/after elements. |
3734 | 3737 |
3735 LayoutRect rect(location(), LayoutSize(caretWidth, size().height())); | 3738 LayoutRect rect(location(), LayoutSize(caretWidth, size().height())); |
3736 bool ltr = box ? box->isLeftToRightDirection() : style()->isLeftToRightDirec
tion(); | 3739 bool ltr = box ? box->isLeftToRightDirection() : style()->isLeftToRightDirec
tion(); |
3737 | 3740 |
3738 if ((!caretOffset) ^ ltr) | 3741 if ((!caretOffset) ^ ltr) |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3770 rect.setX(rect.x() + borderLeft() + paddingLeft()); | 3773 rect.setX(rect.x() + borderLeft() + paddingLeft()); |
3771 rect.setY(rect.y() + paddingTop() + borderTop()); | 3774 rect.setY(rect.y() + paddingTop() + borderTop()); |
3772 } | 3775 } |
3773 | 3776 |
3774 if (!isHorizontalWritingMode()) | 3777 if (!isHorizontalWritingMode()) |
3775 return rect.transposedRect(); | 3778 return rect.transposedRect(); |
3776 | 3779 |
3777 return rect; | 3780 return rect; |
3778 } | 3781 } |
3779 | 3782 |
3780 PositionWithAffinity RenderBox::positionForPoint(const LayoutPoint& point) | 3783 PositionWithAffinity LayoutBox::positionForPoint(const LayoutPoint& point) |
3781 { | 3784 { |
3782 // no children...return this render object's element, if there is one, and o
ffset 0 | 3785 // no children...return this render object's element, if there is one, and o
ffset 0 |
3783 LayoutObject* firstChild = slowFirstChild(); | 3786 LayoutObject* firstChild = slowFirstChild(); |
3784 if (!firstChild) | 3787 if (!firstChild) |
3785 return createPositionWithAffinity(nonPseudoNode() ? firstPositionInOrBef
oreNode(nonPseudoNode()) : Position()); | 3788 return createPositionWithAffinity(nonPseudoNode() ? firstPositionInOrBef
oreNode(nonPseudoNode()) : Position()); |
3786 | 3789 |
3787 if (isTable() && nonPseudoNode()) { | 3790 if (isTable() && nonPseudoNode()) { |
3788 LayoutUnit right = size().width() - verticalScrollbarWidth(); | 3791 LayoutUnit right = size().width() - verticalScrollbarWidth(); |
3789 LayoutUnit bottom = size().height() - horizontalScrollbarHeight(); | 3792 LayoutUnit bottom = size().height() - horizontalScrollbarHeight(); |
3790 | 3793 |
3791 if (point.x() < 0 || point.x() > right || point.y() < 0 || point.y() > b
ottom) { | 3794 if (point.x() < 0 || point.x() > right || point.y() < 0 || point.y() > b
ottom) { |
3792 if (point.x() <= right / 2) | 3795 if (point.x() <= right / 2) |
3793 return createPositionWithAffinity(firstPositionInOrBeforeNode(no
nPseudoNode())); | 3796 return createPositionWithAffinity(firstPositionInOrBeforeNode(no
nPseudoNode())); |
3794 return createPositionWithAffinity(lastPositionInOrAfterNode(nonPseud
oNode())); | 3797 return createPositionWithAffinity(lastPositionInOrAfterNode(nonPseud
oNode())); |
3795 } | 3798 } |
3796 } | 3799 } |
3797 | 3800 |
3798 // Pass off to the closest child. | 3801 // Pass off to the closest child. |
3799 LayoutUnit minDist = LayoutUnit::max(); | 3802 LayoutUnit minDist = LayoutUnit::max(); |
3800 RenderBox* closestRenderer = 0; | 3803 LayoutBox* closestRenderer = 0; |
3801 LayoutPoint adjustedPoint = point; | 3804 LayoutPoint adjustedPoint = point; |
3802 if (isTableRow()) | 3805 if (isTableRow()) |
3803 adjustedPoint.moveBy(location()); | 3806 adjustedPoint.moveBy(location()); |
3804 | 3807 |
3805 for (LayoutObject* layoutObject = firstChild; layoutObject; layoutObject = l
ayoutObject->nextSibling()) { | 3808 for (LayoutObject* layoutObject = firstChild; layoutObject; layoutObject = l
ayoutObject->nextSibling()) { |
3806 if ((!layoutObject->slowFirstChild() && !layoutObject->isInline() && !la
youtObject->isRenderBlockFlow() ) | 3809 if ((!layoutObject->slowFirstChild() && !layoutObject->isInline() && !la
youtObject->isRenderBlockFlow() ) |
3807 || layoutObject->style()->visibility() != VISIBLE) | 3810 || layoutObject->style()->visibility() != VISIBLE) |
3808 continue; | 3811 continue; |
3809 | 3812 |
3810 if (!layoutObject->isBox()) | 3813 if (!layoutObject->isBox()) |
3811 continue; | 3814 continue; |
3812 | 3815 |
3813 RenderBox* renderer = toRenderBox(layoutObject); | 3816 LayoutBox* renderer = toLayoutBox(layoutObject); |
3814 | 3817 |
3815 LayoutUnit top = renderer->borderTop() + renderer->paddingTop() + (isTab
leRow() ? LayoutUnit() : renderer->location().y()); | 3818 LayoutUnit top = renderer->borderTop() + renderer->paddingTop() + (isTab
leRow() ? LayoutUnit() : renderer->location().y()); |
3816 LayoutUnit bottom = top + renderer->contentHeight(); | 3819 LayoutUnit bottom = top + renderer->contentHeight(); |
3817 LayoutUnit left = renderer->borderLeft() + renderer->paddingLeft() + (is
TableRow() ? LayoutUnit() : renderer->location().x()); | 3820 LayoutUnit left = renderer->borderLeft() + renderer->paddingLeft() + (is
TableRow() ? LayoutUnit() : renderer->location().x()); |
3818 LayoutUnit right = left + renderer->contentWidth(); | 3821 LayoutUnit right = left + renderer->contentWidth(); |
3819 | 3822 |
3820 if (point.x() <= right && point.x() >= left && point.y() <= top && point
.y() >= bottom) { | 3823 if (point.x() <= right && point.x() >= left && point.y() <= top && point
.y() >= bottom) { |
3821 if (renderer->isTableRow()) | 3824 if (renderer->isTableRow()) |
3822 return renderer->positionForPoint(point + adjustedPoint - render
er->locationOffset()); | 3825 return renderer->positionForPoint(point + adjustedPoint - render
er->locationOffset()); |
3823 return renderer->positionForPoint(point - renderer->locationOffset()
); | 3826 return renderer->positionForPoint(point - renderer->locationOffset()
); |
(...skipping 30 matching lines...) Expand all Loading... |
3854 closestRenderer = renderer; | 3857 closestRenderer = renderer; |
3855 minDist = dist; | 3858 minDist = dist; |
3856 } | 3859 } |
3857 } | 3860 } |
3858 | 3861 |
3859 if (closestRenderer) | 3862 if (closestRenderer) |
3860 return closestRenderer->positionForPoint(adjustedPoint - closestRenderer
->locationOffset()); | 3863 return closestRenderer->positionForPoint(adjustedPoint - closestRenderer
->locationOffset()); |
3861 return createPositionWithAffinity(firstPositionInOrBeforeNode(nonPseudoNode(
))); | 3864 return createPositionWithAffinity(firstPositionInOrBeforeNode(nonPseudoNode(
))); |
3862 } | 3865 } |
3863 | 3866 |
3864 bool RenderBox::shrinkToAvoidFloats() const | 3867 bool LayoutBox::shrinkToAvoidFloats() const |
3865 { | 3868 { |
3866 // Floating objects don't shrink. Objects that don't avoid floats don't shr
ink. | 3869 // Floating objects don't shrink. Objects that don't avoid floats don't shr
ink. |
3867 if (isInline() || !avoidsFloats() || isFloating()) | 3870 if (isInline() || !avoidsFloats() || isFloating()) |
3868 return false; | 3871 return false; |
3869 | 3872 |
3870 // Only auto width objects can possibly shrink to avoid floats. | 3873 // Only auto width objects can possibly shrink to avoid floats. |
3871 return style()->width().isAuto(); | 3874 return style()->width().isAuto(); |
3872 } | 3875 } |
3873 | 3876 |
3874 static bool isReplacedElement(Node* node) | 3877 static bool isReplacedElement(Node* node) |
3875 { | 3878 { |
3876 // Checkboxes and radioboxes are not isReplaced() nor do they have their own
renderer in which to override avoidFloats(). | 3879 // Checkboxes and radioboxes are not isReplaced() nor do they have their own
renderer in which to override avoidFloats(). |
3877 return node && node->isElementNode() && (toElement(node)->isFormControlEleme
nt() || isHTMLImageElement(toElement(node))); | 3880 return node && node->isElementNode() && (toElement(node)->isFormControlEleme
nt() || isHTMLImageElement(toElement(node))); |
3878 } | 3881 } |
3879 | 3882 |
3880 bool RenderBox::avoidsFloats() const | 3883 bool LayoutBox::avoidsFloats() const |
3881 { | 3884 { |
3882 return isReplaced() || isReplacedElement(node()) || hasOverflowClip() || isH
R() || isLegend() || isWritingModeRoot() || isFlexItemIncludingDeprecated(); | 3885 return isReplaced() || isReplacedElement(node()) || hasOverflowClip() || isH
R() || isLegend() || isWritingModeRoot() || isFlexItemIncludingDeprecated(); |
3883 } | 3886 } |
3884 | 3887 |
3885 bool RenderBox::hasNonCompositedScrollbars() const | 3888 bool LayoutBox::hasNonCompositedScrollbars() const |
3886 { | 3889 { |
3887 if (Layer* layer = this->layer()) { | 3890 if (Layer* layer = this->layer()) { |
3888 if (LayerScrollableArea* scrollableArea = layer->scrollableArea()) { | 3891 if (LayerScrollableArea* scrollableArea = layer->scrollableArea()) { |
3889 if (scrollableArea->hasHorizontalScrollbar() && !scrollableArea->lay
erForHorizontalScrollbar()) | 3892 if (scrollableArea->hasHorizontalScrollbar() && !scrollableArea->lay
erForHorizontalScrollbar()) |
3890 return true; | 3893 return true; |
3891 if (scrollableArea->hasVerticalScrollbar() && !scrollableArea->layer
ForVerticalScrollbar()) | 3894 if (scrollableArea->hasVerticalScrollbar() && !scrollableArea->layer
ForVerticalScrollbar()) |
3892 return true; | 3895 return true; |
3893 } | 3896 } |
3894 } | 3897 } |
3895 return false; | 3898 return false; |
3896 } | 3899 } |
3897 | 3900 |
3898 PaintInvalidationReason RenderBox::paintInvalidationReason(const LayoutBoxModelO
bject& paintInvalidationContainer, | 3901 PaintInvalidationReason LayoutBox::paintInvalidationReason(const LayoutBoxModelO
bject& paintInvalidationContainer, |
3899 const LayoutRect& oldBounds, const LayoutPoint& oldLocation, const LayoutRec
t& newBounds, const LayoutPoint& newLocation) const | 3902 const LayoutRect& oldBounds, const LayoutPoint& oldLocation, const LayoutRec
t& newBounds, const LayoutPoint& newLocation) const |
3900 { | 3903 { |
3901 PaintInvalidationReason invalidationReason = LayoutBoxModelObject::paintInva
lidationReason(paintInvalidationContainer, oldBounds, oldLocation, newBounds, ne
wLocation); | 3904 PaintInvalidationReason invalidationReason = LayoutBoxModelObject::paintInva
lidationReason(paintInvalidationContainer, oldBounds, oldLocation, newBounds, ne
wLocation); |
3902 if (isFullPaintInvalidationReason(invalidationReason)) | 3905 if (isFullPaintInvalidationReason(invalidationReason)) |
3903 return invalidationReason; | 3906 return invalidationReason; |
3904 | 3907 |
3905 // If the transform is not identity or translation, incremental invalidation
is not applicable | 3908 // If the transform is not identity or translation, incremental invalidation
is not applicable |
3906 // because the difference between oldBounds and newBounds doesn't cover all
area needing invalidation. | 3909 // because the difference between oldBounds and newBounds doesn't cover all
area needing invalidation. |
3907 // FIXME: Should also consider ancestor transforms since paintInvalidationCo
ntainer. crbug.com/426111. | 3910 // FIXME: Should also consider ancestor transforms since paintInvalidationCo
ntainer. crbug.com/426111. |
3908 if (invalidationReason == PaintInvalidationIncremental | 3911 if (invalidationReason == PaintInvalidationIncremental |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3941 } | 3944 } |
3942 | 3945 |
3943 if (oldBorderBoxSize.width() != newBorderBoxSize.width() && mustInvalidateBa
ckgroundOrBorderPaintOnWidthChange()) | 3946 if (oldBorderBoxSize.width() != newBorderBoxSize.width() && mustInvalidateBa
ckgroundOrBorderPaintOnWidthChange()) |
3944 return PaintInvalidationBorderBoxChange; | 3947 return PaintInvalidationBorderBoxChange; |
3945 if (oldBorderBoxSize.height() != newBorderBoxSize.height() && mustInvalidate
BackgroundOrBorderPaintOnHeightChange()) | 3948 if (oldBorderBoxSize.height() != newBorderBoxSize.height() && mustInvalidate
BackgroundOrBorderPaintOnHeightChange()) |
3946 return PaintInvalidationBorderBoxChange; | 3949 return PaintInvalidationBorderBoxChange; |
3947 | 3950 |
3948 return PaintInvalidationIncremental; | 3951 return PaintInvalidationIncremental; |
3949 } | 3952 } |
3950 | 3953 |
3951 void RenderBox::incrementallyInvalidatePaint(const LayoutBoxModelObject& paintIn
validationContainer, const LayoutRect& oldBounds, const LayoutRect& newBounds, c
onst LayoutPoint& positionFromPaintInvalidationBacking) | 3954 void LayoutBox::incrementallyInvalidatePaint(const LayoutBoxModelObject& paintIn
validationContainer, const LayoutRect& oldBounds, const LayoutRect& newBounds, c
onst LayoutPoint& positionFromPaintInvalidationBacking) |
3952 { | 3955 { |
3953 LayoutObject::incrementallyInvalidatePaint(paintInvalidationContainer, oldBo
unds, newBounds, positionFromPaintInvalidationBacking); | 3956 LayoutObject::incrementallyInvalidatePaint(paintInvalidationContainer, oldBo
unds, newBounds, positionFromPaintInvalidationBacking); |
3954 | 3957 |
3955 bool hasBoxDecorations = style()->hasBoxDecorations(); | 3958 bool hasBoxDecorations = style()->hasBoxDecorations(); |
3956 if (!style()->hasBackground() && !hasBoxDecorations) | 3959 if (!style()->hasBackground() && !hasBoxDecorations) |
3957 return; | 3960 return; |
3958 | 3961 |
3959 LayoutSize oldBorderBoxSize = computePreviousBorderBoxSize(oldBounds.size())
; | 3962 LayoutSize oldBorderBoxSize = computePreviousBorderBoxSize(oldBounds.size())
; |
3960 LayoutSize newBorderBoxSize = size(); | 3963 LayoutSize newBorderBoxSize = size(); |
3961 | 3964 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3994 LayoutUnit borderBottomRightRadiusHeight = valueForLength(style()->borde
rBottomRightRadius().height(), smallerHeight); | 3997 LayoutUnit borderBottomRightRadiusHeight = valueForLength(style()->borde
rBottomRightRadius().height(), smallerHeight); |
3995 LayoutUnit borderHeight = std::max<LayoutUnit>(borderBottom(), std::max(
borderBottomLeftRadiusHeight, borderBottomRightRadiusHeight)); | 3998 LayoutUnit borderHeight = std::max<LayoutUnit>(borderBottom(), std::max(
borderBottomLeftRadiusHeight, borderBottomRightRadiusHeight)); |
3996 LayoutRect bottomDeltaRect(positionFromPaintInvalidationBacking.x(), | 3999 LayoutRect bottomDeltaRect(positionFromPaintInvalidationBacking.x(), |
3997 positionFromPaintInvalidationBacking.y() + smallerHeight - borderHei
ght, | 4000 positionFromPaintInvalidationBacking.y() + smallerHeight - borderHei
ght, |
3998 std::max(oldBorderBoxSize.width(), newBorderBoxSize.width()), | 4001 std::max(oldBorderBoxSize.width(), newBorderBoxSize.width()), |
3999 deltaHeight + borderHeight); | 4002 deltaHeight + borderHeight); |
4000 invalidatePaintRectClippedByOldAndNewBounds(paintInvalidationContainer,
bottomDeltaRect, oldBounds, newBounds); | 4003 invalidatePaintRectClippedByOldAndNewBounds(paintInvalidationContainer,
bottomDeltaRect, oldBounds, newBounds); |
4001 } | 4004 } |
4002 } | 4005 } |
4003 | 4006 |
4004 void RenderBox::invalidatePaintRectClippedByOldAndNewBounds(const LayoutBoxModel
Object& paintInvalidationContainer, const LayoutRect& rect, const LayoutRect& ol
dBounds, const LayoutRect& newBounds) | 4007 void LayoutBox::invalidatePaintRectClippedByOldAndNewBounds(const LayoutBoxModel
Object& paintInvalidationContainer, const LayoutRect& rect, const LayoutRect& ol
dBounds, const LayoutRect& newBounds) |
4005 { | 4008 { |
4006 if (rect.isEmpty()) | 4009 if (rect.isEmpty()) |
4007 return; | 4010 return; |
4008 LayoutRect rectClippedByOldBounds = intersection(rect, oldBounds); | 4011 LayoutRect rectClippedByOldBounds = intersection(rect, oldBounds); |
4009 LayoutRect rectClippedByNewBounds = intersection(rect, newBounds); | 4012 LayoutRect rectClippedByNewBounds = intersection(rect, newBounds); |
4010 // Invalidate only once if the clipped rects equal. | 4013 // Invalidate only once if the clipped rects equal. |
4011 if (rectClippedByOldBounds == rectClippedByNewBounds) { | 4014 if (rectClippedByOldBounds == rectClippedByNewBounds) { |
4012 invalidatePaintUsingContainer(&paintInvalidationContainer, rectClippedBy
OldBounds, PaintInvalidationIncremental); | 4015 invalidatePaintUsingContainer(&paintInvalidationContainer, rectClippedBy
OldBounds, PaintInvalidationIncremental); |
4013 return; | 4016 return; |
4014 } | 4017 } |
4015 // Invalidate the bigger one if one contains another. Otherwise invalidate b
oth. | 4018 // Invalidate the bigger one if one contains another. Otherwise invalidate b
oth. |
4016 if (!rectClippedByNewBounds.contains(rectClippedByOldBounds)) | 4019 if (!rectClippedByNewBounds.contains(rectClippedByOldBounds)) |
4017 invalidatePaintUsingContainer(&paintInvalidationContainer, rectClippedBy
OldBounds, PaintInvalidationIncremental); | 4020 invalidatePaintUsingContainer(&paintInvalidationContainer, rectClippedBy
OldBounds, PaintInvalidationIncremental); |
4018 if (!rectClippedByOldBounds.contains(rectClippedByNewBounds)) | 4021 if (!rectClippedByOldBounds.contains(rectClippedByNewBounds)) |
4019 invalidatePaintUsingContainer(&paintInvalidationContainer, rectClippedBy
NewBounds, PaintInvalidationIncremental); | 4022 invalidatePaintUsingContainer(&paintInvalidationContainer, rectClippedBy
NewBounds, PaintInvalidationIncremental); |
4020 } | 4023 } |
4021 | 4024 |
4022 void RenderBox::markForPaginationRelayoutIfNeeded(SubtreeLayoutScope& layoutScop
e) | 4025 void LayoutBox::markForPaginationRelayoutIfNeeded(SubtreeLayoutScope& layoutScop
e) |
4023 { | 4026 { |
4024 ASSERT(!needsLayout()); | 4027 ASSERT(!needsLayout()); |
4025 // If fragmentation height has changed, we need to lay out. No need to enter
the renderer if it | 4028 // If fragmentation height has changed, we need to lay out. No need to enter
the renderer if it |
4026 // is childless, though. | 4029 // is childless, though. |
4027 if (view()->layoutState()->pageLogicalHeightChanged() && slowFirstChild()) | 4030 if (view()->layoutState()->pageLogicalHeightChanged() && slowFirstChild()) |
4028 layoutScope.setChildNeedsLayout(this); | 4031 layoutScope.setChildNeedsLayout(this); |
4029 } | 4032 } |
4030 | 4033 |
4031 void RenderBox::addVisualEffectOverflow() | 4034 void LayoutBox::addVisualEffectOverflow() |
4032 { | 4035 { |
4033 if (!style()->hasVisualOverflowingEffect()) | 4036 if (!style()->hasVisualOverflowingEffect()) |
4034 return; | 4037 return; |
4035 | 4038 |
4036 // Add in the final overflow with shadows, outsets and outline combined. | 4039 // Add in the final overflow with shadows, outsets and outline combined. |
4037 LayoutRect visualEffectOverflow = borderBoxRect(); | 4040 LayoutRect visualEffectOverflow = borderBoxRect(); |
4038 visualEffectOverflow.expand(computeVisualEffectOverflowOutsets()); | 4041 visualEffectOverflow.expand(computeVisualEffectOverflowOutsets()); |
4039 addVisualOverflow(visualEffectOverflow); | 4042 addVisualOverflow(visualEffectOverflow); |
4040 } | 4043 } |
4041 | 4044 |
4042 LayoutRectOutsets RenderBox::computeVisualEffectOverflowOutsets() const | 4045 LayoutRectOutsets LayoutBox::computeVisualEffectOverflowOutsets() const |
4043 { | 4046 { |
4044 ASSERT(style()->hasVisualOverflowingEffect()); | 4047 ASSERT(style()->hasVisualOverflowingEffect()); |
4045 | 4048 |
4046 LayoutUnit top; | 4049 LayoutUnit top; |
4047 LayoutUnit right; | 4050 LayoutUnit right; |
4048 LayoutUnit bottom; | 4051 LayoutUnit bottom; |
4049 LayoutUnit left; | 4052 LayoutUnit left; |
4050 | 4053 |
4051 if (const ShadowList* boxShadow = style()->boxShadow()) { | 4054 if (const ShadowList* boxShadow = style()->boxShadow()) { |
4052 // FIXME: Use LayoutUnit edge outsets, and then simplify this. | 4055 // FIXME: Use LayoutUnit edge outsets, and then simplify this. |
(...skipping 29 matching lines...) Expand all Loading... |
4082 top = std::max(top, outlineSize); | 4085 top = std::max(top, outlineSize); |
4083 right = std::max(right, outlineSize); | 4086 right = std::max(right, outlineSize); |
4084 bottom = std::max(bottom, outlineSize); | 4087 bottom = std::max(bottom, outlineSize); |
4085 left = std::max(left, outlineSize); | 4088 left = std::max(left, outlineSize); |
4086 } | 4089 } |
4087 } | 4090 } |
4088 | 4091 |
4089 return LayoutRectOutsets(top, right, bottom, left); | 4092 return LayoutRectOutsets(top, right, bottom, left); |
4090 } | 4093 } |
4091 | 4094 |
4092 void RenderBox::addOverflowFromChild(RenderBox* child, const LayoutSize& delta) | 4095 void LayoutBox::addOverflowFromChild(LayoutBox* child, const LayoutSize& delta) |
4093 { | 4096 { |
4094 // Never allow flow threads to propagate overflow up to a parent. | 4097 // Never allow flow threads to propagate overflow up to a parent. |
4095 if (child->isLayoutFlowThread()) | 4098 if (child->isLayoutFlowThread()) |
4096 return; | 4099 return; |
4097 | 4100 |
4098 // Only propagate layout overflow from the child if the child isn't clipping
its overflow. If it is, then | 4101 // Only propagate layout overflow from the child if the child isn't clipping
its overflow. If it is, then |
4099 // its overflow is internal to it, and we don't care about it. layoutOverfl
owRectForPropagation takes care of this | 4102 // its overflow is internal to it, and we don't care about it. layoutOverfl
owRectForPropagation takes care of this |
4100 // and just propagates the border box rect instead. | 4103 // and just propagates the border box rect instead. |
4101 LayoutRect childLayoutOverflowRect = child->layoutOverflowRectForPropagation
(styleRef()); | 4104 LayoutRect childLayoutOverflowRect = child->layoutOverflowRectForPropagation
(styleRef()); |
4102 childLayoutOverflowRect.move(delta); | 4105 childLayoutOverflowRect.move(delta); |
4103 addLayoutOverflow(childLayoutOverflowRect); | 4106 addLayoutOverflow(childLayoutOverflowRect); |
4104 | 4107 |
4105 // Add in visual overflow from the child. Even if the child clips its overf
low, it may still | 4108 // Add in visual overflow from the child. Even if the child clips its overf
low, it may still |
4106 // have visual overflow of its own set from box shadows or reflections. It
is unnecessary to propagate this | 4109 // have visual overflow of its own set from box shadows or reflections. It
is unnecessary to propagate this |
4107 // overflow if we are clipping our own overflow. | 4110 // overflow if we are clipping our own overflow. |
4108 if (child->hasSelfPaintingLayer()) | 4111 if (child->hasSelfPaintingLayer()) |
4109 return; | 4112 return; |
4110 LayoutRect childVisualOverflowRect = child->visualOverflowRectForPropagation
(styleRef()); | 4113 LayoutRect childVisualOverflowRect = child->visualOverflowRectForPropagation
(styleRef()); |
4111 childVisualOverflowRect.move(delta); | 4114 childVisualOverflowRect.move(delta); |
4112 addContentsVisualOverflow(childVisualOverflowRect); | 4115 addContentsVisualOverflow(childVisualOverflowRect); |
4113 } | 4116 } |
4114 | 4117 |
4115 void RenderBox::addLayoutOverflow(const LayoutRect& rect) | 4118 void LayoutBox::addLayoutOverflow(const LayoutRect& rect) |
4116 { | 4119 { |
4117 LayoutRect clientBox = noOverflowRect(); | 4120 LayoutRect clientBox = noOverflowRect(); |
4118 if (clientBox.contains(rect) || rect.isEmpty()) | 4121 if (clientBox.contains(rect) || rect.isEmpty()) |
4119 return; | 4122 return; |
4120 | 4123 |
4121 // For overflow clip objects, we don't want to propagate overflow into unrea
chable areas. | 4124 // For overflow clip objects, we don't want to propagate overflow into unrea
chable areas. |
4122 LayoutRect overflowRect(rect); | 4125 LayoutRect overflowRect(rect); |
4123 if (hasOverflowClip() || isRenderView()) { | 4126 if (hasOverflowClip() || isRenderView()) { |
4124 // Overflow is in the block's coordinate space and thus is flipped for h
orizontal-bt and vertical-rl | 4127 // Overflow is in the block's coordinate space and thus is flipped for h
orizontal-bt and vertical-rl |
4125 // writing modes. At this stage that is actually a simplification, sinc
e we can treat horizontal-tb/bt as the same | 4128 // writing modes. At this stage that is actually a simplification, sinc
e we can treat horizontal-tb/bt as the same |
(...skipping 22 matching lines...) Expand all Loading... |
4148 if (clientBox.contains(overflowRect) || overflowRect.isEmpty()) | 4151 if (clientBox.contains(overflowRect) || overflowRect.isEmpty()) |
4149 return; | 4152 return; |
4150 } | 4153 } |
4151 | 4154 |
4152 if (!m_overflow) | 4155 if (!m_overflow) |
4153 m_overflow = adoptPtr(new RenderOverflow(clientBox, borderBoxRect())); | 4156 m_overflow = adoptPtr(new RenderOverflow(clientBox, borderBoxRect())); |
4154 | 4157 |
4155 m_overflow->addLayoutOverflow(overflowRect); | 4158 m_overflow->addLayoutOverflow(overflowRect); |
4156 } | 4159 } |
4157 | 4160 |
4158 void RenderBox::addVisualOverflow(const LayoutRect& rect) | 4161 void LayoutBox::addVisualOverflow(const LayoutRect& rect) |
4159 { | 4162 { |
4160 LayoutRect borderBox = borderBoxRect(); | 4163 LayoutRect borderBox = borderBoxRect(); |
4161 if (borderBox.contains(rect) || rect.isEmpty()) | 4164 if (borderBox.contains(rect) || rect.isEmpty()) |
4162 return; | 4165 return; |
4163 | 4166 |
4164 if (!m_overflow) | 4167 if (!m_overflow) |
4165 m_overflow = adoptPtr(new RenderOverflow(noOverflowRect(), borderBox)); | 4168 m_overflow = adoptPtr(new RenderOverflow(noOverflowRect(), borderBox)); |
4166 | 4169 |
4167 m_overflow->addVisualOverflow(rect); | 4170 m_overflow->addVisualOverflow(rect); |
4168 } | 4171 } |
4169 | 4172 |
4170 void RenderBox::addContentsVisualOverflow(const LayoutRect& rect) | 4173 void LayoutBox::addContentsVisualOverflow(const LayoutRect& rect) |
4171 { | 4174 { |
4172 if (!hasOverflowClip()) { | 4175 if (!hasOverflowClip()) { |
4173 addVisualOverflow(rect); | 4176 addVisualOverflow(rect); |
4174 return; | 4177 return; |
4175 } | 4178 } |
4176 | 4179 |
4177 if (!m_overflow) | 4180 if (!m_overflow) |
4178 m_overflow = adoptPtr(new RenderOverflow(noOverflowRect(), borderBoxRect
())); | 4181 m_overflow = adoptPtr(new RenderOverflow(noOverflowRect(), borderBoxRect
())); |
4179 m_overflow->addContentsVisualOverflow(rect); | 4182 m_overflow->addContentsVisualOverflow(rect); |
4180 } | 4183 } |
4181 | 4184 |
4182 void RenderBox::clearLayoutOverflow() | 4185 void LayoutBox::clearLayoutOverflow() |
4183 { | 4186 { |
4184 if (!m_overflow) | 4187 if (!m_overflow) |
4185 return; | 4188 return; |
4186 | 4189 |
4187 if (!hasVisualOverflow() && contentsVisualOverflowRect().isEmpty()) { | 4190 if (!hasVisualOverflow() && contentsVisualOverflowRect().isEmpty()) { |
4188 clearAllOverflows(); | 4191 clearAllOverflows(); |
4189 return; | 4192 return; |
4190 } | 4193 } |
4191 | 4194 |
4192 m_overflow->setLayoutOverflow(noOverflowRect()); | 4195 m_overflow->setLayoutOverflow(noOverflowRect()); |
4193 } | 4196 } |
4194 | 4197 |
4195 bool RenderBox::logicalWidthIsResolvableFromBlock(const RenderBlock* containingB
lock) | 4198 bool LayoutBox::logicalWidthIsResolvableFromBlock(const RenderBlock* containingB
lock) |
4196 { | 4199 { |
4197 const RenderBlock* cb = containingBlock; | 4200 const RenderBlock* cb = containingBlock; |
4198 while (!cb->isRenderView() && !cb->isOutOfFlowPositioned() && (cb->style()->
logicalWidth().isAuto() || cb->isAnonymousBlock())) | 4201 while (!cb->isRenderView() && !cb->isOutOfFlowPositioned() && (cb->style()->
logicalWidth().isAuto() || cb->isAnonymousBlock())) |
4199 cb = cb->containingBlock(); | 4202 cb = cb->containingBlock(); |
4200 | 4203 |
4201 if (cb->style()->logicalWidth().isFixed()) | 4204 if (cb->style()->logicalWidth().isFixed()) |
4202 return true; | 4205 return true; |
4203 if (cb->isRenderView()) | 4206 if (cb->isRenderView()) |
4204 return true; | 4207 return true; |
4205 if (cb->isOutOfFlowPositioned()) | 4208 if (cb->isOutOfFlowPositioned()) |
4206 return true; | 4209 return true; |
4207 if (cb->style()->logicalWidth().isPercent()) | 4210 if (cb->style()->logicalWidth().isPercent()) |
4208 return logicalWidthIsResolvableFromBlock(cb->containingBlock()); | 4211 return logicalWidthIsResolvableFromBlock(cb->containingBlock()); |
4209 | 4212 |
4210 return false; | 4213 return false; |
4211 } | 4214 } |
4212 | 4215 |
4213 bool RenderBox::hasDefiniteLogicalWidth() const | 4216 bool LayoutBox::hasDefiniteLogicalWidth() const |
4214 { | 4217 { |
4215 const Length& logicalWidth = style()->logicalWidth(); | 4218 const Length& logicalWidth = style()->logicalWidth(); |
4216 if (logicalWidth.isIntrinsic() || logicalWidth.isLegacyIntrinsic()) | 4219 if (logicalWidth.isIntrinsic() || logicalWidth.isLegacyIntrinsic()) |
4217 return false; | 4220 return false; |
4218 if (logicalWidth.isFixed()) | 4221 if (logicalWidth.isFixed()) |
4219 return true; | 4222 return true; |
4220 // The size of the containing block of an absolutely positioned element is a
lways definite with respect to that | 4223 // The size of the containing block of an absolutely positioned element is a
lways definite with respect to that |
4221 // element (http://dev.w3.org/csswg/css-sizing-3/#definite). | 4224 // element (http://dev.w3.org/csswg/css-sizing-3/#definite). |
4222 if (isOutOfFlowPositioned()) | 4225 if (isOutOfFlowPositioned()) |
4223 return true; | 4226 return true; |
4224 | 4227 |
4225 return RenderBox::logicalWidthIsResolvableFromBlock(containingBlock()); | 4228 return LayoutBox::logicalWidthIsResolvableFromBlock(containingBlock()); |
4226 } | 4229 } |
4227 | 4230 |
4228 inline static bool percentageLogicalHeightIsResolvable(const RenderBox* box) | 4231 inline static bool percentageLogicalHeightIsResolvable(const LayoutBox* box) |
4229 { | 4232 { |
4230 return RenderBox::percentageLogicalHeightIsResolvableFromBlock(box->containi
ngBlock(), box->isOutOfFlowPositioned()); | 4233 return LayoutBox::percentageLogicalHeightIsResolvableFromBlock(box->containi
ngBlock(), box->isOutOfFlowPositioned()); |
4231 } | 4234 } |
4232 | 4235 |
4233 bool RenderBox::percentageLogicalHeightIsResolvableFromBlock(const RenderBlock*
containingBlock, bool isOutOfFlowPositioned) | 4236 bool LayoutBox::percentageLogicalHeightIsResolvableFromBlock(const RenderBlock*
containingBlock, bool isOutOfFlowPositioned) |
4234 { | 4237 { |
4235 // In quirks mode, blocks with auto height are skipped, and we keep looking
for an enclosing | 4238 // In quirks mode, blocks with auto height are skipped, and we keep looking
for an enclosing |
4236 // block that may have a specified height and then use it. In strict mode, t
his violates the | 4239 // block that may have a specified height and then use it. In strict mode, t
his violates the |
4237 // specification, which states that percentage heights just revert to auto i
f the containing | 4240 // specification, which states that percentage heights just revert to auto i
f the containing |
4238 // block has an auto height. We still skip anonymous containing blocks in bo
th modes, though, and look | 4241 // block has an auto height. We still skip anonymous containing blocks in bo
th modes, though, and look |
4239 // only at explicit containers. | 4242 // only at explicit containers. |
4240 const RenderBlock* cb = containingBlock; | 4243 const RenderBlock* cb = containingBlock; |
4241 bool inQuirksMode = cb->document().inQuirksMode(); | 4244 bool inQuirksMode = cb->document().inQuirksMode(); |
4242 while (!cb->isRenderView() && !cb->isBody() && !cb->isTableCell() && !cb->is
OutOfFlowPositioned() && cb->style()->logicalHeight().isAuto()) { | 4245 while (!cb->isRenderView() && !cb->isBody() && !cb->isTableCell() && !cb->is
OutOfFlowPositioned() && cb->style()->logicalHeight().isAuto()) { |
4243 if (!inQuirksMode && !cb->isAnonymousBlock()) | 4246 if (!inQuirksMode && !cb->isAnonymousBlock()) |
(...skipping 23 matching lines...) Expand all Loading... |
4267 return true; | 4270 return true; |
4268 if (cb->isDocumentElement() && isOutOfFlowPositioned) { | 4271 if (cb->isDocumentElement() && isOutOfFlowPositioned) { |
4269 // Match the positioned objects behavior, which is that positioned objec
ts will fill their viewport | 4272 // Match the positioned objects behavior, which is that positioned objec
ts will fill their viewport |
4270 // always. Note we could only hit this case by recurring into computePe
rcentageLogicalHeight on a positioned containing block. | 4273 // always. Note we could only hit this case by recurring into computePe
rcentageLogicalHeight on a positioned containing block. |
4271 return true; | 4274 return true; |
4272 } | 4275 } |
4273 | 4276 |
4274 return false; | 4277 return false; |
4275 } | 4278 } |
4276 | 4279 |
4277 bool RenderBox::hasDefiniteLogicalHeight() const | 4280 bool LayoutBox::hasDefiniteLogicalHeight() const |
4278 { | 4281 { |
4279 const Length& logicalHeight = style()->logicalHeight(); | 4282 const Length& logicalHeight = style()->logicalHeight(); |
4280 if (logicalHeight.isIntrinsicOrAuto()) | 4283 if (logicalHeight.isIntrinsicOrAuto()) |
4281 return false; | 4284 return false; |
4282 if (logicalHeight.isFixed()) | 4285 if (logicalHeight.isFixed()) |
4283 return true; | 4286 return true; |
4284 // The size of the containing block of an absolutely positioned element is a
lways definite with respect to that | 4287 // The size of the containing block of an absolutely positioned element is a
lways definite with respect to that |
4285 // element (http://dev.w3.org/csswg/css-sizing-3/#definite). | 4288 // element (http://dev.w3.org/csswg/css-sizing-3/#definite). |
4286 if (isOutOfFlowPositioned()) | 4289 if (isOutOfFlowPositioned()) |
4287 return true; | 4290 return true; |
4288 | 4291 |
4289 return percentageLogicalHeightIsResolvable(this); | 4292 return percentageLogicalHeightIsResolvable(this); |
4290 } | 4293 } |
4291 | 4294 |
4292 bool RenderBox::hasUnsplittableScrollingOverflow() const | 4295 bool LayoutBox::hasUnsplittableScrollingOverflow() const |
4293 { | 4296 { |
4294 // We will paginate as long as we don't scroll overflow in the pagination di
rection. | 4297 // We will paginate as long as we don't scroll overflow in the pagination di
rection. |
4295 bool isHorizontal = isHorizontalWritingMode(); | 4298 bool isHorizontal = isHorizontalWritingMode(); |
4296 if ((isHorizontal && !scrollsOverflowY()) || (!isHorizontal && !scrollsOverf
lowX())) | 4299 if ((isHorizontal && !scrollsOverflowY()) || (!isHorizontal && !scrollsOverf
lowX())) |
4297 return false; | 4300 return false; |
4298 | 4301 |
4299 // We do have overflow. We'll still be willing to paginate as long as the bl
ock | 4302 // We do have overflow. We'll still be willing to paginate as long as the bl
ock |
4300 // has auto logical height, auto or undefined max-logical-height and a zero
or auto min-logical-height. | 4303 // has auto logical height, auto or undefined max-logical-height and a zero
or auto min-logical-height. |
4301 // Note this is just a heuristic, and it's still possible to have overflow u
nder these | 4304 // Note this is just a heuristic, and it's still possible to have overflow u
nder these |
4302 // conditions, but it should work out to be good enough for common cases. Pa
ginating overflow | 4305 // conditions, but it should work out to be good enough for common cases. Pa
ginating overflow |
4303 // with scrollbars present is not the end of the world and is what we used t
o do in the old model anyway. | 4306 // with scrollbars present is not the end of the world and is what we used t
o do in the old model anyway. |
4304 return !style()->logicalHeight().isIntrinsicOrAuto() | 4307 return !style()->logicalHeight().isIntrinsicOrAuto() |
4305 || (!style()->logicalMaxHeight().isIntrinsicOrAuto() && !style()->logica
lMaxHeight().isMaxSizeNone() && (!style()->logicalMaxHeight().isPercent() || per
centageLogicalHeightIsResolvable(this))) | 4308 || (!style()->logicalMaxHeight().isIntrinsicOrAuto() && !style()->logica
lMaxHeight().isMaxSizeNone() && (!style()->logicalMaxHeight().isPercent() || per
centageLogicalHeightIsResolvable(this))) |
4306 || (!style()->logicalMinHeight().isIntrinsicOrAuto() && style()->logical
MinHeight().isPositive() && (!style()->logicalMinHeight().isPercent() || percent
ageLogicalHeightIsResolvable(this))); | 4309 || (!style()->logicalMinHeight().isIntrinsicOrAuto() && style()->logical
MinHeight().isPositive() && (!style()->logicalMinHeight().isPercent() || percent
ageLogicalHeightIsResolvable(this))); |
4307 } | 4310 } |
4308 | 4311 |
4309 bool RenderBox::isUnsplittableForPagination() const | 4312 bool LayoutBox::isUnsplittableForPagination() const |
4310 { | 4313 { |
4311 return isReplaced() || hasUnsplittableScrollingOverflow() || (parent() && is
WritingModeRoot()); | 4314 return isReplaced() || hasUnsplittableScrollingOverflow() || (parent() && is
WritingModeRoot()); |
4312 } | 4315 } |
4313 | 4316 |
4314 LayoutUnit RenderBox::lineHeight(bool /*firstLine*/, LineDirectionMode direction
, LinePositionMode /*linePositionMode*/) const | 4317 LayoutUnit LayoutBox::lineHeight(bool /*firstLine*/, LineDirectionMode direction
, LinePositionMode /*linePositionMode*/) const |
4315 { | 4318 { |
4316 if (isReplaced()) | 4319 if (isReplaced()) |
4317 return direction == HorizontalLine ? marginHeight() + size().height() :
marginWidth() + size().width(); | 4320 return direction == HorizontalLine ? marginHeight() + size().height() :
marginWidth() + size().width(); |
4318 return LayoutUnit(); | 4321 return LayoutUnit(); |
4319 } | 4322 } |
4320 | 4323 |
4321 int RenderBox::baselinePosition(FontBaseline baselineType, bool /*firstLine*/, L
ineDirectionMode direction, LinePositionMode linePositionMode) const | 4324 int LayoutBox::baselinePosition(FontBaseline baselineType, bool /*firstLine*/, L
ineDirectionMode direction, LinePositionMode linePositionMode) const |
4322 { | 4325 { |
4323 ASSERT(linePositionMode == PositionOnContainingLine); | 4326 ASSERT(linePositionMode == PositionOnContainingLine); |
4324 if (isReplaced()) { | 4327 if (isReplaced()) { |
4325 int result = direction == HorizontalLine ? marginHeight() + size().heigh
t() : marginWidth() + size().width(); | 4328 int result = direction == HorizontalLine ? marginHeight() + size().heigh
t() : marginWidth() + size().width(); |
4326 if (baselineType == AlphabeticBaseline) | 4329 if (baselineType == AlphabeticBaseline) |
4327 return result; | 4330 return result; |
4328 return result - result / 2; | 4331 return result - result / 2; |
4329 } | 4332 } |
4330 return 0; | 4333 return 0; |
4331 } | 4334 } |
4332 | 4335 |
4333 | 4336 |
4334 Layer* RenderBox::enclosingFloatPaintingLayer() const | 4337 Layer* LayoutBox::enclosingFloatPaintingLayer() const |
4335 { | 4338 { |
4336 const LayoutObject* curr = this; | 4339 const LayoutObject* curr = this; |
4337 while (curr) { | 4340 while (curr) { |
4338 Layer* layer = curr->hasLayer() && curr->isBox() ? toRenderBox(curr)->la
yer() : 0; | 4341 Layer* layer = curr->hasLayer() && curr->isBox() ? toLayoutBox(curr)->la
yer() : 0; |
4339 if (layer && layer->isSelfPaintingLayer()) | 4342 if (layer && layer->isSelfPaintingLayer()) |
4340 return layer; | 4343 return layer; |
4341 curr = curr->parent(); | 4344 curr = curr->parent(); |
4342 } | 4345 } |
4343 return 0; | 4346 return 0; |
4344 } | 4347 } |
4345 | 4348 |
4346 LayoutRect RenderBox::logicalVisualOverflowRectForPropagation(const LayoutStyle&
parentStyle) const | 4349 LayoutRect LayoutBox::logicalVisualOverflowRectForPropagation(const LayoutStyle&
parentStyle) const |
4347 { | 4350 { |
4348 LayoutRect rect = visualOverflowRectForPropagation(parentStyle); | 4351 LayoutRect rect = visualOverflowRectForPropagation(parentStyle); |
4349 if (!parentStyle.isHorizontalWritingMode()) | 4352 if (!parentStyle.isHorizontalWritingMode()) |
4350 return rect.transposedRect(); | 4353 return rect.transposedRect(); |
4351 return rect; | 4354 return rect; |
4352 } | 4355 } |
4353 | 4356 |
4354 LayoutRect RenderBox::visualOverflowRectForPropagation(const LayoutStyle& parent
Style) const | 4357 LayoutRect LayoutBox::visualOverflowRectForPropagation(const LayoutStyle& parent
Style) const |
4355 { | 4358 { |
4356 // If the writing modes of the child and parent match, then we don't have to | 4359 // If the writing modes of the child and parent match, then we don't have to |
4357 // do anything fancy. Just return the result. | 4360 // do anything fancy. Just return the result. |
4358 LayoutRect rect = visualOverflowRect(); | 4361 LayoutRect rect = visualOverflowRect(); |
4359 if (parentStyle.writingMode() == style()->writingMode()) | 4362 if (parentStyle.writingMode() == style()->writingMode()) |
4360 return rect; | 4363 return rect; |
4361 | 4364 |
4362 // We are putting ourselves into our parent's coordinate space. If there is
a flipped block mismatch | 4365 // We are putting ourselves into our parent's coordinate space. If there is
a flipped block mismatch |
4363 // in a particular axis, then we have to flip the rect along that axis. | 4366 // in a particular axis, then we have to flip the rect along that axis. |
4364 if (style()->writingMode() == RightToLeftWritingMode || parentStyle.writingM
ode() == RightToLeftWritingMode) | 4367 if (style()->writingMode() == RightToLeftWritingMode || parentStyle.writingM
ode() == RightToLeftWritingMode) |
4365 rect.setX(size().width() - rect.maxX()); | 4368 rect.setX(size().width() - rect.maxX()); |
4366 else if (style()->writingMode() == BottomToTopWritingMode || parentStyle.wri
tingMode() == BottomToTopWritingMode) | 4369 else if (style()->writingMode() == BottomToTopWritingMode || parentStyle.wri
tingMode() == BottomToTopWritingMode) |
4367 rect.setY(size().height() - rect.maxY()); | 4370 rect.setY(size().height() - rect.maxY()); |
4368 | 4371 |
4369 return rect; | 4372 return rect; |
4370 } | 4373 } |
4371 | 4374 |
4372 LayoutRect RenderBox::logicalLayoutOverflowRectForPropagation(const LayoutStyle&
parentStyle) const | 4375 LayoutRect LayoutBox::logicalLayoutOverflowRectForPropagation(const LayoutStyle&
parentStyle) const |
4373 { | 4376 { |
4374 LayoutRect rect = layoutOverflowRectForPropagation(parentStyle); | 4377 LayoutRect rect = layoutOverflowRectForPropagation(parentStyle); |
4375 if (!parentStyle.isHorizontalWritingMode()) | 4378 if (!parentStyle.isHorizontalWritingMode()) |
4376 return rect.transposedRect(); | 4379 return rect.transposedRect(); |
4377 return rect; | 4380 return rect; |
4378 } | 4381 } |
4379 | 4382 |
4380 LayoutRect RenderBox::layoutOverflowRectForPropagation(const LayoutStyle& parent
Style) const | 4383 LayoutRect LayoutBox::layoutOverflowRectForPropagation(const LayoutStyle& parent
Style) const |
4381 { | 4384 { |
4382 // Only propagate interior layout overflow if we don't clip it. | 4385 // Only propagate interior layout overflow if we don't clip it. |
4383 LayoutRect rect = borderBoxRect(); | 4386 LayoutRect rect = borderBoxRect(); |
4384 // We want to include the margin, but only when it adds height. Quirky margi
ns don't contribute height | 4387 // We want to include the margin, but only when it adds height. Quirky margi
ns don't contribute height |
4385 // nor do the margins of self-collapsing blocks. | 4388 // nor do the margins of self-collapsing blocks. |
4386 if (!styleRef().hasMarginAfterQuirk() && !isSelfCollapsingBlock()) | 4389 if (!styleRef().hasMarginAfterQuirk() && !isSelfCollapsingBlock()) |
4387 rect.expand(isHorizontalWritingMode() ? LayoutSize(LayoutUnit(), marginA
fter()) : LayoutSize(marginAfter(), LayoutUnit())); | 4390 rect.expand(isHorizontalWritingMode() ? LayoutSize(LayoutUnit(), marginA
fter()) : LayoutSize(marginAfter(), LayoutUnit())); |
4388 | 4391 |
4389 if (!hasOverflowClip()) | 4392 if (!hasOverflowClip()) |
4390 rect.unite(layoutOverflowRect()); | 4393 rect.unite(layoutOverflowRect()); |
(...skipping 23 matching lines...) Expand all Loading... |
4414 // We are putting ourselves into our parent's coordinate space. If there is
a flipped block mismatch | 4417 // We are putting ourselves into our parent's coordinate space. If there is
a flipped block mismatch |
4415 // in a particular axis, then we have to flip the rect along that axis. | 4418 // in a particular axis, then we have to flip the rect along that axis. |
4416 if (style()->writingMode() == RightToLeftWritingMode || parentStyle.writingM
ode() == RightToLeftWritingMode) | 4419 if (style()->writingMode() == RightToLeftWritingMode || parentStyle.writingM
ode() == RightToLeftWritingMode) |
4417 rect.setX(size().width() - rect.maxX()); | 4420 rect.setX(size().width() - rect.maxX()); |
4418 else if (style()->writingMode() == BottomToTopWritingMode || parentStyle.wri
tingMode() == BottomToTopWritingMode) | 4421 else if (style()->writingMode() == BottomToTopWritingMode || parentStyle.wri
tingMode() == BottomToTopWritingMode) |
4419 rect.setY(size().height() - rect.maxY()); | 4422 rect.setY(size().height() - rect.maxY()); |
4420 | 4423 |
4421 return rect; | 4424 return rect; |
4422 } | 4425 } |
4423 | 4426 |
4424 LayoutRect RenderBox::noOverflowRect() const | 4427 LayoutRect LayoutBox::noOverflowRect() const |
4425 { | 4428 { |
4426 // Because of the special coordinate system used for overflow rectangles and
many other | 4429 // Because of the special coordinate system used for overflow rectangles and
many other |
4427 // rectangles (not quite logical, not quite physical), we need to flip the b
lock progression | 4430 // rectangles (not quite logical, not quite physical), we need to flip the b
lock progression |
4428 // coordinate in vertical-rl and horizontal-bt writing modes. In other words
, the rectangle | 4431 // coordinate in vertical-rl and horizontal-bt writing modes. In other words
, the rectangle |
4429 // returned is physical, except for the block direction progression coordina
te (y in horizontal | 4432 // returned is physical, except for the block direction progression coordina
te (y in horizontal |
4430 // writing modes, x in vertical writing modes), which is always "logical top
". Apart from the | 4433 // writing modes, x in vertical writing modes), which is always "logical top
". Apart from the |
4431 // flipping, this method does the same as clientBoxRect(). | 4434 // flipping, this method does the same as clientBoxRect(). |
4432 | 4435 |
4433 const int scrollBarWidth = verticalScrollbarWidth(); | 4436 const int scrollBarWidth = verticalScrollbarWidth(); |
4434 const int scrollBarHeight = horizontalScrollbarHeight(); | 4437 const int scrollBarHeight = horizontalScrollbarHeight(); |
(...skipping 12 matching lines...) Expand all Loading... |
4447 // FIXME: when the above mentioned bug is fixed, it should hopefully be poss
ible to call | 4450 // FIXME: when the above mentioned bug is fixed, it should hopefully be poss
ible to call |
4448 // clientBoxRect() or paddingBoxRect() in this method, rather than fiddling
with the edges on | 4451 // clientBoxRect() or paddingBoxRect() in this method, rather than fiddling
with the edges on |
4449 // our own. | 4452 // our own. |
4450 if (style()->shouldPlaceBlockDirectionScrollbarOnLogicalLeft()) | 4453 if (style()->shouldPlaceBlockDirectionScrollbarOnLogicalLeft()) |
4451 rect.contract(0, scrollBarHeight); | 4454 rect.contract(0, scrollBarHeight); |
4452 else | 4455 else |
4453 rect.contract(scrollBarWidth, scrollBarHeight); | 4456 rect.contract(scrollBarWidth, scrollBarHeight); |
4454 return rect; | 4457 return rect; |
4455 } | 4458 } |
4456 | 4459 |
4457 LayoutUnit RenderBox::offsetLeft() const | 4460 LayoutUnit LayoutBox::offsetLeft() const |
4458 { | 4461 { |
4459 return adjustedPositionRelativeToOffsetParent(topLeftLocation()).x(); | 4462 return adjustedPositionRelativeToOffsetParent(topLeftLocation()).x(); |
4460 } | 4463 } |
4461 | 4464 |
4462 LayoutUnit RenderBox::offsetTop() const | 4465 LayoutUnit LayoutBox::offsetTop() const |
4463 { | 4466 { |
4464 return adjustedPositionRelativeToOffsetParent(topLeftLocation()).y(); | 4467 return adjustedPositionRelativeToOffsetParent(topLeftLocation()).y(); |
4465 } | 4468 } |
4466 | 4469 |
4467 LayoutPoint RenderBox::flipForWritingModeForChild(const RenderBox* child, const
LayoutPoint& point) const | 4470 LayoutPoint LayoutBox::flipForWritingModeForChild(const LayoutBox* child, const
LayoutPoint& point) const |
4468 { | 4471 { |
4469 if (!style()->isFlippedBlocksWritingMode()) | 4472 if (!style()->isFlippedBlocksWritingMode()) |
4470 return point; | 4473 return point; |
4471 | 4474 |
4472 // The child is going to add in its x() and y(), so we have to make sure it
ends up in | 4475 // The child is going to add in its x() and y(), so we have to make sure it
ends up in |
4473 // the right place. | 4476 // the right place. |
4474 if (isHorizontalWritingMode()) | 4477 if (isHorizontalWritingMode()) |
4475 return LayoutPoint(point.x(), point.y() + size().height() - child->size(
).height() - (2 * child->location().y())); | 4478 return LayoutPoint(point.x(), point.y() + size().height() - child->size(
).height() - (2 * child->location().y())); |
4476 return LayoutPoint(point.x() + size().width() - child->size().width() - (2 *
child->location().x()), point.y()); | 4479 return LayoutPoint(point.x() + size().width() - child->size().width() - (2 *
child->location().x()), point.y()); |
4477 } | 4480 } |
4478 | 4481 |
4479 LayoutPoint RenderBox::flipForWritingModeIncludingColumns(const LayoutPoint& poi
nt) const | 4482 LayoutPoint LayoutBox::flipForWritingModeIncludingColumns(const LayoutPoint& poi
nt) const |
4480 { | 4483 { |
4481 if (!hasColumns() || !style()->isFlippedBlocksWritingMode()) | 4484 if (!hasColumns() || !style()->isFlippedBlocksWritingMode()) |
4482 return flipForWritingMode(point); | 4485 return flipForWritingMode(point); |
4483 return toRenderBlock(this)->flipForWritingModeIncludingColumns(point); | 4486 return toRenderBlock(this)->flipForWritingModeIncludingColumns(point); |
4484 } | 4487 } |
4485 | 4488 |
4486 LayoutPoint RenderBox::topLeftLocation() const | 4489 LayoutPoint LayoutBox::topLeftLocation() const |
4487 { | 4490 { |
4488 RenderBlock* containerBlock = containingBlock(); | 4491 RenderBlock* containerBlock = containingBlock(); |
4489 if (!containerBlock || containerBlock == this) | 4492 if (!containerBlock || containerBlock == this) |
4490 return location(); | 4493 return location(); |
4491 return containerBlock->flipForWritingModeForChild(this, location()); | 4494 return containerBlock->flipForWritingModeForChild(this, location()); |
4492 } | 4495 } |
4493 | 4496 |
4494 bool RenderBox::hasRelativeLogicalHeight() const | 4497 bool LayoutBox::hasRelativeLogicalHeight() const |
4495 { | 4498 { |
4496 return style()->logicalHeight().isPercent() | 4499 return style()->logicalHeight().isPercent() |
4497 || style()->logicalMinHeight().isPercent() | 4500 || style()->logicalMinHeight().isPercent() |
4498 || style()->logicalMaxHeight().isPercent(); | 4501 || style()->logicalMaxHeight().isPercent(); |
4499 } | 4502 } |
4500 | 4503 |
4501 static void markBoxForRelayoutAfterSplit(RenderBox* box) | 4504 static void markBoxForRelayoutAfterSplit(LayoutBox* box) |
4502 { | 4505 { |
4503 // FIXME: The table code should handle that automatically. If not, | 4506 // FIXME: The table code should handle that automatically. If not, |
4504 // we should fix it and remove the table part checks. | 4507 // we should fix it and remove the table part checks. |
4505 if (box->isTable()) { | 4508 if (box->isTable()) { |
4506 // Because we may have added some sections with already computed column
structures, we need to | 4509 // Because we may have added some sections with already computed column
structures, we need to |
4507 // sync the table structure with them now. This avoids crashes when addi
ng new cells to the table. | 4510 // sync the table structure with them now. This avoids crashes when addi
ng new cells to the table. |
4508 toLayoutTable(box)->forceSectionsRecalc(); | 4511 toLayoutTable(box)->forceSectionsRecalc(); |
4509 } else if (box->isTableSection()) { | 4512 } else if (box->isTableSection()) { |
4510 toLayoutTableSection(box)->setNeedsCellRecalc(); | 4513 toLayoutTableSection(box)->setNeedsCellRecalc(); |
4511 } | 4514 } |
4512 | 4515 |
4513 box->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation(); | 4516 box->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation(); |
4514 } | 4517 } |
4515 | 4518 |
4516 LayoutObject* RenderBox::splitAnonymousBoxesAroundChild(LayoutObject* beforeChil
d) | 4519 LayoutObject* LayoutBox::splitAnonymousBoxesAroundChild(LayoutObject* beforeChil
d) |
4517 { | 4520 { |
4518 bool didSplitParentAnonymousBoxes = false; | 4521 bool didSplitParentAnonymousBoxes = false; |
4519 | 4522 |
4520 while (beforeChild->parent() != this) { | 4523 while (beforeChild->parent() != this) { |
4521 RenderBox* boxToSplit = toRenderBox(beforeChild->parent()); | 4524 LayoutBox* boxToSplit = toLayoutBox(beforeChild->parent()); |
4522 if (boxToSplit->slowFirstChild() != beforeChild && boxToSplit->isAnonymo
us()) { | 4525 if (boxToSplit->slowFirstChild() != beforeChild && boxToSplit->isAnonymo
us()) { |
4523 didSplitParentAnonymousBoxes = true; | 4526 didSplitParentAnonymousBoxes = true; |
4524 | 4527 |
4525 // We have to split the parent box into two boxes and move children | 4528 // We have to split the parent box into two boxes and move children |
4526 // from |beforeChild| to end into the new post box. | 4529 // from |beforeChild| to end into the new post box. |
4527 RenderBox* postBox = boxToSplit->createAnonymousBoxWithSameTypeAs(th
is); | 4530 LayoutBox* postBox = boxToSplit->createAnonymousBoxWithSameTypeAs(th
is); |
4528 postBox->setChildrenInline(boxToSplit->childrenInline()); | 4531 postBox->setChildrenInline(boxToSplit->childrenInline()); |
4529 RenderBox* parentBox = toRenderBox(boxToSplit->parent()); | 4532 LayoutBox* parentBox = toLayoutBox(boxToSplit->parent()); |
4530 // We need to invalidate the |parentBox| before inserting the new no
de | 4533 // We need to invalidate the |parentBox| before inserting the new no
de |
4531 // so that the table paint invalidation logic knows the structure is
dirty. | 4534 // so that the table paint invalidation logic knows the structure is
dirty. |
4532 // See for example LayoutTableCell:clippedOverflowRectForPaintInvali
dation. | 4535 // See for example LayoutTableCell:clippedOverflowRectForPaintInvali
dation. |
4533 markBoxForRelayoutAfterSplit(parentBox); | 4536 markBoxForRelayoutAfterSplit(parentBox); |
4534 parentBox->virtualChildren()->insertChildNode(parentBox, postBox, bo
xToSplit->nextSibling()); | 4537 parentBox->virtualChildren()->insertChildNode(parentBox, postBox, bo
xToSplit->nextSibling()); |
4535 boxToSplit->moveChildrenTo(postBox, beforeChild, 0, true); | 4538 boxToSplit->moveChildrenTo(postBox, beforeChild, 0, true); |
4536 | 4539 |
4537 markBoxForRelayoutAfterSplit(boxToSplit); | 4540 markBoxForRelayoutAfterSplit(boxToSplit); |
4538 markBoxForRelayoutAfterSplit(postBox); | 4541 markBoxForRelayoutAfterSplit(postBox); |
4539 | 4542 |
4540 beforeChild = postBox; | 4543 beforeChild = postBox; |
4541 } else | 4544 } else { |
4542 beforeChild = boxToSplit; | 4545 beforeChild = boxToSplit; |
| 4546 } |
4543 } | 4547 } |
4544 | 4548 |
4545 if (didSplitParentAnonymousBoxes) | 4549 if (didSplitParentAnonymousBoxes) |
4546 markBoxForRelayoutAfterSplit(this); | 4550 markBoxForRelayoutAfterSplit(this); |
4547 | 4551 |
4548 ASSERT(beforeChild->parent() == this); | 4552 ASSERT(beforeChild->parent() == this); |
4549 return beforeChild; | 4553 return beforeChild; |
4550 } | 4554 } |
4551 | 4555 |
4552 LayoutUnit RenderBox::offsetFromLogicalTopOfFirstPage() const | 4556 LayoutUnit LayoutBox::offsetFromLogicalTopOfFirstPage() const |
4553 { | 4557 { |
4554 LayoutState* layoutState = view()->layoutState(); | 4558 LayoutState* layoutState = view()->layoutState(); |
4555 if (layoutState && !layoutState->isPaginated()) | 4559 if (layoutState && !layoutState->isPaginated()) |
4556 return LayoutUnit(); | 4560 return LayoutUnit(); |
4557 | 4561 |
4558 if (!layoutState && !flowThreadContainingBlock()) | 4562 if (!layoutState && !flowThreadContainingBlock()) |
4559 return LayoutUnit(); | 4563 return LayoutUnit(); |
4560 | 4564 |
4561 RenderBlock* containerBlock = containingBlock(); | 4565 RenderBlock* containerBlock = containingBlock(); |
4562 return containerBlock->offsetFromLogicalTopOfFirstPage() + logicalTop(); | 4566 return containerBlock->offsetFromLogicalTopOfFirstPage() + logicalTop(); |
4563 } | 4567 } |
4564 | 4568 |
4565 void RenderBox::savePreviousBorderBoxSizeIfNeeded() | 4569 void LayoutBox::savePreviousBorderBoxSizeIfNeeded() |
4566 { | 4570 { |
4567 // If m_rareData is already created, always save. | 4571 // If m_rareData is already created, always save. |
4568 if (!m_rareData) { | 4572 if (!m_rareData) { |
4569 LayoutSize paintInvalidationSize = previousPaintInvalidationRect().size(
); | 4573 LayoutSize paintInvalidationSize = previousPaintInvalidationRect().size(
); |
4570 | 4574 |
4571 // Don't save old border box size if the paint rect is empty because we'
ll | 4575 // Don't save old border box size if the paint rect is empty because we'
ll |
4572 // full invalidate once the paint rect becomes non-empty. | 4576 // full invalidate once the paint rect becomes non-empty. |
4573 if (paintInvalidationSize.isEmpty()) | 4577 if (paintInvalidationSize.isEmpty()) |
4574 return; | 4578 return; |
4575 | 4579 |
4576 // Don't save old border box size if we can use size of the old paint re
ct | 4580 // Don't save old border box size if we can use size of the old paint re
ct |
4577 // as the old border box size in the next invalidation. | 4581 // as the old border box size in the next invalidation. |
4578 if (paintInvalidationSize == size()) | 4582 if (paintInvalidationSize == size()) |
4579 return; | 4583 return; |
4580 | 4584 |
4581 // We need the old border box size only when the box has background or b
ox decorations. | 4585 // We need the old border box size only when the box has background or b
ox decorations. |
4582 if (!style()->hasBackground() && !style()->hasBoxDecorations()) | 4586 if (!style()->hasBackground() && !style()->hasBoxDecorations()) |
4583 return; | 4587 return; |
4584 } | 4588 } |
4585 | 4589 |
4586 ensureRareData().m_previousBorderBoxSize = size(); | 4590 ensureRareData().m_previousBorderBoxSize = size(); |
4587 } | 4591 } |
4588 | 4592 |
4589 LayoutSize RenderBox::computePreviousBorderBoxSize(const LayoutSize& previousBou
ndsSize) const | 4593 LayoutSize LayoutBox::computePreviousBorderBoxSize(const LayoutSize& previousBou
ndsSize) const |
4590 { | 4594 { |
4591 // PreviousBorderBoxSize is only valid when there is background or box decor
ations. | 4595 // PreviousBorderBoxSize is only valid when there is background or box decor
ations. |
4592 ASSERT(style()->hasBackground() || style()->hasBoxDecorations()); | 4596 ASSERT(style()->hasBackground() || style()->hasBoxDecorations()); |
4593 | 4597 |
4594 if (m_rareData && m_rareData->m_previousBorderBoxSize.width() != -1) | 4598 if (m_rareData && m_rareData->m_previousBorderBoxSize.width() != -1) |
4595 return m_rareData->m_previousBorderBoxSize; | 4599 return m_rareData->m_previousBorderBoxSize; |
4596 | 4600 |
4597 // We didn't save the old border box size because it was the same as the siz
e of oldBounds. | 4601 // We didn't save the old border box size because it was the same as the siz
e of oldBounds. |
4598 return previousBoundsSize; | 4602 return previousBoundsSize; |
4599 } | 4603 } |
4600 | 4604 |
4601 void RenderBox::logicalExtentAfterUpdatingLogicalWidth(const LayoutUnit& newLogi
calTop, RenderBox::LogicalExtentComputedValues& computedValues) | 4605 void LayoutBox::logicalExtentAfterUpdatingLogicalWidth(const LayoutUnit& newLogi
calTop, LayoutBox::LogicalExtentComputedValues& computedValues) |
4602 { | 4606 { |
4603 // FIXME: None of this is right for perpendicular writing-mode children. | 4607 // FIXME: None of this is right for perpendicular writing-mode children. |
4604 LayoutUnit oldLogicalWidth = logicalWidth(); | 4608 LayoutUnit oldLogicalWidth = logicalWidth(); |
4605 LayoutUnit oldLogicalLeft = logicalLeft(); | 4609 LayoutUnit oldLogicalLeft = logicalLeft(); |
4606 LayoutUnit oldMarginLeft = marginLeft(); | 4610 LayoutUnit oldMarginLeft = marginLeft(); |
4607 LayoutUnit oldMarginRight = marginRight(); | 4611 LayoutUnit oldMarginRight = marginRight(); |
4608 LayoutUnit oldLogicalTop = logicalTop(); | 4612 LayoutUnit oldLogicalTop = logicalTop(); |
4609 | 4613 |
4610 setLogicalTop(newLogicalTop); | 4614 setLogicalTop(newLogicalTop); |
4611 updateLogicalWidth(); | 4615 updateLogicalWidth(); |
4612 | 4616 |
4613 computedValues.m_extent = logicalWidth(); | 4617 computedValues.m_extent = logicalWidth(); |
4614 computedValues.m_position = logicalLeft(); | 4618 computedValues.m_position = logicalLeft(); |
4615 computedValues.m_margins.m_start = marginStart(); | 4619 computedValues.m_margins.m_start = marginStart(); |
4616 computedValues.m_margins.m_end = marginEnd(); | 4620 computedValues.m_margins.m_end = marginEnd(); |
4617 | 4621 |
4618 setLogicalTop(oldLogicalTop); | 4622 setLogicalTop(oldLogicalTop); |
4619 setLogicalWidth(oldLogicalWidth); | 4623 setLogicalWidth(oldLogicalWidth); |
4620 setLogicalLeft(oldLogicalLeft); | 4624 setLogicalLeft(oldLogicalLeft); |
4621 setMarginLeft(oldMarginLeft); | 4625 setMarginLeft(oldMarginLeft); |
4622 setMarginRight(oldMarginRight); | 4626 setMarginRight(oldMarginRight); |
4623 } | 4627 } |
4624 | 4628 |
4625 void RenderBox::invalidateDisplayItemClients(DisplayItemList* displayItemList) c
onst | 4629 void LayoutBox::invalidateDisplayItemClients(DisplayItemList* displayItemList) c
onst |
4626 { | 4630 { |
4627 LayoutBoxModelObject::invalidateDisplayItemClients(displayItemList); | 4631 LayoutBoxModelObject::invalidateDisplayItemClients(displayItemList); |
4628 if (LayerScrollableArea* area = scrollableArea()) | 4632 if (LayerScrollableArea* area = scrollableArea()) |
4629 displayItemList->invalidate(area->displayItemClient()); | 4633 displayItemList->invalidate(area->displayItemClient()); |
4630 } | 4634 } |
4631 | 4635 |
4632 } // namespace blink | 4636 } // namespace blink |
OLD | NEW |