Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 | |
| OLD | NEW |