<!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>[185392] 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/185392">185392</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2015-06-09 16:24:12 -0700 (Tue, 09 Jun 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>feComposite filter does not clip the paint rect to its effect rect when the operator is 'in' or 'atop'
https://bugs.webkit.org/show_bug.cgi?id=137856

Patch by Said Abou-Hallawa &lt;sabouhallawa@apple.com&gt; on 2015-06-09
Reviewed by Darin Adler.

Source/WebCore:

There was bug in calculating the absolutePaintRect of the feComposite filter
when the operator is equal to 'in' or 'atop'. The absolutePaintRect was set
to the absolutePaintRect of the background FilterEffect which is correct.
What was missing is clipping this rectangle to the maxEffectRect of the
filter which we do for other operators.

Tests: svg/filters/feComposite-background-rect-control-operators.svg

* platform/graphics/IntRect.h:
(WebCore::operator-=):
(WebCore::operator-): Add new operators to IntRect.

* platform/graphics/filters/FEComposite.cpp:
(WebCore::FEComposite::determineAbsolutePaintRect): Make sure the filter
absolutePaintRect is clipped to maxEffectRect for all operators.

(WebCore::FEComposite::platformApplySoftware): Code clean-up.

* platform/graphics/filters/FilterEffect.cpp:
(WebCore::FilterEffect::determineAbsolutePaintRect): Move the clipping
part to a separate function.

(WebCore::FilterEffect::clipAbsolutePaintRect): Clip the absolutePaintRect
to the maxEffectRect of the filter.

* platform/graphics/filters/FilterEffect.h:

LayoutTests:

* svg/filters/feComposite-background-rect-control-operators-expected.svg: Added.
* svg/filters/feComposite-background-rect-control-operators.svg: Added.
Ensure the painting rect of the feComposite filter with operator 'in' or
'atop' is clipped to its bounding rectangle</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsIntRecth">trunk/Source/WebCore/platform/graphics/IntRect.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsfiltersFECompositecpp">trunk/Source/WebCore/platform/graphics/filters/FEComposite.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsfiltersFilterEffectcpp">trunk/Source/WebCore/platform/graphics/filters/FilterEffect.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsfiltersFilterEffecth">trunk/Source/WebCore/platform/graphics/filters/FilterEffect.h</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestssvgfiltersfeCompositebackgroundrectcontroloperatorsexpectedsvg">trunk/LayoutTests/svg/filters/feComposite-background-rect-control-operators-expected.svg</a></li>
<li><a href="#trunkLayoutTestssvgfiltersfeCompositebackgroundrectcontroloperatorssvg">trunk/LayoutTests/svg/filters/feComposite-background-rect-control-operators.svg</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (185391 => 185392)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2015-06-09 23:22:19 UTC (rev 185391)
+++ trunk/LayoutTests/ChangeLog        2015-06-09 23:24:12 UTC (rev 185392)
</span><span class="lines">@@ -1,3 +1,15 @@
</span><ins>+2015-06-09  Said Abou-Hallawa  &lt;sabouhallawa@apple.com&gt;
+
+        feComposite filter does not clip the paint rect to its effect rect when the operator is 'in' or 'atop'
+        https://bugs.webkit.org/show_bug.cgi?id=137856
+
+        Reviewed by Darin Adler.
+
+        * svg/filters/feComposite-background-rect-control-operators-expected.svg: Added.
+        * svg/filters/feComposite-background-rect-control-operators.svg: Added.
+        Ensure the painting rect of the feComposite filter with operator 'in' or
+        'atop' is clipped to its bounding rectangle
+
</ins><span class="cx"> 2015-06-09  Yusuke Suzuki  &lt;utatane.tea@gmail.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Introduce getter definition into static hash tables and use it for getters in RegExp.prototype.
</span></span></pre></div>
<a id="trunkLayoutTestssvgfiltersfeCompositebackgroundrectcontroloperatorsexpectedsvg"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/svg/filters/feComposite-background-rect-control-operators-expected.svg (0 => 185392)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/svg/filters/feComposite-background-rect-control-operators-expected.svg                                (rev 0)
+++ trunk/LayoutTests/svg/filters/feComposite-background-rect-control-operators-expected.svg        2015-06-09 23:24:12 UTC (rev 185392)
</span><span class="lines">@@ -0,0 +1,4 @@
</span><ins>+&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot; width=&quot;200&quot; height=&quot;100&quot;&gt;
+  &lt;rect x=&quot;20&quot; y=&quot;20&quot; width=&quot;60&quot; height=&quot;60&quot; fill=&quot;green&quot;/&gt;
+  &lt;rect x=&quot;120&quot; y=&quot;20&quot; width=&quot;60&quot; height=&quot;60&quot; fill=&quot;green&quot;/&gt;
+&lt;/svg&gt;
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkLayoutTestssvgfiltersfeCompositebackgroundrectcontroloperatorssvg"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/svg/filters/feComposite-background-rect-control-operators.svg (0 => 185392)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/svg/filters/feComposite-background-rect-control-operators.svg                                (rev 0)
+++ trunk/LayoutTests/svg/filters/feComposite-background-rect-control-operators.svg        2015-06-09 23:24:12 UTC (rev 185392)
</span><span class="lines">@@ -0,0 +1,14 @@
</span><ins>+&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; xmlns:xlink=&quot;http://www.w3.org/1999/xlink&quot; width=&quot;200&quot; height=&quot;100&quot;&gt;
+  &lt;filter id=&quot;filter-in&quot; filterUnits=&quot;objectBoundingBox&quot; primitiveUnits=&quot;objectBoundingBox&quot; x=&quot;0&quot; y=&quot;0&quot; width=&quot;1&quot; height=&quot;1&quot;&gt;
+    &lt;feFlood flood-color=&quot;orange&quot; x=&quot;0&quot; y=&quot;0&quot; width=&quot;0.9&quot; height=&quot;0.9&quot; result=&quot;flood-orange&quot;/&gt;
+    &lt;feFlood flood-color=&quot;green&quot; x=&quot;0.1&quot; y=&quot;0.1&quot; width=&quot;0.9&quot; height=&quot;0.9&quot; result=&quot;flood-green&quot;/&gt;
+    &lt;feComposite x=&quot;0.2&quot; y=&quot;0.2&quot; width=&quot;0.6&quot; height=&quot;0.6&quot; operator=&quot;in&quot; in=&quot;flood-green&quot; in2=&quot;flood-orange&quot;/&gt;
+  &lt;/filter&gt;
+  &lt;filter id=&quot;filter-atop&quot; filterUnits=&quot;objectBoundingBox&quot; primitiveUnits=&quot;objectBoundingBox&quot; x=&quot;0&quot; y=&quot;0&quot; width=&quot;1&quot; height=&quot;1&quot;&gt;
+    &lt;feFlood flood-color=&quot;orange&quot; x=&quot;0&quot; y=&quot;0&quot; width=&quot;0.8&quot; height=&quot;0.8&quot; result=&quot;flood-orange&quot;/&gt;
+    &lt;feFlood flood-color=&quot;green&quot; x=&quot;0.2&quot; y=&quot;0.2&quot; width=&quot;0.8&quot; height=&quot;0.8&quot; result=&quot;flood-green&quot;/&gt;
+    &lt;feComposite x=&quot;0.2&quot; y=&quot;0.2&quot; width=&quot;0.8&quot; height=&quot;0.8&quot; operator=&quot;atop&quot; in=&quot;flood-green&quot; in2=&quot;flood-orange&quot;/&gt;
+  &lt;/filter&gt;
+  &lt;rect x=  &quot;0&quot; y=&quot;0&quot; width=&quot;100&quot; height=&quot;100&quot; fill=&quot;red&quot; filter=&quot;url(#filter-in)&quot;/&gt;
+  &lt;rect x=&quot;100&quot; y=&quot;0&quot; width=&quot;100&quot; height=&quot;100&quot; fill=&quot;red&quot; filter=&quot;url(#filter-atop)&quot;/&gt;
+&lt;/svg&gt;
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (185391 => 185392)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-06-09 23:22:19 UTC (rev 185391)
+++ trunk/Source/WebCore/ChangeLog        2015-06-09 23:24:12 UTC (rev 185392)
</span><span class="lines">@@ -1,3 +1,37 @@
</span><ins>+2015-06-09  Said Abou-Hallawa  &lt;sabouhallawa@apple.com&gt;
+
+        feComposite filter does not clip the paint rect to its effect rect when the operator is 'in' or 'atop'
+        https://bugs.webkit.org/show_bug.cgi?id=137856
+
+        Reviewed by Darin Adler.
+
+        There was bug in calculating the absolutePaintRect of the feComposite filter
+        when the operator is equal to 'in' or 'atop'. The absolutePaintRect was set
+        to the absolutePaintRect of the background FilterEffect which is correct.
+        What was missing is clipping this rectangle to the maxEffectRect of the
+        filter which we do for other operators.
+
+        Tests: svg/filters/feComposite-background-rect-control-operators.svg
+
+        * platform/graphics/IntRect.h:
+        (WebCore::operator-=):
+        (WebCore::operator-): Add new operators to IntRect.
+
+        * platform/graphics/filters/FEComposite.cpp:
+        (WebCore::FEComposite::determineAbsolutePaintRect): Make sure the filter
+        absolutePaintRect is clipped to maxEffectRect for all operators.
+        
+        (WebCore::FEComposite::platformApplySoftware): Code clean-up.
+        
+        * platform/graphics/filters/FilterEffect.cpp:
+        (WebCore::FilterEffect::determineAbsolutePaintRect): Move the clipping
+        part to a separate function.
+        
+        (WebCore::FilterEffect::clipAbsolutePaintRect): Clip the absolutePaintRect
+        to the maxEffectRect of the filter.
+        
+        * platform/graphics/filters/FilterEffect.h:
+
</ins><span class="cx"> 2015-06-09  Matt Rajca  &lt;mrajca@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Implement MediaSessionManager to keep track of all MediaSessions.
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsIntRecth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/IntRect.h (185391 => 185392)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/IntRect.h        2015-06-09 23:22:19 UTC (rev 185391)
+++ trunk/Source/WebCore/platform/graphics/IntRect.h        2015-06-09 23:24:12 UTC (rev 185392)
</span><span class="lines">@@ -216,6 +216,18 @@
</span><span class="cx">     return a.location() != b.location() || a.size() != b.size();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+inline IntRect&amp; operator-=(IntRect&amp; r, const IntPoint&amp; offset)
+{
+    r.move(-offset.x(), -offset.y());
+    return r;
+}
+
+inline IntRect operator-(const IntRect&amp; r, const IntPoint&amp; offset)
+{
+    IntRect t = r;
+    return t -= offset;
+}
+
</ins><span class="cx"> #if USE(CG)
</span><span class="cx"> WEBCORE_EXPORT IntRect enclosingIntRect(const CGRect&amp;);
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsfiltersFECompositecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/filters/FEComposite.cpp (185391 => 185392)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/filters/FEComposite.cpp        2015-06-09 23:22:19 UTC (rev 185391)
+++ trunk/Source/WebCore/platform/graphics/filters/FEComposite.cpp        2015-06-09 23:24:12 UTC (rev 185392)
</span><span class="lines">@@ -235,6 +235,7 @@
</span><span class="cx">         // For In and Atop the first effect just influences the result of
</span><span class="cx">         // the second effect. So just use the absolute paint rect of the second effect here.
</span><span class="cx">         setAbsolutePaintRect(inputEffect(1)-&gt;absolutePaintRect());
</span><ins>+        clipAbsolutePaintRect();
</ins><span class="cx">         return;
</span><span class="cx">     case FECOMPOSITE_OPERATOR_ARITHMETIC:
</span><span class="cx">         // Arithmetic may influnce the compele filter primitive region. So we can't
</span><span class="lines">@@ -290,13 +291,11 @@
</span><span class="cx">         destinationRect.intersect(absolutePaintRect());
</span><span class="cx">         if (destinationRect.isEmpty())
</span><span class="cx">             break;
</span><del>-        IntPoint destinationPoint(destinationRect.x() - absolutePaintRect().x(), destinationRect.y() - absolutePaintRect().y());
-        IntRect sourceRect(IntPoint(destinationRect.x() - in-&gt;absolutePaintRect().x(),
-                                    destinationRect.y() - in-&gt;absolutePaintRect().y()), destinationRect.size());
-        IntRect source2Rect(IntPoint(destinationRect.x() - in2-&gt;absolutePaintRect().x(),
-                                     destinationRect.y() - in2-&gt;absolutePaintRect().y()), destinationRect.size());
-        filterContext-&gt;drawImageBuffer(imageBuffer2, ColorSpaceDeviceRGB, IntRect(destinationPoint, source2Rect.size()), source2Rect);
-        filterContext-&gt;drawImageBuffer(imageBuffer, ColorSpaceDeviceRGB, IntRect(destinationPoint, sourceRect.size()), sourceRect, CompositeSourceIn);
</del><ins>+        IntRect adjustedDestinationRect = destinationRect - absolutePaintRect().location();
+        IntRect sourceRect = destinationRect - in-&gt;absolutePaintRect().location();
+        IntRect source2Rect = destinationRect - in2-&gt;absolutePaintRect().location();
+        filterContext-&gt;drawImageBuffer(imageBuffer2, ColorSpaceDeviceRGB, adjustedDestinationRect, source2Rect);
+        filterContext-&gt;drawImageBuffer(imageBuffer, ColorSpaceDeviceRGB, adjustedDestinationRect, sourceRect, CompositeSourceIn);
</ins><span class="cx">         break;
</span><span class="cx">     }
</span><span class="cx">     case FECOMPOSITE_OPERATOR_OUT:
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsfiltersFilterEffectcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/filters/FilterEffect.cpp (185391 => 185392)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/filters/FilterEffect.cpp        2015-06-09 23:22:19 UTC (rev 185391)
+++ trunk/Source/WebCore/platform/graphics/filters/FilterEffect.cpp        2015-06-09 23:24:12 UTC (rev 185392)
</span><span class="lines">@@ -56,16 +56,18 @@
</span><span class="cx"> void FilterEffect::determineAbsolutePaintRect()
</span><span class="cx"> {
</span><span class="cx">     m_absolutePaintRect = IntRect();
</span><del>-    unsigned size = m_inputEffects.size();
-    for (unsigned i = 0; i &lt; size; ++i)
-        m_absolutePaintRect.unite(m_inputEffects.at(i)-&gt;absolutePaintRect());
-    
</del><ins>+    for (auto&amp; effect : m_inputEffects)
+        m_absolutePaintRect.unite(effect-&gt;absolutePaintRect());
+    clipAbsolutePaintRect();
+}
+
+void FilterEffect::clipAbsolutePaintRect()
+{
</ins><span class="cx">     // Filters in SVG clip to primitive subregion, while CSS doesn't.
</span><span class="cx">     if (m_clipsToBounds)
</span><span class="cx">         m_absolutePaintRect.intersect(enclosingIntRect(m_maxEffectRect));
</span><span class="cx">     else
</span><span class="cx">         m_absolutePaintRect.unite(enclosingIntRect(m_maxEffectRect));
</span><del>-    
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> IntRect FilterEffect::requestedRegionOfInputImageData(const IntRect&amp; effectRect) const
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsfiltersFilterEffecth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/filters/FilterEffect.h (185391 => 185392)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/filters/FilterEffect.h        2015-06-09 23:22:19 UTC (rev 185391)
+++ trunk/Source/WebCore/platform/graphics/filters/FilterEffect.h        2015-06-09 23:24:12 UTC (rev 185392)
</span><span class="lines">@@ -177,6 +177,8 @@
</span><span class="cx">     // If a pre-multiplied image, check every pixel for validity and correct if necessary.
</span><span class="cx">     void forceValidPreMultipliedPixels();
</span><span class="cx"> 
</span><ins>+    void clipAbsolutePaintRect();
+
</ins><span class="cx"> private:
</span><span class="cx">     std::unique_ptr&lt;ImageBuffer&gt; m_imageBufferResult;
</span><span class="cx">     RefPtr&lt;Uint8ClampedArray&gt; m_unmultipliedImageResult;
</span></span></pre>
</div>
</div>

</body>
</html>