diff options
Diffstat (limited to 'WebCore/editing/SplitElementCommand.cpp')
-rw-r--r-- | WebCore/editing/SplitElementCommand.cpp | 35 |
1 files changed, 23 insertions, 12 deletions
diff --git a/WebCore/editing/SplitElementCommand.cpp b/WebCore/editing/SplitElementCommand.cpp index 35dfc6f..2998c6a 100644 --- a/WebCore/editing/SplitElementCommand.cpp +++ b/WebCore/editing/SplitElementCommand.cpp @@ -41,35 +41,39 @@ SplitElementCommand::SplitElementCommand(PassRefPtr<Element> element, PassRefPtr ASSERT(m_atChild->parentNode() == m_element2); } -void SplitElementCommand::doApply() +void SplitElementCommand::executeApply() { - RefPtr<Element> prefixElement = m_element2->cloneElementWithoutChildren(); - if (m_atChild->parentNode() != m_element2) return; - + Vector<RefPtr<Node> > children; for (Node* node = m_element2->firstChild(); node != m_atChild; node = node->nextSibling()) children.append(node); - + ExceptionCode ec = 0; - + Node* parent = m_element2->parentNode(); - if (!parent) + if (!parent || !parent->isContentEditable()) return; - parent->insertBefore(prefixElement.get(), m_element2.get(), ec); + parent->insertBefore(m_element1.get(), m_element2.get(), ec); if (ec) return; - m_element1 = prefixElement.release(); - + size_t size = children.size(); for (size_t i = 0; i < size; ++i) m_element1->appendChild(children[i], ec); } + +void SplitElementCommand::doApply() +{ + m_element1 = m_element2->cloneElementWithoutChildren(); + + executeApply(); +} void SplitElementCommand::doUnapply() { - if (!m_element1) + if (!m_element1 || !m_element1->isContentEditable() || !m_element2->isContentEditable()) return; Vector<RefPtr<Node> > children; @@ -85,7 +89,14 @@ void SplitElementCommand::doUnapply() m_element2->insertBefore(children[i].get(), refChild.get(), ec); m_element1->remove(ec); - m_element1 = 0; } +void SplitElementCommand::doReapply() +{ + if (!m_element1) + return; + + executeApply(); +} + } // namespace WebCore |