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