Index: third_party/WebKit/Source/core/css/resolver/StyleResolver.cpp |
diff --git a/third_party/WebKit/Source/core/css/resolver/StyleResolver.cpp b/third_party/WebKit/Source/core/css/resolver/StyleResolver.cpp |
index dd1ec1e8d8c81e2fb8b27cf5a7c3c0f4fc475fc0..e3bdd995a70c6d93fe8e5d8eaa7b19614c834fe4 100644 |
--- a/third_party/WebKit/Source/core/css/resolver/StyleResolver.cpp |
+++ b/third_party/WebKit/Source/core/css/resolver/StyleResolver.cpp |
@@ -44,6 +44,7 @@ |
#include "core/css/CSSCalculationValue.h" |
#include "core/css/CSSDefaultStyleSheets.h" |
#include "core/css/CSSFontSelector.h" |
+#include "core/css/CSSImportRule.h" |
#include "core/css/CSSKeyframeRule.h" |
#include "core/css/CSSKeyframesRule.h" |
#include "core/css/CSSReflectValue.h" |
@@ -880,6 +881,28 @@ PassRefPtrWillBeRawPtr<CSSRuleList> StyleResolver::cssRulesForElement(Element* e |
return pseudoCSSRulesForElement(element, NOPSEUDO, rulesToInclude); |
} |
+PassRefPtrWillBeRawPtr<CSSRuleList> StyleResolver::keyframesRulesForElement(Element* element) |
+{ |
+ ASSERT(element); |
+ RefPtrWillBeRawPtr<StaticCSSRuleList> ruleList = StaticCSSRuleList::create(); |
+ |
+ // TODO(samli): Repeat for all pseudo elements. |
+ RefPtr<ComputedStyle> style = styleForElement(element); |
+ if (!style) |
+ return ruleList; |
+ const CSSAnimationData* animationData = style->animations(); |
+ for (size_t i = 0; animationData && i < animationData->nameList().size(); ++i) { |
+ AtomicString animationName(animationData->nameList()[i]); |
+ if (animationName == CSSAnimationData::initialName()) |
+ continue; |
+ RefPtrWillBeRawPtr<CSSKeyframesRule> keyframesRule = findCSSKeyframesRule(element, animationName); |
+ if (!keyframesRule) |
+ continue; |
+ ruleList->rules().append(keyframesRule); |
+ } |
+ return ruleList; |
+} |
+ |
void StyleResolver::collectPseudoRulesForElement(Element* element, ElementRuleCollector& collector, PseudoId pseudoId, unsigned rulesToInclude) |
{ |
collector.setPseudoStyleRequest(PseudoStyleRequest(pseudoId)); |
@@ -953,6 +976,24 @@ StyleRuleKeyframes* StyleResolver::findKeyframesRule(const Element* element, con |
return nullptr; |
} |
+PassRefPtrWillBeRawPtr<CSSKeyframesRule> StyleResolver::findCSSKeyframesRule(const Element* element, const AtomicString& animationName) |
+{ |
+ WillBeHeapVector<RawPtrWillBeMember<ScopedStyleResolver>, 8> resolvers; |
+ collectScopedResolversForHostedShadowTrees(element, resolvers); |
+ if (ScopedStyleResolver* scopedResolver = element->treeScope().scopedStyleResolver()) |
+ resolvers.append(scopedResolver); |
+ |
+ for (size_t i = 0; i < resolvers.size(); ++i) { |
+ if (StyleRuleKeyframes* keyframesRule = resolvers[i]->keyframeStylesForAnimation(animationName.impl())) { |
+ CSSStyleSheet* styleSheet = resolvers[i]->styleSheetForAnimation(animationName.impl()); |
+ if (!styleSheet) |
+ continue; |
+ return CSSKeyframesRule::create(keyframesRule, styleSheet); |
alancutter (OOO until 2018)
2015/10/27 23:57:30
I'm not happy with how stylesheets are associated
|
+ } |
+ } |
+ return nullptr; |
+} |
+ |
template <CSSPropertyPriority priority> |
void StyleResolver::applyAnimatedProperties(StyleResolverState& state, const ActiveInterpolationsMap& activeInterpolationsMap) |
{ |