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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 inputEventInit.setRanges(*ranges); | 83 inputEventInit.setRanges(*ranges); |
84 | 84 |
85 return InputEvent::create(EventTypeNames::beforeinput, inputEventInit); | 85 return InputEvent::create(EventTypeNames::beforeinput, inputEventInit); |
86 } | 86 } |
87 | 87 |
88 String InputEvent::inputType() const | 88 String InputEvent::inputType() const |
89 { | 89 { |
90 return convertInputTypeToString(m_inputType); | 90 return convertInputTypeToString(m_inputType); |
91 } | 91 } |
92 | 92 |
| 93 StaticRangeVector InputEvent::getRanges() const |
| 94 { |
| 95 StaticRangeVector staticRanges; |
| 96 for (const auto& range : m_ranges) |
| 97 staticRanges.append(StaticRange::create(range->ownerDocument(), range->s
tartContainer(), range->startOffset(), range->endContainer(), range->endOffset()
)); |
| 98 return staticRanges; |
| 99 } |
| 100 |
93 bool InputEvent::isInputEvent() const | 101 bool InputEvent::isInputEvent() const |
94 { | 102 { |
95 return true; | 103 return true; |
96 } | 104 } |
97 | 105 |
98 // TODO(chongz): We should get rid of this |EventDispatchMediator| pattern and i
ntroduce | 106 // TODO(chongz): We should get rid of this |EventDispatchMediator| pattern and i
ntroduce |
99 // simpler interface such as |beforeDispatchEvent()| and |afterDispatchEvent()|
virtual methods. | 107 // simpler interface such as |beforeDispatchEvent()| and |afterDispatchEvent()|
virtual methods. |
100 EventDispatchMediator* InputEvent::createMediator() | 108 EventDispatchMediator* InputEvent::createMediator() |
101 { | 109 { |
102 return InputEventDispatchMediator::create(this); | 110 return InputEventDispatchMediator::create(this); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 // 3. We don't want authors to hold live |Range| indefinitely by holding |
InputEvent|, so we | 143 // 3. We don't want authors to hold live |Range| indefinitely by holding |
InputEvent|, so we |
136 // clear them after dispatch. | 144 // clear them after dispatch. |
137 // Authors should explicitly call |getRanges()|->|toRange()| if they want to
keep a copy of |Range|. | 145 // Authors should explicitly call |getRanges()|->|toRange()| if they want to
keep a copy of |Range|. |
138 // See Editing TF meeting notes: | 146 // See Editing TF meeting notes: |
139 // https://docs.google.com/document/d/1hCj6QX77NYIVY0RWrMHT1Yra6t8_Qu8PopaWL
G0AM58/edit?usp=sharing | 147 // https://docs.google.com/document/d/1hCj6QX77NYIVY0RWrMHT1Yra6t8_Qu8PopaWL
G0AM58/edit?usp=sharing |
140 event().m_ranges.clear(); | 148 event().m_ranges.clear(); |
141 return result; | 149 return result; |
142 } | 150 } |
143 | 151 |
144 } // namespace blink | 152 } // namespace blink |
OLD | NEW |