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

Side by Side Diff: Source/core/css/invalidation/StyleSheetInvalidationAnalysis.cpp

Issue 993713002: Fix template angle bracket syntax in CSS subdirs (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 9 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) 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 19 matching lines...) Expand all
30 #include "core/css/StyleRuleImport.h" 30 #include "core/css/StyleRuleImport.h"
31 #include "core/css/StyleSheetContents.h" 31 #include "core/css/StyleSheetContents.h"
32 #include "core/dom/ContainerNode.h" 32 #include "core/dom/ContainerNode.h"
33 #include "core/dom/Document.h" 33 #include "core/dom/Document.h"
34 #include "core/dom/ElementTraversal.h" 34 #include "core/dom/ElementTraversal.h"
35 #include "core/dom/shadow/ShadowRoot.h" 35 #include "core/dom/shadow/ShadowRoot.h"
36 #include "core/html/HTMLStyleElement.h" 36 #include "core/html/HTMLStyleElement.h"
37 37
38 namespace blink { 38 namespace blink {
39 39
40 StyleSheetInvalidationAnalysis::StyleSheetInvalidationAnalysis(const WillBeHeapV ector<RawPtrWillBeMember<StyleSheetContents> >& sheets) 40 StyleSheetInvalidationAnalysis::StyleSheetInvalidationAnalysis(const WillBeHeapV ector<RawPtrWillBeMember<StyleSheetContents>>& 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 <StringImpl*>& idScopes, HashSet<StringImpl*>& 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;
(...skipping 18 matching lines...) Expand all
69 if (scopeSelector->match() == CSSSelector::Id) 69 if (scopeSelector->match() == CSSSelector::Id)
70 idScopes.add(scopeSelector->value().impl()); 70 idScopes.add(scopeSelector->value().impl());
71 else 71 else
72 classScopes.add(scopeSelector->value().impl()); 72 classScopes.add(scopeSelector->value().impl());
73 } 73 }
74 return true; 74 return true;
75 } 75 }
76 76
77 static bool hasDistributedRule(StyleSheetContents* styleSheetContents) 77 static bool hasDistributedRule(StyleSheetContents* styleSheetContents)
78 { 78 {
79 const WillBeHeapVector<RefPtrWillBeMember<StyleRuleBase> >& rules = styleShe etContents->childRules(); 79 const WillBeHeapVector<RefPtrWillBeMember<StyleRuleBase>>& rules = styleShee tContents->childRules();
80 for (unsigned i = 0; i < rules.size(); i++) { 80 for (unsigned i = 0; i < rules.size(); i++) {
81 const StyleRuleBase* rule = rules[i].get(); 81 const StyleRuleBase* rule = rules[i].get();
82 if (!rule->isStyleRule()) 82 if (!rule->isStyleRule())
83 continue; 83 continue;
84 84
85 const StyleRule* styleRule = toStyleRule(rule); 85 const StyleRule* styleRule = toStyleRule(rule);
86 const CSSSelectorList& selectorList = styleRule->selectorList(); 86 const CSSSelectorList& selectorList = styleRule->selectorList();
87 for (size_t selectorIndex = 0; selectorIndex != kNotFound; selectorIndex = selectorList.indexOfNextSelectorAfter(selectorIndex)) { 87 for (size_t selectorIndex = 0; selectorIndex != kNotFound; selectorIndex = selectorList.indexOfNextSelectorAfter(selectorIndex)) {
88 if (selectorList.hasShadowDistributedAt(selectorIndex)) 88 if (selectorList.hasShadowDistributedAt(selectorIndex))
89 return true; 89 return true;
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 void StyleSheetInvalidationAnalysis::analyzeStyleSheet(StyleSheetContents* style SheetContents) 137 void StyleSheetInvalidationAnalysis::analyzeStyleSheet(StyleSheetContents* style SheetContents)
138 { 138 {
139 // Updating the style on the shadow DOM for image fallback content can bring us here when imports 139 // Updating the style on the shadow DOM for image fallback content can bring us here when imports
140 // are still getting loaded in the main document. Just need to exit early as we will return here 140 // are still getting loaded in the main document. Just need to exit early as we will return here
141 // when the imports finish loading. 141 // when the imports finish loading.
142 if (styleSheetContents->isLoading()) 142 if (styleSheetContents->isLoading())
143 return; 143 return;
144 144
145 // See if all rules on the sheet are scoped to some specific ids or classes. 145 // See if all rules on the sheet are scoped to some specific ids or classes.
146 // Then test if we actually have any of those in the tree at the moment. 146 // Then test if we actually have any of those in the tree at the moment.
147 const WillBeHeapVector<RefPtrWillBeMember<StyleRuleImport> >& importRules = styleSheetContents->importRules(); 147 const WillBeHeapVector<RefPtrWillBeMember<StyleRuleImport>>& importRules = s tyleSheetContents->importRules();
148 for (unsigned i = 0; i < importRules.size(); ++i) { 148 for (unsigned i = 0; i < importRules.size(); ++i) {
149 if (!importRules[i]->styleSheet()) 149 if (!importRules[i]->styleSheet())
150 continue; 150 continue;
151 analyzeStyleSheet(importRules[i]->styleSheet()); 151 analyzeStyleSheet(importRules[i]->styleSheet());
152 if (m_dirtiesAllStyle) 152 if (m_dirtiesAllStyle)
153 return; 153 return;
154 } 154 }
155 if (styleSheetContents->hasSingleOwnerNode()) { 155 if (styleSheetContents->hasSingleOwnerNode()) {
156 Node* ownerNode = styleSheetContents->singleOwnerNode(); 156 Node* ownerNode = styleSheetContents->singleOwnerNode();
157 if (isHTMLStyleElement(ownerNode) && toHTMLStyleElement(*ownerNode).isIn ShadowTree()) { 157 if (isHTMLStyleElement(ownerNode) && toHTMLStyleElement(*ownerNode).isIn ShadowTree()) {
158 m_scopingNodes.append(determineScopingNodeForStyleInShadow(toHTMLSty leElement(ownerNode), styleSheetContents)); 158 m_scopingNodes.append(determineScopingNodeForStyleInShadow(toHTMLSty leElement(ownerNode), styleSheetContents));
159 return; 159 return;
160 } 160 }
161 } 161 }
162 162
163 const WillBeHeapVector<RefPtrWillBeMember<StyleRuleBase> >& rules = styleShe etContents->childRules(); 163 const WillBeHeapVector<RefPtrWillBeMember<StyleRuleBase>>& rules = styleShee tContents->childRules();
164 for (unsigned i = 0; i < rules.size(); i++) { 164 for (unsigned i = 0; i < rules.size(); i++) {
165 StyleRuleBase* rule = rules[i].get(); 165 StyleRuleBase* rule = rules[i].get();
166 if (!rule->isStyleRule()) { 166 if (!rule->isStyleRule()) {
167 if (ruleAdditionMightRequireDocumentStyleRecalc(rule)) { 167 if (ruleAdditionMightRequireDocumentStyleRecalc(rule)) {
168 m_dirtiesAllStyle = true; 168 m_dirtiesAllStyle = true;
169 return; 169 return;
170 } 170 }
171 continue; 171 continue;
172 } 172 }
173 StyleRule* styleRule = toStyleRule(rule); 173 StyleRule* styleRule = toStyleRule(rule);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 element->setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonFo rTracing::create(StyleChangeReason::StyleSheetChange)); 209 element->setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonFo rTracing::create(StyleChangeReason::StyleSheetChange));
210 // The whole subtree is now invalidated, we can skip to the next sib ling. 210 // The whole subtree is now invalidated, we can skip to the next sib ling.
211 element = ElementTraversal::nextSkippingChildren(*element); 211 element = ElementTraversal::nextSkippingChildren(*element);
212 continue; 212 continue;
213 } 213 }
214 element = ElementTraversal::next(*element); 214 element = ElementTraversal::next(*element);
215 } 215 }
216 } 216 }
217 217
218 } 218 }
OLDNEW
« no previous file with comments | « Source/core/css/invalidation/StyleSheetInvalidationAnalysis.h ('k') | Source/core/css/parser/BisonCSSParser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698