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) |