void ContainerNode::parserInsertBefore(PassRefPtr<Node> newChild, Node* nextChild) { ASSERT(newChild); ASSERT(nextChild); ASSERT(nextChild->parentNode() == this); ASSERT(!newChild->isDocumentFragment()); #if ENABLE(TEMPLATE_ELEMENT) ASSERT(!hasTagName(HTMLNames::templateTag)); #endif if (nextChild->previousSibling() == newChild || nextChild == newChild) // nothing to do return; if (&document() != &newChild->document()) document().adoptNode(newChild.get(), ASSERT_NO_EXCEPTION); insertBeforeCommon(nextChild, newChild.get()); newChild->updateAncestorConnectedSubframeCountForInsertion(); ChildListMutationScope(this).childAdded(newChild.get()); childrenChanged(true, newChild->previousSibling(), nextChild, 1); ChildNodeInsertionNotifier(this).notify(newChild.get()); }
void ContainerNode::parserAppendChild(PassRefPtr<Node> newChild) { ASSERT(newChild); ASSERT(!newChild->parentNode()); // Use appendChild if you need to handle reparenting (and want DOM mutation events). ASSERT(!newChild->isDocumentFragment()); ASSERT(!hasTagName(HTMLNames::templateTag)); if (document() != newChild->document()) document()->adoptNode(newChild.get(), ASSERT_NO_EXCEPTION); Node* last = m_lastChild; { NoEventDispatchAssertion assertNoEventDispatch; // FIXME: This method should take a PassRefPtr. appendChildToContainer(newChild.get(), this); treeScope()->adoptIfNeeded(newChild.get()); } newChild->updateAncestorConnectedSubframeCountForInsertion(); ChildListMutationScope(this).childAdded(newChild.get()); childrenChanged(true, last, 0, 1); ChildNodeInsertionNotifier(this).notify(newChild.get()); }
static void updateTreeAfterInsertion(ContainerNode* parent, Node* child, bool shouldLazyAttach) { ASSERT(parent->refCount()); ASSERT(child->refCount()); #if ENABLE(MUTATION_OBSERVERS) ChildListMutationScope(parent).childAdded(child); #endif #if ENABLE(UNDO_MANAGER) if (UndoManager::isRecordingAutomaticTransaction(parent)) UndoManager::addTransactionStep(NodeInsertingDOMTransactionStep::create(parent, child)); #endif parent->childrenChanged(false, child->previousSibling(), child->nextSibling(), 1); ChildNodeInsertionNotifier(parent).notify(child); // FIXME: Attachment should be the first operation in this function, but some code // (for example, HTMLFormControlElement's autofocus support) requires this ordering. if (parent->attached() && !child->attached() && child->parentNode() == parent) { if (shouldLazyAttach) child->lazyAttach(); else child->attach(); } dispatchChildInsertionEvents(child); }
static void updateTreeAfterInsertion(ContainerNode* parent, Node* child, AttachBehavior attachBehavior) { ASSERT(parent->refCount()); ASSERT(child->refCount()); ChildListMutationScope(parent).childAdded(child); parent->childrenChanged(false, child->previousSibling(), child->nextSibling(), 1); ChildNodeInsertionNotifier(parent).notify(child); // FIXME: Attachment should be the first operation in this function, but some code // (for example, HTMLFormControlElement's autofocus support) requires this ordering. if (parent->attached() && !child->attached() && child->parentNode() == parent) { if (attachBehavior == AttachLazily) { if (child->isElementNode()) toElement(child)->lazyAttach(); else if (child->isTextNode()) { child->setAttached(true); child->setNeedsStyleRecalc(); } } else attachChild(child); } dispatchChildInsertionEvents(child); }
void ContainerNode::parserAppendChild(PassRefPtr<Node> newChild) { ASSERT(newChild); ASSERT(!newChild->parentNode()); // Use appendChild if you need to handle reparenting (and want DOM mutation events). ASSERT(!newChild->isDocumentFragment()); #if ENABLE(TEMPLATE_ELEMENT) ASSERT(!hasTagName(HTMLNames::templateTag)); #endif if (&document() != &newChild->document()) document().adoptNode(newChild.get(), ASSERT_NO_EXCEPTION); { NoEventDispatchAssertion assertNoEventDispatch; // FIXME: This method should take a PassRefPtr. appendChildToContainer(newChild.get(), *this); treeScope().adoptIfNeeded(newChild.get()); } newChild->updateAncestorConnectedSubframeCountForInsertion(); ChildListMutationScope(*this).childAdded(*newChild); notifyChildInserted(*newChild, ChildChangeSourceParser); ChildNodeInsertionNotifier(*this).notify(*newChild); newChild->setNeedsStyleRecalc(ReconstructRenderTree); }
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(); }
void ContainerNode::updateTreeAfterInsertion(Node& child) { ASSERT(child.refCount()); ChildListMutationScope(*this).childAdded(child); notifyChildInserted(child, ChildChangeSourceAPI); ChildNodeInsertionNotifier(*this).notify(child); child.setNeedsStyleRecalc(ReconstructRenderTree); dispatchChildInsertionEvents(child); }
void ContainerNode::willRemoveChild(Node& child) { ASSERT(child.parentNode()); ChildListMutationScope(*child.parentNode()).willRemoveChild(child); child.notifyMutationObserversNodeWillDetach(); dispatchChildRemovalEvents(child); if (child.parentNode() != this) return; child.document().nodeWillBeRemoved(&child); // e.g. mutation event listener can create a new range. if (child.isContainerNode()) disconnectSubframesIfNeeded(toContainerNode(child), RootAndDescendants); }
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(); }
void ContainerNode::parserRemoveChild(Node* oldChild) { ASSERT(oldChild); ASSERT(oldChild->parentNode() == this); ASSERT(!oldChild->isDocumentFragment()); Node* prev = oldChild->previousSibling(); Node* next = oldChild->nextSibling(); oldChild->updateAncestorConnectedSubframeCountForRemoval(); ChildListMutationScope(this).willRemoveChild(oldChild); oldChild->notifyMutationObserversNodeWillDetach(); removeBetween(prev, next, oldChild); childrenChanged(true, prev, next, -1); ChildNodeRemovalNotifier(this).notify(oldChild); }
void ContainerNode::parserRemoveChild(Node& oldChild) { ASSERT(oldChild.parentNode() == this); ASSERT(!oldChild.isDocumentFragment()); Node* prev = oldChild.previousSibling(); Node* next = oldChild.nextSibling(); oldChild.updateAncestorConnectedSubframeCountForRemoval(); ChildListMutationScope(*this).willRemoveChild(oldChild); oldChild.notifyMutationObserversNodeWillDetach(); removeBetween(prev, next, oldChild); notifyChildRemoved(oldChild, prev, next, ChildChangeSourceParser); ChildNodeRemovalNotifier(*this).notify(oldChild); }