This source file includes following definitions.
- m_element
- executeApply
- doApply
- doUnapply
- doReapply
#include "config.h"
#include "core/editing/WrapContentsInDummySpanCommand.h"
#include "bindings/v8/ExceptionStatePlaceholder.h"
#include "core/editing/ApplyStyleCommand.h"
#include "core/html/HTMLElement.h"
namespace WebCore {
WrapContentsInDummySpanCommand::WrapContentsInDummySpanCommand(PassRefPtr<Element> element)
: SimpleEditCommand(element->document())
, m_element(element)
{
ASSERT(m_element);
}
void WrapContentsInDummySpanCommand::executeApply()
{
Vector<RefPtr<Node> > children;
for (Node* child = m_element->firstChild(); child; child = child->nextSibling())
children.append(child);
size_t size = children.size();
for (size_t i = 0; i < size; ++i)
m_dummySpan->appendChild(children[i].release(), IGNORE_EXCEPTION);
m_element->appendChild(m_dummySpan.get(), IGNORE_EXCEPTION);
}
void WrapContentsInDummySpanCommand::doApply()
{
m_dummySpan = createStyleSpanElement(document());
executeApply();
}
void WrapContentsInDummySpanCommand::doUnapply()
{
ASSERT(m_element);
if (!m_dummySpan || !m_element->rendererIsEditable())
return;
Vector<RefPtr<Node> > children;
for (Node* child = m_dummySpan->firstChild(); child; child = child->nextSibling())
children.append(child);
size_t size = children.size();
for (size_t i = 0; i < size; ++i)
m_element->appendChild(children[i].release(), IGNORE_EXCEPTION);
m_dummySpan->remove(IGNORE_EXCEPTION);
}
void WrapContentsInDummySpanCommand::doReapply()
{
ASSERT(m_element);
if (!m_dummySpan || !m_element->rendererIsEditable())
return;
executeApply();
}
}