Title: [237231] trunk/Source/WebCore
- Revision
- 237231
- Author
- commit-qu...@webkit.org
- Date
- 2018-10-17 12:06:49 -0700 (Wed, 17 Oct 2018)
Log Message
[Web Animations] Do not create a DocumentTimeline to suspend or resume animations
https://bugs.webkit.org/show_bug.cgi?id=190660
Patch by Antoine Quint <grao...@apple.com> on 2018-10-17
Reviewed by Dean Jackson.
We check that there is an existing timeline before trying to suspend or resume its animations, otherwise
we're creating a DocumentTimeline when nothing requires for it to exist. We also have to check that we
suspend animations when a DocumentTimeline is created while the page is not visible.
No new tests as there is no change in behavior here.
* animation/DocumentTimeline.cpp:
(WebCore::DocumentTimeline::DocumentTimeline):
* dom/Document.cpp:
(WebCore::Document::didBecomeCurrentDocumentInFrame):
(WebCore::Document::resume):
* page/Frame.cpp:
(WebCore::Frame::clearTimers):
* page/Page.cpp:
(WebCore::Page::setIsVisibleInternal):
(WebCore::Page::hiddenPageCSSAnimationSuspensionStateChanged):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (237230 => 237231)
--- trunk/Source/WebCore/ChangeLog 2018-10-17 19:00:03 UTC (rev 237230)
+++ trunk/Source/WebCore/ChangeLog 2018-10-17 19:06:49 UTC (rev 237231)
@@ -1,3 +1,27 @@
+2018-10-17 Antoine Quint <grao...@apple.com>
+
+ [Web Animations] Do not create a DocumentTimeline to suspend or resume animations
+ https://bugs.webkit.org/show_bug.cgi?id=190660
+
+ Reviewed by Dean Jackson.
+
+ We check that there is an existing timeline before trying to suspend or resume its animations, otherwise
+ we're creating a DocumentTimeline when nothing requires for it to exist. We also have to check that we
+ suspend animations when a DocumentTimeline is created while the page is not visible.
+
+ No new tests as there is no change in behavior here.
+
+ * animation/DocumentTimeline.cpp:
+ (WebCore::DocumentTimeline::DocumentTimeline):
+ * dom/Document.cpp:
+ (WebCore::Document::didBecomeCurrentDocumentInFrame):
+ (WebCore::Document::resume):
+ * page/Frame.cpp:
+ (WebCore::Frame::clearTimers):
+ * page/Page.cpp:
+ (WebCore::Page::setIsVisibleInternal):
+ (WebCore::Page::hiddenPageCSSAnimationSuspensionStateChanged):
+
2018-10-17 Antti Koivisto <an...@apple.com>
Tiling CSS gradients is slow
Modified: trunk/Source/WebCore/animation/DocumentTimeline.cpp (237230 => 237231)
--- trunk/Source/WebCore/animation/DocumentTimeline.cpp 2018-10-17 19:00:03 UTC (rev 237230)
+++ trunk/Source/WebCore/animation/DocumentTimeline.cpp 2018-10-17 19:06:49 UTC (rev 237231)
@@ -63,6 +63,8 @@
, m_animationResolutionTimer(*this, &DocumentTimeline::animationResolutionTimerFired)
#endif
{
+ if (m_document && m_document->page() && !m_document->page()->isVisible())
+ suspendAnimations();
}
DocumentTimeline::~DocumentTimeline() = default;
Modified: trunk/Source/WebCore/dom/Document.cpp (237230 => 237231)
--- trunk/Source/WebCore/dom/Document.cpp 2018-10-17 19:00:03 UTC (rev 237230)
+++ trunk/Source/WebCore/dom/Document.cpp 2018-10-17 19:06:49 UTC (rev 237231)
@@ -2314,16 +2314,18 @@
// be out of sync if the DOM suspension state changed while the document was not in the frame (possibly in the
// page cache, or simply newly created).
if (m_frame->activeDOMObjectsAndAnimationsSuspended()) {
- if (RuntimeEnabledFeatures::sharedFeatures().webAnimationsCSSIntegrationEnabled())
- timeline().suspendAnimations();
- else
+ if (RuntimeEnabledFeatures::sharedFeatures().webAnimationsCSSIntegrationEnabled()) {
+ if (auto* timeline = existingTimeline())
+ timeline->suspendAnimations();
+ } else
m_frame->animation().suspendAnimationsForDocument(this);
suspendScheduledTasks(ReasonForSuspension::PageWillBeSuspended);
} else {
resumeScheduledTasks(ReasonForSuspension::PageWillBeSuspended);
- if (RuntimeEnabledFeatures::sharedFeatures().webAnimationsCSSIntegrationEnabled())
- timeline().resumeAnimations();
- else
+ if (RuntimeEnabledFeatures::sharedFeatures().webAnimationsCSSIntegrationEnabled()) {
+ if (auto* timeline = existingTimeline())
+ timeline->resumeAnimations();
+ } else
m_frame->animation().resumeAnimationsForDocument(this);
}
}
@@ -5089,9 +5091,10 @@
ASSERT(m_frame);
m_frame->loader().client().dispatchDidBecomeFrameset(isFrameSet());
- if (RuntimeEnabledFeatures::sharedFeatures().webAnimationsCSSIntegrationEnabled())
- timeline().resumeAnimations();
- else
+ if (RuntimeEnabledFeatures::sharedFeatures().webAnimationsCSSIntegrationEnabled()) {
+ if (auto* timeline = existingTimeline())
+ timeline->resumeAnimations();
+ } else
m_frame->animation().resumeAnimationsForDocument(this);
resumeScheduledTasks(reason);
Modified: trunk/Source/WebCore/page/Frame.cpp (237230 => 237231)
--- trunk/Source/WebCore/page/Frame.cpp 2018-10-17 19:00:03 UTC (rev 237230)
+++ trunk/Source/WebCore/page/Frame.cpp 2018-10-17 19:06:49 UTC (rev 237231)
@@ -774,9 +774,10 @@
{
if (view) {
view->layoutContext().unscheduleLayout();
- if (RuntimeEnabledFeatures::sharedFeatures().webAnimationsCSSIntegrationEnabled())
- document->timeline().suspendAnimations();
- else
+ if (RuntimeEnabledFeatures::sharedFeatures().webAnimationsCSSIntegrationEnabled()) {
+ if (auto* timeline = document->existingTimeline())
+ timeline->suspendAnimations();
+ } else
view->frame().animation().suspendAnimationsForDocument(document);
view->frame().eventHandler().stopAutoscrollTimer();
}
Modified: trunk/Source/WebCore/page/Page.cpp (237230 => 237231)
--- trunk/Source/WebCore/page/Page.cpp 2018-10-17 19:00:03 UTC (rev 237230)
+++ trunk/Source/WebCore/page/Page.cpp 2018-10-17 19:06:49 UTC (rev 237231)
@@ -1735,7 +1735,8 @@
if (m_settings->hiddenPageCSSAnimationSuspensionEnabled()) {
if (RuntimeEnabledFeatures::sharedFeatures().webAnimationsCSSIntegrationEnabled()) {
forEachDocument([&] (Document& document) {
- document.timeline().resumeAnimations();
+ if (auto* timeline = document.existingTimeline())
+ timeline->resumeAnimations();
});
} else
mainFrame().animation().resumeAnimations();
@@ -1755,7 +1756,8 @@
if (m_settings->hiddenPageCSSAnimationSuspensionEnabled()) {
if (RuntimeEnabledFeatures::sharedFeatures().webAnimationsCSSIntegrationEnabled()) {
forEachDocument([&] (Document& document) {
- document.timeline().suspendAnimations();
+ if (auto* timeline = document.existingTimeline())
+ timeline->suspendAnimations();
});
} else
mainFrame().animation().suspendAnimations();
@@ -2113,10 +2115,12 @@
if (!isVisible()) {
if (RuntimeEnabledFeatures::sharedFeatures().webAnimationsCSSIntegrationEnabled()) {
forEachDocument([&] (Document& document) {
- if (m_settings->hiddenPageCSSAnimationSuspensionEnabled())
- document.timeline().suspendAnimations();
- else
- document.timeline().resumeAnimations();
+ if (auto* timeline = document.existingTimeline()) {
+ if (m_settings->hiddenPageCSSAnimationSuspensionEnabled())
+ timeline->suspendAnimations();
+ else
+ timeline->resumeAnimations();
+ }
});
} else {
if (m_settings->hiddenPageCSSAnimationSuspensionEnabled())
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes