<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>155288</bug_id>
          
          <creation_ts>2016-03-09 21:11:36 -0800</creation_ts>
          <short_desc>Compositing layer is too large when inner element has a blur that is within bounds</short_desc>
          <delta_ts>2016-03-09 23:26:45 -0800</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>Layout and Rendering</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>OS X 10.11</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>INVALID</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          <dependson>81239</dependson>
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Jon Lee">jonlee</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>dino</cc>
    
    <cc>simon.fraser</cc>
    
    <cc>zalan</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1172991</commentid>
    <comment_count>0</comment_count>
      <attachid>273543</attachid>
    <who name="Jon Lee">jonlee</who>
    <bug_when>2016-03-09 21:11:36 -0800</bug_when>
    <thetext>Created attachment 273543
Sample test case

See attached test case. The first example has:

&lt;div class=&quot;container&quot;&gt;
	&lt;div class=&quot;particle&quot; style=&quot;filter:blur(10px)&quot;&gt;&lt;/div&gt;
&lt;/div&gt;

particle is fixed 80x80, the container is 100x100. The 10px blur should make the particle 100x100 large, but the compositing layer (see web inspector) shows a 136x136 layer.

For example 2, the blur on the container should be 120x120, but it&apos;s 156x156 instead.

It&apos;s strange in example 3 that the layer is 100x100, but the blur extends past.

I think example 4 is correct?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1173006</commentid>
    <comment_count>1</comment_count>
    <who name="Simon Fraser (smfr)">simon.fraser</who>
    <bug_when>2016-03-09 22:38:02 -0800</bug_when>
    <thetext>For the first square:
renderer().style().filterOutsets().expandRect(unionBounds);
is adding 28px on each side for the 10px blur. This comes from outsetSizeForBlur() which has this comment:
    // We take the half kernel size and multiply it with three, because we run box blur three times.

The kernel size is 19x19, which is computed by:
    unsigned size = std::max&lt;unsigned&gt;(2, static_cast&lt;unsigned&gt;(floorf(value * gaussianKernelFactor() + 0.5f)));
where gaussianKernelFactor() returns 1.87997127

This is emulating the suggested approximation the SVG spec &lt;https://www.w3.org/TR/SVG/filters.html#feGaussianBlurElement&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1173007</commentid>
    <comment_count>2</comment_count>
    <who name="Simon Fraser (smfr)">simon.fraser</who>
    <bug_when>2016-03-09 23:01:59 -0800</bug_when>
    <thetext>http://dbaron.org/log/20110225-blur-radius also explains this well.
&quot;The SVG feGaussianBlur filter primitive has a stdDeviation attribute, which takes the standard deviation (σ) of the Gaussian blur. So in SVG, the number given is half the number that you would give to get the same blur with CSS or canvas.&quot;

I think when dbaron says &quot;with CSS&quot; he&apos;s referring to box-shadow. The CSS blur filter matches SVG.

This means that &quot;filter: blur(10px)&quot; and &quot;box-shadow: 0 0 10px black&quot; don&apos;t match which is sad.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1173010</commentid>
    <comment_count>3</comment_count>
    <who name="Simon Fraser (smfr)">simon.fraser</who>
    <bug_when>2016-03-09 23:18:56 -0800</bug_when>
    <thetext>For box-shadow we do this:
        // Blurring uses a Gaussian function whose std. deviation is m_radius/2, and which in theory
        // extends to infinity. In 8-bit contexts, however, rounding causes the effect to become
        // undetectable at around 1.4x the radius.
        const float radiusExtentMultiplier = 1.4;

but recall that box-shadow&apos;s &quot;radius&quot; is actually 2 * sigma, so I think this agrees with the 3 * 1.87997127 / 2 = 2.82 for SVG.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1173012</commentid>
    <comment_count>4</comment_count>
    <who name="Simon Fraser (smfr)">simon.fraser</who>
    <bug_when>2016-03-09 23:26:45 -0800</bug_when>
    <thetext>To summarize your test case:

First square: filter: blur(10px) extends the 80x80 circle by a factor of 10 * (3 * 1.87997127 / 2) = 28px on each side, so the resulting layer size is correct.

Second square: filter is composited, and extends the 100x100 container now by 28px per side, hence the 156x156.

Third square: filters apply after overflow:hidden, so it&apos;s clipped, then blurred.

Fourth square: filters apply after rect clipping, so it&apos;s clipped, then blurred.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>273543</attachid>
            <date>2016-03-09 21:11:36 -0800</date>
            <delta_ts>2016-03-09 21:11:36 -0800</delta_ts>
            <desc>Sample test case</desc>
            <filename>test2.html</filename>
            <type>text/html</type>
            <size>857</size>
            <attacher name="Jon Lee">jonlee</attacher>
            
              <data encoding="base64">PHN0eWxlPgouY29udGFpbmVyIHsKCWJhY2tncm91bmQtY29sb3I6IHllbGxvdzsKCXdpZHRoOiAx
MDBweDsKCWhlaWdodDogMTAwcHg7Cglwb3NpdGlvbjogcmVsYXRpdmU7Cgl0cmFuc2Zvcm06IHRy
YW5zbGF0ZVooMCk7Cn0KCi5wYXJ0aWNsZSB7Cglwb3NpdGlvbjogYWJzb2x1dGU7Cglib3JkZXIt
cmFkaXVzOiA1MCU7CgliYWNrZ3JvdW5kLWNvbG9yOiBncmVlbjsKCXdpZHRoOiA4MHB4OwoJaGVp
Z2h0OiA4MHB4OwoJdG9wOiAxMHB4OwoJbGVmdDogMTBweDsKfQo8L3N0eWxlPgo8cD4xMHB4IGJs
dXIgb24gdGhlIGlubmVyIHBhcnRpY2xlICg4MHB4KSwgY29udGFpbmVyIGlzIDE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