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

Side by Side Diff: third_party/WebKit/Source/core/events/InputEvent.cpp

Issue 2558643003: [InputEvent] Move 'beforeinput' logic into |CompositeEditCommand::willApplyEditing()| (3/3) (Closed)
Patch Set: Created 4 years 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 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/events/InputEvent.h" 5 #include "core/events/InputEvent.h"
6 6
7 #include "core/dom/Range.h" 7 #include "core/dom/Range.h"
8 #include "core/events/EventDispatcher.h" 8 #include "core/events/EventDispatcher.h"
9 #include "public/platform/WebEditingCommandType.h" 9 #include "public/platform/WebEditingCommandType.h"
10 10
(...skipping 14 matching lines...) Expand all
25 {InputEvent::InputType::InsertHorizontalRule, "insertHorizontalRule"}, 25 {InputEvent::InputType::InsertHorizontalRule, "insertHorizontalRule"},
26 {InputEvent::InputType::InsertFromPaste, "insertFromPaste"}, 26 {InputEvent::InputType::InsertFromPaste, "insertFromPaste"},
27 {InputEvent::InputType::InsertFromDrop, "insertFromDrop"}, 27 {InputEvent::InputType::InsertFromDrop, "insertFromDrop"},
28 {InputEvent::InputType::InsertReplacementText, "insertReplacementText"}, 28 {InputEvent::InputType::InsertReplacementText, "insertReplacementText"},
29 {InputEvent::InputType::DeleteComposedCharacterForward, 29 {InputEvent::InputType::DeleteComposedCharacterForward,
30 "deleteComposedCharacterForward"}, 30 "deleteComposedCharacterForward"},
31 {InputEvent::InputType::DeleteComposedCharacterBackward, 31 {InputEvent::InputType::DeleteComposedCharacterBackward,
32 "deleteComposedCharacterBackward"}, 32 "deleteComposedCharacterBackward"},
33 {InputEvent::InputType::DeleteWordBackward, "deleteWordBackward"}, 33 {InputEvent::InputType::DeleteWordBackward, "deleteWordBackward"},
34 {InputEvent::InputType::DeleteWordForward, "deleteWordForward"}, 34 {InputEvent::InputType::DeleteWordForward, "deleteWordForward"},
35 {InputEvent::InputType::DeleteLineBackward, "deleteLineBackward"}, 35 {InputEvent::InputType::DeleteSoftLineBackward, "deleteSoftLineBackward"},
36 {InputEvent::InputType::DeleteLineForward, "deleteLineForward"}, 36 {InputEvent::InputType::DeleteSoftLineBackward, "deleteSoftLineForward"},
37 {InputEvent::InputType::DeleteContent, "deleteContent"},
37 {InputEvent::InputType::DeleteContentBackward, "deleteContentBackward"}, 38 {InputEvent::InputType::DeleteContentBackward, "deleteContentBackward"},
38 {InputEvent::InputType::DeleteContentForward, "deleteContentForward"}, 39 {InputEvent::InputType::DeleteContentForward, "deleteContentForward"},
39 {InputEvent::InputType::DeleteByCut, "deleteByCut"}, 40 {InputEvent::InputType::DeleteByCut, "deleteByCut"},
40 {InputEvent::InputType::DeleteByDrag, "deleteByDrag"}, 41 {InputEvent::InputType::DeleteByDrag, "deleteByDrag"},
41 {InputEvent::InputType::HistoryUndo, "historyUndo"}, 42 {InputEvent::InputType::HistoryUndo, "historyUndo"},
42 {InputEvent::InputType::HistoryRedo, "historyRedo"}, 43 {InputEvent::InputType::HistoryRedo, "historyRedo"},
43 {InputEvent::InputType::FormatBold, "formatBold"}, 44 {InputEvent::InputType::FormatBold, "formatBold"},
44 {InputEvent::InputType::FormatItalic, "formatItalic"}, 45 {InputEvent::InputType::FormatItalic, "formatItalic"},
45 {InputEvent::InputType::FormatUnderline, "formatUnderline"}, 46 {InputEvent::InputType::FormatUnderline, "formatUnderline"},
46 {InputEvent::InputType::FormatStrikeThrough, "formatStrikeThrough"}, 47 {InputEvent::InputType::FormatStrikeThrough, "formatStrikeThrough"},
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 inputEventInit.setIsComposing(isComposing == IsComposing); 138 inputEventInit.setIsComposing(isComposing == IsComposing);
138 if (ranges) 139 if (ranges)
139 inputEventInit.setRanges(*ranges); 140 inputEventInit.setRanges(*ranges);
140 inputEventInit.setComposed(true); 141 inputEventInit.setComposed(true);
141 return InputEvent::create(EventTypeNames::beforeinput, inputEventInit); 142 return InputEvent::create(EventTypeNames::beforeinput, inputEventInit);
142 } 143 }
143 144
144 /* static */ 145 /* static */
145 InputEvent* InputEvent::createInput(InputType inputType, 146 InputEvent* InputEvent::createInput(InputType inputType,
146 const String& data, 147 const String& data,
147 EventIsComposing isComposing, 148 EventIsComposing isComposing) {
148 const RangeVector* ranges) {
149 InputEventInit inputEventInit; 149 InputEventInit inputEventInit;
150 150
151 inputEventInit.setBubbles(true); 151 inputEventInit.setBubbles(true);
152 inputEventInit.setCancelable(false); 152 inputEventInit.setCancelable(false);
153 // TODO(ojan): We should find a way to prevent conversion like 153 // TODO(ojan): We should find a way to prevent conversion like
154 // String->enum->String just in order to use initializer. 154 // String->enum->String just in order to use initializer.
155 // See InputEvent::InputEvent() for the second conversion. 155 // See InputEvent::InputEvent() for the second conversion.
156 inputEventInit.setInputType(convertInputTypeToString(inputType)); 156 inputEventInit.setInputType(convertInputTypeToString(inputType));
157 inputEventInit.setData(data); 157 inputEventInit.setData(data);
158 inputEventInit.setIsComposing(isComposing == IsComposing); 158 inputEventInit.setIsComposing(isComposing == IsComposing);
159 if (ranges)
160 inputEventInit.setRanges(*ranges);
161 inputEventInit.setComposed(true); 159 inputEventInit.setComposed(true);
162 return InputEvent::create(EventTypeNames::input, inputEventInit); 160 return InputEvent::create(EventTypeNames::input, inputEventInit);
163 } 161 }
164 162
165 String InputEvent::inputType() const { 163 String InputEvent::inputType() const {
166 return convertInputTypeToString(m_inputType); 164 return convertInputTypeToString(m_inputType);
167 } 165 }
168 166
169 StaticRangeVector InputEvent::getTargetRanges() const { 167 StaticRangeVector InputEvent::getTargetRanges() const {
170 StaticRangeVector staticRanges; 168 StaticRangeVector staticRanges;
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 // 3. We don't want authors to hold live |Range| indefinitely by holding 215 // 3. We don't want authors to hold live |Range| indefinitely by holding
218 // |InputEvent|, so we clear them after dispatch. 216 // |InputEvent|, so we clear them after dispatch.
219 // Authors should explicitly call |getTargetRanges()|->|toRange()| if they 217 // Authors should explicitly call |getTargetRanges()|->|toRange()| if they
220 // want to keep a copy of |Range|. See Editing TF meeting notes: 218 // want to keep a copy of |Range|. See Editing TF meeting notes:
221 // https://docs.google.com/document/d/1hCj6QX77NYIVY0RWrMHT1Yra6t8_Qu8PopaWLG0 AM58/edit?usp=sharing 219 // https://docs.google.com/document/d/1hCj6QX77NYIVY0RWrMHT1Yra6t8_Qu8PopaWLG0 AM58/edit?usp=sharing
222 event().m_ranges.clear(); 220 event().m_ranges.clear();
223 return result; 221 return result;
224 } 222 }
225 223
226 } // namespace blink 224 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698