Chromium Code Reviews| 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 class EventTargeter; | |
| 14 | |
| 13 // EventProcessor receives an event from an EventSource and dispatches it to a | 15 // EventProcessor receives an event from an EventSource and dispatches it to a |
| 14 // tree of EventTargets. | 16 // tree of EventTargets. |
| 15 class EVENTS_EXPORT EventProcessor : public EventDispatcherDelegate { | 17 class EVENTS_EXPORT EventProcessor : public EventDispatcherDelegate { |
| 16 public: | 18 public: |
| 17 ~EventProcessor() override {} | 19 ~EventProcessor() override {} |
| 18 | 20 |
| 19 // Returns the root of the tree this event processor owns. | 21 // Returns the EventTarget with the right EventTargeter that we should use for |
| 20 virtual EventTarget* GetRootTarget() = 0; | 22 // dispatching this |event|. |
| 23 virtual EventTarget* GetRootForEvent(Event* event) = 0; | |
| 24 | |
| 25 virtual EventTargeter* GetDefaultEventTargeter() = 0; | |
|
sadrul
2017/02/13 17:05:42
Document, e.g. "If the root target returned by Get
riajiang
2017/02/13 23:30:34
Done.
| |
| 21 | 26 |
| 22 // Dispatches an event received from the EventSource to the tree of | 27 // Dispatches an event received from the EventSource to the tree of |
| 23 // EventTargets (whose root is returned by GetRootTarget()). The co-ordinate | 28 // 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 | 29 // space of the source must be the same as the root target, except that the |
| 25 // target may have a high-dpi scale applied. | 30 // target may have a high-dpi scale applied. |
| 26 // TODO(tdanderson|sadrul): This is only virtual for testing purposes. It | 31 // TODO(tdanderson|sadrul): This is only virtual for testing purposes. It |
| 27 // should not be virtual at all. | 32 // should not be virtual at all. |
| 28 virtual EventDispatchDetails OnEventFromSource(Event* event) | 33 virtual EventDispatchDetails OnEventFromSource(Event* event) |
| 29 WARN_UNUSED_RESULT; | 34 WARN_UNUSED_RESULT; |
| 30 | 35 |
| 31 protected: | 36 protected: |
| 32 // Invoked at the start of processing, before an EventTargeter is used to | 37 // Invoked at the start of processing, before an EventTargeter is used to |
| 33 // find the target of the event. If processing should not take place, marks | 38 // find the target of the event. If processing should not take place, marks |
| 34 // |event| as handled. Otherwise updates |event| so that the targeter can | 39 // |event| as handled. Otherwise updates |event| so that the targeter can |
| 35 // operate correctly (e.g., it can be used to update the location of the | 40 // operate correctly (e.g., it can be used to update the location of the |
| 36 // event when dispatching from an EventSource in high-DPI) and updates any | 41 // event when dispatching from an EventSource in high-DPI) and updates any |
| 37 // members in the event processor as necessary. | 42 // members in the event processor as necessary. |
| 38 virtual void OnEventProcessingStarted(Event* event); | 43 virtual void OnEventProcessingStarted(Event* event); |
| 39 | 44 |
| 40 // Invoked when the processing of |event| has finished (i.e., when no further | 45 // Invoked when the processing of |event| has finished (i.e., when no further |
| 41 // dispatching of |event| will be performed by this EventProcessor). Note | 46 // dispatching of |event| will be performed by this EventProcessor). Note |
| 42 // that the last target to which |event| was dispatched may have been | 47 // that the last target to which |event| was dispatched may have been |
| 43 // destroyed. | 48 // destroyed. |
| 44 virtual void OnEventProcessingFinished(Event* event); | 49 virtual void OnEventProcessingFinished(Event* event); |
| 45 }; | 50 }; |
| 46 | 51 |
| 47 } // namespace ui | 52 } // namespace ui |
| 48 | 53 |
| 49 #endif // UI_EVENTS_EVENT_PROCESSOR_H_ | 54 #endif // UI_EVENTS_EVENT_PROCESSOR_H_ |
| OLD | NEW |