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

Side by Side Diff: sky/engine/core/css/resolver/ScopedStyleResolver.cpp

Issue 839473005: Simplify ScopedStyleResolver keyframe handling. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 11 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved. 3 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
4 * Copyright (C) 2012 Google Inc. All rights reserved. 4 * Copyright (C) 2012 Google Inc. All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 const RuleSet& ruleSet = sheet->ensureRuleSet(addRuleFlags); 54 const RuleSet& ruleSet = sheet->ensureRuleSet(addRuleFlags);
55 resolver->addMediaQueryResults(ruleSet.viewportDependentMediaQueryResults()) ; 55 resolver->addMediaQueryResults(ruleSet.viewportDependentMediaQueryResults()) ;
56 resolver->processScopedRules(ruleSet, cssSheet, index, treeScope().rootNode( )); 56 resolver->processScopedRules(ruleSet, cssSheet, index, treeScope().rootNode( ));
57 57
58 m_features.add(ruleSet.features()); 58 m_features.add(ruleSet.features());
59 } 59 }
60 60
61 void ScopedStyleResolver::resetAuthorStyle() 61 void ScopedStyleResolver::resetAuthorStyle()
62 { 62 {
63 m_authorStyleSheets.clear(); 63 m_authorStyleSheets.clear();
64 m_keyframesRuleMap.clear();
65 m_features.clear(); 64 m_features.clear();
66 } 65 }
67 66
68 const StyleRuleKeyframes* ScopedStyleResolver::keyframeStylesForAnimation(const StringImpl* animationName) 67 const StyleRuleKeyframes* ScopedStyleResolver::keyframeStylesForAnimation(String animationName)
69 { 68 {
70 if (m_keyframesRuleMap.isEmpty()) 69 for (auto& sheet : m_authorStyleSheets) {
71 return 0; 70 // TODO(esprehn): Maybe just store the keyframes in a map?
72 71 for (auto& rule : sheet->contents()->ruleSet().keyframesRules()) {
73 KeyframesRuleMap::iterator it = m_keyframesRuleMap.find(animationName); 72 if (rule->name() == animationName)
74 if (it == m_keyframesRuleMap.end()) 73 return rule.get();
75 return 0; 74 }
76
77 return it->value.get();
78 }
79
80 void ScopedStyleResolver::addKeyframeStyle(PassRefPtr<StyleRuleKeyframes> rule)
81 {
82 AtomicString s(rule->name());
83 if (rule->isVendorPrefixed()) {
84 KeyframesRuleMap::iterator it = m_keyframesRuleMap.find(rule->name().imp l());
85 if (it == m_keyframesRuleMap.end())
86 m_keyframesRuleMap.set(s.impl(), rule);
87 else if (it->value->isVendorPrefixed())
88 m_keyframesRuleMap.set(s.impl(), rule);
89 } else {
90 m_keyframesRuleMap.set(s.impl(), rule);
91 } 75 }
76 return nullptr;
92 } 77 }
93 78
94 void ScopedStyleResolver::collectMatchingAuthorRules(ElementRuleCollector& colle ctor, bool includeEmptyRules, bool applyAuthorStyles, CascadeScope cascadeScope, CascadeOrder cascadeOrder) 79 void ScopedStyleResolver::collectMatchingAuthorRules(ElementRuleCollector& colle ctor, bool includeEmptyRules, bool applyAuthorStyles, CascadeScope cascadeScope, CascadeOrder cascadeOrder)
95 { 80 {
96 unsigned contextFlags = SelectorChecker::DefaultBehavior; 81 unsigned contextFlags = SelectorChecker::DefaultBehavior;
97 82
98 if (!applyAuthorStyles) 83 if (!applyAuthorStyles)
99 contextFlags |= SelectorChecker::ScopeContainsLastMatchedElement; 84 contextFlags |= SelectorChecker::ScopeContainsLastMatchedElement;
100 85
101 RuleRange ruleRange = collector.matchedResult().ranges.authorRuleRange(); 86 RuleRange ruleRange = collector.matchedResult().ranges.authorRuleRange();
102 for (size_t i = 0; i < m_authorStyleSheets.size(); ++i) { 87 for (size_t i = 0; i < m_authorStyleSheets.size(); ++i) {
103 MatchRequest matchRequest(&m_authorStyleSheets[i]->contents()->ruleSet() , includeEmptyRules, &m_scope->rootNode(), m_authorStyleSheets[i], applyAuthorSt yles, i); 88 MatchRequest matchRequest(&m_authorStyleSheets[i]->contents()->ruleSet() , includeEmptyRules, &m_scope->rootNode(), m_authorStyleSheets[i], applyAuthorSt yles, i);
104 collector.collectMatchingRules(matchRequest, ruleRange, static_cast<Sele ctorChecker::ContextFlags>(contextFlags), cascadeScope, cascadeOrder); 89 collector.collectMatchingRules(matchRequest, ruleRange, static_cast<Sele ctorChecker::ContextFlags>(contextFlags), cascadeScope, cascadeOrder);
105 } 90 }
106 } 91 }
107 92
108 } // namespace blink 93 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698