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 #ifndef InputEvent_h | 5 #ifndef InputEvent_h |
6 #define InputEvent_h | 6 #define InputEvent_h |
7 | 7 |
8 #include "core/events/InputEventInit.h" | 8 #include "core/events/InputEventInit.h" |
9 #include "core/events/UIEvent.h" | 9 #include "core/events/UIEvent.h" |
10 | 10 |
11 namespace blink { | 11 namespace blink { |
12 | 12 |
| 13 class Range; |
| 14 |
13 class InputEvent final : public UIEvent { | 15 class InputEvent final : public UIEvent { |
14 DEFINE_WRAPPERTYPEINFO(); | 16 DEFINE_WRAPPERTYPEINFO(); |
15 | 17 |
16 public: | 18 public: |
17 static InputEvent* create() | 19 static InputEvent* create() |
18 { | 20 { |
19 return new InputEvent; | 21 return new InputEvent; |
20 } | 22 } |
21 | 23 |
22 static InputEvent* create(const AtomicString& type, const InputEventInit& in
itializer) | 24 static InputEvent* create(const AtomicString& type, const InputEventInit& in
itializer) |
(...skipping 17 matching lines...) Expand all Loading... |
40 enum EventCancelable : bool { | 42 enum EventCancelable : bool { |
41 NotCancelable = false, | 43 NotCancelable = false, |
42 IsCancelable = true, | 44 IsCancelable = true, |
43 }; | 45 }; |
44 | 46 |
45 enum EventIsComposing : bool { | 47 enum EventIsComposing : bool { |
46 NotComposing = false, | 48 NotComposing = false, |
47 IsComposing = true, | 49 IsComposing = true, |
48 }; | 50 }; |
49 | 51 |
50 static InputEvent* createBeforeInput(InputType, const String& data, EventCan
celable, EventIsComposing); | 52 static InputEvent* createBeforeInput(InputType, const String& data, EventCan
celable, EventIsComposing, const RangeVector*); |
51 | 53 |
52 String inputType() const; | 54 String inputType() const; |
53 const String& data() const { return m_data; } | 55 const String& data() const { return m_data; } |
54 bool isComposing() const { return m_isComposing; } | 56 bool isComposing() const { return m_isComposing; } |
| 57 // Returns a copy of target ranges during event dispatch, and returns an emp
ty |
| 58 // vector after dispatch. |
| 59 // TODO(chongz): Return Vector<StaticRange>. |
| 60 HeapVector<Member<Range>> getRanges() const { return m_ranges; }; |
55 | 61 |
56 bool isInputEvent() const override; | 62 bool isInputEvent() const override; |
57 | 63 |
| 64 EventDispatchMediator* createMediator() override; |
| 65 |
58 DECLARE_VIRTUAL_TRACE(); | 66 DECLARE_VIRTUAL_TRACE(); |
59 | 67 |
60 private: | 68 private: |
| 69 friend class InputEventDispatchMediator; |
61 InputEvent(); | 70 InputEvent(); |
62 InputEvent(const AtomicString&, const InputEventInit&); | 71 InputEvent(const AtomicString&, const InputEventInit&); |
63 | 72 |
64 InputType m_inputType; | 73 InputType m_inputType; |
65 String m_data; | 74 String m_data; |
66 bool m_isComposing; | 75 bool m_isComposing; |
| 76 // We have to stored |Range| internally and only expose |StaticRange|, pleas
e |
| 77 // see comments in |InputEventDispatchMediator::dispatchEvent()|. |
| 78 RangeVector m_ranges; |
| 79 }; |
| 80 |
| 81 class InputEventDispatchMediator final : public EventDispatchMediator { |
| 82 public: |
| 83 static InputEventDispatchMediator* create(InputEvent*); |
| 84 |
| 85 private: |
| 86 explicit InputEventDispatchMediator(InputEvent*); |
| 87 InputEvent& event() const; |
| 88 DispatchEventResult dispatchEvent(EventDispatcher&) const override; |
67 }; | 89 }; |
68 | 90 |
69 DEFINE_EVENT_TYPE_CASTS(InputEvent); | 91 DEFINE_EVENT_TYPE_CASTS(InputEvent); |
70 | 92 |
71 } // namespace blink | 93 } // namespace blink |
72 | 94 |
73 #endif // InputEvent_h | 95 #endif // InputEvent_h |
OLD | NEW |