void StyleInvalidationAnalysis::invalidateStyle(Document* document) { ASSERT(!m_dirtiesAllStyle); if (m_idScopes.isEmpty() && m_classScopes.isEmpty()) return; Element* element = ElementTraversal::firstWithin(document); while (element) { if (elementMatchesSelectorScopes(element, m_idScopes, m_classScopes)) { element->setNeedsStyleRecalc(); // The whole subtree is now invalidated, we can skip to the next sibling. element = ElementTraversal::nextSkippingChildren(element); continue; } element = ElementTraversal::next(element); } }
void StyleInvalidationAnalysis::invalidateStyle(Document* document) { ASSERT(!m_dirtiesAllStyle); if (m_idScopes.isEmpty() && m_classScopes.isEmpty()) return; Node* node = document->firstChild(); while (node) { if (!node->isStyledElement()) { node = NodeTraversal::next(node); continue; } StyledElement* element = static_cast<StyledElement*>(node); if (elementMatchesSelectorScopes(element, m_idScopes, m_classScopes)) { element->setNeedsStyleRecalc(); // The whole subtree is now invalidated, we can skip to the next sibling. node = NodeTraversal::nextSkippingChildren(node); continue; } node = NodeTraversal::next(node); } }
void StyleSheetInvalidationAnalysis::invalidateStyle() { ASSERT(!m_dirtiesAllStyle); if (m_treeScope->rootNode().isShadowRoot()) { ContainerNode* shadowHost = toShadowRoot(m_treeScope->rootNode()).host(); shadowHost->setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTracing::create(StyleChangeReason::StyleSheetChange)); return; } if (m_idScopes.isEmpty() && m_classScopes.isEmpty()) return; Element* element = ElementTraversal::firstWithin(m_treeScope->document()); while (element) { if (elementMatchesSelectorScopes(element, m_idScopes, m_classScopes)) { element->setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTracing::create(StyleChangeReason::StyleSheetChange)); // The whole subtree is now invalidated, we can skip to the next sibling. element = ElementTraversal::nextSkippingChildren(*element); continue; } element = ElementTraversal::next(*element); } }