Title: [184065] trunk
Revision
184065
Author
[email protected]
Date
2015-05-10 20:56:15 -0700 (Sun, 10 May 2015)

Log Message

background-position sometimes doesn't work properly with background-attachment: fixed
https://bugs.webkit.org/show_bug.cgi?id=103757
rdar://problem/18749925

Reviewed by Darin Adler.

Source/WebCore:

Fix sizing issues with fixed backgrounds when top content inset (blurred toolbar) is in
effect.

The primary issue was that positioningAreaSize was including the top content inset
height, and should not have been, but there were also issues with the "fixedBackgroundPaintsInLocalCoordinates"
code path, which kicks in when the root background is fixed.

Tests: platform/mac-wk2/tiled-drawing/top-content-inset-fixed-attachment-cover-local.html
       platform/mac-wk2/tiled-drawing/top-content-inset-fixed-attachment-cover.html
       platform/mac-wk2/tiled-drawing/top-content-inset-fixed-attachment-local.html
       platform/mac-wk2/tiled-drawing/top-content-inset-fixed-attachment-positioned.html

* rendering/RenderBoxModelObject.cpp:
(WebCore::RenderBoxModelObject::calculateBackgroundImageGeometry):

LayoutTests:

Tests various configurations for painting the fixed backgrounds. The existing test was
actually wrong, so fixed to use a gradient (so you can see where the edges of the image are),
and be valid. Testing is complicated by the fact that setting top content inset actually
causes the snapshot to be inset at the top.

* platform/mac-wk2/tiled-drawing/resources/bordered-image.png: Added.
* platform/mac-wk2/tiled-drawing/top-content-inset-fixed-attachment-cover-expected.html: Added.
* platform/mac-wk2/tiled-drawing/top-content-inset-fixed-attachment-cover-local-expected.html: Added.
* platform/mac-wk2/tiled-drawing/top-content-inset-fixed-attachment-cover-local.html: Copied from LayoutTests/platform/mac-wk2/tiled-drawing/top-content-inset-fixed-attachment.html.
* platform/mac-wk2/tiled-drawing/top-content-inset-fixed-attachment-cover.html: Added.
* platform/mac-wk2/tiled-drawing/top-content-inset-fixed-attachment-expected.html:
* platform/mac-wk2/tiled-drawing/top-content-inset-fixed-attachment-local-expected.html: Added.
* platform/mac-wk2/tiled-drawing/top-content-inset-fixed-attachment-local.html: Added.
* platform/mac-wk2/tiled-drawing/top-content-inset-fixed-attachment-positioned-expected.html: Added.
* platform/mac-wk2/tiled-drawing/top-content-inset-fixed-attachment-positioned.html: Added.
* platform/mac-wk2/tiled-drawing/top-content-inset-fixed-attachment.html:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (184064 => 184065)


--- trunk/LayoutTests/ChangeLog	2015-05-11 03:09:11 UTC (rev 184064)
+++ trunk/LayoutTests/ChangeLog	2015-05-11 03:56:15 UTC (rev 184065)
@@ -1,3 +1,28 @@
+2015-05-10  Simon Fraser  <[email protected]>
+
+        background-position sometimes doesn't work properly with background-attachment: fixed
+        https://bugs.webkit.org/show_bug.cgi?id=103757
+        rdar://problem/18749925
+
+        Reviewed by Darin Adler.
+        
+        Tests various configurations for painting the fixed backgrounds. The existing test was
+        actually wrong, so fixed to use a gradient (so you can see where the edges of the image are),
+        and be valid. Testing is complicated by the fact that setting top content inset actually
+        causes the snapshot to be inset at the top.
+
+        * platform/mac-wk2/tiled-drawing/resources/bordered-image.png: Added.
+        * platform/mac-wk2/tiled-drawing/top-content-inset-fixed-attachment-cover-expected.html: Added.
+        * platform/mac-wk2/tiled-drawing/top-content-inset-fixed-attachment-cover-local-expected.html: Added.
+        * platform/mac-wk2/tiled-drawing/top-content-inset-fixed-attachment-cover-local.html: Copied from LayoutTests/platform/mac-wk2/tiled-drawing/top-content-inset-fixed-attachment.html.
+        * platform/mac-wk2/tiled-drawing/top-content-inset-fixed-attachment-cover.html: Added.
+        * platform/mac-wk2/tiled-drawing/top-content-inset-fixed-attachment-expected.html:
+        * platform/mac-wk2/tiled-drawing/top-content-inset-fixed-attachment-local-expected.html: Added.
+        * platform/mac-wk2/tiled-drawing/top-content-inset-fixed-attachment-local.html: Added.
+        * platform/mac-wk2/tiled-drawing/top-content-inset-fixed-attachment-positioned-expected.html: Added.
+        * platform/mac-wk2/tiled-drawing/top-content-inset-fixed-attachment-positioned.html: Added.
+        * platform/mac-wk2/tiled-drawing/top-content-inset-fixed-attachment.html:
+
 2015-05-10  Martin Robinson  <[email protected]>
 
         [GTK] fast/events/page-visibility-transition-test.html is timing out

Added: trunk/LayoutTests/platform/mac-wk2/tiled-drawing/resources/bordered-image.png


(Binary files differ)
Property changes on: trunk/LayoutTests/platform/mac-wk2/tiled-drawing/resources/bordered-image.png ___________________________________________________________________

Added: svn:mime-type

Added: trunk/LayoutTests/platform/mac-wk2/tiled-drawing/top-content-inset-fixed-attachment-cover-expected.html (0 => 184065)


--- trunk/LayoutTests/platform/mac-wk2/tiled-drawing/top-content-inset-fixed-attachment-cover-expected.html	                        (rev 0)
+++ trunk/LayoutTests/platform/mac-wk2/tiled-drawing/top-content-inset-fixed-attachment-cover-expected.html	2015-05-11 03:56:15 UTC (rev 184065)
@@ -0,0 +1,27 @@
+<html>
+<head>
+<style>
+body {
+    margin: 0;
+}
+.container {
+    width: 100%;
+    height: 100%;
+    background-image: url('resources/bordered-image.png');
+    background-attachment: fixed;
+    background-size: contain;
+    background-repeat: no-repeat;
+}
+</style>
+<script>
+function runTest() {
+    if (window.internals)
+        window.internals.setTopContentInset(100);
+}
+window.addEventListener('load', runTest, false);
+</script>
+</head>
+<body>
+    <div class="container"></div>
+</body>
+</html>

Added: trunk/LayoutTests/platform/mac-wk2/tiled-drawing/top-content-inset-fixed-attachment-cover-local-expected.html (0 => 184065)


--- trunk/LayoutTests/platform/mac-wk2/tiled-drawing/top-content-inset-fixed-attachment-cover-local-expected.html	                        (rev 0)
+++ trunk/LayoutTests/platform/mac-wk2/tiled-drawing/top-content-inset-fixed-attachment-cover-local-expected.html	2015-05-11 03:56:15 UTC (rev 184065)
@@ -0,0 +1,28 @@
+<html>
+<head>
+<style>
+body {
+    margin: 0;
+}
+.container {
+    width: 100%;
+    height: 100%;
+    background-image: url('resources/bordered-image.png');
+    background-attachment: fixed;
+    background-size: contain;
+    background-repeat: no-repeat;
+}
+
+</style>
+<script>
+function runTest() {
+    if (window.internals)
+        window.internals.setTopContentInset(100);
+}
+window.addEventListener('load', runTest, false);
+</script>
+</head>
+<body>
+    <div class="container"></div>
+</body>
+</html>

Copied: trunk/LayoutTests/platform/mac-wk2/tiled-drawing/top-content-inset-fixed-attachment-cover-local.html (from rev 184064, trunk/LayoutTests/platform/mac-wk2/tiled-drawing/top-content-inset-fixed-attachment.html) (0 => 184065)


--- trunk/LayoutTests/platform/mac-wk2/tiled-drawing/top-content-inset-fixed-attachment-cover-local.html	                        (rev 0)
+++ trunk/LayoutTests/platform/mac-wk2/tiled-drawing/top-content-inset-fixed-attachment-cover-local.html	2015-05-11 03:56:15 UTC (rev 184065)
@@ -0,0 +1,31 @@
+<html>
+<head>
+<style>
+
+html {
+    background-color: white;
+}
+body {
+    margin: 0;
+    height: 2000px;
+    overflow: hidden;
+    background-image: url('resources/bordered-image.png');
+    background-attachment: fixed;
+    background-size: contain;
+    background-repeat: no-repeat;
+}
+
+</style>
+
+<script>
+function runTest() {
+    if (window.internals)
+        window.internals.setTopContentInset(100);
+    window.scrollTo(0, 100);
+}
+window.addEventListener('load', runTest, false);
+</script>
+</head>
+<body>
+</body>
+</html>

Added: trunk/LayoutTests/platform/mac-wk2/tiled-drawing/top-content-inset-fixed-attachment-cover.html (0 => 184065)


--- trunk/LayoutTests/platform/mac-wk2/tiled-drawing/top-content-inset-fixed-attachment-cover.html	                        (rev 0)
+++ trunk/LayoutTests/platform/mac-wk2/tiled-drawing/top-content-inset-fixed-attachment-cover.html	2015-05-11 03:56:15 UTC (rev 184065)
@@ -0,0 +1,26 @@
+<html>
+<head>
+<style>
+body {
+    margin: 0;
+    height: 2000px;
+    overflow: hidden;
+    background-image: url('resources/bordered-image.png');
+    background-attachment: fixed;
+    background-size: contain;
+    background-repeat: no-repeat;
+}
+
+</style>
+
+<script>
+function runTest() {
+    if (window.internals)
+        window.internals.setTopContentInset(100);
+}
+window.addEventListener('load', runTest, false);
+</script>
+</head>
+<body>
+</body>
+</html>

Modified: trunk/LayoutTests/platform/mac-wk2/tiled-drawing/top-content-inset-fixed-attachment-expected.html (184064 => 184065)


--- trunk/LayoutTests/platform/mac-wk2/tiled-drawing/top-content-inset-fixed-attachment-expected.html	2015-05-11 03:09:11 UTC (rev 184064)
+++ trunk/LayoutTests/platform/mac-wk2/tiled-drawing/top-content-inset-fixed-attachment-expected.html	2015-05-11 03:56:15 UTC (rev 184065)
@@ -9,18 +9,25 @@
 }
 
 #fixed-background-box {
+    position: absolute;
+    top: -100px;
     width:400px;
     height:600px;
-    background-image:url(resources/green.png);
+    background-image: linear-gradient(blue, blue 10px, green 10px, green 490px, black 490px, black);
     background-attachment:fixed;
+    background-repeat:no-repeat;
 }
 
 </style>
+<script>
+function runTest() {
+    if (window.internals)
+        window.internals.setTopContentInset(100);
+}
+window.addEventListener('load', runTest, false);
+</script>
 </head>
-
 <body>
-
-<div id="fixed-background-box"></div>
-
+    <div id="fixed-background-box"></div>
 </body>
 </html>

Added: trunk/LayoutTests/platform/mac-wk2/tiled-drawing/top-content-inset-fixed-attachment-local-expected.html (0 => 184065)


--- trunk/LayoutTests/platform/mac-wk2/tiled-drawing/top-content-inset-fixed-attachment-local-expected.html	                        (rev 0)
+++ trunk/LayoutTests/platform/mac-wk2/tiled-drawing/top-content-inset-fixed-attachment-local-expected.html	2015-05-11 03:56:15 UTC (rev 184065)
@@ -0,0 +1,30 @@
+<html>
+<head>
+<style>
+body {
+    margin: 0;
+}
+.container {
+    width: 100%;
+    height: 100%;
+    background-image:
+          linear-gradient(blue, blue 10px, green 10px, green 490px, black 490px, black)
+        , linear-gradient(blue, blue 10px, green 10px, green 490px, black 490px, black)
+        , linear-gradient(blue, blue 10px, green 10px, green 490px, black 490px, black);
+    background-size: 200px 500px;
+    background-position: left bottom, 200px center, 400px top;
+    background-repeat: no-repeat;
+}
+</style>
+<script>
+function runTest() {
+    if (window.internals)
+        window.internals.setTopContentInset(100);
+}
+window.addEventListener('load', runTest, false);
+</script>
+</head>
+<body>
+    <div class="container"></div>
+</body>
+</html>

Added: trunk/LayoutTests/platform/mac-wk2/tiled-drawing/top-content-inset-fixed-attachment-local.html (0 => 184065)


--- trunk/LayoutTests/platform/mac-wk2/tiled-drawing/top-content-inset-fixed-attachment-local.html	                        (rev 0)
+++ trunk/LayoutTests/platform/mac-wk2/tiled-drawing/top-content-inset-fixed-attachment-local.html	2015-05-11 03:56:15 UTC (rev 184065)
@@ -0,0 +1,34 @@
+<html>
+<head>
+<style>
+html {
+    background: white;
+}
+body {
+    margin: 0;
+    height: 2000px;
+    overflow: hidden;
+    background-image:
+          linear-gradient(blue, blue 10px, green 10px, green 490px, black 490px, black)
+        , linear-gradient(blue, blue 10px, green 10px, green 490px, black 490px, black)
+        , linear-gradient(blue, blue 10px, green 10px, green 490px, black 490px, black);
+    background-attachment: fixed;
+    background-size: 200px 500px;
+    background-position: left bottom, 200px center, 400px top;
+    background-repeat: no-repeat;
+}
+
+</style>
+
+<script>
+function runTest() {
+    if (window.internals)
+        window.internals.setTopContentInset(100);
+    window.scrollTo(0, 100);
+}
+window.addEventListener('load', runTest, false);
+</script>
+</head>
+<body>
+</body>
+</html>

Added: trunk/LayoutTests/platform/mac-wk2/tiled-drawing/top-content-inset-fixed-attachment-positioned-expected.html (0 => 184065)


--- trunk/LayoutTests/platform/mac-wk2/tiled-drawing/top-content-inset-fixed-attachment-positioned-expected.html	                        (rev 0)
+++ trunk/LayoutTests/platform/mac-wk2/tiled-drawing/top-content-inset-fixed-attachment-positioned-expected.html	2015-05-11 03:56:15 UTC (rev 184065)
@@ -0,0 +1,30 @@
+<html>
+<head>
+<style>
+body {
+    margin: 0;
+}
+.container {
+    width: 100%;
+    height: 100%;
+    background-image:
+          linear-gradient(blue, blue 10px, green 10px, green 490px, black 490px, black)
+        , linear-gradient(blue, blue 10px, green 10px, green 490px, black 490px, black)
+        , linear-gradient(blue, blue 10px, green 10px, green 490px, black 490px, black);
+    background-size: 200px 500px;
+    background-position: left bottom, 200px center, 400px top;
+    background-repeat: no-repeat;
+}
+</style>
+<script>
+function runTest() {
+    if (window.internals)
+        window.internals.setTopContentInset(100);
+}
+window.addEventListener('load', runTest, false);
+</script>
+</head>
+<body>
+    <div class="container"></div>
+</body>
+</html>

Added: trunk/LayoutTests/platform/mac-wk2/tiled-drawing/top-content-inset-fixed-attachment-positioned.html (0 => 184065)


--- trunk/LayoutTests/platform/mac-wk2/tiled-drawing/top-content-inset-fixed-attachment-positioned.html	                        (rev 0)
+++ trunk/LayoutTests/platform/mac-wk2/tiled-drawing/top-content-inset-fixed-attachment-positioned.html	2015-05-11 03:56:15 UTC (rev 184065)
@@ -0,0 +1,28 @@
+<html>
+<head>
+<style>
+html {
+    height: 2000px;
+    overflow: hidden;
+    background-image:
+          linear-gradient(blue, blue 10px, green 10px, green 490px, black 490px, black)
+        , linear-gradient(blue, blue 10px, green 10px, green 490px, black 490px, black)
+        , linear-gradient(blue, blue 10px, green 10px, green 490px, black 490px, black);
+    background-attachment: fixed;
+    background-size: 200px 500px;
+    background-position: left bottom, 200px center, 400px top;
+    background-repeat: no-repeat;
+}
+
+</style>
+<script>
+function runTest() {
+    if (window.internals)
+        window.internals.setTopContentInset(100);
+}
+window.addEventListener('load', runTest, false);
+</script>
+</head>
+<body>
+</body>
+</html>

Modified: trunk/LayoutTests/platform/mac-wk2/tiled-drawing/top-content-inset-fixed-attachment.html (184064 => 184065)


--- trunk/LayoutTests/platform/mac-wk2/tiled-drawing/top-content-inset-fixed-attachment.html	2015-05-11 03:09:11 UTC (rev 184064)
+++ trunk/LayoutTests/platform/mac-wk2/tiled-drawing/top-content-inset-fixed-attachment.html	2015-05-11 03:56:15 UTC (rev 184065)
@@ -9,28 +9,24 @@
 }
 
 #fixed-background-box {
-    width:400px;
-    height:600px;
-    background-image:url(resources/green.png);
-    background-attachment:fixed;
+    width: 400px;
+    height: 600px;
+    background-image: linear-gradient(blue, blue 10px, green 10px, green 490px, black 490px, black);
+    background-attachment: fixed;
+    background-repeat:no-repeat;
 }
 
 </style>
-
 <script>
 function runTest() {
     if (window.internals)
         window.internals.setTopContentInset(100);
     window.scrollTo(0, 100);
 }
-
 window.addEventListener('load', runTest, false);
 </script>
 </head>
-
 <body>
-
-<div id="fixed-background-box"></div>
-
+    <div id="fixed-background-box"></div>
 </body>
 </html>

Modified: trunk/Source/WebCore/ChangeLog (184064 => 184065)


--- trunk/Source/WebCore/ChangeLog	2015-05-11 03:09:11 UTC (rev 184064)
+++ trunk/Source/WebCore/ChangeLog	2015-05-11 03:56:15 UTC (rev 184065)
@@ -1,3 +1,26 @@
+2015-05-10  Simon Fraser  <[email protected]>
+
+        background-position sometimes doesn't work properly with background-attachment: fixed
+        https://bugs.webkit.org/show_bug.cgi?id=103757
+        rdar://problem/18749925
+
+        Reviewed by Darin Adler.
+        
+        Fix sizing issues with fixed backgrounds when top content inset (blurred toolbar) is in
+        effect.
+        
+        The primary issue was that positioningAreaSize was including the top content inset
+        height, and should not have been, but there were also issues with the "fixedBackgroundPaintsInLocalCoordinates"
+        code path, which kicks in when the root background is fixed.
+
+        Tests: platform/mac-wk2/tiled-drawing/top-content-inset-fixed-attachment-cover-local.html
+               platform/mac-wk2/tiled-drawing/top-content-inset-fixed-attachment-cover.html
+               platform/mac-wk2/tiled-drawing/top-content-inset-fixed-attachment-local.html
+               platform/mac-wk2/tiled-drawing/top-content-inset-fixed-attachment-positioned.html
+
+        * rendering/RenderBoxModelObject.cpp:
+        (WebCore::RenderBoxModelObject::calculateBackgroundImageGeometry):
+
 2015-05-10  Sungmann Cho  <[email protected]>
 
         Get rid of the public item accessors in BackForwardClient

Modified: trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp (184064 => 184065)


--- trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp	2015-05-11 03:09:11 UTC (rev 184064)
+++ trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp	2015-05-11 03:56:15 UTC (rev 184065)
@@ -1111,16 +1111,20 @@
             positioningAreaSize = paintRect.size() - LayoutSize(left + right, top + bottom);
     } else {
         LayoutRect viewportRect;
+        float topContentInset = 0;
         if (frame().settings().fixedBackgroundsPaintRelativeToDocument())
             viewportRect = view().unscaledDocumentRect();
         else {
-            viewportRect.setSize(view().frameView().unscaledVisibleContentSizeIncludingObscuredArea());
+            FrameView& frameView = view().frameView();
+            viewportRect.setSize(frameView.unscaledVisibleContentSizeIncludingObscuredArea());
+            topContentInset = frameView.topContentInset(ScrollView::TopContentInsetType::WebCoreOrPlatformContentInset);
+
             if (fixedBackgroundPaintsInLocalCoordinates())
-                viewportRect.setLocation(LayoutPoint());
-            else {
-                viewportRect.setLocation(toLayoutPoint(view().frameView().documentScrollOffsetRelativeToViewOrigin()));
-                top += view().frameView().topContentInset(ScrollView::TopContentInsetType::WebCoreOrPlatformContentInset);
-            }
+                viewportRect.setLocation(LayoutPoint(0, -topContentInset));
+            else
+                viewportRect.setLocation(toLayoutPoint(frameView.documentScrollOffsetRelativeToViewOrigin()));
+
+            top += topContentInset;
         }
         
         if (paintContainer)
@@ -1128,6 +1132,7 @@
 
         destinationRect = viewportRect;
         positioningAreaSize = destinationRect.size();
+        positioningAreaSize.setHeight(positioningAreaSize.height() - topContentInset);
     }
 
     auto clientForBackgroundImage = backgroundObject ? backgroundObject : this;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to