This source file includes following definitions.
- m_shouldAssumeContentIsAlwaysEditable
- doApply
- doUnapply
#include "config.h"
#include "core/editing/InsertNodeBeforeCommand.h"
#include "bindings/v8/ExceptionStatePlaceholder.h"
#include "core/dom/Document.h"
namespace WebCore {
InsertNodeBeforeCommand::InsertNodeBeforeCommand(PassRefPtr<Node> insertChild, PassRefPtr<Node> refChild,
ShouldAssumeContentIsAlwaysEditable shouldAssumeContentIsAlwaysEditable)
: SimpleEditCommand(refChild->document())
, m_insertChild(insertChild)
, m_refChild(refChild)
, m_shouldAssumeContentIsAlwaysEditable(shouldAssumeContentIsAlwaysEditable)
{
ASSERT(m_insertChild);
ASSERT(!m_insertChild->parentNode());
ASSERT(m_refChild);
ASSERT(m_refChild->parentNode());
ASSERT(m_refChild->parentNode()->rendererIsEditable() || !m_refChild->parentNode()->inActiveDocument());
}
void InsertNodeBeforeCommand::doApply()
{
ContainerNode* parent = m_refChild->parentNode();
if (!parent || (m_shouldAssumeContentIsAlwaysEditable == DoNotAssumeContentIsAlwaysEditable && !parent->isContentEditable(Node::UserSelectAllIsAlwaysNonEditable)))
return;
ASSERT(parent->isContentEditable(Node::UserSelectAllIsAlwaysNonEditable));
parent->insertBefore(m_insertChild.get(), m_refChild.get(), IGNORE_EXCEPTION);
}
void InsertNodeBeforeCommand::doUnapply()
{
if (!m_insertChild->isContentEditable(Node::UserSelectAllIsAlwaysNonEditable))
return;
m_insertChild->remove(IGNORE_EXCEPTION);
}
}