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

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

Issue 2450213002: Utilize EditCommand::setEndingSelection() taking SelectionInDOMTree (Closed)
Patch Set: 2016-10-28T14:44:14 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
Index: third_party/WebKit/Source/core/editing/commands/CompositeEditCommand.cpp
diff --git a/third_party/WebKit/Source/core/editing/commands/CompositeEditCommand.cpp b/third_party/WebKit/Source/core/editing/commands/CompositeEditCommand.cpp
index 6d872a4d4de20e5f238b3a37c11f0fd591a90365..2c0b4f3f93ecdf7bbadb9012b93bf57798206b49 100644
--- a/third_party/WebKit/Source/core/editing/commands/CompositeEditCommand.cpp
+++ b/third_party/WebKit/Source/core/editing/commands/CompositeEditCommand.cpp
@@ -297,7 +297,7 @@ void CompositeEditCommand::applyCommandToComposite(
command->setParent(this);
if (selection != command->endingSelection()) {
command->setStartingSelection(selection);
- command->setEndingSelection(selection);
+ command->setEndingVisibleSelection(selection);
}
command->doApply(editingState);
if (!editingState->isAborted())
@@ -1242,8 +1242,8 @@ void CompositeEditCommand::pushAnchorElementDown(Element* anchorNode,
DCHECK(anchorNode->isLink()) << anchorNode;
- setEndingSelection(createVisibleSelection(
- SelectionInDOMTree::Builder().selectAllChildren(*anchorNode).build()));
+ setEndingSelection(
+ SelectionInDOMTree::Builder().selectAllChildren(*anchorNode).build());
applyStyledElement(anchorNode, editingState);
if (editingState->isAborted())
return;
@@ -1437,10 +1437,8 @@ void CompositeEditCommand::moveParagraphWithClones(
cloneParagraphUnderNewElement(start, end, outerNode, blockElement,
editingState);
- document().updateStyleAndLayoutIgnorePendingStylesheets();
-
- setEndingSelection(createVisibleSelection(
- SelectionInDOMTree::Builder().collapse(start).extend(end).build()));
+ setEndingSelection(
+ SelectionInDOMTree::Builder().collapse(start).extend(end).build());
deleteSelection(editingState, false, false, false);
if (editingState->isAborted())
return;
@@ -1599,8 +1597,8 @@ void CompositeEditCommand::moveParagraphs(
DCHECK(!document().needsLayoutTreeUpdate());
- setEndingSelection(createVisibleSelection(
- SelectionInDOMTree::Builder().collapse(start).extend(end).build()));
+ setEndingSelection(
+ SelectionInDOMTree::Builder().collapse(start).extend(end).build());
document()
.frame()
->spellChecker()
@@ -1648,11 +1646,11 @@ void CompositeEditCommand::moveParagraphs(
Position::firstPositionInNode(document().documentElement()),
destination.toParentAnchoredPosition(), true);
- VisibleSelection destinationSelection =
- createVisibleSelection(SelectionInDOMTree::Builder()
- .collapse(destination.toPositionWithAffinity())
- .setIsDirectional(originalIsDirectional)
- .build());
+ const SelectionInDOMTree& destinationSelection =
+ SelectionInDOMTree::Builder()
+ .collapse(destination.toPositionWithAffinity())
+ .setIsDirectional(originalIsDirectional)
+ .build();
if (endingSelection().isNone()) {
// We abort executing command since |destination| becomes invisible.
editingState->abort();
@@ -1711,12 +1709,11 @@ void CompositeEditCommand::moveParagraphs(
.createRangeForSelection(*documentElement);
if (endRange.isNull())
return;
- setEndingSelection(
- createVisibleSelection(SelectionInDOMTree::Builder()
- .collapse(startRange.startPosition())
- .extend(endRange.startPosition())
- .setIsDirectional(originalIsDirectional)
- .build()));
+ setEndingSelection(SelectionInDOMTree::Builder()
+ .collapse(startRange.startPosition())
+ .extend(endRange.startPosition())
+ .setIsDirectional(originalIsDirectional)
+ .build());
}
// FIXME: Send an appropriate shouldDeleteRange call.
@@ -1817,12 +1814,10 @@ bool CompositeEditCommand::breakOutOfEmptyListItem(EditingState* editingState) {
if (editingState->isAborted())
return false;
- document().updateStyleAndLayoutIgnorePendingStylesheets();
- setEndingSelection(createVisibleSelection(
- SelectionInDOMTree::Builder()
- .collapse(Position::firstPositionInNode(newBlock))
- .setIsDirectional(endingSelection().isDirectional())
- .build()));
+ setEndingSelection(SelectionInDOMTree::Builder()
+ .collapse(Position::firstPositionInNode(newBlock))
+ .setIsDirectional(endingSelection().isDirectional())
+ .build());
style->prepareToApplyAt(endingSelection().start());
if (!style->isEmpty()) {
@@ -1881,11 +1876,10 @@ bool CompositeEditCommand::breakOutOfEmptyMailBlockquotedParagraph(
return false;
document().updateStyleAndLayoutIgnorePendingStylesheets();
}
- setEndingSelection(createVisibleSelection(
- SelectionInDOMTree::Builder()
- .collapse(atBR.toPositionWithAffinity())
- .setIsDirectional(endingSelection().isDirectional())
- .build()));
+ setEndingSelection(SelectionInDOMTree::Builder()
+ .collapse(atBR.toPositionWithAffinity())
+ .setIsDirectional(endingSelection().isDirectional())
+ .build());
// If this is an empty paragraph there must be a line break here.
if (!lineBreakExistsAtVisiblePosition(caret))

Powered by Google App Engine
This is Rietveld 408576698