Index: third_party/WebKit/Source/core/dom/ContainerNode.cpp |
diff --git a/third_party/WebKit/Source/core/dom/ContainerNode.cpp b/third_party/WebKit/Source/core/dom/ContainerNode.cpp |
index d79ca295123a608636d760e440f2afc8dd9c9ea9..56e6d7f94a91ca27078ad1250620c405b0e82712 100644 |
--- a/third_party/WebKit/Source/core/dom/ContainerNode.cpp |
+++ b/third_party/WebKit/Source/core/dom/ContainerNode.cpp |
@@ -1229,6 +1229,9 @@ void ContainerNode::checkForSiblingStyleChanges(SiblingCheckType changeType, Ele |
if (!hasRestyleFlag(ChildrenAffectedByStructuralRules)) |
return; |
+ Element* elementAfterChange = !nodeAfterChange || nodeAfterChange->isElementNode() ? toElement(nodeAfterChange) : ElementTraversal::nextSibling(*nodeAfterChange); |
+ Element* elementBeforeChange = !nodeBeforeChange || nodeBeforeChange->isElementNode() ? toElement(nodeBeforeChange) : ElementTraversal::previousSibling(*nodeBeforeChange); |
+ |
// Forward positional selectors include :nth-child, :nth-of-type, |
// :first-of-type, and only-of-type. The indirect adjacent selector is the ~ |
// selector. Backward positional selectors include :nth-last-child, |
@@ -1241,15 +1244,12 @@ void ContainerNode::checkForSiblingStyleChanges(SiblingCheckType changeType, Ele |
// don't want to make childrenChanged O(n^2) by crawling all our kids here. |
// recalcStyle will then force a walk of the children when it sees that this |
// has happened. |
- if ((childrenAffectedByForwardPositionalRules() && nodeAfterChange) |
- || (childrenAffectedByBackwardPositionalRules() && nodeBeforeChange)) { |
+ if ((childrenAffectedByForwardPositionalRules() && elementAfterChange) |
+ || (childrenAffectedByBackwardPositionalRules() && elementBeforeChange)) { |
setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTracing::create(StyleChangeReason::SiblingSelector)); |
return; |
} |
- Element* elementAfterChange = !nodeAfterChange || nodeAfterChange->isElementNode() ? toElement(nodeAfterChange) : ElementTraversal::nextSibling(*nodeAfterChange); |
- Element* elementBeforeChange = !nodeBeforeChange || nodeBeforeChange->isElementNode() ? toElement(nodeBeforeChange) : ElementTraversal::previousSibling(*nodeBeforeChange); |
- |
if (childrenAffectedByFirstChildRules() && !elementBeforeChange && elementAfterChange && elementAfterChange->affectedByFirstChildRules()) { |
DCHECK_NE(changeType, FinishedParsingChildren); |
elementAfterChange->pseudoStateChanged(CSSSelector::PseudoFirstChild); |