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

Unified Diff: third_party/WebKit/Source/core/css/resolver/ScopedStyleResolver.cpp

Issue 1371723002: Devtools Animations: Add method to fetch CSS keyframed animations (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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/css/resolver/ScopedStyleResolver.cpp
diff --git a/third_party/WebKit/Source/core/css/resolver/ScopedStyleResolver.cpp b/third_party/WebKit/Source/core/css/resolver/ScopedStyleResolver.cpp
index eb08585fb873a2a9b0d323c7396672c59c2e04ad..181d4ec6b74f903a785bf070e73a1277106191fd 100644
--- a/third_party/WebKit/Source/core/css/resolver/ScopedStyleResolver.cpp
+++ b/third_party/WebKit/Source/core/css/resolver/ScopedStyleResolver.cpp
@@ -55,11 +55,11 @@ ScopedStyleResolver* ScopedStyleResolver::parent() const
return nullptr;
}
-void ScopedStyleResolver::addKeyframeRules(const RuleSet& ruleSet)
+void ScopedStyleResolver::addKeyframeRules(const RuleSet& ruleSet, CSSStyleSheet* styleSheet)
{
const WillBeHeapVector<RawPtrWillBeMember<StyleRuleKeyframes>> keyframesRules = ruleSet.keyframesRules();
for (unsigned i = 0; i < keyframesRules.size(); ++i)
- addKeyframeStyle(keyframesRules[i]);
+ addKeyframeStyle(keyframesRules[i], styleSheet);
}
void ScopedStyleResolver::addFontFaceRules(const RuleSet& ruleSet)
@@ -87,7 +87,7 @@ void ScopedStyleResolver::appendCSSStyleSheet(CSSStyleSheet& cssSheet, const Med
AddRuleFlags addRuleFlags = treeScope().document().securityOrigin()->canRequest(sheet->baseURL()) ? RuleHasDocumentSecurityOrigin : RuleHasNoSpecialState;
const RuleSet& ruleSet = sheet->ensureRuleSet(medium, addRuleFlags);
- addKeyframeRules(ruleSet);
+ addKeyframeRules(ruleSet, &cssSheet);
addFontFaceRules(ruleSet);
addTreeBoundaryCrossingRules(ruleSet, &cssSheet, index);
treeScope().document().styleResolver()->addMediaQueryResults(ruleSet.viewportDependentMediaQueryResults());
@@ -113,6 +113,7 @@ void ScopedStyleResolver::resetAuthorStyle()
{
m_authorStyleSheets.clear();
m_keyframesRuleMap.clear();
+ m_keyframesStyleSheetMap.clear();
m_treeBoundaryCrossingRuleSet = nullptr;
}
@@ -128,18 +129,34 @@ StyleRuleKeyframes* ScopedStyleResolver::keyframeStylesForAnimation(const String
return it->value.get();
}
-void ScopedStyleResolver::addKeyframeStyle(PassRefPtrWillBeRawPtr<StyleRuleKeyframes> rule)
+CSSStyleSheet* ScopedStyleResolver::styleSheetForAnimation(const StringImpl* animationName)
+{
+ if (m_keyframesStyleSheetMap.isEmpty())
+ return nullptr;
+
+ WillBeHeapHashMap<const StringImpl*, CSSStyleSheet*>::iterator it = m_keyframesStyleSheetMap.find(animationName);
+ if (it == m_keyframesStyleSheetMap.end())
+ return nullptr;
+
+ return it->value;
+}
+
+void ScopedStyleResolver::addKeyframeStyle(PassRefPtrWillBeRawPtr<StyleRuleKeyframes> rule, CSSStyleSheet* styleSheet)
{
AtomicString s(rule->name());
if (rule->isVendorPrefixed()) {
KeyframesRuleMap::iterator it = m_keyframesRuleMap.find(s.impl());
- if (it == m_keyframesRuleMap.end())
+ if (it == m_keyframesRuleMap.end()) {
m_keyframesRuleMap.set(s.impl(), rule);
- else if (it->value->isVendorPrefixed())
+ m_keyframesStyleSheetMap.set(s.impl(), styleSheet);
+ } else if (it->value->isVendorPrefixed()) {
m_keyframesRuleMap.set(s.impl(), rule);
+ m_keyframesStyleSheetMap.set(s.impl(), styleSheet);
+ }
} else {
m_keyframesRuleMap.set(s.impl(), rule);
+ m_keyframesStyleSheetMap.set(s.impl(), styleSheet);
}
}

Powered by Google App Engine
This is Rietveld 408576698