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

Side by Side Diff: Source/core/css/StyleInvalidationAnalysis.cpp

Issue 19804005: Remove AtomicStringImpl. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 5 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Apple Inc. All rights reserved. 2 * Copyright (C) 2012 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 26 matching lines...) Expand all
37 37
38 namespace WebCore { 38 namespace WebCore {
39 39
40 StyleInvalidationAnalysis::StyleInvalidationAnalysis(const Vector<StyleSheetCont ents*>& sheets) 40 StyleInvalidationAnalysis::StyleInvalidationAnalysis(const Vector<StyleSheetCont ents*>& sheets)
41 : m_dirtiesAllStyle(false) 41 : m_dirtiesAllStyle(false)
42 { 42 {
43 for (unsigned i = 0; i < sheets.size() && !m_dirtiesAllStyle; ++i) 43 for (unsigned i = 0; i < sheets.size() && !m_dirtiesAllStyle; ++i)
44 analyzeStyleSheet(sheets[i]); 44 analyzeStyleSheet(sheets[i]);
45 } 45 }
46 46
47 static bool determineSelectorScopes(const CSSSelectorList& selectorList, HashSet <AtomicStringImpl*>& idScopes, HashSet<AtomicStringImpl*>& classScopes) 47 static bool determineSelectorScopes(const CSSSelectorList& selectorList, HashSet <StringImpl*>& idScopes, HashSet<StringImpl*>& classScopes)
48 { 48 {
49 for (const CSSSelector* selector = selectorList.first(); selector; selector = CSSSelectorList::next(selector)) { 49 for (const CSSSelector* selector = selectorList.first(); selector; selector = CSSSelectorList::next(selector)) {
50 const CSSSelector* scopeSelector = 0; 50 const CSSSelector* scopeSelector = 0;
51 // This picks the widest scope, not the narrowest, to minimize the numbe r of found scopes. 51 // This picks the widest scope, not the narrowest, to minimize the numbe r of found scopes.
52 for (const CSSSelector* current = selector; current; current = current-> tagHistory()) { 52 for (const CSSSelector* current = selector; current; current = current-> tagHistory()) {
53 // Prefer ids over classes. 53 // Prefer ids over classes.
54 if (current->m_match == CSSSelector::Id) 54 if (current->m_match == CSSSelector::Id)
55 scopeSelector = current; 55 scopeSelector = current;
56 else if (current->m_match == CSSSelector::Class && (!scopeSelector | | scopeSelector->m_match != CSSSelector::Id)) 56 else if (current->m_match == CSSSelector::Class && (!scopeSelector | | scopeSelector->m_match != CSSSelector::Id))
57 scopeSelector = current; 57 scopeSelector = current;
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 return; 134 return;
135 } 135 }
136 StyleRule* styleRule = static_cast<StyleRule*>(rule); 136 StyleRule* styleRule = static_cast<StyleRule*>(rule);
137 if (!determineSelectorScopes(styleRule->selectorList(), m_idScopes, m_cl assScopes)) { 137 if (!determineSelectorScopes(styleRule->selectorList(), m_idScopes, m_cl assScopes)) {
138 m_dirtiesAllStyle = true; 138 m_dirtiesAllStyle = true;
139 return; 139 return;
140 } 140 }
141 } 141 }
142 } 142 }
143 143
144 static bool elementMatchesSelectorScopes(const Element* element, const HashSet<A tomicStringImpl*>& idScopes, const HashSet<AtomicStringImpl*>& classScopes) 144 static bool elementMatchesSelectorScopes(const Element* element, const HashSet<S tringImpl*>& idScopes, const HashSet<StringImpl*>& classScopes)
145 { 145 {
146 if (!idScopes.isEmpty() && element->hasID() && idScopes.contains(element->id ForStyleResolution().impl())) 146 if (!idScopes.isEmpty() && element->hasID() && idScopes.contains(element->id ForStyleResolution().impl()))
147 return true; 147 return true;
148 if (classScopes.isEmpty() || !element->hasClass()) 148 if (classScopes.isEmpty() || !element->hasClass())
149 return false; 149 return false;
150 const SpaceSplitString& classNames = element->classNames(); 150 const SpaceSplitString& classNames = element->classNames();
151 for (unsigned i = 0; i < classNames.size(); ++i) { 151 for (unsigned i = 0; i < classNames.size(); ++i) {
152 if (classScopes.contains(classNames[i].impl())) 152 if (classScopes.contains(classNames[i].impl()))
153 return true; 153 return true;
154 } 154 }
(...skipping 17 matching lines...) Expand all
172 element->setNeedsStyleRecalc(); 172 element->setNeedsStyleRecalc();
173 // The whole subtree is now invalidated, we can skip to the next sib ling. 173 // The whole subtree is now invalidated, we can skip to the next sib ling.
174 element = ElementTraversal::nextSkippingChildren(element); 174 element = ElementTraversal::nextSkippingChildren(element);
175 continue; 175 continue;
176 } 176 }
177 element = ElementTraversal::next(element); 177 element = ElementTraversal::next(element);
178 } 178 }
179 } 179 }
180 180
181 } 181 }
OLDNEW
« no previous file with comments | « Source/core/css/StyleInvalidationAnalysis.h ('k') | Source/core/css/resolver/ScopedStyleResolver.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698