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

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

Issue 1297593004: Don't call Document::nodeWillRemoved() with a node in different document (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 2015-08-18T17:03:20 Changes for review comments Created 5 years, 4 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 | « LayoutTests/fast/dom/Range/range-dom-node-removed-assert.html ('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 070befc354fafaac6d3c7ca80832b99221d00764..90fb8b95765b2b14cd01fa75d3bc6bcc2658450c 100644
--- a/Source/core/dom/ContainerNode.cpp
+++ b/Source/core/dom/ContainerNode.cpp
@@ -438,12 +438,18 @@ void ContainerNode::willRemoveChild(Node& child)
child.notifyMutationObserversNodeWillDetach();
dispatchChildRemovalEvents(child);
ChildFrameDisconnector(child).disconnect();
+ if (document() != child.document()) {
+ // |child| was moved another document by DOM mutation event handler.
+ return;
+ }
- // nodeWillBeRemoved must be run after ChildFrameDisconnector, because ChildFrameDisconnector can run script
- // which may cause state that is to be invalidated by removing the node.
+ // |nodeWillBeRemoved()| must be run after |ChildFrameDisconnector|, because
+ // |ChildFrameDisconnector| can run script which may cause state that is to
+ // be invalidated by removing the node.
ScriptForbiddenScope scriptForbiddenScope;
EventDispatchForbiddenScope assertNoEventDispatch;
- document().nodeWillBeRemoved(child); // e.g. mutation event listener can create a new range.
+ // e.g. mutation event listener can create a new range.
+ document().nodeWillBeRemoved(child);
}
void ContainerNode::willRemoveChildren()
« no previous file with comments | « LayoutTests/fast/dom/Range/range-dom-node-removed-assert.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698