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

Unified Diff: third_party/WebKit/Source/core/editing/commands/InsertTextCommand.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/InsertTextCommand.cpp
diff --git a/third_party/WebKit/Source/core/editing/commands/InsertTextCommand.cpp b/third_party/WebKit/Source/core/editing/commands/InsertTextCommand.cpp
index dedda26481f4c9ea7ab4887abc8ff1ddb2f2dde7..e806ae436f4523006b13d27ec377c42715ea427a 100644
--- a/third_party/WebKit/Source/core/editing/commands/InsertTextCommand.cpp
+++ b/third_party/WebKit/Source/core/editing/commands/InsertTextCommand.cpp
@@ -79,10 +79,11 @@ void InsertTextCommand::setEndingSelectionWithoutValidation(
// We could have inserted a part of composed character sequence,
// so we are basically treating ending selection as a range to avoid
// validation. <http://bugs.webkit.org/show_bug.cgi?id=15781>
- VisibleSelection forcedEndingSelection;
- forcedEndingSelection.setWithoutValidation(startPosition, endPosition);
- forcedEndingSelection.setIsDirectional(endingSelection().isDirectional());
- setEndingSelection(forcedEndingSelection);
+ setEndingSelection(SelectionInDOMTree::Builder()
+ .collapse(startPosition)
+ .extend(endPosition)
+ .setIsDirectional(endingSelection().isDirectional())
+ .build());
}
// This avoids the expense of a full fledged delete operation, and avoids a
@@ -103,12 +104,10 @@ bool InsertTextCommand::performTrivialReplace(const String& text,
setEndingSelectionWithoutValidation(start, endPosition);
if (selectInsertedText)
return true;
- document().updateStyleAndLayoutIgnorePendingStylesheets();
- setEndingSelection(createVisibleSelection(
- SelectionInDOMTree::Builder()
- .collapse(endingSelection().end())
- .setIsDirectional(endingSelection().isDirectional())
- .build()));
+ setEndingSelection(SelectionInDOMTree::Builder()
+ .collapse(endingSelection().end())
+ .setIsDirectional(endingSelection().isDirectional())
+ .build());
return true;
}
@@ -132,16 +131,12 @@ bool InsertTextCommand::performOverwrite(const String& text,
Position endPosition =
Position(textNode, start.offsetInContainerNode() + text.length());
setEndingSelectionWithoutValidation(start, endPosition);
- if (selectInsertedText)
+ if (selectInsertedText || endingSelection().isNone())
return true;
- document().updateStyleAndLayoutIgnorePendingStylesheets();
- if (endingSelection().isNone())
- return true;
- setEndingSelection(createVisibleSelection(
- SelectionInDOMTree::Builder()
- .collapse(endingSelection().end())
- .setIsDirectional(endingSelection().isDirectional())
- .build()));
+ setEndingSelection(SelectionInDOMTree::Builder()
+ .collapse(endingSelection().end())
+ .setIsDirectional(endingSelection().isDirectional())
+ .build());
return true;
}
@@ -282,13 +277,12 @@ void InsertTextCommand::doApply(EditingState* editingState) {
}
if (!m_selectInsertedText) {
- document().updateStyleAndLayoutIgnorePendingStylesheets();
SelectionInDOMTree::Builder builder;
builder.setAffinity(endingSelection().affinity());
builder.setIsDirectional(endingSelection().isDirectional());
if (endingSelection().end().isNotNull())
builder.collapse(endingSelection().end());
- setEndingSelection(createVisibleSelection(builder.build()));
+ setEndingSelection(builder.build());
}
}

Powered by Google App Engine
This is Rietveld 408576698