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

Unified Diff: Source/core/dom/ContainerNode.cpp

Issue 380073002: Rename variables in ContainerNode::checkForSiblingStyleChanges() for clarity (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/dom/ContainerNode.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/ContainerNode.cpp
diff --git a/Source/core/dom/ContainerNode.cpp b/Source/core/dom/ContainerNode.cpp
index 71aaabaefc7a916f48eb9d6fcbe36fbf272feeab..a4c5c90a7c0e563295bfd4c1c83a0f42c01753cc 100644
--- a/Source/core/dom/ContainerNode.cpp
+++ b/Source/core/dom/ContainerNode.cpp
@@ -1151,7 +1151,7 @@ void ContainerNode::checkForChildrenAdjacentRuleChanges()
}
}
-void ContainerNode::checkForSiblingStyleChanges(SiblingCheckType changeType, Node* beforeChange, Node* afterChange)
+void ContainerNode::checkForSiblingStyleChanges(SiblingCheckType changeType, Node* nodeBeforeChange, Node* nodeAfterChange)
Inactive 2014/07/10 01:05:11 Possible improvement idea: it seems like we are ca
{
if (!inActiveDocument() || document().hasPendingForcedStyleRecalc() || styleChangeType() >= SubtreeStyleChange)
return;
@@ -1167,8 +1167,8 @@ void ContainerNode::checkForSiblingStyleChanges(SiblingCheckType changeType, Nod
// |afterChange| is 0 in the parser callback case, so we won't do any work for the forward case if we don't have to.
// For performance reasons we just mark the parent node as changed, since we 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() || childrenAffectedByIndirectAdjacentRules()) && afterChange)
- || (childrenAffectedByBackwardPositionalRules() && beforeChange)) {
+ if (((childrenAffectedByForwardPositionalRules() || childrenAffectedByIndirectAdjacentRules()) && nodeAfterChange)
Inactive 2014/07/10 01:05:11 Possible improvement idea: it seems like we may be
+ || (childrenAffectedByBackwardPositionalRules() && nodeBeforeChange)) {
Inactive 2014/07/10 01:05:11 Possible improvement idea: it seems like we may be
setNeedsStyleRecalc(SubtreeStyleChange);
return;
}
@@ -1176,49 +1176,51 @@ void ContainerNode::checkForSiblingStyleChanges(SiblingCheckType changeType, Nod
// :first-child. In the parser callback case, we don't have to check anything, since we were right the first time.
// In the DOM case, we only need to do something if |afterChange| is not 0.
// |afterChange| is 0 in the parser case, so it works out that we'll skip this block.
- if (childrenAffectedByFirstChildRules() && afterChange) {
- // Find our new first child.
- Element* newFirstChild = ElementTraversal::firstWithin(*this);
- RenderStyle* newFirstChildStyle = newFirstChild ? newFirstChild->renderStyle() : 0;
-
- // Find the first element node following |afterChange|
- Node* firstElementAfterInsertion = afterChange->isElementNode() ? afterChange : ElementTraversal::nextSibling(*afterChange);
- RenderStyle* firstElementAfterInsertionStyle = firstElementAfterInsertion ? firstElementAfterInsertion->renderStyle() : 0;
-
- // This is the insert/append case.
- if (newFirstChild != firstElementAfterInsertion && firstElementAfterInsertionStyle && firstElementAfterInsertionStyle->firstChildState())
- firstElementAfterInsertion->setNeedsStyleRecalc(SubtreeStyleChange);
-
- // We also have to handle node removal.
- if (changeType == SiblingRemoved && newFirstChild == firstElementAfterInsertion && newFirstChild && (!newFirstChildStyle || !newFirstChildStyle->firstChildState()))
- newFirstChild->setNeedsStyleRecalc(SubtreeStyleChange);
+ if (childrenAffectedByFirstChildRules() && nodeAfterChange) {
+ ASSERT(changeType != FinishedParsingChildren);
+ // Find our new first child element.
+ Element* firstChildElement = ElementTraversal::firstChild(*this);
+ RenderStyle* firstChildElementStyle = firstChildElement ? firstChildElement->renderStyle() : 0;
+
+ // Find the first element after the change.
+ Element* elementAfterChange = nodeAfterChange->isElementNode() ? toElement(nodeAfterChange) : ElementTraversal::nextSibling(*nodeAfterChange);
+ RenderStyle* elementAfterChangeStyle = elementAfterChange ? elementAfterChange->renderStyle() : 0;
+
+ // This is the element insertion as first child element case.
+ if (firstChildElement != elementAfterChange && elementAfterChangeStyle && elementAfterChangeStyle->firstChildState())
+ elementAfterChange->setNeedsStyleRecalc(SubtreeStyleChange);
+
+ // This is the first child element removal case.
+ if (changeType == SiblingRemoved && firstChildElement == elementAfterChange && firstChildElement && (!firstChildElementStyle || !firstChildElementStyle->firstChildState()))
Inactive 2014/07/10 01:05:11 Possible improvement idea: Seems like this could b
+ firstChildElement->setNeedsStyleRecalc(SubtreeStyleChange);
}
// :last-child. In the parser callback case, we don't have to check anything, since we were right the first time.
// In the DOM case, we only need to do something if |afterChange| is not 0.
- if (childrenAffectedByLastChildRules() && beforeChange) {
- // Find our new last child.
- Node* newLastChild = ElementTraversal::lastChild(*this);
- RenderStyle* newLastChildStyle = newLastChild ? newLastChild->renderStyle() : 0;
+ if (childrenAffectedByLastChildRules() && nodeBeforeChange) {
+ // Find our new last child element.
+ Element* lastChildElement = ElementTraversal::lastChild(*this);
+ RenderStyle* lastChildElementStyle = lastChildElement ? lastChildElement->renderStyle() : 0;
- // Find the last element node going backwards from |beforeChange|
- Node* lastElementBeforeInsertion = beforeChange->isElementNode() ? beforeChange : ElementTraversal::previousSibling(*beforeChange);
- RenderStyle* lastElementBeforeInsertionStyle = lastElementBeforeInsertion ? lastElementBeforeInsertion->renderStyle() : 0;
+ // Find the last element before the change.
+ Element* elementBeforeChange = nodeBeforeChange->isElementNode() ? toElement(nodeBeforeChange) : ElementTraversal::previousSibling(*nodeBeforeChange);
+ RenderStyle* elementBeforeChangeStyle = elementBeforeChange ? elementBeforeChange->renderStyle() : 0;
- if (newLastChild != lastElementBeforeInsertion && lastElementBeforeInsertionStyle && lastElementBeforeInsertionStyle->lastChildState())
- lastElementBeforeInsertion->setNeedsStyleRecalc(SubtreeStyleChange);
+ // This is the element insertion as last child element case.
+ if (lastChildElement != elementBeforeChange && elementBeforeChangeStyle && elementBeforeChangeStyle->lastChildState())
+ elementBeforeChange->setNeedsStyleRecalc(SubtreeStyleChange);
- // We also have to handle node removal. The parser callback case is similar to node removal as well in that we need to change the last child
+ // This is the last child element removal case. The parser callback case is similar to node removal as well in that we need to change the last child
// to match now.
- if ((changeType == SiblingRemoved || changeType == FinishedParsingChildren) && newLastChild == lastElementBeforeInsertion && newLastChild && (!newLastChildStyle || !newLastChildStyle->lastChildState()))
- newLastChild->setNeedsStyleRecalc(SubtreeStyleChange);
+ if ((changeType == SiblingRemoved || changeType == FinishedParsingChildren) && lastChildElement == elementBeforeChange && lastChildElement && (!lastChildElementStyle || !lastChildElementStyle->lastChildState()))
Inactive 2014/07/10 01:05:11 Possible improvement idea: Seems like this could b
+ lastChildElement->setNeedsStyleRecalc(SubtreeStyleChange);
}
- // The + selector. We need to invalidate the first element following the insertion point. It is the only possible element
+ // The + selector. We need to invalidate the first element following the change. It is the only possible element
// that could be affected by this DOM change.
- if (childrenAffectedByDirectAdjacentRules() && afterChange) {
- if (Node* firstElementAfterInsertion = afterChange->isElementNode() ? afterChange : ElementTraversal::nextSibling(*afterChange))
- firstElementAfterInsertion->setNeedsStyleRecalc(SubtreeStyleChange);
+ if (childrenAffectedByDirectAdjacentRules() && nodeAfterChange) {
+ if (Element* elementAfterChange = nodeAfterChange->isElementNode() ? toElement(nodeAfterChange) : ElementTraversal::nextSibling(*nodeAfterChange))
+ elementAfterChange->setNeedsStyleRecalc(SubtreeStyleChange);
}
}
« no previous file with comments | « Source/core/dom/ContainerNode.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698