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

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

Issue 2258663003: [InputEvent] Support |deleteByCut|&|insertFromPaste| with |dataTransfer| field (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: yosin's review2, fix nits Created 4 years, 3 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 // 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/clipboard/DataTransfer.h"
8 #include "core/dom/StaticRange.h" 9 #include "core/dom/StaticRange.h"
9 #include "core/events/InputEventInit.h" 10 #include "core/events/InputEventInit.h"
10 #include "core/events/UIEvent.h" 11 #include "core/events/UIEvent.h"
11 12
12 namespace blink { 13 namespace blink {
13 14
14 class InputEvent final : public UIEvent { 15 class InputEvent final : public UIEvent {
15 DEFINE_WRAPPERTYPEINFO(); 16 DEFINE_WRAPPERTYPEINFO();
16 17
17 public: 18 public:
18 static InputEvent* create(const AtomicString& type, const InputEventInit& in itializer) 19 static InputEvent* create(const AtomicString& type, const InputEventInit& in itializer)
19 { 20 {
20 return new InputEvent(type, initializer); 21 return new InputEvent(type, initializer);
21 } 22 }
22 23
23 enum class InputType { 24 enum class InputType {
24 None, 25 None,
25 // Insertion. 26 // Insertion.
26 InsertText, 27 InsertText,
27 InsertNonText, 28 InsertNonText,
28 InsertLineBreak, 29 InsertLineBreak,
29 InsertParagraph, 30 InsertParagraph,
30 InsertOrderedList, 31 InsertOrderedList,
31 InsertUnorderedList, 32 InsertUnorderedList,
32 InsertHorizontalRule, 33 InsertHorizontalRule,
34 InsertFromPaste,
33 // Deletion. 35 // Deletion.
34 DeleteComposedCharacterForward, 36 DeleteComposedCharacterForward,
35 DeleteComposedCharacterBackward, 37 DeleteComposedCharacterBackward,
36 DeleteWordBackward, 38 DeleteWordBackward,
37 DeleteWordForward, 39 DeleteWordForward,
38 DeleteLineBackward, 40 DeleteLineBackward,
39 DeleteLineForward, 41 DeleteLineForward,
40 DeleteContentBackward, 42 DeleteContentBackward,
41 DeleteContentForward, 43 DeleteContentForward,
44 DeleteByCut,
42 // Command. 45 // Command.
43 Undo, 46 Undo,
44 Redo, 47 Redo,
45 Copy,
46 Cut,
47 Paste,
48 // Styling. 48 // Styling.
49 Bold, 49 Bold,
50 Italic, 50 Italic,
51 Underline, 51 Underline,
52 StrikeThrough, 52 StrikeThrough,
53 Superscript, 53 Superscript,
54 Subscript, 54 Subscript,
55 // Formatting. 55 // Formatting.
56 JustifyCenter, 56 JustifyCenter,
57 JustifyRight, 57 JustifyRight,
(...skipping 23 matching lines...) Expand all
81 NotCancelable = false, 81 NotCancelable = false,
82 IsCancelable = true, 82 IsCancelable = true,
83 }; 83 };
84 84
85 enum EventIsComposing : bool { 85 enum EventIsComposing : bool {
86 NotComposing = false, 86 NotComposing = false,
87 IsComposing = true, 87 IsComposing = true,
88 }; 88 };
89 89
90 static InputEvent* createBeforeInput(InputType, const String& data, EventCan celable, EventIsComposing, const RangeVector*); 90 static InputEvent* createBeforeInput(InputType, const String& data, EventCan celable, EventIsComposing, const RangeVector*);
91 static InputEvent* createBeforeInput(InputType, DataTransfer*, EventCancelab le, EventIsComposing, const RangeVector*);
91 static InputEvent* createInput(InputType, const String& data, EventIsComposi ng, const RangeVector*); 92 static InputEvent* createInput(InputType, const String& data, EventIsComposi ng, const RangeVector*);
92 93
93 String inputType() const; 94 String inputType() const;
94 const String& data() const { return m_data; } 95 const String& data() const { return m_data; }
96 DataTransfer* dataTransfer() const { return m_dataTransfer.get(); }
95 bool isComposing() const { return m_isComposing; } 97 bool isComposing() const { return m_isComposing; }
96 // Returns a copy of target ranges during event dispatch, and returns an emp ty 98 // Returns a copy of target ranges during event dispatch, and returns an emp ty
97 // vector after dispatch. 99 // vector after dispatch.
98 StaticRangeVector getRanges() const; 100 StaticRangeVector getRanges() const;
99 101
100 bool isInputEvent() const override; 102 bool isInputEvent() const override;
101 103
102 EventDispatchMediator* createMediator() override; 104 EventDispatchMediator* createMediator() override;
103 105
104 DECLARE_VIRTUAL_TRACE(); 106 DECLARE_VIRTUAL_TRACE();
105 107
106 private: 108 private:
107 friend class InputEventDispatchMediator; 109 friend class InputEventDispatchMediator;
108 InputEvent(const AtomicString&, const InputEventInit&); 110 InputEvent(const AtomicString&, const InputEventInit&);
109 111
110 InputType m_inputType; 112 InputType m_inputType;
111 String m_data; 113 String m_data;
114 Member<DataTransfer> m_dataTransfer;
112 bool m_isComposing; 115 bool m_isComposing;
113 // We have to stored |Range| internally and only expose |StaticRange|, pleas e 116 // We have to stored |Range| internally and only expose |StaticRange|, pleas e
114 // see comments in |InputEventDispatchMediator::dispatchEvent()|. 117 // see comments in |InputEventDispatchMediator::dispatchEvent()|.
115 RangeVector m_ranges; 118 RangeVector m_ranges;
116 }; 119 };
117 120
118 class InputEventDispatchMediator final : public EventDispatchMediator { 121 class InputEventDispatchMediator final : public EventDispatchMediator {
119 public: 122 public:
120 static InputEventDispatchMediator* create(InputEvent*); 123 static InputEventDispatchMediator* create(InputEvent*);
121 124
122 private: 125 private:
123 explicit InputEventDispatchMediator(InputEvent*); 126 explicit InputEventDispatchMediator(InputEvent*);
124 InputEvent& event() const; 127 InputEvent& event() const;
125 DispatchEventResult dispatchEvent(EventDispatcher&) const override; 128 DispatchEventResult dispatchEvent(EventDispatcher&) const override;
126 }; 129 };
127 130
128 DEFINE_EVENT_TYPE_CASTS(InputEvent); 131 DEFINE_EVENT_TYPE_CASTS(InputEvent);
129 132
130 } // namespace blink 133 } // namespace blink
131 134
132 #endif // InputEvent_h 135 #endif // InputEvent_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698