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

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

Issue 837883002: Store features in the ScopedStyleResoolver. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Simpler even. 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 void ScopedStyleResolver::addRulesFromSheet(CSSStyleSheet* cssSheet, StyleResolv er* resolver) 47 void ScopedStyleResolver::addRulesFromSheet(CSSStyleSheet* cssSheet, StyleResolv er* resolver)
48 { 48 {
49 m_authorStyleSheets.append(cssSheet); 49 m_authorStyleSheets.append(cssSheet);
50 unsigned index = m_authorStyleSheets.size() - 1; 50 unsigned index = m_authorStyleSheets.size() - 1;
51 StyleSheetContents* sheet = cssSheet->contents(); 51 StyleSheetContents* sheet = cssSheet->contents();
52 52
53 AddRuleFlags addRuleFlags = RuleHasNoSpecialState; 53 AddRuleFlags addRuleFlags = RuleHasNoSpecialState;
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 }
58 57
59 void ScopedStyleResolver::collectFeaturesTo(RuleFeatureSet& features, HashSet<co nst StyleSheetContents*>& visitedSharedStyleSheetContents) const 58 m_features.add(ruleSet.features());
60 {
61 for (size_t i = 0; i < m_authorStyleSheets.size(); ++i) {
62 StyleSheetContents* contents = m_authorStyleSheets[i]->contents();
63 if (visitedSharedStyleSheetContents.add(contents).isNewEntry)
64 features.add(contents->ruleSet().features());
65 }
66 } 59 }
67 60
68 void ScopedStyleResolver::resetAuthorStyle() 61 void ScopedStyleResolver::resetAuthorStyle()
69 { 62 {
70 m_authorStyleSheets.clear(); 63 m_authorStyleSheets.clear();
71 m_keyframesRuleMap.clear(); 64 m_keyframesRuleMap.clear();
65 m_features.clear();
72 } 66 }
73 67
74 const StyleRuleKeyframes* ScopedStyleResolver::keyframeStylesForAnimation(const StringImpl* animationName) 68 const StyleRuleKeyframes* ScopedStyleResolver::keyframeStylesForAnimation(const StringImpl* animationName)
75 { 69 {
76 if (m_keyframesRuleMap.isEmpty()) 70 if (m_keyframesRuleMap.isEmpty())
77 return 0; 71 return 0;
78 72
79 KeyframesRuleMap::iterator it = m_keyframesRuleMap.find(animationName); 73 KeyframesRuleMap::iterator it = m_keyframesRuleMap.find(animationName);
80 if (it == m_keyframesRuleMap.end()) 74 if (it == m_keyframesRuleMap.end())
81 return 0; 75 return 0;
(...skipping 23 matching lines...) Expand all
105 contextFlags |= SelectorChecker::ScopeContainsLastMatchedElement; 99 contextFlags |= SelectorChecker::ScopeContainsLastMatchedElement;
106 100
107 RuleRange ruleRange = collector.matchedResult().ranges.authorRuleRange(); 101 RuleRange ruleRange = collector.matchedResult().ranges.authorRuleRange();
108 for (size_t i = 0; i < m_authorStyleSheets.size(); ++i) { 102 for (size_t i = 0; i < m_authorStyleSheets.size(); ++i) {
109 MatchRequest matchRequest(&m_authorStyleSheets[i]->contents()->ruleSet() , includeEmptyRules, &m_scope->rootNode(), m_authorStyleSheets[i], applyAuthorSt yles, i); 103 MatchRequest matchRequest(&m_authorStyleSheets[i]->contents()->ruleSet() , includeEmptyRules, &m_scope->rootNode(), m_authorStyleSheets[i], applyAuthorSt yles, i);
110 collector.collectMatchingRules(matchRequest, ruleRange, static_cast<Sele ctorChecker::ContextFlags>(contextFlags), cascadeScope, cascadeOrder); 104 collector.collectMatchingRules(matchRequest, ruleRange, static_cast<Sele ctorChecker::ContextFlags>(contextFlags), cascadeScope, cascadeOrder);
111 } 105 }
112 } 106 }
113 107
114 } // namespace blink 108 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698