Mask deformations when masked content is rotated
authorfmalita@chromium.org <fmalita@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 15 May 2012 12:56:35 +0000 (12:56 +0000)
committerfmalita@chromium.org <fmalita@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 15 May 2012 12:56:35 +0000 (12:56 +0000)
https://bugs.webkit.org/show_bug.cgi?id=76527

Reviewed by Nikolas Zimmermann.

Source/WebCore:

Test: svg/repaint/mask-clip-target-transform.svg

RenderSVGResource::markForLayoutAndParentResourceInvalidation() needs to also
invalidate parent mask and clip resources, not just filters.

* rendering/svg/RenderSVGResource.cpp:
(WebCore::removeFromCacheAndInvalidateDependencies):
(WebCore::RenderSVGResource::markForLayoutAndParentResourceInvalidation):

LayoutTests:

* platform/chromium-linux/svg/repaint/mask-clip-target-transform-expected.png: Added.
* platform/chromium/test_expectations.txt:
* platform/mac/test_expectations.txt:
* svg/repaint/mask-clip-target-transform-expected.txt: Added.
* svg/repaint/mask-clip-target-transform.svg: Added.

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

LayoutTests/ChangeLog
LayoutTests/platform/chromium-linux/svg/repaint/mask-clip-target-transform-expected.png [new file with mode: 0644]
LayoutTests/platform/chromium/test_expectations.txt
LayoutTests/platform/mac/test_expectations.txt
LayoutTests/svg/repaint/mask-clip-target-transform-expected.txt [new file with mode: 0644]
LayoutTests/svg/repaint/mask-clip-target-transform.svg [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/rendering/svg/RenderSVGResource.cpp

index 0e6b3c1..d558fd5 100644 (file)
@@ -1,3 +1,16 @@
+2012-05-15  Florin Malita  <fmalita@chromium.org>
+
+        Mask deformations when masked content is rotated
+        https://bugs.webkit.org/show_bug.cgi?id=76527
+
+        Reviewed by Nikolas Zimmermann.
+
+        * platform/chromium-linux/svg/repaint/mask-clip-target-transform-expected.png: Added.
+        * platform/chromium/test_expectations.txt:
+        * platform/mac/test_expectations.txt:
+        * svg/repaint/mask-clip-target-transform-expected.txt: Added.
+        * svg/repaint/mask-clip-target-transform.svg: Added.
+
 2012-05-15  Sheriff Bot  <webkit.review.bot@gmail.com>
 
         Unreviewed, rolling out r117052.
diff --git a/LayoutTests/platform/chromium-linux/svg/repaint/mask-clip-target-transform-expected.png b/LayoutTests/platform/chromium-linux/svg/repaint/mask-clip-target-transform-expected.png
new file mode 100644 (file)
index 0000000..0724ac0
Binary files /dev/null and b/LayoutTests/platform/chromium-linux/svg/repaint/mask-clip-target-transform-expected.png differ
index 183ccf3..7eb0b1c 100644 (file)
@@ -1218,6 +1218,9 @@ BUGWK81217 : svg/custom/use-detach.svg = PASS FAIL
 BUGWK81217 : svg/carto.net/tabgroup.svg = PASS FAIL
 BUGWK81217 : svg/hixie/perf/003.xml = PASS FAIL
 
+// Needs rebaselining after landing 76527
+BUGWK76527 WIN MAC : svg/repaint/mask-clip-target-transform.svg = IMAGE+TEXT IMAGE TEXT PASS
+
 BUGWK81240 MAC : svg/text/bidi-reorder-value-lists.svg = PASS IMAGE+TEXT
 
 BUGWK81243 : svg/repaint/repainting-after-animation-element-removal.svg = PASS IMAGE
index 742f172..9ad0671 100644 (file)
@@ -207,6 +207,9 @@ BUGWK85689 SKIP : fast/animation/request-animation-frame-disabled.html = TEXT
 BUGWK85990 : media/video-controls-rendering-toggle-display-none.html = TEXT
 BUGWK85990 : media/video-controls-toggling.html = TIMEOUT TEXT
 
+// Requires rebaseline after bug 76527
+BUGWK76527 : svg/repaint/mask-clip-target-transform.svg = IMAGE+TEXT IMAGE TEXT PASS
+
 BUGWK85308 : ietestcenter/css3/valuesandunits/units-000.htm = IMAGE
 BUGWK85310 : ietestcenter/css3/valuesandunits/units-010.htm = IMAGE
 
diff --git a/LayoutTests/svg/repaint/mask-clip-target-transform-expected.txt b/LayoutTests/svg/repaint/mask-clip-target-transform-expected.txt
new file mode 100644 (file)
index 0000000..9693d1f
--- /dev/null
@@ -0,0 +1,18 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderSVGRoot {svg} at (50,50) size 200x200
+    RenderSVGHiddenContainer {defs} at (0,0) size 0x0
+      RenderSVGResourceMasker {mask} [id="mask"] [maskUnits=objectBoundingBox] [maskContentUnits=userSpaceOnUse]
+        RenderSVGEllipse {circle} at (150,50) size 100x100 [fill={[type=SOLID] [color=#FFFFFF]}] [cx=100.00] [cy=0.00] [r=50.00]
+      RenderSVGResourceClipper {clipPath} [id="clip"] [clipPathUnits=userSpaceOnUse]
+        RenderSVGEllipse {circle} at (50,150) size 100x100 [fill={[type=SOLID] [color=#000000]}] [cx=0.00] [cy=100.00] [r=50.00]
+        RenderSVGEllipse {circle} at (0,0) size 0x0 [fill={[type=SOLID] [color=#000000]}] [cx=0.00] [cy=0.00] [r=0.00]
+    RenderSVGEllipse {circle} at (150,50) size 100x100 [fill={[type=SOLID] [color=#FF0000]}] [cx=100.00] [cy=0.00] [r=50.00]
+    RenderSVGContainer {g} at (150,50) size 100x100
+      [masker="mask"] RenderSVGResourceMasker {mask} at (50,-50) size 100x100
+      RenderSVGRect {rect} at (100,0) size 200x300 [transform={m=((0.00,1.00)(-1.00,0.00)) t=(0.00,0.00)}] [fill={[type=SOLID] [color=#008000]}] [x=-200.00] [y=-200.00] [width=400.00] [height=200.00]
+    RenderSVGEllipse {circle} at (50,150) size 100x100 [fill={[type=SOLID] [color=#FF0000]}] [cx=0.00] [cy=100.00] [r=50.00]
+    RenderSVGContainer {g} at (50,150) size 100x100
+      [clipPath="clip"] RenderSVGResourceClipper {clipPath} at (-50,50) size 100x100
+      RenderSVGRect {rect} at (0,100) size 300x200 [transform={m=((0.00,1.00)(-1.00,0.00)) t=(0.00,0.00)}] [fill={[type=SOLID] [color=#008000]}] [x=0.00] [y=-200.00] [width=200.00] [height=400.00]
diff --git a/LayoutTests/svg/repaint/mask-clip-target-transform.svg b/LayoutTests/svg/repaint/mask-clip-target-transform.svg
new file mode 100644 (file)
index 0000000..90e7248
--- /dev/null
@@ -0,0 +1,40 @@
+<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="-100 -100 800 600" onload="runRepaintTest();">
+  <!--
+    Test for https://bugs.webkit.org/show_bug.cgi?id=76527.
+    Only two green circles should be visible.
+  -->
+  <script xlink:href="../../fast/repaint/resources/repaint.js" type="text/javascript"></script>
+  <defs>
+    <mask id="mask">
+      <circle cx="100" r="50" fill="white"/>
+    </mask>
+
+    <clipPath id="clip">
+      <circle cy="100" r="50"/>
+      <!--Two clip shapes are needed to avoid triggering pathOnlyClipping -->
+      <circle cx="0" cy="0" r="0"/>
+    </clipPath>
+  </defs>
+
+  <circle cx="100" r="50" fill="red"/>
+  <g mask="url(#mask)">
+    <rect id="masker" x="-200" y="-200" width="400" height="200" fill="green"/>
+  </g>
+
+  <circle cy="100" r="50" fill="red"/>
+  <g clip-path="url(#clip)">
+    <rect id="clipper" x="0" y="-200" width="200" height="400" fill="green"/>
+  </g>
+
+  <script>
+      function rotate(target, angle) {
+        document.getElementById(target).setAttribute('transform', 'rotate(' + angle + ')');
+      }
+
+      function repaintTest() {
+        rotate("masker", 90);
+        rotate("clipper", 90);
+      }
+  </script>
+</svg>
+
index 0657938..64fd293 100644 (file)
@@ -1,3 +1,19 @@
+2012-05-15  Florin Malita  <fmalita@chromium.org>
+
+        Mask deformations when masked content is rotated
+        https://bugs.webkit.org/show_bug.cgi?id=76527
+
+        Reviewed by Nikolas Zimmermann.
+
+        Test: svg/repaint/mask-clip-target-transform.svg
+
+        RenderSVGResource::markForLayoutAndParentResourceInvalidation() needs to also
+        invalidate parent mask and clip resources, not just filters.
+
+        * rendering/svg/RenderSVGResource.cpp:
+        (WebCore::removeFromCacheAndInvalidateDependencies):
+        (WebCore::RenderSVGResource::markForLayoutAndParentResourceInvalidation):
+
 2012-05-15  Pavel Feldman  <pfeldman@chromium.org>
 
         Web Inspector: merge show navigator with pin navigator buttons.
index 4fc5e23..fd16ef2 100644 (file)
 
 #include "Frame.h"
 #include "FrameView.h"
+#include "RenderSVGResourceClipper.h"
 #include "RenderSVGResourceContainer.h"
 #include "RenderSVGResourceFilter.h"
+#include "RenderSVGResourceMasker.h"
 #include "RenderSVGResourceSolidColor.h"
 #include "SVGResources.h"
 #include "SVGResourcesCache.h"
@@ -161,15 +163,21 @@ RenderSVGResourceSolidColor* RenderSVGResource::sharedSolidPaintingResource()
     return s_sharedSolidPaintingResource;
 }
 
-static inline void removeFromFilterCacheAndInvalidateDependencies(RenderObject* object, bool needsLayout)
+static inline void removeFromCacheAndInvalidateDependencies(RenderObject* object, bool needsLayout)
 {
     ASSERT(object);
-#if ENABLE(FILTERS)
     if (SVGResources* resources = SVGResourcesCache::cachedResourcesForRenderObject(object)) {
+#if ENABLE(FILTERS)
         if (RenderSVGResourceFilter* filter = resources->filter())
             filter->removeClientFromCache(object);
-    }
 #endif
+        if (RenderSVGResourceMasker* masker = resources->masker())
+            masker->removeClientFromCache(object);
+
+        if (RenderSVGResourceClipper* clipper = resources->clipper())
+            clipper->removeClientFromCache(object);
+    }
+
     if (!object->node() || !object->node()->isSVGElement())
         return;
     HashSet<SVGElement*>* dependencies = object->document()->accessSVGExtensions()->setOfElementsReferencingTarget(static_cast<SVGElement*>(object->node()));
@@ -191,12 +199,12 @@ void RenderSVGResource::markForLayoutAndParentResourceInvalidation(RenderObject*
     if (needsLayout)
         object->setNeedsLayout(true);
 
-    removeFromFilterCacheAndInvalidateDependencies(object, needsLayout);
+    removeFromCacheAndInvalidateDependencies(object, needsLayout);
 
     // Invalidate resources in ancestor chain, if needed.
     RenderObject* current = object->parent();
     while (current) {
-        removeFromFilterCacheAndInvalidateDependencies(current, needsLayout);
+        removeFromCacheAndInvalidateDependencies(current, needsLayout);
 
         if (current->isSVGResourceContainer()) {
             // This will process the rest of the ancestors.