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

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

Issue 1773443002: Revert of Simplify TypingCommand::insertText (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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/TypingCommand.h ('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/TypingCommand.cpp
diff --git a/third_party/WebKit/Source/core/editing/commands/TypingCommand.cpp b/third_party/WebKit/Source/core/editing/commands/TypingCommand.cpp
index a3adb9915ca80936c7b53d7c5bb9fd87b9bd661f..65a3e20d0f8857e2aea232620d9de380ba551d10 100644
--- a/third_party/WebKit/Source/core/editing/commands/TypingCommand.cpp
+++ b/third_party/WebKit/Source/core/editing/commands/TypingCommand.cpp
@@ -183,7 +183,7 @@ static String dispatchBeforeTextInsertedEvent(const String& text, const VisibleS
return newText;
}
-void TypingCommand::insertText(Document& document, const String& text, Options options, TextCompositionType compositionType)
+void TypingCommand::insertText(Document& document, const String& text, Options options, TextCompositionType composition)
{
LocalFrame* frame = document.frame();
ASSERT(frame);
@@ -191,17 +191,26 @@ void TypingCommand::insertText(Document& document, const String& text, Options o
if (!text.isEmpty())
document.frame()->spellChecker().updateMarkersForWordsAffectedByEditing(isSpaceOrNewline(text[0]));
- const VisibleSelection& currentSelection = frame->selection().selection();
+ insertText(document, text, frame->selection().selection(), options, composition);
+}
- String newText = dispatchBeforeTextInsertedEvent(text, currentSelection, compositionType == TextCompositionUpdate);
+// FIXME: We shouldn't need to take selectionForInsertion. It should be identical to FrameSelection's current selection.
+void TypingCommand::insertText(Document& document, const String& text, const VisibleSelection& selectionForInsertion, Options options, TextCompositionType compositionType)
+{
+ RefPtrWillBeRawPtr<LocalFrame> frame = document.frame();
+ ASSERT(frame);
+
+ VisibleSelection currentSelection = frame->selection().selection();
+
+ String newText = dispatchBeforeTextInsertedEvent(text, selectionForInsertion, compositionType == TextCompositionUpdate);
// Set the starting and ending selection appropriately if we are using a selection
// that is different from the current selection. In the future, we should change EditCommand
// to deal with custom selections in a general way that can be used by all of the commands.
- if (RefPtrWillBeRawPtr<TypingCommand> lastTypingCommand = lastTypingCommandIfStillOpenForTyping(frame)) {
- if (!equalSelectionsInDOMTree(lastTypingCommand->endingSelection(), currentSelection)) {
- lastTypingCommand->setStartingSelection(currentSelection);
- lastTypingCommand->setEndingSelection(currentSelection);
+ if (RefPtrWillBeRawPtr<TypingCommand> lastTypingCommand = lastTypingCommandIfStillOpenForTyping(frame.get())) {
+ if (!equalSelectionsInDOMTree(lastTypingCommand->endingSelection(), selectionForInsertion)) {
+ lastTypingCommand->setStartingSelection(selectionForInsertion);
+ lastTypingCommand->setEndingSelection(selectionForInsertion);
}
lastTypingCommand->setCompositionType(compositionType);
@@ -214,7 +223,7 @@ void TypingCommand::insertText(Document& document, const String& text, Options o
}
RefPtrWillBeRawPtr<TypingCommand> cmd = TypingCommand::create(document, InsertText, newText, options, compositionType);
- cmd->apply();
+ applyTextInsertionCommand(frame.get(), cmd, selectionForInsertion, currentSelection);
}
bool TypingCommand::insertLineBreak(Document& document)
« no previous file with comments | « third_party/WebKit/Source/core/editing/commands/TypingCommand.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698