This source file includes following definitions.
- m_shouldAssumeContentIsAlwaysEditable
- doApply
- doUnapply
#include "config.h"
#include "core/editing/RemoveNodeCommand.h"
#include "bindings/v8/ExceptionStatePlaceholder.h"
#include "core/dom/Node.h"
#include "wtf/Assertions.h"
namespace WebCore {
RemoveNodeCommand::RemoveNodeCommand(PassRefPtr<Node> node, ShouldAssumeContentIsAlwaysEditable shouldAssumeContentIsAlwaysEditable)
: SimpleEditCommand(node->document())
, m_node(node)
, m_shouldAssumeContentIsAlwaysEditable(shouldAssumeContentIsAlwaysEditable)
{
ASSERT(m_node);
ASSERT(m_node->parentNode());
}
void RemoveNodeCommand::doApply()
{
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);
}
void RemoveNodeCommand::doUnapply()
{
RefPtr<ContainerNode> parent = m_parent.release();
RefPtr<Node> refChild = m_refChild.release();
if (!parent || !parent->rendererIsEditable())
return;
parent->insertBefore(m_node.get(), refChild.get(), IGNORE_EXCEPTION);
}
}