<!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>[170557] trunk/Source</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/170557">170557</a></dd>
<dt>Author</dt> <dd>antti@apple.com</dd>
<dt>Date</dt> <dd>2014-06-27 14:58:06 -0700 (Fri, 27 Jun 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Flush throttling with remote layers
https://bugs.webkit.org/show_bug.cgi?id=134398

Reviewed by Darin Adler.


Source/WebCore: 
With remote layer trees the flush scheduling lives in the WebKit2 layer. The throttling code
needs to live there as well.
        
Add the required callbacks and disable the existing throttling code in RenderLayerCompositor
when remote layers are in use. Later we can get rid of the RenderLayerCompositor throttling code.

* WebCore.xcodeproj/project.pbxproj:
* loader/FrameLoader.cpp:
(WebCore::FrameLoader::loadProgressingStatusChanged):
* page/ChromeClient.h:
(WebCore::ChromeClient::adjustLayerFlushThrottling):
* page/FrameView.cpp:
(WebCore::FrameView::disableLayerFlushThrottlingTemporarilyForInteraction):
(WebCore::FrameView::loadProgressingStatusChanged):
        
    Factor the progress status change activities to a function.

(WebCore::FrameView::updateLayerFlushThrottling):
(WebCore::FrameView::setExposedRect):
        
    Move the call to adjustTiledBackingCoverage from WebKit to here.

(WebCore::FrameView::updateLayerFlushThrottlingInAllFrames): Deleted.
* page/FrameView.h:
* page/LayerFlushThrottleState.h: Added.
* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::RenderLayerCompositor):

Source/WebKit2: 
* WebProcess/WebCoreSupport/WebChromeClient.cpp:
(WebKit::WebChromeClient::adjustLayerFlushThrottling):
* WebProcess/WebCoreSupport/WebChromeClient.h:
* WebProcess/WebCoreSupport/ios/WebChromeClientIOS.mm:
* WebProcess/WebPage/DrawingArea.h:
(WebKit::DrawingArea::adjustLayerFlushThrottling):
* WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.h:
* WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.mm:
(WebKit::RemoteLayerTreeDrawingArea::RemoteLayerTreeDrawingArea):
(WebKit::RemoteLayerTreeDrawingArea::updateScrolledExposedRect):
(WebKit::RemoteLayerTreeDrawingArea::scheduleCompositingLayerFlush):

    Delay layer flushes during page loading.
    If use interacts with the page the next flush in unthrottled even if loading is in progress.

(WebKit::RemoteLayerTreeDrawingArea::adjustLayerFlushThrottling):
        
    Compute the new delay. The first visual flush uses a shorter delay.
    Flush immediately when we are no longer throttling.

* WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm:
(WebKit::TiledCoreAnimationDrawingArea::updateScrolledExposedRect):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreWebCorexcodeprojprojectpbxproj">trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWebCoreloaderFrameLoadercpp">trunk/Source/WebCore/loader/FrameLoader.cpp</a></li>
<li><a href="#trunkSourceWebCorepageChromeClienth">trunk/Source/WebCore/page/ChromeClient.h</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="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebCoreSupportWebChromeClientcpp">trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebCoreSupportWebChromeClienth">trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebCoreSupportiosWebChromeClientIOSmm">trunk/Source/WebKit2/WebProcess/WebCoreSupport/ios/WebChromeClientIOS.mm</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPageDrawingAreah">trunk/Source/WebKit2/WebProcess/WebPage/DrawingArea.h</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPagemacRemoteLayerTreeDrawingAreah">trunk/Source/WebKit2/WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.h</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPagemacRemoteLayerTreeDrawingAreamm">trunk/Source/WebKit2/WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.mm</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPagemacTiledCoreAnimationDrawingAreamm">trunk/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebCorepageLayerFlushThrottleStateh">trunk/Source/WebCore/page/LayerFlushThrottleState.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (170556 => 170557)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-06-27 21:57:25 UTC (rev 170556)
+++ trunk/Source/WebCore/ChangeLog        2014-06-27 21:58:06 UTC (rev 170557)
</span><span class="lines">@@ -1,3 +1,38 @@
</span><ins>+2014-06-27  Antti Koivisto  &lt;antti@apple.com&gt;
+
+        Flush throttling with remote layers
+        https://bugs.webkit.org/show_bug.cgi?id=134398
+
+        Reviewed by Darin Adler.
+
+        With remote layer trees the flush scheduling lives in the WebKit2 layer. The throttling code
+        needs to live there as well.
+        
+        Add the required callbacks and disable the existing throttling code in RenderLayerCompositor
+        when remote layers are in use. Later we can get rid of the RenderLayerCompositor throttling code.
+
+        * WebCore.xcodeproj/project.pbxproj:
+        * loader/FrameLoader.cpp:
+        (WebCore::FrameLoader::loadProgressingStatusChanged):
+        * page/ChromeClient.h:
+        (WebCore::ChromeClient::adjustLayerFlushThrottling):
+        * page/FrameView.cpp:
+        (WebCore::FrameView::disableLayerFlushThrottlingTemporarilyForInteraction):
+        (WebCore::FrameView::loadProgressingStatusChanged):
+        
+            Factor the progress status change activities to a function.
+
+        (WebCore::FrameView::updateLayerFlushThrottling):
+        (WebCore::FrameView::setExposedRect):
+        
+            Move the call to adjustTiledBackingCoverage from WebKit to here.
+
+        (WebCore::FrameView::updateLayerFlushThrottlingInAllFrames): Deleted.
+        * page/FrameView.h:
+        * page/LayerFlushThrottleState.h: Added.
+        * rendering/RenderLayerCompositor.cpp:
+        (WebCore::RenderLayerCompositor::RenderLayerCompositor):
+
</ins><span class="cx"> 2014-06-27  Brady Eidson  &lt;beidson@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         The user pressing a button on a gamepad should cause gamepads to become visible to all NavigatorGamepads.
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (170556 => 170557)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2014-06-27 21:57:25 UTC (rev 170556)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2014-06-27 21:58:06 UTC (rev 170557)
</span><span class="lines">@@ -6150,6 +6150,7 @@
</span><span class="cx">                 E47E276816036EDC00EE2AFB /* DocumentStyleSheetCollection.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E47E276716036EDC00EE2AFB /* DocumentStyleSheetCollection.cpp */; };
</span><span class="cx">                 E48944A2180B57D800F165D8 /* SimpleLineLayout.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E48944A0180B57D800F165D8 /* SimpleLineLayout.cpp */; };
</span><span class="cx">                 E48944A3180B57D800F165D8 /* SimpleLineLayout.h in Headers */ = {isa = PBXBuildFile; fileRef = E48944A1180B57D800F165D8 /* SimpleLineLayout.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><ins>+                E4916FF7195DF6A0005AB349 /* LayerFlushThrottleState.h in Headers */ = {isa = PBXBuildFile; fileRef = E4916FF6195DF6A0005AB349 /* LayerFlushThrottleState.h */; settings = {ATTRIBUTES = (Private, ); }; };
</ins><span class="cx">                 E4946EAE156E64DD00D3297F /* StyleRuleImport.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4946EAC156E64DD00D3297F /* StyleRuleImport.cpp */; };
</span><span class="cx">                 E4946EAF156E64DD00D3297F /* StyleRuleImport.h in Headers */ = {isa = PBXBuildFile; fileRef = E4946EAD156E64DD00D3297F /* StyleRuleImport.h */; };
</span><span class="cx">                 E49BD9FA131FD2ED003C56F0 /* CSSValuePool.h in Headers */ = {isa = PBXBuildFile; fileRef = E49BD9F9131FD2ED003C56F0 /* CSSValuePool.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="lines">@@ -13647,6 +13648,7 @@
</span><span class="cx">                 E47E276716036EDC00EE2AFB /* DocumentStyleSheetCollection.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DocumentStyleSheetCollection.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 E48944A0180B57D800F165D8 /* SimpleLineLayout.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SimpleLineLayout.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 E48944A1180B57D800F165D8 /* SimpleLineLayout.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SimpleLineLayout.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                E4916FF6195DF6A0005AB349 /* LayerFlushThrottleState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LayerFlushThrottleState.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 E4946EAC156E64DD00D3297F /* StyleRuleImport.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StyleRuleImport.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 E4946EAD156E64DD00D3297F /* StyleRuleImport.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StyleRuleImport.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 E49BD9F9131FD2ED003C56F0 /* CSSValuePool.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSValuePool.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -16572,6 +16574,7 @@
</span><span class="cx">                                 BC94D1500C275C8B006BC617 /* History.cpp */,
</span><span class="cx">                                 BC94D1510C275C8B006BC617 /* History.h */,
</span><span class="cx">                                 BC94D1520C275C8B006BC617 /* History.idl */,
</span><ins>+                                E4916FF6195DF6A0005AB349 /* LayerFlushThrottleState.h */,
</ins><span class="cx">                                 931D72F515FE695300C4C07E /* LayoutMilestones.h */,
</span><span class="cx">                                 BCE1C41A0D982980003B02F2 /* Location.cpp */,
</span><span class="cx">                                 BCE1C4190D982980003B02F2 /* Location.h */,
</span><span class="lines">@@ -24362,6 +24365,7 @@
</span><span class="cx">                                 977B37241228721700B81FF8 /* HTMLElementStack.h in Headers */,
</span><span class="cx">                                 B562DB6017D3CD630010AF96 /* HTMLElementTypeHelpers.h in Headers */,
</span><span class="cx">                                 A871D45C0A127CBC00B12A68 /* HTMLEmbedElement.h in Headers */,
</span><ins>+                                E4916FF7195DF6A0005AB349 /* LayerFlushThrottleState.h in Headers */,
</ins><span class="cx">                                 977B386A122883E900B81FF8 /* HTMLEntityParser.h in Headers */,
</span><span class="cx">                                 977B386C122883E900B81FF8 /* HTMLEntitySearch.h in Headers */,
</span><span class="cx">                                 977B386D122883E900B81FF8 /* HTMLEntityTable.h in Headers */,
</span></span></pre></div>
<a id="trunkSourceWebCoreloaderFrameLoadercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/FrameLoader.cpp (170556 => 170557)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/FrameLoader.cpp        2014-06-27 21:57:25 UTC (rev 170556)
+++ trunk/Source/WebCore/loader/FrameLoader.cpp        2014-06-27 21:58:06 UTC (rev 170557)
</span><span class="lines">@@ -3408,12 +3408,8 @@
</span><span class="cx"> 
</span><span class="cx"> void FrameLoader::loadProgressingStatusChanged()
</span><span class="cx"> {
</span><del>-    FrameView* view = m_frame.mainFrame().view();
-    if (!view)
-        return;
-
-    view-&gt;updateLayerFlushThrottlingInAllFrames();
-    view-&gt;adjustTiledBackingCoverage();
</del><ins>+    if (auto* view = m_frame.mainFrame().view())
+        view-&gt;loadProgressingStatusChanged();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void FrameLoader::forcePageTransitionIfNeeded()
</span></span></pre></div>
<a id="trunkSourceWebCorepageChromeClienth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/ChromeClient.h (170556 => 170557)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/ChromeClient.h        2014-06-27 21:57:25 UTC (rev 170556)
+++ trunk/Source/WebCore/page/ChromeClient.h        2014-06-27 21:58:06 UTC (rev 170557)
</span><span class="lines">@@ -29,6 +29,7 @@
</span><span class="cx"> #include &quot;FrameLoader.h&quot;
</span><span class="cx"> #include &quot;GraphicsContext.h&quot;
</span><span class="cx"> #include &quot;HostWindow.h&quot;
</span><ins>+#include &quot;LayerFlushThrottleState.h&quot;
</ins><span class="cx"> #include &quot;PopupMenu.h&quot;
</span><span class="cx"> #include &quot;PopupMenuClient.h&quot;
</span><span class="cx"> #include &quot;RenderEmbeddedObject.h&quot;
</span><span class="lines">@@ -327,6 +328,8 @@
</span><span class="cx">     // Returns true if layer tree updates are disabled.
</span><span class="cx">     virtual bool layerTreeStateIsFrozen() const { return false; }
</span><span class="cx"> 
</span><ins>+    virtual bool adjustLayerFlushThrottling(LayerFlushThrottleState::Flags) { return false; }
+
</ins><span class="cx">     virtual PassRefPtr&lt;ScrollingCoordinator&gt; createScrollingCoordinator(Page*) const { return nullptr; }
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(WIN) &amp;&amp; USE(AVFOUNDATION)
</span></span></pre></div>
<a id="trunkSourceWebCorepageFrameViewcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/FrameView.cpp (170556 => 170557)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/FrameView.cpp        2014-06-27 21:57:25 UTC (rev 170556)
+++ trunk/Source/WebCore/page/FrameView.cpp        2014-06-27 21:58:06 UTC (rev 170557)
</span><span class="lines">@@ -2253,13 +2253,33 @@
</span><span class="cx"> 
</span><span class="cx"> void FrameView::disableLayerFlushThrottlingTemporarilyForInteraction()
</span><span class="cx"> {
</span><ins>+    bool mainLoadProgressing = frame().page()-&gt;progress().isMainLoadProgressing();
+
+    LayerFlushThrottleState::Flags flags = LayerFlushThrottleState::UserIsInteracting | (mainLoadProgressing ? LayerFlushThrottleState::MainLoadProgressing : 0);
+    if (frame().page()-&gt;chrome().client().adjustLayerFlushThrottling(flags))
+        return;
+
</ins><span class="cx">     if (RenderView* view = renderView())
</span><span class="cx">         view-&gt;compositor().disableLayerFlushThrottlingTemporarilyForInteraction();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void FrameView::updateLayerFlushThrottlingInAllFrames()
</del><ins>+void FrameView::loadProgressingStatusChanged()
</ins><span class="cx"> {
</span><ins>+    updateLayerFlushThrottling();
+    adjustTiledBackingCoverage();
+}
+
+void FrameView::updateLayerFlushThrottling()
+{
+    ASSERT(frame().isMainFrame());
+
</ins><span class="cx">     bool isMainLoadProgressing = frame().page()-&gt;progress().isMainLoadProgressing();
</span><ins>+
+    // See if the client is handling throttling.
+    LayerFlushThrottleState::Flags flags = isMainLoadProgressing ? LayerFlushThrottleState::MainLoadProgressing : 0;
+    if (frame().page()-&gt;chrome().client().adjustLayerFlushThrottling(flags))
+        return;
+
</ins><span class="cx">     for (Frame* frame = m_frame.get(); frame; frame = frame-&gt;tree().traverseNext(m_frame.get())) {
</span><span class="cx">         if (RenderView* renderView = frame-&gt;contentRenderer())
</span><span class="cx">             renderView-&gt;compositor().setLayerFlushThrottlingEnabled(isMainLoadProgressing);
</span><span class="lines">@@ -4420,8 +4440,10 @@
</span><span class="cx">     // FIXME: We should support clipping to the exposed rect for subframes as well.
</span><span class="cx">     if (!m_frame-&gt;isMainFrame())
</span><span class="cx">         return;
</span><del>-    if (TiledBacking* tiledBacking = this-&gt;tiledBacking())
</del><ins>+    if (TiledBacking* tiledBacking = this-&gt;tiledBacking()) {
+        adjustTiledBackingCoverage();
</ins><span class="cx">         tiledBacking-&gt;setTiledScrollingIndicatorPosition(exposedRect.location());
</span><ins>+    }
</ins><span class="cx"> 
</span><span class="cx">     if (auto* view = renderView())
</span><span class="cx">         view-&gt;compositor().scheduleLayerFlush(false /* canThrottle */);
</span></span></pre></div>
<a id="trunkSourceWebCorepageFrameViewh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/FrameView.h (170556 => 170557)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/FrameView.h        2014-06-27 21:57:25 UTC (rev 170556)
+++ trunk/Source/WebCore/page/FrameView.h        2014-06-27 21:58:06 UTC (rev 170557)
</span><span class="lines">@@ -290,9 +290,8 @@
</span><span class="cx">     bool fixedElementsLayoutRelativeToFrame() const;
</span><span class="cx"> 
</span><span class="cx">     void disableLayerFlushThrottlingTemporarilyForInteraction();
</span><del>-    void updateLayerFlushThrottlingInAllFrames();
-    void adjustTiledBackingCoverage();
</del><span class="cx">     bool speculativeTilingEnabled() const { return m_speculativeTilingEnabled; }
</span><ins>+    void loadProgressingStatusChanged();
</ins><span class="cx"> 
</span><span class="cx"> #if ENABLE(DASHBOARD_SUPPORT)
</span><span class="cx">     void updateAnnotatedRegions();
</span><span class="lines">@@ -544,6 +543,9 @@
</span><span class="cx">     void performPostLayoutTasks();
</span><span class="cx">     void autoSizeIfEnabled();
</span><span class="cx"> 
</span><ins>+    void updateLayerFlushThrottling();
+    void adjustTiledBackingCoverage();
+
</ins><span class="cx">     virtual void repaintContentRectangle(const IntRect&amp;) override;
</span><span class="cx">     virtual void contentsResized() override;
</span><span class="cx">     virtual void visibleContentsResized() override;
</span></span></pre></div>
<a id="trunkSourceWebCorepageLayerFlushThrottleStateh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/page/LayerFlushThrottleState.h (0 => 170557)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/LayerFlushThrottleState.h                                (rev 0)
+++ trunk/Source/WebCore/page/LayerFlushThrottleState.h        2014-06-27 21:58:06 UTC (rev 170557)
</span><span class="lines">@@ -0,0 +1,41 @@
</span><ins>+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef LayerFlushThrottleState_h
+#define LayerFlushThrottleState_h
+
+namespace WebCore {
+
+struct LayerFlushThrottleState {
+    enum {
+        MainLoadProgressing = 1 &lt;&lt; 0,
+        UserIsInteracting = 1 &lt;&lt; 1
+    };
+    typedef unsigned Flags;
+};
+
+} // namespace WebCore
+
+#endif // LayerFlushThrottleState_h
</ins></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderLayerCompositorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp (170556 => 170557)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp        2014-06-27 21:57:25 UTC (rev 170556)
+++ trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp        2014-06-27 21:58:06 UTC (rev 170557)
</span><span class="lines">@@ -45,7 +45,6 @@
</span><span class="cx"> #include &quot;MainFrame.h&quot;
</span><span class="cx"> #include &quot;NodeList.h&quot;
</span><span class="cx"> #include &quot;Page.h&quot;
</span><del>-#include &quot;ProgressTracker.h&quot;
</del><span class="cx"> #include &quot;RenderEmbeddedObject.h&quot;
</span><span class="cx"> #include &quot;RenderFlowThread.h&quot;
</span><span class="cx"> #include &quot;RenderFullScreen.h&quot;
</span><span class="lines">@@ -284,7 +283,7 @@
</span><span class="cx">     , m_layersWithTiledBackingCount(0)
</span><span class="cx">     , m_rootLayerAttachment(RootLayerUnattached)
</span><span class="cx">     , m_layerFlushTimer(this, &amp;RenderLayerCompositor::layerFlushTimerFired)
</span><del>-    , m_layerFlushThrottlingEnabled(page() &amp;&amp; page()-&gt;progress().isMainLoadProgressing())
</del><ins>+    , m_layerFlushThrottlingEnabled(false)
</ins><span class="cx">     , m_layerFlushThrottlingTemporarilyDisabledForInteraction(false)
</span><span class="cx">     , m_hasPendingLayerFlush(false)
</span><span class="cx">     , m_paintRelatedMilestonesTimer(this, &amp;RenderLayerCompositor::paintRelatedMilestonesTimerFired)
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (170556 => 170557)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2014-06-27 21:57:25 UTC (rev 170556)
+++ trunk/Source/WebKit2/ChangeLog        2014-06-27 21:58:06 UTC (rev 170557)
</span><span class="lines">@@ -1,3 +1,33 @@
</span><ins>+2014-06-27  Antti Koivisto  &lt;antti@apple.com&gt;
+
+        Flush throttling with remote layers
+        https://bugs.webkit.org/show_bug.cgi?id=134398
+
+        Reviewed by Darin Adler.
+
+        * WebProcess/WebCoreSupport/WebChromeClient.cpp:
+        (WebKit::WebChromeClient::adjustLayerFlushThrottling):
+        * WebProcess/WebCoreSupport/WebChromeClient.h:
+        * WebProcess/WebCoreSupport/ios/WebChromeClientIOS.mm:
+        * WebProcess/WebPage/DrawingArea.h:
+        (WebKit::DrawingArea::adjustLayerFlushThrottling):
+        * WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.h:
+        * WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.mm:
+        (WebKit::RemoteLayerTreeDrawingArea::RemoteLayerTreeDrawingArea):
+        (WebKit::RemoteLayerTreeDrawingArea::updateScrolledExposedRect):
+        (WebKit::RemoteLayerTreeDrawingArea::scheduleCompositingLayerFlush):
+
+            Delay layer flushes during page loading.
+            If use interacts with the page the next flush in unthrottled even if loading is in progress.
+
+        (WebKit::RemoteLayerTreeDrawingArea::adjustLayerFlushThrottling):
+        
+            Compute the new delay. The first visual flush uses a shorter delay.
+            Flush immediately when we are no longer throttling.
+
+        * WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm:
+        (WebKit::TiledCoreAnimationDrawingArea::updateScrolledExposedRect):
+
</ins><span class="cx"> 2014-06-27  Joseph Pecoraro  &lt;pecoraro@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [iOS][WK2] &lt;select&gt; tapping &quot;next&quot; does not save new picker value
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebCoreSupportWebChromeClientcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp (170556 => 170557)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp        2014-06-27 21:57:25 UTC (rev 170556)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp        2014-06-27 21:58:06 UTC (rev 170557)
</span><span class="lines">@@ -843,6 +843,10 @@
</span><span class="cx">         m_page-&gt;drawingArea()-&gt;scheduleCompositingLayerFlush();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+bool WebChromeClient::adjustLayerFlushThrottling(WebCore::LayerFlushThrottleState::Flags flags)
+{
+    return m_page-&gt;drawingArea() &amp;&amp; m_page-&gt;drawingArea()-&gt;adjustLayerFlushThrottling(flags);
+}
</ins><span class="cx"> 
</span><span class="cx"> bool WebChromeClient::layerTreeStateIsFrozen() const
</span><span class="cx"> {
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebCoreSupportWebChromeClienth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h (170556 => 170557)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h        2014-06-27 21:57:25 UTC (rev 170556)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h        2014-06-27 21:58:06 UTC (rev 170557)
</span><span class="lines">@@ -210,6 +210,7 @@
</span><span class="cx">     virtual void attachRootGraphicsLayer(WebCore::Frame*, WebCore::GraphicsLayer*) override;
</span><span class="cx">     virtual void setNeedsOneShotDrawingSynchronization() override;
</span><span class="cx">     virtual void scheduleCompositingLayerFlush() override;
</span><ins>+    virtual bool adjustLayerFlushThrottling(WebCore::LayerFlushThrottleState::Flags) override;
</ins><span class="cx">     virtual WebCore::GraphicsLayer* documentOverlayLayerForFrame(WebCore::Frame&amp;) override;
</span><span class="cx"> 
</span><span class="cx"> #if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebCoreSupportiosWebChromeClientIOSmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/ios/WebChromeClientIOS.mm (170556 => 170557)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/ios/WebChromeClientIOS.mm        2014-06-27 21:57:25 UTC (rev 170556)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/ios/WebChromeClientIOS.mm        2014-06-27 21:58:06 UTC (rev 170557)
</span><span class="lines">@@ -28,11 +28,12 @@
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx"> 
</span><del>-#import &lt;WebCore/NotImplemented.h&gt;
</del><ins>+#import &quot;DrawingArea.h&quot;
</ins><span class="cx"> #import &quot;WebCoreArgumentCoders.h&quot;
</span><span class="cx"> #import &quot;WebFrame.h&quot;
</span><span class="cx"> #import &quot;WebPage.h&quot;
</span><span class="cx"> #import &quot;WebPageProxyMessages.h&quot;
</span><ins>+#import &lt;WebCore/NotImplemented.h&gt;
</ins><span class="cx"> 
</span><span class="cx"> namespace WebKit {
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPageDrawingAreah"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/DrawingArea.h (170556 => 170557)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/DrawingArea.h        2014-06-27 21:57:25 UTC (rev 170556)
+++ trunk/Source/WebKit2/WebProcess/WebPage/DrawingArea.h        2014-06-27 21:58:06 UTC (rev 170557)
</span><span class="lines">@@ -30,6 +30,7 @@
</span><span class="cx"> #include &quot;LayerTreeContext.h&quot;
</span><span class="cx"> #include &lt;WebCore/FloatRect.h&gt;
</span><span class="cx"> #include &lt;WebCore/IntRect.h&gt;
</span><ins>+#include &lt;WebCore/LayerFlushThrottleState.h&gt;
</ins><span class="cx"> #include &lt;WebCore/PlatformScreen.h&gt;
</span><span class="cx"> #include &lt;WebCore/ViewState.h&gt;
</span><span class="cx"> #include &lt;functional&gt;
</span><span class="lines">@@ -119,6 +120,8 @@
</span><span class="cx"> 
</span><span class="cx">     virtual bool markLayersVolatileImmediatelyIfPossible() { return true; }
</span><span class="cx"> 
</span><ins>+    virtual bool adjustLayerFlushThrottling(WebCore::LayerFlushThrottleState::Flags) { return false; }
+
</ins><span class="cx"> protected:
</span><span class="cx">     DrawingArea(DrawingAreaType, WebPage&amp;);
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPagemacRemoteLayerTreeDrawingAreah"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.h (170556 => 170557)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.h        2014-06-27 21:57:25 UTC (rev 170556)
+++ trunk/Source/WebKit2/WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.h        2014-06-27 21:58:06 UTC (rev 170557)
</span><span class="lines">@@ -99,6 +99,8 @@
</span><span class="cx"> 
</span><span class="cx">     virtual void viewStateDidChange(WebCore::ViewState::Flags changed, bool wantsDidUpdateViewState) override;
</span><span class="cx"> 
</span><ins>+    virtual bool adjustLayerFlushThrottling(WebCore::LayerFlushThrottleState::Flags) override;
+
</ins><span class="cx">     // GraphicsLayerClient
</span><span class="cx">     virtual void notifyAnimationStarted(const WebCore::GraphicsLayer*, double time) override { }
</span><span class="cx">     virtual void notifyFlushRequired(const WebCore::GraphicsLayer*) override { }
</span><span class="lines">@@ -143,6 +145,9 @@
</span><span class="cx">     WebCore::Timer&lt;RemoteLayerTreeDrawingArea&gt; m_layerFlushTimer;
</span><span class="cx">     bool m_isFlushingSuspended;
</span><span class="cx">     bool m_hasDeferredFlush;
</span><ins>+    bool m_isThrottlingLayerFlushes;
+    bool m_isLayerFlushThrottlingTemporarilyDisabledForInteraction;
+    bool m_isInitialThrottledLayerFlush;
</ins><span class="cx"> 
</span><span class="cx">     bool m_waitingForBackingStoreSwap;
</span><span class="cx">     bool m_hadFlushDeferredWhileWaitingForBackingStoreSwap;
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPagemacRemoteLayerTreeDrawingAreamm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.mm (170556 => 170557)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.mm        2014-06-27 21:57:25 UTC (rev 170556)
+++ trunk/Source/WebKit2/WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.mm        2014-06-27 21:58:06 UTC (rev 170557)
</span><span class="lines">@@ -59,6 +59,9 @@
</span><span class="cx">     , m_layerFlushTimer(this, &amp;RemoteLayerTreeDrawingArea::layerFlushTimerFired)
</span><span class="cx">     , m_isFlushingSuspended(false)
</span><span class="cx">     , m_hasDeferredFlush(false)
</span><ins>+    , m_isThrottlingLayerFlushes(false)
+    , m_isLayerFlushThrottlingTemporarilyDisabledForInteraction(false)
+    , m_isInitialThrottledLayerFlush(false)
</ins><span class="cx">     , m_waitingForBackingStoreSwap(false)
</span><span class="cx">     , m_hadFlushDeferredWhileWaitingForBackingStoreSwap(false)
</span><span class="cx">     , m_displayRefreshMonitorsToNotify(nullptr)
</span><span class="lines">@@ -226,7 +229,6 @@
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx">     frameView-&gt;setExposedRect(m_scrolledExposedRect);
</span><del>-    frameView-&gt;adjustTiledBackingCoverage();
</del><span class="cx"> 
</span><span class="cx">     m_webPage.pageOverlayController().didChangeExposedRect();
</span><span class="cx"> }
</span><span class="lines">@@ -239,12 +241,47 @@
</span><span class="cx"> 
</span><span class="cx"> void RemoteLayerTreeDrawingArea::scheduleCompositingLayerFlush()
</span><span class="cx"> {
</span><ins>+    if (m_isFlushingSuspended) {
+        m_isLayerFlushThrottlingTemporarilyDisabledForInteraction = false;
+        m_hasDeferredFlush = true;
+        return;
+    }
+    if (m_isLayerFlushThrottlingTemporarilyDisabledForInteraction) {
+        m_isLayerFlushThrottlingTemporarilyDisabledForInteraction = false;
+        m_layerFlushTimer.startOneShot(0_ms);
+        return;
+    }
+
</ins><span class="cx">     if (m_layerFlushTimer.isActive())
</span><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    m_layerFlushTimer.startOneShot(0);
</del><ins>+    const auto initialFlushDelay = 500_ms;
+    const auto flushDelay = 1500_ms;
+    auto throttleDelay = m_isThrottlingLayerFlushes ? (m_isInitialThrottledLayerFlush ? initialFlushDelay : flushDelay) : 0_ms;
+    m_isInitialThrottledLayerFlush = false;
+
+    m_layerFlushTimer.startOneShot(throttleDelay);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+bool RemoteLayerTreeDrawingArea::adjustLayerFlushThrottling(WebCore::LayerFlushThrottleState::Flags flags)
+{
+    if (flags &amp; WebCore::LayerFlushThrottleState::UserIsInteracting)
+        m_isLayerFlushThrottlingTemporarilyDisabledForInteraction = true;
+
+    bool wasThrottlingLayerFlushes = m_isThrottlingLayerFlushes;
+    m_isThrottlingLayerFlushes = flags &amp; WebCore::LayerFlushThrottleState::MainLoadProgressing;
+
+    if (!wasThrottlingLayerFlushes &amp;&amp; m_isThrottlingLayerFlushes)
+        m_isInitialThrottledLayerFlush = true;
+
+    // Re-schedule the flush if we stopped throttling.
+    if (wasThrottlingLayerFlushes &amp;&amp; !m_isThrottlingLayerFlushes &amp;&amp; m_layerFlushTimer.isActive()) {
+        m_layerFlushTimer.stop();
+        scheduleCompositingLayerFlush();
+    }
+    return true;
+}
+
</ins><span class="cx"> void RemoteLayerTreeDrawingArea::layerFlushTimerFired(WebCore::Timer&lt;RemoteLayerTreeDrawingArea&gt;*)
</span><span class="cx"> {
</span><span class="cx">     flushLayers();
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPagemacTiledCoreAnimationDrawingAreamm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm (170556 => 170557)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm        2014-06-27 21:57:25 UTC (rev 170556)
+++ trunk/Source/WebKit2/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm        2014-06-27 21:58:06 UTC (rev 170557)
</span><span class="lines">@@ -358,7 +358,6 @@
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx">     frameView-&gt;setExposedRect(m_scrolledExposedRect);
</span><del>-    frameView-&gt;adjustTiledBackingCoverage();
</del><span class="cx"> 
</span><span class="cx">     m_webPage.pageOverlayController().didChangeExposedRect();
</span><span class="cx"> }
</span></span></pre>
</div>
</div>

</body>
</html>