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

Side by Side Diff: ui/views/scoped_target_handler.cc

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 (nits 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
« no previous file with comments | « ui/views/scoped_target_handler.h ('k') | ui/views/view_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "ui/views/scoped_target_handler.h"
6
7 #include "ui/events/event.h"
8 #include "ui/events/event_handler.h"
9 #include "ui/events/event_target.h"
10 #include "ui/views/view.h"
11
12 namespace views {
13
14 ScopedTargetHandler::ScopedTargetHandler(View* view,
15 ui::EventHandler* handler)
16 : destroyed_flag_(NULL), view_(view), new_handler_(handler){
17 original_handler_ = view_->SetTargetHandler(this);
18 }
19
20 ScopedTargetHandler::~ScopedTargetHandler() {
21 EventHandler* handler = view_->SetTargetHandler(original_handler_);
22 DCHECK_EQ(this, handler);
23 if (destroyed_flag_)
24 *destroyed_flag_ = true;
25 }
26
27 void ScopedTargetHandler::OnEvent(ui::Event* event) {
28 bool destroyed = false;
29 destroyed_flag_ = &destroyed;
30
31 if (original_handler_)
32 original_handler_->OnEvent(event);
33 else
34 EventHandler::OnEvent(event);
35
36 if (destroyed)
37 return;
38 destroyed_flag_ = NULL;
39
40 new_handler_->OnEvent(event);
41 }
42
43 void ScopedTargetHandler::OnKeyEvent(ui::KeyEvent* event) {
44 static_cast<EventHandler*>(view_)->OnKeyEvent(event);
45 }
46
47 void ScopedTargetHandler::OnMouseEvent(ui::MouseEvent* event) {
48 static_cast<EventHandler*>(view_)->OnMouseEvent(event);
49 }
50
51 void ScopedTargetHandler::OnScrollEvent(ui::ScrollEvent* event) {
52 static_cast<EventHandler*>(view_)->OnScrollEvent(event);
53 }
54
55 void ScopedTargetHandler::OnTouchEvent(ui::TouchEvent* event) {
56 static_cast<EventHandler*>(view_)->OnTouchEvent(event);
57 }
58
59 void ScopedTargetHandler::OnGestureEvent(ui::GestureEvent* event) {
60 static_cast<EventHandler*>(view_)->OnGestureEvent(event);
61 }
62
63 void ScopedTargetHandler::OnCancelMode(ui::CancelModeEvent* event) {
64 static_cast<EventHandler*>(view_)->OnCancelMode(event);
65 }
66
67 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/scoped_target_handler.h ('k') | ui/views/view_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698