OLD | NEW |
---|---|
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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
137 inputEventInit.setIsComposing(isComposing == IsComposing); | 137 inputEventInit.setIsComposing(isComposing == IsComposing); |
138 if (ranges) | 138 if (ranges) |
139 inputEventInit.setRanges(*ranges); | 139 inputEventInit.setRanges(*ranges); |
140 inputEventInit.setComposed(true); | 140 inputEventInit.setComposed(true); |
141 return InputEvent::create(EventTypeNames::beforeinput, inputEventInit); | 141 return InputEvent::create(EventTypeNames::beforeinput, inputEventInit); |
142 } | 142 } |
143 | 143 |
144 /* static */ | 144 /* static */ |
145 InputEvent* InputEvent::createInput(InputType inputType, | 145 InputEvent* InputEvent::createInput(InputType inputType, |
146 const String& data, | 146 const String& data, |
147 EventIsComposing isComposing, | 147 EventIsComposing isComposing) { |
148 const RangeVector* ranges) { | |
149 InputEventInit inputEventInit; | 148 InputEventInit inputEventInit; |
150 | 149 |
151 inputEventInit.setBubbles(true); | 150 inputEventInit.setBubbles(true); |
152 inputEventInit.setCancelable(false); | 151 inputEventInit.setCancelable(false); |
153 // TODO(ojan): We should find a way to prevent conversion like | 152 // TODO(ojan): We should find a way to prevent conversion like |
154 // String->enum->String just in order to use initializer. | 153 // String->enum->String just in order to use initializer. |
155 // See InputEvent::InputEvent() for the second conversion. | 154 // See InputEvent::InputEvent() for the second conversion. |
156 inputEventInit.setInputType(convertInputTypeToString(inputType)); | 155 inputEventInit.setInputType(convertInputTypeToString(inputType)); |
157 inputEventInit.setData(data); | 156 inputEventInit.setData(data); |
158 inputEventInit.setIsComposing(isComposing == IsComposing); | 157 inputEventInit.setIsComposing(isComposing == IsComposing); |
159 if (ranges) | |
160 inputEventInit.setRanges(*ranges); | |
chongz
2016/12/20 23:27:53
'input' event always has null target ranges.
| |
161 inputEventInit.setComposed(true); | 158 inputEventInit.setComposed(true); |
162 return InputEvent::create(EventTypeNames::input, inputEventInit); | 159 return InputEvent::create(EventTypeNames::input, inputEventInit); |
163 } | 160 } |
164 | 161 |
165 String InputEvent::inputType() const { | 162 String InputEvent::inputType() const { |
166 return convertInputTypeToString(m_inputType); | 163 return convertInputTypeToString(m_inputType); |
167 } | 164 } |
168 | 165 |
169 StaticRangeVector InputEvent::getTargetRanges() const { | 166 StaticRangeVector InputEvent::getTargetRanges() const { |
170 StaticRangeVector staticRanges; | 167 StaticRangeVector staticRanges; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
217 // 3. We don't want authors to hold live |Range| indefinitely by holding | 214 // 3. We don't want authors to hold live |Range| indefinitely by holding |
218 // |InputEvent|, so we clear them after dispatch. | 215 // |InputEvent|, so we clear them after dispatch. |
219 // Authors should explicitly call |getTargetRanges()|->|toRange()| if they | 216 // Authors should explicitly call |getTargetRanges()|->|toRange()| if they |
220 // want to keep a copy of |Range|. See Editing TF meeting notes: | 217 // 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 | 218 // https://docs.google.com/document/d/1hCj6QX77NYIVY0RWrMHT1Yra6t8_Qu8PopaWLG0 AM58/edit?usp=sharing |
222 event().m_ranges.clear(); | 219 event().m_ranges.clear(); |
223 return result; | 220 return result; |
224 } | 221 } |
225 | 222 |
226 } // namespace blink | 223 } // namespace blink |
OLD | NEW |