| 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 68aee201cbbe8b3e2226b5d4b3e667d7bc59ff60..5bbb1ff301d2a56183fac8a10182296827f36c8a 100644
|
| --- a/third_party/WebKit/Source/core/editing/commands/TypingCommand.cpp
|
| +++ b/third_party/WebKit/Source/core/editing/commands/TypingCommand.cpp
|
| @@ -49,12 +49,13 @@ namespace blink {
|
| using namespace HTMLNames;
|
|
|
| TypingCommand::TypingCommand(Document& document,
|
| + CommandSource source,
|
| ETypingCommand commandType,
|
| const String& textToInsert,
|
| Options options,
|
| TextGranularity granularity,
|
| TextCompositionType compositionType)
|
| - : CompositeEditCommand(document),
|
| + : CompositeEditCommand(document, source),
|
| m_commandType(commandType),
|
| m_textToInsert(textToInsert),
|
| m_openForMoreTyping(true),
|
| @@ -70,7 +71,9 @@ TypingCommand::TypingCommand(Document& document,
|
| updatePreservesTypingStyle(m_commandType);
|
| }
|
|
|
| -void TypingCommand::deleteSelection(Document& document, Options options) {
|
| +void TypingCommand::deleteSelection(Document& document,
|
| + CommandSource source,
|
| + Options options) {
|
| LocalFrame* frame = document.frame();
|
| DCHECK(frame);
|
|
|
| @@ -90,10 +93,12 @@ void TypingCommand::deleteSelection(Document& document, Options options) {
|
| return;
|
| }
|
|
|
| - TypingCommand::create(document, DeleteSelection, "", options)->apply();
|
| + TypingCommand::create(document, source, DeleteSelection, "", options)
|
| + ->apply();
|
| }
|
|
|
| void TypingCommand::deleteKeyPressed(Document& document,
|
| + CommandSource source,
|
| Options options,
|
| TextGranularity granularity) {
|
| if (granularity == CharacterGranularity) {
|
| @@ -116,10 +121,12 @@ void TypingCommand::deleteKeyPressed(Document& document,
|
| }
|
| }
|
|
|
| - TypingCommand::create(document, DeleteKey, "", options, granularity)->apply();
|
| + TypingCommand::create(document, source, DeleteKey, "", options, granularity)
|
| + ->apply();
|
| }
|
|
|
| void TypingCommand::forwardDeleteKeyPressed(Document& document,
|
| + CommandSource source,
|
| EditingState* editingState,
|
| Options options,
|
| TextGranularity granularity) {
|
| @@ -138,7 +145,8 @@ void TypingCommand::forwardDeleteKeyPressed(Document& document,
|
| }
|
| }
|
|
|
| - TypingCommand::create(document, ForwardDeleteKey, "", options, granularity)
|
| + TypingCommand::create(document, source, ForwardDeleteKey, "", options,
|
| + granularity)
|
| ->apply();
|
| }
|
|
|
| @@ -181,6 +189,7 @@ static String dispatchBeforeTextInsertedEvent(
|
| }
|
|
|
| void TypingCommand::insertText(Document& document,
|
| + CommandSource source,
|
| const String& text,
|
| Options options,
|
| TextCompositionType composition) {
|
| @@ -191,13 +200,14 @@ void TypingCommand::insertText(Document& document,
|
| document.frame()->spellChecker().updateMarkersForWordsAffectedByEditing(
|
| isSpaceOrNewline(text[0]));
|
|
|
| - insertText(document, text, frame->selection().selection(), options,
|
| + insertText(document, source, text, frame->selection().selection(), options,
|
| composition);
|
| }
|
|
|
| // FIXME: We shouldn't need to take selectionForInsertion. It should be
|
| // identical to FrameSelection's current selection.
|
| void TypingCommand::insertText(Document& document,
|
| + CommandSource source,
|
| const String& text,
|
| const VisibleSelection& selectionForInsertion,
|
| Options options,
|
| @@ -233,8 +243,8 @@ void TypingCommand::insertText(Document& document,
|
| return;
|
| }
|
|
|
| - TypingCommand* command = TypingCommand::create(document, InsertText, newText,
|
| - options, compositionType);
|
| + TypingCommand* command = TypingCommand::create(
|
| + document, source, InsertText, newText, options, compositionType);
|
| bool changeSelection = selectionForInsertion != currentSelection;
|
| if (changeSelection) {
|
| command->setStartingSelection(selectionForInsertion);
|
| @@ -247,7 +257,7 @@ void TypingCommand::insertText(Document& document,
|
| }
|
| }
|
|
|
| -bool TypingCommand::insertLineBreak(Document& document) {
|
| +bool TypingCommand::insertLineBreak(Document& document, CommandSource source) {
|
| if (TypingCommand* lastTypingCommand =
|
| lastTypingCommandIfStillOpenForTyping(document.frame())) {
|
| lastTypingCommand->setShouldRetainAutocorrectionIndicator(false);
|
| @@ -256,11 +266,13 @@ bool TypingCommand::insertLineBreak(Document& document) {
|
| return !editingState.isAborted();
|
| }
|
|
|
| - return TypingCommand::create(document, InsertLineBreak, "", 0)->apply();
|
| + return TypingCommand::create(document, source, InsertLineBreak, "", 0)
|
| + ->apply();
|
| }
|
|
|
| bool TypingCommand::insertParagraphSeparatorInQuotedContent(
|
| - Document& document) {
|
| + Document& document,
|
| + CommandSource source) {
|
| if (TypingCommand* lastTypingCommand =
|
| lastTypingCommandIfStillOpenForTyping(document.frame())) {
|
| EditingState editingState;
|
| @@ -268,12 +280,13 @@ bool TypingCommand::insertParagraphSeparatorInQuotedContent(
|
| return !editingState.isAborted();
|
| }
|
|
|
| - return TypingCommand::create(document,
|
| + return TypingCommand::create(document, source,
|
| InsertParagraphSeparatorInQuotedContent)
|
| ->apply();
|
| }
|
|
|
| -bool TypingCommand::insertParagraphSeparator(Document& document) {
|
| +bool TypingCommand::insertParagraphSeparator(Document& document,
|
| + CommandSource source) {
|
| if (TypingCommand* lastTypingCommand =
|
| lastTypingCommandIfStillOpenForTyping(document.frame())) {
|
| lastTypingCommand->setShouldRetainAutocorrectionIndicator(false);
|
| @@ -282,7 +295,8 @@ bool TypingCommand::insertParagraphSeparator(Document& document) {
|
| return !editingState.isAborted();
|
| }
|
|
|
| - return TypingCommand::create(document, InsertParagraphSeparator, "", 0)
|
| + return TypingCommand::create(document, source, InsertParagraphSeparator, "",
|
| + 0)
|
| ->apply();
|
| }
|
|
|
| @@ -428,7 +442,7 @@ void TypingCommand::insertTextRunWithoutNewlines(const String& text,
|
| bool selectInsertedText,
|
| EditingState* editingState) {
|
| InsertTextCommand* command = InsertTextCommand::create(
|
| - document(), text, selectInsertedText,
|
| + document(), commandSource(), text, selectInsertedText,
|
| m_compositionType == TextCompositionNone
|
| ? InsertTextCommand::RebalanceLeadingAndTrailingWhitespaces
|
| : InsertTextCommand::RebalanceAllWhitespaces);
|
| @@ -454,8 +468,9 @@ void TypingCommand::insertLineBreak(EditingState* editingState) {
|
| if (!canAppendNewLineFeedToSelection(endingSelection()))
|
| return;
|
|
|
| - applyCommandToComposite(InsertLineBreakCommand::create(document()),
|
| - editingState);
|
| + applyCommandToComposite(
|
| + InsertLineBreakCommand::create(document(), commandSource()),
|
| + editingState);
|
| if (editingState->isAborted())
|
| return;
|
| typingAddedToOpenCommand(InsertLineBreak);
|
| @@ -465,8 +480,9 @@ void TypingCommand::insertParagraphSeparator(EditingState* editingState) {
|
| if (!canAppendNewLineFeedToSelection(endingSelection()))
|
| return;
|
|
|
| - applyCommandToComposite(InsertParagraphSeparatorCommand::create(document()),
|
| - editingState);
|
| + applyCommandToComposite(
|
| + InsertParagraphSeparatorCommand::create(document(), commandSource()),
|
| + editingState);
|
| if (editingState->isAborted())
|
| return;
|
| typingAddedToOpenCommand(InsertParagraphSeparator);
|
| @@ -482,8 +498,9 @@ void TypingCommand::insertParagraphSeparatorInQuotedContent(
|
| return;
|
| }
|
|
|
| - applyCommandToComposite(BreakBlockquoteCommand::create(document()),
|
| - editingState);
|
| + applyCommandToComposite(
|
| + BreakBlockquoteCommand::create(document(), commandSource()),
|
| + editingState);
|
| if (editingState->isAborted())
|
| return;
|
| typingAddedToOpenCommand(InsertParagraphSeparatorInQuotedContent);
|
|
|