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

Side by Side Diff: third_party/WebKit/Source/core/dom/TreeScopeStyleSheetCollection.cpp

Issue 2553343002: Avoid WTF::Vector::at() and operator[] in core/dom. (Closed)
Patch Set: Created 4 years 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 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org)
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 Apple Inc. All 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 Apple Inc. All
7 * rights reserved. 7 * rights reserved.
8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved.
9 * (http://www.torchmobile.com/) 9 * (http://www.torchmobile.com/)
10 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) 10 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 // existing StyleResolver. If there were insertions we need to re-add all the 82 // existing StyleResolver. If there were insertions we need to re-add all the
83 // stylesheets so rules are ordered correctly. 83 // stylesheets so rules are ordered correctly.
84 return hasInsertions ? Reset : Additive; 84 return hasInsertions ? Reset : Additive;
85 } 85 }
86 86
87 bool TreeScopeStyleSheetCollection::activeLoadingStyleSheetLoaded( 87 bool TreeScopeStyleSheetCollection::activeLoadingStyleSheetLoaded(
88 const HeapVector<Member<CSSStyleSheet>>& newStyleSheets) { 88 const HeapVector<Member<CSSStyleSheet>>& newStyleSheets) {
89 // StyleSheets of <style> elements that @import stylesheets are active but 89 // StyleSheets of <style> elements that @import stylesheets are active but
90 // loading. We need to trigger a full recalc when such loads are done. 90 // loading. We need to trigger a full recalc when such loads are done.
91 bool hasActiveLoadingStylesheet = false; 91 bool hasActiveLoadingStylesheet = false;
92 unsigned newStylesheetCount = newStyleSheets.size(); 92 for (const auto& sheet : newStyleSheets) {
93 for (unsigned i = 0; i < newStylesheetCount; ++i) { 93 if (sheet->isLoading())
94 if (newStyleSheets[i]->isLoading())
95 hasActiveLoadingStylesheet = true; 94 hasActiveLoadingStylesheet = true;
96 } 95 }
97 if (m_hadActiveLoadingStylesheet && !hasActiveLoadingStylesheet) { 96 if (m_hadActiveLoadingStylesheet && !hasActiveLoadingStylesheet) {
98 m_hadActiveLoadingStylesheet = false; 97 m_hadActiveLoadingStylesheet = false;
99 return true; 98 return true;
100 } 99 }
101 m_hadActiveLoadingStylesheet = hasActiveLoadingStylesheet; 100 m_hadActiveLoadingStylesheet = hasActiveLoadingStylesheet;
102 return false; 101 return false;
103 } 102 }
104 103
105 static bool findFontFaceRulesFromStyleSheetContents( 104 static bool findFontFaceRulesFromStyleSheetContents(
106 const HeapVector<Member<StyleSheetContents>>& sheets, 105 const HeapVector<Member<StyleSheetContents>>& sheets,
107 HeapVector<Member<const StyleRuleFontFace>>& fontFaceRules) { 106 HeapVector<Member<const StyleRuleFontFace>>& fontFaceRules) {
108 bool hasFontFaceRule = false; 107 bool hasFontFaceRule = false;
109 108
110 for (unsigned i = 0; i < sheets.size(); ++i) { 109 for (const auto& sheet : sheets) {
111 DCHECK(sheets[i]); 110 DCHECK(sheet);
112 if (sheets[i]->hasFontFaceRule()) { 111 if (sheet->hasFontFaceRule()) {
113 // FIXME: We don't need this for styles in shadow tree. 112 // FIXME: We don't need this for styles in shadow tree.
114 sheets[i]->findFontFaceRules(fontFaceRules); 113 sheet->findFontFaceRules(fontFaceRules);
115 hasFontFaceRule = true; 114 hasFontFaceRule = true;
116 } 115 }
117 } 116 }
118 return hasFontFaceRule; 117 return hasFontFaceRule;
119 } 118 }
120 119
121 void TreeScopeStyleSheetCollection::analyzeStyleSheetChange( 120 void TreeScopeStyleSheetCollection::analyzeStyleSheetChange(
122 StyleResolverUpdateMode updateMode, 121 StyleResolverUpdateMode updateMode,
123 const HeapVector<Member<CSSStyleSheet>>& newActiveAuthorStyleSheets, 122 const HeapVector<Member<CSSStyleSheet>>& newActiveAuthorStyleSheets,
124 StyleSheetChange& change) { 123 StyleSheetChange& change) {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 StyleSheetInvalidationAnalysis invalidationAnalysis(*m_treeScope, 163 StyleSheetInvalidationAnalysis invalidationAnalysis(*m_treeScope,
165 addedSheets); 164 addedSheets);
166 if (invalidationAnalysis.dirtiesAllStyle()) 165 if (invalidationAnalysis.dirtiesAllStyle())
167 return; 166 return;
168 invalidationAnalysis.invalidateStyle(); 167 invalidationAnalysis.invalidateStyle();
169 change.requiresFullStyleRecalc = false; 168 change.requiresFullStyleRecalc = false;
170 return; 169 return;
171 } 170 }
172 171
173 void TreeScopeStyleSheetCollection::clearMediaQueryRuleSetStyleSheets() { 172 void TreeScopeStyleSheetCollection::clearMediaQueryRuleSetStyleSheets() {
174 for (size_t i = 0; i < m_activeAuthorStyleSheets.size(); ++i) { 173 for (const auto& sheet : m_activeAuthorStyleSheets) {
175 StyleSheetContents* contents = m_activeAuthorStyleSheets[i]->contents(); 174 StyleSheetContents* contents = sheet->contents();
176 if (contents->hasMediaQueries()) 175 if (contents->hasMediaQueries())
177 contents->clearRuleSet(); 176 contents->clearRuleSet();
178 } 177 }
179 } 178 }
180 179
181 DEFINE_TRACE(TreeScopeStyleSheetCollection) { 180 DEFINE_TRACE(TreeScopeStyleSheetCollection) {
182 visitor->trace(m_treeScope); 181 visitor->trace(m_treeScope);
183 visitor->trace(m_styleSheetCandidateNodes); 182 visitor->trace(m_styleSheetCandidateNodes);
184 StyleSheetCollection::trace(visitor); 183 StyleSheetCollection::trace(visitor);
185 } 184 }
186 185
187 } // namespace blink 186 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698