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

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: Build fix 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') | Source/core/dom/Element.cpp » ('j') | 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 77fd24eda9f1ea4bb39e51cc0e0fda2cadfe1af8..5b632d5abb0b32b3a6dbb99959ca5549da215681 100644
--- a/Source/core/dom/ContainerNode.cpp
+++ b/Source/core/dom/ContainerNode.cpp
@@ -568,8 +568,7 @@ PassRefPtrWillBeRawPtr<Node> ContainerNode::removeChild(PassRefPtrWillBeRawPtr<N
Node* next = child->nextSibling();
removeBetween(prev, next, *child);
notifyNodeRemoved(*child);
- ChildrenChange change = {ChildRemoved, prev, next, ChildrenChangeSourceAPI};
- childrenChanged(change);
+ childrenChanged(ChildrenChange::forRemoval(*child, prev, next, ChildrenChangeSourceAPI));
}
dispatchSubtreeModifiedEvent();
return child;
@@ -615,9 +614,8 @@ void ContainerNode::parserRemoveChild(Node& oldChild)
removeBetween(prev, next, oldChild);
- ChildrenChange change = {ChildRemoved, prev, next, ChildrenChangeSourceParser};
notifyNodeRemoved(oldChild);
- childrenChanged(change);
+ childrenChanged(ChildrenChange::forRemoval(oldChild, prev, next, ChildrenChangeSourceParser));
}
// this differs from other remove functions because it forcibly removes all the children,
@@ -768,6 +766,7 @@ void ContainerNode::parserAppendChild(PassRefPtrWillBeRawPtr<Node> newChild)
ChildListMutationScope(*this).childAdded(*newChild);
}
+
esprehn 2014/08/01 14:12:26 why extra nl?
Inactive 2014/08/01 15:40:07 Done.
notifyNodeInserted(*newChild, ChildrenChangeSourceParser);
}
@@ -787,10 +786,8 @@ void ContainerNode::notifyNodeInserted(Node& root, ChildrenChangeSource source)
// children changed when one is added.
// FIXME: We should have a separate code path for ShadowRoot since it only
// needs to call insertedInto and the rest of this logic is not needed.
- if (!root.isShadowRoot()) {
- ChildrenChange change = {ChildInserted, root.previousSibling(), root.nextSibling(), source};
- childrenChanged(change);
- }
+ if (!root.isShadowRoot())
+ childrenChanged(ChildrenChange::forInsertion(root, source));
esprehn 2014/08/01 14:12:26 This code needs to be rebased again.
Inactive 2014/08/01 15:40:07 Done.
for (size_t i = 0; i < postInsertionNotificationTargets.size(); ++i) {
Node* targetNode = postInsertionNotificationTargets[i].get();
@@ -856,7 +853,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();
}
@@ -1287,11 +1284,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);
}
@@ -1307,12 +1306,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);
}
« no previous file with comments | « Source/core/dom/ContainerNode.h ('k') | Source/core/dom/Element.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698