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

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

Issue 2361733004: Adding @keyframes rules only affects TreeScope plus host. (Closed)
Patch Set: Rebased Created 4 years, 3 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/Animation.cpp
diff --git a/third_party/WebKit/Source/core/animation/Animation.cpp b/third_party/WebKit/Source/core/animation/Animation.cpp
index b34fac998d20df5135d6d6c6536ca9d01492b56b..c16097004d21dc3ea3c0c37e99412918d3b36cda 100644
--- a/third_party/WebKit/Source/core/animation/Animation.cpp
+++ b/third_party/WebKit/Source/core/animation/Animation.cpp
@@ -36,6 +36,7 @@
#include "core/dom/Document.h"
#include "core/dom/ExceptionCode.h"
#include "core/dom/StyleChangeReason.h"
+#include "core/dom/shadow/ShadowRoot.h"
#include "core/events/AnimationPlaybackEvent.h"
#include "core/frame/UseCounter.h"
#include "core/inspector/InspectorInstrumentation.h"
@@ -1086,12 +1087,28 @@ void Animation::disableCompositedAnimationForTesting()
cancelAnimationOnCompositor();
}
-void Animation::invalidateKeyframeEffect()
+static bool isAffectedByKeyframesFromScope(const Element& element, const TreeScope& treeScope)
+{
+ // Animated elements are affected by @keyframes rules from the same scope
+ // and from their shadow sub-trees if they are shadow hosts.
+ if (element.treeScope() == treeScope)
+ return true;
+ if (!isShadowHost(element))
+ return false;
+ if (treeScope.rootNode() == treeScope.document())
+ return false;
+ return toShadowRoot(treeScope.rootNode()).host() == element;
+}
alancutter (OOO until 2018) 2016/09/27 06:49:50 Nit: Move this static method to core/animation/css
rune 2016/09/28 21:35:57 Did you mean like patch set 4?
+
+void Animation::invalidateKeyframeEffect(const TreeScope& treeScope)
{
if (!m_content || !m_content->isKeyframeEffect())
return;
- toKeyframeEffect(m_content.get())->target()->setNeedsStyleRecalc(LocalStyleChange, StyleChangeReasonForTracing::create(StyleChangeReason::StyleSheetChange));
+ Element& target = *toKeyframeEffect(m_content.get())->target();
+
+ if (isAffectedByKeyframesFromScope(target, treeScope))
+ target.setNeedsStyleRecalc(LocalStyleChange, StyleChangeReasonForTracing::create(StyleChangeReason::StyleSheetChange));
}
DEFINE_TRACE(Animation)
« no previous file with comments | « third_party/WebKit/Source/core/animation/Animation.h ('k') | third_party/WebKit/Source/core/animation/AnimationTimeline.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698