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

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

Issue 395633007: Call ContainerNode::checkForSiblingStyleChanges() for Element insertion / removal only (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix typo 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
Index: Source/core/dom/ContainerNode.cpp
diff --git a/Source/core/dom/ContainerNode.cpp b/Source/core/dom/ContainerNode.cpp
index 6d8dc594f20539c21e4f8d93fbd9c4eee9d1dbf5..64147ab5075edb9f79868beb61351cfbaaf6e225 100644
--- a/Source/core/dom/ContainerNode.cpp
+++ b/Source/core/dom/ContainerNode.cpp
@@ -312,8 +312,7 @@ void ContainerNode::parserInsertBefore(PassRefPtrWillBeRawPtr<Node> newChild, No
ChildListMutationScope(*this).childAdded(*newChild);
- ChildrenChange change = {ChildInserted, newChild->previousSibling(), &nextChild, ChildrenChangeSourceParser};
- childrenChanged(change);
+ childrenChanged(ChildrenChange::forInsertion(*newChild, ChildrenChangeSourceParser));
notifyNodeInserted(*newChild);
}
@@ -568,8 +567,7 @@ PassRefPtrWillBeRawPtr<Node> ContainerNode::removeChild(PassRefPtrWillBeRawPtr<N
Node* prev = child->previousSibling();
Node* next = child->nextSibling();
removeBetween(prev, next, *child);
- ChildrenChange change = {ChildRemoved, prev, next, ChildrenChangeSourceAPI};
- childrenChanged(change);
+ childrenChanged(ChildrenChange::forRemoval(*child, prev, next, ChildrenChangeSourceAPI));
notifyNodeRemoved(*child);
}
dispatchSubtreeModifiedEvent();
@@ -616,8 +614,7 @@ void ContainerNode::parserRemoveChild(Node& oldChild)
removeBetween(prev, next, oldChild);
- ChildrenChange change = {ChildRemoved, prev, next, ChildrenChangeSourceParser};
- childrenChanged(change);
+ childrenChanged(ChildrenChange::forRemoval(oldChild, prev, next, ChildrenChangeSourceParser));
notifyNodeRemoved(oldChild);
}
@@ -751,8 +748,6 @@ void ContainerNode::parserAppendChild(PassRefPtrWillBeRawPtr<Node> newChild)
if (document() != newChild->document())
document().adoptNode(newChild.get(), ASSERT_NO_EXCEPTION);
- Node* last = m_lastChild;
-
{
NoEventDispatchAssertion assertNoEventDispatch;
ScriptForbiddenScope forbidScript;
@@ -763,8 +758,7 @@ void ContainerNode::parserAppendChild(PassRefPtrWillBeRawPtr<Node> newChild)
ChildListMutationScope(*this).childAdded(*newChild);
}
- ChildrenChange change = {ChildInserted, last, nullptr, ChildrenChangeSourceParser};
- childrenChanged(change);
+ childrenChanged(ChildrenChange::forInsertion(*newChild, ChildrenChangeSourceParser));
notifyNodeInserted(*newChild);
}
@@ -844,7 +838,7 @@ void ContainerNode::childrenChanged(const ChildrenChange& change)
if (!change.byParser && change.type != TextChanged)
document().updateRangesAfterChildrenChanged(this);
invalidateNodeListCachesInAncestors();
- if (change.type == ChildInserted && !childNeedsStyleRecalc()) {
+ if (change.isChildInsertion() && !childNeedsStyleRecalc()) {
setChildNeedsStyleRecalc();
markAncestorsWithChildNeedsStyleRecalc();
}
@@ -1191,8 +1185,7 @@ void ContainerNode::updateTreeAfterInsertion(Node& child)
ChildListMutationScope(*this).childAdded(child);
- ChildrenChange change = {ChildInserted, child.previousSibling(), child.nextSibling(), ChildrenChangeSourceAPI};
- childrenChanged(change);
+ childrenChanged(ChildrenChange::forInsertion(child, ChildrenChangeSourceAPI));
notifyNodeInserted(child);
@@ -1278,11 +1271,13 @@ void ContainerNode::checkForSiblingStyleChanges(SiblingCheckType changeType, Nod
RenderStyle* elementAfterChangeStyle = elementAfterChange ? elementAfterChange->renderStyle() : 0;
// This is the element insertion as first child element case.
- if (firstChildElement != elementAfterChange && elementAfterChangeStyle && elementAfterChangeStyle->firstChildState())
+ if (firstChildElement != elementAfterChange && elementAfterChangeStyle && elementAfterChangeStyle->firstChildState()) {
+ ASSERT(changeType == SiblingElementInserted);
elementAfterChange->setNeedsStyleRecalc(SubtreeStyleChange);
+ }
// This is the first child element removal case.
- if (changeType == SiblingRemoved && firstChildElement == elementAfterChange && firstChildElement && (!firstChildElementStyle || !firstChildElementStyle->firstChildState()))
+ if (changeType == SiblingElementRemoved && firstChildElement == elementAfterChange && firstChildElement && (!firstChildElementStyle || !firstChildElementStyle->firstChildState()))
firstChildElement->setNeedsStyleRecalc(SubtreeStyleChange);
}
@@ -1298,12 +1293,14 @@ void ContainerNode::checkForSiblingStyleChanges(SiblingCheckType changeType, Nod
RenderStyle* elementBeforeChangeStyle = elementBeforeChange ? elementBeforeChange->renderStyle() : 0;
// This is the element insertion as last child element case.
- if (lastChildElement != elementBeforeChange && elementBeforeChangeStyle && elementBeforeChangeStyle->lastChildState())
+ if (lastChildElement != elementBeforeChange && elementBeforeChangeStyle && elementBeforeChangeStyle->lastChildState()) {
+ ASSERT(SiblingElementInserted);
elementBeforeChange->setNeedsStyleRecalc(SubtreeStyleChange);
+ }
// 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) && lastChildElement == elementBeforeChange && lastChildElement && (!lastChildElementStyle || !lastChildElementStyle->lastChildState()))
+ if ((changeType == SiblingElementRemoved || changeType == FinishedParsingChildren) && lastChildElement == elementBeforeChange && lastChildElement && (!lastChildElementStyle || !lastChildElementStyle->lastChildState()))
lastChildElement->setNeedsStyleRecalc(SubtreeStyleChange);
}

Powered by Google App Engine
This is Rietveld 408576698