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

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

Issue 2634633002: Revert of [Editing] Introduce |CompositeEditCommand::willApplyEditing()| in prepare for (1/3) (Closed)
Patch Set: Created 3 years, 11 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 c7c0ecd59787bc4b6e651bf237664260cad014a9..6f61e1415dde1c184090c49eb3054870f6ffb778 100644
--- a/third_party/WebKit/Source/core/editing/commands/TypingCommand.cpp
+++ b/third_party/WebKit/Source/core/editing/commands/TypingCommand.cpp
@@ -122,39 +122,6 @@
return event->text().length();
}
-InputEvent::InputType inputTypeForTypingCommand(
- TypingCommand::ETypingCommand commandType,
- TextGranularity granularity,
- TypingCommand::TextCompositionType compositionType) {
- using InputType = InputEvent::InputType;
-
- switch (commandType) {
- // TODO(chongz): |DeleteSelection| is used by IME but we don't have
- // direction info.
- case TypingCommand::DeleteSelection:
- return InputType::DeleteContentBackward;
- case TypingCommand::DeleteKey:
- if (compositionType != TypingCommand::TextCompositionNone)
- return InputType::DeleteComposedCharacterBackward;
- return deletionInputTypeFromTextGranularity(DeleteDirection::Backward,
- granularity);
- case TypingCommand::ForwardDeleteKey:
- if (compositionType != TypingCommand::TextCompositionNone)
- return InputType::DeleteComposedCharacterForward;
- return deletionInputTypeFromTextGranularity(DeleteDirection::Forward,
- granularity);
- case TypingCommand::InsertText:
- return InputType::InsertText;
- case TypingCommand::InsertLineBreak:
- return InputType::InsertLineBreak;
- case TypingCommand::InsertParagraphSeparator:
- case TypingCommand::InsertParagraphSeparatorInQuotedContent:
- return InputType::InsertParagraph;
- default:
- return InputType::None;
- }
-}
-
} // anonymous namespace
using namespace HTMLNames;
@@ -178,8 +145,6 @@
m_shouldRetainAutocorrectionIndicator(options &
RetainAutocorrectionIndicator),
m_shouldPreventSpellChecking(options & PreventSpellChecking) {
- m_inputType = inputTypeForTypingCommand(m_commandType, m_granularity,
- m_compositionType);
updatePreservesTypingStyle(m_commandType);
}
@@ -198,9 +163,6 @@
lastTypingCommand->setShouldPreventSpellChecking(options &
PreventSpellChecking);
- if (!lastTypingCommand->willAddTypingToOpenCommand(
- source, InputEvent::InputType::DeleteContentBackward))
- return;
// InputMethodController uses this function to delete composition
// selection. It won't be aborted.
lastTypingCommand->deleteSelection(options & SmartDelete,
@@ -227,9 +189,6 @@
frame);
lastTypingCommand->setShouldPreventSpellChecking(options &
PreventSpellChecking);
- if (!lastTypingCommand->willAddTypingToOpenCommand(
- source, InputEvent::InputType::DeleteContentBackward))
- return;
EditingState editingState;
lastTypingCommand->deleteKeyPressed(granularity, options & KillRing,
&editingState);
@@ -256,9 +215,6 @@
updateSelectionIfDifferentFromCurrentSelection(lastTypingCommand, frame);
lastTypingCommand->setShouldPreventSpellChecking(options &
PreventSpellChecking);
- if (!lastTypingCommand->willAddTypingToOpenCommand(
- source, InputEvent::InputType::DeleteContentForward))
- return;
lastTypingCommand->forwardDeleteKeyPressed(
granularity, options & KillRing, editingState);
return;
@@ -270,9 +226,9 @@
}
String TypingCommand::textDataForInputEvent() const {
- if (m_inputType == InputEvent::InputType::InsertText)
+ if (m_commands.isEmpty() || isIncrementalInsertion())
return m_textToInsert;
- return CompositeEditCommand::textDataForInputEvent();
+ return m_commands.back()->textDataForInputEvent();
}
void TypingCommand::updateSelectionIfDifferentFromCurrentSelection(
@@ -375,11 +331,8 @@
options & RetainAutocorrectionIndicator);
lastTypingCommand->setShouldPreventSpellChecking(options &
PreventSpellChecking);
+ EditingState editingState;
lastTypingCommand->m_isIncrementalInsertion = isIncrementalInsertion;
- if (!lastTypingCommand->willAddTypingToOpenCommand(
- source, InputEvent::InputType::InsertText, newText))
- return;
- EditingState editingState;
lastTypingCommand->insertText(newText, options & SelectInsertedText,
&editingState);
@@ -430,9 +383,6 @@
if (TypingCommand* lastTypingCommand =
lastTypingCommandIfStillOpenForTyping(document.frame())) {
lastTypingCommand->setShouldRetainAutocorrectionIndicator(false);
- if (!lastTypingCommand->willAddTypingToOpenCommand(
- source, InputEvent::InputType::InsertLineBreak))
- return false;
EditingState editingState;
lastTypingCommand->insertLineBreak(&editingState);
return !editingState.isAborted();
@@ -446,9 +396,6 @@
EditCommandSource source) {
if (TypingCommand* lastTypingCommand =
lastTypingCommandIfStillOpenForTyping(document.frame())) {
- if (!lastTypingCommand->willAddTypingToOpenCommand(
- source, InputEvent::InputType::InsertParagraph))
- return false;
EditingState editingState;
lastTypingCommand->insertParagraphSeparatorInQuotedContent(&editingState);
return !editingState.isAborted();
@@ -464,9 +411,6 @@
if (TypingCommand* lastTypingCommand =
lastTypingCommandIfStillOpenForTyping(document.frame())) {
lastTypingCommand->setShouldRetainAutocorrectionIndicator(false);
- if (!lastTypingCommand->willAddTypingToOpenCommand(
- source, InputEvent::InputType::InsertParagraph))
- return false;
EditingState editingState;
lastTypingCommand->insertParagraphSeparator(&editingState);
return !editingState.isAborted();
@@ -531,15 +475,33 @@
}
InputEvent::InputType TypingCommand::inputType() const {
- return m_inputType;
-}
-
-bool TypingCommand::willAddTypingToOpenCommand(EditCommandSource source,
- InputEvent::InputType inputType,
- const String& text) {
- m_inputType = inputType;
- m_textToInsert = text;
- return willApplyEditing(source);
+ using InputType = InputEvent::InputType;
+
+ switch (m_commandType) {
+ // TODO(chongz): |DeleteSelection| is used by IME but we don't have
+ // direction info.
+ case DeleteSelection:
+ return InputType::DeleteContentBackward;
+ case DeleteKey:
+ if (m_compositionType != TextCompositionNone)
+ return InputType::DeleteComposedCharacterBackward;
+ return deletionInputTypeFromTextGranularity(DeleteDirection::Backward,
+ m_granularity);
+ case ForwardDeleteKey:
+ if (m_compositionType != TextCompositionNone)
+ return InputType::DeleteComposedCharacterForward;
+ return deletionInputTypeFromTextGranularity(DeleteDirection::Forward,
+ m_granularity);
+ case InsertText:
+ return InputType::InsertText;
+ case InsertLineBreak:
+ return InputType::InsertLineBreak;
+ case InsertParagraphSeparator:
+ case InsertParagraphSeparatorInQuotedContent:
+ return InputType::InsertParagraph;
+ default:
+ return InputType::None;
+ }
}
void TypingCommand::typingAddedToOpenCommand(
« 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