Title: [133686] trunk
Revision
133686
Author
simon.fra...@apple.com
Date
2012-11-06 16:03:53 -0800 (Tue, 06 Nov 2012)

Log Message

-webkit-background-clip:text produces artifacts when applied to the body and the browser is resized
https://bugs.webkit.org/show_bug.cgi?id=89287

Reviewed by Beth Dakin.

Source/WebCore:

If the body had -webkit-background-clip: text, we'd fail to paint
anything behind it, so would see garbage pixels.

Fix by having RenderView::paintBoxDecorations() check for a background-clip of "text"
on the renderer that paints the root background.

Added some new pixel tests for combinations of html and body transform
and backgrounds; earlier versions of the patch broke some of these tests.

Tests: fast/backgrounds/background-clip-text-on-body.html
       fast/backgrounds/transformed-body-background.html
       fast/backgrounds/transformed-body-html-background.html
       fast/backgrounds/transformed-html-body-background.html

* rendering/RenderView.cpp:
(WebCore::rendererObscuresBackground): Broke up the single condition
into early 'false' returns when possible. We need to also check whether
the renderer that actually paints the background (which might be the body)
will fill it; background-clip: text does not.
(WebCore::RenderView::paintBoxDecorations): Rather than checking firstChild(),
actually check the root renderer, so that we can reliably get to the renderer
that mains the root background.

LayoutTests:

Test with -webkit-background-clip: text on the body, which scrolls.

Some additional tests that exercise different combinations of html and
body transform and background.

* compositing/repaint/composited-document-element.html:
* fast/backgrounds/background-clip-text-on-body-expected.png: Added.
* fast/backgrounds/background-clip-text-on-body-expected.txt: Added.
* fast/backgrounds/background-clip-text-on-body.html: Added.
* fast/backgrounds/transformed-body-background-expected.png: Added.
* fast/backgrounds/transformed-body-background-expected.txt: Added.
* fast/backgrounds/transformed-body-background.html: Added.
* fast/backgrounds/transformed-body-html-background-expected.png: Added.
* fast/backgrounds/transformed-body-html-background-expected.txt: Added.
* fast/backgrounds/transformed-body-html-background.html: Added.
* fast/backgrounds/transformed-html-body-background-expected.png: Added.
* fast/backgrounds/transformed-html-body-background-expected.txt: Added.
* fast/backgrounds/transformed-html-body-background.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (133685 => 133686)


--- trunk/LayoutTests/ChangeLog	2012-11-06 23:52:34 UTC (rev 133685)
+++ trunk/LayoutTests/ChangeLog	2012-11-07 00:03:53 UTC (rev 133686)
@@ -1,3 +1,29 @@
+2012-11-06  Simon Fraser  <simon.fra...@apple.com>
+
+        -webkit-background-clip:text produces artifacts when applied to the body and the browser is resized
+        https://bugs.webkit.org/show_bug.cgi?id=89287
+
+        Reviewed by Beth Dakin.
+
+        Test with -webkit-background-clip: text on the body, which scrolls.
+        
+        Some additional tests that exercise different combinations of html and
+        body transform and background.
+
+        * compositing/repaint/composited-document-element.html:
+        * fast/backgrounds/background-clip-text-on-body-expected.png: Added.
+        * fast/backgrounds/background-clip-text-on-body-expected.txt: Added.
+        * fast/backgrounds/background-clip-text-on-body.html: Added.
+        * fast/backgrounds/transformed-body-background-expected.png: Added.
+        * fast/backgrounds/transformed-body-background-expected.txt: Added.
+        * fast/backgrounds/transformed-body-background.html: Added.
+        * fast/backgrounds/transformed-body-html-background-expected.png: Added.
+        * fast/backgrounds/transformed-body-html-background-expected.txt: Added.
+        * fast/backgrounds/transformed-body-html-background.html: Added.
+        * fast/backgrounds/transformed-html-body-background-expected.png: Added.
+        * fast/backgrounds/transformed-html-body-background-expected.txt: Added.
+        * fast/backgrounds/transformed-html-body-background.html: Added.
+
 2012-11-06  Hans Muller  <hmul...@adobe.com>
 
         [CSS Exclusions] Store ExclusionPolygonEdge vertices in clockwise order

Modified: trunk/LayoutTests/compositing/repaint/composited-document-element.html (133685 => 133686)


--- trunk/LayoutTests/compositing/repaint/composited-document-element.html	2012-11-06 23:52:34 UTC (rev 133685)
+++ trunk/LayoutTests/compositing/repaint/composited-document-element.html	2012-11-07 00:03:53 UTC (rev 133686)
@@ -2,7 +2,7 @@
 
 <html>
 <head>
-  <style type="text/css">
+  <style>
     html {
       -webkit-perspective: 1200px;
       background-color: red;
@@ -11,7 +11,7 @@
       background-color: transparent;
     }
     body {
-      -webkit-transform-style: preserve-3d;
+      -webkit-transform: translateZ(0);
     }
     .box {
       width: 100px;
@@ -19,7 +19,7 @@
       background-color: blue;
     }
   </style>
-  <script type="text/_javascript_" charset="utf-8">
+  <script>
     if (window.testRunner)
       testRunner.waitUntilDone();
 

Added: trunk/LayoutTests/fast/backgrounds/background-clip-text-on-body-expected.png


(Binary files differ)
Property changes on: trunk/LayoutTests/fast/backgrounds/background-clip-text-on-body-expected.png ___________________________________________________________________

Added: svn:mime-type

Added: trunk/LayoutTests/fast/backgrounds/background-clip-text-on-body-expected.txt (0 => 133686)


--- trunk/LayoutTests/fast/backgrounds/background-clip-text-on-body-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/backgrounds/background-clip-text-on-body-expected.txt	2012-11-07 00:03:53 UTC (rev 133686)
@@ -0,0 +1 @@
+Text should remain legible when window is resized. No background artifacts should appear.
Property changes on: trunk/LayoutTests/fast/backgrounds/background-clip-text-on-body-expected.txt
___________________________________________________________________

Added: svn:mime-type

Added: svn:keywords

Added: svn:eol-style

Added: trunk/LayoutTests/fast/backgrounds/background-clip-text-on-body.html (0 => 133686)


--- trunk/LayoutTests/fast/backgrounds/background-clip-text-on-body.html	                        (rev 0)
+++ trunk/LayoutTests/fast/backgrounds/background-clip-text-on-body.html	2012-11-07 00:03:53 UTC (rev 133686)
@@ -0,0 +1,28 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style type="text/css">
+    body {
+        font-size: 5em;
+        -webkit-background-clip: text;
+        height: 2000px;
+        overflow: hidden;
+    }
+</style>
+<script>
+    if (window.testRunner)
+        testRunner.dumpAsText(true);
+
+    function doTest()
+    {
+        window.scrollTo(0, 600);
+    }
+    window.addEventListener('load', doTest, false);
+</script>
+</head>
+<body>
+
+Text should remain legible when window is resized. No background artifacts should appear.
+
+</body>
+</html>
Property changes on: trunk/LayoutTests/fast/backgrounds/background-clip-text-on-body.html
___________________________________________________________________

Added: svn:mime-type

Added: svn:keywords

Added: svn:eol-style

Added: trunk/LayoutTests/fast/backgrounds/transformed-body-background-expected.png


(Binary files differ)
Property changes on: trunk/LayoutTests/fast/backgrounds/transformed-body-background-expected.png ___________________________________________________________________

Added: svn:mime-type

Added: trunk/LayoutTests/fast/backgrounds/transformed-body-background-expected.txt (0 => 133686)


--- trunk/LayoutTests/fast/backgrounds/transformed-body-background-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/backgrounds/transformed-body-background-expected.txt	2012-11-07 00:03:53 UTC (rev 133686)
@@ -0,0 +1 @@
+
Property changes on: trunk/LayoutTests/fast/backgrounds/transformed-body-background-expected.txt
___________________________________________________________________

Added: svn:mime-type

Added: svn:keywords

Added: svn:eol-style

Added: trunk/LayoutTests/fast/backgrounds/transformed-body-background.html (0 => 133686)


--- trunk/LayoutTests/fast/backgrounds/transformed-body-background.html	                        (rev 0)
+++ trunk/LayoutTests/fast/backgrounds/transformed-body-background.html	2012-11-07 00:03:53 UTC (rev 133686)
@@ -0,0 +1,27 @@
+<!DOCTYPE html>
+
+<html>
+<head>
+    <style>
+        body {
+            -webkit-transform: rotate(20deg);
+            -webkit-transform-origin: top left;
+            background-color: silver;
+            overflow: hidden;
+        }
+        
+        .contents {
+            height: 1200px;
+            width: 100%;
+            border: 1px solid black;
+        }
+    </style>
+    <script>
+        if (window.testRunner)
+            testRunner.dumpAsText(true);
+    </script>
+</head>
+<body>
+    <div class="contents"></div>
+</body>
+</html>
Property changes on: trunk/LayoutTests/fast/backgrounds/transformed-body-background.html
___________________________________________________________________

Added: svn:mime-type

Added: svn:keywords

Added: svn:eol-style

Added: trunk/LayoutTests/fast/backgrounds/transformed-body-html-background-expected.png


(Binary files differ)
Property changes on: trunk/LayoutTests/fast/backgrounds/transformed-body-html-background-expected.png ___________________________________________________________________

Added: svn:mime-type

Added: trunk/LayoutTests/fast/backgrounds/transformed-body-html-background-expected.txt (0 => 133686)


--- trunk/LayoutTests/fast/backgrounds/transformed-body-html-background-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/backgrounds/transformed-body-html-background-expected.txt	2012-11-07 00:03:53 UTC (rev 133686)
@@ -0,0 +1 @@
+
Property changes on: trunk/LayoutTests/fast/backgrounds/transformed-body-html-background-expected.txt
___________________________________________________________________

Added: svn:mime-type

Added: svn:keywords

Added: svn:eol-style

Added: trunk/LayoutTests/fast/backgrounds/transformed-body-html-background.html (0 => 133686)


--- trunk/LayoutTests/fast/backgrounds/transformed-body-html-background.html	                        (rev 0)
+++ trunk/LayoutTests/fast/backgrounds/transformed-body-html-background.html	2012-11-07 00:03:53 UTC (rev 133686)
@@ -0,0 +1,31 @@
+<!DOCTYPE html>
+
+<html>
+<head>
+    <style>
+        html {
+            background: gray;
+        }
+        
+        body {
+            -webkit-transform: rotate(20deg);
+            -webkit-transform-origin: top left;
+            background-color: silver;
+            overflow: hidden;
+        }
+        
+        .contents {
+            height: 1200px;
+            width: 100%;
+            border: 1px solid black;
+        }
+    </style>
+    <script>
+        if (window.testRunner)
+            testRunner.dumpAsText(true);
+    </script>
+</head>
+<body>
+    <div class="contents"></div>
+</body>
+</html>
Property changes on: trunk/LayoutTests/fast/backgrounds/transformed-body-html-background.html
___________________________________________________________________

Added: svn:mime-type

Added: svn:keywords

Added: svn:eol-style

Added: trunk/LayoutTests/fast/backgrounds/transformed-html-body-background-expected.png


(Binary files differ)
Property changes on: trunk/LayoutTests/fast/backgrounds/transformed-html-body-background-expected.png ___________________________________________________________________

Added: svn:mime-type

Added: trunk/LayoutTests/fast/backgrounds/transformed-html-body-background-expected.txt (0 => 133686)


--- trunk/LayoutTests/fast/backgrounds/transformed-html-body-background-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/backgrounds/transformed-html-body-background-expected.txt	2012-11-07 00:03:53 UTC (rev 133686)
@@ -0,0 +1 @@
+
Property changes on: trunk/LayoutTests/fast/backgrounds/transformed-html-body-background-expected.txt
___________________________________________________________________

Added: svn:mime-type

Added: svn:keywords

Added: svn:eol-style

Added: trunk/LayoutTests/fast/backgrounds/transformed-html-body-background.html (0 => 133686)


--- trunk/LayoutTests/fast/backgrounds/transformed-html-body-background.html	                        (rev 0)
+++ trunk/LayoutTests/fast/backgrounds/transformed-html-body-background.html	2012-11-07 00:03:53 UTC (rev 133686)
@@ -0,0 +1,30 @@
+<!DOCTYPE html>
+
+<html>
+<head>
+    <style>
+        html {
+            -webkit-transform: rotate(20deg);
+            -webkit-transform-origin: top left;
+        }
+        
+        body {
+            background-color: silver;
+            overflow: hidden;
+        }
+        
+        .contents {
+            height: 1200px;
+            width: 100%;
+            border: 1px solid black;
+        }
+    </style>
+    <script>
+        if (window.testRunner)
+            testRunner.dumpAsText(true);
+    </script>
+</head>
+<body>
+    <div class="contents"></div>
+</body>
+</html>
Property changes on: trunk/LayoutTests/fast/backgrounds/transformed-html-body-background.html
___________________________________________________________________

Added: svn:mime-type

Added: svn:keywords

Added: svn:eol-style

Modified: trunk/Source/WebCore/ChangeLog (133685 => 133686)


--- trunk/Source/WebCore/ChangeLog	2012-11-06 23:52:34 UTC (rev 133685)
+++ trunk/Source/WebCore/ChangeLog	2012-11-07 00:03:53 UTC (rev 133686)
@@ -1,3 +1,33 @@
+2012-11-06  Simon Fraser  <simon.fra...@apple.com>
+
+        -webkit-background-clip:text produces artifacts when applied to the body and the browser is resized
+        https://bugs.webkit.org/show_bug.cgi?id=89287
+
+        Reviewed by Beth Dakin.
+
+        If the body had -webkit-background-clip: text, we'd fail to paint
+        anything behind it, so would see garbage pixels.
+        
+        Fix by having RenderView::paintBoxDecorations() check for a background-clip of "text"
+        on the renderer that paints the root background.
+        
+        Added some new pixel tests for combinations of html and body transform
+        and backgrounds; earlier versions of the patch broke some of these tests.
+
+        Tests: fast/backgrounds/background-clip-text-on-body.html
+               fast/backgrounds/transformed-body-background.html
+               fast/backgrounds/transformed-body-html-background.html
+               fast/backgrounds/transformed-html-body-background.html
+
+        * rendering/RenderView.cpp:
+        (WebCore::rendererObscuresBackground): Broke up the single condition
+        into early 'false' returns when possible. We need to also check whether
+        the renderer that actually paints the background (which might be the body)
+        will fill it; background-clip: text does not.
+        (WebCore::RenderView::paintBoxDecorations): Rather than checking firstChild(),
+        actually check the root renderer, so that we can reliably get to the renderer
+        that mains the root background.
+
 2012-11-06  Stephen White  <senorbla...@chromium.org>
 
         Implement save and restore for a bunch of InternalSettings state

Modified: trunk/Source/WebCore/rendering/RenderView.cpp (133685 => 133686)


--- trunk/Source/WebCore/rendering/RenderView.cpp	2012-11-06 23:52:34 UTC (rev 133685)
+++ trunk/Source/WebCore/rendering/RenderView.cpp	2012-11-07 00:03:53 UTC (rev 133686)
@@ -305,14 +305,27 @@
     return object->hasLayer() && toRenderLayerModelObject(object)->layer()->isComposited();
 }
 
-static inline bool rendererObscuresBackground(RenderObject* object)
+static inline bool rendererObscuresBackground(RenderObject* rootObject)
 {
-    return object && object->style()->visibility() == VISIBLE
-        && object->style()->opacity() == 1
-        && !object->style()->hasTransform()
-        && !isComposited(object);
+    if (!rootObject)
+        return false;
+    
+    RenderStyle* style = rootObject->style();
+    if (style->visibility() != VISIBLE
+        || style->opacity() != 1
+        || style->hasTransform())
+        return false;
+    
+    if (isComposited(rootObject))
+        return false;
+
+    const RenderObject* rootRenderer = rootObject->rendererForRootBackground();
+    if (rootRenderer->style()->backgroundClip() == TextFillBox)
+        return false;
+
+    return true;
 }
-    
+
 void RenderView::paintBoxDecorations(PaintInfo& paintInfo, const LayoutPoint&)
 {
     // Check to see if we are enclosed by a layer that requires complex painting rules.  If so, we cannot blit
@@ -342,18 +355,20 @@
         return;
 
     bool rootFillsViewport = false;
+    bool rootObscuresBackground = false;
     Node* documentElement = document()->documentElement();
     if (RenderObject* rootRenderer = documentElement ? documentElement->renderer() : 0) {
         // The document element's renderer is currently forced to be a block, but may not always be.
         RenderBox* rootBox = rootRenderer->isBox() ? toRenderBox(rootRenderer) : 0;
         rootFillsViewport = rootBox && !rootBox->x() && !rootBox->y() && rootBox->width() >= width() && rootBox->height() >= height();
+        rootObscuresBackground = rendererObscuresBackground(rootRenderer);
     }
     
     Page* page = document()->page();
     float pageScaleFactor = page ? page->pageScaleFactor() : 1;
 
     // If painting will entirely fill the view, no need to fill the background.
-    if (rootFillsViewport && rendererObscuresBackground(firstChild()) && pageScaleFactor >= 1)
+    if (rootFillsViewport && rootObscuresBackground && pageScaleFactor >= 1)
         return;
 
     // This code typically only executes if the root element's visibility has been set to hidden,
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to