Changeset 212218 in webkit for trunk/Source/WebCore/dom/ContainerNode.cpp
- Timestamp:
- Feb 12, 2017 8:21:03 PM (10 months ago)
- File:
-
- 1 edited
-
trunk/Source/WebCore/dom/ContainerNode.cpp (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/dom/ContainerNode.cpp
r211965 r212218 131 131 } 132 132 133 // FIXME: We need to do notifyMutationObserversNodeWillDetach() for each child, 134 // probably inside removeDetachedChildrenInContainer. 135 136 oldParent->removeDetachedChildren(); 137 133 disconnectSubframesIfNeeded(*oldParent, DescendantsOnly); 134 { 135 NoEventDispatchAssertion assertNoEventDispatch; 136 137 oldParent->document().nodeChildrenWillBeRemoved(*oldParent); 138 139 WidgetHierarchyUpdatesSuspensionScope suspendWidgetHierarchyUpdates; 140 while (RefPtr<Node> child = oldParent->m_firstChild) { 141 oldParent->removeBetween(nullptr, child->nextSibling(), *child); 142 notifyChildNodeRemoved(*oldParent, *child); 143 } 144 ChildChange change = { AllChildrenRemoved, nullptr, nullptr, ChildChangeSourceParser }; 145 childrenChanged(change); 146 } 147 148 // FIXME: assert that we don't dispatch events here since this container node is still disconnected. 138 149 for (auto& child : children) { 139 destroyRenderTreeIfNeeded(child); 140 141 // FIXME: We need a no mutation event version of adoptNode. 142 auto adoptedChild = document().adoptNode(child).releaseReturnValue(); 143 parserAppendChild(adoptedChild); 144 // FIXME: Together with adoptNode above, the tree scope might get updated recursively twice 145 // (if the document changed or oldParent was in a shadow tree, AND *this is in a shadow tree). 146 // Can we do better? 147 treeScope().adoptIfNeeded(adoptedChild); 150 RELEASE_ASSERT(!child->parentNode() && &child->treeScope() == &treeScope()); 151 ASSERT(!ensurePreInsertionValidity(child, nullptr).hasException()); 152 treeScope().adoptIfNeeded(child); 153 parserAppendChild(child); 148 154 } 149 155 } … … 487 493 if (is<ContainerNode>(child)) 488 494 disconnectSubframesIfNeeded(downcast<ContainerNode>(child), RootAndDescendants); 489 490 if (child.parentNode() != &container)491 return;492 493 child.document().nodeWillBeRemoved(child); // e.g. mutation event listener can create a new range.494 495 } 495 496 … … 509 510 510 511 disconnectSubframesIfNeeded(container, DescendantsOnly); 511 512 container.document().nodeChildrenWillBeRemoved(container);513 514 512 } 515 513 … … 535 533 willRemoveChild(*this, child); 536 534 537 // Mutation events might have moved this child into a different parent.535 // Mutation events in willRemoveChild might have moved this child into a different parent. 538 536 if (child->parentNode() != this) 539 537 return Exception { NOT_FOUND_ERR }; … … 542 540 WidgetHierarchyUpdatesSuspensionScope suspendWidgetHierarchyUpdates; 543 541 NoEventDispatchAssertion assertNoEventDispatch; 542 543 document().nodeWillBeRemoved(child); 544 544 545 545 Node* prev = child->previousSibling(); … … 592 592 void ContainerNode::parserRemoveChild(Node& oldChild) 593 593 { 594 disconnectSubframesIfNeeded(*this, DescendantsOnly); 595 594 596 NoEventDispatchAssertion assertNoEventDispatch; 597 598 document().nodeChildrenWillBeRemoved(*this); 595 599 596 600 ASSERT(oldChild.parentNode() == this); … … 599 603 Node* prev = oldChild.previousSibling(); 600 604 Node* next = oldChild.nextSibling(); 601 602 oldChild.updateAncestorConnectedSubframeCountForRemoval();603 605 604 606 ChildListMutationScope(*this).willRemoveChild(oldChild); … … 644 646 { 645 647 NoEventDispatchAssertion assertNoEventDispatch; 648 649 document().nodeChildrenWillBeRemoved(*this); 650 646 651 while (RefPtr<Node> child = m_firstChild) { 647 652 removeBetween(nullptr, child->nextSibling(), *child); … … 686 691 WidgetHierarchyUpdatesSuspensionScope suspendWidgetHierarchyUpdates; 687 692 NoEventDispatchAssertion assertNoEventDispatch; 693 694 document().nodeChildrenWillBeRemoved(*this); 688 695 689 696 while (RefPtr<Node> child = m_firstChild) {
Note: See TracChangeset
for help on using the changeset viewer.