summaryrefslogtreecommitdiff
path: root/Source/WebCore/editing/SplitElementCommand.cpp
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
commit1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch)
tree46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/WebCore/editing/SplitElementCommand.cpp
parent32761a6cee1d0dee366b885b7b9c777e67885688 (diff)
downloadWebKitGtk-tarball-master.tar.gz
Diffstat (limited to 'Source/WebCore/editing/SplitElementCommand.cpp')
-rw-r--r--Source/WebCore/editing/SplitElementCommand.cpp40
1 files changed, 18 insertions, 22 deletions
diff --git a/Source/WebCore/editing/SplitElementCommand.cpp b/Source/WebCore/editing/SplitElementCommand.cpp
index 6ad8f1921..2d4e85498 100644
--- a/Source/WebCore/editing/SplitElementCommand.cpp
+++ b/Source/WebCore/editing/SplitElementCommand.cpp
@@ -10,10 +10,10 @@
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
@@ -47,30 +47,26 @@ void SplitElementCommand::executeApply()
if (m_atChild->parentNode() != m_element2)
return;
- Vector<RefPtr<Node>> children;
+ Vector<Ref<Node>> children;
for (Node* node = m_element2->firstChild(); node != m_atChild; node = node->nextSibling())
- children.append(node);
-
- ExceptionCode ec = 0;
-
- ContainerNode* parent = m_element2->parentNode();
+ children.append(*node);
+
+ auto* parent = m_element2->parentNode();
if (!parent || !parent->hasEditableStyle())
return;
- parent->insertBefore(m_element1.get(), m_element2.get(), ec);
- if (ec)
+ if (parent->insertBefore(*m_element1, m_element2.get()).hasException())
return;
// Delete id attribute from the second element because the same id cannot be used for more than one element
m_element2->removeAttribute(HTMLNames::idAttr);
- size_t size = children.size();
- for (size_t i = 0; i < size; ++i)
- m_element1->appendChild(children[i], ec);
+ for (auto& child : children)
+ m_element1->appendChild(child);
}
void SplitElementCommand::doApply()
{
- m_element1 = m_element2->cloneElementWithoutChildren();
+ m_element1 = m_element2->cloneElementWithoutChildren(document());
executeApply();
}
@@ -80,21 +76,21 @@ void SplitElementCommand::doUnapply()
if (!m_element1 || !m_element1->hasEditableStyle() || !m_element2->hasEditableStyle())
return;
- Vector<RefPtr<Node>> children;
+ Vector<Ref<Node>> children;
for (Node* node = m_element1->firstChild(); node; node = node->nextSibling())
- children.append(node);
+ children.append(*node);
RefPtr<Node> refChild = m_element2->firstChild();
- size_t size = children.size();
- for (size_t i = 0; i < size; ++i)
- m_element2->insertBefore(children[i].get(), refChild.get(), IGNORE_EXCEPTION);
+ for (auto& child : children)
+ m_element2->insertBefore(child, refChild.get());
// Recover the id attribute of the original element.
- if (m_element1->hasAttribute(HTMLNames::idAttr))
- m_element2->setAttribute(HTMLNames::idAttr, m_element1->getAttribute(HTMLNames::idAttr));
+ const AtomicString& id = m_element1->getIdAttribute();
+ if (!id.isNull())
+ m_element2->setIdAttribute(id);
- m_element1->remove(IGNORE_EXCEPTION);
+ m_element1->remove();
}
void SplitElementCommand::doReapply()