Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(865)

Unified Diff: Source/core/editing/ReplaceNodeWithSpanCommand.cpp

Issue 430843002: Use tighter typing in editing: PlainTextRange / ReplaceNodeWithSpanCommand (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/editing/ReplaceNodeWithSpanCommand.h ('k') | Source/core/editing/ReplaceSelectionCommand.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/editing/ReplaceNodeWithSpanCommand.cpp
diff --git a/Source/core/editing/ReplaceNodeWithSpanCommand.cpp b/Source/core/editing/ReplaceNodeWithSpanCommand.cpp
index 7a6162e67dbe1f574edc50817e49265d7e1ae703..0e3088b0983b379c7455126549bb5bcd02e655ac 100644
--- a/Source/core/editing/ReplaceNodeWithSpanCommand.cpp
+++ b/Source/core/editing/ReplaceNodeWithSpanCommand.cpp
@@ -35,6 +35,7 @@
#include "core/HTMLNames.h"
#include "core/editing/htmlediting.h"
#include "core/html/HTMLElement.h"
+#include "core/html/HTMLSpanElement.h"
#include "wtf/Assertions.h"
namespace blink {
@@ -48,21 +49,21 @@ ReplaceNodeWithSpanCommand::ReplaceNodeWithSpanCommand(PassRefPtrWillBeRawPtr<HT
ASSERT(m_elementToReplace);
}
-static void swapInNodePreservingAttributesAndChildren(HTMLElement* newNode, HTMLElement& nodeToReplace)
+static void swapInNodePreservingAttributesAndChildren(HTMLElement* newElement, HTMLElement& elementToReplace)
{
- ASSERT(nodeToReplace.inDocument());
- RefPtrWillBeRawPtr<ContainerNode> parentNode = nodeToReplace.parentNode();
- parentNode->insertBefore(newNode, &nodeToReplace);
+ ASSERT(elementToReplace.inDocument());
+ RefPtrWillBeRawPtr<ContainerNode> parentNode = elementToReplace.parentNode();
+ parentNode->insertBefore(newElement, &elementToReplace);
NodeVector children;
- getChildNodes(nodeToReplace, children);
+ getChildNodes(elementToReplace, children);
for (size_t i = 0; i < children.size(); ++i)
- newNode->appendChild(children[i]);
+ newElement->appendChild(children[i]);
// FIXME: Fix this to send the proper MutationRecords when MutationObservers are present.
- newNode->cloneDataFromElement(nodeToReplace);
+ newElement->cloneDataFromElement(elementToReplace);
- parentNode->removeChild(&nodeToReplace, ASSERT_NO_EXCEPTION);
+ parentNode->removeChild(&elementToReplace, ASSERT_NO_EXCEPTION);
}
void ReplaceNodeWithSpanCommand::doApply()
@@ -70,7 +71,7 @@ void ReplaceNodeWithSpanCommand::doApply()
if (!m_elementToReplace->inDocument())
return;
if (!m_spanElement)
- m_spanElement = createHTMLElement(m_elementToReplace->document(), spanTag);
+ m_spanElement = toHTMLSpanElement(createHTMLElement(m_elementToReplace->document(), spanTag).get());
swapInNodePreservingAttributesAndChildren(m_spanElement.get(), *m_elementToReplace);
}
« no previous file with comments | « Source/core/editing/ReplaceNodeWithSpanCommand.h ('k') | Source/core/editing/ReplaceSelectionCommand.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698