<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[175847] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/175847">175847</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2014-11-10 19:25:36 -0800 (Mon, 10 Nov 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>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 &lt;sabouhallawa@apple.com&gt; 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 &lt;sabouhallawa@apple.com&gt; 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:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsplatformmacsvgzoompagezoomforeignObjectexpectedtxt">trunk/LayoutTests/platform/mac/svg/zoom/page/zoom-foreignObject-expected.txt</a></li>
<li><a href="#trunkLayoutTestssvgzoompagezoomforeigncontentexpectedtxt">trunk/LayoutTests/svg/zoom/page/zoom-foreign-content-expected.txt</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorerenderingsvgRenderSVGForeignObjectcpp">trunk/Source/WebCore/rendering/svg/RenderSVGForeignObject.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingsvgRenderSVGForeignObjecth">trunk/Source/WebCore/rendering/svg/RenderSVGForeignObject.h</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestssvgtransformssvgtransformforeignobjectrepaintexpectedpng">trunk/LayoutTests/svg/transforms/svg-transform-foreign-object-repaint-expected.png</a></li>
<li><a href="#trunkLayoutTestssvgtransformssvgtransformforeignobjectrepaintexpectedtxt">trunk/LayoutTests/svg/transforms/svg-transform-foreign-object-repaint-expected.txt</a></li>
<li><a href="#trunkLayoutTestssvgtransformssvgtransformforeignobjectrepainthtml">trunk/LayoutTests/svg/transforms/svg-transform-foreign-object-repaint.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (175846 => 175847)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2014-11-11 03:10:13 UTC (rev 175846)
+++ trunk/LayoutTests/ChangeLog        2014-11-11 03:25:36 UTC (rev 175847)
</span><span class="lines">@@ -1,3 +1,23 @@
</span><ins>+2014-11-10  Said Abou-Hallawa  &lt;sabouhallawa@apple.com&gt;
+
+        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:
+
</ins><span class="cx"> 2014-11-10  Andreas Kling  &lt;akling@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         The JIT should cache property lookup misses.
</span></span></pre></div>
<a id="trunkLayoutTestsplatformmacsvgzoompagezoomforeignObjectexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/mac/svg/zoom/page/zoom-foreignObject-expected.txt (175846 => 175847)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -16,12 +16,12 @@
</span><span class="cx">           text run at (0,0) width 56: &quot;[HTML]&quot;
</span><span class="cx">     RenderSVGRect {rect} at (0,0) size 361x289 [stroke={[type=SOLID] [color=#008000]}] [x=0.00] [y=0.00] [width=250.00] [height=200.00]
</span><span class="cx">     RenderSVGForeignObject {foreignObject} at (260,0) size 250x200
</span><del>-      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)}]
</del><ins>+      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)}]
</ins><span class="cx">           RenderSVGText {text} at (0,1) size 82x19 contains 1 chunk(s)
</span><span class="cx">             RenderSVGInlineText {#text} at (0,0) size 82x19
</span><span class="cx">               chunk 1 text run 1 at (0.00,16.00) startOffset 0 endOffset 14 width 81.05: &quot;This is a text&quot;
</span><del>-          RenderSVGContainer {a} at (265,62) size 204x74
</del><ins>+          RenderSVGContainer {a} at (381,89) size 295x107
</ins><span class="cx">             RenderSVGText {text} at (0,20) size 67x19 contains 1 chunk(s)
</span><span class="cx">               RenderSVGInlineText {#text} at (0,0) size 67x19
</span><span class="cx">                 chunk 1 text run 1 at (0.00,35.00) startOffset 0 endOffset 11 width 66.16: &quot;and a link.&quot;
</span></span></pre></div>
<a id="trunkLayoutTestssvgtransformssvgtransformforeignobjectrepaintexpectedpng"></a>
<div class="binary"><h4>Added: trunk/LayoutTests/svg/transforms/svg-transform-foreign-object-repaint-expected.png</h4>
<pre class="diff"><span>
<span class="cx">(Binary files differ)
</span></span></pre></div>
<span class="cx">Property changes on: trunk/LayoutTests/svg/transforms/svg-transform-foreign-object-repaint-expected.png
</span><span class="cx">___________________________________________________________________
</span><a id="svnmimetype"></a>
<div class="addfile"><h4>Added: svn:mime-type</h4></div>
<a id="trunkLayoutTestssvgtransformssvgtransformforeignobjectrepaintexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/svg/transforms/svg-transform-foreign-object-repaint-expected.txt (0 => 175847)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -0,0 +1,6 @@
</span><ins>+(repaint rects
+  (rect 58 58 100 100)
+  (rect 58 58 100 100)
+  (rect 58 58 100 100)
+)
+
</ins></span></pre></div>
<a id="trunkLayoutTestssvgtransformssvgtransformforeignobjectrepainthtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/svg/transforms/svg-transform-foreign-object-repaint.html (0 => 175847)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -0,0 +1,54 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+  &lt;head&gt;
+    &lt;style&gt;
+      .box {
+        height: 100px;
+        width: 100px;
+        background-color: red;
+      }
+      .changed {
+        background-color: green;
+      }
+      pre {
+        color: transparent;
+      }
+    &lt;/style&gt;
+  &lt;/head&gt;
+  &lt;body&gt;
+    &lt;svg width=&quot;100%&quot; height=&quot;300&quot;&gt;
+      &lt;g transform=&quot;translate(50, 50)&quot;&gt;
+        &lt;foreignobject width=&quot;100&quot; height=&quot;100&quot; stroke=&quot;blue&quot;&gt;
+          &lt;div class=&quot;box&quot;/&gt;
+        &lt;/foreignobject&gt;
+      &lt;/g&gt;
+    &lt;/svg&gt;
+    &lt;script&gt;
+      if (window.testRunner)
+        testRunner.dumpAsText(true);
+
+      function changeBackground() {
+        var elements = document.getElementsByClassName(&quot;box&quot;);
+        elements[0].classList.add('changed');
+        
+        if (window.testRunner &amp;&amp; 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 &amp;&amp; window.internals) {
+        window.internals.startTrackingRepaints();
+        testRunner.waitUntilDone();
+      }
+    
+      setTimeout(changeBackground, 20);
+    &lt;/script&gt;
+  &lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestssvgzoompagezoomforeigncontentexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/svg/zoom/page/zoom-foreign-content-expected.txt (175846 => 175847)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -3,8 +3,8 @@
</span><span class="cx"> layer at (0,0) size 800x600
</span><span class="cx">   RenderSVGRoot {svg} at (0,0) size 800x600
</span><span class="cx">     RenderSVGForeignObject {foreignObject} at (0,0) size 800x600
</span><del>-      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]
</del><ins>+      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]
</ins><span class="cx">       RenderText {#text} at (0,0) size 0x0
</span><span class="cx">     RenderSVGForeignObject {foreignObject} at (0,0) size 800x600
</span><span class="cx">       RenderBlock {html} at (0,0) size 800x99
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (175846 => 175847)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -1,3 +1,28 @@
</span><ins>+2014-11-10  Said Abou-Hallawa  &lt;sabouhallawa@apple.com&gt;
+
+        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:
+
</ins><span class="cx"> 2014-11-10  Gyuyoung Kim  &lt;gyuyoung.kim@samsung.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Use std::unique_ptr&lt;&gt; and std::make_unique&lt;&gt; in WebCore
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingsvgRenderSVGForeignObjectcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/svg/RenderSVGForeignObject.cpp (175846 => 175847)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -102,6 +102,13 @@
</span><span class="cx">     SVGRenderSupport::computeFloatRectForRepaint(*this, repaintContainer, repaintRect, fixed);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void RenderSVGForeignObject::computeRectForRepaint(const RenderLayerModelObject* repaintContainer, LayoutRect&amp; repaintRect, bool fixed) const
+{
+    FloatRect floatRect(repaintRect);
+    computeFloatRectForRepaint(repaintContainer, floatRect, fixed);
+    repaintRect = enclosingLayoutRect(floatRect);
+}
+
</ins><span class="cx"> const AffineTransform&amp; RenderSVGForeignObject::localToParentTransform() const
</span><span class="cx"> {
</span><span class="cx">     m_localToParentTransform = localTransform();
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingsvgRenderSVGForeignObjecth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/svg/RenderSVGForeignObject.h (175846 => 175847)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -41,6 +41,7 @@
</span><span class="cx"> 
</span><span class="cx">     virtual LayoutRect clippedOverflowRectForRepaint(const RenderLayerModelObject* repaintContainer) const override;
</span><span class="cx">     virtual void computeFloatRectForRepaint(const RenderLayerModelObject* repaintContainer, FloatRect&amp;, bool fixed = false) const override;
</span><ins>+    virtual void computeRectForRepaint(const RenderLayerModelObject* repaintContainer, LayoutRect&amp;, bool fixed = false) const override;
</ins><span class="cx"> 
</span><span class="cx">     virtual bool requiresLayer() const override { return false; }
</span><span class="cx">     virtual void layout() override;
</span></span></pre>
</div>
</div>

</body>
</html>