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

Unified Diff: third_party/WebKit/Source/core/editing/Editor.cpp

Issue 2117543003: [InputEvent] Fill |data| field for 'input' event InsertText (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add tests for InputEvent.data Created 4 years, 5 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/Editor.cpp
diff --git a/third_party/WebKit/Source/core/editing/Editor.cpp b/third_party/WebKit/Source/core/editing/Editor.cpp
index af360607889dfe0a89484963e17705382a367e14..f4b173989700cce780c05c8e0fe74633ba9b1ec4 100644
--- a/third_party/WebKit/Source/core/editing/Editor.cpp
+++ b/third_party/WebKit/Source/core/editing/Editor.cpp
@@ -142,6 +142,22 @@ InputEvent::InputType inputTypeFromCommand(const CompositeEditCommand* command)
return InputEvent::InputType::None;
}
+String dataFromCommand(const CompositeEditCommand* command)
+{
+ if (command->isTypingCommand()) {
yosin_UTC9 2016/07/05 01:22:07 nit: To reduce indentation, we could write: if (!
chongz 2016/07/05 20:33:27 Done.
+ const TypingCommand* typingCommand = toTypingCommand(command);
+ // Only InsertText has |data|.
+ switch (typingCommand->commandTypeOfOpenCommand()) {
+ case TypingCommand::InsertText:
+ return typingCommand->textOfLastCommand();
yosin_UTC9 2016/07/05 01:22:07 Can we make |textOfLastCommand()| as virtual funct
chongz 2016/07/05 20:33:27 Changed to |textData()|.
+ default:
+ return emptyString();
+ }
+ }
+
+ return emptyString();
+}
+
InputEvent::EventIsComposing isComposingFromCommand(const CompositeEditCommand* command)
{
if (command->isTypingCommand() && toTypingCommand(command)->compositionType() != TypingCommand::TextCompositionNone)
@@ -752,8 +768,7 @@ void Editor::appliedEditing(CompositeEditCommand* cmd)
DCHECK(composition);
dispatchEditableContentChangedEvents(composition->startingRootEditableElement(), composition->endingRootEditableElement());
// TODO(chongz): Filter empty InputType after spec is finalized.
- // TODO(chongz): Fill in |data| field.
- dispatchInputEventEditableContentChanged(composition->startingRootEditableElement(), composition->endingRootEditableElement(), inputTypeFromCommand(cmd), emptyString(), isComposingFromCommand(cmd));
+ dispatchInputEventEditableContentChanged(composition->startingRootEditableElement(), composition->endingRootEditableElement(), inputTypeFromCommand(cmd), dataFromCommand(cmd), isComposingFromCommand(cmd));
VisibleSelection newSelection(cmd->endingSelection());
// Don't clear the typing style with this selection change. We do those things elsewhere if necessary.

Powered by Google App Engine
This is Rietveld 408576698