Chromium Code Reviews| Index: Source/core/layout/LayoutView.cpp |
| diff --git a/Source/core/layout/LayoutView.cpp b/Source/core/layout/LayoutView.cpp |
| index f100481a8ab8727510cb2745c1dc77de5c6c09f4..9dd4ec39aeb0675d2c7a01af2b9b1ad176fd1327 100644 |
| --- a/Source/core/layout/LayoutView.cpp |
| +++ b/Source/core/layout/LayoutView.cpp |
| @@ -195,16 +195,14 @@ bool LayoutView::shouldDoFullPaintInvalidationForNextLayout() const |
| return true; |
| if (size().height() != viewLogicalHeightForBoxSizing()) { |
| - if (LayoutObject* backgroundLayoutObject = this->backgroundLayoutObject()) { |
| - // When background-attachment is 'fixed', we treat the viewport (instead of the 'root' |
| - // i.e. html or body) as the background positioning area, and we should full paint invalidation |
| - // viewport resize if the background image is not composited and needs full paint invalidation on |
| - // background positioning area resize. |
| - if (!m_compositor || !m_compositor->needsFixedRootBackgroundLayer(layer())) { |
| - if (backgroundLayoutObject->style()->hasFixedBackgroundImage() |
| - && mustInvalidateFillLayersPaintOnHeightChange(backgroundLayoutObject->style()->backgroundLayers())) |
| - return true; |
| - } |
| + // When background-attachment is 'fixed', we treat the viewport (instead of the 'root' |
| + // i.e. html or body) as the background positioning area, and we should full paint invalidation |
| + // viewport resize if the background image is not composited and needs full paint invalidation on |
| + // background positioning area resize. |
| + if (!m_compositor || !m_compositor->needsFixedRootBackgroundLayer(layer())) { |
| + if (style()->hasFixedBackgroundImage() |
| + && mustInvalidateFillLayersPaintOnHeightChange(style()->backgroundLayers())) |
| + return true; |
| } |
| } |
| @@ -221,8 +219,6 @@ void LayoutView::layout() |
| SubtreeLayoutScope layoutScope(*this); |
| - LayoutRect oldLayoutOverflowRect = layoutOverflowRect(); |
| - |
| // Use calcWidth/Height to get the new width/height, since this will take the full page zoom factor into account. |
| bool relayoutChildren = !shouldUsePrintingLayout() && (!m_frameView |
| || logicalWidth() != viewLogicalWidthForBoxSizing() |
| @@ -254,22 +250,71 @@ void LayoutView::layout() |
| layoutContent(); |
| - if (RuntimeEnabledFeatures::slimmingPaintEnabled() && layoutOverflowRect() != oldLayoutOverflowRect) { |
| - // The document element paints the viewport background, so we need to invalidate it when |
| - // layout overflow changes. |
| - // FIXME: Improve viewport background styling/invalidation/painting. crbug.com/475115 |
| - if (Element* documentElement = document().documentElement()) { |
| - if (LayoutObject* rootObject = documentElement->layoutObject()) |
| - rootObject->setShouldDoFullPaintInvalidation(); |
| - } |
| - } |
| - |
| #if ENABLE(ASSERT) |
| checkLayoutState(); |
| #endif |
| clearNeedsLayout(); |
| } |
| +void LayoutView::styleDidChange(StyleDifference diff, const ComputedStyle* oldStyle) |
| +{ |
| + const ComputedStyle& newStyle = styleRef(); |
| + |
| + if (oldStyle && oldStyle->hasEntirelyFixedBackground() != newStyle.hasEntirelyFixedBackground()) |
| + compositor()->setNeedsUpdateFixedBackground(); |
| + |
| + LayoutBlockFlow::styleDidChange(diff, oldStyle); |
| +} |
| + |
| +void LayoutView::getBackgroundPositioningFromDocumentElement(BackgroundPositioning& position) const |
| +{ |
| + const LayoutObject* rootObject = document().documentElement() ? document().documentElement()->layoutObject() : nullptr; |
| + if (!rootObject || !rootObject->isBox()) |
| + return; |
| + |
| + const LayoutBox& rootBox = toLayoutBox(*rootObject); |
| + position.borderBoxSize = rootBox.size(); |
| + position.paddingBoxRect = rootBox.paddingBoxRect(); |
| + position.contentBoxRect = rootBox.contentBoxRect(); |
| + if (rootBox.hasLayer()) { |
| + const DeprecatedPaintLayer& rootLayer = *rootBox.layer(); |
| + LayoutPoint offset; |
| + rootLayer.convertToLayerCoords(nullptr, offset); |
| + position.transform.translate(offset.x(), offset.y()); |
| + position.transform.multiply(rootLayer.currentTransform()); |
| + } |
| +} |
| + |
| +PaintInvalidationReason LayoutView::paintInvalidationReason(const LayoutBoxModelObject& paintInvalidationContainer, |
| + const LayoutRect& oldBounds, const LayoutPoint& oldLocation, |
| + const LayoutRect& newBounds, const LayoutPoint& newLocation) const |
| +{ |
| + const BackgroundPositioning& oldPosition = m_previousRootBackgroundPositioning; |
| + BackgroundPositioning newPosition; |
| + getBackgroundPositioningFromDocumentElement(newPosition); |
| + |
| + if (oldPosition.transform != newPosition.transform) |
| + return PaintInvalidationLocationChange; |
| + |
| + const FillLayer& backgroundLayers = style()->backgroundLayers(); |
| + if (mustInvalidateFillLayersPaintOnWidthChange(backgroundLayers) || mustInvalidateFillLayersPaintOnHeightChange(backgroundLayers)) { |
| + if (oldPosition.borderBoxSize != newPosition.borderBoxSize |
| + || oldPosition.paddingBoxRect != newPosition.paddingBoxRect |
| + || oldPosition.contentBoxRect != newPosition.contentBoxRect) { |
| + return PaintInvalidationBorderBoxChange; |
| + } |
| + } |
| + |
| + return LayoutBlockFlow::paintInvalidationReason(paintInvalidationContainer, oldBounds, oldLocation, newBounds, newLocation); |
| +} |
| + |
| +PaintInvalidationReason LayoutView::invalidatePaintIfNeeded(PaintInvalidationState& paintInvalidationState, const LayoutBoxModelObject& newPaintInvalidationContainer) |
| +{ |
| + getBackgroundPositioningFromDocumentElement(m_previousRootBackgroundPositioning); |
|
Xianzhu
2015/06/05 05:08:28
This seems incorrect. m_previousRootBackgroundPosi
|
| + |
| + return LayoutBlockFlow::invalidatePaintIfNeeded(paintInvalidationState, newPaintInvalidationContainer); |
| +} |
| + |
| void LayoutView::mapLocalToContainer(const LayoutBoxModelObject* paintInvalidationContainer, TransformState& transformState, MapCoordinatesFlags mode, bool* wasFixed, const PaintInvalidationState* paintInvalidationState) const |
| { |
| ASSERT_UNUSED(wasFixed, !wasFixed || *wasFixed == static_cast<bool>(mode & IsFixed)); |
| @@ -844,18 +889,7 @@ IntRect LayoutView::unscaledDocumentRect() const |
| bool LayoutView::rootBackgroundIsEntirelyFixed() const |
| { |
| - if (LayoutObject* backgroundLayoutObject = this->backgroundLayoutObject()) |
| - return backgroundLayoutObject->style()->hasEntirelyFixedBackground(); |
| - return false; |
| -} |
| - |
| -LayoutObject* LayoutView::backgroundLayoutObject() const |
| -{ |
| - if (Element* documentElement = document().documentElement()) { |
| - if (LayoutObject* rootObject = documentElement->layoutObject()) |
| - return rootObject->layoutObjectForRootBackground(); |
| - } |
| - return 0; |
| + return style()->hasEntirelyFixedBackground(); |
| } |
| LayoutRect LayoutView::backgroundRect(LayoutBox* backgroundLayoutObject) const |