<!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>[179063] branches/safari-600.1.4.15-branch/Source/WebCore</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/179063">179063</a></dd>
<dt>Author</dt> <dd>ddkilzer@apple.com</dd>
<dt>Date</dt> <dd>2015-01-24 09:00:27 -0800 (Sat, 24 Jan 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>Merged <a href="http://trac.webkit.org/projects/webkit/changeset/174356">r174356</a>.  rdar://problem/19419853</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#branchessafari6001415branchSourceWebCoreChangeLog">branches/safari-600.1.4.15-branch/Source/WebCore/ChangeLog</a></li>
<li><a href="#branchessafari6001415branchSourceWebCorerenderingRenderLayercpp">branches/safari-600.1.4.15-branch/Source/WebCore/rendering/RenderLayer.cpp</a></li>
<li><a href="#branchessafari6001415branchSourceWebCorerenderingRenderLayerh">branches/safari-600.1.4.15-branch/Source/WebCore/rendering/RenderLayer.h</a></li>
<li><a href="#branchessafari6001415branchSourceWebCorerenderingRenderLayerCompositorcpp">branches/safari-600.1.4.15-branch/Source/WebCore/rendering/RenderLayerCompositor.cpp</a></li>
<li><a href="#branchessafari6001415branchSourceWebCorerenderingRenderLayerCompositorh">branches/safari-600.1.4.15-branch/Source/WebCore/rendering/RenderLayerCompositor.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="branchessafari6001415branchSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-600.1.4.15-branch/Source/WebCore/ChangeLog (179062 => 179063)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.1.4.15-branch/Source/WebCore/ChangeLog        2015-01-24 17:00:24 UTC (rev 179062)
+++ branches/safari-600.1.4.15-branch/Source/WebCore/ChangeLog        2015-01-24 17:00:27 UTC (rev 179063)
</span><span class="lines">@@ -1,3 +1,33 @@
</span><ins>+2015-01-24  David Kilzer  &lt;ddkilzer@apple.com&gt;
+
+        Merge r174356.
+
+    2014-10-06  Simon Fraser  &lt;simon.fraser@apple.com&gt;
+
+        Some compositing logic cleanup
+        https://bugs.webkit.org/show_bug.cgi?id=133060
+
+        Reviewed by Zalan Bujtas.
+
+        Move compositing-related code from RenderLayer::styleChanged() to
+        RenderLayerCompositor::layerStyleChanged(). Combine various tests
+        (many clip-related) for changes that require layer rebuilding into 
+        styleChangeRequiresLayerRebuild().
+        
+        Remove code that calls setBackingNeedsRepaint() after filters change
+        between being composited or not; I verified that existing &quot;repaint after
+        style change&quot; code takes care those repaints.
+
+        * rendering/RenderLayer.cpp:
+        (WebCore::RenderLayer::calculateClipRects):
+        (WebCore::RenderLayer::checkIfDescendantClippingContextNeedsUpdate): Deleted.
+        * rendering/RenderLayer.h:
+        * rendering/RenderLayerCompositor.cpp:
+        (WebCore::checkIfDescendantClippingContextNeedsUpdate):
+        (WebCore::styleChangeRequiresLayerRebuild):
+        (WebCore::RenderLayerCompositor::layerStyleChanged):
+        * rendering/RenderLayerCompositor.h:
+
</ins><span class="cx"> 2015-01-23  Pratik Solanki  &lt;psolanki@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         &lt;rdar://problem/19564738&gt; Stowe: CrashTracer: [USER] com.apple.WebKit.WebContent at com.apple.WebCore: WebCore::SharedBuffer::createPurgeableBuffer const + 14
</span></span></pre></div>
<a id="branchessafari6001415branchSourceWebCorerenderingRenderLayercpp"></a>
<div class="modfile"><h4>Modified: branches/safari-600.1.4.15-branch/Source/WebCore/rendering/RenderLayer.cpp (179062 => 179063)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.1.4.15-branch/Source/WebCore/rendering/RenderLayer.cpp        2015-01-24 17:00:24 UTC (rev 179062)
+++ branches/safari-600.1.4.15-branch/Source/WebCore/rendering/RenderLayer.cpp        2015-01-24 17:00:27 UTC (rev 179063)
</span><span class="lines">@@ -1150,21 +1150,6 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-// Return true if the new clipping behaviour requires layer update.
-bool RenderLayer::checkIfDescendantClippingContextNeedsUpdate(bool isClipping)
-{
-    for (RenderLayer* child = firstChild(); child; child = child-&gt;nextSibling()) {
-        RenderLayerBacking* backing = child-&gt;backing();
-        // Layer subtree needs update when new clipping is added or existing clipping is removed.
-        if (backing &amp;&amp; (isClipping || backing-&gt;hasAncestorClippingLayer()))
-            return true;
-
-        if (child-&gt;checkIfDescendantClippingContextNeedsUpdate(isClipping))
-            return true;
-    }
-    return false;
-}
-
</del><span class="cx"> void RenderLayer::dirty3DTransformedDescendantStatus()
</span><span class="cx"> {
</span><span class="cx">     RenderLayer* curr = stackingContainer();
</span><span class="lines">@@ -6374,18 +6359,6 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-inline bool RenderLayer::needsCompositingLayersRebuiltForClip(const RenderStyle* oldStyle, const RenderStyle* newStyle) const
-{
-    ASSERT(newStyle);
-    return oldStyle &amp;&amp; (oldStyle-&gt;clip() != newStyle-&gt;clip() || oldStyle-&gt;hasClip() != newStyle-&gt;hasClip());
-}
-
-inline bool RenderLayer::needsCompositingLayersRebuiltForOverflow(const RenderStyle* oldStyle, const RenderStyle* newStyle) const
-{
-    ASSERT(newStyle);
-    return !isComposited() &amp;&amp; oldStyle &amp;&amp; (oldStyle-&gt;overflowX() != newStyle-&gt;overflowX()) &amp;&amp; stackingContainer()-&gt;hasCompositingDescendant();
-}
-
</del><span class="cx"> void RenderLayer::styleChanged(StyleDifference diff, const RenderStyle* oldStyle)
</span><span class="cx"> {
</span><span class="cx">     bool isNormalFlowOnly = shouldBeNormalFlowOnly();
</span><span class="lines">@@ -6442,28 +6415,9 @@
</span><span class="cx"> 
</span><span class="cx">     updateNeedsCompositedScrolling();
</span><span class="cx"> 
</span><del>-    const RenderStyle&amp; newStyle = renderer().style();
-    if (compositor().updateLayerCompositingState(*this)
-        || needsCompositingLayersRebuiltForClip(oldStyle, &amp;newStyle)
-        || needsCompositingLayersRebuiltForOverflow(oldStyle, &amp;newStyle))
-        compositor().setCompositingLayersNeedRebuild();
-    else if (isComposited()) {
-        // FIXME: updating geometry here is potentially harmful, because layout is not up-to-date.
-        backing()-&gt;updateGeometry();
-        backing()-&gt;updateAfterDescendents();
-    }
</del><ins>+    compositor().layerStyleChanged(*this, oldStyle);
</ins><span class="cx"> 
</span><del>-    if (oldStyle) {
-        // Compositing layers keep track of whether they are clipped by any of the ancestors.
-        // When the current layer's clipping behaviour changes, we need to propagate it to the descendants.
-        const RenderStyle&amp; style = renderer().style();
-        bool wasClipping = oldStyle-&gt;hasClip() || oldStyle-&gt;overflowX() != OVISIBLE || oldStyle-&gt;overflowY() != OVISIBLE;
-        bool isClipping = style.hasClip() || style.overflowX() != OVISIBLE || style.overflowY() != OVISIBLE;
-        if (isClipping != wasClipping) {
-            if (checkIfDescendantClippingContextNeedsUpdate(isClipping))
-                compositor().setCompositingLayersNeedRebuild();
-        }
-    }
</del><ins>+    updateOrRemoveFilterEffectRenderer();
</ins><span class="cx"> 
</span><span class="cx"> #if PLATFORM(IOS) &amp;&amp; ENABLE(TOUCH_EVENTS)
</span><span class="cx">     if (diff == StyleDifferenceRecompositeLayer || diff &gt;= StyleDifferenceLayoutPositionedMovementOnly)
</span><span class="lines">@@ -6471,16 +6425,6 @@
</span><span class="cx"> #else
</span><span class="cx">     UNUSED_PARAM(diff);
</span><span class="cx"> #endif
</span><del>-
-#if ENABLE(CSS_FILTERS)
-    updateOrRemoveFilterEffectRenderer();
-    bool backingDidCompositeLayers = isComposited() &amp;&amp; backing()-&gt;canCompositeFilters();
-    if (isComposited() &amp;&amp; backingDidCompositeLayers &amp;&amp; !backing()-&gt;canCompositeFilters()) {
-        // The filters used to be drawn by platform code, but now the platform cannot draw them anymore.
-        // Fallback to drawing them in software.
-        setBackingNeedsRepaint();
-    }
-#endif
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void RenderLayer::updateScrollableAreaSet(bool hasOverflow)
</span><span class="lines">@@ -6633,7 +6577,7 @@
</span><span class="cx">         // Don't delete the whole filter info here, because we might use it
</span><span class="cx">         // for loading SVG reference filter files.
</span><span class="cx">         if (FilterInfo* filterInfo = FilterInfo::getIfExists(*this))
</span><del>-            filterInfo-&gt;setRenderer(0);
</del><ins>+            filterInfo-&gt;setRenderer(nullptr);
</ins><span class="cx"> 
</span><span class="cx">         // Early-return only if we *don't* have reference filters.
</span><span class="cx">         // For reference filters, we still want the FilterEffect graph built
</span><span class="lines">@@ -6660,7 +6604,7 @@
</span><span class="cx">     // If the filter fails to build, remove it from the layer. It will still attempt to
</span><span class="cx">     // go through regular processing (e.g. compositing), but never apply anything.
</span><span class="cx">     if (!filterInfo.renderer()-&gt;build(&amp;renderer(), renderer().style().filter(), FilterProperty))
</span><del>-        filterInfo.setRenderer(0);
</del><ins>+        filterInfo.setRenderer(nullptr);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void RenderLayer::filterNeedsRepaint()
</span></span></pre></div>
<a id="branchessafari6001415branchSourceWebCorerenderingRenderLayerh"></a>
<div class="modfile"><h4>Modified: branches/safari-600.1.4.15-branch/Source/WebCore/rendering/RenderLayer.h (179062 => 179063)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.1.4.15-branch/Source/WebCore/rendering/RenderLayer.h        2015-01-24 17:00:24 UTC (rev 179062)
+++ branches/safari-600.1.4.15-branch/Source/WebCore/rendering/RenderLayer.h        2015-01-24 17:00:27 UTC (rev 179063)
</span><span class="lines">@@ -829,8 +829,6 @@
</span><span class="cx">     virtual GraphicsLayer* layerForScrollCorner() const override;
</span><span class="cx">     virtual bool usesCompositedScrolling() const override;
</span><span class="cx">     bool needsCompositedScrolling() const;
</span><del>-    bool needsCompositingLayersRebuiltForClip(const RenderStyle* oldStyle, const RenderStyle* newStyle) const;
-    bool needsCompositingLayersRebuiltForOverflow(const RenderStyle* oldStyle, const RenderStyle* newStyle) const;
</del><span class="cx"> 
</span><span class="cx">     bool paintsWithTransparency(PaintBehavior paintBehavior) const
</span><span class="cx">     {
</span><span class="lines">@@ -1105,7 +1103,6 @@
</span><span class="cx">     void setAncestorChainHasVisibleDescendant();
</span><span class="cx"> 
</span><span class="cx">     void updateDescendantDependentFlags(HashSet&lt;const RenderObject*&gt;* outOfFlowDescendantContainingBlocks = nullptr);
</span><del>-    bool checkIfDescendantClippingContextNeedsUpdate(bool isClipping);
</del><span class="cx"> 
</span><span class="cx">     bool has3DTransformedDescendant() const { return m_has3DTransformedDescendant; }
</span><span class="cx"> 
</span></span></pre></div>
<a id="branchessafari6001415branchSourceWebCorerenderingRenderLayerCompositorcpp"></a>
<div class="modfile"><h4>Modified: branches/safari-600.1.4.15-branch/Source/WebCore/rendering/RenderLayerCompositor.cpp (179062 => 179063)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.1.4.15-branch/Source/WebCore/rendering/RenderLayerCompositor.cpp        2015-01-24 17:00:24 UTC (rev 179062)
+++ branches/safari-600.1.4.15-branch/Source/WebCore/rendering/RenderLayerCompositor.cpp        2015-01-24 17:00:27 UTC (rev 179063)
</span><span class="lines">@@ -838,6 +838,54 @@
</span><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+static bool checkIfDescendantClippingContextNeedsUpdate(const RenderLayer&amp; layer, bool isClipping)
+{
+    for (RenderLayer* child = layer.firstChild(); child; child = child-&gt;nextSibling()) {
+        RenderLayerBacking* backing = child-&gt;backing();
+        if (backing &amp;&amp; (isClipping || backing-&gt;hasAncestorClippingLayer()))
+            return true;
+
+        if (checkIfDescendantClippingContextNeedsUpdate(*child, isClipping))
+            return true;
+    }
+    return false;
+}
+
+static bool styleChangeRequiresLayerRebuild(const RenderLayer&amp; layer, const RenderStyle&amp; oldStyle, const RenderStyle&amp; newStyle)
+{
+    // Clip can affect ancestor compositing bounds, so we need recompute overlap when it changes on a non-composited layer.
+    // FIXME: we should avoid doing this for all clip changes.
+    if (oldStyle.clip() != newStyle.clip() || oldStyle.hasClip() != newStyle.hasClip())
+        return true;
+
+    // When overflow changes, composited layers may need to update their ancestorClipping layers.
+    if (!layer.isComposited() &amp;&amp; (oldStyle.overflowX() != newStyle.overflowX()) &amp;&amp; layer.stackingContainer()-&gt;hasCompositingDescendant())
+        return true;
+
+    // Compositing layers keep track of whether they are clipped by any of the ancestors.
+    // When the current layer's clipping behaviour changes, we need to propagate it to the descendants.
+    bool wasClipping = oldStyle.hasClip() || oldStyle.overflowX() != OVISIBLE || oldStyle.overflowY() != OVISIBLE;
+    bool isClipping = newStyle.hasClip() || newStyle.overflowX() != OVISIBLE || newStyle.overflowY() != OVISIBLE;
+    if (isClipping != wasClipping) {
+        if (checkIfDescendantClippingContextNeedsUpdate(layer, isClipping))
+            return true;
+    }
+
+    return false;
+}
+
+void RenderLayerCompositor::layerStyleChanged(RenderLayer&amp; layer, const RenderStyle* oldStyle)
+{
+    const RenderStyle&amp; newStyle = layer.renderer().style();
+    if (updateLayerCompositingState(layer) || (oldStyle &amp;&amp; styleChangeRequiresLayerRebuild(layer, *oldStyle, newStyle)))
+        setCompositingLayersNeedRebuild();
+    else if (layer.isComposited()) {
+        // FIXME: updating geometry here is potentially harmful, because layout is not up-to-date.
+        layer.backing()-&gt;updateGeometry();
+        layer.backing()-&gt;updateAfterDescendents();
+    }
+}
+
</ins><span class="cx"> bool RenderLayerCompositor::updateBacking(RenderLayer&amp; layer, CompositingChangeRepaint shouldRepaint)
</span><span class="cx"> {
</span><span class="cx">     bool layerChanged = false;
</span></span></pre></div>
<a id="branchessafari6001415branchSourceWebCorerenderingRenderLayerCompositorh"></a>
<div class="modfile"><h4>Modified: branches/safari-600.1.4.15-branch/Source/WebCore/rendering/RenderLayerCompositor.h (179062 => 179063)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.1.4.15-branch/Source/WebCore/rendering/RenderLayerCompositor.h        2015-01-24 17:00:24 UTC (rev 179062)
+++ branches/safari-600.1.4.15-branch/Source/WebCore/rendering/RenderLayerCompositor.h        2015-01-24 17:00:27 UTC (rev 179063)
</span><span class="lines">@@ -169,6 +169,8 @@
</span><span class="cx">     void layerWasAdded(RenderLayer&amp; parent, RenderLayer&amp; child);
</span><span class="cx">     void layerWillBeRemoved(RenderLayer&amp; parent, RenderLayer&amp; child);
</span><span class="cx"> 
</span><ins>+    void layerStyleChanged(RenderLayer&amp;, const RenderStyle* oldStyle);
+
</ins><span class="cx">     // Get the nearest ancestor layer that has overflow or clip, but is not a stacking context
</span><span class="cx">     RenderLayer* enclosingNonStackingClippingLayer(const RenderLayer&amp;) const;
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>