Title: [105091] trunk
Revision
105091
Author
[email protected]
Date
2012-01-16 14:21:48 -0800 (Mon, 16 Jan 2012)

Log Message

Borders and box masks behave incorrectly with overlapping offsets
https://bugs.webkit.org/show_bug.cgi?id=76137

Source/WebCore:

Reviewed by Dean Jackson.

There are some correct behaviors for -webkit-mask-box-image where
parts of the mask are missing (when the sum of the slice sizes is
greater than one dimension of the image). To render correctly
in these cases, always use a transparency layer when rendering
the mask.

Test: fast/backgrounds/mask-box-image.html

* rendering/RenderBox.cpp:
(WebCore::RenderBox::paintMaskImages):

LayoutTests:

Reviewed by Dean Jackson.

Test -webkit-mask-box-image with large slice sizes, with and
without a transform.

* fast/backgrounds/mask-box-image.html: Added.
* fast/backgrounds/resources/dot.png: Added.
* platform/mac/fast/backgrounds/mask-box-image-expected.png: Added.
* platform/mac/fast/backgrounds/mask-box-image-expected.txt: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (105090 => 105091)


--- trunk/LayoutTests/ChangeLog	2012-01-16 22:19:36 UTC (rev 105090)
+++ trunk/LayoutTests/ChangeLog	2012-01-16 22:21:48 UTC (rev 105091)
@@ -1,5 +1,20 @@
 2012-01-16  Simon Fraser  <[email protected]>
 
+        Borders and box masks behave incorrectly with overlapping offsets
+        https://bugs.webkit.org/show_bug.cgi?id=76137
+
+        Reviewed by Dean Jackson.
+        
+        Test -webkit-mask-box-image with large slice sizes, with and
+        without a transform.
+
+        * fast/backgrounds/mask-box-image.html: Added.
+        * fast/backgrounds/resources/dot.png: Added.
+        * platform/mac/fast/backgrounds/mask-box-image-expected.png: Added.
+        * platform/mac/fast/backgrounds/mask-box-image-expected.txt: Added.
+
+2012-01-16  Simon Fraser  <[email protected]>
+
         Filtered element with composited content beneath it must be composited
         https://bugs.webkit.org/show_bug.cgi?id=76322
 

Added: trunk/LayoutTests/fast/backgrounds/mask-box-image.html (0 => 105091)


--- trunk/LayoutTests/fast/backgrounds/mask-box-image.html	                        (rev 0)
+++ trunk/LayoutTests/fast/backgrounds/mask-box-image.html	2012-01-16 22:21:48 UTC (rev 105091)
@@ -0,0 +1,42 @@
+<html>
+    <head>
+        <style>
+            .container {
+                display: inline-block;
+                border: 1px solid black;
+                margin: 20px;
+            }
+            
+            .scaled {
+                -webkit-transform: scale(1.0001);
+                -webkit-transform-origin: top left;
+            }
+
+            .box {
+                width: 100px;
+                height: 100px;
+                background-color: black;
+                margin: 10px;
+            }
+            
+            .mask3 {
+                -webkit-mask-box-image: url(resources/dot.png) 3 stretch stretch;
+            }
+
+            .mask6 {
+                -webkit-mask-box-image: url(resources/dot.png) 6 stretch stretch;
+            }
+        </style>
+    </head>
+    <body>
+        <!-- Other than the scale, left and right sides should look the same. -->
+        <div class="container">
+            <div class="mask3 box"></div>
+            <div class="mask6 box"></div>
+        </div>
+        <div class="scaled container">
+            <div class="mask3 box"></div>
+            <div class="mask6 box"></div>
+        </div>
+    </body>
+</html>
Property changes on: trunk/LayoutTests/fast/backgrounds/mask-box-image.html
___________________________________________________________________

Added: svn:mime-type

Added: svn:keywords

Added: svn:eol-style

Added: trunk/LayoutTests/fast/backgrounds/resources/dot.png


(Binary files differ)
Property changes on: trunk/LayoutTests/fast/backgrounds/resources/dot.png ___________________________________________________________________

Added: svn:mime-type

Added: trunk/LayoutTests/platform/mac/fast/backgrounds/mask-box-image-expected.png


(Binary files differ)
Property changes on: trunk/LayoutTests/platform/mac/fast/backgrounds/mask-box-image-expected.png ___________________________________________________________________

Added: svn:mime-type

Added: trunk/LayoutTests/platform/mac/fast/backgrounds/mask-box-image-expected.txt (0 => 105091)


--- trunk/LayoutTests/platform/mac/fast/backgrounds/mask-box-image-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/mac/fast/backgrounds/mask-box-image-expected.txt	2012-01-16 22:21:48 UTC (rev 105091)
@@ -0,0 +1,19 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderBlock {HTML} at (0,0) size 800x600
+    RenderBody {BODY} at (8,8) size 784x584
+      RenderBlock {DIV} at (20,20) size 122x232 [border: (1px solid #000000)]
+      RenderText {#text} at (162,258) size 4x18
+        text run at (162,258) width 4: " "
+      RenderText {#text} at (0,0) size 0x0
+layer at (39,39) size 100x100
+  RenderBlock {DIV} at (11,11) size 100x100 [bgcolor=#000000]
+layer at (39,149) size 100x100
+  RenderBlock {DIV} at (11,121) size 100x100 [bgcolor=#000000]
+layer at (194,28) size 122x232
+  RenderBlock {DIV} at (186,20) size 122x232 [border: (1px solid #000000)]
+layer at (205,39) size 100x100
+  RenderBlock {DIV} at (11,11) size 100x100 [bgcolor=#000000]
+layer at (205,149) size 100x100
+  RenderBlock {DIV} at (11,121) size 100x100 [bgcolor=#000000]
Property changes on: trunk/LayoutTests/platform/mac/fast/backgrounds/mask-box-image-expected.txt
___________________________________________________________________

Added: svn:mime-type

Added: svn:keywords

Added: svn:eol-style

Modified: trunk/Source/WebCore/ChangeLog (105090 => 105091)


--- trunk/Source/WebCore/ChangeLog	2012-01-16 22:19:36 UTC (rev 105090)
+++ trunk/Source/WebCore/ChangeLog	2012-01-16 22:21:48 UTC (rev 105091)
@@ -1,5 +1,23 @@
 2012-01-16  Simon Fraser  <[email protected]>
 
+        Borders and box masks behave incorrectly with overlapping offsets
+        https://bugs.webkit.org/show_bug.cgi?id=76137
+
+        Reviewed by Dean Jackson.
+        
+        There are some correct behaviors for -webkit-mask-box-image where
+        parts of the mask are missing (when the sum of the slice sizes is
+        greater than one dimension of the image). To render correctly
+        in these cases, always use a transparency layer when rendering
+        the mask.
+
+        Test: fast/backgrounds/mask-box-image.html
+
+        * rendering/RenderBox.cpp:
+        (WebCore::RenderBox::paintMaskImages):
+
+2012-01-16  Simon Fraser  <[email protected]>
+
         Filtered element with composited content beneath it must be composited
         https://bugs.webkit.org/show_bug.cgi?id=76322
 

Modified: trunk/Source/WebCore/rendering/RenderBox.cpp (105090 => 105091)


--- trunk/Source/WebCore/rendering/RenderBox.cpp	2012-01-16 22:19:36 UTC (rev 105090)
+++ trunk/Source/WebCore/rendering/RenderBox.cpp	2012-01-16 22:21:48 UTC (rev 105091)
@@ -973,11 +973,7 @@
     bool allMaskImagesLoaded = true;
     
     if (!compositedMask) {
-        // If the context has a rotation, scale or skew, then use a transparency layer to avoid
-        // pixel cruft around the edge of the mask.
-        const AffineTransform& currentCTM = paintInfo.context->getCTM();
-        pushTransparencyLayer = !currentCTM.isIdentityOrTranslationOrFlipped();
-
+        pushTransparencyLayer = true;
         StyleImage* maskBoxImage = style()->maskBoxImage().image();
         const FillLayer* maskLayers = style()->maskLayers();
 
@@ -988,37 +984,9 @@
         if (maskLayers)
             allMaskImagesLoaded &= maskLayers->imagesAreLoaded();
 
-        // Before all images have loaded, just use an empty transparency layer as the mask.
-        if (!allMaskImagesLoaded)
-            pushTransparencyLayer = true;
-
-        bool hasMaskLayerWithImage = maskLayers->hasImage();
-        if (maskBoxImage && hasMaskLayerWithImage) {
-            // We have a mask-box-image and mask-image, so need to composite them together before using the result as a mask.
-            pushTransparencyLayer = true;
-        } else if (hasMaskLayerWithImage) {
-            // We have to use an extra image buffer to hold the mask. Multiple mask images need
-            // to composite together using source-over so that they can then combine into a single unified mask that
-            // can be composited with the content using destination-in.  SVG images need to be able to set compositing modes
-            // as they draw images contained inside their sub-document, so we paint all our images into a separate buffer
-            // and composite that buffer as the mask.
-            // We have to check that the mask images to be rendered contain at least one image that can be actually used in rendering
-            // before pushing the transparency layer.
-            for (const FillLayer* fillLayer = maskLayers->next(); fillLayer; fillLayer = fillLayer->next()) {
-                if (fillLayer->image() && fillLayer->image()->canRender(this, style()->effectiveZoom())) {
-                    pushTransparencyLayer = true;
-                    // We found one image that can be used in rendering, exit the loop
-                    break;
-                }
-            }
-        }
-        
-        compositeOp = CompositeDestinationIn;
-        if (pushTransparencyLayer) {
-            paintInfo.context->setCompositeOperation(CompositeDestinationIn);
-            paintInfo.context->beginTransparencyLayer(1.0f);
-            compositeOp = CompositeSourceOver;
-        }
+        paintInfo.context->setCompositeOperation(CompositeDestinationIn);
+        paintInfo.context->beginTransparencyLayer(1);
+        compositeOp = CompositeSourceOver;
     }
 
     if (allMaskImagesLoaded) {
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to