Title: [151623] trunk
Revision
151623
Author
[email protected]
Date
2013-06-16 10:24:40 -0700 (Sun, 16 Jun 2013)

Log Message

Source/WebCore: Painting of fixed background images is wrong in composited layers
https://bugs.webkit.org/show_bug.cgi?id=65793

Reviewed by Sam Weinig.

The code that computed background image geometry for background-attachment:fixed
images was unaware of compositing, so often painting the image at the wrong location.

Fix by having RenderBoxModelObject::calculateBackgroundImageGeometry() do the correct
math for fixed backgrounds in composited layer by offsetting the viewport rect by
the paint container's absolute position.

Tests: compositing/backgrounds/fixed-background-on-descendant.html
       compositing/backgrounds/fixed-backgrounds.html

* rendering/RenderBox.cpp:
(WebCore::RenderBox::getBackgroundPaintedExtent): Now returns a bool indicating
whether it is returning a reliable extent rect. It can return false in the case where
a background is fixed, since computing the correct extent would require finding
the appropriate composited ancestor to pass to calculateBackgroundImageGeometry().
This is OK since this function is used for "background opaque" optimizations.
(WebCore::RenderBox::computeBackgroundIsKnownToBeObscured): If getBackgroundPaintedExtent()
returns false, return false.
(WebCore::RenderBox::maskClipRect): We removed mask-attachment, so we never need to
compute the composited ancestor here and can pass null.
(WebCore::RenderBox::repaintLayerRectsForImage): Unwrap a comment.
If the changed image is related to a fixed background, geometry.hasNonLocalGeometry()
will be true. In that cause, just repaint the entire renderer rather than groveling
around for a composited ancestor.
* rendering/RenderBox.h: Changed name and signature of backgroundPaintedExtent.
* rendering/RenderBoxModelObject.cpp:
(WebCore::RenderBoxModelObject::paintFillLayerExtended): calculateBackgroundImageGeometry()
now needs to know the painting container.
(WebCore::RenderBoxModelObject::calculateBackgroundImageGeometry): Now takes a painting
container, that is required to correctly compute the viewport-relative offset for fixed
backgrounds. geometry.setHasNonLocalGeometry() is set for fixed backgrounds to indicate
to callers that, if they didn't pass a paint container, the destRect is not accurate.
The main bug fix is also here: we move the viewportRect by the absolute location of
paint container, which is equivalent to the composited layer offset.
(WebCore::RenderBoxModelObject::getGeometryForBackgroundImage): calculateBackgroundImageGeometry()
takes a paint container.
* rendering/RenderBoxModelObject.h:
(WebCore::RenderBoxModelObject::BackgroundImageGeometry::BackgroundImageGeometry):
(WebCore::RenderBoxModelObject::BackgroundImageGeometry::setHasNonLocalGeometry):
(WebCore::RenderBoxModelObject::BackgroundImageGeometry::hasNonLocalGeometry):
* rendering/RenderImage.cpp:
(WebCore::RenderImage::computeBackgroundIsKnownToBeObscured): If getBackgroundPaintedExtent()
can't cheaply give an accurate answer, return false.
* rendering/RenderLayerBacking.cpp:
(WebCore::RenderLayerBacking::updateDirectlyCompositedBackgroundImage): Pass the paint container,
which is our own renderer.

LayoutTests: Fixed background images behave strangely with webkit transitions
https://bugs.webkit.org/show_bug.cgi?id=65793

Reviewed by Sam Weinig.

Ref tests that compare fixed background rendering after a scroll, with and
without compositing, with a couple of layer configurations.

* compositing/backgrounds/fixed-background-on-descendant-expected.html: Added.
* compositing/backgrounds/fixed-background-on-descendant.html: Added.
* compositing/backgrounds/fixed-backgrounds-expected.html: Added.
* compositing/backgrounds/fixed-backgrounds.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (151622 => 151623)


--- trunk/LayoutTests/ChangeLog	2013-06-16 16:57:14 UTC (rev 151622)
+++ trunk/LayoutTests/ChangeLog	2013-06-16 17:24:40 UTC (rev 151623)
@@ -1,5 +1,20 @@
 2013-06-15  Simon Fraser  <[email protected]>
 
+        Fixed background images behave strangely with webkit transitions
+        https://bugs.webkit.org/show_bug.cgi?id=65793
+
+        Reviewed by Sam Weinig.
+        
+        Ref tests that compare fixed background rendering after a scroll, with and
+        without compositing, with a couple of layer configurations.
+
+        * compositing/backgrounds/fixed-background-on-descendant-expected.html: Added.
+        * compositing/backgrounds/fixed-background-on-descendant.html: Added.
+        * compositing/backgrounds/fixed-backgrounds-expected.html: Added.
+        * compositing/backgrounds/fixed-backgrounds.html: Added.
+
+2013-06-15  Simon Fraser  <[email protected]>
+
         webkit-backface-visibility on a parent element stops background-position from updating
         https://bugs.webkit.org/show_bug.cgi?id=116319
 

Added: trunk/LayoutTests/compositing/backgrounds/fixed-background-on-descendant-expected.html (0 => 151623)


--- trunk/LayoutTests/compositing/backgrounds/fixed-background-on-descendant-expected.html	                        (rev 0)
+++ trunk/LayoutTests/compositing/backgrounds/fixed-background-on-descendant-expected.html	2013-06-16 17:24:40 UTC (rev 151623)
@@ -0,0 +1,56 @@
+<!DOCTYPE html>
+
+<html>
+<head>
+    <style>
+        body {
+            height: 2000px;
+            width: 2000px;
+            overflow: hidden;
+        }
+        
+        .box {
+            width: 300px;
+            height: 300px;
+            margin: 20px;
+            position: relative;
+        }
+        
+        body > .box {
+            border: 1px solid black;
+            float: left;
+        }
+        .child {
+            position: absolute;
+            top: 50px;
+            left: 50px;
+            height: 200px;
+            width: 200px;
+            margin-left: 10px;
+            background-image: url('../resources/alpha-blocks.png');
+            background-size: 500px 300px;
+            background-repeat: no-repeat;
+            background-attachment: fixed;
+            border: 4px solid gray;
+        }
+    </style>
+    <script>
+        function doTest()
+        {
+            window.scrollTo(35, 45);
+        }
+        window.addEventListener('load', doTest, false);
+    </script>
+</head>
+<body>
+
+<div class="box">
+    <div class="child box"></div>
+</div>
+
+<div class="box">
+    <div class="child box"></div>
+</div>
+
+</body>
+</html>

Added: trunk/LayoutTests/compositing/backgrounds/fixed-background-on-descendant.html (0 => 151623)


--- trunk/LayoutTests/compositing/backgrounds/fixed-background-on-descendant.html	                        (rev 0)
+++ trunk/LayoutTests/compositing/backgrounds/fixed-background-on-descendant.html	2013-06-16 17:24:40 UTC (rev 151623)
@@ -0,0 +1,60 @@
+<!DOCTYPE html>
+
+<html>
+<head>
+    <style>
+        body {
+            height: 2000px;
+            width: 2000px;
+            overflow: hidden;
+        }
+        
+        .box {
+            width: 300px;
+            height: 300px;
+            margin: 20px;
+            position: relative;
+        }
+        
+        body > .box {
+            border: 1px solid black;
+            float: left;
+        }
+        .child {
+            position: absolute;
+            top: 50px;
+            left: 50px;
+            height: 200px;
+            width: 200px;
+            margin-left: 10px;
+            background-image: url('../resources/alpha-blocks.png');
+            background-size: 500px 300px;
+            background-repeat: no-repeat;
+            background-attachment: fixed;
+            border: 4px solid gray;
+        }
+        
+        .composited {
+            -webkit-transform: translateZ(0);
+        }
+    </style>
+    <script>
+        function doTest()
+        {
+            window.scrollTo(35, 45);
+        }
+        window.addEventListener('load', doTest, false);
+    </script>
+</head>
+<body>
+
+<div class="composited box">
+    <div class="child box"></div>
+</div>
+
+<div class="composited box">
+    <div class="child box"></div>
+</div>
+
+</body>
+</html>

Added: trunk/LayoutTests/compositing/backgrounds/fixed-backgrounds-expected.html (0 => 151623)


--- trunk/LayoutTests/compositing/backgrounds/fixed-backgrounds-expected.html	                        (rev 0)
+++ trunk/LayoutTests/compositing/backgrounds/fixed-backgrounds-expected.html	2013-06-16 17:24:40 UTC (rev 151623)
@@ -0,0 +1,40 @@
+<!DOCTYPE html>
+
+<html>
+<head>
+    <style>
+        body {
+            height: 2000px;
+            width: 2000px;
+            overflow: hidden;
+        }
+        
+        .box {
+            height: 300px;
+            width: 300px;
+            margin: 20px;
+            margin-left: 10px;
+            background-image: url('../resources/alpha-blocks.png');
+            background-size: 500px 300px;
+            background-repeat: no-repeat;
+            background-attachment: fixed;
+            box-shadow: 0 0 10px black; /* inflates composited bounds */
+            border: 4px solid gray;
+            float: left;
+        }
+    </style>
+    <script>
+        function doTest()
+        {
+            window.scrollTo(35, 45);
+        }
+        window.addEventListener('load', doTest, false);
+    </script>
+</head>
+<body>
+
+<div class="box"></div>
+<div class="box"></div>
+
+</body>
+</html>

Added: trunk/LayoutTests/compositing/backgrounds/fixed-backgrounds.html (0 => 151623)


--- trunk/LayoutTests/compositing/backgrounds/fixed-backgrounds.html	                        (rev 0)
+++ trunk/LayoutTests/compositing/backgrounds/fixed-backgrounds.html	2013-06-16 17:24:40 UTC (rev 151623)
@@ -0,0 +1,45 @@
+<!DOCTYPE html>
+
+<html>
+<head>
+    <style>
+        body {
+            height: 2000px;
+            width: 2000px;
+            overflow: hidden;
+        }
+        
+        .box {
+            height: 300px;
+            width: 300px;
+            margin: 20px;
+            margin-left: 10px;
+            background-image: url('../resources/alpha-blocks.png');
+
+            background-size: 500px 300px;
+            background-repeat: no-repeat;
+            background-attachment: fixed;
+            box-shadow: 0 0 10px black; /* inflates composited bounds */
+            border: 4px solid gray;
+            float: left;
+        }
+        
+        .composited {
+            -webkit-transform: translateZ(0);
+        }
+    </style>
+    <script>
+        function doTest()
+        {
+            window.scrollTo(35, 45);
+        }
+        window.addEventListener('load', doTest, false);
+    </script>
+</head>
+<body>
+
+<div class="composited box"></div>
+<div class="composited box"></div>
+
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (151622 => 151623)


--- trunk/Source/WebCore/ChangeLog	2013-06-16 16:57:14 UTC (rev 151622)
+++ trunk/Source/WebCore/ChangeLog	2013-06-16 17:24:40 UTC (rev 151623)
@@ -1,5 +1,59 @@
 2013-06-15  Simon Fraser  <[email protected]>
 
+        Painting of fixed background images is wrong in composited layers
+        https://bugs.webkit.org/show_bug.cgi?id=65793
+
+        Reviewed by Sam Weinig.
+        
+        The code that computed background image geometry for background-attachment:fixed
+        images was unaware of compositing, so often painting the image at the wrong location.
+        
+        Fix by having RenderBoxModelObject::calculateBackgroundImageGeometry() do the correct
+        math for fixed backgrounds in composited layer by offsetting the viewport rect by
+        the paint container's absolute position.
+
+        Tests: compositing/backgrounds/fixed-background-on-descendant.html
+               compositing/backgrounds/fixed-backgrounds.html
+
+        * rendering/RenderBox.cpp:
+        (WebCore::RenderBox::getBackgroundPaintedExtent): Now returns a bool indicating
+        whether it is returning a reliable extent rect. It can return false in the case where
+        a background is fixed, since computing the correct extent would require finding
+        the appropriate composited ancestor to pass to calculateBackgroundImageGeometry().
+        This is OK since this function is used for "background opaque" optimizations.
+        (WebCore::RenderBox::computeBackgroundIsKnownToBeObscured): If getBackgroundPaintedExtent()
+        returns false, return false.
+        (WebCore::RenderBox::maskClipRect): We removed mask-attachment, so we never need to
+        compute the composited ancestor here and can pass null.
+        (WebCore::RenderBox::repaintLayerRectsForImage): Unwrap a comment.
+        If the changed image is related to a fixed background, geometry.hasNonLocalGeometry()
+        will be true. In that cause, just repaint the entire renderer rather than groveling
+        around for a composited ancestor.
+        * rendering/RenderBox.h: Changed name and signature of backgroundPaintedExtent.
+        * rendering/RenderBoxModelObject.cpp:
+        (WebCore::RenderBoxModelObject::paintFillLayerExtended): calculateBackgroundImageGeometry()
+        now needs to know the painting container.
+        (WebCore::RenderBoxModelObject::calculateBackgroundImageGeometry): Now takes a painting
+        container, that is required to correctly compute the viewport-relative offset for fixed
+        backgrounds. geometry.setHasNonLocalGeometry() is set for fixed backgrounds to indicate
+        to callers that, if they didn't pass a paint container, the destRect is not accurate.
+        The main bug fix is also here: we move the viewportRect by the absolute location of
+        paint container, which is equivalent to the composited layer offset.
+        (WebCore::RenderBoxModelObject::getGeometryForBackgroundImage): calculateBackgroundImageGeometry()
+        takes a paint container.
+        * rendering/RenderBoxModelObject.h:
+        (WebCore::RenderBoxModelObject::BackgroundImageGeometry::BackgroundImageGeometry):
+        (WebCore::RenderBoxModelObject::BackgroundImageGeometry::setHasNonLocalGeometry):
+        (WebCore::RenderBoxModelObject::BackgroundImageGeometry::hasNonLocalGeometry):
+        * rendering/RenderImage.cpp:
+        (WebCore::RenderImage::computeBackgroundIsKnownToBeObscured): If getBackgroundPaintedExtent()
+        can't cheaply give an accurate answer, return false.
+        * rendering/RenderLayerBacking.cpp:
+        (WebCore::RenderLayerBacking::updateDirectlyCompositedBackgroundImage): Pass the paint container,
+        which is our own renderer.
+
+2013-06-15  Simon Fraser  <[email protected]>
+
         webkit-backface-visibility on a parent element stops background-position from updating
         https://bugs.webkit.org/show_bug.cgi?id=116319
 

Modified: trunk/Source/WebCore/rendering/RenderBox.cpp (151622 => 151623)


--- trunk/Source/WebCore/rendering/RenderBox.cpp	2013-06-16 16:57:14 UTC (rev 151622)
+++ trunk/Source/WebCore/rendering/RenderBox.cpp	2013-06-16 17:24:40 UTC (rev 151623)
@@ -1140,19 +1140,26 @@
     paintFillLayers(paintInfo, style()->visitedDependentColor(CSSPropertyBackgroundColor), style()->backgroundLayers(), paintRect, bleedAvoidance);
 }
 
-LayoutRect RenderBox::backgroundPaintedExtent() const
+bool RenderBox::getBackgroundPaintedExtent(LayoutRect& paintedExtent) const
 {
     ASSERT(hasBackground());
     LayoutRect backgroundRect = pixelSnappedIntRect(borderBoxRect());
 
     Color backgroundColor = style()->visitedDependentColor(CSSPropertyBackgroundColor);
-    if (backgroundColor.isValid() && backgroundColor.alpha())
-        return backgroundRect;
-    if (!style()->backgroundLayers()->image() || style()->backgroundLayers()->next())
-        return backgroundRect;
+    if (backgroundColor.isValid() && backgroundColor.alpha()) {
+        paintedExtent = backgroundRect;
+        return true;
+    }
+
+    if (!style()->backgroundLayers()->image() || style()->backgroundLayers()->next()) {
+        paintedExtent =  backgroundRect;
+        return true;
+    }
+
     BackgroundImageGeometry geometry;
-    const_cast<RenderBox*>(this)->calculateBackgroundImageGeometry(style()->backgroundLayers(), backgroundRect, geometry);
-    return geometry.destRect();
+    calculateBackgroundImageGeometry(0, style()->backgroundLayers(), backgroundRect, geometry);
+    paintedExtent = geometry.destRect();
+    return !geometry.hasNonLocalGeometry();
 }
 
 bool RenderBox::backgroundIsKnownToBeOpaqueInRect(const LayoutRect& localRect) const
@@ -1259,7 +1266,9 @@
     if (isTable() || isRoot())
         return false;
 
-    LayoutRect backgroundRect = backgroundPaintedExtent();
+    LayoutRect backgroundRect;
+    if (!getBackgroundPaintedExtent(backgroundRect))
+        return false;
     return foregroundIsKnownToBeOpaqueInRect(backgroundRect, backgroundObscurationTestMaxDepth);
 }
 
@@ -1347,7 +1356,8 @@
     for (const FillLayer* maskLayer = style()->maskLayers(); maskLayer; maskLayer = maskLayer->next()) {
         if (maskLayer->image()) {
             BackgroundImageGeometry geometry;
-            calculateBackgroundImageGeometry(maskLayer, borderBox, geometry);
+            // Masks should never have fixed attachment, so it's OK for paintContainer to be null.
+            calculateBackgroundImageGeometry(0, maskLayer, borderBox, geometry);
             result.unite(geometry.destRect());
         }
     }
@@ -1445,8 +1455,7 @@
 
     for (const FillLayer* curLayer = layers; curLayer; curLayer = curLayer->next()) {
         if (curLayer->image() && image == curLayer->image()->data() && curLayer->image()->canRender(this, style()->effectiveZoom())) {
-            // Now that we know this image is being used, compute the renderer and the rect
-            // if we haven't already
+            // Now that we know this image is being used, compute the renderer and the rect if we haven't already.
             if (!layerRenderer) {
                 bool drawingRootBackground = drawingBackground && (isRoot() || (isBody() && !document()->documentElement()->renderer()->hasBackground()));
                 if (drawingRootBackground) {
@@ -1473,7 +1482,14 @@
             }
 
             BackgroundImageGeometry geometry;
-            layerRenderer->calculateBackgroundImageGeometry(curLayer, rendererRect, geometry);
+            layerRenderer->calculateBackgroundImageGeometry(0, curLayer, rendererRect, geometry);
+            if (geometry.hasNonLocalGeometry()) {
+                // Rather than incur the costs of computing the paintContainer for renderers with fixed backgrounds
+                // in order to get the right destRect, just repaint the entire renderer.
+                layerRenderer->repaint();
+                return true;
+            }
+            
             layerRenderer->repaintRectangle(geometry.destRect());
             if (geometry.destRect() == rendererRect)
                 return true;

Modified: trunk/Source/WebCore/rendering/RenderBox.h (151622 => 151623)


--- trunk/Source/WebCore/rendering/RenderBox.h	2013-06-16 16:57:14 UTC (rev 151622)
+++ trunk/Source/WebCore/rendering/RenderBox.h	2013-06-16 17:24:40 UTC (rev 151623)
@@ -588,7 +588,8 @@
     virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle);
     virtual void updateFromStyle() OVERRIDE;
 
-    LayoutRect backgroundPaintedExtent() const;
+    // Returns false if it could not cheaply compute the extent (e.g. fixed background), in which case the returned rect may be incorrect.
+    bool getBackgroundPaintedExtent(LayoutRect&) const;
     virtual bool foregroundIsKnownToBeOpaqueInRect(const LayoutRect& localRect, unsigned maxDepthToTest) const;
     virtual bool computeBackgroundIsKnownToBeObscured() OVERRIDE;
 

Modified: trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp (151622 => 151623)


--- trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp	2013-06-16 16:57:14 UTC (rev 151622)
+++ trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp	2013-06-16 17:24:40 UTC (rev 151623)
@@ -976,7 +976,7 @@
     // no progressive loading of the background image
     if (shouldPaintBackgroundImage) {
         BackgroundImageGeometry geometry;
-        calculateBackgroundImageGeometry(bgLayer, scrolledPaintRect, geometry, backgroundObject);
+        calculateBackgroundImageGeometry(paintInfo.paintContainer, bgLayer, scrolledPaintRect, geometry, backgroundObject);
         geometry.clip(paintInfo.rect);
         if (!geometry.destRect().isEmpty()) {
             CompositeOperator compositeOp = op == CompositeSourceOver ? bgLayer->composite() : op;
@@ -1214,8 +1214,8 @@
 #endif
 }
 
-void RenderBoxModelObject::calculateBackgroundImageGeometry(const FillLayer* fillLayer, const LayoutRect& paintRect,
-    BackgroundImageGeometry& geometry, RenderObject* backgroundObject)
+void RenderBoxModelObject::calculateBackgroundImageGeometry(const RenderLayerModelObject* paintContainer, const FillLayer* fillLayer, const LayoutRect& paintRect,
+    BackgroundImageGeometry& geometry, RenderObject* backgroundObject) const
 {
     LayoutUnit left = 0;
     LayoutUnit top = 0;
@@ -1224,8 +1224,9 @@
 
     // Determine the background positioning area and set destRect to the background painting area.
     // destRect will be adjusted later if the background is non-repeating.
+    // FIXME: transforms spec says that fixed backgrounds behave like scroll inside transforms. https://bugs.webkit.org/show_bug.cgi?id=15679
     bool fixedAttachment = fillLayer->attachment() == FixedBackgroundAttachment;
-
+    
 #if ENABLE(FAST_MOBILE_SCROLLING)
     if (view()->frameView() && view()->frameView()->canBlitOnScroll()) {
         // As a side effect of an optimization to blit on scroll, we do not honor the CSS
@@ -1265,17 +1266,24 @@
         } else
             positioningAreaSize = pixelSnappedIntSize(paintRect.size() - LayoutSize(left + right, top + bottom), paintRect.location());
     } else {
+        geometry.setHasNonLocalGeometry();
+
         IntRect viewportRect = pixelSnappedIntRect(viewRect());
         if (fixedBackgroundPaintsInLocalCoordinates())
             viewportRect.setLocation(IntPoint());
         else if (FrameView* frameView = view()->frameView())
             viewportRect.setLocation(IntPoint(frameView->scrollOffsetForFixedPosition()));
-        
+
+        if (paintContainer) {
+            IntPoint absoluteContainerOffset = roundedIntPoint(paintContainer->localToAbsolute(FloatPoint()));
+            viewportRect.moveBy(-absoluteContainerOffset);
+        }
+
         geometry.setDestRect(pixelSnappedIntRect(viewportRect));
         positioningAreaSize = geometry.destRect().size();
     }
 
-    RenderObject* clientForBackgroundImage = backgroundObject ? backgroundObject : this;
+    const RenderObject* clientForBackgroundImage = backgroundObject ? backgroundObject : this;
     IntSize fillTileSize = calculateFillTileSize(fillLayer, positioningAreaSize);
     fillLayer->image()->setContainerSizeForRenderer(clientForBackgroundImage, fillTileSize, style()->effectiveZoom());
     geometry.setTileSize(fillTileSize);
@@ -1308,11 +1316,11 @@
     geometry.setDestOrigin(geometry.destRect().location());
 }
 
-void RenderBoxModelObject::getGeometryForBackgroundImage(IntRect& destRect, IntPoint& phase, IntSize& tileSize)
+void RenderBoxModelObject::getGeometryForBackgroundImage(const RenderLayerModelObject* paintContainer, IntRect& destRect, IntPoint& phase, IntSize& tileSize) const
 {
     const FillLayer* backgroundLayer = style()->backgroundLayers();
     BackgroundImageGeometry geometry;
-    calculateBackgroundImageGeometry(backgroundLayer, destRect, geometry);
+    calculateBackgroundImageGeometry(paintContainer, backgroundLayer, destRect, geometry);
     phase = geometry.phase();
     tileSize = geometry.tileSize();
     destRect = geometry.destRect();

Modified: trunk/Source/WebCore/rendering/RenderBoxModelObject.h (151622 => 151623)


--- trunk/Source/WebCore/rendering/RenderBoxModelObject.h	2013-06-16 16:57:14 UTC (rev 151622)
+++ trunk/Source/WebCore/rendering/RenderBoxModelObject.h	2013-06-16 17:24:40 UTC (rev 151623)
@@ -177,7 +177,7 @@
 
     bool canHaveBoxInfoInRegion() const { return !isFloating() && !isReplaced() && !isInline() && !hasColumns() && !isTableCell() && isBlockFlow(); }
 
-    void getGeometryForBackgroundImage(IntRect& destRect, IntPoint& phase, IntSize& tileSize);
+    void getGeometryForBackgroundImage(const RenderLayerModelObject* paintContainer, IntRect& destRect, IntPoint& phase, IntSize& tileSize) const;
 #if USE(ACCELERATED_COMPOSITING)
     void contentChanged(ContentChangeType);
     bool hasAcceleratedCompositing() const;
@@ -198,6 +198,9 @@
 
     class BackgroundImageGeometry {
     public:
+        BackgroundImageGeometry()
+            : m_hasNonLocalGeometry(false)
+        { }
         IntPoint destOrigin() const { return m_destOrigin; }
         void setDestOrigin(const IntPoint& destOrigin)
         {
@@ -234,16 +237,21 @@
         void useFixedAttachment(const IntPoint& attachmentPoint);
         
         void clip(const IntRect&);
+        
+        void setHasNonLocalGeometry(bool hasNonLocalGeometry = true) { m_hasNonLocalGeometry = hasNonLocalGeometry; }
+        bool hasNonLocalGeometry() const { return m_hasNonLocalGeometry; }
+
     private:
         IntRect m_destRect;
         IntPoint m_destOrigin;
         IntPoint m_phase;
         IntSize m_tileSize;
+        bool m_hasNonLocalGeometry; // Has background-attachment: fixed. Implies that we can't always cheaply compute destRect.
     };
 
     LayoutPoint adjustedPositionRelativeToOffsetParent(const LayoutPoint&) const;
 
-    void calculateBackgroundImageGeometry(const FillLayer*, const LayoutRect& paintRect, BackgroundImageGeometry&, RenderObject* = 0);
+    void calculateBackgroundImageGeometry(const RenderLayerModelObject* paintContainer, const FillLayer*, const LayoutRect& paintRect, BackgroundImageGeometry&, RenderObject* = 0) const;
     void getBorderEdgeInfo(class BorderEdge[], const RenderStyle*, bool includeLogicalLeftEdge = true, bool includeLogicalRightEdge = true) const;
     bool borderObscuresBackgroundEdge(const FloatSize& contextScale) const;
     bool borderObscuresBackground() const;

Modified: trunk/Source/WebCore/rendering/RenderImage.cpp (151622 => 151623)


--- trunk/Source/WebCore/rendering/RenderImage.cpp	2013-06-16 16:57:14 UTC (rev 151622)
+++ trunk/Source/WebCore/rendering/RenderImage.cpp	2013-06-16 17:24:40 UTC (rev 151623)
@@ -510,7 +510,11 @@
 {
     if (!hasBackground())
         return false;
-    return foregroundIsKnownToBeOpaqueInRect(backgroundPaintedExtent(), 0);
+    
+    LayoutRect paintedExtent;
+    if (!getBackgroundPaintedExtent(paintedExtent))
+        return false;
+    return foregroundIsKnownToBeOpaqueInRect(paintedExtent, 0);
 }
 
 LayoutUnit RenderImage::minimumReplacedHeight() const

Modified: trunk/Source/WebCore/rendering/RenderLayerBacking.cpp (151622 => 151623)


--- trunk/Source/WebCore/rendering/RenderLayerBacking.cpp	2013-06-16 16:57:14 UTC (rev 151622)
+++ trunk/Source/WebCore/rendering/RenderLayerBacking.cpp	2013-06-16 17:24:40 UTC (rev 151623)
@@ -1464,7 +1464,7 @@
     IntSize tileSize;
 
     RefPtr<Image> image = style->backgroundLayers()->image()->cachedImage()->image();
-    toRenderBox(renderer())->getGeometryForBackgroundImage(destRect, phase, tileSize);
+    toRenderBox(renderer())->getGeometryForBackgroundImage(m_owningLayer->renderer(), destRect, phase, tileSize);
     m_graphicsLayer->setContentsTileSize(tileSize);
     m_graphicsLayer->setContentsTilePhase(phase);
     m_graphicsLayer->setContentsRect(destRect);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to