static void willRemoveChildren(ContainerNode* container) { NodeVector children; getChildNodes(container, children); container->document()->nodeChildrenWillBeRemoved(container); #if ENABLE(MUTATION_OBSERVERS) ChildListMutationScope mutation(container); #endif for (NodeVector::const_iterator it = children.begin(); it != children.end(); it++) { Node* child = it->get(); #if ENABLE(MUTATION_OBSERVERS) mutation.willRemoveChild(child); child->notifyMutationObserversNodeWillDetach(); #endif #if ENABLE(UNDO_MANAGER) if (UndoManager::isRecordingAutomaticTransaction(container)) UndoManager::addTransactionStep(NodeRemovingDOMTransactionStep::create(container, child)); #endif // fire removed from document mutation events. dispatchChildRemovalEvents(child); } ChildFrameDisconnector(container, ChildFrameDisconnector::DoNotIncludeRoot).disconnect(); }
static void willRemoveChild(Node* child) { ASSERT(child->parentNode()); ChildListMutationScope(child->parentNode()).willRemoveChild(child); child->notifyMutationObserversNodeWillDetach(); dispatchChildRemovalEvents(child); child->document()->nodeWillBeRemoved(child); // e.g. mutation event listener can create a new range. ChildFrameDisconnector(child).disconnect(); }
// this differs from other remove functions because it forcibly removes all the children, // regardless of read-only status or event exceptions, e.g. void ContainerNode::removeChildren() { if (!m_firstChild) return; // The container node can be removed from event handlers. RefPtr<ContainerNode> protect(this); // Exclude this node when looking for the focused or full screen Node since // only children will be removed. // FIXME: We should call these inside the loop below. Right now you can focus // a node with mutation events and it'll never get blured. document()->removeFocusedNodeOfSubtree(this, true); document()->removeFullScreenElementOfSubtree(this, true); ChildListMutationScope mutation(this); NodeVector removedChildren; { WidgetHierarchyUpdatesSuspensionScope suspendWidgetHierarchyUpdates; while (RefPtr<Node> child = m_firstChild) { // Dispatch synchronous events like mutation and unload events. dispatchChildRemovalEvents(child.get()); ChildFrameDisconnector(child.get()).disconnect(); // FIXME: In theory this can fire focus events when the selection // changes, but there's no obvious way to test it. document()->nodeWillBeRemoved(child.get()); // If an event moved the child start over. if (child != m_firstChild) continue; mutation.willRemoveChild(child.get()); child->notifyMutationObserversNodeWillDetach(); removeBetween(0, child->nextSibling(), child.get()); removedChildren.append(child.release()); } // FIXME: We could avoid walking all the children twice by calling // notify inside the loop and childrenChanged after but that would mean // calling childrenChanged in a different order than all other methods. // Figure out if this is safe. childrenChanged(false, 0, 0, -static_cast<int>(removedChildren.size())); for (size_t i = 0; i < removedChildren.size(); ++i) ChildNodeRemovalNotifier(this).notify(removedChildren[i].get()); } dispatchSubtreeModifiedEvent(); }
static void willRemoveChild(Node* child) { #if ENABLE(MUTATION_OBSERVERS) ASSERT(child->parentNode()); ChildListMutationScope(child->parentNode()).willRemoveChild(child); child->notifyMutationObserversNodeWillDetach(); #endif #if ENABLE(UNDO_MANAGER) if (UndoManager::isRecordingAutomaticTransaction(child->parentNode())) UndoManager::addTransactionStep(NodeRemovingDOMTransactionStep::create(child->parentNode(), child)); #endif dispatchChildRemovalEvents(child); child->document()->nodeWillBeRemoved(child); // e.g. mutation event listener can create a new range. ChildFrameDisconnector(child).disconnect(); }
static void willRemoveChildren(ContainerNode* container) { NodeVector children; getChildNodes(container, children); container->document()->nodeChildrenWillBeRemoved(container); ChildListMutationScope mutation(container); for (NodeVector::const_iterator it = children.begin(); it != children.end(); it++) { Node* child = it->get(); mutation.willRemoveChild(child); child->notifyMutationObserversNodeWillDetach(); // fire removed from document mutation events. dispatchChildRemovalEvents(child); } ChildFrameDisconnector(container).disconnect(ChildFrameDisconnector::DescendantsOnly); }
void ContainerNode::disconnectDescendantFrames() { ChildFrameDisconnector(this).disconnect(); }