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

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

Issue 23548010: Have htmlediting create functions take a Document reference in argument (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 3 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
Index: Source/core/editing/ReplaceSelectionCommand.cpp
diff --git a/Source/core/editing/ReplaceSelectionCommand.cpp b/Source/core/editing/ReplaceSelectionCommand.cpp
index da4ecdd787cbc53a7084e924db55d460658ebd63..44eda01792fad2db43439b4bd9912b63900c5adb 100644
--- a/Source/core/editing/ReplaceSelectionCommand.cpp
+++ b/Source/core/editing/ReplaceSelectionCommand.cpp
@@ -245,7 +245,8 @@ void ReplacementFragment::insertNodeBefore(PassRefPtr<Node> node, Node* refNode)
PassRefPtr<Element> ReplacementFragment::insertFragmentForTestRendering(Node* rootEditableElement)
{
- RefPtr<Element> holder = createDefaultParagraphElement(m_document.get());
+ ASSERT(m_document);
+ RefPtr<Element> holder = createDefaultParagraphElement(*m_document.get());
holder->appendChild(m_fragment);
rootEditableElement->appendChild(holder.get());
@@ -818,7 +819,7 @@ void ReplaceSelectionCommand::mergeEndIfNeeded()
// Merging forward could result in deleting the destination anchor node.
// To avoid this, we add a placeholder node before the start of the paragraph.
if (endOfParagraph(startOfParagraphToMove) == destination) {
- RefPtr<Node> placeholder = createBreakElement(&document());
+ RefPtr<Node> placeholder = createBreakElement(document());
insertNodeBefore(placeholder, startOfParagraphToMove.deepEquivalent().deprecatedNode());
destination = VisiblePosition(positionBeforeNode(placeholder.get()));
}
@@ -1115,7 +1116,7 @@ void ReplaceSelectionCommand::doApply()
// We inserted before the startBlock to prevent nesting, and the content before the startBlock wasn't in its own block and
// didn't have a br after it, so the inserted content ended up in the same paragraph.
if (startBlock && insertionPos.deprecatedNode() == startBlock->parentNode() && (unsigned)insertionPos.deprecatedEditingOffset() < startBlock->nodeIndex() && !isStartOfParagraph(startOfInsertedContent))
- insertNodeAt(createBreakElement(&document()).get(), startOfInsertedContent.deepEquivalent());
+ insertNodeAt(createBreakElement(document()).get(), startOfInsertedContent.deepEquivalent());
if (endBR && (plainTextFragment || shouldRemoveEndBR(endBR, originalVisPosBeforeEndBR))) {
RefPtr<Node> parent = endBR->parentNode();
@@ -1150,7 +1151,7 @@ void ReplaceSelectionCommand::doApply()
// We insert a placeholder before the newly inserted content to avoid being merged into the inline.
Node* destinationNode = destination.deepEquivalent().deprecatedNode();
if (m_shouldMergeEnd && destinationNode != enclosingInline(destinationNode) && enclosingInline(destinationNode)->nextSibling())
- insertNodeBefore(createBreakElement(&document()), refNode.get());
+ insertNodeBefore(createBreakElement(document()), refNode.get());
// Merging the the first paragraph of inserted content with the content that came
// before the selection that was pasted into would also move content after
@@ -1161,7 +1162,7 @@ void ReplaceSelectionCommand::doApply()
// comes after and prevent that from happening.
VisiblePosition endOfInsertedContent = positionAtEndOfInsertedContent();
if (startOfParagraph(endOfInsertedContent) == startOfParagraphToMove) {
- insertNodeAt(createBreakElement(&document()).get(), endOfInsertedContent.deepEquivalent());
+ insertNodeAt(createBreakElement(document()).get(), endOfInsertedContent.deepEquivalent());
// Mutation events (bug 22634) triggered by inserting the <br> might have removed the content we're about to move
if (!startOfParagraphToMove.deepEquivalent().anchorNode()->inDocument())
return;
@@ -1185,7 +1186,7 @@ void ReplaceSelectionCommand::doApply()
setEndingSelection(endOfInsertedContent);
Node* enclosingNode = enclosingBlock(endOfInsertedContent.deepEquivalent().deprecatedNode());
if (isListItem(enclosingNode)) {
- RefPtr<Node> newListItem = createListItemElement(&document());
+ RefPtr<Node> newListItem = createListItemElement(document());
insertNodeAfter(newListItem, enclosingNode);
setEndingSelection(VisiblePosition(firstPositionInNode(newListItem.get())));
} else {
« no previous file with comments | « Source/core/editing/ReplaceNodeWithSpanCommand.cpp ('k') | Source/core/editing/WrapContentsInDummySpanCommand.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698