OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 UI_EVENTS_EVENT_PROCESSOR_H_ | 5 #ifndef UI_EVENTS_EVENT_PROCESSOR_H_ |
6 #define UI_EVENTS_EVENT_PROCESSOR_H_ | 6 #define UI_EVENTS_EVENT_PROCESSOR_H_ |
7 | 7 |
8 #include "ui/events/event_dispatcher.h" | 8 #include "ui/events/event_dispatcher.h" |
9 #include "ui/events/event_source.h" | 9 #include "ui/events/event_source.h" |
10 | 10 |
11 namespace ui { | 11 namespace ui { |
12 | 12 |
13 // EventProcessor receives an event from an EventSource and dispatches it to a | 13 // EventProcessor receives an event from an EventSource and dispatches it to a |
14 // tree of EventTargets. | 14 // tree of EventTargets. |
15 class EVENTS_EXPORT EventProcessor : public EventDispatcherDelegate { | 15 class EVENTS_EXPORT EventProcessor : public EventDispatcherDelegate { |
16 public: | 16 public: |
17 virtual ~EventProcessor() {} | 17 virtual ~EventProcessor() {} |
18 | 18 |
19 // Returns the root of the tree this event processor owns. | 19 // Returns the root of the tree this event processor owns. |
20 virtual EventTarget* GetRootTarget() = 0; | 20 virtual EventTarget* GetRootTarget() = 0; |
21 | 21 |
22 // Dispatches an event received from the EventSource to the tree of | 22 // Dispatches an event received from the EventSource to the tree of |
23 // EventTargets (whose root is returned by GetRootTarget()). The co-ordinate | 23 // EventTargets (whose root is returned by GetRootTarget()). The co-ordinate |
24 // space of the source must be the same as the root target, except that the | 24 // space of the source must be the same as the root target, except that the |
25 // target may have a high-dpi scale applied. | 25 // target may have a high-dpi scale applied. |
26 // TODO(tdanderson|sadrul): This is only virtual for testing purposes. It | |
27 // should not be virtual at all. | |
26 virtual EventDispatchDetails OnEventFromSource(Event* event) | 28 virtual EventDispatchDetails OnEventFromSource(Event* event) |
27 WARN_UNUSED_RESULT; | 29 WARN_UNUSED_RESULT; |
28 | 30 |
29 protected: | 31 protected: |
30 // Prepares the event so that it can be dispatched. This is invoked before | 32 // Returns true if the event should be processed and prepares the event |
31 // an EventTargeter is used to find the target of the event. So this can be | 33 // so that it can be dispatched. This is invoked before an EventTargeter |
32 // used to update the event so that the targeter can operate correctly (e.g. | 34 // is used to find the target of the event. So this can be used to update the |
33 // it can be used to updated the location of the event when disptaching from | 35 // event so that the targeter can operate correctly (e.g. it can be used to |
34 // an EventSource in high-DPI). | 36 // update the location of the event when disptaching from an EventSource in |
35 virtual void PrepareEventForDispatch(Event* event); | 37 // high-DPI). |
38 virtual bool OnEventProcessingStarted(Event* event); | |
sadrul
2014/09/15 14:10:36
I remember we briefly discussed making this not re
tdanderson
2014/09/15 18:20:26
Sorry, I actually don't remember discussing that o
| |
36 | 39 |
37 // Invoked when the processing of |event| has finished (i.e., when no further | 40 // Invoked when the processing of |event| has finished (i.e., when no further |
38 // dispatching of |event| will be performed by this EventProcessor). Note | 41 // dispatching of |event| will be performed by this EventProcessor). Note |
39 // that the last target to which |event| was dispatched may have been | 42 // that the last target to which |event| was dispatched may have been |
40 // destroyed. | 43 // destroyed. |
41 virtual void OnEventProcessingFinished(Event* event); | 44 virtual void OnEventProcessingFinished(Event* event); |
42 }; | 45 }; |
43 | 46 |
44 } // namespace ui | 47 } // namespace ui |
45 | 48 |
46 #endif // UI_EVENTS_EVENT_PROCESSOR_H_ | 49 #endif // UI_EVENTS_EVENT_PROCESSOR_H_ |
OLD | NEW |