diff options
author | sadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-14 16:18:08 +0000 |
---|---|---|
committer | sadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-14 16:18:08 +0000 |
commit | 6f34b4836f777a3c325ded3256b313c030fc3568 (patch) | |
tree | eae5bf57b0b2fe311894d5da221fc254882d57b9 /ash | |
parent | 4d1e595f9c36f20be4aa2fee6e15a95c650a72a9 (diff) | |
download | chromium_src-6f34b4836f777a3c325ded3256b313c030fc3568.zip chromium_src-6f34b4836f777a3c325ded3256b313c030fc3568.tar.gz chromium_src-6f34b4836f777a3c325ded3256b313c030fc3568.tar.bz2 |
events: Update scroll and touch handlers to not return EventResult.
BUG=163618
Review URL: https://codereview.chromium.org/11568006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@173166 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
23 files changed, 53 insertions, 67 deletions
diff --git a/ash/drag_drop/drag_drop_controller.cc b/ash/drag_drop/drag_drop_controller.cc index 4248099..f3d0343 100644 --- a/ash/drag_drop/drag_drop_controller.cc +++ b/ash/drag_drop/drag_drop_controller.cc @@ -325,23 +325,20 @@ ui::EventResult DragDropController::OnMouseEvent(ui::MouseEvent* event) { return ui::ER_CONSUMED; } -ui::EventResult DragDropController::OnTouchEvent(ui::TouchEvent* event) { +void DragDropController::OnTouchEvent(ui::TouchEvent* event) { if (!IsDragDropInProgress()) - return ui::ER_UNHANDLED; + return; // If current drag session was not started by touch, dont process this touch // event, but consume it so it does not interfere with current drag session. if (current_drag_event_source_ != ui::DragDropTypes::DRAG_EVENT_SOURCE_TOUCH) - return ui::ER_CONSUMED; + event->StopPropagation(); - switch (event->type()) { - case ui::ET_TOUCH_CANCELLED: - DragCancel(); - break; - default: - break; - } - return ui::ER_UNHANDLED; + if (event->handled()) + return; + + if (event->type() == ui::ET_TOUCH_CANCELLED) + DragCancel(); } void DragDropController::OnGestureEvent(ui::GestureEvent* event) { diff --git a/ash/drag_drop/drag_drop_controller.h b/ash/drag_drop/drag_drop_controller.h index 6fe58a1..bef79a0 100644 --- a/ash/drag_drop/drag_drop_controller.h +++ b/ash/drag_drop/drag_drop_controller.h @@ -67,7 +67,7 @@ class ASH_EXPORT DragDropController // Overridden from ui::EventHandler: virtual ui::EventResult OnKeyEvent(ui::KeyEvent* event) OVERRIDE; virtual ui::EventResult OnMouseEvent(ui::MouseEvent* event) OVERRIDE; - virtual ui::EventResult OnTouchEvent(ui::TouchEvent* event) OVERRIDE; + virtual void OnTouchEvent(ui::TouchEvent* event) OVERRIDE; virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; // Overridden from aura::WindowObserver. diff --git a/ash/launcher/launcher_tooltip_manager.cc b/ash/launcher/launcher_tooltip_manager.cc index f99e552..dfc2a4b 100644 --- a/ash/launcher/launcher_tooltip_manager.cc +++ b/ash/launcher/launcher_tooltip_manager.cc @@ -278,11 +278,10 @@ ui::EventResult LauncherTooltipManager::OnMouseEvent(ui::MouseEvent* event) { return ui::ER_UNHANDLED; } -ui::EventResult LauncherTooltipManager::OnTouchEvent(ui::TouchEvent* event) { +void LauncherTooltipManager::OnTouchEvent(ui::TouchEvent* event) { aura::Window* target = static_cast<aura::Window*>(event->target()); if (widget_ && widget_->IsVisible() && widget_->GetNativeWindow() != target) Close(); - return ui::ER_UNHANDLED; } void LauncherTooltipManager::OnGestureEvent(ui::GestureEvent* event) { diff --git a/ash/launcher/launcher_tooltip_manager.h b/ash/launcher/launcher_tooltip_manager.h index 8bb764f..a4e28c5 100644 --- a/ash/launcher/launcher_tooltip_manager.h +++ b/ash/launcher/launcher_tooltip_manager.h @@ -77,7 +77,7 @@ class ASH_EXPORT LauncherTooltipManager : public ui::EventHandler, protected: // ui::EventHandler overrides: virtual ui::EventResult OnMouseEvent(ui::MouseEvent* event) OVERRIDE; - virtual ui::EventResult OnTouchEvent(ui::TouchEvent* event) OVERRIDE; + virtual void OnTouchEvent(ui::TouchEvent* event) OVERRIDE; virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; // SessionStateObserver override: diff --git a/ash/launcher/launcher_tooltip_manager_unittest.cc b/ash/launcher/launcher_tooltip_manager_unittest.cc index c6d81dd..e1464da 100644 --- a/ash/launcher/launcher_tooltip_manager_unittest.cc +++ b/ash/launcher/launcher_tooltip_manager_unittest.cc @@ -164,16 +164,16 @@ TEST_F(LauncherTooltipManagerTest, ShouldHideForEvents) { ui::TouchEvent touch_event( ui::ET_TOUCH_PRESSED, gfx::Point(), 0, base::TimeDelta()); SetEventTarget(root_window, &touch_event); - EXPECT_EQ(ui::ER_UNHANDLED, - event_handler->OnTouchEvent(&touch_event)); + event_handler->OnTouchEvent(&touch_event); + EXPECT_FALSE(touch_event.handled()); EXPECT_FALSE(TooltipIsVisible()); // Shouldn't hide if the touch happens on the tooltip. ShowImmediately(); views::Widget* tooltip_widget = GetTooltipWidget(); SetEventTarget(tooltip_widget->GetNativeWindow(), &touch_event); - EXPECT_EQ(ui::ER_UNHANDLED, - event_handler->OnTouchEvent(&touch_event)); + event_handler->OnTouchEvent(&touch_event); + EXPECT_FALSE(touch_event.handled()); EXPECT_TRUE(TooltipIsVisible()); // Should hide for gesture events. diff --git a/ash/launcher/overflow_bubble.cc b/ash/launcher/overflow_bubble.cc index d2f889e..06a0f52 100644 --- a/ash/launcher/overflow_bubble.cc +++ b/ash/launcher/overflow_bubble.cc @@ -74,7 +74,7 @@ class OverflowBubbleView : public views::BubbleDelegateView { virtual bool OnMouseWheel(const ui::MouseWheelEvent& event) OVERRIDE; // ui::EventHandler overrides: - virtual ui::EventResult OnScrollEvent(ui::ScrollEvent* event) OVERRIDE; + virtual void OnScrollEvent(ui::ScrollEvent* event) OVERRIDE; // views::BubbleDelegate overrides: virtual gfx::Rect GetBubbleBounds() OVERRIDE; @@ -185,11 +185,11 @@ bool OverflowBubbleView::OnMouseWheel(const ui::MouseWheelEvent& event) { return true; } -ui::EventResult OverflowBubbleView::OnScrollEvent(ui::ScrollEvent* event) { +void OverflowBubbleView::OnScrollEvent(ui::ScrollEvent* event) { ScrollByXOffset(-event->x_offset()); ScrollByYOffset(-event->y_offset()); Layout(); - return ui::ER_HANDLED; + event->SetHandled(); } gfx::Rect OverflowBubbleView::GetBubbleBounds() { diff --git a/ash/magnifier/magnification_controller.cc b/ash/magnifier/magnification_controller.cc index b7e90c1..0912e37 100644 --- a/ash/magnifier/magnification_controller.cc +++ b/ash/magnifier/magnification_controller.cc @@ -115,7 +115,7 @@ class MagnificationControllerImpl : virtual public MagnificationController, // ui::EventHandler overrides: virtual ui::EventResult OnMouseEvent(ui::MouseEvent* event) OVERRIDE; - virtual ui::EventResult OnScrollEvent(ui::ScrollEvent* event) OVERRIDE; + virtual void OnScrollEvent(ui::ScrollEvent* event) OVERRIDE; aura::RootWindow* root_window_; @@ -506,12 +506,13 @@ ui::EventResult MagnificationControllerImpl::OnMouseEvent( return ui::ER_UNHANDLED; } -ui::EventResult MagnificationControllerImpl::OnScrollEvent( +void MagnificationControllerImpl::OnScrollEvent( ui::ScrollEvent* event) { if (event->IsAltDown() && event->IsControlDown()) { if (event->type() == ui::ET_SCROLL_FLING_START || event->type() == ui::ET_SCROLL_FLING_CANCEL) { - return ui::ER_CONSUMED; + event->StopPropagation(); + return; } if (event->type() == ui::ET_SCROLL) { @@ -519,11 +520,10 @@ ui::EventResult MagnificationControllerImpl::OnScrollEvent( float scale = GetScale(); scale += scroll_event->y_offset() * kScrollScaleChangeFactor; SetScale(scale, true); - return ui::ER_CONSUMED; + event->StopPropagation(); + return; } } - - return ui::ER_UNHANDLED; } //////////////////////////////////////////////////////////////////////////////// diff --git a/ash/system/tray/tray_event_filter.cc b/ash/system/tray/tray_event_filter.cc index 01a751b..e1a223c 100644 --- a/ash/system/tray/tray_event_filter.cc +++ b/ash/system/tray/tray_event_filter.cc @@ -36,12 +36,9 @@ ui::EventResult TrayEventFilter::OnMouseEvent(ui::MouseEvent* event) { return ui::ER_UNHANDLED; } -ui::EventResult TrayEventFilter::OnTouchEvent(ui::TouchEvent* event) { - if (event->type() == ui::ET_TOUCH_PRESSED && - ProcessLocatedEvent(event)) { - return ui::ER_CONSUMED; - } - return ui::ER_UNHANDLED; +void TrayEventFilter::OnTouchEvent(ui::TouchEvent* event) { + if (event->type() == ui::ET_TOUCH_PRESSED && ProcessLocatedEvent(event)) + event->StopPropagation(); } bool TrayEventFilter::ProcessLocatedEvent(ui::LocatedEvent* event) { diff --git a/ash/system/tray/tray_event_filter.h b/ash/system/tray/tray_event_filter.h index dd86f3b..65fec335 100644 --- a/ash/system/tray/tray_event_filter.h +++ b/ash/system/tray/tray_event_filter.h @@ -27,7 +27,7 @@ class TrayEventFilter : public ui::EventHandler { // Overridden from ui::EventHandler. virtual ui::EventResult OnMouseEvent(ui::MouseEvent* event) OVERRIDE; - virtual ui::EventResult OnTouchEvent(ui::TouchEvent* event) OVERRIDE; + virtual void OnTouchEvent(ui::TouchEvent* event) OVERRIDE; private: // Returns true if the event is handled. diff --git a/ash/tooltips/tooltip_controller.cc b/ash/tooltips/tooltip_controller.cc index 1639419dd..21dcab5 100644 --- a/ash/tooltips/tooltip_controller.cc +++ b/ash/tooltips/tooltip_controller.cc @@ -302,7 +302,7 @@ ui::EventResult TooltipController::OnMouseEvent(ui::MouseEvent* event) { return ui::ER_UNHANDLED; } -ui::EventResult TooltipController::OnTouchEvent(ui::TouchEvent* event) { +void TooltipController::OnTouchEvent(ui::TouchEvent* event) { // TODO(varunjain): need to properly implement tooltips for // touch events. // Hide the tooltip for touch events. @@ -311,7 +311,6 @@ ui::EventResult TooltipController::OnTouchEvent(ui::TouchEvent* event) { if (tooltip_window_) tooltip_window_->RemoveObserver(this); tooltip_window_ = NULL; - return ui::ER_UNHANDLED; } void TooltipController::OnSessionStateEvent( diff --git a/ash/tooltips/tooltip_controller.h b/ash/tooltips/tooltip_controller.h index dc21527..d07f181 100644 --- a/ash/tooltips/tooltip_controller.h +++ b/ash/tooltips/tooltip_controller.h @@ -46,7 +46,7 @@ class ASH_EXPORT TooltipController : public aura::client::TooltipClient, // Overridden from ui::EventHandler. virtual ui::EventResult OnKeyEvent(ui::KeyEvent* event) OVERRIDE; virtual ui::EventResult OnMouseEvent(ui::MouseEvent* event) OVERRIDE; - virtual ui::EventResult OnTouchEvent(ui::TouchEvent* event) OVERRIDE; + virtual void OnTouchEvent(ui::TouchEvent* event) OVERRIDE; // Overridden from SessionStateController. virtual void OnSessionStateEvent(SessionStateObserver::EventType event) diff --git a/ash/touch/touch_observer_hud.cc b/ash/touch/touch_observer_hud.cc index 22dc029..176e52f 100644 --- a/ash/touch/touch_observer_hud.cc +++ b/ash/touch/touch_observer_hud.cc @@ -182,9 +182,9 @@ void TouchObserverHUD::UpdateTouchPointLabel(int index) { touch_labels_[index]->SetText(UTF8ToUTF16(string)); } -ui::EventResult TouchObserverHUD::OnTouchEvent(ui::TouchEvent* event) { +void TouchObserverHUD::OnTouchEvent(ui::TouchEvent* event) { if (event->touch_id() >= kMaxTouchPoints) - return ui::ER_UNHANDLED; + return; if (event->type() != ui::ET_TOUCH_CANCELLED) touch_positions_[event->touch_id()] = event->root_location(); @@ -197,8 +197,6 @@ ui::EventResult TouchObserverHUD::OnTouchEvent(ui::TouchEvent* event) { UpdateTouchPointLabel(event->touch_id()); widget_->SetSize(widget_->GetContentsView()->GetPreferredSize()); - - return ui::ER_UNHANDLED; } void TouchObserverHUD::OnWidgetClosing(views::Widget* widget) { diff --git a/ash/touch/touch_observer_hud.h b/ash/touch/touch_observer_hud.h index 03c1bac..acee910 100644 --- a/ash/touch/touch_observer_hud.h +++ b/ash/touch/touch_observer_hud.h @@ -35,7 +35,7 @@ class TouchObserverHUD : public ui::EventHandler, void UpdateTouchPointLabel(int index); // Overriden from ui::EventHandler: - virtual ui::EventResult OnTouchEvent(ui::TouchEvent* event) OVERRIDE; + virtual void OnTouchEvent(ui::TouchEvent* event) OVERRIDE; // Overridden from views::WidgetObserver: virtual void OnWidgetClosing(views::Widget* widget) OVERRIDE; diff --git a/ash/wm/activation_controller.cc b/ash/wm/activation_controller.cc index 274ab56..5544078 100644 --- a/ash/wm/activation_controller.cc +++ b/ash/wm/activation_controller.cc @@ -282,14 +282,12 @@ ui::EventResult ActivationController::OnMouseEvent(ui::MouseEvent* event) { return ui::ER_UNHANDLED; } -ui::EventResult ActivationController::OnScrollEvent(ui::ScrollEvent* event) { - return ui::ER_UNHANDLED; +void ActivationController::OnScrollEvent(ui::ScrollEvent* event) { } -ui::EventResult ActivationController::OnTouchEvent(ui::TouchEvent* event) { +void ActivationController::OnTouchEvent(ui::TouchEvent* event) { if (event->type() == ui::ET_TOUCH_PRESSED) FocusWindowWithEvent(event); - return ui::ER_UNHANDLED; } void ActivationController::OnGestureEvent(ui::GestureEvent* event) { diff --git a/ash/wm/activation_controller.h b/ash/wm/activation_controller.h index 24bf0508..23fe737 100644 --- a/ash/wm/activation_controller.h +++ b/ash/wm/activation_controller.h @@ -77,8 +77,8 @@ class ASH_EXPORT ActivationController // Overridden from ui::EventHandler: virtual ui::EventResult OnKeyEvent(ui::KeyEvent* event) OVERRIDE; virtual ui::EventResult OnMouseEvent(ui::MouseEvent* event) OVERRIDE; - virtual ui::EventResult OnScrollEvent(ui::ScrollEvent* event) OVERRIDE; - virtual ui::EventResult OnTouchEvent(ui::TouchEvent* event) OVERRIDE; + virtual void OnScrollEvent(ui::ScrollEvent* event) OVERRIDE; + virtual void OnTouchEvent(ui::TouchEvent* event) OVERRIDE; virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; // Implementation of ActivateWindow() with an Event. diff --git a/ash/wm/system_gesture_event_filter.cc b/ash/wm/system_gesture_event_filter.cc index 57aecd4..019cf53 100644 --- a/ash/wm/system_gesture_event_filter.cc +++ b/ash/wm/system_gesture_event_filter.cc @@ -65,11 +65,10 @@ ui::EventResult SystemGestureEventFilter::OnMouseEvent(ui::MouseEvent* event) { return ui::ER_UNHANDLED; } -ui::EventResult SystemGestureEventFilter::OnTouchEvent(ui::TouchEvent* event) { +void SystemGestureEventFilter::OnTouchEvent(ui::TouchEvent* event) { aura::Window* target = static_cast<aura::Window*>(event->target()); touch_uma_.RecordTouchEvent(target, *event); long_press_affordance_->ProcessEvent(target, event, event->touch_id()); - return ui::ER_UNHANDLED; } void SystemGestureEventFilter::OnGestureEvent(ui::GestureEvent* event) { diff --git a/ash/wm/system_gesture_event_filter.h b/ash/wm/system_gesture_event_filter.h index 961929e..984604d 100644 --- a/ash/wm/system_gesture_event_filter.h +++ b/ash/wm/system_gesture_event_filter.h @@ -46,7 +46,7 @@ class SystemGestureEventFilter : public ui::EventHandler, // Overridden from ui::EventHandler: virtual ui::EventResult OnMouseEvent(ui::MouseEvent* event) OVERRIDE; - virtual ui::EventResult OnTouchEvent(ui::TouchEvent* event) OVERRIDE; + virtual void OnTouchEvent(ui::TouchEvent* event) OVERRIDE; virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; // Overridden from aura::WindowObserver. diff --git a/ash/wm/user_activity_detector.cc b/ash/wm/user_activity_detector.cc index ee6a2b7..4338acc 100644 --- a/ash/wm/user_activity_detector.cc +++ b/ash/wm/user_activity_detector.cc @@ -48,14 +48,12 @@ ui::EventResult UserActivityDetector::OnMouseEvent(ui::MouseEvent* event) { return ui::ER_UNHANDLED; } -ui::EventResult UserActivityDetector::OnScrollEvent(ui::ScrollEvent* event) { +void UserActivityDetector::OnScrollEvent(ui::ScrollEvent* event) { MaybeNotify(); - return ui::ER_UNHANDLED; } -ui::EventResult UserActivityDetector::OnTouchEvent(ui::TouchEvent* event) { +void UserActivityDetector::OnTouchEvent(ui::TouchEvent* event) { MaybeNotify(); - return ui::ER_UNHANDLED; } void UserActivityDetector::OnGestureEvent(ui::GestureEvent* event) { diff --git a/ash/wm/user_activity_detector.h b/ash/wm/user_activity_detector.h index b28b9ec..89a2518 100644 --- a/ash/wm/user_activity_detector.h +++ b/ash/wm/user_activity_detector.h @@ -37,8 +37,8 @@ class ASH_EXPORT UserActivityDetector : public ui::EventHandler { // ui::EventHandler implementation. virtual ui::EventResult OnKeyEvent(ui::KeyEvent* event) OVERRIDE; virtual ui::EventResult OnMouseEvent(ui::MouseEvent* event) OVERRIDE; - virtual ui::EventResult OnScrollEvent(ui::ScrollEvent* event) OVERRIDE; - virtual ui::EventResult OnTouchEvent(ui::TouchEvent* event) OVERRIDE; + virtual void OnScrollEvent(ui::ScrollEvent* event) OVERRIDE; + virtual void OnTouchEvent(ui::TouchEvent* event) OVERRIDE; virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; private: diff --git a/ash/wm/user_activity_detector_unittest.cc b/ash/wm/user_activity_detector_unittest.cc index 2aa0ef5f..1e3105b 100644 --- a/ash/wm/user_activity_detector_unittest.cc +++ b/ash/wm/user_activity_detector_unittest.cc @@ -117,7 +117,8 @@ TEST_F(UserActivityDetectorTest, Basic) { ui::TouchEvent touch_event( ui::ET_TOUCH_PRESSED, gfx::Point(), 0, base::TimeDelta()); SetEventTarget(window.get(), &touch_event); - EXPECT_EQ(ui::ER_UNHANDLED, detector_->OnTouchEvent(&touch_event)); + detector_->OnTouchEvent(&touch_event); + EXPECT_FALSE(touch_event.handled()); EXPECT_EQ(1, observer_->num_invocations()); observer_->reset_stats(); diff --git a/ash/wm/window_modality_controller_unittest.cc b/ash/wm/window_modality_controller_unittest.cc index 94a647c..65927af 100644 --- a/ash/wm/window_modality_controller_unittest.cc +++ b/ash/wm/window_modality_controller_unittest.cc @@ -298,9 +298,9 @@ class TouchTrackerWindowDelegate : public aura::test::TestWindowDelegate { private: // Overridden from aura::test::TestWindowDelegate. - virtual ui::EventResult OnTouchEvent(ui::TouchEvent* event) OVERRIDE { + virtual void OnTouchEvent(ui::TouchEvent* event) OVERRIDE { received_touch_ = true; - return aura::test::TestWindowDelegate::OnTouchEvent(event); + aura::test::TestWindowDelegate::OnTouchEvent(event); } bool received_touch_; diff --git a/ash/wm/workspace/workspace_cycler.cc b/ash/wm/workspace/workspace_cycler.cc index 3e6878b..1080bb0 100644 --- a/ash/wm/workspace/workspace_cycler.cc +++ b/ash/wm/workspace/workspace_cycler.cc @@ -39,16 +39,16 @@ WorkspaceCycler::~WorkspaceCycler() { ash::Shell::GetInstance()->RemovePreTargetHandler(this); } -ui::EventResult WorkspaceCycler::OnScrollEvent(ui::ScrollEvent* event) { +void WorkspaceCycler::OnScrollEvent(ui::ScrollEvent* event) { if (event->finger_count() != 3 || event->type() != ui::ET_SCROLL) { scrubbing_ = false; - return ui::ER_UNHANDLED; + return; } if (!IsScrubbingEnabled()) { scrubbing_ = false; - return ui::ER_UNHANDLED; + return; } if (!scrubbing_) { @@ -73,7 +73,8 @@ ui::EventResult WorkspaceCycler::OnScrollEvent(ui::ScrollEvent* event) { scroll_x_ = 0; scroll_y_ = 0; - return ui::ER_HANDLED; + event->SetHandled(); + return; } if (std::abs(scroll_x_) > kWorkspaceStepSize) { @@ -86,7 +87,6 @@ ui::EventResult WorkspaceCycler::OnScrollEvent(ui::ScrollEvent* event) { } // The active workspace was not changed, do not consume the event. - return ui::ER_UNHANDLED; } } // namespace internal diff --git a/ash/wm/workspace/workspace_cycler.h b/ash/wm/workspace/workspace_cycler.h index e828006..032f54c 100644 --- a/ash/wm/workspace/workspace_cycler.h +++ b/ash/wm/workspace/workspace_cycler.h @@ -24,7 +24,7 @@ class ASH_EXPORT WorkspaceCycler : public ui::EventHandler { private: // ui::EventHandler overrides: - virtual ui::EventResult OnScrollEvent(ui::ScrollEvent* event) OVERRIDE; + virtual void OnScrollEvent(ui::ScrollEvent* event) OVERRIDE; WorkspaceManager* workspace_manager_; |