| 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)
|
|
|