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

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

Issue 1311463004: Invalidate style from shadow host, not root, to apply :host rules. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 3 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
« no previous file with comments | « LayoutTests/fast/css/invalidation/shadow-add-sheet-host-expected.txt ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 if (classScopes.isEmpty() || !element->hasClass()) 170 if (classScopes.isEmpty() || !element->hasClass())
171 return false; 171 return false;
172 const SpaceSplitString& classNames = element->classNames(); 172 const SpaceSplitString& classNames = element->classNames();
173 for (unsigned i = 0; i < classNames.size(); ++i) { 173 for (unsigned i = 0; i < classNames.size(); ++i) {
174 if (classScopes.contains(classNames[i].impl())) 174 if (classScopes.contains(classNames[i].impl()))
175 return true; 175 return true;
176 } 176 }
177 return false; 177 return false;
178 } 178 }
179 179
180 static ContainerNode* outermostShadowHost(const ShadowRoot& root) 180 static ContainerNode* outermostShadowHost(ContainerNode& host)
181 { 181 {
182 ContainerNode* host = root.host(); 182 ContainerNode* outerHost = &host;
183 while (host->isInShadowTree()) 183 while (outerHost->isInShadowTree())
184 host = host->containingShadowRoot()->host(); 184 outerHost = outerHost->containingShadowRoot()->host();
185 return host; 185 return outerHost;
186 } 186 }
187 187
188 void StyleSheetInvalidationAnalysis::invalidateStyle() 188 void StyleSheetInvalidationAnalysis::invalidateStyle()
189 { 189 {
190 ASSERT(!m_dirtiesAllStyle); 190 ASSERT(!m_dirtiesAllStyle);
191 191
192 if (m_treeScope->rootNode().isShadowRoot()) { 192 if (m_treeScope->rootNode().isShadowRoot()) {
193 ContainerNode* invalidationRoot = &m_treeScope->rootNode(); 193 ContainerNode* invalidationRoot = toShadowRoot(m_treeScope->rootNode()). host();
194 if (m_hasDistributedRules) 194 if (m_hasDistributedRules)
195 invalidationRoot = outermostShadowHost(*toShadowRoot(invalidationRoo t)); 195 invalidationRoot = outermostShadowHost(*invalidationRoot);
196 invalidationRoot->setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeRea sonForTracing::create(StyleChangeReason::StyleSheetChange)); 196 invalidationRoot->setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeRea sonForTracing::create(StyleChangeReason::StyleSheetChange));
197 return; 197 return;
198 } 198 }
199 199
200 if (m_idScopes.isEmpty() && m_classScopes.isEmpty()) 200 if (m_idScopes.isEmpty() && m_classScopes.isEmpty())
201 return; 201 return;
202 Element* element = ElementTraversal::firstWithin(m_treeScope->document()); 202 Element* element = ElementTraversal::firstWithin(m_treeScope->document());
203 while (element) { 203 while (element) {
204 if (elementMatchesSelectorScopes(element, m_idScopes, m_classScopes)) { 204 if (elementMatchesSelectorScopes(element, m_idScopes, m_classScopes)) {
205 element->setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonFo rTracing::create(StyleChangeReason::StyleSheetChange)); 205 element->setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonFo rTracing::create(StyleChangeReason::StyleSheetChange));
206 // The whole subtree is now invalidated, we can skip to the next sib ling. 206 // The whole subtree is now invalidated, we can skip to the next sib ling.
207 element = ElementTraversal::nextSkippingChildren(*element); 207 element = ElementTraversal::nextSkippingChildren(*element);
208 continue; 208 continue;
209 } 209 }
210 element = ElementTraversal::next(*element); 210 element = ElementTraversal::next(*element);
211 } 211 }
212 } 212 }
213 213
214 } 214 }
OLDNEW
« no previous file with comments | « LayoutTests/fast/css/invalidation/shadow-add-sheet-host-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698