void RemoveNodeCommand::doApply(EditingState* editingState) { ContainerNode* parent = m_node->parentNode(); if (!parent || (m_shouldAssumeContentIsAlwaysEditable == DoNotAssumeContentIsAlwaysEditable && !parent->isContentEditable(Node::UserSelectAllIsAlwaysNonEditable) && parent->inActiveDocument())) return; ASSERT(parent->isContentEditable(Node::UserSelectAllIsAlwaysNonEditable) || !parent->inActiveDocument()); m_parent = parent; m_refChild = m_node->nextSibling(); m_node->remove(IGNORE_EXCEPTION); // Node::remove dispatch synchronous events such as IFRAME unload events, // and event handlers may break the document. We check the document state // here in order to prevent further processing in bad situation. ABORT_EDITING_COMMAND_IF(!m_node->document().frame()); ABORT_EDITING_COMMAND_IF(!m_node->document().documentElement()); }
void RemoveNodePreservingChildrenCommand::doApply(EditingState* editingState) { ABORT_EDITING_COMMAND_IF(!m_node->parentNode()); ABORT_EDITING_COMMAND_IF(!hasEditableStyle(*m_node->parentNode())); if (m_node->isContainerNode()) { NodeVector children; getChildNodes(toContainerNode(*m_node), children); for (auto& currentChild : children) { Node* child = currentChild.release(); removeNode(child, editingState, m_shouldAssumeContentIsAlwaysEditable); if (editingState->isAborted()) return; insertNodeBefore(child, m_node, editingState, m_shouldAssumeContentIsAlwaysEditable); if (editingState->isAborted()) return; } } removeNode(m_node, editingState, m_shouldAssumeContentIsAlwaysEditable); }