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

Unified Diff: third_party/WebKit/Source/core/editing/commands/ReplaceSelectionCommand.cpp

Issue 2451093002: Get rid of EditCommand::setEndingSelection() taking one VisiblePosition (Closed)
Patch Set: 2016-10-26T16:39:39 Created 4 years, 2 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 | « third_party/WebKit/Source/core/editing/commands/InsertListCommand.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/editing/commands/ReplaceSelectionCommand.cpp
diff --git a/third_party/WebKit/Source/core/editing/commands/ReplaceSelectionCommand.cpp b/third_party/WebKit/Source/core/editing/commands/ReplaceSelectionCommand.cpp
index 65611647e36dbe5c7407d91728e52c9fc1fce5cb..14fdb25f65bb59bbb96233c64a0fa3e0df639aa4 100644
--- a/third_party/WebKit/Source/core/editing/commands/ReplaceSelectionCommand.cpp
+++ b/third_party/WebKit/Source/core/editing/commands/ReplaceSelectionCommand.cpp
@@ -1207,10 +1207,14 @@ void ReplaceSelectionCommand::doApply(EditingState* editingState) {
VisiblePosition startAfterDelete = endingSelection().visibleStart();
if (isEndOfParagraph(startAfterDelete) &&
!isStartOfParagraph(startAfterDelete) &&
- !isEndOfEditableOrNonEditableContent(startAfterDelete))
- setEndingSelection(nextPositionOf(startAfterDelete));
- else
+ !isEndOfEditableOrNonEditableContent(startAfterDelete)) {
+ setEndingSelection(
+ SelectionInDOMTree::Builder()
+ .collapse(nextPositionOf(startAfterDelete).deepEquivalent())
+ .build());
+ } else {
insertParagraphSeparator(editingState);
+ }
if (editingState->isAborted())
return;
}
@@ -1221,7 +1225,9 @@ void ReplaceSelectionCommand::doApply(EditingState* editingState) {
nextPositionOf(visibleStart, CannotCrossEditingBoundary);
if (isEndOfParagraph(visibleStart) && !isStartOfParagraph(visibleStart) &&
next.isNotNull()) {
- setEndingSelection(next);
+ setEndingSelection(SelectionInDOMTree::Builder()
+ .collapse(next.deepEquivalent())
+ .build());
} else {
insertParagraphSeparator(editingState);
if (editingState->isAborted())
@@ -1250,7 +1256,11 @@ void ReplaceSelectionCommand::doApply(EditingState* editingState) {
if (editingState->isAborted())
return;
document().updateStyleAndLayoutIgnorePendingStylesheets();
- setEndingSelection(previousPositionOf(endingSelection().visibleStart()));
+ setEndingSelection(
+ SelectionInDOMTree::Builder()
+ .collapse(previousPositionOf(endingSelection().visibleStart())
+ .deepEquivalent())
+ .build());
}
}
@@ -1627,14 +1637,17 @@ void ReplaceSelectionCommand::doApply(EditingState* editingState) {
if (editingState->isAborted())
return;
}
- document().updateStyleAndLayoutIgnorePendingStylesheets();
setEndingSelection(
- VisiblePosition::afterNode(insertedNodes.lastLeafInserted()));
+ SelectionInDOMTree::Builder()
+ .collapse(Position::afterNode(insertedNodes.lastLeafInserted()))
+ .build());
// Select up to the paragraph separator that was added.
lastPositionToSelect =
endingSelection().visibleStart().deepEquivalent();
} else if (!isStartOfParagraph(endOfInsertedContent)) {
- setEndingSelection(endOfInsertedContent);
+ setEndingSelection(SelectionInDOMTree::Builder()
+ .collapse(endOfInsertedContent.deepEquivalent())
+ .build());
Element* enclosingBlockElement =
enclosingBlock(endOfInsertedContent.deepEquivalent().anchorNode());
if (isListItem(enclosingBlockElement)) {
@@ -1642,8 +1655,10 @@ void ReplaceSelectionCommand::doApply(EditingState* editingState) {
insertNodeAfter(newListItem, enclosingBlockElement, editingState);
if (editingState->isAborted())
return;
- document().updateStyleAndLayoutIgnorePendingStylesheets();
- setEndingSelection(VisiblePosition::firstPositionInNode(newListItem));
+ setEndingSelection(
+ SelectionInDOMTree::Builder()
+ .collapse(Position::firstPositionInNode(newListItem))
+ .build());
} else {
// Use a default paragraph element (a plain div) for the empty
// paragraph, using the last paragraph block's style seems to annoy
« no previous file with comments | « third_party/WebKit/Source/core/editing/commands/InsertListCommand.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698