Title: [175847] trunk
Revision
175847
Author
commit-qu...@webkit.org
Date
2014-11-10 19:25:36 -0800 (Mon, 10 Nov 2014)

Log Message

Source/WebCore:
SVG foreign objects do not inherit the container coordinates system if they are repainted.
https://bugs.webkit.org/show_bug.cgi?id=138481.

Patch by Said Abou-Hallawa <sabouhall...@apple.com> on 2014-11-10
Reviewed by Simon Fraser.

If a foreign object is included in an SVG, it should inherit the coordinates system
of the container if it is repainted. The foreign object is actually redrawn in the
CSS coordinates system regardless of the transformation that may be applied to the
container.

The bug is RenderSVG* classes use computeFloatRectForRepaint(), but the rest of the
render classes use computeRectForRepaint(). RenderSVGForeignObject::computeRectForRepaint()
was not defined, so we end up hitting RenderObject::computeRectForRepaint() for
a RenderSVGTransformableContainer and completely miss the transform.

Tests: svg/transforms/svg-transform-foreign-object-repaint.html

Implement RenderSVGForeignObject::computeRectForRepaint() so we can apply the
container transformation on the SVG foreign object repaint rectangle.
* rendering/svg/RenderSVGForeignObject.cpp:
(WebCore::RenderSVGForeignObject::computeRectForRepaint):
* rendering/svg/RenderSVGForeignObject.h:

LayoutTests:
SVG foreign objects do not inherit the container coordinates system if they are repainted..
https://bugs.webkit.org/show_bug.cgi?id=138481.

Patch by Said Abou-Hallawa <sabouhall...@apple.com> on 2014-11-10
Reviewed by Simon Fraser.

Ensure the repaint rectangle of the SVG foreign object is calculated correctly
when the container element has transformation.

* svg/transforms/svg-transform-foreign-object-repaint-expected.png: Added.
* svg/transforms/svg-transform-foreign-object-repaint-expected.txt: Added.
* svg/transforms/svg-transform-foreign-object-repaint.html: Added.

Re-baseline these tests since the render tree dumping uses renderer.absoluteClippedOverflowRect()
in writePositionAndStyle() to get the object rectangle so this issue only affects test output.

* svg/zoom/page/zoom-foreign-content-expected.txt:
* platform/mac/svg/zoom/page/zoom-foreignObject-expected.txt:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (175846 => 175847)


--- trunk/LayoutTests/ChangeLog	2014-11-11 03:10:13 UTC (rev 175846)
+++ trunk/LayoutTests/ChangeLog	2014-11-11 03:25:36 UTC (rev 175847)
@@ -1,3 +1,23 @@
+2014-11-10  Said Abou-Hallawa  <sabouhall...@apple.com>
+
+        SVG foreign objects do not inherit the container coordinates system if they are repainted..
+        https://bugs.webkit.org/show_bug.cgi?id=138481.
+
+        Reviewed by Simon Fraser.
+
+        Ensure the repaint rectangle of the SVG foreign object is calculated correctly
+        when the container element has transformation.
+        
+        * svg/transforms/svg-transform-foreign-object-repaint-expected.png: Added.
+        * svg/transforms/svg-transform-foreign-object-repaint-expected.txt: Added.
+        * svg/transforms/svg-transform-foreign-object-repaint.html: Added.
+        
+        Re-baseline these tests since the render tree dumping uses renderer.absoluteClippedOverflowRect() 
+        in writePositionAndStyle() to get the object rectangle so this issue only affects test output.
+
+        * svg/zoom/page/zoom-foreign-content-expected.txt:
+        * platform/mac/svg/zoom/page/zoom-foreignObject-expected.txt:
+
 2014-11-10  Andreas Kling  <akl...@apple.com>
 
         The JIT should cache property lookup misses.

Modified: trunk/LayoutTests/platform/mac/svg/zoom/page/zoom-foreignObject-expected.txt (175846 => 175847)


--- trunk/LayoutTests/platform/mac/svg/zoom/page/zoom-foreignObject-expected.txt	2014-11-11 03:10:13 UTC (rev 175846)
+++ trunk/LayoutTests/platform/mac/svg/zoom/page/zoom-foreignObject-expected.txt	2014-11-11 03:25:36 UTC (rev 175847)
@@ -16,12 +16,12 @@
           text run at (0,0) width 56: "[HTML]"
     RenderSVGRect {rect} at (0,0) size 361x289 [stroke={[type=SOLID] [color=#008000]}] [x=0.00] [y=0.00] [width=250.00] [height=200.00]
     RenderSVGForeignObject {foreignObject} at (260,0) size 250x200
-      RenderSVGRoot {svg} at (260,5) size 250x195
-        RenderSVGContainer {g} at (260,5) size 250x195 [transform={m=((3.00,0.26)(0.26,3.02)) t=(0.00,0.00)}]
+      RenderSVGRoot {svg} at (374,7) size 361x281
+        RenderSVGContainer {g} at (374,7) size 361x281 [transform={m=((3.00,0.26)(0.26,3.02)) t=(0.00,0.00)}]
           RenderSVGText {text} at (0,1) size 82x19 contains 1 chunk(s)
             RenderSVGInlineText {#text} at (0,0) size 82x19
               chunk 1 text run 1 at (0.00,16.00) startOffset 0 endOffset 14 width 81.05: "This is a text"
-          RenderSVGContainer {a} at (265,62) size 204x74
+          RenderSVGContainer {a} at (381,89) size 295x107
             RenderSVGText {text} at (0,20) size 67x19 contains 1 chunk(s)
               RenderSVGInlineText {#text} at (0,0) size 67x19
                 chunk 1 text run 1 at (0.00,35.00) startOffset 0 endOffset 11 width 66.16: "and a link."

Added: trunk/LayoutTests/svg/transforms/svg-transform-foreign-object-repaint-expected.png


(Binary files differ)
Property changes on: trunk/LayoutTests/svg/transforms/svg-transform-foreign-object-repaint-expected.png ___________________________________________________________________

Added: svn:mime-type

Added: trunk/LayoutTests/svg/transforms/svg-transform-foreign-object-repaint-expected.txt (0 => 175847)


--- trunk/LayoutTests/svg/transforms/svg-transform-foreign-object-repaint-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/svg/transforms/svg-transform-foreign-object-repaint-expected.txt	2014-11-11 03:25:36 UTC (rev 175847)
@@ -0,0 +1,6 @@
+(repaint rects
+  (rect 58 58 100 100)
+  (rect 58 58 100 100)
+  (rect 58 58 100 100)
+)
+

Added: trunk/LayoutTests/svg/transforms/svg-transform-foreign-object-repaint.html (0 => 175847)


--- trunk/LayoutTests/svg/transforms/svg-transform-foreign-object-repaint.html	                        (rev 0)
+++ trunk/LayoutTests/svg/transforms/svg-transform-foreign-object-repaint.html	2014-11-11 03:25:36 UTC (rev 175847)
@@ -0,0 +1,54 @@
+<!DOCTYPE html>
+<html>
+  <head>
+    <style>
+      .box {
+        height: 100px;
+        width: 100px;
+        background-color: red;
+      }
+      .changed {
+        background-color: green;
+      }
+      pre {
+        color: transparent;
+      }
+    </style>
+  </head>
+  <body>
+    <svg width="100%" height="300">
+      <g transform="translate(50, 50)">
+        <foreignobject width="100" height="100" stroke="blue">
+          <div class="box"/>
+        </foreignobject>
+      </g>
+    </svg>
+    <script>
+      if (window.testRunner)
+        testRunner.dumpAsText(true);
+
+      function changeBackground() {
+        var elements = document.getElementsByClassName("box");
+        elements[0].classList.add('changed');
+        
+        if (window.testRunner && window.internals) {
+          var dummy = document.body.offsetTop;
+          var repaintRects = window.internals.repaintRectsAsText();
+          window.internals.stopTrackingRepaints();
+
+          var pre = document.createElement('pre');
+          document.body.appendChild(pre);
+          pre.innerHTML = repaintRects;
+          testRunner.notifyDone();
+        }
+      }
+      
+      if (window.testRunner && window.internals) {
+        window.internals.startTrackingRepaints();
+        testRunner.waitUntilDone();
+      }
+    
+      setTimeout(changeBackground, 20);
+    </script>
+  </body>
+</html>

Modified: trunk/LayoutTests/svg/zoom/page/zoom-foreign-content-expected.txt (175846 => 175847)


--- trunk/LayoutTests/svg/zoom/page/zoom-foreign-content-expected.txt	2014-11-11 03:10:13 UTC (rev 175846)
+++ trunk/LayoutTests/svg/zoom/page/zoom-foreign-content-expected.txt	2014-11-11 03:25:36 UTC (rev 175847)
@@ -3,8 +3,8 @@
 layer at (0,0) size 800x600
   RenderSVGRoot {svg} at (0,0) size 800x600
     RenderSVGForeignObject {foreignObject} at (0,0) size 800x600
-      RenderSVGRoot {svg} at (0,0) size 99x99
-        RenderSVGRect {rect} at (0,0) size 99x99 [fill={[type=SOLID] [color=#FF0000]}] [x=0.00] [y=0.00] [width=99.00] [height=99.00]
+      RenderSVGRoot {svg} at (0,0) size 206x206
+        RenderSVGRect {rect} at (0,0) size 206x206 [fill={[type=SOLID] [color=#FF0000]}] [x=0.00] [y=0.00] [width=99.00] [height=99.00]
       RenderText {#text} at (0,0) size 0x0
     RenderSVGForeignObject {foreignObject} at (0,0) size 800x600
       RenderBlock {html} at (0,0) size 800x99

Modified: trunk/Source/WebCore/ChangeLog (175846 => 175847)


--- trunk/Source/WebCore/ChangeLog	2014-11-11 03:10:13 UTC (rev 175846)
+++ trunk/Source/WebCore/ChangeLog	2014-11-11 03:25:36 UTC (rev 175847)
@@ -1,3 +1,28 @@
+2014-11-10  Said Abou-Hallawa  <sabouhall...@apple.com>
+
+        SVG foreign objects do not inherit the container coordinates system if they are repainted.
+        https://bugs.webkit.org/show_bug.cgi?id=138481.
+
+        Reviewed by Simon Fraser.
+
+        If a foreign object is included in an SVG, it should inherit the coordinates system
+        of the container if it is repainted. The foreign object is actually redrawn in the
+        CSS coordinates system regardless of the transformation that may be applied to the
+        container.
+
+        The bug is RenderSVG* classes use computeFloatRectForRepaint(), but the rest of the
+        render classes use computeRectForRepaint(). RenderSVGForeignObject::computeRectForRepaint()
+        was not defined, so we end up hitting RenderObject::computeRectForRepaint() for 
+        a RenderSVGTransformableContainer and completely miss the transform.
+
+        Tests: svg/transforms/svg-transform-foreign-object-repaint.html
+
+        Implement RenderSVGForeignObject::computeRectForRepaint() so we can apply the
+        container transformation on the SVG foreign object repaint rectangle.
+        * rendering/svg/RenderSVGForeignObject.cpp:
+        (WebCore::RenderSVGForeignObject::computeRectForRepaint):
+        * rendering/svg/RenderSVGForeignObject.h:
+
 2014-11-10  Gyuyoung Kim  <gyuyoung....@samsung.com>
 
         Use std::unique_ptr<> and std::make_unique<> in WebCore

Modified: trunk/Source/WebCore/rendering/svg/RenderSVGForeignObject.cpp (175846 => 175847)


--- trunk/Source/WebCore/rendering/svg/RenderSVGForeignObject.cpp	2014-11-11 03:10:13 UTC (rev 175846)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGForeignObject.cpp	2014-11-11 03:25:36 UTC (rev 175847)
@@ -102,6 +102,13 @@
     SVGRenderSupport::computeFloatRectForRepaint(*this, repaintContainer, repaintRect, fixed);
 }
 
+void RenderSVGForeignObject::computeRectForRepaint(const RenderLayerModelObject* repaintContainer, LayoutRect& repaintRect, bool fixed) const
+{
+    FloatRect floatRect(repaintRect);
+    computeFloatRectForRepaint(repaintContainer, floatRect, fixed);
+    repaintRect = enclosingLayoutRect(floatRect);
+}
+
 const AffineTransform& RenderSVGForeignObject::localToParentTransform() const
 {
     m_localToParentTransform = localTransform();

Modified: trunk/Source/WebCore/rendering/svg/RenderSVGForeignObject.h (175846 => 175847)


--- trunk/Source/WebCore/rendering/svg/RenderSVGForeignObject.h	2014-11-11 03:10:13 UTC (rev 175846)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGForeignObject.h	2014-11-11 03:25:36 UTC (rev 175847)
@@ -41,6 +41,7 @@
 
     virtual LayoutRect clippedOverflowRectForRepaint(const RenderLayerModelObject* repaintContainer) const override;
     virtual void computeFloatRectForRepaint(const RenderLayerModelObject* repaintContainer, FloatRect&, bool fixed = false) const override;
+    virtual void computeRectForRepaint(const RenderLayerModelObject* repaintContainer, LayoutRect&, bool fixed = false) const override;
 
     virtual bool requiresLayer() const override { return false; }
     virtual void layout() override;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to