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

Side by Side Diff: ui/events/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 (moved ACTION_PENDING handling to toolbar_action_view for now) Created 5 years, 1 month 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 #include "ui/events/scoped_target_handler.h"
6
7 #include "ui/events/event.h"
8 #include "ui/events/event_target.h"
9
10 namespace ui {
11
12 ScopedTargetHandler::ScopedTargetHandler(EventTarget* target)
13 : target_(target) {
14 original_handler_ = target_->SetTargetHandler(this);
15 }
16
17 ScopedTargetHandler::~ScopedTargetHandler() {
18 EventHandler* handler = target_->SetTargetHandler(original_handler_);
19 DCHECK_EQ(this, handler);
20 }
21
22 void ScopedTargetHandler::OnEvent(ui::Event* event) {
23 // Dispatch to |target_| first and then to |original_handler_|.
24 EventHandler::OnEvent(event);
bruthig 2015/11/20 16:25:33 Don't we want the ToolbarActionView to handle the
varkha 2015/11/20 17:48:26 This is what happens with this code (inside EventH
bruthig 2015/11/20 18:56:27 Ah yes you're right, man that is hard to follow. I
varkha 2015/11/21 01:07:37 See if this way (using "has" instead of "is") make
25 if (original_handler_)
26 original_handler_->OnEvent(event);
27 }
28
29 void ScopedTargetHandler::OnKeyEvent(ui::KeyEvent* event) {
30 static_cast<EventHandler*>(target_)->OnKeyEvent(event);
bruthig 2015/11/20 16:25:33 Are these casts necessary? EventTarget extends Ev
varkha 2015/11/20 17:48:26 Yes they are even though yes it does. This is beca
bruthig 2015/11/20 18:56:27 I guess this begs the question, should the On*Even
varkha 2015/11/21 01:07:37 I think this prevents _random_ code from doing som
31 }
32
33 void ScopedTargetHandler::OnMouseEvent(ui::MouseEvent* event) {
34 static_cast<EventHandler*>(target_)->OnMouseEvent(event);
35 }
36
37 void ScopedTargetHandler::OnScrollEvent(ui::ScrollEvent* event) {
38 static_cast<EventHandler*>(target_)->OnScrollEvent(event);
39 }
40
41 void ScopedTargetHandler::OnTouchEvent(ui::TouchEvent* event) {
42 static_cast<EventHandler*>(target_)->OnTouchEvent(event);
43 }
44
45 void ScopedTargetHandler::OnGestureEvent(ui::GestureEvent* event) {
46 static_cast<EventHandler*>(target_)->OnGestureEvent(event);
47 }
48
49 void ScopedTargetHandler::OnCancelMode(ui::CancelModeEvent* event) {
50 static_cast<EventHandler*>(target_)->OnCancelMode(event);
51 }
52
53 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698