Chromium Code Reviews| Index: Source/core/dom/ContainerNode.cpp |
| diff --git a/Source/core/dom/ContainerNode.cpp b/Source/core/dom/ContainerNode.cpp |
| index 070befc354fafaac6d3c7ca80832b99221d00764..5404abfb917ceb6c089e5e2746ac69cee9aa125e 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| is moved another document by DOM mutation event handler. |
|
tkent
2015/08/18 07:49:58
nit: |is moved| -> |was moved to|
yosin_UTC9
2015/08/18 08:11:08
Done.
|
| + 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() |
| @@ -1241,6 +1247,10 @@ static void dispatchChildRemovalEvents(Node& child) |
| InspectorInstrumentation::willRemoveDOMNode(&child); |
| + // TODO(yosin) We should dispatch "DOMNodeRemoved" and |
|
tkent
2015/08/18 07:49:58
DOM mutation event is an obsoleted feature, and we
|
| + // "DOMNodeRemovedFromDocument" after |Document.nodeWillRemoved()| to |
| + // make JS event handler to see relocated |Range| objects, and |
| + // |FrameSelection|. |
| RefPtrWillBeRawPtr<Node> c(child); |
| RefPtrWillBeRawPtr<Document> document(child.document()); |