event_processor.h revision 5d1f7b1de12d16ceb2c938c56701a3e8bfa558f7
1a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)// Copyright 2013 The Chromium Authors. All rights reserved.
2a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
3a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)// found in the LICENSE file.
4a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)
5a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)#ifndef UI_EVENTS_EVENT_PROCESSOR_H_
6a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)#define UI_EVENTS_EVENT_PROCESSOR_H_
7a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)
8a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)#include "ui/events/event_dispatcher.h"
9a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)#include "ui/events/event_source.h"
10a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)
11a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)namespace ui {
12a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)
13a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)// EventProcessor receives an event from an EventSource and dispatches it to a
14a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)// tree of EventTargets.
15a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)class EVENTS_EXPORT EventProcessor : public EventDispatcherDelegate {
16a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) public:
17a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  virtual ~EventProcessor() {}
18a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)
19a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  // Returns the root of the tree this event processor owns.
20a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  virtual EventTarget* GetRootTarget() = 0;
21a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)
22a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  // Dispatches an event received from the EventSource to the tree of
23a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  // EventTargets (whose root is returned by GetRootTarget()).
24a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  virtual EventDispatchDetails OnEventFromSource(Event* event)
25a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)      WARN_UNUSED_RESULT;
265d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
275d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) protected:
285d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // Prepares the event so that it can be dispatched. This is invoked before
295d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // an EventTargeter is used to find the target of the event. So this can be
305d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // used to update the event so that the targeter can operate correctly (e.g.
315d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // it can be used to updated the location of the event when disptaching from
325d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // an EventSource in high-DPI).
335d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  virtual void PrepareEventForDispatch(Event* event);
34a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)};
35a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)
36a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)}  // namespace ui
37a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)
38a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)#endif  // UI_EVENTS_EVENT_PROCESSOR_H_
39