diff options
Diffstat (limited to 'WebCore/editing/WrapContentsInDummySpanCommand.cpp')
-rw-r--r-- | WebCore/editing/WrapContentsInDummySpanCommand.cpp | 40 |
1 files changed, 26 insertions, 14 deletions
diff --git a/WebCore/editing/WrapContentsInDummySpanCommand.cpp b/WebCore/editing/WrapContentsInDummySpanCommand.cpp index 7622c1e..5fa0b39 100644 --- a/WebCore/editing/WrapContentsInDummySpanCommand.cpp +++ b/WebCore/editing/WrapContentsInDummySpanCommand.cpp @@ -38,35 +38,37 @@ WrapContentsInDummySpanCommand::WrapContentsInDummySpanCommand(PassRefPtr<Elemen ASSERT(m_element); } -void WrapContentsInDummySpanCommand::doApply() +void WrapContentsInDummySpanCommand::executeApply() { Vector<RefPtr<Node> > children; for (Node* child = m_element->firstChild(); child; child = child->nextSibling()) children.append(child); - - RefPtr<HTMLElement> span = createStyleSpanElement(document()); - + ExceptionCode ec; - + size_t size = children.size(); for (size_t i = 0; i < size; ++i) - span->appendChild(children[i].release(), ec); - - m_element->appendChild(span.get(), ec); - - m_dummySpan = span.release(); + m_dummySpan->appendChild(children[i].release(), ec); + + m_element->appendChild(m_dummySpan.get(), ec); } +void WrapContentsInDummySpanCommand::doApply() +{ + m_dummySpan = createStyleSpanElement(document()); + + executeApply(); +} + void WrapContentsInDummySpanCommand::doUnapply() { ASSERT(m_element); - RefPtr<HTMLElement> span = m_dummySpan.release(); - if (!span) + if (!m_dummySpan || !m_element->isContentEditable()) return; Vector<RefPtr<Node> > children; - for (Node* child = span->firstChild(); child; child = child->nextSibling()) + for (Node* child = m_dummySpan->firstChild(); child; child = child->nextSibling()) children.append(child); ExceptionCode ec; @@ -75,7 +77,17 @@ void WrapContentsInDummySpanCommand::doUnapply() for (size_t i = 0; i < size; ++i) m_element->appendChild(children[i].release(), ec); - span->remove(ec); + m_dummySpan->remove(ec); } +void WrapContentsInDummySpanCommand::doReapply() +{ + ASSERT(m_element); + + if (!m_dummySpan || !m_element->isContentEditable()) + return; + + executeApply(); +} + } // namespace WebCore |