Index: Source/core/dom/ContainerNode.cpp |
diff --git a/Source/core/dom/ContainerNode.cpp b/Source/core/dom/ContainerNode.cpp |
index 19d79ab8704453a72d111d5a649e1d7f66f26f27..fed648dbb0002f7a4a4f906e439df3f33500c162 100644 |
--- a/Source/core/dom/ContainerNode.cpp |
+++ b/Source/core/dom/ContainerNode.cpp |
@@ -1116,20 +1116,16 @@ void ContainerNode::checkForChildrenAdjacentRuleChanges() |
bool forceCheckOfAnyElementSibling = false; |
Document& document = this->document(); |
- for (Node* child = firstChild(); child; child = child->nextSibling()) { |
- if (!child->isElementNode()) |
- continue; |
- Element* element = toElement(child); |
- bool childRulesChanged = element->needsStyleRecalc() && element->styleChangeType() >= SubtreeStyleChange; |
+ for (Element* child = ElementTraversal::firstChild(*this); child; child = ElementTraversal::nextSibling(*child)) { |
+ bool childRulesChanged = child->needsStyleRecalc() && child->styleChangeType() >= SubtreeStyleChange; |
if (forceCheckOfNextElementCount || forceCheckOfAnyElementSibling) |
- element->setNeedsStyleRecalc(SubtreeStyleChange); |
- |
- if (forceCheckOfNextElementCount) |
- forceCheckOfNextElementCount--; |
+ child->setNeedsStyleRecalc(SubtreeStyleChange); |
if (childRulesChanged && hasDirectAdjacentRules) |
forceCheckOfNextElementCount = document.styleEngine()->maxDirectAdjacentSelectors(); |
+ else if (forceCheckOfNextElementCount) |
+ --forceCheckOfNextElementCount; |
forceCheckOfAnyElementSibling = forceCheckOfAnyElementSibling || (childRulesChanged && hasIndirectAdjacentRules); |
} |