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

Side by Side 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008, 2011 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008, 2011 Apple Inc. All rights reserved.
3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 return InputEvent::InputType::InsertText; 135 return InputEvent::InputType::InsertText;
136 default: 136 default:
137 return InputEvent::InputType::None; 137 return InputEvent::InputType::None;
138 } 138 }
139 } 139 }
140 140
141 // TODO(chongz): Handle other edit actions. 141 // TODO(chongz): Handle other edit actions.
142 return InputEvent::InputType::None; 142 return InputEvent::InputType::None;
143 } 143 }
144 144
145 String dataFromCommand(const CompositeEditCommand* command)
146 {
147 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.
148 const TypingCommand* typingCommand = toTypingCommand(command);
149 // Only InsertText has |data|.
150 switch (typingCommand->commandTypeOfOpenCommand()) {
151 case TypingCommand::InsertText:
152 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()|.
153 default:
154 return emptyString();
155 }
156 }
157
158 return emptyString();
159 }
160
145 InputEvent::EventIsComposing isComposingFromCommand(const CompositeEditCommand* command) 161 InputEvent::EventIsComposing isComposingFromCommand(const CompositeEditCommand* command)
146 { 162 {
147 if (command->isTypingCommand() && toTypingCommand(command)->compositionType( ) != TypingCommand::TextCompositionNone) 163 if (command->isTypingCommand() && toTypingCommand(command)->compositionType( ) != TypingCommand::TextCompositionNone)
148 return InputEvent::EventIsComposing::IsComposing; 164 return InputEvent::EventIsComposing::IsComposing;
149 return InputEvent::EventIsComposing::NotComposing; 165 return InputEvent::EventIsComposing::NotComposing;
150 } 166 }
151 167
152 } // anonymous namespace 168 } // anonymous namespace
153 169
154 Editor::RevealSelectionScope::RevealSelectionScope(Editor* editor) 170 Editor::RevealSelectionScope::RevealSelectionScope(Editor* editor)
(...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after
745 EventQueueScope scope; 761 EventQueueScope scope;
746 frame().document()->updateStyleAndLayout(); 762 frame().document()->updateStyleAndLayout();
747 763
748 // Request spell checking after pasting before any further DOM change. 764 // Request spell checking after pasting before any further DOM change.
749 requestSpellcheckingAfterApplyingCommand(cmd); 765 requestSpellcheckingAfterApplyingCommand(cmd);
750 766
751 EditCommandComposition* composition = cmd->composition(); 767 EditCommandComposition* composition = cmd->composition();
752 DCHECK(composition); 768 DCHECK(composition);
753 dispatchEditableContentChangedEvents(composition->startingRootEditableElemen t(), composition->endingRootEditableElement()); 769 dispatchEditableContentChangedEvents(composition->startingRootEditableElemen t(), composition->endingRootEditableElement());
754 // TODO(chongz): Filter empty InputType after spec is finalized. 770 // TODO(chongz): Filter empty InputType after spec is finalized.
755 // TODO(chongz): Fill in |data| field. 771 dispatchInputEventEditableContentChanged(composition->startingRootEditableEl ement(), composition->endingRootEditableElement(), inputTypeFromCommand(cmd), da taFromCommand(cmd), isComposingFromCommand(cmd));
756 dispatchInputEventEditableContentChanged(composition->startingRootEditableEl ement(), composition->endingRootEditableElement(), inputTypeFromCommand(cmd), em ptyString(), isComposingFromCommand(cmd));
757 VisibleSelection newSelection(cmd->endingSelection()); 772 VisibleSelection newSelection(cmd->endingSelection());
758 773
759 // Don't clear the typing style with this selection change. We do those thin gs elsewhere if necessary. 774 // Don't clear the typing style with this selection change. We do those thin gs elsewhere if necessary.
760 changeSelectionAfterCommand(newSelection, 0); 775 changeSelectionAfterCommand(newSelection, 0);
761 776
762 if (!cmd->preservesTypingStyle()) 777 if (!cmd->preservesTypingStyle())
763 frame().selection().clearTypingStyle(); 778 frame().selection().clearTypingStyle();
764 779
765 // Command will be equal to last edit command only in the case of typing 780 // Command will be equal to last edit command only in the case of typing
766 if (m_lastEditCommand.get() == cmd) { 781 if (m_lastEditCommand.get() == cmd) {
(...skipping 656 matching lines...) Expand 10 before | Expand all | Expand 10 after
1423 1438
1424 DEFINE_TRACE(Editor) 1439 DEFINE_TRACE(Editor)
1425 { 1440 {
1426 visitor->trace(m_frame); 1441 visitor->trace(m_frame);
1427 visitor->trace(m_lastEditCommand); 1442 visitor->trace(m_lastEditCommand);
1428 visitor->trace(m_undoStack); 1443 visitor->trace(m_undoStack);
1429 visitor->trace(m_mark); 1444 visitor->trace(m_mark);
1430 } 1445 }
1431 1446
1432 } // namespace blink 1447 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698