<!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>[183710] 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/183710">183710</a></dd>
<dt>Author</dt> <dd>simon.fraser@apple.com</dd>
<dt>Date</dt> <dd>2015-05-01 19:32:29 -0700 (Fri, 01 May 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>Avoid compositing updates after style recalcs which have no compositing implications
https://bugs.webkit.org/show_bug.cgi?id=144502

Reviewed by Darin Adler.

Source/WebCore:

After <a href="http://trac.webkit.org/projects/webkit/changeset/183461">r183461</a>, we have reliable information about whether a style change with zero
diff can be reliably ignored. Use that information to track whether a given
recalcStyle() does anything which should force a compositing update.

This eliminates up to 40% of the post-recalcStyle compositing updates on some pages.

Add Internals API to test.

Test: compositing/updates/no-style-change-updates.html

* dom/Document.cpp:
(WebCore::Document::recalcStyle): Tell the FrameView we're going to recalc style.
* page/FrameView.cpp:
(WebCore::FrameView::willRecalcStyle): Pass it on to the compositor.
(WebCore::FrameView::updateCompositingLayersAfterStyleChange): Move the code
that was here into RenderLayerCompositor::didRecalcStyleWithNoPendingLayout().
* page/FrameView.h:
* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::willRecalcStyle): Reset the m_layerNeedsCompositingUpdate flag.
(WebCore::RenderLayerCompositor::didRecalcStyleWithNoPendingLayout): Bail on the update if
no layers changed.
(WebCore::RenderLayerCompositor::updateCompositingLayers): Logging. Increment m_compositingUpdateCount,
which is used for testing.
(WebCore::RenderLayerCompositor::layerStyleChanged): Set the m_layerNeedsCompositingUpdate flag.
(WebCore::RenderLayerCompositor::startTrackingCompositingUpdates): Reset the counter.
(WebCore::RenderLayerCompositor::compositingUpdateCount):
* rendering/RenderLayerCompositor.h:
* testing/Internals.cpp:
(WebCore::Internals::startTrackingCompositingUpdates):
(WebCore::Internals::compositingUpdateCount):
* testing/Internals.h:
* testing/Internals.idl:

LayoutTests:

Use internals.compositingUpdateCount() to see if various document mutations
cause a compositing update. Doesn't actually detect any behavior change
from this patch, but seems useful in general.

* compositing/updates/no-style-change-updates-expected.txt: Added.
* compositing/updates/no-style-change-updates.html: Added.</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="#trunkSourceWebCoredomDocumentcpp">trunk/Source/WebCore/dom/Document.cpp</a></li>
<li><a href="#trunkSourceWebCorepageFrameViewcpp">trunk/Source/WebCore/page/FrameView.cpp</a></li>
<li><a href="#trunkSourceWebCorepageFrameViewh">trunk/Source/WebCore/page/FrameView.h</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderLayerCompositorcpp">trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderLayerCompositorh">trunk/Source/WebCore/rendering/RenderLayerCompositor.h</a></li>
<li><a href="#trunkSourceWebCoretestingInternalscpp">trunk/Source/WebCore/testing/Internals.cpp</a></li>
<li><a href="#trunkSourceWebCoretestingInternalsh">trunk/Source/WebCore/testing/Internals.h</a></li>
<li><a href="#trunkSourceWebCoretestingInternalsidl">trunk/Source/WebCore/testing/Internals.idl</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li>trunk/LayoutTests/compositing/updates/</li>
<li><a href="#trunkLayoutTestscompositingupdatesnostylechangeupdatesexpectedtxt">trunk/LayoutTests/compositing/updates/no-style-change-updates-expected.txt</a></li>
<li><a href="#trunkLayoutTestscompositingupdatesnostylechangeupdateshtml">trunk/LayoutTests/compositing/updates/no-style-change-updates.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (183709 => 183710)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2015-05-02 02:23:01 UTC (rev 183709)
+++ trunk/LayoutTests/ChangeLog        2015-05-02 02:32:29 UTC (rev 183710)
</span><span class="lines">@@ -1,3 +1,17 @@
</span><ins>+2015-05-01  Simon Fraser  &lt;simon.fraser@apple.com&gt;
+
+        Avoid compositing updates after style recalcs which have no compositing implications
+        https://bugs.webkit.org/show_bug.cgi?id=144502
+
+        Reviewed by Darin Adler.
+        
+        Use internals.compositingUpdateCount() to see if various document mutations
+        cause a compositing update. Doesn't actually detect any behavior change
+        from this patch, but seems useful in general.
+
+        * compositing/updates/no-style-change-updates-expected.txt: Added.
+        * compositing/updates/no-style-change-updates.html: Added.
+
</ins><span class="cx"> 2015-05-01  Ryosuke Niwa  &lt;rniwa@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         Class syntax should allow string and numeric identifiers for method names
</span></span></pre></div>
<a id="trunkLayoutTestscompositingupdatesnostylechangeupdatesexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/compositing/updates/no-style-change-updates-expected.txt (0 => 183710)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/compositing/updates/no-style-change-updates-expected.txt                                (rev 0)
+++ trunk/LayoutTests/compositing/updates/no-style-change-updates-expected.txt        2015-05-02 02:32:29 UTC (rev 183710)
</span><span class="lines">@@ -0,0 +1,14 @@
</span><ins>+Test that compositing updates do not happen for style changes that do not need them.
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+PASS updateCount is 0
+PASS updateCount is 1
+PASS updateCount is 0
+PASS updateCount is 1
+PASS updateCount is 0
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestscompositingupdatesnostylechangeupdateshtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/compositing/updates/no-style-change-updates.html (0 => 183710)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/compositing/updates/no-style-change-updates.html                                (rev 0)
+++ trunk/LayoutTests/compositing/updates/no-style-change-updates.html        2015-05-02 02:32:29 UTC (rev 183710)
</span><span class="lines">@@ -0,0 +1,109 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+
+&lt;html&gt;
+&lt;head&gt;
+    &lt;style&gt;
+        .box {
+            width: 100px;
+            height: 100px;
+            margin: 10px;
+            background-color: blue;
+            border: 2px solid black;
+            -webkit-transform: translateZ(0);
+        }
+        
+        .colorchange {
+            background-color: green;
+        }
+        
+        .dummy {
+            /* Empty. */
+        }
+        
+    &lt;/style&gt;
+    &lt;script src=&quot;../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+    &lt;script&gt;
+        description('Test that compositing updates do not happen for style changes that do not need them.');
+        window.jsTestIsAsync = true;
+
+        var updateCount;
+        
+        function zeroUpdateCount()
+        {
+            if (window.internals) {
+                internals.updateLayoutIgnorePendingStylesheetsAndRunPostLayoutTasks();
+                internals.startTrackingCompositingUpdates();
+            }
+        }
+
+        function updateLayoutAndCompositingCount()
+        {
+            if (window.internals) {
+                internals.updateLayoutIgnorePendingStylesheetsAndRunPostLayoutTasks();
+                updateCount = internals.compositingUpdateCount();
+            }
+        }
+        
+        function testForCompositingUpdate(callback)
+        {
+            zeroUpdateCount();
+            callback();
+            updateLayoutAndCompositingCount();
+        }
+        
+        function runTest()
+        {
+            updateLayoutAndCompositingCount();
+
+            if (window.internals) {
+                internals.startTrackingCompositingUpdates();
+                updateCount = internals.compositingUpdateCount();
+            }
+
+            shouldBe('updateCount', '0');
+            
+            testForCompositingUpdate(function() {
+                document.getElementById('box').classList.add('colorchange');
+            });
+            
+            shouldBe('updateCount', '1');
+
+            testForCompositingUpdate(function() {
+                document.getElementById('box').classList.add('dummy');
+            });
+
+            shouldBe('updateCount', '0');
+            
+            testForCompositingUpdate(function() {
+                var div = document.createElement('div');
+                div.className = 'box';
+                document.body.appendChild(div);
+            });
+            
+            shouldBe('updateCount', '1');
+            
+            testForCompositingUpdate(function() {
+                var stylesheet = document.createElement('style');
+                stylesheet.type = 'text/css';
+                stylesheet.rel = 'stylesheet';
+                stylesheet.textContent = '.unmatched { border: 5px solid blue; }';
+                document.getElementsByTagName(&quot;head&quot;)[0].appendChild(stylesheet);
+            });
+            
+            shouldBe('updateCount', '0');
+
+            finishJSTest();
+        }
+        
+        window.addEventListener('load', function() {
+            window.setTimeout(runTest, 200);
+        }, false);
+    &lt;/script&gt;
+
+&lt;/head&gt;
+&lt;body&gt;
+    &lt;div id=&quot;box&quot; class=&quot;box&quot;&gt;&lt;/div&gt;
+
+    &lt;script src=&quot;../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (183709 => 183710)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-05-02 02:23:01 UTC (rev 183709)
+++ trunk/Source/WebCore/ChangeLog        2015-05-02 02:32:29 UTC (rev 183710)
</span><span class="lines">@@ -1,3 +1,43 @@
</span><ins>+2015-05-01  Simon Fraser  &lt;simon.fraser@apple.com&gt;
+
+        Avoid compositing updates after style recalcs which have no compositing implications
+        https://bugs.webkit.org/show_bug.cgi?id=144502
+
+        Reviewed by Darin Adler.
+        
+        After r183461, we have reliable information about whether a style change with zero
+        diff can be reliably ignored. Use that information to track whether a given
+        recalcStyle() does anything which should force a compositing update.
+        
+        This eliminates up to 40% of the post-recalcStyle compositing updates on some pages.
+        
+        Add Internals API to test.
+
+        Test: compositing/updates/no-style-change-updates.html
+
+        * dom/Document.cpp:
+        (WebCore::Document::recalcStyle): Tell the FrameView we're going to recalc style.
+        * page/FrameView.cpp:
+        (WebCore::FrameView::willRecalcStyle): Pass it on to the compositor.
+        (WebCore::FrameView::updateCompositingLayersAfterStyleChange): Move the code
+        that was here into RenderLayerCompositor::didRecalcStyleWithNoPendingLayout().
+        * page/FrameView.h:
+        * rendering/RenderLayerCompositor.cpp:
+        (WebCore::RenderLayerCompositor::willRecalcStyle): Reset the m_layerNeedsCompositingUpdate flag.
+        (WebCore::RenderLayerCompositor::didRecalcStyleWithNoPendingLayout): Bail on the update if
+        no layers changed.
+        (WebCore::RenderLayerCompositor::updateCompositingLayers): Logging. Increment m_compositingUpdateCount,
+        which is used for testing.
+        (WebCore::RenderLayerCompositor::layerStyleChanged): Set the m_layerNeedsCompositingUpdate flag.
+        (WebCore::RenderLayerCompositor::startTrackingCompositingUpdates): Reset the counter.
+        (WebCore::RenderLayerCompositor::compositingUpdateCount):
+        * rendering/RenderLayerCompositor.h:
+        * testing/Internals.cpp:
+        (WebCore::Internals::startTrackingCompositingUpdates):
+        (WebCore::Internals::compositingUpdateCount):
+        * testing/Internals.h:
+        * testing/Internals.idl:
+
</ins><span class="cx"> 2015-05-01  Andreas Kling  &lt;akling@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Reproducible crash removing name attribute from &lt;img&gt; node
</span></span></pre></div>
<a id="trunkSourceWebCoredomDocumentcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/Document.cpp (183709 => 183710)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/Document.cpp        2015-05-02 02:23:01 UTC (rev 183709)
+++ trunk/Source/WebCore/dom/Document.cpp        2015-05-02 02:32:29 UTC (rev 183710)
</span><span class="lines">@@ -1748,6 +1748,8 @@
</span><span class="cx"> 
</span><span class="cx">     m_styleSheetCollection.flushPendingUpdates();
</span><span class="cx"> 
</span><ins>+    frameView.willRecalcStyle();
+
</ins><span class="cx">     InspectorInstrumentationCookie cookie = InspectorInstrumentation::willRecalculateStyle(*this);
</span><span class="cx"> 
</span><span class="cx">     // FIXME: We never reset this flags.
</span></span></pre></div>
<a id="trunkSourceWebCorepageFrameViewcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/FrameView.cpp (183709 => 183710)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/FrameView.cpp        2015-05-02 02:23:01 UTC (rev 183709)
+++ trunk/Source/WebCore/page/FrameView.cpp        2015-05-02 02:32:29 UTC (rev 183710)
</span><span class="lines">@@ -728,6 +728,15 @@
</span><span class="cx">     }    
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void FrameView::willRecalcStyle()
+{
+    RenderView* renderView = this-&gt;renderView();
+    if (!renderView)
+        return;
+
+    renderView-&gt;compositor().willRecalcStyle();
+}
+
</ins><span class="cx"> void FrameView::updateCompositingLayersAfterStyleChange()
</span><span class="cx"> {
</span><span class="cx">     RenderView* renderView = this-&gt;renderView();
</span><span class="lines">@@ -738,10 +747,7 @@
</span><span class="cx">     if (inPreLayoutStyleUpdate() || layoutPending() || renderView-&gt;needsLayout())
</span><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    RenderLayerCompositor&amp; compositor = renderView-&gt;compositor();
-    // This call will make sure the cached hasAcceleratedCompositing is updated from the pref
-    compositor.cacheAcceleratedCompositingFlags();
-    compositor.updateCompositingLayers(CompositingUpdateAfterStyleChange);
</del><ins>+    renderView-&gt;compositor().didRecalcStyleWithNoPendingLayout();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void FrameView::updateCompositingLayersAfterLayout()
</span></span></pre></div>
<a id="trunkSourceWebCorepageFrameViewh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/FrameView.h (183709 => 183710)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/FrameView.h        2015-05-02 02:23:01 UTC (rev 183709)
+++ trunk/Source/WebCore/page/FrameView.h        2015-05-02 02:32:29 UTC (rev 183710)
</span><span class="lines">@@ -147,6 +147,7 @@
</span><span class="cx">     WEBCORE_EXPORT void serviceScriptedAnimations(double monotonicAnimationStartTime);
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+    void willRecalcStyle();
</ins><span class="cx">     void updateCompositingLayersAfterStyleChange();
</span><span class="cx">     void updateCompositingLayersAfterLayout();
</span><span class="cx">     bool flushCompositingStateForThisFrame(Frame* rootFrameForFlush);
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderLayerCompositorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp (183709 => 183710)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp        2015-05-02 02:23:01 UTC (rev 183709)
+++ trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp        2015-05-02 02:32:29 UTC (rev 183710)
</span><span class="lines">@@ -384,6 +384,20 @@
</span><span class="cx">         m_compositingLayersNeedRebuild = needRebuild;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void RenderLayerCompositor::willRecalcStyle()
+{
+    m_layerNeedsCompositingUpdate = false;
+}
+
+void RenderLayerCompositor::didRecalcStyleWithNoPendingLayout()
+{
+    if (!m_layerNeedsCompositingUpdate)
+        return;
+    
+    cacheAcceleratedCompositingFlags();
+    updateCompositingLayers(CompositingUpdateAfterStyleChange);
+}
+
</ins><span class="cx"> void RenderLayerCompositor::customPositionForVisibleRectComputation(const GraphicsLayer* graphicsLayer, FloatPoint&amp; position) const
</span><span class="cx"> {
</span><span class="cx">     if (graphicsLayer != m_scrollLayer.get())
</span><span class="lines">@@ -656,6 +670,8 @@
</span><span class="cx"> 
</span><span class="cx"> void RenderLayerCompositor::updateCompositingLayers(CompositingUpdateType updateType, RenderLayer* updateRoot)
</span><span class="cx"> {
</span><ins>+    LOG(Compositing, &quot;RenderLayerCompositor %p updateCompositingLayers %d %p&quot;, this, updateType, updateRoot);
+
</ins><span class="cx">     m_updateCompositingLayersTimer.stop();
</span><span class="cx"> 
</span><span class="cx">     ASSERT(!m_renderView.document().inPageCache());
</span><span class="lines">@@ -674,6 +690,8 @@
</span><span class="cx">     if (!m_reevaluateCompositingAfterLayout &amp;&amp; !m_compositing)
</span><span class="cx">         return;
</span><span class="cx"> 
</span><ins>+    ++m_compositingUpdateCount;
+
</ins><span class="cx">     AnimationUpdateBlock animationUpdateBlock(&amp;m_renderView.frameView().frame().animation());
</span><span class="cx"> 
</span><span class="cx">     TemporaryChange&lt;bool&gt; postLayoutChange(m_inPostLayoutUpdate, true);
</span><span class="lines">@@ -710,6 +728,8 @@
</span><span class="cx">     if (isFullUpdate &amp;&amp; updateType == CompositingUpdateAfterLayout)
</span><span class="cx">         m_reevaluateCompositingAfterLayout = false;
</span><span class="cx"> 
</span><ins>+    LOG(Compositing, &quot; checkForHierarchyUpdate %d, needGeometryUpdate %d&quot;, checkForHierarchyUpdate, needHierarchyUpdate);
+
</ins><span class="cx"> #if !LOG_DISABLED
</span><span class="cx">     double startTime = 0;
</span><span class="cx">     if (compositingLogEnabled()) {
</span><span class="lines">@@ -920,6 +940,8 @@
</span><span class="cx">     if (diff == StyleDifferenceEqual)
</span><span class="cx">         return;
</span><span class="cx"> 
</span><ins>+    m_layerNeedsCompositingUpdate = true;
+
</ins><span class="cx">     const RenderStyle&amp; newStyle = layer.renderer().style();
</span><span class="cx">     if (updateLayerCompositingState(layer) || (oldStyle &amp;&amp; styleChangeRequiresLayerRebuild(layer, *oldStyle, newStyle)))
</span><span class="cx">         setCompositingLayersNeedRebuild();
</span><span class="lines">@@ -4186,4 +4208,14 @@
</span><span class="cx">     return m_layerFlushCount;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void RenderLayerCompositor::startTrackingCompositingUpdates()
+{
+    m_compositingUpdateCount = 0;
+}
+
+unsigned RenderLayerCompositor::compositingUpdateCount() const
+{
+    return m_compositingUpdateCount;
+}
+
</ins><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderLayerCompositorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderLayerCompositor.h (183709 => 183710)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderLayerCompositor.h        2015-05-02 02:23:01 UTC (rev 183709)
+++ trunk/Source/WebCore/rendering/RenderLayerCompositor.h        2015-05-02 02:32:29 UTC (rev 183710)
</span><span class="lines">@@ -119,6 +119,9 @@
</span><span class="cx">     // created, destroyed or re-parented).
</span><span class="cx">     void setCompositingLayersNeedRebuild(bool needRebuild = true);
</span><span class="cx">     bool compositingLayersNeedRebuild() const { return m_compositingLayersNeedRebuild; }
</span><ins>+    
+    void willRecalcStyle();
+    void didRecalcStyleWithNoPendingLayout();
</ins><span class="cx"> 
</span><span class="cx">     // GraphicsLayers buffer state, which gets pushed to the underlying platform layers
</span><span class="cx">     // at specific times.
</span><span class="lines">@@ -311,6 +314,9 @@
</span><span class="cx">     WEBCORE_EXPORT void startTrackingLayerFlushes();
</span><span class="cx">     WEBCORE_EXPORT unsigned layerFlushCount() const;
</span><span class="cx"> 
</span><ins>+    WEBCORE_EXPORT void startTrackingCompositingUpdates();
+    WEBCORE_EXPORT unsigned compositingUpdateCount() const;
+
</ins><span class="cx"> private:
</span><span class="cx">     class OverlapMap;
</span><span class="cx">     struct CompositingState;
</span><span class="lines">@@ -498,6 +504,7 @@
</span><span class="cx">     int m_compositedLayerCount { 0 };
</span><span class="cx">     unsigned m_layersWithTiledBackingCount { 0 };
</span><span class="cx">     unsigned m_layerFlushCount { 0 };
</span><ins>+    unsigned m_compositingUpdateCount { 0 };
</ins><span class="cx"> 
</span><span class="cx">     RootLayerAttachment m_rootLayerAttachment;
</span><span class="cx"> 
</span><span class="lines">@@ -534,6 +541,7 @@
</span><span class="cx">     bool m_layerFlushThrottlingEnabled;
</span><span class="cx">     bool m_layerFlushThrottlingTemporarilyDisabledForInteraction;
</span><span class="cx">     bool m_hasPendingLayerFlush;
</span><ins>+    bool m_layerNeedsCompositingUpdate { false };
</ins><span class="cx"> 
</span><span class="cx">     Timer m_paintRelatedMilestonesTimer;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoretestingInternalscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/testing/Internals.cpp (183709 => 183710)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/testing/Internals.cpp        2015-05-02 02:23:01 UTC (rev 183709)
+++ trunk/Source/WebCore/testing/Internals.cpp        2015-05-02 02:32:29 UTC (rev 183710)
</span><span class="lines">@@ -2114,6 +2114,28 @@
</span><span class="cx">     return document-&gt;styleRecalcCount();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void Internals::startTrackingCompositingUpdates(ExceptionCode&amp; ec)
+{
+    Document* document = contextDocument();
+    if (!document || !document-&gt;renderView()) {
+        ec = INVALID_ACCESS_ERR;
+        return;
+    }
+
+    document-&gt;renderView()-&gt;compositor().startTrackingCompositingUpdates();
+}
+
+unsigned long Internals::compositingUpdateCount(ExceptionCode&amp; ec)
+{
+    Document* document = contextDocument();
+    if (!document || !document-&gt;renderView()) {
+        ec = INVALID_ACCESS_ERR;
+        return 0;
+    }
+    
+    return document-&gt;renderView()-&gt;compositor().compositingUpdateCount();
+}
+
</ins><span class="cx"> void Internals::updateLayoutIgnorePendingStylesheetsAndRunPostLayoutTasks(ExceptionCode&amp; ec)
</span><span class="cx"> {
</span><span class="cx">     updateLayoutIgnorePendingStylesheetsAndRunPostLayoutTasks(nullptr, ec);
</span></span></pre></div>
<a id="trunkSourceWebCoretestingInternalsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/testing/Internals.h (183709 => 183710)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/testing/Internals.h        2015-05-02 02:23:01 UTC (rev 183709)
+++ trunk/Source/WebCore/testing/Internals.h        2015-05-02 02:32:29 UTC (rev 183710)
</span><span class="lines">@@ -303,6 +303,9 @@
</span><span class="cx">     void startTrackingStyleRecalcs(ExceptionCode&amp;);
</span><span class="cx">     unsigned long styleRecalcCount(ExceptionCode&amp;);
</span><span class="cx"> 
</span><ins>+    void startTrackingCompositingUpdates(ExceptionCode&amp;);
+    unsigned long compositingUpdateCount(ExceptionCode&amp;);
+
</ins><span class="cx">     void updateLayoutIgnorePendingStylesheetsAndRunPostLayoutTasks(ExceptionCode&amp;);
</span><span class="cx">     void updateLayoutIgnorePendingStylesheetsAndRunPostLayoutTasks(Node*, ExceptionCode&amp;);
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoretestingInternalsidl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/testing/Internals.idl (183709 => 183710)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/testing/Internals.idl        2015-05-02 02:23:01 UTC (rev 183709)
+++ trunk/Source/WebCore/testing/Internals.idl        2015-05-02 02:32:29 UTC (rev 183710)
</span><span class="lines">@@ -280,6 +280,9 @@
</span><span class="cx">     [RaisesException] void startTrackingStyleRecalcs();
</span><span class="cx">     [RaisesException] unsigned long styleRecalcCount();
</span><span class="cx"> 
</span><ins>+    [RaisesException] void startTrackingCompositingUpdates();
+    [RaisesException] unsigned long compositingUpdateCount();
+
</ins><span class="cx">     // |node| should be Document, HTMLIFrameElement, or unspecified.
</span><span class="cx">     // If |node| is an HTMLIFrameElement, it assumes node.contentDocument is
</span><span class="cx">     // specified without security checks. Unspecified means this document.
</span></span></pre>
</div>
</div>

</body>
</html>