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 |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 if (parentBlockFlow) { | 164 if (parentBlockFlow) { |
165 parentBlockFlow->markSiblingsWithFloatsForLayout(this); | 165 parentBlockFlow->markSiblingsWithFloatsForLayout(this); |
166 parentBlockFlow->markAllDescendantsWithFloatsForLayout(this, false); | 166 parentBlockFlow->markAllDescendantsWithFloatsForLayout(this, false); |
167 } | 167 } |
168 } | 168 } |
169 | 169 |
170 if (isOutOfFlowPositioned()) | 170 if (isOutOfFlowPositioned()) |
171 LayoutBlock::removePositionedObject(this); | 171 LayoutBlock::removePositionedObject(this); |
172 } | 172 } |
173 | 173 |
174 void LayoutBox::styleWillChange(StyleDifference diff, const LayoutStyle& newStyl
e) | 174 void LayoutBox::styleWillChange(StyleDifference diff, const ComputedStyle& newSt
yle) |
175 { | 175 { |
176 const LayoutStyle* oldStyle = style(); | 176 const ComputedStyle* oldStyle = style(); |
177 if (oldStyle) { | 177 if (oldStyle) { |
178 // The background of the root element or the body element could propagat
e up to | 178 // The background of the root element or the body element could propagat
e up to |
179 // the canvas. Just dirty the entire canvas when our style changes subst
antially. | 179 // the canvas. Just dirty the entire canvas when our style changes subst
antially. |
180 if ((diff.needsPaintInvalidation() || diff.needsLayout()) && node() | 180 if ((diff.needsPaintInvalidation() || diff.needsLayout()) && node() |
181 && (isHTMLHtmlElement(*node()) || isHTMLBodyElement(*node()))) { | 181 && (isHTMLHtmlElement(*node()) || isHTMLBodyElement(*node()))) { |
182 view()->setShouldDoFullPaintInvalidation(); | 182 view()->setShouldDoFullPaintInvalidation(); |
183 | 183 |
184 if (oldStyle->hasEntirelyFixedBackground() != newStyle.hasEntirelyFi
xedBackground()) | 184 if (oldStyle->hasEntirelyFixedBackground() != newStyle.hasEntirelyFi
xedBackground()) |
185 view()->compositor()->setNeedsUpdateFixedBackground(); | 185 view()->compositor()->setNeedsUpdateFixedBackground(); |
186 } | 186 } |
(...skipping 11 matching lines...) Expand all Loading... |
198 } | 198 } |
199 // FIXME: This branch runs when !oldStyle, which means that layout was never
called | 199 // FIXME: This branch runs when !oldStyle, which means that layout was never
called |
200 // so what's the point in invalidating the whole view that we never painted? | 200 // so what's the point in invalidating the whole view that we never painted? |
201 } else if (isBody()) { | 201 } else if (isBody()) { |
202 view()->setShouldDoFullPaintInvalidation(); | 202 view()->setShouldDoFullPaintInvalidation(); |
203 } | 203 } |
204 | 204 |
205 LayoutBoxModelObject::styleWillChange(diff, newStyle); | 205 LayoutBoxModelObject::styleWillChange(diff, newStyle); |
206 } | 206 } |
207 | 207 |
208 void LayoutBox::styleDidChange(StyleDifference diff, const LayoutStyle* oldStyle
) | 208 void LayoutBox::styleDidChange(StyleDifference diff, const ComputedStyle* oldSty
le) |
209 { | 209 { |
210 // Horizontal writing mode definition is updated in LayoutBoxModelObject::up
dateFromStyle, | 210 // Horizontal writing mode definition is updated in LayoutBoxModelObject::up
dateFromStyle, |
211 // (as part of the LayoutBoxModelObject::styleDidChange call below). So, we
can safely cache the horizontal | 211 // (as part of the LayoutBoxModelObject::styleDidChange call below). So, we
can safely cache the horizontal |
212 // writing mode value before style change here. | 212 // writing mode value before style change here. |
213 bool oldHorizontalWritingMode = isHorizontalWritingMode(); | 213 bool oldHorizontalWritingMode = isHorizontalWritingMode(); |
214 | 214 |
215 LayoutBoxModelObject::styleDidChange(diff, oldStyle); | 215 LayoutBoxModelObject::styleDidChange(diff, oldStyle); |
216 | 216 |
217 const LayoutStyle& newStyle = styleRef(); | 217 const ComputedStyle& newStyle = styleRef(); |
218 if (needsLayout() && oldStyle) | 218 if (needsLayout() && oldStyle) |
219 LayoutBlock::removePercentHeightDescendantIfNeeded(this); | 219 LayoutBlock::removePercentHeightDescendantIfNeeded(this); |
220 | 220 |
221 if (LayoutBlock::hasPercentHeightContainerMap() && slowFirstChild() | 221 if (LayoutBlock::hasPercentHeightContainerMap() && slowFirstChild() |
222 && oldHorizontalWritingMode != isHorizontalWritingMode()) | 222 && oldHorizontalWritingMode != isHorizontalWritingMode()) |
223 LayoutBlock::clearPercentHeightDescendantsFrom(this); | 223 LayoutBlock::clearPercentHeightDescendantsFrom(this); |
224 | 224 |
225 // If our zoom factor changes and we have a defined scrollLeft/Top, we need
to adjust that value into the | 225 // If our zoom factor changes and we have a defined scrollLeft/Top, we need
to adjust that value into the |
226 // new zoomed coordinate space. | 226 // new zoomed coordinate space. |
227 if (hasOverflowClip() && oldStyle && oldStyle->effectiveZoom() != newStyle.e
ffectiveZoom() && layer()) { | 227 if (hasOverflowClip() && oldStyle && oldStyle->effectiveZoom() != newStyle.e
ffectiveZoom() && layer()) { |
(...skipping 20 matching lines...) Expand all Loading... |
248 document().view()->recalculateScrollbarOverlayStyle(); | 248 document().view()->recalculateScrollbarOverlayStyle(); |
249 document().view()->recalculateCustomScrollbarStyle(); | 249 document().view()->recalculateCustomScrollbarStyle(); |
250 } | 250 } |
251 updateShapeOutsideInfoAfterStyleChange(*style(), oldStyle); | 251 updateShapeOutsideInfoAfterStyleChange(*style(), oldStyle); |
252 updateGridPositionAfterStyleChange(oldStyle); | 252 updateGridPositionAfterStyleChange(oldStyle); |
253 | 253 |
254 if (LayoutMultiColumnSpannerPlaceholder* placeholder = this->spannerPlacehol
der()) | 254 if (LayoutMultiColumnSpannerPlaceholder* placeholder = this->spannerPlacehol
der()) |
255 placeholder->updateMarginProperties(); | 255 placeholder->updateMarginProperties(); |
256 } | 256 } |
257 | 257 |
258 void LayoutBox::updateShapeOutsideInfoAfterStyleChange(const LayoutStyle& style,
const LayoutStyle* oldStyle) | 258 void LayoutBox::updateShapeOutsideInfoAfterStyleChange(const ComputedStyle& styl
e, const ComputedStyle* oldStyle) |
259 { | 259 { |
260 const ShapeValue* shapeOutside = style.shapeOutside(); | 260 const ShapeValue* shapeOutside = style.shapeOutside(); |
261 const ShapeValue* oldShapeOutside = oldStyle ? oldStyle->shapeOutside() : La
youtStyle::initialShapeOutside(); | 261 const ShapeValue* oldShapeOutside = oldStyle ? oldStyle->shapeOutside() : Co
mputedStyle::initialShapeOutside(); |
262 | 262 |
263 Length shapeMargin = style.shapeMargin(); | 263 Length shapeMargin = style.shapeMargin(); |
264 Length oldShapeMargin = oldStyle ? oldStyle->shapeMargin() : LayoutStyle::in
itialShapeMargin(); | 264 Length oldShapeMargin = oldStyle ? oldStyle->shapeMargin() : ComputedStyle::
initialShapeMargin(); |
265 | 265 |
266 float shapeImageThreshold = style.shapeImageThreshold(); | 266 float shapeImageThreshold = style.shapeImageThreshold(); |
267 float oldShapeImageThreshold = oldStyle ? oldStyle->shapeImageThreshold() :
LayoutStyle::initialShapeImageThreshold(); | 267 float oldShapeImageThreshold = oldStyle ? oldStyle->shapeImageThreshold() :
ComputedStyle::initialShapeImageThreshold(); |
268 | 268 |
269 // FIXME: A future optimization would do a deep comparison for equality. (bu
g 100811) | 269 // FIXME: A future optimization would do a deep comparison for equality. (bu
g 100811) |
270 if (shapeOutside == oldShapeOutside && shapeMargin == oldShapeMargin && shap
eImageThreshold == oldShapeImageThreshold) | 270 if (shapeOutside == oldShapeOutside && shapeMargin == oldShapeMargin && shap
eImageThreshold == oldShapeImageThreshold) |
271 return; | 271 return; |
272 | 272 |
273 if (!shapeOutside) | 273 if (!shapeOutside) |
274 ShapeOutsideInfo::removeInfo(*this); | 274 ShapeOutsideInfo::removeInfo(*this); |
275 else | 275 else |
276 ShapeOutsideInfo::ensureInfo(*this).markShapeAsDirty(); | 276 ShapeOutsideInfo::ensureInfo(*this).markShapeAsDirty(); |
277 | 277 |
278 if (shapeOutside || shapeOutside != oldShapeOutside) | 278 if (shapeOutside || shapeOutside != oldShapeOutside) |
279 markShapeOutsideDependentsForLayout(); | 279 markShapeOutsideDependentsForLayout(); |
280 } | 280 } |
281 | 281 |
282 void LayoutBox::updateGridPositionAfterStyleChange(const LayoutStyle* oldStyle) | 282 void LayoutBox::updateGridPositionAfterStyleChange(const ComputedStyle* oldStyle
) |
283 { | 283 { |
284 if (!oldStyle || !parent() || !parent()->isLayoutGrid()) | 284 if (!oldStyle || !parent() || !parent()->isLayoutGrid()) |
285 return; | 285 return; |
286 | 286 |
287 if (oldStyle->gridColumnStart() == style()->gridColumnStart() | 287 if (oldStyle->gridColumnStart() == style()->gridColumnStart() |
288 && oldStyle->gridColumnEnd() == style()->gridColumnEnd() | 288 && oldStyle->gridColumnEnd() == style()->gridColumnEnd() |
289 && oldStyle->gridRowStart() == style()->gridRowStart() | 289 && oldStyle->gridRowStart() == style()->gridRowStart() |
290 && oldStyle->gridRowEnd() == style()->gridRowEnd() | 290 && oldStyle->gridRowEnd() == style()->gridRowEnd() |
291 && oldStyle->order() == style()->order() | 291 && oldStyle->order() == style()->order() |
292 && oldStyle->hasOutOfFlowPosition() == style()->hasOutOfFlowPosition()) | 292 && oldStyle->hasOutOfFlowPosition() == style()->hasOutOfFlowPosition()) |
293 return; | 293 return; |
294 | 294 |
295 // It should be possible to not dirty the grid in some cases (like moving an
explicitly placed grid item). | 295 // It should be possible to not dirty the grid in some cases (like moving an
explicitly placed grid item). |
296 // For now, it's more simple to just always recompute the grid. | 296 // For now, it's more simple to just always recompute the grid. |
297 toLayoutGrid(parent())->dirtyGrid(); | 297 toLayoutGrid(parent())->dirtyGrid(); |
298 } | 298 } |
299 | 299 |
300 void LayoutBox::updateFromStyle() | 300 void LayoutBox::updateFromStyle() |
301 { | 301 { |
302 LayoutBoxModelObject::updateFromStyle(); | 302 LayoutBoxModelObject::updateFromStyle(); |
303 | 303 |
304 const LayoutStyle& styleToUse = styleRef(); | 304 const ComputedStyle& styleToUse = styleRef(); |
305 bool isRootObject = isDocumentElement(); | 305 bool isRootObject = isDocumentElement(); |
306 bool isViewObject = isLayoutView(); | 306 bool isViewObject = isLayoutView(); |
307 bool rootLayerScrolls = document().settings() && document().settings()->root
LayerScrolls(); | 307 bool rootLayerScrolls = document().settings() && document().settings()->root
LayerScrolls(); |
308 | 308 |
309 // The root and the LayoutView always paint their backgrounds/borders. | 309 // The root and the LayoutView always paint their backgrounds/borders. |
310 if (isRootObject || isViewObject) | 310 if (isRootObject || isViewObject) |
311 setHasBoxDecorationBackground(true); | 311 setHasBoxDecorationBackground(true); |
312 | 312 |
313 setFloating(!isOutOfFlowPositioned() && styleToUse.isFloating()); | 313 setFloating(!isOutOfFlowPositioned() && styleToUse.isFloating()); |
314 | 314 |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
571 | 571 |
572 void LayoutBox::updateLayerTransformAfterLayout() | 572 void LayoutBox::updateLayerTransformAfterLayout() |
573 { | 573 { |
574 // Transform-origin depends on box size, so we need to update the layer tran
sform after layout. | 574 // Transform-origin depends on box size, so we need to update the layer tran
sform after layout. |
575 if (hasLayer()) | 575 if (hasLayer()) |
576 layer()->updateTransformationMatrix(); | 576 layer()->updateTransformationMatrix(); |
577 } | 577 } |
578 | 578 |
579 LayoutUnit LayoutBox::constrainLogicalWidthByMinMax(LayoutUnit logicalWidth, Lay
outUnit availableWidth, LayoutBlock* cb) const | 579 LayoutUnit LayoutBox::constrainLogicalWidthByMinMax(LayoutUnit logicalWidth, Lay
outUnit availableWidth, LayoutBlock* cb) const |
580 { | 580 { |
581 const LayoutStyle& styleToUse = styleRef(); | 581 const ComputedStyle& styleToUse = styleRef(); |
582 if (!styleToUse.logicalMaxWidth().isMaxSizeNone()) | 582 if (!styleToUse.logicalMaxWidth().isMaxSizeNone()) |
583 logicalWidth = std::min(logicalWidth, computeLogicalWidthUsing(MaxSize,
styleToUse.logicalMaxWidth(), availableWidth, cb)); | 583 logicalWidth = std::min(logicalWidth, computeLogicalWidthUsing(MaxSize,
styleToUse.logicalMaxWidth(), availableWidth, cb)); |
584 return std::max(logicalWidth, computeLogicalWidthUsing(MinSize, styleToUse.l
ogicalMinWidth(), availableWidth, cb)); | 584 return std::max(logicalWidth, computeLogicalWidthUsing(MinSize, styleToUse.l
ogicalMinWidth(), availableWidth, cb)); |
585 } | 585 } |
586 | 586 |
587 LayoutUnit LayoutBox::constrainLogicalHeightByMinMax(LayoutUnit logicalHeight, L
ayoutUnit intrinsicContentHeight) const | 587 LayoutUnit LayoutBox::constrainLogicalHeightByMinMax(LayoutUnit logicalHeight, L
ayoutUnit intrinsicContentHeight) const |
588 { | 588 { |
589 const LayoutStyle& styleToUse = styleRef(); | 589 const ComputedStyle& styleToUse = styleRef(); |
590 if (!styleToUse.logicalMaxHeight().isMaxSizeNone()) { | 590 if (!styleToUse.logicalMaxHeight().isMaxSizeNone()) { |
591 LayoutUnit maxH = computeLogicalHeightUsing(styleToUse.logicalMaxHeight(
), intrinsicContentHeight); | 591 LayoutUnit maxH = computeLogicalHeightUsing(styleToUse.logicalMaxHeight(
), intrinsicContentHeight); |
592 if (maxH != -1) | 592 if (maxH != -1) |
593 logicalHeight = std::min(logicalHeight, maxH); | 593 logicalHeight = std::min(logicalHeight, maxH); |
594 } | 594 } |
595 return std::max(logicalHeight, computeLogicalHeightUsing(styleToUse.logicalM
inHeight(), intrinsicContentHeight)); | 595 return std::max(logicalHeight, computeLogicalHeightUsing(styleToUse.logicalM
inHeight(), intrinsicContentHeight)); |
596 } | 596 } |
597 | 597 |
598 LayoutUnit LayoutBox::constrainContentBoxLogicalHeightByMinMax(LayoutUnit logica
lHeight, LayoutUnit intrinsicContentHeight) const | 598 LayoutUnit LayoutBox::constrainContentBoxLogicalHeightByMinMax(LayoutUnit logica
lHeight, LayoutUnit intrinsicContentHeight) const |
599 { | 599 { |
600 const LayoutStyle& styleToUse = styleRef(); | 600 const ComputedStyle& styleToUse = styleRef(); |
601 if (!styleToUse.logicalMaxHeight().isMaxSizeNone()) { | 601 if (!styleToUse.logicalMaxHeight().isMaxSizeNone()) { |
602 LayoutUnit maxH = computeContentLogicalHeight(styleToUse.logicalMaxHeigh
t(), intrinsicContentHeight); | 602 LayoutUnit maxH = computeContentLogicalHeight(styleToUse.logicalMaxHeigh
t(), intrinsicContentHeight); |
603 if (maxH != -1) | 603 if (maxH != -1) |
604 logicalHeight = std::min(logicalHeight, maxH); | 604 logicalHeight = std::min(logicalHeight, maxH); |
605 } | 605 } |
606 return std::max(logicalHeight, computeContentLogicalHeight(styleToUse.logica
lMinHeight(), intrinsicContentHeight)); | 606 return std::max(logicalHeight, computeContentLogicalHeight(styleToUse.logica
lMinHeight(), intrinsicContentHeight)); |
607 } | 607 } |
608 | 608 |
609 void LayoutBox::setLocationAndUpdateOverflowControlsIfNeeded(const LayoutPoint&
location) | 609 void LayoutBox::setLocationAndUpdateOverflowControlsIfNeeded(const LayoutPoint&
location) |
610 { | 610 { |
(...skipping 634 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1245 backgroundRect = contentBoxRect(); | 1245 backgroundRect = contentBoxRect(); |
1246 break; | 1246 break; |
1247 default: | 1247 default: |
1248 break; | 1248 break; |
1249 } | 1249 } |
1250 return backgroundRect.contains(localRect); | 1250 return backgroundRect.contains(localRect); |
1251 } | 1251 } |
1252 | 1252 |
1253 static bool isCandidateForOpaquenessTest(const LayoutBox& childBox) | 1253 static bool isCandidateForOpaquenessTest(const LayoutBox& childBox) |
1254 { | 1254 { |
1255 const LayoutStyle& childStyle = childBox.styleRef(); | 1255 const ComputedStyle& childStyle = childBox.styleRef(); |
1256 if (childStyle.position() != StaticPosition && childBox.containingBlock() !=
childBox.parent()) | 1256 if (childStyle.position() != StaticPosition && childBox.containingBlock() !=
childBox.parent()) |
1257 return false; | 1257 return false; |
1258 if (childStyle.visibility() != VISIBLE || childStyle.shapeOutside()) | 1258 if (childStyle.visibility() != VISIBLE || childStyle.shapeOutside()) |
1259 return false; | 1259 return false; |
1260 if (childBox.size().isZero()) | 1260 if (childBox.size().isZero()) |
1261 return false; | 1261 return false; |
1262 if (DeprecatedPaintLayer* childLayer = childBox.layer()) { | 1262 if (DeprecatedPaintLayer* childLayer = childBox.layer()) { |
1263 // FIXME: perhaps this could be less conservative? | 1263 // FIXME: perhaps this could be less conservative? |
1264 if (childLayer->compositingState() != NotComposited) | 1264 if (childLayer->compositingState() != NotComposited) |
1265 return false; | 1265 return false; |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1553 | 1553 |
1554 LayoutUnit LayoutBox::perpendicularContainingBlockLogicalHeight() const | 1554 LayoutUnit LayoutBox::perpendicularContainingBlockLogicalHeight() const |
1555 { | 1555 { |
1556 if (hasOverrideContainingBlockLogicalHeight()) | 1556 if (hasOverrideContainingBlockLogicalHeight()) |
1557 return overrideContainingBlockContentLogicalHeight(); | 1557 return overrideContainingBlockContentLogicalHeight(); |
1558 | 1558 |
1559 LayoutBlock* cb = containingBlock(); | 1559 LayoutBlock* cb = containingBlock(); |
1560 if (cb->hasOverrideHeight()) | 1560 if (cb->hasOverrideHeight()) |
1561 return cb->overrideLogicalContentHeight(); | 1561 return cb->overrideLogicalContentHeight(); |
1562 | 1562 |
1563 const LayoutStyle& containingBlockStyle = cb->styleRef(); | 1563 const ComputedStyle& containingBlockStyle = cb->styleRef(); |
1564 Length logicalHeightLength = containingBlockStyle.logicalHeight(); | 1564 Length logicalHeightLength = containingBlockStyle.logicalHeight(); |
1565 | 1565 |
1566 // FIXME: For now just support fixed heights. Eventually should support per
centage heights as well. | 1566 // FIXME: For now just support fixed heights. Eventually should support per
centage heights as well. |
1567 if (!logicalHeightLength.isFixed()) { | 1567 if (!logicalHeightLength.isFixed()) { |
1568 LayoutUnit fillFallbackExtent = containingBlockStyle.isHorizontalWriting
Mode() | 1568 LayoutUnit fillFallbackExtent = containingBlockStyle.isHorizontalWriting
Mode() |
1569 ? view()->frameView()->unscaledVisibleContentSize().height() | 1569 ? view()->frameView()->unscaledVisibleContentSize().height() |
1570 : view()->frameView()->unscaledVisibleContentSize().width(); | 1570 : view()->frameView()->unscaledVisibleContentSize().width(); |
1571 LayoutUnit fillAvailableExtent = containingBlock()->availableLogicalHeig
ht(ExcludeMarginBorderPadding); | 1571 LayoutUnit fillAvailableExtent = containingBlock()->availableLogicalHeig
ht(ExcludeMarginBorderPadding); |
1572 return std::min(fillAvailableExtent, fillFallbackExtent); | 1572 return std::min(fillAvailableExtent, fillFallbackExtent); |
1573 } | 1573 } |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1802 void LayoutBox::mapRectToPaintInvalidationBacking(const LayoutBoxModelObject* pa
intInvalidationContainer, LayoutRect& rect, const PaintInvalidationState* paintI
nvalidationState) const | 1802 void LayoutBox::mapRectToPaintInvalidationBacking(const LayoutBoxModelObject* pa
intInvalidationContainer, LayoutRect& rect, const PaintInvalidationState* paintI
nvalidationState) const |
1803 { | 1803 { |
1804 // The rect we compute at each step is shifted by our x/y offset in the pare
nt container's coordinate space. | 1804 // The rect we compute at each step is shifted by our x/y offset in the pare
nt container's coordinate space. |
1805 // Only when we cross a writing mode boundary will we have to possibly flipF
orWritingMode (to convert into a more appropriate | 1805 // Only when we cross a writing mode boundary will we have to possibly flipF
orWritingMode (to convert into a more appropriate |
1806 // offset corner for the enclosing container). This allows for a fully RL or
BT document to issue paint invalidations | 1806 // offset corner for the enclosing container). This allows for a fully RL or
BT document to issue paint invalidations |
1807 // properly even during layout, since the rect remains flipped all the way u
ntil the end. | 1807 // properly even during layout, since the rect remains flipped all the way u
ntil the end. |
1808 // | 1808 // |
1809 // LayoutView::computeRectForPaintInvalidation then converts the rect to phy
sical coordinates. We also convert to | 1809 // LayoutView::computeRectForPaintInvalidation then converts the rect to phy
sical coordinates. We also convert to |
1810 // physical when we hit a paintInvalidationContainer boundary. Therefore the
final rect returned is always in the | 1810 // physical when we hit a paintInvalidationContainer boundary. Therefore the
final rect returned is always in the |
1811 // physical coordinate space of the paintInvalidationContainer. | 1811 // physical coordinate space of the paintInvalidationContainer. |
1812 const LayoutStyle& styleToUse = styleRef(); | 1812 const ComputedStyle& styleToUse = styleRef(); |
1813 | 1813 |
1814 EPosition position = styleToUse.position(); | 1814 EPosition position = styleToUse.position(); |
1815 | 1815 |
1816 // We need to inflate the paint invalidation rect before we use paintInvalid
ationState, | 1816 // We need to inflate the paint invalidation rect before we use paintInvalid
ationState, |
1817 // else we would forget to inflate it for the current renderer. FIXME: If th
ese were | 1817 // else we would forget to inflate it for the current renderer. FIXME: If th
ese were |
1818 // included into the visual overflow for repaint, we wouldn't have this issu
e. | 1818 // included into the visual overflow for repaint, we wouldn't have this issu
e. |
1819 inflatePaintInvalidationRectForReflectionAndFilter(rect); | 1819 inflatePaintInvalidationRectForReflectionAndFilter(rect); |
1820 | 1820 |
1821 if (paintInvalidationState && paintInvalidationState->canMapToContainer(pain
tInvalidationContainer) && position != FixedPosition) { | 1821 if (paintInvalidationState && paintInvalidationState->canMapToContainer(pain
tInvalidationContainer) && position != FixedPosition) { |
1822 if (layer() && layer()->transform()) | 1822 if (layer() && layer()->transform()) |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1978 computedValues.m_extent = overrideLogicalContentWidth() + borderAndPaddi
ngLogicalWidth(); | 1978 computedValues.m_extent = overrideLogicalContentWidth() + borderAndPaddi
ngLogicalWidth(); |
1979 return; | 1979 return; |
1980 } | 1980 } |
1981 | 1981 |
1982 // FIXME: Account for writing-mode in flexible boxes. | 1982 // FIXME: Account for writing-mode in flexible boxes. |
1983 // https://bugs.webkit.org/show_bug.cgi?id=46418 | 1983 // https://bugs.webkit.org/show_bug.cgi?id=46418 |
1984 bool inVerticalBox = parent()->isDeprecatedFlexibleBox() && (parent()->style
()->boxOrient() == VERTICAL); | 1984 bool inVerticalBox = parent()->isDeprecatedFlexibleBox() && (parent()->style
()->boxOrient() == VERTICAL); |
1985 bool stretching = (parent()->style()->boxAlign() == BSTRETCH); | 1985 bool stretching = (parent()->style()->boxAlign() == BSTRETCH); |
1986 bool treatAsReplaced = shouldComputeSizeAsReplaced() && (!inVerticalBox || !
stretching); | 1986 bool treatAsReplaced = shouldComputeSizeAsReplaced() && (!inVerticalBox || !
stretching); |
1987 | 1987 |
1988 const LayoutStyle& styleToUse = styleRef(); | 1988 const ComputedStyle& styleToUse = styleRef(); |
1989 Length logicalWidthLength = treatAsReplaced ? Length(computeReplacedLogicalW
idth(), Fixed) : styleToUse.logicalWidth(); | 1989 Length logicalWidthLength = treatAsReplaced ? Length(computeReplacedLogicalW
idth(), Fixed) : styleToUse.logicalWidth(); |
1990 | 1990 |
1991 LayoutBlock* cb = containingBlock(); | 1991 LayoutBlock* cb = containingBlock(); |
1992 LayoutUnit containerLogicalWidth = std::max(LayoutUnit(), containingBlockLog
icalWidthForContent()); | 1992 LayoutUnit containerLogicalWidth = std::max(LayoutUnit(), containingBlockLog
icalWidthForContent()); |
1993 bool hasPerpendicularContainingBlock = cb->isHorizontalWritingMode() != isHo
rizontalWritingMode(); | 1993 bool hasPerpendicularContainingBlock = cb->isHorizontalWritingMode() != isHo
rizontalWritingMode(); |
1994 | 1994 |
1995 if (isInline() && !isInlineBlockOrInlineTable()) { | 1995 if (isInline() && !isInlineBlockOrInlineTable()) { |
1996 // just calculate margins | 1996 // just calculate margins |
1997 computedValues.m_margins.m_start = minimumValueForLength(styleToUse.marg
inStart(), containerLogicalWidth); | 1997 computedValues.m_margins.m_start = minimumValueForLength(styleToUse.marg
inStart(), containerLogicalWidth); |
1998 computedValues.m_margins.m_end = minimumValueForLength(styleToUse.margin
End(), containerLogicalWidth); | 1998 computedValues.m_margins.m_end = minimumValueForLength(styleToUse.margin
End(), containerLogicalWidth); |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2211 } | 2211 } |
2212 | 2212 |
2213 // CSS 2.1 (10.3.3): "If 'width' is not 'auto' and 'border-left-width' + 'pa
dding-left' + 'width' + 'padding-right' + 'border-right-width' | 2213 // CSS 2.1 (10.3.3): "If 'width' is not 'auto' and 'border-left-width' + 'pa
dding-left' + 'width' + 'padding-right' + 'border-right-width' |
2214 // (plus any of 'margin-left' or 'margin-right' that are not 'auto') is larg
er than the width of the containing block, then any 'auto' | 2214 // (plus any of 'margin-left' or 'margin-right' that are not 'auto') is larg
er than the width of the containing block, then any 'auto' |
2215 // values for 'margin-left' or 'margin-right' are, for the following rules,
treated as zero. | 2215 // values for 'margin-left' or 'margin-right' are, for the following rules,
treated as zero. |
2216 LayoutUnit marginBoxWidth = childWidth + (!style()->width().isAuto() ? margi
nStartWidth + marginEndWidth : LayoutUnit()); | 2216 LayoutUnit marginBoxWidth = childWidth + (!style()->width().isAuto() ? margi
nStartWidth + marginEndWidth : LayoutUnit()); |
2217 | 2217 |
2218 if (marginBoxWidth < availableWidth) { | 2218 if (marginBoxWidth < availableWidth) { |
2219 // CSS 2.1: "If both 'margin-left' and 'margin-right' are 'auto', their
used values are equal. This horizontally centers the element | 2219 // CSS 2.1: "If both 'margin-left' and 'margin-right' are 'auto', their
used values are equal. This horizontally centers the element |
2220 // with respect to the edges of the containing block." | 2220 // with respect to the edges of the containing block." |
2221 const LayoutStyle& containingBlockStyle = containingBlock->styleRef(); | 2221 const ComputedStyle& containingBlockStyle = containingBlock->styleRef(); |
2222 if ((marginStartLength.isAuto() && marginEndLength.isAuto()) | 2222 if ((marginStartLength.isAuto() && marginEndLength.isAuto()) |
2223 || (!marginStartLength.isAuto() && !marginEndLength.isAuto() && cont
ainingBlockStyle.textAlign() == WEBKIT_CENTER)) { | 2223 || (!marginStartLength.isAuto() && !marginEndLength.isAuto() && cont
ainingBlockStyle.textAlign() == WEBKIT_CENTER)) { |
2224 // Other browsers center the margin box for align=center elements so
we match them here. | 2224 // Other browsers center the margin box for align=center elements so
we match them here. |
2225 LayoutUnit centeredMarginBoxStart = std::max(LayoutUnit(), (availabl
eWidth - childWidth - marginStartWidth - marginEndWidth) / 2); | 2225 LayoutUnit centeredMarginBoxStart = std::max(LayoutUnit(), (availabl
eWidth - childWidth - marginStartWidth - marginEndWidth) / 2); |
2226 marginStart = centeredMarginBoxStart + marginStartWidth; | 2226 marginStart = centeredMarginBoxStart + marginStartWidth; |
2227 marginEnd = availableWidth - childWidth - marginStart + marginEndWid
th; | 2227 marginEnd = availableWidth - childWidth - marginStart + marginEndWid
th; |
2228 return; | 2228 return; |
2229 } | 2229 } |
2230 | 2230 |
2231 // Adjust margins for the align attribute | 2231 // Adjust margins for the align attribute |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2446 LayoutUnit rootMarginBorderPaddingHeight = 0; | 2446 LayoutUnit rootMarginBorderPaddingHeight = 0; |
2447 while (!cb->isLayoutView() && skipContainingBlockForPercentHeightCalculation
(cb)) { | 2447 while (!cb->isLayoutView() && skipContainingBlockForPercentHeightCalculation
(cb)) { |
2448 if (cb->isBody() || cb->isDocumentElement()) | 2448 if (cb->isBody() || cb->isDocumentElement()) |
2449 rootMarginBorderPaddingHeight += cb->marginBefore() + cb->marginAfte
r() + cb->borderAndPaddingLogicalHeight(); | 2449 rootMarginBorderPaddingHeight += cb->marginBefore() + cb->marginAfte
r() + cb->borderAndPaddingLogicalHeight(); |
2450 skippedAutoHeightContainingBlock = true; | 2450 skippedAutoHeightContainingBlock = true; |
2451 containingBlockChild = cb; | 2451 containingBlockChild = cb; |
2452 cb = cb->containingBlock(); | 2452 cb = cb->containingBlock(); |
2453 } | 2453 } |
2454 cb->addPercentHeightDescendant(const_cast<LayoutBox*>(this)); | 2454 cb->addPercentHeightDescendant(const_cast<LayoutBox*>(this)); |
2455 | 2455 |
2456 const LayoutStyle& cbstyle = cb->styleRef(); | 2456 const ComputedStyle& cbstyle = cb->styleRef(); |
2457 | 2457 |
2458 // A positioned element that specified both top/bottom or that specifies hei
ght should be treated as though it has a height | 2458 // A positioned element that specified both top/bottom or that specifies hei
ght should be treated as though it has a height |
2459 // explicitly specified that can be used for any percentage computations. | 2459 // explicitly specified that can be used for any percentage computations. |
2460 bool isOutOfFlowPositionedWithSpecifiedHeight = cb->isOutOfFlowPositioned()
&& (!cbstyle.logicalHeight().isAuto() || (!cbstyle.logicalTop().isAuto() && !cbs
tyle.logicalBottom().isAuto())); | 2460 bool isOutOfFlowPositionedWithSpecifiedHeight = cb->isOutOfFlowPositioned()
&& (!cbstyle.logicalHeight().isAuto() || (!cbstyle.logicalTop().isAuto() && !cbs
tyle.logicalBottom().isAuto())); |
2461 | 2461 |
2462 bool includeBorderPadding = isTable(); | 2462 bool includeBorderPadding = isTable(); |
2463 | 2463 |
2464 if (isHorizontalWritingMode() != cb->isHorizontalWritingMode()) { | 2464 if (isHorizontalWritingMode() != cb->isHorizontalWritingMode()) { |
2465 availableHeight = containingBlockChild->containingBlockLogicalWidthForCo
ntent(); | 2465 availableHeight = containingBlockChild->containingBlockLogicalWidthForCo
ntent(); |
2466 } else if (hasOverrideContainingBlockLogicalHeight()) { | 2466 } else if (hasOverrideContainingBlockLogicalHeight()) { |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2588 | 2588 |
2589 LayoutUnit LayoutBox::computeReplacedLogicalHeight() const | 2589 LayoutUnit LayoutBox::computeReplacedLogicalHeight() const |
2590 { | 2590 { |
2591 return computeReplacedLogicalHeightRespectingMinMaxHeight(computeReplacedLog
icalHeightUsing(style()->logicalHeight())); | 2591 return computeReplacedLogicalHeightRespectingMinMaxHeight(computeReplacedLog
icalHeightUsing(style()->logicalHeight())); |
2592 } | 2592 } |
2593 | 2593 |
2594 bool LayoutBox::logicalHeightComputesAsNone(SizeType sizeType) const | 2594 bool LayoutBox::logicalHeightComputesAsNone(SizeType sizeType) const |
2595 { | 2595 { |
2596 ASSERT(sizeType == MinSize || sizeType == MaxSize); | 2596 ASSERT(sizeType == MinSize || sizeType == MaxSize); |
2597 Length logicalHeight = sizeType == MinSize ? style()->logicalMinHeight() : s
tyle()->logicalMaxHeight(); | 2597 Length logicalHeight = sizeType == MinSize ? style()->logicalMinHeight() : s
tyle()->logicalMaxHeight(); |
2598 Length initialLogicalHeight = sizeType == MinSize ? LayoutStyle::initialMinS
ize() : LayoutStyle::initialMaxSize(); | 2598 Length initialLogicalHeight = sizeType == MinSize ? ComputedStyle::initialMi
nSize() : ComputedStyle::initialMaxSize(); |
2599 | 2599 |
2600 if (logicalHeight == initialLogicalHeight) | 2600 if (logicalHeight == initialLogicalHeight) |
2601 return true; | 2601 return true; |
2602 | 2602 |
2603 if (LayoutBlock* cb = containingBlockForAutoHeightDetection(logicalHeight)) | 2603 if (LayoutBlock* cb = containingBlockForAutoHeightDetection(logicalHeight)) |
2604 return cb->hasAutoHeightOrContainingBlockWithAutoHeight(); | 2604 return cb->hasAutoHeightOrContainingBlockWithAutoHeight(); |
2605 return false; | 2605 return false; |
2606 } | 2606 } |
2607 | 2607 |
2608 LayoutUnit LayoutBox::computeReplacedLogicalHeightRespectingMinMaxHeight(LayoutU
nit logicalHeight) const | 2608 LayoutUnit LayoutBox::computeReplacedLogicalHeightRespectingMinMaxHeight(LayoutU
nit logicalHeight) const |
(...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3212 // <http://www.w3.org/TR/2005/WD-CSS21-20050613/visudet.html#abs-non-replace
d-height> | 3212 // <http://www.w3.org/TR/2005/WD-CSS21-20050613/visudet.html#abs-non-replace
d-height> |
3213 // (block-style-comments in this function and in computePositionedLogicalHei
ghtUsing() | 3213 // (block-style-comments in this function and in computePositionedLogicalHei
ghtUsing() |
3214 // correspond to text from the spec) | 3214 // correspond to text from the spec) |
3215 | 3215 |
3216 | 3216 |
3217 // We don't use containingBlock(), since we may be positioned by an enclosin
g relpositioned inline. | 3217 // We don't use containingBlock(), since we may be positioned by an enclosin
g relpositioned inline. |
3218 const LayoutBoxModelObject* containerBlock = toLayoutBoxModelObject(containe
r()); | 3218 const LayoutBoxModelObject* containerBlock = toLayoutBoxModelObject(containe
r()); |
3219 | 3219 |
3220 const LayoutUnit containerLogicalHeight = containingBlockLogicalHeightForPos
itioned(containerBlock); | 3220 const LayoutUnit containerLogicalHeight = containingBlockLogicalHeightForPos
itioned(containerBlock); |
3221 | 3221 |
3222 const LayoutStyle& styleToUse = styleRef(); | 3222 const ComputedStyle& styleToUse = styleRef(); |
3223 const LayoutUnit bordersPlusPadding = borderAndPaddingLogicalHeight(); | 3223 const LayoutUnit bordersPlusPadding = borderAndPaddingLogicalHeight(); |
3224 const Length marginBefore = styleToUse.marginBefore(); | 3224 const Length marginBefore = styleToUse.marginBefore(); |
3225 const Length marginAfter = styleToUse.marginAfter(); | 3225 const Length marginAfter = styleToUse.marginAfter(); |
3226 Length logicalTopLength = styleToUse.logicalTop(); | 3226 Length logicalTopLength = styleToUse.logicalTop(); |
3227 Length logicalBottomLength = styleToUse.logicalBottom(); | 3227 Length logicalBottomLength = styleToUse.logicalBottom(); |
3228 | 3228 |
3229 /*--------------------------------------------------------------------------
-*\ | 3229 /*--------------------------------------------------------------------------
-*\ |
3230 * For the purposes of this section and the next, the term "static position" | 3230 * For the purposes of this section and the next, the term "static position" |
3231 * (of an element) refers, roughly, to the position an element would have ha
d | 3231 * (of an element) refers, roughly, to the position an element would have ha
d |
3232 * in the normal flow. More precisely, the static position for 'top' is the | 3232 * in the normal flow. More precisely, the static position for 'top' is the |
(...skipping 1124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4357 const LayoutObject* curr = this; | 4357 const LayoutObject* curr = this; |
4358 while (curr) { | 4358 while (curr) { |
4359 DeprecatedPaintLayer* layer = curr->hasLayer() && curr->isBox() ? toLayo
utBox(curr)->layer() : 0; | 4359 DeprecatedPaintLayer* layer = curr->hasLayer() && curr->isBox() ? toLayo
utBox(curr)->layer() : 0; |
4360 if (layer && layer->isSelfPaintingLayer()) | 4360 if (layer && layer->isSelfPaintingLayer()) |
4361 return layer; | 4361 return layer; |
4362 curr = curr->parent(); | 4362 curr = curr->parent(); |
4363 } | 4363 } |
4364 return 0; | 4364 return 0; |
4365 } | 4365 } |
4366 | 4366 |
4367 LayoutRect LayoutBox::logicalVisualOverflowRectForPropagation(const LayoutStyle&
parentStyle) const | 4367 LayoutRect LayoutBox::logicalVisualOverflowRectForPropagation(const ComputedStyl
e& parentStyle) const |
4368 { | 4368 { |
4369 LayoutRect rect = visualOverflowRectForPropagation(parentStyle); | 4369 LayoutRect rect = visualOverflowRectForPropagation(parentStyle); |
4370 if (!parentStyle.isHorizontalWritingMode()) | 4370 if (!parentStyle.isHorizontalWritingMode()) |
4371 return rect.transposedRect(); | 4371 return rect.transposedRect(); |
4372 return rect; | 4372 return rect; |
4373 } | 4373 } |
4374 | 4374 |
4375 LayoutRect LayoutBox::visualOverflowRectForPropagation(const LayoutStyle& parent
Style) const | 4375 LayoutRect LayoutBox::visualOverflowRectForPropagation(const ComputedStyle& pare
ntStyle) const |
4376 { | 4376 { |
4377 // If the writing modes of the child and parent match, then we don't have to | 4377 // If the writing modes of the child and parent match, then we don't have to |
4378 // do anything fancy. Just return the result. | 4378 // do anything fancy. Just return the result. |
4379 LayoutRect rect = visualOverflowRect(); | 4379 LayoutRect rect = visualOverflowRect(); |
4380 if (parentStyle.writingMode() == style()->writingMode()) | 4380 if (parentStyle.writingMode() == style()->writingMode()) |
4381 return rect; | 4381 return rect; |
4382 | 4382 |
4383 // We are putting ourselves into our parent's coordinate space. If there is
a flipped block mismatch | 4383 // We are putting ourselves into our parent's coordinate space. If there is
a flipped block mismatch |
4384 // in a particular axis, then we have to flip the rect along that axis. | 4384 // in a particular axis, then we have to flip the rect along that axis. |
4385 if (style()->writingMode() == RightToLeftWritingMode || parentStyle.writingM
ode() == RightToLeftWritingMode) | 4385 if (style()->writingMode() == RightToLeftWritingMode || parentStyle.writingM
ode() == RightToLeftWritingMode) |
4386 rect.setX(size().width() - rect.maxX()); | 4386 rect.setX(size().width() - rect.maxX()); |
4387 else if (style()->writingMode() == BottomToTopWritingMode || parentStyle.wri
tingMode() == BottomToTopWritingMode) | 4387 else if (style()->writingMode() == BottomToTopWritingMode || parentStyle.wri
tingMode() == BottomToTopWritingMode) |
4388 rect.setY(size().height() - rect.maxY()); | 4388 rect.setY(size().height() - rect.maxY()); |
4389 | 4389 |
4390 return rect; | 4390 return rect; |
4391 } | 4391 } |
4392 | 4392 |
4393 LayoutRect LayoutBox::logicalLayoutOverflowRectForPropagation(const LayoutStyle&
parentStyle) const | 4393 LayoutRect LayoutBox::logicalLayoutOverflowRectForPropagation(const ComputedStyl
e& parentStyle) const |
4394 { | 4394 { |
4395 LayoutRect rect = layoutOverflowRectForPropagation(parentStyle); | 4395 LayoutRect rect = layoutOverflowRectForPropagation(parentStyle); |
4396 if (!parentStyle.isHorizontalWritingMode()) | 4396 if (!parentStyle.isHorizontalWritingMode()) |
4397 return rect.transposedRect(); | 4397 return rect.transposedRect(); |
4398 return rect; | 4398 return rect; |
4399 } | 4399 } |
4400 | 4400 |
4401 LayoutRect LayoutBox::layoutOverflowRectForPropagation(const LayoutStyle& parent
Style) const | 4401 LayoutRect LayoutBox::layoutOverflowRectForPropagation(const ComputedStyle& pare
ntStyle) const |
4402 { | 4402 { |
4403 // Only propagate interior layout overflow if we don't clip it. | 4403 // Only propagate interior layout overflow if we don't clip it. |
4404 LayoutRect rect = borderBoxRect(); | 4404 LayoutRect rect = borderBoxRect(); |
4405 // We want to include the margin, but only when it adds height. Quirky margi
ns don't contribute height | 4405 // We want to include the margin, but only when it adds height. Quirky margi
ns don't contribute height |
4406 // nor do the margins of self-collapsing blocks. | 4406 // nor do the margins of self-collapsing blocks. |
4407 if (!styleRef().hasMarginAfterQuirk() && !isSelfCollapsingBlock()) | 4407 if (!styleRef().hasMarginAfterQuirk() && !isSelfCollapsingBlock()) |
4408 rect.expand(isHorizontalWritingMode() ? LayoutSize(LayoutUnit(), marginA
fter()) : LayoutSize(marginAfter(), LayoutUnit())); | 4408 rect.expand(isHorizontalWritingMode() ? LayoutSize(LayoutUnit(), marginA
fter()) : LayoutSize(marginAfter(), LayoutUnit())); |
4409 | 4409 |
4410 if (!hasOverflowClip()) | 4410 if (!hasOverflowClip()) |
4411 rect.unite(layoutOverflowRect()); | 4411 rect.unite(layoutOverflowRect()); |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4645 computedValues.m_margins.m_end = marginEnd(); | 4645 computedValues.m_margins.m_end = marginEnd(); |
4646 | 4646 |
4647 setLogicalTop(oldLogicalTop); | 4647 setLogicalTop(oldLogicalTop); |
4648 setLogicalWidth(oldLogicalWidth); | 4648 setLogicalWidth(oldLogicalWidth); |
4649 setLogicalLeft(oldLogicalLeft); | 4649 setLogicalLeft(oldLogicalLeft); |
4650 setMarginLeft(oldMarginLeft); | 4650 setMarginLeft(oldMarginLeft); |
4651 setMarginRight(oldMarginRight); | 4651 setMarginRight(oldMarginRight); |
4652 } | 4652 } |
4653 | 4653 |
4654 } // namespace blink | 4654 } // namespace blink |
OLD | NEW |