Diff
Modified: trunk/LayoutTests/ChangeLog (230578 => 230579)
--- trunk/LayoutTests/ChangeLog 2018-04-12 16:34:42 UTC (rev 230578)
+++ trunk/LayoutTests/ChangeLog 2018-04-12 16:35:32 UTC (rev 230579)
@@ -1,5 +1,16 @@
2018-04-12 Antoine Quint <grao...@apple.com>
+ [Web Animations] Throttle animations when lowPowerMode is on
+ https://bugs.webkit.org/show_bug.cgi?id=184540
+
+ Reviewed by Jon Lee.
+
+ Mark one more test as passing when the CSS Animations and CSS Transitions as Web Animations flag is on.
+
+ * fast/animation/css-animation-throttling-lowPowerMode.html:
+
+2018-04-12 Antoine Quint <grao...@apple.com>
+
[Web Animations] Ensure elements overlapping with elements animating also get composited
https://bugs.webkit.org/show_bug.cgi?id=184539
Modified: trunk/LayoutTests/fast/animation/css-animation-throttling-lowPowerMode.html (230578 => 230579)
--- trunk/LayoutTests/fast/animation/css-animation-throttling-lowPowerMode.html 2018-04-12 16:34:42 UTC (rev 230578)
+++ trunk/LayoutTests/fast/animation/css-animation-throttling-lowPowerMode.html 2018-04-12 16:35:32 UTC (rev 230579)
@@ -1,4 +1,4 @@
-<!DOCTYPE html>
+<!DOCTYPE html><!-- webkit-test-runner [ enableCSSAnimationsAndCSSTransitionsBackedByWebAnimations=true ] -->
<html>
<head>
<script src=""
Modified: trunk/Source/WebCore/ChangeLog (230578 => 230579)
--- trunk/Source/WebCore/ChangeLog 2018-04-12 16:34:42 UTC (rev 230578)
+++ trunk/Source/WebCore/ChangeLog 2018-04-12 16:35:32 UTC (rev 230579)
@@ -1,5 +1,25 @@
2018-04-12 Antoine Quint <grao...@apple.com>
+ [Web Animations] Throttle animations when lowPowerMode is on
+ https://bugs.webkit.org/show_bug.cgi?id=184540
+
+ Reviewed by Jon Lee.
+
+ Ensure animations are sampled at a lower frequency when lowPowerMode is on.
+
+ * animation/DocumentTimeline.cpp:
+ (WebCore::DocumentTimeline::updateThrottlingState):
+ (WebCore::DocumentTimeline::animationInterval const):
+ (WebCore::DocumentTimeline::updateAnimationSchedule):
+ (WebCore::DocumentTimeline::scheduleAnimationResolution):
+ * animation/DocumentTimeline.h:
+ * page/Page.cpp:
+ (WebCore::Page::handleLowModePowerChange):
+ * testing/Internals.cpp:
+ (WebCore::Internals::animationsInterval const):
+
+2018-04-12 Antoine Quint <grao...@apple.com>
+
[Web Animations] Ensure elements overlapping with elements animating also get composited
https://bugs.webkit.org/show_bug.cgi?id=184539
Modified: trunk/Source/WebCore/animation/DocumentTimeline.cpp (230578 => 230579)
--- trunk/Source/WebCore/animation/DocumentTimeline.cpp 2018-04-12 16:34:42 UTC (rev 230578)
+++ trunk/Source/WebCore/animation/DocumentTimeline.cpp 2018-04-12 16:35:32 UTC (rev 230579)
@@ -38,7 +38,8 @@
#include "Page.h"
#include "RenderElement.h"
-static const Seconds animationInterval { 15_ms };
+static const Seconds defaultAnimationInterval { 15_ms };
+static const Seconds throttledAnimationInterval { 30_ms };
namespace WebCore {
@@ -69,6 +70,19 @@
m_document = nullptr;
}
+void DocumentTimeline::updateThrottlingState()
+{
+ m_needsUpdateAnimationSchedule = false;
+ timingModelDidChange();
+}
+
+Seconds DocumentTimeline::animationInterval() const
+{
+ if (!m_document || !m_document->page())
+ return Seconds::infinity();
+ return m_document->page()->isLowPowerModeEnabled() ? throttledAnimationInterval : defaultAnimationInterval;
+}
+
std::optional<Seconds> DocumentTimeline::currentTime()
{
if (m_paused || !m_document || !m_document->domWindow())
@@ -136,7 +150,7 @@
for (const auto& animation : animations()) {
auto animationTimeToNextRequiredTick = animation->timeToNextRequiredTick();
- if (animationTimeToNextRequiredTick < animationInterval) {
+ if (animationTimeToNextRequiredTick < animationInterval()) {
scheduleAnimationResolution();
return;
}
@@ -159,7 +173,7 @@
#else
// FIXME: We need to use the same logic as ScriptedAnimationController here,
// which will be addressed by the refactor tracked by webkit.org/b/179293.
- m_animationResolutionTimer.startOneShot(animationInterval);
+ m_animationResolutionTimer.startOneShot(animationInterval());
#endif
}
Modified: trunk/Source/WebCore/animation/DocumentTimeline.h (230578 => 230579)
--- trunk/Source/WebCore/animation/DocumentTimeline.h 2018-04-12 16:34:42 UTC (rev 230578)
+++ trunk/Source/WebCore/animation/DocumentTimeline.h 2018-04-12 16:35:32 UTC (rev 230579)
@@ -71,6 +71,9 @@
void enqueueAnimationPlaybackEvent(AnimationPlaybackEvent&);
+ void updateThrottlingState();
+ WEBCORE_EXPORT Seconds animationInterval() const;
+
private:
DocumentTimeline(Document&, PlatformDisplayID);
Modified: trunk/Source/WebCore/page/Page.cpp (230578 => 230579)
--- trunk/Source/WebCore/page/Page.cpp 2018-04-12 16:34:42 UTC (rev 230578)
+++ trunk/Source/WebCore/page/Page.cpp 2018-04-12 16:35:32 UTC (rev 230579)
@@ -40,6 +40,7 @@
#include "DiagnosticLoggingKeys.h"
#include "DocumentLoader.h"
#include "DocumentMarkerController.h"
+#include "DocumentTimeline.h"
#include "DragController.h"
#include "Editor.h"
#include "EditorClient.h"
@@ -1139,7 +1140,13 @@
void Page::handleLowModePowerChange(bool isLowPowerModeEnabled)
{
updateScriptedAnimationsThrottlingReason(*this, isLowPowerModeEnabled ? ThrottlingReasonOperation::Add : ThrottlingReasonOperation::Remove, ScriptedAnimationController::ThrottlingReason::LowPowerMode);
- mainFrame().animation().updateThrottlingState();
+ if (RuntimeEnabledFeatures::sharedFeatures().cssAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled()) {
+ forEachDocument([&] (Document& document) {
+ if (auto timeline = document.existingTimeline())
+ timeline->updateThrottlingState();
+ });
+ } else
+ mainFrame().animation().updateThrottlingState();
updateDOMTimerAlignmentInterval();
}
Modified: trunk/Source/WebCore/testing/Internals.cpp (230578 => 230579)
--- trunk/Source/WebCore/testing/Internals.cpp 2018-04-12 16:34:42 UTC (rev 230578)
+++ trunk/Source/WebCore/testing/Internals.cpp 2018-04-12 16:35:32 UTC (rev 230579)
@@ -57,6 +57,7 @@
#include "Document.h"
#include "DocumentLoader.h"
#include "DocumentMarkerController.h"
+#include "DocumentTimeline.h"
#include "Editor.h"
#include "Element.h"
#include "EventHandler.h"
@@ -124,6 +125,7 @@
#include "RenderView.h"
#include "RenderedDocumentMarker.h"
#include "ResourceLoadObserver.h"
+#include "RuntimeEnabledFeatures.h"
#include "SMILTimeContainer.h"
#include "SVGDocumentExtensions.h"
#include "SVGPathStringBuilder.h"
@@ -928,9 +930,17 @@
double Internals::animationsInterval() const
{
Document* document = contextDocument();
- if (!document || !document->frame())
+ if (!document)
return INFINITY;
+ if (RuntimeEnabledFeatures::sharedFeatures().cssAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled()) {
+ if (auto timeline = document->existingTimeline())
+ return timeline->animationInterval().seconds();
+ return INFINITY;
+ }
+
+ if (!document->frame())
+ return INFINITY;
return document->frame()->animation().animationInterval().value();
}