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

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

Issue 315173002: Revert of Remove scoped styles. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: 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* determineScopingNodeForStyleInShadow(HTMLStyleElement* ownerElement , StyleSheetContents* styleSheetContents) 95 static Node* determineScopingNodeForStyleScoped(HTMLStyleElement* ownerElement, StyleSheetContents* styleSheetContents)
96 { 96 {
97 ASSERT(ownerElement && ownerElement->isInShadowTree()); 97 ASSERT(ownerElement && ownerElement->isRegisteredAsScoped());
98 98
99 if (hasDistributedRule(styleSheetContents)) { 99 if (ownerElement->isInShadowTree()) {
100 ContainerNode* scope = ownerElement; 100 if (hasDistributedRule(styleSheetContents)) {
101 do { 101 ContainerNode* scope = ownerElement;
102 scope = scope->containingShadowRoot()->shadowHost(); 102 do {
103 } while (scope->isInShadowTree()); 103 scope = scope->containingShadowRoot()->shadowHost();
104 return scope; 104 } while (scope->isInShadowTree());
105
106 return scope;
107 }
108 if (ownerElement->isRegisteredAsScoped())
109 return ownerElement->containingShadowRoot()->shadowHost();
105 } 110 }
106 111
107 return ownerElement->containingShadowRoot()->shadowHost(); 112 return ownerElement->isRegisteredInShadowRoot() ? ownerElement->containingSh adowRoot()->shadowHost() : ownerElement->parentNode();
108 } 113 }
109 114
110 static bool ruleAdditionMightRequireDocumentStyleRecalc(StyleRuleBase* rule) 115 static bool ruleAdditionMightRequireDocumentStyleRecalc(StyleRuleBase* rule)
111 { 116 {
112 // This funciton is conservative. We only return false when we know that 117 // This funciton is conservative. We only return false when we know that
113 // the added @rule can't require style recalcs. 118 // the added @rule can't require style recalcs.
114 switch (rule->type()) { 119 switch (rule->type()) {
115 case StyleRule::Import: // Whatever we import should do its own analysis, we don't need to invalidate the document here! 120 case StyleRule::Import: // Whatever we import should do its own analysis, we don't need to invalidate the document here!
116 case StyleRule::Keyframes: // Keyframes never cause style invalidations and are handled during sheet insertion. 121 case StyleRule::Keyframes: // Keyframes never cause style invalidations and are handled during sheet insertion.
117 case StyleRule::Page: // Page rules apply only during printing, we force a f ull-recalc before printing. 122 case StyleRule::Page: // Page rules apply only during printing, we force a f ull-recalc before printing.
(...skipping 27 matching lines...) Expand all
145 const WillBeHeapVector<RefPtrWillBeMember<StyleRuleImport> >& importRules = styleSheetContents->importRules(); 150 const WillBeHeapVector<RefPtrWillBeMember<StyleRuleImport> >& importRules = styleSheetContents->importRules();
146 for (unsigned i = 0; i < importRules.size(); ++i) { 151 for (unsigned i = 0; i < importRules.size(); ++i) {
147 if (!importRules[i]->styleSheet()) 152 if (!importRules[i]->styleSheet())
148 continue; 153 continue;
149 analyzeStyleSheet(importRules[i]->styleSheet()); 154 analyzeStyleSheet(importRules[i]->styleSheet());
150 if (m_dirtiesAllStyle) 155 if (m_dirtiesAllStyle)
151 return; 156 return;
152 } 157 }
153 if (styleSheetContents->hasSingleOwnerNode()) { 158 if (styleSheetContents->hasSingleOwnerNode()) {
154 Node* ownerNode = styleSheetContents->singleOwnerNode(); 159 Node* ownerNode = styleSheetContents->singleOwnerNode();
155 if (isHTMLStyleElement(ownerNode) && toHTMLStyleElement(*ownerNode).isIn ShadowTree()) { 160 if (isHTMLStyleElement(ownerNode) && toHTMLStyleElement(*ownerNode).isRe gisteredAsScoped()) {
156 m_scopingNodes.append(determineScopingNodeForStyleInShadow(toHTMLSty leElement(ownerNode), styleSheetContents)); 161 m_scopingNodes.append(determineScopingNodeForStyleScoped(toHTMLStyle Element(ownerNode), styleSheetContents));
157 return; 162 return;
158 } 163 }
159 } 164 }
160 165
161 const WillBeHeapVector<RefPtrWillBeMember<StyleRuleBase> >& rules = styleShe etContents->childRules(); 166 const WillBeHeapVector<RefPtrWillBeMember<StyleRuleBase> >& rules = styleShe etContents->childRules();
162 for (unsigned i = 0; i < rules.size(); i++) { 167 for (unsigned i = 0; i < rules.size(); i++) {
163 StyleRuleBase* rule = rules[i].get(); 168 StyleRuleBase* rule = rules[i].get();
164 if (!rule->isStyleRule()) { 169 if (!rule->isStyleRule()) {
165 if (ruleAdditionMightRequireDocumentStyleRecalc(rule)) { 170 if (ruleAdditionMightRequireDocumentStyleRecalc(rule)) {
166 m_dirtiesAllStyle = true; 171 m_dirtiesAllStyle = true;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 element->setNeedsStyleRecalc(SubtreeStyleChange); 212 element->setNeedsStyleRecalc(SubtreeStyleChange);
208 // The whole subtree is now invalidated, we can skip to the next sib ling. 213 // The whole subtree is now invalidated, we can skip to the next sib ling.
209 element = ElementTraversal::nextSkippingChildren(*element); 214 element = ElementTraversal::nextSkippingChildren(*element);
210 continue; 215 continue;
211 } 216 }
212 element = ElementTraversal::next(*element); 217 element = ElementTraversal::next(*element);
213 } 218 }
214 } 219 }
215 220
216 } 221 }
OLDNEW
« no previous file with comments | « LayoutTests/fast/dom/shadow/style-scoped-not-enabled-expected.txt ('k') | Source/core/css/resolver/ScopedStyleResolver.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698