Source/WebCore: Avoid creating background layers on pages with a fixed background...
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 24 Jan 2013 05:35:37 +0000 (05:35 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 24 Jan 2013 05:35:37 +0000 (05:35 +0000)
https://bugs.webkit.org/show_bug.cgi?id=107783
<rdar://problem/13074450>

Reviewed by Beth Dakin.

http://www.nme.com has background-attachment: fixed on the <body>, but
not background image. In that case there's no point making a layer
for the fixed root background.

Test: platform/mac/tiled-drawing/fixed-background/fixed-background-no-image.html

* rendering/style/RenderStyle.cpp:
(WebCore::allLayersAreFixed): Check to see if we have an image, as well
as fixed attachment.

LayoutTests: Avoid creating background layers on pages with a fixed background, but no image
https://bugs.webkit.org/show_bug.cgi?id=107783

Reviewed by Beth Dakin.

Testcase with body { background-attachment:fixed; } but no image.

* platform/mac/tiled-drawing/fixed-background/fixed-background-no-image-expected.txt: Added.
* platform/mac/tiled-drawing/fixed-background/fixed-background-no-image.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@140648 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/platform/mac/tiled-drawing/fixed-background/fixed-background-no-image-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/tiled-drawing/fixed-background/fixed-background-no-image.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/rendering/style/RenderStyle.cpp

index 2811567..f3d0611 100644 (file)
@@ -1,3 +1,15 @@
+2013-01-23  Simon Fraser  <simon.fraser@apple.com>
+
+        Avoid creating background layers on pages with a fixed background, but no image
+        https://bugs.webkit.org/show_bug.cgi?id=107783
+
+        Reviewed by Beth Dakin.
+        
+        Testcase with body { background-attachment:fixed; } but no image.
+
+        * platform/mac/tiled-drawing/fixed-background/fixed-background-no-image-expected.txt: Added.
+        * platform/mac/tiled-drawing/fixed-background/fixed-background-no-image.html: Added.
+
 2013-01-23  Yoshifumi Inoue  <yosin@chromium.org>
 
         Layout Test platform/chromium-win/fast/events/panScroll-panIcon.html is failing
diff --git a/LayoutTests/platform/mac/tiled-drawing/fixed-background/fixed-background-no-image-expected.txt b/LayoutTests/platform/mac/tiled-drawing/fixed-background/fixed-background-no-image-expected.txt
new file mode 100644 (file)
index 0000000..54f4344
--- /dev/null
@@ -0,0 +1,18 @@
+(GraphicsLayer
+  (bounds 785.00 1700.00)
+  (children 1
+    (GraphicsLayer
+      (bounds 785.00 1700.00)
+      (drawsContent 1)
+      (backgroundColor #FFFFFF)
+      (tile cache coverage 0, 0 785 x 1700)
+      (tile size 512 x 512)
+      (top left tile 0, 0 tiles grid 2 x 4)
+      (children 1
+        (GraphicsLayer
+        )
+      )
+    )
+  )
+)
+
diff --git a/LayoutTests/platform/mac/tiled-drawing/fixed-background/fixed-background-no-image.html b/LayoutTests/platform/mac/tiled-drawing/fixed-background/fixed-background-no-image.html
new file mode 100644 (file)
index 0000000..2cb4122
--- /dev/null
@@ -0,0 +1,43 @@
+<!DOCTYPE html>
+
+<html>
+<head>
+    <style>
+        body {
+            margin: 100px;
+            height: 1500px;
+            background-attachment: fixed;
+        }
+        
+        .test {
+            height: 400px;
+            width: 600px;
+            background-color: rgba(0, 0, 0, 0.5);
+            border: 20px solid orange;
+        }
+        
+        #layers {
+            opacity: 0;
+        }
+    </style>
+    <script>
+    if (window.testRunner)
+        testRunner.dumpAsText(true);
+    
+    function doTest()
+    {
+        window.scrollTo(0, 200);
+
+        if (window.internals)
+            document.getElementById('layers').innerText = internals.layerTreeAsText(document, internals.LAYER_TREE_INCLUDES_TILE_CACHES);
+    }
+    
+    window.addEventListener('load', doTest, false);
+    </script>
+</head>
+<body>
+
+    <div class="test"></div>
+<pre id="layers"></pre>
+</body>
+</html>
index ec82450..0e70eb8 100644 (file)
@@ -1,3 +1,21 @@
+2013-01-23  Simon Fraser  <simon.fraser@apple.com>
+
+        Avoid creating background layers on pages with a fixed background, but no image
+        https://bugs.webkit.org/show_bug.cgi?id=107783
+        <rdar://problem/13074450>
+
+        Reviewed by Beth Dakin.
+        
+        http://www.nme.com has background-attachment: fixed on the <body>, but
+        not background image. In that case there's no point making a layer
+        for the fixed root background.
+
+        Test: platform/mac/tiled-drawing/fixed-background/fixed-background-no-image.html
+
+        * rendering/style/RenderStyle.cpp:
+        (WebCore::allLayersAreFixed): Check to see if we have an image, as well
+        as fixed attachment.
+
 2013-01-23  Wei Jia  <wjia@chromium.org>
 
         Enable autoplay when <video>'s src is from media stream
index 23bac88..e256ce6 100644 (file)
@@ -1032,7 +1032,7 @@ static bool allLayersAreFixed(const FillLayer* layer)
     bool allFixed = true;
     
     for (const FillLayer* currLayer = layer; currLayer; currLayer = currLayer->next())
-        allFixed &= currLayer->attachment() == FixedBackgroundAttachment;
+        allFixed &= (currLayer->image() && currLayer->attachment() == FixedBackgroundAttachment);
 
     return layer && allFixed;
 }