<!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>[211612] 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/211612">211612</a></dd>
<dt>Author</dt> <dd>cdumez@apple.com</dd>
<dt>Date</dt> <dd>2017-02-02 17:00:30 -0800 (Thu, 02 Feb 2017)</dd>
</dl>
<h3>Log Message</h3>
<pre>Suspend SVG animations in hidden pages
https://bugs.webkit.org/show_bug.cgi?id=167763
<rdar://problem/29986313>
Reviewed by Simon Fraser.
Source/WebCore:
Suspend SVG animations in hidden pages to save power, similarly to what
we already do for another types of animations.
Test: svg/animations/animations-paused-page-non-visible.html
* page/Page.cpp:
(WebCore::setSVGAnimationSuspended):
(WebCore::Page::setIsVisibleInternal):
* svg/SVGDocumentExtensions.cpp:
(WebCore::SVGDocumentExtensions::pauseAnimations):
(WebCore::SVGDocumentExtensions::unpauseAnimations):
* svg/SVGDocumentExtensions.h:
(WebCore::SVGDocumentExtensions::areAnimationsPaused):
* testing/Internals.cpp:
(WebCore::Internals::areSVGAnimationsPaused):
* testing/Internals.h:
* testing/Internals.idl:
LayoutTests:
Add layout test coverage.
* svg/animations/animations-paused-page-non-visible-expected.txt: Added.
* svg/animations/animations-paused-page-non-visible.html: Added.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsplatformiossimulatorTestExpectations">trunk/LayoutTests/platform/ios-simulator/TestExpectations</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorepagePagecpp">trunk/Source/WebCore/page/Page.cpp</a></li>
<li><a href="#trunkSourceWebCoresvgSVGDocumentExtensionscpp">trunk/Source/WebCore/svg/SVGDocumentExtensions.cpp</a></li>
<li><a href="#trunkSourceWebCoresvgSVGDocumentExtensionsh">trunk/Source/WebCore/svg/SVGDocumentExtensions.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><a href="#trunkLayoutTestssvganimationsanimationspausedpagenonvisibleexpectedtxt">trunk/LayoutTests/svg/animations/animations-paused-page-non-visible-expected.txt</a></li>
<li><a href="#trunkLayoutTestssvganimationsanimationspausedpagenonvisiblehtml">trunk/LayoutTests/svg/animations/animations-paused-page-non-visible.html</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (211611 => 211612)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2017-02-03 00:53:10 UTC (rev 211611)
+++ trunk/LayoutTests/ChangeLog        2017-02-03 01:00:30 UTC (rev 211612)
</span><span class="lines">@@ -1,5 +1,18 @@
</span><span class="cx"> 2017-02-02 Chris Dumez <cdumez@apple.com>
</span><span class="cx">
</span><ins>+ Suspend SVG animations in hidden pages
+ https://bugs.webkit.org/show_bug.cgi?id=167763
+ <rdar://problem/29986313>
+
+ Reviewed by Simon Fraser.
+
+ Add layout test coverage.
+
+ * svg/animations/animations-paused-page-non-visible-expected.txt: Added.
+ * svg/animations/animations-paused-page-non-visible.html: Added.
+
+2017-02-02 Chris Dumez <cdumez@apple.com>
+
</ins><span class="cx"> {}.toString.call(crossOriginWindow) should return "[object Object]"
</span><span class="cx"> https://bugs.webkit.org/show_bug.cgi?id=167701
</span><span class="cx"> <rdar://problem/30330797>
</span></span></pre></div>
<a id="trunkLayoutTestsplatformiossimulatorTestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/ios-simulator/TestExpectations (211611 => 211612)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/ios-simulator/TestExpectations        2017-02-03 00:53:10 UTC (rev 211611)
+++ trunk/LayoutTests/platform/ios-simulator/TestExpectations        2017-02-03 01:00:30 UTC (rev 211612)
</span><span class="lines">@@ -300,6 +300,7 @@
</span><span class="cx">
</span><span class="cx"> # testRunner.setPageVisibility is not implemented for iOS
</span><span class="cx"> webkit.org/b/165799 fast/events/page-visibility-onvisibilitychange.html [ Skip ]
</span><ins>+webkit.org/b/165799 svg/animations/animations-paused-page-non-visible.html [ Skip ]
</ins><span class="cx">
</span><span class="cx"> # AutoFill button is not supported
</span><span class="cx"> fast/forms/auto-fill-button/mouse-down-input-mouse-release-auto-fill-button.html
</span></span></pre></div>
<a id="trunkLayoutTestssvganimationsanimationspausedpagenonvisibleexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/svg/animations/animations-paused-page-non-visible-expected.txt (0 => 211612)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/svg/animations/animations-paused-page-non-visible-expected.txt         (rev 0)
+++ trunk/LayoutTests/svg/animations/animations-paused-page-non-visible-expected.txt        2017-02-03 01:00:30 UTC (rev 211612)
</span><span class="lines">@@ -0,0 +1,16 @@
</span><ins>+Tests that SVG animations are properly paused when the page becomes hidden.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS internals.areSVGAnimationsPaused is false
+* Page is now hidden
+PASS document.hidden is true
+PASS internals.areSVGAnimationsPaused is true
+* Page is now visible
+PASS document.hidden is false
+PASS internals.areSVGAnimationsPaused is false
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestssvganimationsanimationspausedpagenonvisiblehtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/svg/animations/animations-paused-page-non-visible.html (0 => 211612)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/svg/animations/animations-paused-page-non-visible.html         (rev 0)
+++ trunk/LayoutTests/svg/animations/animations-paused-page-non-visible.html        2017-02-03 01:00:30 UTC (rev 211612)
</span><span class="lines">@@ -0,0 +1,43 @@
</span><ins>+<!DOCTYPE html>
+<html>
+<body>
+<script src="../../resources/js-test-pre.js"></script>
+<svg width="300px" height="100px">
+ <rect x="0" y="0" width="300" height="100" stroke="black" stroke-width="1" />
+ <circle cx="0" cy="50" r="15" fill="blue" stroke="black" stroke-width="1">
+ <animate attributeName="cx" from="0" to="100" dur="5s" repeatCount="indefinite" />
+ </circle>
+</svg>
+<script>
+description("Tests that SVG animations are properly paused when the page becomes hidden.");
+jsTestIsAsync = true;
+
+var expectedState = "hidden";
+
+window.onload = function() {
+ shouldBeFalse("internals.areSVGAnimationsPaused");
+ document.addEventListener("visibilitychange", function() {
+ if (expectedState == "hidden") {
+ debug("* Page is now hidden");
+ shouldBeTrue("document.hidden");
+ setTimeout(function() {
+ shouldBeTrue("internals.areSVGAnimationsPaused");
+ expectedState = "visible";
+ testRunner.setPageVisibility("visible");
+ }, 0);
+ } else {
+ debug("* Page is now visible");
+ shouldBeFalse("document.hidden");
+ setTimeout(function() {
+ shouldBeFalse("internals.areSVGAnimationsPaused");
+ finishJSTest();
+ }, 0);
+ }
+ });
+ if (window.testRunner)
+ testRunner.setPageVisibility("hidden");
+}
+</script>
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (211611 => 211612)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2017-02-03 00:53:10 UTC (rev 211611)
+++ trunk/Source/WebCore/ChangeLog        2017-02-03 01:00:30 UTC (rev 211612)
</span><span class="lines">@@ -1,3 +1,29 @@
</span><ins>+2017-02-02 Chris Dumez <cdumez@apple.com>
+
+ Suspend SVG animations in hidden pages
+ https://bugs.webkit.org/show_bug.cgi?id=167763
+ <rdar://problem/29986313>
+
+ Reviewed by Simon Fraser.
+
+ Suspend SVG animations in hidden pages to save power, similarly to what
+ we already do for another types of animations.
+
+ Test: svg/animations/animations-paused-page-non-visible.html
+
+ * page/Page.cpp:
+ (WebCore::setSVGAnimationSuspended):
+ (WebCore::Page::setIsVisibleInternal):
+ * svg/SVGDocumentExtensions.cpp:
+ (WebCore::SVGDocumentExtensions::pauseAnimations):
+ (WebCore::SVGDocumentExtensions::unpauseAnimations):
+ * svg/SVGDocumentExtensions.h:
+ (WebCore::SVGDocumentExtensions::areAnimationsPaused):
+ * testing/Internals.cpp:
+ (WebCore::Internals::areSVGAnimationsPaused):
+ * testing/Internals.h:
+ * testing/Internals.idl:
+
</ins><span class="cx"> 2017-02-02 Commit Queue <commit-queue@webkit.org>
</span><span class="cx">
</span><span class="cx"> Unreviewed, rolling out r211596 and r211605.
</span></span></pre></div>
<a id="trunkSourceWebCorepagePagecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/Page.cpp (211611 => 211612)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/Page.cpp        2017-02-03 00:53:10 UTC (rev 211611)
+++ trunk/Source/WebCore/page/Page.cpp        2017-02-03 01:00:30 UTC (rev 211612)
</span><span class="lines">@@ -81,6 +81,7 @@
</span><span class="cx"> #include "RenderWidget.h"
</span><span class="cx"> #include "ResourceUsageOverlay.h"
</span><span class="cx"> #include "RuntimeEnabledFeatures.h"
</span><ins>+#include "SVGDocumentExtensions.h"
</ins><span class="cx"> #include "SchemeRegistry.h"
</span><span class="cx"> #include "ScriptController.h"
</span><span class="cx"> #include "ScrollingCoordinator.h"
</span><span class="lines">@@ -1531,6 +1532,24 @@
</span><span class="cx"> setActivityState((m_activityState & ~(ActivityState::IsVisible | ActivityState::IsVisibleOrOccluded)) | ActivityState::IsVisuallyIdle);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+enum class SVGAnimationsState { Paused, Resumed };
+static inline void setSVGAnimationsState(Page& page, SVGAnimationsState state)
+{
+ for (Frame* frame = &page.mainFrame(); frame; frame = frame->tree().traverseNext()) {
+ auto* document = frame->document();
+ if (!document)
+ continue;
+
+ if (!document->svgExtensions())
+ continue;
+
+ if (state == SVGAnimationsState::Paused)
+ document->accessSVGExtensions().pauseAnimations();
+ else
+ document->accessSVGExtensions().unpauseAnimations();
+ }
+}
+
</ins><span class="cx"> void Page::setIsVisibleInternal(bool isVisible)
</span><span class="cx"> {
</span><span class="cx"> // FIXME: The visibility state should be stored on the top-level document.
</span><span class="lines">@@ -1550,6 +1569,8 @@
</span><span class="cx"> if (m_settings->hiddenPageCSSAnimationSuspensionEnabled())
</span><span class="cx"> mainFrame().animation().resumeAnimations();
</span><span class="cx">
</span><ins>+ setSVGAnimationsState(*this, SVGAnimationsState::Resumed);
+
</ins><span class="cx"> resumeAnimatingImages();
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -1564,6 +1585,8 @@
</span><span class="cx"> if (m_settings->hiddenPageCSSAnimationSuspensionEnabled())
</span><span class="cx"> mainFrame().animation().suspendAnimations();
</span><span class="cx">
</span><ins>+ setSVGAnimationsState(*this, SVGAnimationsState::Paused);
+
</ins><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx"> suspendDeviceMotionAndOrientationUpdates();
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebCoresvgSVGDocumentExtensionscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/svg/SVGDocumentExtensions.cpp (211611 => 211612)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/svg/SVGDocumentExtensions.cpp        2017-02-03 00:53:10 UTC (rev 211611)
+++ trunk/Source/WebCore/svg/SVGDocumentExtensions.cpp        2017-02-03 01:00:30 UTC (rev 211612)
</span><span class="lines">@@ -102,6 +102,7 @@
</span><span class="cx"> {
</span><span class="cx"> for (auto& container : m_timeContainers)
</span><span class="cx"> container->pauseAnimations();
</span><ins>+ m_areAnimationsPaused = true;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void SVGDocumentExtensions::unpauseAnimations()
</span><span class="lines">@@ -108,6 +109,7 @@
</span><span class="cx"> {
</span><span class="cx"> for (auto& container : m_timeContainers)
</span><span class="cx"> container->unpauseAnimations();
</span><ins>+ m_areAnimationsPaused = false;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void SVGDocumentExtensions::dispatchSVGLoadEventToOutermostSVGElements()
</span></span></pre></div>
<a id="trunkSourceWebCoresvgSVGDocumentExtensionsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/svg/SVGDocumentExtensions.h (211611 => 211612)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/svg/SVGDocumentExtensions.h        2017-02-03 00:53:10 UTC (rev 211611)
+++ trunk/Source/WebCore/svg/SVGDocumentExtensions.h        2017-02-03 01:00:30 UTC (rev 211612)
</span><span class="lines">@@ -54,6 +54,7 @@
</span><span class="cx"> void pauseAnimations();
</span><span class="cx"> void unpauseAnimations();
</span><span class="cx"> void dispatchSVGLoadEventToOutermostSVGElements();
</span><ins>+ bool areAnimationsPaused() const { return m_areAnimationsPaused; }
</ins><span class="cx">
</span><span class="cx"> void reportWarning(const String&);
</span><span class="cx"> void reportError(const String&);
</span><span class="lines">@@ -88,6 +89,8 @@
</span><span class="cx"> std::unique_ptr<SVGResourcesCache> m_resourcesCache;
</span><span class="cx">
</span><span class="cx"> Vector<SVGElement*> m_rebuildElements;
</span><ins>+ bool m_areAnimationsPaused { false }; // For testing.
+
</ins><span class="cx"> public:
</span><span class="cx"> // This HashMap contains a list of pending resources. Pending resources, are such
</span><span class="cx"> // which are referenced by any object in the SVG document, but do NOT exist yet.
</span></span></pre></div>
<a id="trunkSourceWebCoretestingInternalscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/testing/Internals.cpp (211611 => 211612)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/testing/Internals.cpp        2017-02-03 00:53:10 UTC (rev 211611)
+++ trunk/Source/WebCore/testing/Internals.cpp        2017-02-03 01:00:30 UTC (rev 211612)
</span><span class="lines">@@ -113,6 +113,7 @@
</span><span class="cx"> #include "RenderView.h"
</span><span class="cx"> #include "RenderedDocumentMarker.h"
</span><span class="cx"> #include "ResourceLoadObserver.h"
</span><ins>+#include "SVGDocumentExtensions.h"
</ins><span class="cx"> #include "SVGPathStringBuilder.h"
</span><span class="cx"> #include "SchemeRegistry.h"
</span><span class="cx"> #include "ScriptedAnimationController.h"
</span><span class="lines">@@ -498,6 +499,18 @@
</span><span class="cx"> return WorkerThread::workerThreadCount();
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+bool Internals::areSVGAnimationsPaused() const
+{
+ auto* document = contextDocument();
+ if (!document)
+ return false;
+
+ if (!document->svgExtensions())
+ return false;
+
+ return document->accessSVGExtensions().areAnimationsPaused();
+}
+
</ins><span class="cx"> String Internals::address(Node& node)
</span><span class="cx"> {
</span><span class="cx"> return String::format("%p", &node);
</span></span></pre></div>
<a id="trunkSourceWebCoretestingInternalsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/testing/Internals.h (211611 => 211612)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/testing/Internals.h        2017-02-03 00:53:10 UTC (rev 211611)
+++ trunk/Source/WebCore/testing/Internals.h        2017-02-03 01:00:30 UTC (rev 211612)
</span><span class="lines">@@ -250,6 +250,7 @@
</span><span class="cx">
</span><span class="cx"> InternalSettings* settings() const;
</span><span class="cx"> unsigned workerThreadCount() const;
</span><ins>+ bool areSVGAnimationsPaused() const;
</ins><span class="cx">
</span><span class="cx"> ExceptionOr<void> setDeviceProximity(const String& eventType, double value, double min, double max);
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCoretestingInternalsidl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/testing/Internals.idl (211611 => 211612)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/testing/Internals.idl        2017-02-03 00:53:10 UTC (rev 211611)
+++ trunk/Source/WebCore/testing/Internals.idl        2017-02-03 01:00:30 UTC (rev 211612)
</span><span class="lines">@@ -246,6 +246,8 @@
</span><span class="cx"> readonly attribute InternalSettings settings;
</span><span class="cx"> readonly attribute unsigned long workerThreadCount;
</span><span class="cx">
</span><ins>+ readonly attribute boolean areSVGAnimationsPaused;
+
</ins><span class="cx"> // Flags for layerTreeAsText.
</span><span class="cx"> const unsigned short LAYER_TREE_INCLUDES_VISIBLE_RECTS = 1;
</span><span class="cx"> const unsigned short LAYER_TREE_INCLUDES_TILE_CACHES = 2;
</span></span></pre>
</div>
</div>
</body>
</html>