<!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>[163983] trunk/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/163983">163983</a></dd>
<dt>Author</dt> <dd>barraclough@apple.com</dd>
<dt>Date</dt> <dd>2014-02-12 13:56:32 -0800 (Wed, 12 Feb 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Clean up PageThrottler interface
https://bugs.webkit.org/show_bug.cgi?id=128677

Reviewed by Benjamin Poulain.

Currently, responsibility for throttling DOM timers &amp; suspending animations is split
between the Page &amp; the PageThrottler. Clarify by making Page responsible for suspending
animations (PageThrottler is now purely related to aspects of timer throttling), and
move all timer throttling policy to the PageThrottler, with a single function on Page to
enable (Page::setTimerThrottlingEnabled).

Also, transmit the full ViewState to the PageThrottler (not just the IsVisuallyIdle flag),
and distinguish between media &amp; page-load activity.

* WebCore.exp.in:
    - removed setDOMTimerAlignmentInterval.
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::parseAttribute):
    - createActivityToken -&gt; mediaActivityToken
* loader/FrameLoader.cpp:
(WebCore::FrameLoader::started):
    - createActivityToken -&gt; pageLoadActivityToken
* page/Page.cpp:
(WebCore::Page::Page):
    - added m_timerThrottlingEnabled, made PageThrottler a member
(WebCore::Page::setIsVisuallyIdleInternal):
    - update animiation suspension.
(WebCore::Page::setTimerThrottlingEnabled):
    - setTimerAlignmentInterval -&gt; setTimerThrottlingEnabled
(WebCore::Page::setViewState):
    - pass viewState to PageThrottler.
(WebCore::Page::setIsVisibleInternal):
    - don't update timer throttling.
* page/Page.h:
(WebCore::Page::pageThrottler):
    - made PageThrottler a member.
(WebCore::Page::timerAlignmentInterval):
    - inlined.
* page/PageThrottler.cpp:
(WebCore::PageThrottler::PageThrottler):
    - initialize ViewState.
(WebCore::PageThrottler::~PageThrottler):
    - clean up by calling setTimerThrottlingEnabled directly.
(WebCore::PageThrottler::hiddenPageDOMTimerThrottlingStateChanged):
    - moved from Page.
(WebCore::PageThrottler::mediaActivityToken):
(WebCore::PageThrottler::pageLoadActivityToken):
    - from Page::createActivityToken
(WebCore::PageThrottler::throttlePage):
(WebCore::PageThrottler::unthrottlePage):
    - don't throttle animations here.
(WebCore::PageThrottler::setViewState):
(WebCore::PageThrottler::setIsVisible):
    - added, throttle Dom timers.
* page/PageThrottler.h:
* page/Settings.cpp:
(WebCore::Settings::setHiddenPageDOMTimerThrottlingEnabled):
    - removed setDOMTimerAlignmentInterval, hiddenPageDOMTimerThrottlingStateChanged moved to PageThrottler.
* page/Settings.h:
    - removed setDOMTimerAlignmentInterval.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreWebCoreexpin">trunk/Source/WebCore/WebCore.exp.in</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLMediaElementcpp">trunk/Source/WebCore/html/HTMLMediaElement.cpp</a></li>
<li><a href="#trunkSourceWebCoreloaderFrameLoadercpp">trunk/Source/WebCore/loader/FrameLoader.cpp</a></li>
<li><a href="#trunkSourceWebCorepagePagecpp">trunk/Source/WebCore/page/Page.cpp</a></li>
<li><a href="#trunkSourceWebCorepagePageh">trunk/Source/WebCore/page/Page.h</a></li>
<li><a href="#trunkSourceWebCorepagePageThrottlercpp">trunk/Source/WebCore/page/PageThrottler.cpp</a></li>
<li><a href="#trunkSourceWebCorepagePageThrottlerh">trunk/Source/WebCore/page/PageThrottler.h</a></li>
<li><a href="#trunkSourceWebCorepageSettingscpp">trunk/Source/WebCore/page/Settings.cpp</a></li>
<li><a href="#trunkSourceWebCorepageSettingsh">trunk/Source/WebCore/page/Settings.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (163982 => 163983)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-02-12 21:38:57 UTC (rev 163982)
+++ trunk/Source/WebCore/ChangeLog        2014-02-12 21:56:32 UTC (rev 163983)
</span><span class="lines">@@ -1,3 +1,66 @@
</span><ins>+2014-02-12  Gavin Barraclough  &lt;barraclough@apple.com&gt;
+
+        Clean up PageThrottler interface
+        https://bugs.webkit.org/show_bug.cgi?id=128677
+
+        Reviewed by Benjamin Poulain.
+
+        Currently, responsibility for throttling DOM timers &amp; suspending animations is split
+        between the Page &amp; the PageThrottler. Clarify by making Page responsible for suspending
+        animations (PageThrottler is now purely related to aspects of timer throttling), and
+        move all timer throttling policy to the PageThrottler, with a single function on Page to
+        enable (Page::setTimerThrottlingEnabled).
+
+        Also, transmit the full ViewState to the PageThrottler (not just the IsVisuallyIdle flag),
+        and distinguish between media &amp; page-load activity.
+
+        * WebCore.exp.in:
+            - removed setDOMTimerAlignmentInterval.
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::parseAttribute):
+            - createActivityToken -&gt; mediaActivityToken
+        * loader/FrameLoader.cpp:
+        (WebCore::FrameLoader::started):
+            - createActivityToken -&gt; pageLoadActivityToken
+        * page/Page.cpp:
+        (WebCore::Page::Page):
+            - added m_timerThrottlingEnabled, made PageThrottler a member
+        (WebCore::Page::setIsVisuallyIdleInternal):
+            - update animiation suspension.
+        (WebCore::Page::setTimerThrottlingEnabled):
+            - setTimerAlignmentInterval -&gt; setTimerThrottlingEnabled
+        (WebCore::Page::setViewState):
+            - pass viewState to PageThrottler.
+        (WebCore::Page::setIsVisibleInternal):
+            - don't update timer throttling.
+        * page/Page.h:
+        (WebCore::Page::pageThrottler):
+            - made PageThrottler a member.
+        (WebCore::Page::timerAlignmentInterval):
+            - inlined.
+        * page/PageThrottler.cpp:
+        (WebCore::PageThrottler::PageThrottler):
+            - initialize ViewState.
+        (WebCore::PageThrottler::~PageThrottler):
+            - clean up by calling setTimerThrottlingEnabled directly.
+        (WebCore::PageThrottler::hiddenPageDOMTimerThrottlingStateChanged):
+            - moved from Page.
+        (WebCore::PageThrottler::mediaActivityToken):
+        (WebCore::PageThrottler::pageLoadActivityToken):
+            - from Page::createActivityToken
+        (WebCore::PageThrottler::throttlePage):
+        (WebCore::PageThrottler::unthrottlePage):
+            - don't throttle animations here.
+        (WebCore::PageThrottler::setViewState):
+        (WebCore::PageThrottler::setIsVisible):
+            - added, throttle Dom timers.
+        * page/PageThrottler.h:
+        * page/Settings.cpp:
+        (WebCore::Settings::setHiddenPageDOMTimerThrottlingEnabled):
+            - removed setDOMTimerAlignmentInterval, hiddenPageDOMTimerThrottlingStateChanged moved to PageThrottler.
+        * page/Settings.h:
+            - removed setDOMTimerAlignmentInterval.
+
</ins><span class="cx"> 2014-02-12  Benjamin Poulain  &lt;bpoulain@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [WK2][iOS] Add back the special viewport for the old xhtml mobile doctype
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCoreexpin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.exp.in (163982 => 163983)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.exp.in        2014-02-12 21:38:57 UTC (rev 163982)
+++ trunk/Source/WebCore/WebCore.exp.in        2014-02-12 21:56:32 UTC (rev 163983)
</span><span class="lines">@@ -1245,7 +1245,6 @@
</span><span class="cx"> __ZN7WebCore8Settings26setSimpleLineLayoutEnabledEb
</span><span class="cx"> __ZN7WebCore8Settings27setJavaEnabledForLocalFilesEb
</span><span class="cx"> __ZN7WebCore8Settings27setLoadsImagesAutomaticallyEb
</span><del>-__ZN7WebCore8Settings28setDOMTimerAlignmentIntervalEd
</del><span class="cx"> __ZN7WebCore8Settings29setAuthorAndUserStylesEnabledEb
</span><span class="cx"> __ZN7WebCore8Settings29setDefaultMinDOMTimerIntervalEd
</span><span class="cx"> __ZN7WebCore8Settings30setShowTiledScrollingIndicatorEb
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLMediaElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (163982 => 163983)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLMediaElement.cpp        2014-02-12 21:38:57 UTC (rev 163982)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp        2014-02-12 21:56:32 UTC (rev 163983)
</span><span class="lines">@@ -63,6 +63,7 @@
</span><span class="cx"> #include &quot;MediaSessionManager.h&quot;
</span><span class="cx"> #include &quot;PageActivityAssertionToken.h&quot;
</span><span class="cx"> #include &quot;PageGroup.h&quot;
</span><ins>+#include &quot;PageThrottler.h&quot;
</ins><span class="cx"> #include &quot;ProgressTracker.h&quot;
</span><span class="cx"> #include &quot;RenderLayerCompositor.h&quot;
</span><span class="cx"> #include &quot;RenderVideo.h&quot;
</span><span class="lines">@@ -4286,7 +4287,7 @@
</span><span class="cx">         if (hasMediaControls())
</span><span class="cx">             mediaControls()-&gt;playbackStarted();
</span><span class="cx">         if (document().page())
</span><del>-            m_activityToken = document().page()-&gt;createActivityToken();
</del><ins>+            m_activityToken = document().page()-&gt;pageThrottler().mediaActivityToken();
</ins><span class="cx"> 
</span><span class="cx">         startPlaybackProgressTimer();
</span><span class="cx">         m_playing = true;
</span></span></pre></div>
<a id="trunkSourceWebCoreloaderFrameLoadercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/FrameLoader.cpp (163982 => 163983)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/FrameLoader.cpp        2014-02-12 21:38:57 UTC (rev 163982)
+++ trunk/Source/WebCore/loader/FrameLoader.cpp        2014-02-12 21:56:32 UTC (rev 163983)
</span><span class="lines">@@ -85,6 +85,7 @@
</span><span class="cx"> #include &quot;Page.h&quot;
</span><span class="cx"> #include &quot;PageActivityAssertionToken.h&quot;
</span><span class="cx"> #include &quot;PageCache.h&quot;
</span><ins>+#include &quot;PageThrottler.h&quot;
</ins><span class="cx"> #include &quot;PageTransitionEvent.h&quot;
</span><span class="cx"> #include &quot;PlatformStrategies.h&quot;
</span><span class="cx"> #include &quot;PluginData.h&quot;
</span><span class="lines">@@ -1142,7 +1143,7 @@
</span><span class="cx"> void FrameLoader::started()
</span><span class="cx"> {
</span><span class="cx">     if (m_frame.page())
</span><del>-        m_activityAssertion = m_frame.page()-&gt;createActivityToken();
</del><ins>+        m_activityAssertion = m_frame.page()-&gt;pageThrottler().pageLoadActivityToken();
</ins><span class="cx">     for (Frame* frame = &amp;m_frame; frame; frame = frame-&gt;tree().parent())
</span><span class="cx">         frame-&gt;loader().m_isComplete = false;
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCorepagePagecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/Page.cpp (163982 => 163983)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/Page.cpp        2014-02-12 21:38:57 UTC (rev 163982)
+++ trunk/Source/WebCore/page/Page.cpp        2014-02-12 21:56:32 UTC (rev 163983)
</span><span class="lines">@@ -172,6 +172,7 @@
</span><span class="cx">     , m_viewMode(ViewModeWindowed)
</span><span class="cx"> #endif // ENABLE(VIEW_MODE_CSS_MEDIA)
</span><span class="cx">     , m_minimumTimerInterval(Settings::defaultMinDOMTimerInterval())
</span><ins>+    , m_timerThrottlingEnabled(false)
</ins><span class="cx">     , m_timerAlignmentInterval(Settings::defaultDOMTimerAlignmentInterval())
</span><span class="cx">     , m_isEditable(false)
</span><span class="cx">     , m_isPrerender(false)
</span><span class="lines">@@ -185,7 +186,7 @@
</span><span class="cx"> #endif
</span><span class="cx">     , m_alternativeTextClient(pageClients.alternativeTextClient)
</span><span class="cx">     , m_scriptedAnimationsSuspended(false)
</span><del>-    , m_pageThrottler(std::make_unique&lt;PageThrottler&gt;(*this))
</del><ins>+    , m_pageThrottler(*this, PageInitialViewState)
</ins><span class="cx">     , m_console(std::make_unique&lt;PageConsole&gt;(*this))
</span><span class="cx"> #if ENABLE(REMOTE_INSPECTOR)
</span><span class="cx">     , m_inspectorDebuggable(std::make_unique&lt;PageDebuggable&gt;(*this))
</span><span class="lines">@@ -847,7 +848,10 @@
</span><span class="cx"> 
</span><span class="cx"> void Page::setIsVisuallyIdleInternal(bool isVisuallyIdle)
</span><span class="cx"> {
</span><del>-    m_pageThrottler-&gt;setIsVisuallyIdle(isVisuallyIdle);
</del><ins>+    for (Frame* frame = &amp;mainFrame(); frame; frame = frame-&gt;tree().traverseNext()) {
+        if (frame-&gt;document())
+            frame-&gt;document()-&gt;scriptedAnimationControllerSetThrottled(isVisuallyIdle);
+    }
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void Page::userStyleSheetLocationChanged()
</span><span class="lines">@@ -1040,23 +1044,25 @@
</span><span class="cx">     return m_minimumTimerInterval;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void Page::setTimerAlignmentInterval(double interval)
</del><ins>+void Page::setTimerThrottlingEnabled(bool enabled)
</ins><span class="cx"> {
</span><del>-    if (interval == m_timerAlignmentInterval)
</del><ins>+#if ENABLE(HIDDEN_PAGE_DOM_TIMER_THROTTLING)
+    if (!m_settings-&gt;hiddenPageDOMTimerThrottlingEnabled())
+        enabled = false;
+#endif
+
+    if (enabled == m_timerThrottlingEnabled)
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    m_timerAlignmentInterval = interval;
</del><ins>+    m_timerThrottlingEnabled = enabled;
+    m_timerAlignmentInterval = enabled ? Settings::hiddenPageDOMTimerAlignmentInterval() : Settings::defaultDOMTimerAlignmentInterval();
+    
</ins><span class="cx">     for (Frame* frame = &amp;mainFrame(); frame; frame = frame-&gt;tree().traverseNextWithWrap(false)) {
</span><span class="cx">         if (frame-&gt;document())
</span><span class="cx">             frame-&gt;document()-&gt;didChangeTimerAlignmentInterval();
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-double Page::timerAlignmentInterval() const
-{
-    return m_timerAlignmentInterval;
-}
-
</del><span class="cx"> void Page::dnsPrefetchingStateChanged()
</span><span class="cx"> {
</span><span class="cx">     for (Frame* frame = &amp;mainFrame(); frame; frame = frame-&gt;tree().traverseNext())
</span><span class="lines">@@ -1123,22 +1129,6 @@
</span><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-void Page::throttleTimers()
-{
-#if ENABLE(HIDDEN_PAGE_DOM_TIMER_THROTTLING)
-    if (m_settings-&gt;hiddenPageDOMTimerThrottlingEnabled())
-        setTimerAlignmentInterval(Settings::hiddenPageDOMTimerAlignmentInterval());
-#endif
-}
-
-void Page::unthrottleTimers()
-{
-#if ENABLE(HIDDEN_PAGE_DOM_TIMER_THROTTLING)
-    if (m_settings-&gt;hiddenPageDOMTimerThrottlingEnabled())
-        setTimerAlignmentInterval(Settings::defaultDOMTimerAlignmentInterval());
-#endif
-}
-
</del><span class="cx"> void Page::resumeAnimatingImages()
</span><span class="cx"> {
</span><span class="cx">     // Drawing models which cache painted content while out-of-window (WebKit2's composited drawing areas, etc.)
</span><span class="lines">@@ -1158,6 +1148,7 @@
</span><span class="cx"> 
</span><span class="cx">     m_viewState = viewState;
</span><span class="cx">     m_focusController-&gt;setViewState(viewState);
</span><ins>+    m_pageThrottler.setViewState(viewState);
</ins><span class="cx"> 
</span><span class="cx">     if (changed &amp; ViewState::IsVisible)
</span><span class="cx">         setIsVisibleInternal(viewState &amp; ViewState::IsVisible);
</span><span class="lines">@@ -1190,8 +1181,6 @@
</span><span class="cx">         if (FrameView* view = mainFrame().view())
</span><span class="cx">             view-&gt;show();
</span><span class="cx"> 
</span><del>-        unthrottleTimers();
-
</del><span class="cx"> #if ENABLE(PAGE_VISIBILITY_API)
</span><span class="cx">         if (m_settings-&gt;hiddenPageCSSAnimationSuspensionEnabled())
</span><span class="cx">             mainFrame().animation().resumeAnimations();
</span><span class="lines">@@ -1210,9 +1199,6 @@
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx">     if (!isVisible) {
</span><del>-        if (m_pageThrottler-&gt;shouldThrottleTimers())
-            throttleTimers();
-
</del><span class="cx"> #if ENABLE(PAGE_VISIBILITY_API)
</span><span class="cx">         if (m_settings-&gt;hiddenPageCSSAnimationSuspensionEnabled())
</span><span class="cx">             mainFrame().animation().suspendAnimations();
</span><span class="lines">@@ -1479,24 +1465,6 @@
</span><span class="cx">     m_seenMediaEngines.clear();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-std::unique_ptr&lt;PageActivityAssertionToken&gt; Page::createActivityToken()
-{
-    return m_pageThrottler-&gt;createActivityToken();
-}
-
-#if ENABLE(HIDDEN_PAGE_DOM_TIMER_THROTTLING)
-void Page::hiddenPageDOMTimerThrottlingStateChanged()
-{
-    if (m_settings-&gt;hiddenPageDOMTimerThrottlingEnabled()) {
-#if ENABLE(PAGE_VISIBILITY_API)
-        if (m_pageThrottler-&gt;shouldThrottleTimers())
-            setTimerAlignmentInterval(Settings::hiddenPageDOMTimerAlignmentInterval());
-#endif
-    } else
-        setTimerAlignmentInterval(Settings::defaultDOMTimerAlignmentInterval());
-}
-#endif
-
</del><span class="cx"> #if (ENABLE_PAGE_VISIBILITY_API)
</span><span class="cx"> void Page::hiddenPageCSSAnimationSuspensionStateChanged()
</span><span class="cx"> {
</span></span></pre></div>
<a id="trunkSourceWebCorepagePageh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/Page.h (163982 => 163983)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/Page.h        2014-02-12 21:38:57 UTC (rev 163982)
+++ trunk/Source/WebCore/page/Page.h        2014-02-12 21:56:32 UTC (rev 163983)
</span><span class="lines">@@ -26,6 +26,7 @@
</span><span class="cx"> #include &quot;FrameLoaderTypes.h&quot;
</span><span class="cx"> #include &quot;LayoutMilestones.h&quot;
</span><span class="cx"> #include &quot;LayoutRect.h&quot;
</span><ins>+#include &quot;PageThrottler.h&quot;
</ins><span class="cx"> #include &quot;PageVisibilityState.h&quot;
</span><span class="cx"> #include &quot;Pagination.h&quot;
</span><span class="cx"> #include &quot;PlatformScreen.h&quot;
</span><span class="lines">@@ -390,14 +391,10 @@
</span><span class="cx">     void sawMediaEngine(const String&amp; engineName);
</span><span class="cx">     void resetSeenMediaEngines();
</span><span class="cx"> 
</span><del>-    PageThrottler&amp; pageThrottler() { return *m_pageThrottler; }
-    std::unique_ptr&lt;PageActivityAssertionToken&gt; createActivityToken();
</del><ins>+    PageThrottler&amp; pageThrottler() { return m_pageThrottler; }
</ins><span class="cx"> 
</span><span class="cx">     PageConsole&amp; console() { return *m_console; }
</span><span class="cx"> 
</span><del>-#if ENABLE(HIDDEN_PAGE_DOM_TIMER_THROTTLING)
-    void hiddenPageDOMTimerThrottlingStateChanged();
-#endif
</del><span class="cx"> #if ENABLE(PAGE_VISIBILITY_API)
</span><span class="cx">     void hiddenPageCSSAnimationSuspensionStateChanged();
</span><span class="cx"> #endif
</span><span class="lines">@@ -438,13 +435,11 @@
</span><span class="cx">     void setMinimumTimerInterval(double);
</span><span class="cx">     double minimumTimerInterval() const;
</span><span class="cx"> 
</span><del>-    void setTimerAlignmentInterval(double);
-    double timerAlignmentInterval() const;
</del><ins>+    double timerAlignmentInterval() const { return m_timerAlignmentInterval; }
</ins><span class="cx"> 
</span><span class="cx">     Vector&lt;Ref&lt;PluginViewBase&gt;&gt; pluginViews();
</span><span class="cx"> 
</span><del>-    void throttleTimers();
-    void unthrottleTimers();
</del><ins>+    void setTimerThrottlingEnabled(bool);
</ins><span class="cx"> 
</span><span class="cx">     const std::unique_ptr&lt;Chrome&gt; m_chrome;
</span><span class="cx">     const std::unique_ptr&lt;DragCaretController&gt; m_dragCaretController;
</span><span class="lines">@@ -522,6 +517,7 @@
</span><span class="cx"> 
</span><span class="cx">     double m_minimumTimerInterval;
</span><span class="cx"> 
</span><ins>+    bool m_timerThrottlingEnabled;
</ins><span class="cx">     double m_timerAlignmentInterval;
</span><span class="cx"> 
</span><span class="cx">     bool m_isEditable;
</span><span class="lines">@@ -544,7 +540,7 @@
</span><span class="cx">     AlternativeTextClient* m_alternativeTextClient;
</span><span class="cx"> 
</span><span class="cx">     bool m_scriptedAnimationsSuspended;
</span><del>-    const std::unique_ptr&lt;PageThrottler&gt; m_pageThrottler;
</del><ins>+    PageThrottler m_pageThrottler;
</ins><span class="cx">     const std::unique_ptr&lt;PageConsole&gt; m_console;
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(REMOTE_INSPECTOR)
</span></span></pre></div>
<a id="trunkSourceWebCorepagePageThrottlercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/PageThrottler.cpp (163982 => 163983)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/PageThrottler.cpp        2014-02-12 21:38:57 UTC (rev 163982)
+++ trunk/Source/WebCore/page/PageThrottler.cpp        2014-02-12 21:56:32 UTC (rev 163983)
</span><span class="lines">@@ -37,19 +37,22 @@
</span><span class="cx"> 
</span><span class="cx"> static const double kThrottleHysteresisSeconds = 2.0;
</span><span class="cx"> 
</span><del>-PageThrottler::PageThrottler(Page&amp; page)
</del><ins>+PageThrottler::PageThrottler(Page&amp; page, ViewState::Flags viewState)
</ins><span class="cx">     : m_page(page)
</span><ins>+    , m_viewState(viewState)
</ins><span class="cx">     , m_throttleState(PageNotThrottledState)
</span><span class="cx">     , m_throttleHysteresisTimer(this, &amp;PageThrottler::throttleHysteresisTimerFired)
</span><span class="cx">     , m_visuallyNonIdle(&quot;Page is not visually idle.&quot;)
</span><span class="cx">     , m_pageActivity(&quot;Page is active.&quot;)
</span><span class="cx"> {
</span><span class="cx">     m_pageActivity.beginActivity();
</span><ins>+
+    setIsVisuallyIdle(viewState &amp; ViewState::IsVisuallyIdle);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> PageThrottler::~PageThrottler()
</span><span class="cx"> {
</span><del>-    setIsVisuallyIdle(false);
</del><ins>+    m_page.setTimerThrottlingEnabled(false);
</ins><span class="cx"> 
</span><span class="cx">     for (auto it = m_activityTokens.begin(), end = m_activityTokens.end(); it != end; ++it)
</span><span class="cx">         (*it)-&gt;invalidate();
</span><span class="lines">@@ -58,23 +61,28 @@
</span><span class="cx">         m_pageActivity.endActivity();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-std::unique_ptr&lt;PageActivityAssertionToken&gt; PageThrottler::createActivityToken()
</del><ins>+void PageThrottler::hiddenPageDOMTimerThrottlingStateChanged()
</ins><span class="cx"> {
</span><ins>+    m_page.setTimerThrottlingEnabled(m_throttleState != PageNotThrottledState);
+}
+
+std::unique_ptr&lt;PageActivityAssertionToken&gt; PageThrottler::mediaActivityToken()
+{
</ins><span class="cx">     return std::make_unique&lt;PageActivityAssertionToken&gt;(*this);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+std::unique_ptr&lt;PageActivityAssertionToken&gt; PageThrottler::pageLoadActivityToken()
+{
+    return std::make_unique&lt;PageActivityAssertionToken&gt;(*this);
+}
+
</ins><span class="cx"> void PageThrottler::throttlePage()
</span><span class="cx"> {
</span><span class="cx">     m_throttleState = PageThrottledState;
</span><span class="cx"> 
</span><span class="cx">     m_pageActivity.endActivity();
</span><span class="cx"> 
</span><del>-    for (Frame* frame = &amp;m_page.mainFrame(); frame; frame = frame-&gt;tree().traverseNext()) {
-        if (frame-&gt;document())
-            frame-&gt;document()-&gt;scriptedAnimationControllerSetThrottled(true);
-    }
-
-    m_page.throttleTimers();
</del><ins>+    m_page.setTimerThrottlingEnabled(true);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void PageThrottler::unthrottlePage()
</span><span class="lines">@@ -88,14 +96,28 @@
</span><span class="cx">     if (oldState == PageThrottledState)
</span><span class="cx">         m_pageActivity.beginActivity();
</span><span class="cx">     
</span><del>-    for (Frame* frame = &amp;m_page.mainFrame(); frame; frame = frame-&gt;tree().traverseNext()) {
-        if (frame-&gt;document())
-            frame-&gt;document()-&gt;scriptedAnimationControllerSetThrottled(false);
-    }
</del><ins>+    m_page.setTimerThrottlingEnabled(false);
+}
</ins><span class="cx"> 
</span><del>-    m_page.unthrottleTimers();
</del><ins>+void PageThrottler::setViewState(ViewState::Flags viewState)
+{
+    ViewState::Flags changed = m_viewState ^ viewState;
+    m_viewState = viewState;
+
+    if (changed &amp; ViewState::IsVisible)
+        setIsVisible(viewState &amp; ViewState::IsVisible);
+    if (changed &amp; ViewState::IsVisuallyIdle)
+        setIsVisuallyIdle(viewState &amp; ViewState::IsVisuallyIdle);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void PageThrottler::setIsVisible(bool isVisible)
+{
+    if (isVisible)
+        m_page.setTimerThrottlingEnabled(false);
+    else if (m_throttleState != PageNotThrottledState)
+        m_page.setTimerThrottlingEnabled(true);
+}
+
</ins><span class="cx"> void PageThrottler::setIsVisuallyIdle(bool isVisuallyIdle)
</span><span class="cx"> {
</span><span class="cx">     if (isVisuallyIdle) {
</span></span></pre></div>
<a id="trunkSourceWebCorepagePageThrottlerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/PageThrottler.h (163982 => 163983)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/PageThrottler.h        2014-02-12 21:38:57 UTC (rev 163982)
+++ trunk/Source/WebCore/page/PageThrottler.h        2014-02-12 21:56:32 UTC (rev 163983)
</span><span class="lines">@@ -29,6 +29,7 @@
</span><span class="cx"> #include &quot;Timer.h&quot;
</span><span class="cx"> 
</span><span class="cx"> #include &quot;UserActivity.h&quot;
</span><ins>+#include &quot;ViewState.h&quot;
</ins><span class="cx"> #include &lt;wtf/HashSet.h&gt;
</span><span class="cx"> #include &lt;wtf/OwnPtr.h&gt;
</span><span class="cx"> #include &lt;wtf/PassOwnPtr.h&gt;
</span><span class="lines">@@ -40,19 +41,18 @@
</span><span class="cx"> 
</span><span class="cx"> class PageThrottler {
</span><span class="cx"> public:
</span><del>-    PageThrottler(Page&amp;);
</del><ins>+    PageThrottler(Page&amp;, ViewState::Flags);
</ins><span class="cx">     ~PageThrottler();
</span><span class="cx"> 
</span><del>-    std::unique_ptr&lt;PageActivityAssertionToken&gt; createActivityToken();
</del><ins>+    void setViewState(ViewState::Flags);
</ins><span class="cx"> 
</span><del>-    bool shouldThrottleAnimations() const { return m_throttleState != PageNotThrottledState; }
-    bool shouldThrottleTimers() const { return m_throttleState != PageNotThrottledState; }
-
-    void setIsVisuallyIdle(bool);
-
</del><span class="cx">     void didReceiveUserInput() { reportInterestingEvent(); }
</span><span class="cx">     void pluginDidEvaluate() { reportInterestingEvent(); }
</span><ins>+    std::unique_ptr&lt;PageActivityAssertionToken&gt; mediaActivityToken();
+    std::unique_ptr&lt;PageActivityAssertionToken&gt; pageLoadActivityToken();
</ins><span class="cx"> 
</span><ins>+    void hiddenPageDOMTimerThrottlingStateChanged();
+
</ins><span class="cx"> private:
</span><span class="cx">     enum PageThrottleState {
</span><span class="cx">         PageNotThrottledState,
</span><span class="lines">@@ -73,7 +73,11 @@
</span><span class="cx">     void throttlePage();
</span><span class="cx">     void unthrottlePage();
</span><span class="cx"> 
</span><ins>+    void setIsVisuallyIdle(bool);
+    void setIsVisible(bool);
+
</ins><span class="cx">     Page&amp; m_page;
</span><ins>+    ViewState::Flags m_viewState;
</ins><span class="cx">     PageThrottleState m_throttleState;
</span><span class="cx">     Timer&lt;PageThrottler&gt; m_throttleHysteresisTimer;
</span><span class="cx">     HashSet&lt;PageActivityAssertionToken*&gt; m_activityTokens;
</span></span></pre></div>
<a id="trunkSourceWebCorepageSettingscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/Settings.cpp (163982 => 163983)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/Settings.cpp        2014-02-12 21:38:57 UTC (rev 163982)
+++ trunk/Source/WebCore/page/Settings.cpp        2014-02-12 21:56:32 UTC (rev 163983)
</span><span class="lines">@@ -499,11 +499,6 @@
</span><span class="cx">     return gDefaultDOMTimerAlignmentInterval;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void Settings::setDOMTimerAlignmentInterval(double interval)
-{
-    m_page-&gt;setTimerAlignmentInterval(interval);
-}
-
</del><span class="cx"> double Settings::domTimerAlignmentInterval() const
</span><span class="cx"> {
</span><span class="cx">     return m_page-&gt;timerAlignmentInterval();
</span><span class="lines">@@ -693,7 +688,7 @@
</span><span class="cx">     if (m_hiddenPageDOMTimerThrottlingEnabled == flag)
</span><span class="cx">         return;
</span><span class="cx">     m_hiddenPageDOMTimerThrottlingEnabled = flag;
</span><del>-    m_page-&gt;hiddenPageDOMTimerThrottlingStateChanged();
</del><ins>+    m_page-&gt;pageThrottler().hiddenPageDOMTimerThrottlingStateChanged();
</ins><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorepageSettingsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/Settings.h (163982 => 163983)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/Settings.h        2014-02-12 21:38:57 UTC (rev 163982)
+++ trunk/Source/WebCore/page/Settings.h        2014-02-12 21:56:32 UTC (rev 163983)
</span><span class="lines">@@ -169,7 +169,6 @@
</span><span class="cx">     static void setDefaultDOMTimerAlignmentInterval(double);
</span><span class="cx">     static double defaultDOMTimerAlignmentInterval();
</span><span class="cx"> 
</span><del>-    void setDOMTimerAlignmentInterval(double);
</del><span class="cx">     double domTimerAlignmentInterval() const;
</span><span class="cx"> 
</span><span class="cx">     void setLayoutInterval(std::chrono::milliseconds);
</span></span></pre>
</div>
</div>

</body>
</html>