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

Side by Side Diff: ui/events/scoped_target_handler.h

Issue 1411833006: Refactoring to make adding ink drop animations easier (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Refactor ink drop animations (comments in ui/views/) Created 5 years 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
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef UI_EVENTS_SCOPED_TARGET_HANDLER_H_
6 #define UI_EVENTS_SCOPED_TARGET_HANDLER_H_
7
8 #include "base/macros.h"
9 #include "ui/events/event_handler.h"
10 #include "ui/events/events_export.h"
11
12 namespace ui {
13
14 class EventTarget;
15
16 // An EventHandler that replaces an EventTarget's target handler with itself
17 // to pass events to both the original handlers and an additional new
18 // EventHandler.
sadrul 2015/11/25 22:38:58 Document the ordering (i.e. whether the new handle
varkha 2015/11/26 00:05:46 Done.
19 class EVENTS_EXPORT ScopedTargetHandler : public EventHandler {
20 public:
21 ScopedTargetHandler(EventTarget* target, EventHandler* new_handler);
22 ~ScopedTargetHandler() override;
23
24 // ui::EventHandler:
25 void OnEvent(ui::Event* event) override;
26 void OnKeyEvent(ui::KeyEvent* event) override;
27 void OnMouseEvent(ui::MouseEvent* event) override;
28 void OnScrollEvent(ui::ScrollEvent* event) override;
29 void OnTouchEvent(ui::TouchEvent* event) override;
30 void OnGestureEvent(ui::GestureEvent* event) override;
31 void OnCancelMode(ui::CancelModeEvent* event) override;
32
33 private:
34 // If non-null the destructor sets this to true. This is set while handling
35 // an event and used to detect if |this| has been deleted.
36 bool* destroyed_flag_;
37
38 // An EventTarget that has its target handler replaced with |this| for a life
39 // time of |this|.
40 EventTarget* target_;
41
42 // An EventHandler that gets restored on |target_| when |this| is destroyed.
43 EventHandler* original_handler_;
44
45 // A new handler that gets events in addition to the |original_handler_| or
46 // |target_|.
47 EventHandler* new_handler_;
48
49 DISALLOW_COPY_AND_ASSIGN(ScopedTargetHandler);
50 };
51
52 } // namespace ui
53
54 #endif // UI_EVENTS_SCOPED_TARGET_HANDLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698