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

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

Issue 310443002: Remove scoped styles. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix layout test Created 6 years, 6 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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
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;
90 } 90 }
91 } 91 }
92 return false; 92 return false;
93 } 93 }
94 94
95 static Node* determineScopingNodeForStyleScoped(HTMLStyleElement* ownerElement, StyleSheetContents* styleSheetContents) 95 static Node* determineScopingNodeForStyleScoped(HTMLStyleElement* ownerElement, StyleSheetContents* styleSheetContents)
tasak 2014/06/03 05:57:48 Probably it would be better to rename this functio
kochi 2014/06/03 07:47:05 Done.
96 { 96 {
97 ASSERT(ownerElement && ownerElement->isRegisteredAsScoped()); 97 ASSERT(ownerElement && ownerElement->isScoped());
98 ASSERT(ownerElement->isInShadowTree());
tasak 2014/06/03 05:57:48 Now isScoped() has the same meaning as isInShadowT
kochi 2014/06/03 07:47:05 Reduced to one ASSERT().
98 99
99 if (ownerElement->isInShadowTree()) { 100 if (hasDistributedRule(styleSheetContents)) {
100 if (hasDistributedRule(styleSheetContents)) { 101 ContainerNode* scope = ownerElement;
101 ContainerNode* scope = ownerElement; 102 do {
102 do { 103 scope = scope->containingShadowRoot()->shadowHost();
103 scope = scope->containingShadowRoot()->shadowHost(); 104 } while (scope->isInShadowTree());
104 } while (scope->isInShadowTree()); 105 return scope;
105
106 return scope;
107 }
108 if (ownerElement->isRegisteredAsScoped())
109 return ownerElement->containingShadowRoot()->shadowHost();
110 } 106 }
111 107
112 return ownerElement->isRegisteredInShadowRoot() ? ownerElement->containingSh adowRoot()->shadowHost() : ownerElement->parentNode(); 108 return ownerElement->containingShadowRoot()->shadowHost();
113 } 109 }
114 110
115 static bool ruleAdditionMightRequireDocumentStyleRecalc(StyleRuleBase* rule) 111 static bool ruleAdditionMightRequireDocumentStyleRecalc(StyleRuleBase* rule)
116 { 112 {
117 // This funciton is conservative. We only return false when we know that 113 // This funciton is conservative. We only return false when we know that
118 // the added @rule can't require style recalcs. 114 // the added @rule can't require style recalcs.
119 switch (rule->type()) { 115 switch (rule->type()) {
120 case StyleRule::Import: // Whatever we import should do its own analysis, we don't need to invalidate the document here! 116 case StyleRule::Import: // Whatever we import should do its own analysis, we don't need to invalidate the document here!
121 case StyleRule::Keyframes: // Keyframes never cause style invalidations and are handled during sheet insertion. 117 case StyleRule::Keyframes: // Keyframes never cause style invalidations and are handled during sheet insertion.
122 case StyleRule::Page: // Page rules apply only during printing, we force a f ull-recalc before printing. 118 case StyleRule::Page: // Page rules apply only during printing, we force a f ull-recalc before printing.
(...skipping 27 matching lines...) Expand all
150 const WillBeHeapVector<RefPtrWillBeMember<StyleRuleImport> >& importRules = styleSheetContents->importRules(); 146 const WillBeHeapVector<RefPtrWillBeMember<StyleRuleImport> >& importRules = styleSheetContents->importRules();
151 for (unsigned i = 0; i < importRules.size(); ++i) { 147 for (unsigned i = 0; i < importRules.size(); ++i) {
152 if (!importRules[i]->styleSheet()) 148 if (!importRules[i]->styleSheet())
153 continue; 149 continue;
154 analyzeStyleSheet(importRules[i]->styleSheet()); 150 analyzeStyleSheet(importRules[i]->styleSheet());
155 if (m_dirtiesAllStyle) 151 if (m_dirtiesAllStyle)
156 return; 152 return;
157 } 153 }
158 if (styleSheetContents->hasSingleOwnerNode()) { 154 if (styleSheetContents->hasSingleOwnerNode()) {
159 Node* ownerNode = styleSheetContents->singleOwnerNode(); 155 Node* ownerNode = styleSheetContents->singleOwnerNode();
160 if (isHTMLStyleElement(ownerNode) && toHTMLStyleElement(*ownerNode).isRe gisteredAsScoped()) { 156 if (isHTMLStyleElement(ownerNode) && toHTMLStyleElement(*ownerNode).isSc oped()) {
161 m_scopingNodes.append(determineScopingNodeForStyleScoped(toHTMLStyle Element(ownerNode), styleSheetContents)); 157 m_scopingNodes.append(determineScopingNodeForStyleScoped(toHTMLStyle Element(ownerNode), styleSheetContents));
162 return; 158 return;
163 } 159 }
164 } 160 }
165 161
166 const WillBeHeapVector<RefPtrWillBeMember<StyleRuleBase> >& rules = styleShe etContents->childRules(); 162 const WillBeHeapVector<RefPtrWillBeMember<StyleRuleBase> >& rules = styleShe etContents->childRules();
167 for (unsigned i = 0; i < rules.size(); i++) { 163 for (unsigned i = 0; i < rules.size(); i++) {
168 StyleRuleBase* rule = rules[i].get(); 164 StyleRuleBase* rule = rules[i].get();
169 if (!rule->isStyleRule()) { 165 if (!rule->isStyleRule()) {
170 if (ruleAdditionMightRequireDocumentStyleRecalc(rule)) { 166 if (ruleAdditionMightRequireDocumentStyleRecalc(rule)) {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 element->setNeedsStyleRecalc(SubtreeStyleChange); 208 element->setNeedsStyleRecalc(SubtreeStyleChange);
213 // The whole subtree is now invalidated, we can skip to the next sib ling. 209 // The whole subtree is now invalidated, we can skip to the next sib ling.
214 element = ElementTraversal::nextSkippingChildren(*element); 210 element = ElementTraversal::nextSkippingChildren(*element);
215 continue; 211 continue;
216 } 212 }
217 element = ElementTraversal::next(*element); 213 element = ElementTraversal::next(*element);
218 } 214 }
219 } 215 }
220 216
221 } 217 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698