Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(119)

Unified Diff: third_party/WebKit/Source/core/animation/AnimationTimeline.cpp

Issue 2105743002: Optimize style recalc when adding @keyframes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/animation/AnimationTimeline.cpp
diff --git a/third_party/WebKit/Source/core/animation/AnimationTimeline.cpp b/third_party/WebKit/Source/core/animation/AnimationTimeline.cpp
index e753bba98fa8b3a49529b1a33c63b0ac6a7b02af..da5f7c5883a91c13f418dfa075dc7a0cc6c522ee 100644
--- a/third_party/WebKit/Source/core/animation/AnimationTimeline.cpp
+++ b/third_party/WebKit/Source/core/animation/AnimationTimeline.cpp
@@ -33,6 +33,7 @@
#include "core/animation/AnimationClock.h"
#include "core/animation/ElementAnimations.h"
#include "core/dom/Document.h"
+#include "core/dom/StyleChangeReason.h"
#include "core/frame/FrameView.h"
#include "core/loader/DocumentLoader.h"
#include "core/page/Page.h"
@@ -347,6 +348,25 @@ double AnimationTimeline::playbackRate() const
return m_playbackRate;
}
+void AnimationTimeline::keyframesRulesAdded()
+{
+ if (m_hasUnresolvedKeyframesRule) {
+ m_hasUnresolvedKeyframesRule = false;
+ if (m_document)
+ m_document->setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTracing::create(StyleChangeReason::Animation));
+ return;
+ }
+
+ for (const auto& animation : m_animations) {
+ const AnimationEffect* effect = animation->effect();
+ if (!effect)
+ continue;
+ if (!effect->isKeyframeEffect())
+ continue;
+ toKeyframeEffect(effect)->target()->setNeedsStyleRecalc(LocalStyleChange, StyleChangeReasonForTracing::create(StyleChangeReason::Animation));
+ }
+}
+
DEFINE_TRACE(AnimationTimeline)
{
visitor->trace(m_document);

Powered by Google App Engine
This is Rietveld 408576698