diff options
131 files changed, 401 insertions, 464 deletions
diff --git a/ash/drag_drop/drag_drop_controller.cc b/ash/drag_drop/drag_drop_controller.cc index db0e213..cf6135e 100644 --- a/ash/drag_drop/drag_drop_controller.cc +++ b/ash/drag_drop/drag_drop_controller.cc @@ -332,14 +332,17 @@ ui::EventResult DragDropController::OnTouchEvent(ui::TouchEvent* event) { return ui::ER_UNHANDLED; } -ui::EventResult DragDropController::OnGestureEvent(ui::GestureEvent* event) { +void DragDropController::OnGestureEvent(ui::GestureEvent* 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; + if (current_drag_event_source_ != + ui::DragDropTypes::DRAG_EVENT_SOURCE_TOUCH) { + event->StopPropagation(); + return; + } // Apply kTouchDragImageVerticalOffset to the location. ui::GestureEvent touch_offset_event(*event, @@ -356,7 +359,8 @@ ui::EventResult DragDropController::OnGestureEvent(ui::GestureEvent* event) { drag_drop_tracker_->GetTarget(touch_offset_event); if (!translated_target) { DragCancel(); - return ui::ER_HANDLED; + event->SetHandled(); + return; } scoped_ptr<ui::LocatedEvent> translated_event( drag_drop_tracker_->ConvertEvent(translated_target, touch_offset_event)); @@ -384,7 +388,7 @@ ui::EventResult DragDropController::OnGestureEvent(ui::GestureEvent* event) { default: break; } - return ui::ER_HANDLED; + event->SetHandled(); } void DragDropController::OnWindowDestroyed(aura::Window* window) { diff --git a/ash/drag_drop/drag_drop_controller.h b/ash/drag_drop/drag_drop_controller.h index f38b522..6fe58a1 100644 --- a/ash/drag_drop/drag_drop_controller.h +++ b/ash/drag_drop/drag_drop_controller.h @@ -68,7 +68,7 @@ class ASH_EXPORT DragDropController 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 ui::EventResult OnGestureEvent(ui::GestureEvent* event) OVERRIDE; + virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; // Overridden from aura::WindowObserver. virtual void OnWindowDestroyed(aura::Window* window) OVERRIDE; diff --git a/ash/drag_drop/drag_drop_controller_unittest.cc b/ash/drag_drop/drag_drop_controller_unittest.cc index 5847fdc..14a25c6 100644 --- a/ash/drag_drop/drag_drop_controller_unittest.cc +++ b/ash/drag_drop/drag_drop_controller_unittest.cc @@ -85,10 +85,10 @@ class DragTestView : public views::View { return true; } - ui::EventResult OnGestureEvent(ui::GestureEvent* event) OVERRIDE { + void OnGestureEvent(ui::GestureEvent* event) OVERRIDE { if (event->type() == ui::ET_GESTURE_LONG_TAP) long_tap_received_ = true; - return ui::ER_UNHANDLED; + return; } bool GetDropFormats(int* formats, diff --git a/ash/launcher/launcher_button.cc b/ash/launcher/launcher_button.cc index b4c4f9b..be5e381 100644 --- a/ash/launcher/launcher_button.cc +++ b/ash/launcher/launcher_button.cc @@ -304,7 +304,7 @@ void LauncherButton::OnBlur() { CustomButton::OnBlur(); } -ui::EventResult LauncherButton::OnGestureEvent(ui::GestureEvent* event) { +void LauncherButton::OnGestureEvent(ui::GestureEvent* event) { switch (event->type()) { case ui::ET_GESTURE_TAP_DOWN: AddState(STATE_HOVERED); @@ -314,14 +314,17 @@ ui::EventResult LauncherButton::OnGestureEvent(ui::GestureEvent* event) { return CustomButton::OnGestureEvent(event); case ui::ET_GESTURE_SCROLL_BEGIN: host_->PointerPressedOnButton(this, LauncherButtonHost::TOUCH, *event); - return ui::ER_CONSUMED; + event->SetHandled(); + return; case ui::ET_GESTURE_SCROLL_UPDATE: host_->PointerDraggedOnButton(this, LauncherButtonHost::TOUCH, *event); - return ui::ER_CONSUMED; + event->SetHandled(); + return; case ui::ET_GESTURE_SCROLL_END: case ui::ET_SCROLL_FLING_START: host_->PointerReleasedOnButton(this, LauncherButtonHost::TOUCH, false); - return ui::ER_CONSUMED; + event->SetHandled(); + return; default: return CustomButton::OnGestureEvent(event); } diff --git a/ash/launcher/launcher_button.h b/ash/launcher/launcher_button.h index f4c0755..c46b209 100644 --- a/ash/launcher/launcher_button.h +++ b/ash/launcher/launcher_button.h @@ -91,7 +91,7 @@ class LauncherButton : public views::CustomButton { virtual void OnBlur() OVERRIDE; // ui::EventHandler overrides: - virtual ui::EventResult OnGestureEvent(ui::GestureEvent* event) OVERRIDE; + virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; // Sets the icon image with a shadow. void SetShadowedImage(const gfx::ImageSkia& bitmap); diff --git a/ash/launcher/launcher_tooltip_manager.cc b/ash/launcher/launcher_tooltip_manager.cc index 4263bd6..05e8ccc 100644 --- a/ash/launcher/launcher_tooltip_manager.cc +++ b/ash/launcher/launcher_tooltip_manager.cc @@ -302,15 +302,12 @@ ui::EventResult LauncherTooltipManager::OnTouchEvent(ui::TouchEvent* event) { return ui::ER_UNHANDLED; } -ui::EventResult LauncherTooltipManager::OnGestureEvent( - ui::GestureEvent* event) { +void LauncherTooltipManager::OnGestureEvent(ui::GestureEvent* event) { if (widget_ && widget_->IsVisible()) { // Because this mouse event may arrive to |view_|, here we just schedule // the closing event rather than directly calling Close(). CloseSoon(); } - - return ui::ER_UNHANDLED; } void LauncherTooltipManager::OnSessionStateEvent( diff --git a/ash/launcher/launcher_tooltip_manager.h b/ash/launcher/launcher_tooltip_manager.h index 5bbab27..ee3395f 100644 --- a/ash/launcher/launcher_tooltip_manager.h +++ b/ash/launcher/launcher_tooltip_manager.h @@ -75,7 +75,7 @@ protected: // ui::EventHandler overrides: virtual ui::EventResult OnMouseEvent(ui::MouseEvent* event) OVERRIDE; virtual ui::EventResult OnTouchEvent(ui::TouchEvent* event) OVERRIDE; - virtual ui::EventResult OnGestureEvent(ui::GestureEvent* event) OVERRIDE; + virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; // SessionStateObserver override: virtual void OnSessionStateEvent(SessionStateObserver::EventType event) diff --git a/ash/launcher/launcher_tooltip_manager_unittest.cc b/ash/launcher/launcher_tooltip_manager_unittest.cc index 94b4c28..39ba6dc 100644 --- a/ash/launcher/launcher_tooltip_manager_unittest.cc +++ b/ash/launcher/launcher_tooltip_manager_unittest.cc @@ -184,8 +184,8 @@ TEST_F(LauncherTooltipManagerTest, ShouldHideForEvents) { base::TimeDelta::FromMilliseconds(base::Time::Now().ToDoubleT() * 1000), ui::GestureEventDetails(ui::ET_GESTURE_BEGIN, 0.0f, 0.0f), 0); SetEventTarget(tooltip_widget->GetNativeWindow(), &gesture_event); - EXPECT_EQ(ui::ER_UNHANDLED, - event_handler->OnGestureEvent(&gesture_event)); + event_handler->OnGestureEvent(&gesture_event); + EXPECT_FALSE(gesture_event.handled()); RunAllPendingInMessageLoop(); EXPECT_FALSE(TooltipIsVisible()); } diff --git a/ash/launcher/launcher_view.cc b/ash/launcher/launcher_view.cc index f51da7a..4148c87 100644 --- a/ash/launcher/launcher_view.cc +++ b/ash/launcher/launcher_view.cc @@ -788,9 +788,9 @@ views::FocusTraversable* LauncherView::GetPaneFocusTraversable() { return this; } -ui::EventResult LauncherView::OnGestureEvent(ui::GestureEvent* event) { - return gesture_handler_.ProcessGestureEvent(*event) ? - ui::ER_CONSUMED : ui::ER_UNHANDLED; +void LauncherView::OnGestureEvent(ui::GestureEvent* event) { + if (gesture_handler_.ProcessGestureEvent(*event)) + event->StopPropagation(); } void LauncherView::LauncherItemAdded(int model_index) { diff --git a/ash/launcher/launcher_view.h b/ash/launcher/launcher_view.h index ece7ba6..ff5fd6a 100644 --- a/ash/launcher/launcher_view.h +++ b/ash/launcher/launcher_view.h @@ -184,7 +184,7 @@ class ASH_EXPORT LauncherView : public views::View, virtual FocusTraversable* GetPaneFocusTraversable() OVERRIDE; // Overridden from ui::EventHandler: - virtual ui::EventResult OnGestureEvent(ui::GestureEvent* event) OVERRIDE; + virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; // Overridden from LauncherModelObserver: virtual void LauncherItemAdded(int model_index) OVERRIDE; diff --git a/ash/system/status_area_widget_delegate.cc b/ash/system/status_area_widget_delegate.cc index 94d6ea5..f82ec13 100644 --- a/ash/system/status_area_widget_delegate.cc +++ b/ash/system/status_area_widget_delegate.cc @@ -61,12 +61,11 @@ const views::Widget* StatusAreaWidgetDelegate::GetWidget() const { return View::GetWidget(); } -ui::EventResult StatusAreaWidgetDelegate::OnGestureEvent( - ui::GestureEvent* event) { +void StatusAreaWidgetDelegate::OnGestureEvent(ui::GestureEvent* event) { if (gesture_handler_.ProcessGestureEvent(*event)) - return ui::ER_CONSUMED; - - return views::AccessiblePaneView::OnGestureEvent(event); + event->StopPropagation(); + else + views::AccessiblePaneView::OnGestureEvent(event); } bool StatusAreaWidgetDelegate::CanActivate() const { diff --git a/ash/system/status_area_widget_delegate.h b/ash/system/status_area_widget_delegate.h index 7c56ff3..f924231 100644 --- a/ash/system/status_area_widget_delegate.h +++ b/ash/system/status_area_widget_delegate.h @@ -43,7 +43,7 @@ class ASH_EXPORT StatusAreaWidgetDelegate : public views::AccessiblePaneView, virtual const views::Widget* GetWidget() const OVERRIDE; // Overridden from ui::EventHandler: - virtual ui::EventResult OnGestureEvent(ui::GestureEvent* event) OVERRIDE; + virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; // views::WidgetDelegate overrides: virtual bool CanActivate() const OVERRIDE; diff --git a/ash/system/tray/tray_notification_view.cc b/ash/system/tray/tray_notification_view.cc index 2c4929b..1565fd7 100644 --- a/ash/system/tray/tray_notification_view.cc +++ b/ash/system/tray/tray_notification_view.cc @@ -124,13 +124,14 @@ bool TrayNotificationView::OnMousePressed(const ui::MouseEvent& event) { return true; } -ui::EventResult TrayNotificationView::OnGestureEvent(ui::GestureEvent* event) { - if (SlideOutView::OnGestureEvent(event) == ui::ER_CONSUMED) - return ui::ER_CONSUMED; +void TrayNotificationView::OnGestureEvent(ui::GestureEvent* event) { + SlideOutView::OnGestureEvent(event); + if (event->handled()) + return; if (event->type() != ui::ET_GESTURE_TAP) - return ui::ER_UNHANDLED; + return; HandleClickAction(); - return ui::ER_CONSUMED; + event->SetHandled(); } void TrayNotificationView::OnClose() { diff --git a/ash/system/tray/tray_notification_view.h b/ash/system/tray/tray_notification_view.h index 059e5c6..84ee9ac 100644 --- a/ash/system/tray/tray_notification_view.h +++ b/ash/system/tray/tray_notification_view.h @@ -59,7 +59,7 @@ class TrayNotificationView : public views::SlideOutView, virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE; // Overridden from ui::EventHandler. - virtual ui::EventResult OnGestureEvent(ui::GestureEvent* event) OVERRIDE; + virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; protected: // Called when the close button is pressed. Does nothing by default. diff --git a/ash/system/tray/tray_views.cc b/ash/system/tray/tray_views.cc index ca7e625..522ca71 100644 --- a/ash/system/tray/tray_views.cc +++ b/ash/system/tray/tray_views.cc @@ -182,12 +182,9 @@ void ActionableView::OnPaintFocusBorder(gfx::Canvas* canvas) { DrawBorder(canvas, GetLocalBounds()); } -ui::EventResult ActionableView::OnGestureEvent(ui::GestureEvent* event) { - if (event->type() == ui::ET_GESTURE_TAP) { - return PerformAction(*event) ? ui::ER_CONSUMED : - ui::ER_UNHANDLED; - } - return ui::ER_UNHANDLED; +void ActionableView::OnGestureEvent(ui::GestureEvent* event) { + if (event->type() == ui::ET_GESTURE_TAP && PerformAction(*event)) + event->SetHandled(); } void ActionableView::GetAccessibleState(ui::AccessibleViewState* state) { diff --git a/ash/system/tray/tray_views.h b/ash/system/tray/tray_views.h index 84e8d17..92be6dd 100644 --- a/ash/system/tray/tray_views.h +++ b/ash/system/tray/tray_views.h @@ -82,7 +82,7 @@ class ASH_EXPORT ActionableView : public views::View { virtual void OnPaintFocusBorder(gfx::Canvas* canvas) OVERRIDE; // Overridden from ui::EventHandler. - virtual ui::EventResult OnGestureEvent(ui::GestureEvent* event) OVERRIDE; + virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; private: string16 accessible_name_; diff --git a/ash/wm/activation_controller.cc b/ash/wm/activation_controller.cc index 0810d51..337979b 100644 --- a/ash/wm/activation_controller.cc +++ b/ash/wm/activation_controller.cc @@ -286,12 +286,11 @@ ui::EventResult ActivationController::OnTouchEvent(ui::TouchEvent* event) { return ui::ER_UNHANDLED; } -ui::EventResult ActivationController::OnGestureEvent(ui::GestureEvent* event) { +void ActivationController::OnGestureEvent(ui::GestureEvent* event) { if (event->type() == ui::ET_GESTURE_BEGIN && event->details().touch_points() == 1) { FocusWindowWithEvent(event); } - return ui::ER_UNHANDLED; } //////////////////////////////////////////////////////////////////////////////// diff --git a/ash/wm/activation_controller.h b/ash/wm/activation_controller.h index 3b439ab..6af15ed 100644 --- a/ash/wm/activation_controller.h +++ b/ash/wm/activation_controller.h @@ -77,7 +77,7 @@ class ASH_EXPORT ActivationController 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 ui::EventResult OnGestureEvent(ui::GestureEvent* event) OVERRIDE; + virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; // Implementation of ActivateWindow() with an Event. void ActivateWindowWithEvent(aura::Window* window, diff --git a/ash/wm/app_list_controller.cc b/ash/wm/app_list_controller.cc index 2abb2b9..e0785c8 100644 --- a/ash/wm/app_list_controller.cc +++ b/ash/wm/app_list_controller.cc @@ -253,10 +253,9 @@ ui::EventResult AppListController::OnMouseEvent(ui::MouseEvent* event) { return ui::ER_UNHANDLED; } -ui::EventResult AppListController::OnGestureEvent(ui::GestureEvent* event) { +void AppListController::OnGestureEvent(ui::GestureEvent* event) { if (event->type() == ui::ET_GESTURE_TAP) ProcessLocatedEvent(event); - return ui::ER_UNHANDLED; } //////////////////////////////////////////////////////////////////////////////// diff --git a/ash/wm/app_list_controller.h b/ash/wm/app_list_controller.h index 0446791..6f08a3f 100644 --- a/ash/wm/app_list_controller.h +++ b/ash/wm/app_list_controller.h @@ -76,7 +76,7 @@ class AppListController : public views::corewm::FocusChangeShim, // ui::EventHandler overrides: virtual ui::EventResult OnMouseEvent(ui::MouseEvent* event) OVERRIDE; - virtual ui::EventResult OnGestureEvent(ui::GestureEvent* event) OVERRIDE; + virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; // aura::client::FocusChangeObserver overrides: virtual void OnWindowFocused(aura::Window* window) OVERRIDE; diff --git a/ash/wm/system_gesture_event_filter.cc b/ash/wm/system_gesture_event_filter.cc index 5e40f93..57aecd4 100644 --- a/ash/wm/system_gesture_event_filter.cc +++ b/ash/wm/system_gesture_event_filter.cc @@ -72,8 +72,7 @@ ui::EventResult SystemGestureEventFilter::OnTouchEvent(ui::TouchEvent* event) { return ui::ER_UNHANDLED; } -ui::EventResult SystemGestureEventFilter::OnGestureEvent( - ui::GestureEvent* event) { +void SystemGestureEventFilter::OnGestureEvent(ui::GestureEvent* event) { aura::Window* target = static_cast<aura::Window*>(event->target()); touch_uma_.RecordGestureEvent(target, *event); long_press_affordance_->ProcessEvent(target, event, @@ -81,18 +80,21 @@ ui::EventResult SystemGestureEventFilter::OnGestureEvent( if (!target || target == target->GetRootWindow()) { bezel_gestures_->ProcessGestureEvent(target, *event); - return ui::ER_CONSUMED; + event->StopPropagation(); + return; } - if (two_finger_drag_->ProcessGestureEvent(target, *event)) - return ui::ER_CONSUMED; + if (two_finger_drag_->ProcessGestureEvent(target, *event)) { + event->StopPropagation(); + return; + } if (!system_gestures_enabled_) - return ui::ER_UNHANDLED; + return; aura::Window* system_target = GetTargetForSystemGestureEvent(target); if (!system_target) - return ui::ER_UNHANDLED; + return; RootWindowController* root_controller = GetRootWindowController(system_target->GetRootWindow()); @@ -108,9 +110,9 @@ ui::EventResult SystemGestureEventFilter::OnGestureEvent( ash::AcceleratorController* accelerator = ash::Shell::GetInstance()->accelerator_controller(); if (accelerator->PerformAction(CYCLE_FORWARD_MRU, ui::Accelerator())) - return ui::ER_CONSUMED; + event->StopPropagation(); } - return ui::ER_UNHANDLED; + return; } WindowPinchHandlerMap::iterator find = pinch_handlers_.find(system_target); @@ -119,18 +121,16 @@ ui::EventResult SystemGestureEventFilter::OnGestureEvent( (*find).second->ProcessGestureEvent(*event); if (status == SYSTEM_GESTURE_END) ClearGestureHandlerForWindow(system_target); - return ui::ER_CONSUMED; + event->StopPropagation(); } else { if (event->type() == ui::ET_GESTURE_BEGIN && event->details().touch_points() >= SystemPinchHandler::kSystemGesturePoints) { pinch_handlers_[system_target] = new SystemPinchHandler(system_target); system_target->AddObserver(this); - return ui::ER_CONSUMED; + event->StopPropagation(); } } - - return ui::ER_UNHANDLED; } void SystemGestureEventFilter::OnWindowVisibilityChanged(aura::Window* window, diff --git a/ash/wm/system_gesture_event_filter.h b/ash/wm/system_gesture_event_filter.h index 8d7843f..961929e 100644 --- a/ash/wm/system_gesture_event_filter.h +++ b/ash/wm/system_gesture_event_filter.h @@ -47,7 +47,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 ui::EventResult OnGestureEvent(ui::GestureEvent* event) OVERRIDE; + virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; // Overridden from aura::WindowObserver. virtual void OnWindowVisibilityChanged(aura::Window* window, diff --git a/ash/wm/toplevel_window_event_handler.cc b/ash/wm/toplevel_window_event_handler.cc index 4f5ad28..db7acb4 100644 --- a/ash/wm/toplevel_window_event_handler.cc +++ b/ash/wm/toplevel_window_event_handler.cc @@ -156,11 +156,10 @@ ui::EventResult ToplevelWindowEventHandler::OnMouseEvent( return ui::ER_UNHANDLED; } -ui::EventResult ToplevelWindowEventHandler::OnGestureEvent( - ui::GestureEvent* event) { +void ToplevelWindowEventHandler::OnGestureEvent(ui::GestureEvent* event) { aura::Window* target = static_cast<aura::Window*>(event->target()); if (!target->delegate()) - return ui::ER_UNHANDLED; + return; switch (event->type()) { case ui::ET_GESTURE_SCROLL_BEGIN: { @@ -168,7 +167,7 @@ ui::EventResult ToplevelWindowEventHandler::OnGestureEvent( target->delegate()->GetNonClientComponent(event->location()); if (WindowResizer::GetBoundsChangeForWindowComponent(component) == 0) { window_resizer_.reset(); - return ui::ER_UNHANDLED; + return; } in_gesture_drag_ = true; gfx::Point location_in_parent( @@ -178,14 +177,14 @@ ui::EventResult ToplevelWindowEventHandler::OnGestureEvent( } case ui::ET_GESTURE_SCROLL_UPDATE: { if (!in_gesture_drag_) - return ui::ER_UNHANDLED; + return; HandleDrag(target, event); break; } case ui::ET_GESTURE_SCROLL_END: case ui::ET_SCROLL_FLING_START: { if (!in_gesture_drag_) - return ui::ER_UNHANDLED; + return; CompleteDrag(DRAG_COMPLETE, event->flags()); if (in_move_loop_) { @@ -194,15 +193,17 @@ ui::EventResult ToplevelWindowEventHandler::OnGestureEvent( } in_gesture_drag_ = false; - if (event->type() == ui::ET_GESTURE_SCROLL_END) - return ui::ER_CONSUMED; + if (event->type() == ui::ET_GESTURE_SCROLL_END) { + event->StopPropagation(); + return; + } int component = target->delegate()->GetNonClientComponent(event->location()); if (WindowResizer::GetBoundsChangeForWindowComponent(component) == 0) - return ui::ER_UNHANDLED; + return; if (!wm::IsWindowNormal(target)) - return ui::ER_UNHANDLED; + return; if (fabs(event->details().velocity_y()) > kMinVertVelocityForWindowMinimize) { @@ -225,10 +226,10 @@ ui::EventResult ToplevelWindowEventHandler::OnGestureEvent( break; } default: - return ui::ER_UNHANDLED; + return; } - return ui::ER_CONSUMED; + event->StopPropagation(); } aura::client::WindowMoveResult ToplevelWindowEventHandler::RunMoveLoop( diff --git a/ash/wm/toplevel_window_event_handler.h b/ash/wm/toplevel_window_event_handler.h index dc2c6d5..7b1a0b5 100644 --- a/ash/wm/toplevel_window_event_handler.h +++ b/ash/wm/toplevel_window_event_handler.h @@ -40,7 +40,7 @@ class ASH_EXPORT ToplevelWindowEventHandler // Overridden from ui::EventHandler: virtual ui::EventResult OnKeyEvent(ui::KeyEvent* event) OVERRIDE; virtual ui::EventResult OnMouseEvent(ui::MouseEvent* event) OVERRIDE; - virtual ui::EventResult OnGestureEvent(ui::GestureEvent* event) OVERRIDE; + virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; // Overridden form aura::client::WindowMoveClient: virtual aura::client::WindowMoveResult RunMoveLoop( diff --git a/ash/wm/user_activity_detector.cc b/ash/wm/user_activity_detector.cc index f245d55..ee6a2b7 100644 --- a/ash/wm/user_activity_detector.cc +++ b/ash/wm/user_activity_detector.cc @@ -58,9 +58,8 @@ ui::EventResult UserActivityDetector::OnTouchEvent(ui::TouchEvent* event) { return ui::ER_UNHANDLED; } -ui::EventResult UserActivityDetector::OnGestureEvent(ui::GestureEvent* event) { +void UserActivityDetector::OnGestureEvent(ui::GestureEvent* event) { MaybeNotify(); - return ui::ER_UNHANDLED; } void UserActivityDetector::MaybeNotify() { diff --git a/ash/wm/user_activity_detector.h b/ash/wm/user_activity_detector.h index a555034..b28b9ec 100644 --- a/ash/wm/user_activity_detector.h +++ b/ash/wm/user_activity_detector.h @@ -39,7 +39,7 @@ class ASH_EXPORT UserActivityDetector : public ui::EventHandler { 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 ui::EventResult OnGestureEvent(ui::GestureEvent* event) OVERRIDE; + virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; private: // Notifies observers if enough time has passed since the last notification. diff --git a/ash/wm/user_activity_detector_unittest.cc b/ash/wm/user_activity_detector_unittest.cc index 14c48a1..2aa0ef5f 100644 --- a/ash/wm/user_activity_detector_unittest.cc +++ b/ash/wm/user_activity_detector_unittest.cc @@ -127,7 +127,8 @@ TEST_F(UserActivityDetectorTest, Basic) { base::TimeDelta::FromMilliseconds(base::Time::Now().ToDoubleT() * 1000), ui::GestureEventDetails(ui::ET_GESTURE_TAP, 0, 0), 0U); SetEventTarget(window.get(), &gesture_event); - EXPECT_FALSE(detector_->OnGestureEvent(&gesture_event)); + detector_->OnGestureEvent(&gesture_event); + EXPECT_FALSE(gesture_event.handled()); EXPECT_EQ(1, observer_->num_invocations()); observer_->reset_stats(); } diff --git a/ash/wm/workspace/frame_maximize_button.cc b/ash/wm/workspace/frame_maximize_button.cc index 2d2a57a..a1c8ca9 100644 --- a/ash/wm/workspace/frame_maximize_button.cc +++ b/ash/wm/workspace/frame_maximize_button.cc @@ -245,11 +245,12 @@ void FrameMaximizeButton::OnMouseCaptureLost() { ImageButton::OnMouseCaptureLost(); } -ui::EventResult FrameMaximizeButton::OnGestureEvent(ui::GestureEvent* event) { +void FrameMaximizeButton::OnGestureEvent(ui::GestureEvent* event) { if (event->type() == ui::ET_GESTURE_TAP_DOWN) { is_snap_enabled_ = true; ProcessStartEvent(*event); - return ui::ER_CONSUMED; + event->SetHandled(); + return; } if (event->type() == ui::ET_GESTURE_TAP || @@ -261,7 +262,8 @@ ui::EventResult FrameMaximizeButton::OnGestureEvent(ui::GestureEvent* event) { if (event->type() == ui::ET_GESTURE_TAP) snap_type_ = SnapTypeForLocation(event->location()); ProcessEndEvent(*event); - return ui::ER_CONSUMED; + event->SetHandled(); + return; } if (is_snap_enabled_) { @@ -272,17 +274,19 @@ ui::EventResult FrameMaximizeButton::OnGestureEvent(ui::GestureEvent* event) { ProcessUpdateEvent(*event); snap_type_ = SnapTypeForLocation(event->location()); ProcessEndEvent(*event); - return ui::ER_CONSUMED; + event->SetHandled(); + return; } if (event->type() == ui::ET_GESTURE_SCROLL_UPDATE || event->type() == ui::ET_GESTURE_SCROLL_BEGIN) { ProcessUpdateEvent(*event); - return ui::ER_CONSUMED; + event->SetHandled(); + return; } } - return ImageButton::OnGestureEvent(event); + ImageButton::OnGestureEvent(event); } void FrameMaximizeButton::ProcessStartEvent(const ui::LocatedEvent& event) { diff --git a/ash/wm/workspace/frame_maximize_button.h b/ash/wm/workspace/frame_maximize_button.h index 6179deb..2e76bbb 100644 --- a/ash/wm/workspace/frame_maximize_button.h +++ b/ash/wm/workspace/frame_maximize_button.h @@ -66,7 +66,7 @@ class ASH_EXPORT FrameMaximizeButton : public views::ImageButton, virtual void OnMouseCaptureLost() OVERRIDE; // ui::EventHandler overrides: - virtual ui::EventResult OnGestureEvent(ui::GestureEvent* event) OVERRIDE; + virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; // Unit test overwrite: Change the UI delay used for the bubble show up. void set_bubble_appearance_delay_ms(int bubble_appearance_delay_ms) { diff --git a/ash/wm/workspace/workspace_event_handler.cc b/ash/wm/workspace/workspace_event_handler.cc index 75626ff..929d09c 100644 --- a/ash/wm/workspace/workspace_event_handler.cc +++ b/ash/wm/workspace/workspace_event_handler.cc @@ -106,15 +106,16 @@ ui::EventResult WorkspaceEventHandler::OnMouseEvent(ui::MouseEvent* event) { return ToplevelWindowEventHandler::OnMouseEvent(event); } -ui::EventResult WorkspaceEventHandler::OnGestureEvent(ui::GestureEvent* event) { +void WorkspaceEventHandler::OnGestureEvent(ui::GestureEvent* event) { aura::Window* target = static_cast<aura::Window*>(event->target()); if (event->type() == ui::ET_GESTURE_DOUBLE_TAP && target->delegate()->GetNonClientComponent(event->location()) == HTCAPTION) { ToggleMaximizedState(target); // |this| may be destroyed from here. - return ui::ER_CONSUMED; + event->StopPropagation(); + return; } - return ToplevelWindowEventHandler::OnGestureEvent(event); + ToplevelWindowEventHandler::OnGestureEvent(event); } void WorkspaceEventHandler::HandleVerticalResizeDoubleClick( diff --git a/ash/wm/workspace/workspace_event_handler.h b/ash/wm/workspace/workspace_event_handler.h index 62da0bd..66e10d0 100644 --- a/ash/wm/workspace/workspace_event_handler.h +++ b/ash/wm/workspace/workspace_event_handler.h @@ -24,7 +24,7 @@ class WorkspaceEventHandler : public ToplevelWindowEventHandler { // Overridden from ToplevelWindowEventHandler: virtual ui::EventResult OnMouseEvent(ui::MouseEvent* event) OVERRIDE; - virtual ui::EventResult OnGestureEvent(ui::GestureEvent* event) OVERRIDE; + virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; private: friend class WorkspaceEventHandlerTestHelper; diff --git a/chrome/browser/ui/views/browser_action_view.cc b/chrome/browser/ui/views/browser_action_view.cc index dbf8278..65ce7ac 100644 --- a/chrome/browser/ui/views/browser_action_view.cc +++ b/chrome/browser/ui/views/browser_action_view.cc @@ -345,9 +345,11 @@ bool BrowserActionButton::OnKeyReleased(const ui::KeyEvent& event) { TextButton::OnKeyReleased(event); } -ui::EventResult BrowserActionButton::OnGestureEvent(ui::GestureEvent* event) { - return IsPopup() ? MenuButton::OnGestureEvent(event) : - TextButton::OnGestureEvent(event); +void BrowserActionButton::OnGestureEvent(ui::GestureEvent* event) { + if (IsPopup()) + MenuButton::OnGestureEvent(event); + else + TextButton::OnGestureEvent(event); } bool BrowserActionButton::AcceleratorPressed( diff --git a/chrome/browser/ui/views/browser_action_view.h b/chrome/browser/ui/views/browser_action_view.h index c1a175b..980eb8e 100644 --- a/chrome/browser/ui/views/browser_action_view.h +++ b/chrome/browser/ui/views/browser_action_view.h @@ -158,7 +158,7 @@ class BrowserActionButton : public views::MenuButton, virtual void OnMouseReleased(const ui::MouseEvent& event) OVERRIDE; virtual void OnMouseExited(const ui::MouseEvent& event) OVERRIDE; virtual bool OnKeyReleased(const ui::KeyEvent& event) OVERRIDE; - virtual ui::EventResult OnGestureEvent(ui::GestureEvent* event) OVERRIDE; + virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; // Overridden from ui::AcceleratorTarget. virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE; diff --git a/chrome/browser/ui/views/download/download_item_view.cc b/chrome/browser/ui/views/download/download_item_view.cc index bd5eefb..2fe55db 100644 --- a/chrome/browser/ui/views/download/download_item_view.cc +++ b/chrome/browser/ui/views/download/download_item_view.cc @@ -505,19 +505,21 @@ void DownloadItemView::OnThemeChanged() { UpdateColorsFromTheme(); } -ui::EventResult DownloadItemView::OnGestureEvent(ui::GestureEvent* event) { +void DownloadItemView::OnGestureEvent(ui::GestureEvent* event) { if (event->type() == ui::ET_GESTURE_TAP_DOWN) { HandlePressEvent(*event, true); - return ui::ER_CONSUMED; + event->SetHandled(); + return; } if (event->type() == ui::ET_GESTURE_TAP) { HandleClickEvent(*event, true); - return ui::ER_CONSUMED; + event->SetHandled(); + return; } SetState(NORMAL, NORMAL); - return views::View::OnGestureEvent(event); + views::View::OnGestureEvent(event); } void DownloadItemView::ShowContextMenuForView(View* source, diff --git a/chrome/browser/ui/views/download/download_item_view.h b/chrome/browser/ui/views/download/download_item_view.h index a45c4f9..f4d91b2 100644 --- a/chrome/browser/ui/views/download/download_item_view.h +++ b/chrome/browser/ui/views/download/download_item_view.h @@ -95,7 +95,7 @@ class DownloadItemView : public views::ButtonListener, virtual void OnThemeChanged() OVERRIDE; // Overridden from ui::EventHandler: - virtual ui::EventResult OnGestureEvent(ui::GestureEvent* event) OVERRIDE; + virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; // Overridden from views::ContextMenuController. virtual void ShowContextMenuForView(View* source, diff --git a/chrome/browser/ui/views/immersive_mode_controller.cc b/chrome/browser/ui/views/immersive_mode_controller.cc index c92e9a6..59bc7cf 100644 --- a/chrome/browser/ui/views/immersive_mode_controller.cc +++ b/chrome/browser/ui/views/immersive_mode_controller.cc @@ -164,10 +164,6 @@ void ImmersiveModeController::SetEnabled(bool enabled) { } // ui::EventHandler overrides: -ui::EventResult ImmersiveModeController::OnKeyEvent(ui::KeyEvent* event) { - return ui::ER_UNHANDLED; -} - ui::EventResult ImmersiveModeController::OnMouseEvent(ui::MouseEvent* event) { if (event->type() != ui::ET_MOUSE_MOVED) return ui::ER_UNHANDLED; @@ -186,19 +182,6 @@ ui::EventResult ImmersiveModeController::OnMouseEvent(ui::MouseEvent* event) { return ui::ER_UNHANDLED; } -ui::EventResult ImmersiveModeController::OnScrollEvent(ui::ScrollEvent* event) { - return ui::ER_UNHANDLED; -} - -ui::EventResult ImmersiveModeController::OnTouchEvent(ui::TouchEvent* event) { - return ui::ER_UNHANDLED; -} - -ui::EventResult ImmersiveModeController::OnGestureEvent( - ui::GestureEvent* event) { - return ui::ER_UNHANDLED; -} - // views::MouseWatcherListener overrides: void ImmersiveModeController::MouseMovedOutOfHost() { EndReveal(true); diff --git a/chrome/browser/ui/views/immersive_mode_controller.h b/chrome/browser/ui/views/immersive_mode_controller.h index 2544619..8fb989a 100644 --- a/chrome/browser/ui/views/immersive_mode_controller.h +++ b/chrome/browser/ui/views/immersive_mode_controller.h @@ -39,11 +39,7 @@ class ImmersiveModeController : public ui::EventHandler, bool IsRevealed() const { return enabled_ && revealed_; } // ui::EventHandler overrides: - 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 ui::EventResult OnGestureEvent(ui::GestureEvent* event) OVERRIDE; // ui::ImplicitAnimationObserver overrides: virtual void OnImplicitAnimationsCompleted() OVERRIDE; diff --git a/chrome/browser/ui/views/location_bar/ev_bubble_view.cc b/chrome/browser/ui/views/location_bar/ev_bubble_view.cc index 04a0122..5d651be 100644 --- a/chrome/browser/ui/views/location_bar/ev_bubble_view.cc +++ b/chrome/browser/ui/views/location_bar/ev_bubble_view.cc @@ -26,10 +26,9 @@ void EVBubbleView::OnMouseReleased(const ui::MouseEvent& event) { page_info_helper_.ProcessEvent(event); } -ui::EventResult EVBubbleView::OnGestureEvent(ui::GestureEvent* event) { +void EVBubbleView::OnGestureEvent(ui::GestureEvent* event) { if (event->type() == ui::ET_GESTURE_TAP) { page_info_helper_.ProcessEvent(*event); - return ui::ER_CONSUMED; + event->SetHandled(); } - return ui::ER_UNHANDLED; } diff --git a/chrome/browser/ui/views/location_bar/ev_bubble_view.h b/chrome/browser/ui/views/location_bar/ev_bubble_view.h index 6fca232..41633ec 100644 --- a/chrome/browser/ui/views/location_bar/ev_bubble_view.h +++ b/chrome/browser/ui/views/location_bar/ev_bubble_view.h @@ -28,7 +28,7 @@ class EVBubbleView : public IconLabelBubbleView { virtual void OnMouseReleased(const ui::MouseEvent& event) OVERRIDE; // Overridden from ui::EventHandler. - virtual ui::EventResult OnGestureEvent(ui::GestureEvent* event) OVERRIDE; + virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; private: PageInfoHelper page_info_helper_; diff --git a/chrome/browser/ui/views/location_bar/location_bar_decoration_view.cc b/chrome/browser/ui/views/location_bar/location_bar_decoration_view.cc index c6f6581..2aa0743 100644 --- a/chrome/browser/ui/views/location_bar/location_bar_decoration_view.cc +++ b/chrome/browser/ui/views/location_bar/location_bar_decoration_view.cc @@ -72,17 +72,14 @@ gfx::Size LocationBarDecorationView::GetPreferredSize() { return preferred_size; } -ui::EventResult LocationBarDecorationView::OnGestureEvent( - ui::GestureEvent* event) { +void LocationBarDecorationView::OnGestureEvent(ui::GestureEvent* event) { if (event->type() == ui::ET_GESTURE_TAP) { AnimationOnClick(); OnClick(parent_); - return ui::ER_CONSUMED; + event->SetHandled(); } else if (event->type() == ui::ET_GESTURE_TAP_DOWN) { - return ui::ER_CONSUMED; + event->SetHandled(); } - - return ui::ER_UNHANDLED; } void LocationBarDecorationView::AnimationEnded(const ui::Animation* animation) { diff --git a/chrome/browser/ui/views/location_bar/location_bar_decoration_view.h b/chrome/browser/ui/views/location_bar/location_bar_decoration_view.h index 9762941..0a5fda1 100644 --- a/chrome/browser/ui/views/location_bar/location_bar_decoration_view.h +++ b/chrome/browser/ui/views/location_bar/location_bar_decoration_view.h @@ -58,7 +58,7 @@ class LocationBarDecorationView : public views::View, virtual gfx::Size GetPreferredSize() OVERRIDE; // ui::EventHandler overrides: - virtual ui::EventResult OnGestureEvent(ui::GestureEvent* event) OVERRIDE; + virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; // ui::AnimationDelegate overrides: virtual void AnimationEnded(const ui::Animation* animation) OVERRIDE; diff --git a/chrome/browser/ui/views/location_bar/location_icon_view.cc b/chrome/browser/ui/views/location_bar/location_icon_view.cc index e9b4fda..d4986c5 100644 --- a/chrome/browser/ui/views/location_bar/location_icon_view.cc +++ b/chrome/browser/ui/views/location_bar/location_icon_view.cc @@ -27,12 +27,11 @@ void LocationIconView::OnMouseReleased(const ui::MouseEvent& event) { page_info_helper_.ProcessEvent(event); } -ui::EventResult LocationIconView::OnGestureEvent(ui::GestureEvent* event) { +void LocationIconView::OnGestureEvent(ui::GestureEvent* event) { if (event->type() == ui::ET_GESTURE_TAP) { page_info_helper_.ProcessEvent(*event); - return ui::ER_CONSUMED; + event->SetHandled(); } - return ui::ER_UNHANDLED; } int LocationIconView::GetBuiltInHorizontalPadding() const { diff --git a/chrome/browser/ui/views/location_bar/location_icon_view.h b/chrome/browser/ui/views/location_bar/location_icon_view.h index 8753c35..85c3790d 100644 --- a/chrome/browser/ui/views/location_bar/location_icon_view.h +++ b/chrome/browser/ui/views/location_bar/location_icon_view.h @@ -29,7 +29,7 @@ class LocationIconView virtual void OnMouseReleased(const ui::MouseEvent& event) OVERRIDE; // Overridden from ui::EventHandler: - virtual ui::EventResult OnGestureEvent(ui::GestureEvent* event) OVERRIDE; + virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; // TouchableLocationBarView. virtual int GetBuiltInHorizontalPadding() const OVERRIDE; diff --git a/chrome/browser/ui/views/location_bar/script_bubble_icon_view.cc b/chrome/browser/ui/views/location_bar/script_bubble_icon_view.cc index e5679c8..c6cddca 100644 --- a/chrome/browser/ui/views/location_bar/script_bubble_icon_view.cc +++ b/chrome/browser/ui/views/location_bar/script_bubble_icon_view.cc @@ -84,12 +84,11 @@ bool ScriptBubbleIconView::OnKeyPressed(const ui::KeyEvent& event) { return false; } -ui::EventResult ScriptBubbleIconView::OnGestureEvent(ui::GestureEvent* event) { +void ScriptBubbleIconView::OnGestureEvent(ui::GestureEvent* event) { if (event->type() == ui::ET_GESTURE_TAP) { ShowScriptBubble(this, location_bar_delegate_->GetWebContents()); - return ui::ER_CONSUMED; + event->SetHandled(); } - return ui::ER_UNHANDLED; } void ScriptBubbleIconView::ShowScriptBubble(views::View* anchor_view, diff --git a/chrome/browser/ui/views/location_bar/script_bubble_icon_view.h b/chrome/browser/ui/views/location_bar/script_bubble_icon_view.h index da28753..404f0e9 100644 --- a/chrome/browser/ui/views/location_bar/script_bubble_icon_view.h +++ b/chrome/browser/ui/views/location_bar/script_bubble_icon_view.h @@ -42,7 +42,7 @@ class ScriptBubbleIconView : public views::ImageView, virtual bool OnKeyPressed(const ui::KeyEvent& event) OVERRIDE; // ui::EventHandler overrides: - virtual ui::EventResult OnGestureEvent(ui::GestureEvent* event) OVERRIDE; + virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; // Shows the script bubble, anchored to anchor_view. void ShowScriptBubble(views::View* anchor_view, diff --git a/chrome/browser/ui/views/location_bar/star_view.cc b/chrome/browser/ui/views/location_bar/star_view.cc index 8f65c1a..72814b8 100644 --- a/chrome/browser/ui/views/location_bar/star_view.cc +++ b/chrome/browser/ui/views/location_bar/star_view.cc @@ -80,13 +80,12 @@ bool StarView::OnKeyPressed(const ui::KeyEvent& event) { return false; } -ui::EventResult StarView::OnGestureEvent(ui::GestureEvent* event) { +void StarView::OnGestureEvent(ui::GestureEvent* event) { if (event->type() == ui::ET_GESTURE_TAP) { UMA_HISTOGRAM_ENUMERATION("Bookmarks.EntryPoint", bookmark_utils::ENTRY_POINT_STAR_GESTURE, bookmark_utils::ENTRY_POINT_LIMIT); command_updater_->ExecuteCommand(IDC_BOOKMARK_PAGE_FROM_STAR); - return ui::ER_CONSUMED; + event->SetHandled(); } - return ui::ER_UNHANDLED; } diff --git a/chrome/browser/ui/views/location_bar/star_view.h b/chrome/browser/ui/views/location_bar/star_view.h index b16f560..100497d 100644 --- a/chrome/browser/ui/views/location_bar/star_view.h +++ b/chrome/browser/ui/views/location_bar/star_view.h @@ -36,7 +36,7 @@ class StarView : public views::ImageView, virtual bool OnKeyPressed(const ui::KeyEvent& event) OVERRIDE; // ui::EventHandler overrides: - virtual ui::EventResult OnGestureEvent(ui::GestureEvent* event) OVERRIDE; + virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; // The CommandUpdater for the Browser object that owns the location bar. CommandUpdater* command_updater_; diff --git a/chrome/browser/ui/views/location_bar/zoom_bubble_view.cc b/chrome/browser/ui/views/location_bar/zoom_bubble_view.cc index caedd3c..d28292b 100644 --- a/chrome/browser/ui/views/location_bar/zoom_bubble_view.cc +++ b/chrome/browser/ui/views/location_bar/zoom_bubble_view.cc @@ -114,16 +114,16 @@ void ZoomBubbleView::OnMouseExited(const ui::MouseEvent& event) { StartTimerIfNecessary(); } -ui::EventResult ZoomBubbleView::OnGestureEvent(ui::GestureEvent* event) { +void ZoomBubbleView::OnGestureEvent(ui::GestureEvent* event) { if (!zoom_bubble_ || !zoom_bubble_->auto_close_ || event->type() != ui::ET_GESTURE_TAP) { - return ui::ER_UNHANDLED; + return; } // If an auto-closing bubble was tapped, show a non-auto-closing bubble in // its place. ShowBubble(zoom_bubble_->anchor_view(), zoom_bubble_->web_contents_, false); - return ui::ER_CONSUMED; + event->SetHandled(); } void ZoomBubbleView::ButtonPressed(views::Button* sender, diff --git a/chrome/browser/ui/views/location_bar/zoom_bubble_view.h b/chrome/browser/ui/views/location_bar/zoom_bubble_view.h index d1fdf5f..34287ad 100644 --- a/chrome/browser/ui/views/location_bar/zoom_bubble_view.h +++ b/chrome/browser/ui/views/location_bar/zoom_bubble_view.h @@ -55,7 +55,7 @@ class ZoomBubbleView : public views::BubbleDelegateView, virtual void OnMouseExited(const ui::MouseEvent& event) OVERRIDE; // ui::EventHandler method. - virtual ui::EventResult OnGestureEvent(ui::GestureEvent* event) OVERRIDE; + virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; // views::ButtonListener method. virtual void ButtonPressed(views::Button* sender, diff --git a/chrome/browser/ui/views/location_bar/zoom_view.cc b/chrome/browser/ui/views/location_bar/zoom_view.cc index 44ccf12..78be1e5 100644 --- a/chrome/browser/ui/views/location_bar/zoom_view.cc +++ b/chrome/browser/ui/views/location_bar/zoom_view.cc @@ -73,12 +73,11 @@ bool ZoomView::OnKeyPressed(const ui::KeyEvent& event) { return true; } -ui::EventResult ZoomView::OnGestureEvent(ui::GestureEvent* event) { - if (event->type() != ui::ET_GESTURE_TAP) - return ui::ER_UNHANDLED; - - ActivateBubble(); - return ui::ER_CONSUMED; +void ZoomView::OnGestureEvent(ui::GestureEvent* event) { + if (event->type() == ui::ET_GESTURE_TAP) { + ActivateBubble(); + event->SetHandled(); + } } int ZoomView::GetBuiltInHorizontalPadding() const { diff --git a/chrome/browser/ui/views/location_bar/zoom_view.h b/chrome/browser/ui/views/location_bar/zoom_view.h index 009a09a..4610f81 100644 --- a/chrome/browser/ui/views/location_bar/zoom_view.h +++ b/chrome/browser/ui/views/location_bar/zoom_view.h @@ -41,7 +41,7 @@ class ZoomView : public views::ImageView, virtual bool OnKeyPressed(const ui::KeyEvent& event) OVERRIDE; // ui::EventHandler: - virtual ui::EventResult OnGestureEvent(ui::GestureEvent* event) OVERRIDE; + virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; // TouchableLocationBarView. virtual int GetBuiltInHorizontalPadding() const OVERRIDE; diff --git a/chrome/browser/ui/views/omnibox/omnibox_popup_contents_view.cc b/chrome/browser/ui/views/omnibox/omnibox_popup_contents_view.cc index d80c1ab..3a94322 100644 --- a/chrome/browser/ui/views/omnibox/omnibox_popup_contents_view.cc +++ b/chrome/browser/ui/views/omnibox/omnibox_popup_contents_view.cc @@ -358,8 +358,7 @@ void OmniboxPopupContentsView::OnMouseExited( model_->SetHoveredLine(OmniboxPopupModel::kNoMatch); } -ui::EventResult OmniboxPopupContentsView::OnGestureEvent( - ui::GestureEvent* event) { +void OmniboxPopupContentsView::OnGestureEvent(ui::GestureEvent* event) { switch (event->type()) { case ui::ET_GESTURE_TAP_DOWN: case ui::ET_GESTURE_SCROLL_BEGIN: @@ -371,9 +370,9 @@ ui::EventResult OmniboxPopupContentsView::OnGestureEvent( OpenSelectedLine(*event, CURRENT_TAB); break; default: - return ui::ER_UNHANDLED; + return; } - return ui::ER_CONSUMED; + event->SetHandled(); } //////////////////////////////////////////////////////////////////////////////// diff --git a/chrome/browser/ui/views/omnibox/omnibox_popup_contents_view.h b/chrome/browser/ui/views/omnibox/omnibox_popup_contents_view.h index 0eff81e..67d5018 100644 --- a/chrome/browser/ui/views/omnibox/omnibox_popup_contents_view.h +++ b/chrome/browser/ui/views/omnibox/omnibox_popup_contents_view.h @@ -72,7 +72,7 @@ class OmniboxPopupContentsView : public views::View, virtual void OnMouseExited(const ui::MouseEvent& event) OVERRIDE; // Overridden from ui::EventHandler: - virtual ui::EventResult OnGestureEvent(ui::GestureEvent* event) OVERRIDE; + virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; protected: OmniboxPopupContentsView(const gfx::Font& font, diff --git a/chrome/browser/ui/views/tabs/tab.cc b/chrome/browser/ui/views/tabs/tab.cc index 7e39d66..0cf26ba 100644 --- a/chrome/browser/ui/views/tabs/tab.cc +++ b/chrome/browser/ui/views/tabs/tab.cc @@ -357,11 +357,11 @@ class Tab::TabCloseButton : public views::ImageButton { CustomButton::OnMouseReleased(event); } - virtual ui::EventResult OnGestureEvent(ui::GestureEvent* event) OVERRIDE { + virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE { // Consume all gesture events here so that the parent (Tab) does not // start consuming gestures. ImageButton::OnGestureEvent(event); - return ui::ER_CONSUMED; + event->SetHandled(); } private: @@ -936,14 +936,16 @@ void Tab::OnMouseExited(const ui::MouseEvent& event) { hover_controller_.Hide(); } -ui::EventResult Tab::OnGestureEvent(ui::GestureEvent* event) { - if (!controller()) - return ui::ER_CONSUMED; +void Tab::OnGestureEvent(ui::GestureEvent* event) { + if (!controller()) { + event->SetHandled(); + return; + } switch (event->type()) { case ui::ET_GESTURE_BEGIN: { if (event->details().touch_points() != 1) - return ui::ER_UNHANDLED; + return; TabStripSelectionModel original_selection; original_selection.Copy(controller()->GetSelectionModel()); @@ -966,7 +968,7 @@ ui::EventResult Tab::OnGestureEvent(ui::GestureEvent* event) { default: break; } - return ui::ER_CONSUMED; + event->SetHandled(); } void Tab::GetAccessibleState(ui::AccessibleViewState* state) { diff --git a/chrome/browser/ui/views/tabs/tab.h b/chrome/browser/ui/views/tabs/tab.h index 4d22ee8..37a1925 100644 --- a/chrome/browser/ui/views/tabs/tab.h +++ b/chrome/browser/ui/views/tabs/tab.h @@ -180,7 +180,7 @@ class Tab : public ui::AnimationDelegate, virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; // Overridden from ui::EventHandler: - virtual ui::EventResult OnGestureEvent(ui::GestureEvent* event) OVERRIDE; + virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; // Returns the bounds of the title and icon. const gfx::Rect& GetTitleBounds() const; diff --git a/chrome/browser/ui/views/tabs/tab_strip.cc b/chrome/browser/ui/views/tabs/tab_strip.cc index 871f843..8623624 100644 --- a/chrome/browser/ui/views/tabs/tab_strip.cc +++ b/chrome/browser/ui/views/tabs/tab_strip.cc @@ -307,7 +307,7 @@ class NewTabButton : public views::ImageButton { virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; // Overridden from ui::EventHandler: - virtual ui::EventResult OnGestureEvent(ui::GestureEvent* event) OVERRIDE; + virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; private: bool ShouldUseNativeFrame() const; @@ -380,11 +380,11 @@ void NewTabButton::OnPaint(gfx::Canvas* canvas) { canvas->DrawImageInt(image, 0, height() - image.height()); } -ui::EventResult NewTabButton::OnGestureEvent(ui::GestureEvent* event) { +void NewTabButton::OnGestureEvent(ui::GestureEvent* event) { // Consume all gesture events here so that the parent (Tab) does not // start consuming gestures. views::ImageButton::OnGestureEvent(event); - return ui::ER_CONSUMED; + event->SetHandled(); } bool NewTabButton::ShouldUseNativeFrame() const { @@ -1463,7 +1463,7 @@ void TabStrip::OnMouseEntered(const ui::MouseEvent& event) { SetResetToShrinkOnExit(true); } -ui::EventResult TabStrip::OnGestureEvent(ui::GestureEvent* event) { +void TabStrip::OnGestureEvent(ui::GestureEvent* event) { SetResetToShrinkOnExit(false); switch (event->type()) { case ui::ET_GESTURE_END: @@ -1490,7 +1490,7 @@ ui::EventResult TabStrip::OnGestureEvent(ui::GestureEvent* event) { default: break; } - return ui::ER_CONSUMED; + event->SetHandled(); } void TabStrip::GetCurrentTabWidths(double* unselected_width, diff --git a/chrome/browser/ui/views/tabs/tab_strip.h b/chrome/browser/ui/views/tabs/tab_strip.h index a1ccaa6..f306358 100644 --- a/chrome/browser/ui/views/tabs/tab_strip.h +++ b/chrome/browser/ui/views/tabs/tab_strip.h @@ -235,7 +235,7 @@ class TabStrip : public views::View, virtual void OnMouseEntered(const ui::MouseEvent& event) OVERRIDE; // ui::EventHandler overrides. - virtual ui::EventResult OnGestureEvent(ui::GestureEvent* event) OVERRIDE; + virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; private: typedef std::map<int, std::vector<Tab*> > TabsClosingMap; diff --git a/content/browser/renderer_host/render_widget_host_view_aura.cc b/content/browser/renderer_host/render_widget_host_view_aura.cc index 1651dd0..b0ba2c4 100644 --- a/content/browser/renderer_host/render_widget_host_view_aura.cc +++ b/content/browser/renderer_host/render_widget_host_view_aura.cc @@ -1682,14 +1682,14 @@ ui::EventResult RenderWidgetHostViewAura::OnTouchEvent(ui::TouchEvent* event) { return result; } -ui::EventResult RenderWidgetHostViewAura::OnGestureEvent( - ui::GestureEvent* event) { +void RenderWidgetHostViewAura::OnGestureEvent(ui::GestureEvent* event) { TRACE_EVENT0("browser", "RenderWidgetHostViewAura::OnGestureEvent"); // Pinch gestures are currently disabled by default. See crbug.com/128477. if ((event->type() == ui::ET_GESTURE_PINCH_BEGIN || event->type() == ui::ET_GESTURE_PINCH_UPDATE || event->type() == ui::ET_GESTURE_PINCH_END) && !ShouldSendPinchGesture()) { - return ui::ER_CONSUMED; + event->SetHandled(); + return; } RenderViewHostDelegate* delegate = NULL; @@ -1728,10 +1728,8 @@ ui::EventResult RenderWidgetHostViewAura::OnGestureEvent( } // If a gesture is not processed by the webpage, then WebKit processes it - // (e.g. generates synthetic mouse events). So CONSUMED should be returned - // from here to avoid any duplicate synthetic mouse-events being generated - // from aura. - return ui::ER_CONSUMED; + // (e.g. generates synthetic mouse events). + event->SetHandled(); } //////////////////////////////////////////////////////////////////////////////// diff --git a/content/browser/renderer_host/render_widget_host_view_aura.h b/content/browser/renderer_host/render_widget_host_view_aura.h index a702f50..42e9fec 100644 --- a/content/browser/renderer_host/render_widget_host_view_aura.h +++ b/content/browser/renderer_host/render_widget_host_view_aura.h @@ -197,7 +197,7 @@ class RenderWidgetHostViewAura 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 ui::EventResult OnGestureEvent(ui::GestureEvent* event) OVERRIDE; + virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; // Overridden from aura::client::ActivationDelegate: virtual bool ShouldActivate() const OVERRIDE; diff --git a/content/browser/web_contents/web_contents_view_aura.cc b/content/browser/web_contents/web_contents_view_aura.cc index c3d194c..e435be3 100644 --- a/content/browser/web_contents/web_contents_view_aura.cc +++ b/content/browser/web_contents/web_contents_view_aura.cc @@ -923,15 +923,6 @@ ui::EventResult WebContentsViewAura::OnMouseEvent(ui::MouseEvent* event) { return ui::ER_UNHANDLED; } -ui::EventResult WebContentsViewAura::OnTouchEvent(ui::TouchEvent* event) { - return ui::ER_UNHANDLED; -} - -ui::EventResult WebContentsViewAura::OnGestureEvent( - ui::GestureEvent* event) { - return ui::ER_UNHANDLED; -} - //////////////////////////////////////////////////////////////////////////////// // WebContentsViewAura, aura::client::DragDropDelegate implementation: diff --git a/content/browser/web_contents/web_contents_view_aura.h b/content/browser/web_contents/web_contents_view_aura.h index 36527d6..5d9dc63 100644 --- a/content/browser/web_contents/web_contents_view_aura.h +++ b/content/browser/web_contents/web_contents_view_aura.h @@ -155,8 +155,6 @@ class CONTENT_EXPORT WebContentsViewAura // 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 ui::EventResult OnGestureEvent(ui::GestureEvent* event) OVERRIDE; // Overridden from aura::client::DragDropDelegate: virtual void OnDragEntered(const ui::DropTargetEvent& event) OVERRIDE; diff --git a/ui/app_list/app_list_item_view.cc b/ui/app_list/app_list_item_view.cc index 07d35ad..0e8eb26 100644 --- a/ui/app_list/app_list_item_view.cc +++ b/ui/app_list/app_list_item_view.cc @@ -313,18 +313,18 @@ bool AppListItemView::OnMouseDragged(const ui::MouseEvent& event) { return true; } -ui::EventResult AppListItemView::OnGestureEvent(ui::GestureEvent* event) { +void AppListItemView::OnGestureEvent(ui::GestureEvent* event) { switch (event->type()) { case ui::ET_GESTURE_SCROLL_BEGIN: if (touch_dragging_) { apps_grid_view_->InitiateDrag(this, AppsGridView::TOUCH, *event); - return ui::ER_CONSUMED; + event->SetHandled(); } break; case ui::ET_GESTURE_SCROLL_UPDATE: if (touch_dragging_) { apps_grid_view_->UpdateDrag(this, AppsGridView::TOUCH, *event); - return ui::ER_CONSUMED; + event->SetHandled(); } break; case ui::ET_GESTURE_SCROLL_END: @@ -332,13 +332,14 @@ ui::EventResult AppListItemView::OnGestureEvent(ui::GestureEvent* event) { if (touch_dragging_) { SetTouchDragging(false); apps_grid_view_->EndDrag(false); - return ui::ER_CONSUMED; + event->SetHandled(); } break; case ui::ET_GESTURE_LONG_PRESS: if (!apps_grid_view_->has_dragged_view()) SetTouchDragging(true); - return ui::ER_CONSUMED; + event->SetHandled(); + break; case ui::ET_GESTURE_END: if (touch_dragging_) { SetTouchDragging(false); @@ -351,7 +352,8 @@ ui::EventResult AppListItemView::OnGestureEvent(ui::GestureEvent* event) { default: break; } - return CustomButton::OnGestureEvent(event); + if (!event->handled()) + CustomButton::OnGestureEvent(event); } } // namespace app_list diff --git a/ui/app_list/app_list_item_view.h b/ui/app_list/app_list_item_view.h index 0e1937c..4bf09c4 100644 --- a/ui/app_list/app_list_item_view.h +++ b/ui/app_list/app_list_item_view.h @@ -86,7 +86,7 @@ class APP_LIST_EXPORT AppListItemView : public views::CustomButton, virtual bool OnMouseDragged(const ui::MouseEvent& event) OVERRIDE; // ui::EventHandler overrides: - virtual ui::EventResult OnGestureEvent(ui::GestureEvent* event) OVERRIDE; + virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; AppListItemModel* model_; // Owned by AppListModel::Apps. diff --git a/ui/app_list/contents_view.cc b/ui/app_list/contents_view.cc index 076dd1f..fbbb1b1 100644 --- a/ui/app_list/contents_view.cc +++ b/ui/app_list/contents_view.cc @@ -185,24 +185,27 @@ bool ContentsView::OnMouseWheel(const ui::MouseWheelEvent& event) { return false; } -ui::EventResult ContentsView::OnGestureEvent(ui::GestureEvent* event) { +void ContentsView::OnGestureEvent(ui::GestureEvent* event) { if (show_state_ != SHOW_APPS) - return ui::ER_UNHANDLED; + return; switch (event->type()) { case ui::ET_GESTURE_SCROLL_BEGIN: pagination_model_->StartScroll(); - return ui::ER_CONSUMED; + event->SetHandled(); + return; case ui::ET_GESTURE_SCROLL_UPDATE: // event->details.scroll_x() > 0 means moving contents to right. That is, // transitioning to previous page. pagination_model_->UpdateScroll( event->details().scroll_x() / GetContentsBounds().width()); - return ui::ER_CONSUMED; + event->SetHandled(); + return; case ui::ET_GESTURE_SCROLL_END: pagination_model_->EndScroll(pagination_model_-> transition().progress < kFinishTransitionThreshold); - return ui::ER_CONSUMED; + event->SetHandled(); + return; case ui::ET_SCROLL_FLING_START: { pagination_model_->EndScroll(true); if (fabs(event->details().velocity_x()) > kMinHorizVelocityToSwitchPage) { @@ -210,13 +213,12 @@ ui::EventResult ContentsView::OnGestureEvent(ui::GestureEvent* event) { event->details().velocity_x() < 0 ? 1 : -1, true); } - return ui::ER_CONSUMED; + event->SetHandled(); + return; } default: break; } - - return ui::ER_UNHANDLED; } ui::EventResult ContentsView::OnScrollEvent(ui::ScrollEvent* event) { diff --git a/ui/app_list/contents_view.h b/ui/app_list/contents_view.h index 7a2160e..8c283d5 100644 --- a/ui/app_list/contents_view.h +++ b/ui/app_list/contents_view.h @@ -57,7 +57,7 @@ class ContentsView : public views::View { virtual bool OnMouseWheel(const ui::MouseWheelEvent& event) OVERRIDE; // Overridden from ui::EventHandler: - virtual ui::EventResult OnGestureEvent(ui::GestureEvent* event) OVERRIDE; + virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; virtual ui::EventResult OnScrollEvent(ui::ScrollEvent* event) OVERRIDE; ShowState show_state_; diff --git a/ui/aura/demo/demo_main.cc b/ui/aura/demo/demo_main.cc index b1ab577..64614b9 100644 --- a/ui/aura/demo/demo_main.cc +++ b/ui/aura/demo/demo_main.cc @@ -73,20 +73,6 @@ class DemoWindowDelegate : public aura::WindowDelegate { return scoped_refptr<ui::Texture>(); } - // Overridden from ui::EventHandler: - virtual ui::EventResult OnKeyEvent(ui::KeyEvent* event) OVERRIDE { - return ui::ER_UNHANDLED; - } - virtual ui::EventResult OnMouseEvent(ui::MouseEvent* event) OVERRIDE { - return ui::ER_HANDLED; - } - virtual ui::EventResult OnTouchEvent(ui::TouchEvent* event) OVERRIDE { - return ui::ER_UNHANDLED; - } - virtual ui::EventResult OnGestureEvent(ui::GestureEvent* event) OVERRIDE { - return ui::ER_UNHANDLED; - } - private: SkColor color_; diff --git a/ui/aura/gestures/gesture_recognizer_unittest.cc b/ui/aura/gestures/gesture_recognizer_unittest.cc index 76251b8..3593b0d 100644 --- a/ui/aura/gestures/gesture_recognizer_unittest.cc +++ b/ui/aura/gestures/gesture_recognizer_unittest.cc @@ -176,8 +176,7 @@ class GestureEventConsumeDelegate : public TestWindowDelegate { run_loop_->Run(); } - virtual ui::EventResult OnGestureEvent( - ui::GestureEvent* gesture) OVERRIDE { + virtual void OnGestureEvent(ui::GestureEvent* gesture) OVERRIDE { events_.push_back(gesture->type()); bounding_box_ = gesture->details().bounding_box(); switch (gesture->type()) { @@ -256,7 +255,7 @@ class GestureEventConsumeDelegate : public TestWindowDelegate { run_loop_->Quit(); wait_until_event_ = ui::ET_UNKNOWN; } - return ui::ER_CONSUMED; + gesture->StopPropagation(); } private: diff --git a/ui/aura/root_window_unittest.cc b/ui/aura/root_window_unittest.cc index 7de3bf3..98d3eb1 100644 --- a/ui/aura/root_window_unittest.cc +++ b/ui/aura/root_window_unittest.cc @@ -459,9 +459,8 @@ class EventFilterRecorder : public ui::EventHandler { return ui::ER_UNHANDLED; } - virtual ui::EventResult OnGestureEvent(ui::GestureEvent* event) OVERRIDE { + virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE { events_.push_back(event->type()); - return ui::ER_UNHANDLED; } private: @@ -746,16 +745,17 @@ class DetachesParentOnTapDelegate : public test::TestWindowDelegate { virtual ~DetachesParentOnTapDelegate() {} private: - virtual ui::EventResult OnGestureEvent(ui::GestureEvent* event) OVERRIDE { - if (event->type() == ui::ET_GESTURE_TAP_DOWN) - return ui::ER_HANDLED; + virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE { + if (event->type() == ui::ET_GESTURE_TAP_DOWN) { + event->SetHandled(); + return; + } if (event->type() == ui::ET_GESTURE_TAP) { Window* parent = static_cast<Window*>(event->target())->parent(); parent->parent()->RemoveChild(parent); - return ui::ER_HANDLED; + event->SetHandled(); } - return ui::ER_UNHANDLED; } DISALLOW_COPY_AND_ASSIGN(DetachesParentOnTapDelegate); diff --git a/ui/aura/test/test_event_handler.cc b/ui/aura/test/test_event_handler.cc index 45cdabc..dac45cc 100644 --- a/ui/aura/test/test_event_handler.cc +++ b/ui/aura/test/test_event_handler.cc @@ -45,9 +45,8 @@ ui::EventResult TestEventHandler::OnTouchEvent(ui::TouchEvent* event) { return ui::ER_UNHANDLED; } -ui::EventResult TestEventHandler::OnGestureEvent(ui::GestureEvent* event) { +void TestEventHandler::OnGestureEvent(ui::GestureEvent* event) { num_gesture_events_++; - return ui::ER_UNHANDLED; } } // namespace test diff --git a/ui/aura/test/test_event_handler.h b/ui/aura/test/test_event_handler.h index aa74ca7..32ee250 100644 --- a/ui/aura/test/test_event_handler.h +++ b/ui/aura/test/test_event_handler.h @@ -32,7 +32,7 @@ class TestEventHandler : public ui::EventHandler { 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 ui::EventResult OnGestureEvent(ui::GestureEvent* event) OVERRIDE; + virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; private: // How many events have been received of each type? diff --git a/ui/aura/test/test_window_delegate.cc b/ui/aura/test/test_window_delegate.cc index 7e5835c..51f2dfb 100644 --- a/ui/aura/test/test_window_delegate.cc +++ b/ui/aura/test/test_window_delegate.cc @@ -101,23 +101,6 @@ scoped_refptr<ui::Texture> TestWindowDelegate::CopyTexture() { return scoped_refptr<ui::Texture>(); } -ui::EventResult TestWindowDelegate::OnKeyEvent(ui::KeyEvent* event) { - return ui::ER_UNHANDLED; -} - -ui::EventResult TestWindowDelegate::OnMouseEvent(ui::MouseEvent* event) { - return ui::ER_UNHANDLED; -} - -ui::EventResult TestWindowDelegate::OnTouchEvent(ui::TouchEvent* event) { - return ui::ER_UNHANDLED; -} - -ui::EventResult TestWindowDelegate::OnGestureEvent( - ui::GestureEvent* event) { - return ui::ER_UNHANDLED; -} - //////////////////////////////////////////////////////////////////////////////// // ColorTestWindowDelegate diff --git a/ui/aura/test/test_window_delegate.h b/ui/aura/test/test_window_delegate.h index faa2f5e..98d8a59 100644 --- a/ui/aura/test/test_window_delegate.h +++ b/ui/aura/test/test_window_delegate.h @@ -61,12 +61,6 @@ class TestWindowDelegate : public WindowDelegate { virtual void GetHitTestMask(gfx::Path* mask) const OVERRIDE; virtual scoped_refptr<ui::Texture> CopyTexture() OVERRIDE; - // 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 ui::EventResult OnGestureEvent(ui::GestureEvent* event) OVERRIDE; - private: int window_component_; bool delete_on_destroyed_; diff --git a/ui/aura/window_unittest.cc b/ui/aura/window_unittest.cc index 4dde778..08a4a42 100644 --- a/ui/aura/window_unittest.cc +++ b/ui/aura/window_unittest.cc @@ -180,10 +180,8 @@ class CaptureWindowDelegateImpl : public TestWindowDelegate { touch_event_count_++; return ui::ER_UNHANDLED; } - virtual ui::EventResult OnGestureEvent( - ui::GestureEvent* event) OVERRIDE { + virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE { gesture_event_count_++; - return ui::ER_UNHANDLED; } virtual void OnCaptureLost() OVERRIDE { capture_lost_count_++; @@ -223,10 +221,9 @@ class GestureTrackPositionDelegate : public TestWindowDelegate { public: GestureTrackPositionDelegate() {} - virtual ui::EventResult OnGestureEvent( - ui::GestureEvent* event) OVERRIDE { + virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE { position_ = event->location(); - return ui::ER_CONSUMED; + event->StopPropagation(); } const gfx::Point& position() const { return position_; } diff --git a/ui/base/events/event.cc b/ui/base/events/event.cc index a489eae..96ab69b 100644 --- a/ui/base/events/event.cc +++ b/ui/base/events/event.cc @@ -72,13 +72,13 @@ bool Event::HasNativeEvent() const { } void Event::StopPropagation() { - CHECK(phase_ != EP_PREDISPATCH && phase_ != EP_POSTDISPATCH); +// CHECK(phase_ != EP_PREDISPATCH && phase_ != EP_POSTDISPATCH); result_ = static_cast<ui::EventResult>(result_ | ER_CONSUMED); CHECK(stopped_propagation()); } void Event::SetHandled() { - CHECK(phase_ != EP_PREDISPATCH && phase_ != EP_POSTDISPATCH); +// CHECK(phase_ != EP_PREDISPATCH && phase_ != EP_POSTDISPATCH); result_ = static_cast<ui::EventResult>(result_ | ER_HANDLED); } diff --git a/ui/base/events/event_dispatcher_unittest.cc b/ui/base/events/event_dispatcher_unittest.cc index 00eca7a..de6444d 100644 --- a/ui/base/events/event_dispatcher_unittest.cc +++ b/ui/base/events/event_dispatcher_unittest.cc @@ -100,9 +100,12 @@ class TestEventHandler : public EventHandler { return event_result_; } - virtual EventResult OnGestureEvent(GestureEvent* event) OVERRIDE { + virtual void OnGestureEvent(GestureEvent* event) OVERRIDE { ReceivedEvent(event); - return event_result_; + if (event_result_ & ui::ER_CONSUMED) + event->StopPropagation(); + if (event_result_ & ui::ER_HANDLED) + event->SetHandled(); } int id_; diff --git a/ui/base/events/event_handler.cc b/ui/base/events/event_handler.cc index d6fcea7..395db78 100644 --- a/ui/base/events/event_handler.cc +++ b/ui/base/events/event_handler.cc @@ -25,7 +25,7 @@ void EventHandler::OnEvent(Event* event) { else if (event->IsTouchEvent()) result = OnTouchEvent(static_cast<TouchEvent*>(event)); else if (event->IsGestureEvent()) - result = OnGestureEvent(static_cast<GestureEvent*>(event)); + OnGestureEvent(static_cast<GestureEvent*>(event)); if (result & ui::ER_CONSUMED) event->StopPropagation(); @@ -49,8 +49,7 @@ EventResult EventHandler::OnTouchEvent(TouchEvent* event) { return ui::ER_UNHANDLED; } -EventResult EventHandler::OnGestureEvent(GestureEvent* event) { - return ui::ER_UNHANDLED; +void EventHandler::OnGestureEvent(GestureEvent* event) { } } // namespace ui diff --git a/ui/base/events/event_handler.h b/ui/base/events/event_handler.h index 405c65d..36e5853 100644 --- a/ui/base/events/event_handler.h +++ b/ui/base/events/event_handler.h @@ -42,7 +42,7 @@ class UI_EXPORT EventHandler { virtual EventResult OnTouchEvent(TouchEvent* event); - virtual EventResult OnGestureEvent(GestureEvent* event); + virtual void OnGestureEvent(GestureEvent* event); }; typedef std::vector<EventHandler*> EventHandlerList; diff --git a/ui/base/events/event_target.cc b/ui/base/events/event_target.cc index 1f8db028..6c1d671 100644 --- a/ui/base/events/event_target.cc +++ b/ui/base/events/event_target.cc @@ -65,10 +65,10 @@ EventResult EventTarget::OnTouchEvent(TouchEvent* event) { ER_UNHANDLED; } -EventResult EventTarget::OnGestureEvent(GestureEvent* event) { +void EventTarget::OnGestureEvent(GestureEvent* event) { CHECK_EQ(this, event->target()); - return target_handler_ ? target_handler_->OnGestureEvent(event) : - ER_UNHANDLED; + if (target_handler_) + target_handler_->OnGestureEvent(event); } void EventTarget::GetPreTargetHandlers(EventHandlerList* list) { diff --git a/ui/base/events/event_target.h b/ui/base/events/event_target.h index 0b23997..4531db8 100644 --- a/ui/base/events/event_target.h +++ b/ui/base/events/event_target.h @@ -76,7 +76,7 @@ class UI_EXPORT EventTarget : public EventHandler { virtual EventResult OnMouseEvent(MouseEvent* event) OVERRIDE; virtual EventResult OnScrollEvent(ScrollEvent* event) OVERRIDE; virtual EventResult OnTouchEvent(TouchEvent* event) OVERRIDE; - virtual EventResult OnGestureEvent(GestureEvent* event) OVERRIDE; + virtual void OnGestureEvent(GestureEvent* event) OVERRIDE; private: friend class EventDispatcher; diff --git a/ui/message_center/message_view.cc b/ui/message_center/message_view.cc index 7eba173..2fbc834 100644 --- a/ui/message_center/message_view.cc +++ b/ui/message_center/message_view.cc @@ -134,28 +134,29 @@ bool MessageView::OnMousePressed(const ui::MouseEvent& event) { return true; } -ui::EventResult MessageView::OnGestureEvent(ui::GestureEvent* event) { +void MessageView::OnGestureEvent(ui::GestureEvent* event) { if (event->type() == ui::ET_GESTURE_TAP) { list_delegate_->OnNotificationClicked(notification_.id); - return ui::ER_CONSUMED; + event->SetHandled(); + return; } if (event->type() == ui::ET_GESTURE_LONG_PRESS) { ShowMenu(event->location()); - return ui::ER_CONSUMED; + event->SetHandled(); + return; } - ui::EventResult result = SlideOutView::OnGestureEvent(event); - if (result & ui::ER_CONSUMED) - return result; + SlideOutView::OnGestureEvent(event); + if (event->handled()) + return; if (!event->IsScrollGestureEvent()) - return result; + return; if (scroller_) scroller_->OnGestureEvent(event); - - return ui::ER_CONSUMED; + event->SetHandled(); } void MessageView::ButtonPressed(views::Button* sender, diff --git a/ui/message_center/message_view.h b/ui/message_center/message_view.h index e59484d..e1691c5 100644 --- a/ui/message_center/message_view.h +++ b/ui/message_center/message_view.h @@ -43,7 +43,7 @@ class MessageView : public views::SlideOutView, virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE; // ui::EventHandler overrides. - virtual ui::EventResult OnGestureEvent(ui::GestureEvent* event) OVERRIDE; + virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; // Overridden from ButtonListener. virtual void ButtonPressed(views::Button* sender, diff --git a/ui/views/color_chooser/color_chooser_view.cc b/ui/views/color_chooser/color_chooser_view.cc index fb23fce..99ae5ee 100644 --- a/ui/views/color_chooser/color_chooser_view.cc +++ b/ui/views/color_chooser/color_chooser_view.cc @@ -73,14 +73,13 @@ class LocatedEventHandlerView : public views::View { return true; } - virtual ui::EventResult OnGestureEvent(ui::GestureEvent* event) OVERRIDE { + virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE { if (event->type() == ui::ET_GESTURE_TAP || event->type() == ui::ET_GESTURE_TAP_DOWN || event->IsScrollGestureEvent()) { ProcessEventAtLocation(event->location()); - return ui::ER_CONSUMED; + event->SetHandled(); } - return ui::ER_UNHANDLED; } DISALLOW_COPY_AND_ASSIGN(LocatedEventHandlerView); diff --git a/ui/views/controls/button/custom_button.cc b/ui/views/controls/button/custom_button.cc index eaa0a81..aad0b80 100644 --- a/ui/views/controls/button/custom_button.cc +++ b/ui/views/controls/button/custom_button.cc @@ -207,9 +207,11 @@ bool CustomButton::OnKeyReleased(const ui::KeyEvent& event) { return true; } -ui::EventResult CustomButton::OnGestureEvent(ui::GestureEvent* event) { - if (state_ == STATE_DISABLED) - return Button::OnGestureEvent(event); +void CustomButton::OnGestureEvent(ui::GestureEvent* event) { + if (state_ == STATE_DISABLED) { + Button::OnGestureEvent(event); + return; + } if (event->type() == ui::ET_GESTURE_TAP && IsTriggerableEvent(*event)) { // Set the button state to hot and start the animation fully faded in. The @@ -218,17 +220,18 @@ ui::EventResult CustomButton::OnGestureEvent(ui::GestureEvent* event) { SetState(STATE_HOVERED); hover_animation_->Reset(1.0); NotifyClick(*event); - return ui::ER_CONSUMED; + event->StopPropagation(); } else if (event->type() == ui::ET_GESTURE_TAP_DOWN && ShouldEnterPushedState(*event)) { SetState(STATE_PRESSED); if (request_focus_on_press_) RequestFocus(); - return ui::ER_CONSUMED; + event->StopPropagation(); } else { SetState(STATE_NORMAL); } - return Button::OnGestureEvent(event); + if (!event->handled()) + Button::OnGestureEvent(event); } bool CustomButton::AcceleratorPressed(const ui::Accelerator& accelerator) { diff --git a/ui/views/controls/button/custom_button.h b/ui/views/controls/button/custom_button.h index 3de4d9d..bb3a6a2 100644 --- a/ui/views/controls/button/custom_button.h +++ b/ui/views/controls/button/custom_button.h @@ -90,7 +90,7 @@ class VIEWS_EXPORT CustomButton : public Button, virtual void OnMouseMoved(const ui::MouseEvent& event) OVERRIDE; virtual bool OnKeyPressed(const ui::KeyEvent& event) OVERRIDE; virtual bool OnKeyReleased(const ui::KeyEvent& event) OVERRIDE; - virtual ui::EventResult OnGestureEvent(ui::GestureEvent* event) OVERRIDE; + virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE; virtual void ShowContextMenu(const gfx::Point& p, bool is_mouse_gesture) OVERRIDE; diff --git a/ui/views/controls/button/menu_button.cc b/ui/views/controls/button/menu_button.cc index 601726a..b770a64 100644 --- a/ui/views/controls/button/menu_button.cc +++ b/ui/views/controls/button/menu_button.cc @@ -219,13 +219,13 @@ void MenuButton::OnMouseExited(const ui::MouseEvent& event) { } } -ui::EventResult MenuButton::OnGestureEvent(ui::GestureEvent* event) { +void MenuButton::OnGestureEvent(ui::GestureEvent* event) { if (state() != STATE_DISABLED && event->type() == ui::ET_GESTURE_TAP) { if (Activate()) - return ui::ER_CONSUMED; - return ui::ER_UNHANDLED; + event->StopPropagation(); + return; } - return TextButton::OnGestureEvent(event); + TextButton::OnGestureEvent(event); } bool MenuButton::OnKeyPressed(const ui::KeyEvent& event) { diff --git a/ui/views/controls/button/menu_button.h b/ui/views/controls/button/menu_button.h index cb48bb5..a6cb678 100644 --- a/ui/views/controls/button/menu_button.h +++ b/ui/views/controls/button/menu_button.h @@ -62,7 +62,7 @@ class VIEWS_EXPORT MenuButton : public TextButton { virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE; virtual void OnMouseReleased(const ui::MouseEvent& event) OVERRIDE; virtual void OnMouseExited(const ui::MouseEvent& event) OVERRIDE; - virtual ui::EventResult OnGestureEvent(ui::GestureEvent* event) OVERRIDE; + virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; virtual bool OnKeyPressed(const ui::KeyEvent& event) OVERRIDE; virtual bool OnKeyReleased(const ui::KeyEvent& event) OVERRIDE; virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; diff --git a/ui/views/controls/combobox/native_combobox_views.cc b/ui/views/controls/combobox/native_combobox_views.cc index 9f67153..8148e28 100644 --- a/ui/views/controls/combobox/native_combobox_views.cc +++ b/ui/views/controls/combobox/native_combobox_views.cc @@ -161,13 +161,14 @@ void NativeComboboxViews::OnBlur() { ///////////////////////////////////////////////////////////////// // NativeComboboxViews, ui::EventHandler overrides: -ui::EventResult NativeComboboxViews::OnGestureEvent(ui::GestureEvent* gesture) { +void NativeComboboxViews::OnGestureEvent(ui::GestureEvent* gesture) { if (gesture->type() == ui::ET_GESTURE_TAP) { UpdateFromModel(); ShowDropDownMenu(); - return ui::ER_CONSUMED; + gesture->StopPropagation(); + return; } - return View::OnGestureEvent(gesture); + View::OnGestureEvent(gesture); } ///////////////////////////////////////////////////////////////// diff --git a/ui/views/controls/combobox/native_combobox_views.h b/ui/views/controls/combobox/native_combobox_views.h index 780c344..c61e254 100644 --- a/ui/views/controls/combobox/native_combobox_views.h +++ b/ui/views/controls/combobox/native_combobox_views.h @@ -40,7 +40,7 @@ class NativeComboboxViews : public views::View, virtual void OnBlur() OVERRIDE; // ui::EventHandler overrides: - virtual ui::EventResult OnGestureEvent(ui::GestureEvent* gesture) OVERRIDE; + virtual void OnGestureEvent(ui::GestureEvent* gesture) OVERRIDE; // NativeComboboxWrapper overrides: virtual void UpdateFromModel() OVERRIDE; diff --git a/ui/views/controls/link.cc b/ui/views/controls/link.cc index 4eea3cf..04c83ac 100644 --- a/ui/views/controls/link.cc +++ b/ui/views/controls/link.cc @@ -122,9 +122,9 @@ void Link::GetAccessibleState(ui::AccessibleViewState* state) { state->role = ui::AccessibilityTypes::ROLE_LINK; } -ui::EventResult Link::OnGestureEvent(ui::GestureEvent* event) { +void Link::OnGestureEvent(ui::GestureEvent* event) { if (!enabled()) - return ui::ER_UNHANDLED; + return; if (event->type() == ui::ET_GESTURE_TAP_DOWN) { SetPressed(true); @@ -134,9 +134,9 @@ ui::EventResult Link::OnGestureEvent(ui::GestureEvent* event) { listener_->LinkClicked(this, event->flags()); } else { SetPressed(false); - return ui::ER_UNHANDLED; + return; } - return ui::ER_CONSUMED; + event->SetHandled(); } void Link::SetFont(const gfx::Font& font) { diff --git a/ui/views/controls/link.h b/ui/views/controls/link.h index 8369992..798a9b2 100644 --- a/ui/views/controls/link.h +++ b/ui/views/controls/link.h @@ -45,7 +45,7 @@ class VIEWS_EXPORT Link : public Label { virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; // Overridden from ui::EventHandler: - virtual ui::EventResult OnGestureEvent(ui::GestureEvent* event) OVERRIDE; + virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; // Overridden from Label: virtual void SetFont(const gfx::Font& font) OVERRIDE; diff --git a/ui/views/controls/menu/menu_controller.cc b/ui/views/controls/menu/menu_controller.cc index 1cbb70f..d6aecd1 100644 --- a/ui/views/controls/menu/menu_controller.cc +++ b/ui/views/controls/menu/menu_controller.cc @@ -506,17 +506,16 @@ bool MenuController::OnMouseWheel(SubmenuView* source, } #endif -ui::EventResult MenuController::OnGestureEvent( - SubmenuView* source, - ui::GestureEvent* event) { +void MenuController::OnGestureEvent(SubmenuView* source, + ui::GestureEvent* event) { MenuPart part = GetMenuPart(source, event->location()); if (event->type() == ui::ET_GESTURE_TAP_DOWN) { SetSelectionOnPointerDown(source, *event); - return ui::ER_CONSUMED; + event->StopPropagation(); } else if (event->type() == ui::ET_GESTURE_LONG_PRESS) { if (part.type == MenuPart::MENU_ITEM && part.menu) { if (ShowContextMenu(part.menu, source, *event)) - return ui::ER_CONSUMED; + event->StopPropagation(); } } else if (event->type() == ui::ET_GESTURE_TAP) { if (!part.is_scroll() && part.menu && @@ -525,17 +524,20 @@ ui::EventResult MenuController::OnGestureEvent( part.menu, *event)) { Accept(part.menu, 0); } - return ui::ER_CONSUMED; + event->StopPropagation(); } else if (part.type == MenuPart::MENU_ITEM) { // User either tapped on empty space, or a menu that has children. SetSelection(part.menu ? part.menu : state_.item, SELECTION_OPEN_SUBMENU | SELECTION_UPDATE_IMMEDIATELY); - return ui::ER_CONSUMED; + event->StopPropagation(); } } + if (event->stopped_propagation()) + return; + if (!part.submenu) - return ui::ER_UNHANDLED; - return part.submenu->OnGestureEvent(event); + return; + part.submenu->OnGestureEvent(event); } bool MenuController::GetDropFormats( diff --git a/ui/views/controls/menu/menu_controller.h b/ui/views/controls/menu/menu_controller.h index eff6170..832ef34 100644 --- a/ui/views/controls/menu/menu_controller.h +++ b/ui/views/controls/menu/menu_controller.h @@ -109,8 +109,7 @@ class VIEWS_EXPORT MenuController #if defined(OS_LINUX) bool OnMouseWheel(SubmenuView* source, const ui::MouseWheelEvent& event); #endif - ui::EventResult OnGestureEvent(SubmenuView* source, - ui::GestureEvent* event); + void OnGestureEvent(SubmenuView* source, ui::GestureEvent* event); bool GetDropFormats( SubmenuView* source, diff --git a/ui/views/controls/menu/menu_host_root_view.cc b/ui/views/controls/menu/menu_host_root_view.cc index 8b6bd3e..ad8bf0a 100644 --- a/ui/views/controls/menu/menu_host_root_view.cc +++ b/ui/views/controls/menu/menu_host_root_view.cc @@ -62,16 +62,16 @@ bool MenuHostRootView::OnMouseWheel(const ui::MouseWheelEvent& event) { #endif } -ui::EventResult MenuHostRootView::DispatchGestureEvent( +void MenuHostRootView::DispatchGestureEvent( ui::GestureEvent* event) { - ui::EventResult result = RootView::DispatchGestureEvent(event); - if (result != ui::ER_UNHANDLED) - return result; + RootView::DispatchGestureEvent(event); + if (event->handled()) + return; // ChromeOS uses MenuController to forward events like other // mouse events. if (!GetMenuController()) - return ui::ER_UNHANDLED; - return GetMenuController()->OnGestureEvent(submenu_, event); + return; + GetMenuController()->OnGestureEvent(submenu_, event); } MenuController* MenuHostRootView::GetMenuController() { diff --git a/ui/views/controls/menu/menu_host_root_view.h b/ui/views/controls/menu/menu_host_root_view.h index 616e2e0..2b8d6ba5 100644 --- a/ui/views/controls/menu/menu_host_root_view.h +++ b/ui/views/controls/menu/menu_host_root_view.h @@ -32,7 +32,7 @@ class MenuHostRootView : public internal::RootView { virtual bool OnMouseWheel(const ui::MouseWheelEvent& event) OVERRIDE; // Overridden from internal::RootView: - virtual ui::EventResult DispatchGestureEvent(ui::GestureEvent* e) OVERRIDE; + virtual void DispatchGestureEvent(ui::GestureEvent* e) OVERRIDE; private: // Returns the MenuController for this MenuHostRootView. diff --git a/ui/views/controls/menu/submenu_view.cc b/ui/views/controls/menu/submenu_view.cc index 71da326..0ace2d1 100644 --- a/ui/views/controls/menu/submenu_view.cc +++ b/ui/views/controls/menu/submenu_view.cc @@ -260,8 +260,8 @@ bool SubmenuView::OnMouseWheel(const ui::MouseWheelEvent& e) { return true; } -ui::EventResult SubmenuView::OnGestureEvent(ui::GestureEvent* event) { - ui::EventResult to_return = ui::ER_CONSUMED; +void SubmenuView::OnGestureEvent(ui::GestureEvent* event) { + bool handled = true; switch (event->type()) { case ui::ET_GESTURE_SCROLL_BEGIN: scroll_animator_->Stop(); @@ -280,10 +280,11 @@ ui::EventResult SubmenuView::OnGestureEvent(ui::GestureEvent* event) { scroll_animator_->Stop(); break; default: - to_return = ui::ER_UNHANDLED; + handled = false; break; } - return to_return; + if (handled) + event->SetHandled(); } bool SubmenuView::IsShowing() { diff --git a/ui/views/controls/menu/submenu_view.h b/ui/views/controls/menu/submenu_view.h index 2ef095a..a83c5a9a 100644 --- a/ui/views/controls/menu/submenu_view.h +++ b/ui/views/controls/menu/submenu_view.h @@ -77,7 +77,7 @@ class VIEWS_EXPORT SubmenuView : public View, // Overridden from ui::EventHandler. // Scrolls on menu item boundaries. - virtual ui::EventResult OnGestureEvent(ui::GestureEvent* event) OVERRIDE; + virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; // Returns true if the menu is showing. bool IsShowing(); diff --git a/ui/views/controls/scroll_view.cc b/ui/views/controls/scroll_view.cc index b85553f..b05f798 100644 --- a/ui/views/controls/scroll_view.cc +++ b/ui/views/controls/scroll_view.cc @@ -433,9 +433,7 @@ bool ScrollView::OnKeyPressed(const ui::KeyEvent& event) { return processed; } -ui::EventResult ScrollView::OnGestureEvent(ui::GestureEvent* event) { - ui::EventResult status = ui::ER_UNHANDLED; - +void ScrollView::OnGestureEvent(ui::GestureEvent* event) { // If the event happened on one of the scrollbars, then those events are // sent directly to the scrollbars. Otherwise, only scroll events are sent to // the scrollbars. @@ -446,13 +444,12 @@ ui::EventResult ScrollView::OnGestureEvent(ui::GestureEvent* event) { if (vert_sb_->visible()) { if (vert_sb_->bounds().Contains(event->location()) || scroll_event) - status = vert_sb_->OnGestureEvent(event); + vert_sb_->OnGestureEvent(event); } - if (status == ui::ER_UNHANDLED && horiz_sb_->visible()) { + if (!event->handled() && horiz_sb_->visible()) { if (horiz_sb_->bounds().Contains(event->location()) || scroll_event) - status = horiz_sb_->OnGestureEvent(event); + horiz_sb_->OnGestureEvent(event); } - return status; } bool ScrollView::OnMouseWheel(const ui::MouseWheelEvent& e) { diff --git a/ui/views/controls/scroll_view.h b/ui/views/controls/scroll_view.h index 1eb0e56..84eb876 100644 --- a/ui/views/controls/scroll_view.h +++ b/ui/views/controls/scroll_view.h @@ -79,7 +79,7 @@ class VIEWS_EXPORT ScrollView : public View, public ScrollBarController { virtual bool OnMouseWheel(const ui::MouseWheelEvent& e) OVERRIDE; // Overridden from ui::EventHandler: - virtual ui::EventResult OnGestureEvent(ui::GestureEvent* event) OVERRIDE; + virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; virtual std::string GetClassName() const OVERRIDE; diff --git a/ui/views/controls/scrollbar/base_scroll_bar.cc b/ui/views/controls/scrollbar/base_scroll_bar.cc index 833ac79..6643735 100644 --- a/ui/views/controls/scrollbar/base_scroll_bar.cc +++ b/ui/views/controls/scrollbar/base_scroll_bar.cc @@ -172,7 +172,7 @@ bool BaseScrollBar::OnMouseWheel(const ui::MouseWheelEvent& event) { return true; } -ui::EventResult BaseScrollBar::OnGestureEvent(ui::GestureEvent* event) { +void BaseScrollBar::OnGestureEvent(ui::GestureEvent* event) { // If a fling is in progress, then stop the fling for any incoming gesture // event (except for the GESTURE_END event that is generated at the end of the // fling). @@ -184,13 +184,14 @@ ui::EventResult BaseScrollBar::OnGestureEvent(ui::GestureEvent* event) { if (event->type() == ui::ET_GESTURE_TAP_DOWN) { ProcessPressEvent(*event); - return ui::ER_CONSUMED; + event->SetHandled(); + return; } if (event->type() == ui::ET_GESTURE_LONG_PRESS) { // For a long-press, the repeater started in tap-down should continue. So // return early. - return ui::ER_UNHANDLED; + return; } ResetState(); @@ -198,17 +199,21 @@ ui::EventResult BaseScrollBar::OnGestureEvent(ui::GestureEvent* event) { if (event->type() == ui::ET_GESTURE_TAP) { // TAP_DOWN would have already scrolled some amount. So scrolling again on // TAP is not necessary. - return ui::ER_CONSUMED; + event->SetHandled(); + return; } if (event->type() == ui::ET_GESTURE_SCROLL_BEGIN || - event->type() == ui::ET_GESTURE_SCROLL_END) - return ui::ER_CONSUMED; + event->type() == ui::ET_GESTURE_SCROLL_END) { + event->SetHandled(); + return; + } if (event->type() == ui::ET_GESTURE_SCROLL_UPDATE) { ScrollByContentsOffset(IsHorizontal() ? event->details().scroll_x() : event->details().scroll_y()); - return ui::ER_CONSUMED; + event->SetHandled(); + return; } if (event->type() == ui::ET_SCROLL_FLING_START) { @@ -217,10 +222,8 @@ ui::EventResult BaseScrollBar::OnGestureEvent(ui::GestureEvent* event) { scroll_animator_->Start( IsHorizontal() ? event->details().velocity_x() : 0.f, IsHorizontal() ? 0.f : event->details().velocity_y()); - return ui::ER_CONSUMED; + event->SetHandled(); } - - return ui::ER_UNHANDLED; } /////////////////////////////////////////////////////////////////////////////// diff --git a/ui/views/controls/scrollbar/base_scroll_bar.h b/ui/views/controls/scrollbar/base_scroll_bar.h index 060f397..4621325 100644 --- a/ui/views/controls/scrollbar/base_scroll_bar.h +++ b/ui/views/controls/scrollbar/base_scroll_bar.h @@ -67,7 +67,7 @@ class VIEWS_EXPORT BaseScrollBar : public ScrollBar, virtual bool OnMouseWheel(const ui::MouseWheelEvent& event) OVERRIDE; // ui::EventHandler overrides: - virtual ui::EventResult OnGestureEvent(ui::GestureEvent* event) OVERRIDE; + virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; // ScrollBar overrides: virtual void Update(int viewport_size, diff --git a/ui/views/controls/scrollbar/native_scroll_bar.cc b/ui/views/controls/scrollbar/native_scroll_bar.cc index 77c4387..0848576 100644 --- a/ui/views/controls/scrollbar/native_scroll_bar.cc +++ b/ui/views/controls/scrollbar/native_scroll_bar.cc @@ -78,10 +78,10 @@ bool NativeScrollBar::OnKeyPressed(const ui::KeyEvent& event) { return native_wrapper_->GetView()->OnKeyPressed(event); } -ui::EventResult NativeScrollBar::OnGestureEvent(ui::GestureEvent* event) { +void NativeScrollBar::OnGestureEvent(ui::GestureEvent* event) { if (!native_wrapper_) - return ui::ER_UNHANDLED; - return native_wrapper_->GetView()->OnGestureEvent(event); + return; + native_wrapper_->GetView()->OnGestureEvent(event); } bool NativeScrollBar::OnMouseWheel(const ui::MouseWheelEvent& event) { diff --git a/ui/views/controls/scrollbar/native_scroll_bar.h b/ui/views/controls/scrollbar/native_scroll_bar.h index c15cb60..c105f29 100644 --- a/ui/views/controls/scrollbar/native_scroll_bar.h +++ b/ui/views/controls/scrollbar/native_scroll_bar.h @@ -52,7 +52,7 @@ class VIEWS_EXPORT NativeScrollBar : public ScrollBar { virtual bool OnMouseWheel(const ui::MouseWheelEvent& e) OVERRIDE; // Overridden from ui::EventHandler. - virtual ui::EventResult OnGestureEvent(ui::GestureEvent* event) OVERRIDE; + virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; // Overridden from ScrollBar. virtual void Update(int viewport_size, diff --git a/ui/views/controls/slide_out_view.cc b/ui/views/controls/slide_out_view.cc index 058421d..2ecf3cd 100644 --- a/ui/views/controls/slide_out_view.cc +++ b/ui/views/controls/slide_out_view.cc @@ -19,7 +19,7 @@ SlideOutView::SlideOutView() SlideOutView::~SlideOutView() { } -ui::EventResult SlideOutView::OnGestureEvent(ui::GestureEvent* event) { +void SlideOutView::OnGestureEvent(ui::GestureEvent* event) { if (event->type() == ui::ET_SCROLL_FLING_START) { // The threshold for the fling velocity is computed empirically. // The unit is in pixels/second. @@ -27,14 +27,15 @@ ui::EventResult SlideOutView::OnGestureEvent(ui::GestureEvent* event) { if (fabsf(event->details().velocity_x()) > kFlingThresholdForClose) { SlideOutAndClose(event->details().velocity_x() < 0 ? SLIDE_LEFT : SLIDE_RIGHT); - return ui::ER_CONSUMED; + event->StopPropagation(); + return; } RestoreVisualState(); - return ui::ER_UNHANDLED; + return; } if (!event->IsScrollGestureEvent()) - return ui::ER_UNHANDLED; + return; if (event->type() == ui::ET_GESTURE_SCROLL_BEGIN) { gesture_scroll_amount_ = 0.f; @@ -52,12 +53,13 @@ ui::EventResult SlideOutView::OnGestureEvent(ui::GestureEvent* event) { float scrolled_ratio = fabsf(gesture_scroll_amount_) / width(); if (scrolled_ratio >= kScrollRatioForClosingNotification) { SlideOutAndClose(gesture_scroll_amount_ < 0 ? SLIDE_LEFT : SLIDE_RIGHT); - return ui::ER_CONSUMED; + event->StopPropagation(); + return; } RestoreVisualState(); } - return ui::ER_HANDLED; + event->SetHandled(); } void SlideOutView::RestoreVisualState() { diff --git a/ui/views/controls/slide_out_view.h b/ui/views/controls/slide_out_view.h index eeeba18..4d36dc4 100644 --- a/ui/views/controls/slide_out_view.h +++ b/ui/views/controls/slide_out_view.h @@ -23,7 +23,7 @@ class VIEWS_EXPORT SlideOutView : public views::View, virtual void OnSlideOut() = 0; // Overridden from views::View. - virtual ui::EventResult OnGestureEvent(ui::GestureEvent* event) OVERRIDE; + virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; private: enum SlideDirection { diff --git a/ui/views/controls/slider.cc b/ui/views/controls/slider.cc index 99a0a9f..b6d07e1 100644 --- a/ui/views/controls/slider.cc +++ b/ui/views/controls/slider.cc @@ -291,19 +291,17 @@ bool Slider::OnKeyPressed(const ui::KeyEvent& event) { return false; } -ui::EventResult Slider::OnGestureEvent(ui::GestureEvent* event) { +void Slider::OnGestureEvent(ui::GestureEvent* event) { if (event->type() == ui::ET_GESTURE_SCROLL_BEGIN || event->type() == ui::ET_GESTURE_TAP_DOWN) { PrepareForMove(event->location()); MoveButtonTo(event->location()); - return ui::ER_CONSUMED; - } else - if (event->type() == ui::ET_GESTURE_SCROLL_UPDATE || - event->type() == ui::ET_GESTURE_SCROLL_END) { + event->SetHandled(); + } else if (event->type() == ui::ET_GESTURE_SCROLL_UPDATE || + event->type() == ui::ET_GESTURE_SCROLL_END) { MoveButtonTo(event->location()); - return ui::ER_CONSUMED; + event->SetHandled(); } - return ui::ER_UNHANDLED; } void Slider::AnimationProgressed(const ui::Animation* animation) { diff --git a/ui/views/controls/slider.h b/ui/views/controls/slider.h index 3b6338c..5cfd3f5 100644 --- a/ui/views/controls/slider.h +++ b/ui/views/controls/slider.h @@ -94,7 +94,7 @@ class VIEWS_EXPORT Slider : public View, virtual void OnPaintFocusBorder(gfx::Canvas* canvas) OVERRIDE; // ui::EventHandler overrides: - virtual ui::EventResult OnGestureEvent(ui::GestureEvent* event) OVERRIDE; + virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; // ui::AnimationDelegate overrides: virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE; diff --git a/ui/views/controls/textfield/native_textfield_views.cc b/ui/views/controls/textfield/native_textfield_views.cc index 5be141a..c3d489e 100644 --- a/ui/views/controls/textfield/native_textfield_views.cc +++ b/ui/views/controls/textfield/native_textfield_views.cc @@ -143,10 +143,10 @@ void NativeTextfieldViews::OnMouseReleased(const ui::MouseEvent& event) { OnAfterUserAction(); } -ui::EventResult NativeTextfieldViews::OnGestureEvent(ui::GestureEvent* event) { - ui::EventResult status = textfield_->OnGestureEvent(event); - if (status != ui::ER_UNHANDLED) - return status; +void NativeTextfieldViews::OnGestureEvent(ui::GestureEvent* event) { + textfield_->OnGestureEvent(event); + if (event->handled()) + return; switch (event->type()) { case ui::ET_GESTURE_TAP_DOWN: @@ -158,20 +158,23 @@ ui::EventResult NativeTextfieldViews::OnGestureEvent(ui::GestureEvent* event) { MoveCursorTo(event->location(), false)) SchedulePaint(); OnAfterUserAction(); - return ui::ER_CONSUMED; + event->SetHandled(); + return; case ui::ET_GESTURE_DOUBLE_TAP: SelectAll(false); - return ui::ER_CONSUMED; + event->SetHandled(); + return; case ui::ET_GESTURE_SCROLL_UPDATE: OnBeforeUserAction(); if (MoveCursorTo(event->location(), true)) SchedulePaint(); OnAfterUserAction(); - return ui::ER_CONSUMED; + event->SetHandled(); + return; default: break; } - return TouchSelectionClientView::OnGestureEvent(event); + TouchSelectionClientView::OnGestureEvent(event); } bool NativeTextfieldViews::OnKeyPressed(const ui::KeyEvent& event) { diff --git a/ui/views/controls/textfield/native_textfield_views.h b/ui/views/controls/textfield/native_textfield_views.h index a3004ee..822bab8 100644 --- a/ui/views/controls/textfield/native_textfield_views.h +++ b/ui/views/controls/textfield/native_textfield_views.h @@ -61,7 +61,7 @@ class VIEWS_EXPORT NativeTextfieldViews : public TouchSelectionClientView, virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE; virtual bool OnMouseDragged(const ui::MouseEvent& event) OVERRIDE; virtual void OnMouseReleased(const ui::MouseEvent& event) OVERRIDE; - virtual ui::EventResult OnGestureEvent(ui::GestureEvent* event) OVERRIDE; + virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; virtual bool OnKeyPressed(const ui::KeyEvent& event) OVERRIDE; virtual bool GetDropFormats( int* formats, diff --git a/ui/views/controls/tree/tree_view_views.cc b/ui/views/controls/tree/tree_view_views.cc index 3f6b4c4..e030f71 100644 --- a/ui/views/controls/tree/tree_view_views.cc +++ b/ui/views/controls/tree/tree_view_views.cc @@ -302,13 +302,12 @@ bool TreeView::OnMousePressed(const ui::MouseEvent& event) { return OnClickOrTap(event); } -ui::EventResult TreeView::OnGestureEvent(ui::GestureEvent* event) { +void TreeView::OnGestureEvent(ui::GestureEvent* event) { if (event->type() == ui::ET_GESTURE_TAP || event->type() == ui::ET_GESTURE_DOUBLE_TAP) { if (OnClickOrTap(*event)) - return ui::ER_CONSUMED; + event->SetHandled(); } - return ui::ER_UNHANDLED; } void TreeView::ShowContextMenu(const gfx::Point& p, bool is_mouse_gesture) { diff --git a/ui/views/controls/tree/tree_view_views.h b/ui/views/controls/tree/tree_view_views.h index 35488d0..47018b0 100644 --- a/ui/views/controls/tree/tree_view_views.h +++ b/ui/views/controls/tree/tree_view_views.h @@ -108,7 +108,7 @@ class VIEWS_EXPORT TreeView : public View, virtual void Layout() OVERRIDE; virtual gfx::Size GetPreferredSize() OVERRIDE; virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE; - virtual ui::EventResult OnGestureEvent(ui::GestureEvent* event) OVERRIDE; + virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; virtual void ShowContextMenu(const gfx::Point& p, bool is_mouse_gesture) OVERRIDE; virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; diff --git a/ui/views/corewm/compound_event_filter.cc b/ui/views/corewm/compound_event_filter.cc index 87c4981..fe83efd 100644 --- a/ui/views/corewm/compound_event_filter.cc +++ b/ui/views/corewm/compound_event_filter.cc @@ -242,15 +242,13 @@ ui::EventResult CompoundEventFilter::OnTouchEvent(ui::TouchEvent* event) { return result; } -ui::EventResult CompoundEventFilter::OnGestureEvent(ui::GestureEvent* event) { - int result = ui::ER_UNHANDLED; +void CompoundEventFilter::OnGestureEvent(ui::GestureEvent* event) { if (handlers_.might_have_observers()) { ObserverListBase<ui::EventHandler>::Iterator it(handlers_); ui::EventHandler* handler; - while (!(result & ui::ER_CONSUMED) && (handler = it.GetNext()) != NULL) - result |= handler->OnGestureEvent(event); + while (!event->stopped_propagation() && (handler = it.GetNext()) != NULL) + handler->OnGestureEvent(event); } - return static_cast<ui::EventResult>(result); } } // namespace corewm diff --git a/ui/views/corewm/compound_event_filter.h b/ui/views/corewm/compound_event_filter.h index 9999569..a995fb6 100644 --- a/ui/views/corewm/compound_event_filter.h +++ b/ui/views/corewm/compound_event_filter.h @@ -82,7 +82,7 @@ class VIEWS_EXPORT CompoundEventFilter : public ui::EventHandler { 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 ui::EventResult OnGestureEvent(ui::GestureEvent* event) OVERRIDE; + virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; // Additional pre-target event handlers. ObserverList<ui::EventHandler, true> handlers_; diff --git a/ui/views/corewm/compound_event_filter_unittest.cc b/ui/views/corewm/compound_event_filter_unittest.cc index 677d267..f8af783 100644 --- a/ui/views/corewm/compound_event_filter_unittest.cc +++ b/ui/views/corewm/compound_event_filter_unittest.cc @@ -64,8 +64,8 @@ class ConsumeGestureEventFilter : public ui::EventHandler { private: // Overridden from ui::EventHandler: - virtual ui::EventResult OnGestureEvent(ui::GestureEvent* e) OVERRIDE { - return ui::ER_CONSUMED; + virtual void OnGestureEvent(ui::GestureEvent* e) OVERRIDE { + e->StopPropagation(); } DISALLOW_COPY_AND_ASSIGN(ConsumeGestureEventFilter); diff --git a/ui/views/corewm/focus_controller.cc b/ui/views/corewm/focus_controller.cc index 2d89a34..90b4863 100644 --- a/ui/views/corewm/focus_controller.cc +++ b/ui/views/corewm/focus_controller.cc @@ -167,12 +167,11 @@ ui::EventResult FocusController::OnTouchEvent(ui::TouchEvent* event) { return ui::ER_UNHANDLED; } -ui::EventResult FocusController::OnGestureEvent(ui::GestureEvent* event) { +void FocusController::OnGestureEvent(ui::GestureEvent* event) { if (event->type() == ui::ET_GESTURE_BEGIN && event->details().touch_points() == 1) { WindowFocusedFromInputEvent(static_cast<aura::Window*>(event->target())); } - return ui::ER_UNHANDLED; } //////////////////////////////////////////////////////////////////////////////// diff --git a/ui/views/corewm/focus_controller.h b/ui/views/corewm/focus_controller.h index aebcb1d..12e3d4c 100644 --- a/ui/views/corewm/focus_controller.h +++ b/ui/views/corewm/focus_controller.h @@ -71,7 +71,7 @@ class VIEWS_EXPORT FocusController : public aura::client::ActivationClient, 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 ui::EventResult OnGestureEvent(ui::GestureEvent* event) OVERRIDE; + virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; // Overridden from aura::WindowObserver: virtual void OnWindowVisibilityChanging(aura::Window* window, diff --git a/ui/views/view.cc b/ui/views/view.cc index 5c96c3c..1ec3d9a 100644 --- a/ui/views/view.cc +++ b/ui/views/view.cc @@ -883,8 +883,7 @@ ui::EventResult View::OnTouchEvent(ui::TouchEvent* event) { return ui::ER_UNHANDLED; } -ui::EventResult View::OnGestureEvent(ui::GestureEvent* event) { - return ui::ER_UNHANDLED; +void View::OnGestureEvent(ui::GestureEvent* event) { } ui::TextInputClient* View::GetTextInputClient() { @@ -1999,10 +1998,10 @@ ui::EventResult View::ProcessTouchEvent(ui::TouchEvent* event) { return OnTouchEvent(event); } -ui::EventResult View::ProcessGestureEvent(ui::GestureEvent* event) { - ui::EventResult status = OnGestureEvent(event); - if (status != ui::ER_UNHANDLED) - return status; +void View::ProcessGestureEvent(ui::GestureEvent* event) { + OnGestureEvent(event); + if (event->handled()) + return; if (CommandLine::ForCurrentProcess()->HasSwitch( switches::kEnableTouchDragDrop)) { @@ -2010,8 +2009,10 @@ ui::EventResult View::ProcessGestureEvent(ui::GestureEvent* event) { (!drag_controller_ || drag_controller_->CanStartDragForView( this, event->location(), event->location()))) { if (DoDrag(*event, event->location(), - ui::DragDropTypes::DRAG_EVENT_SOURCE_TOUCH)) - return ui::ER_CONSUMED; + ui::DragDropTypes::DRAG_EVENT_SOURCE_TOUCH)) { + event->StopPropagation(); + return; + } } } @@ -2022,9 +2023,8 @@ ui::EventResult View::ProcessGestureEvent(ui::GestureEvent* event) { gfx::Point location(event->location()); ConvertPointToScreen(this, &location); ShowContextMenu(location, true); - return ui::ER_CONSUMED; + event->StopPropagation(); } - return status; } // Accelerators ---------------------------------------------------------------- diff --git a/ui/views/view.h b/ui/views/view.h index e080008..edec526 100644 --- a/ui/views/view.h +++ b/ui/views/view.h @@ -655,7 +655,7 @@ class VIEWS_EXPORT View : public ui::LayerDelegate, 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 ui::EventResult OnGestureEvent(ui::GestureEvent* event) OVERRIDE; + virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; // Accelerators -------------------------------------------------------------- @@ -1300,9 +1300,9 @@ class VIEWS_EXPORT View : public ui::LayerDelegate, // of OnTouchEvent. ui::EventResult ProcessTouchEvent(ui::TouchEvent* event); - // RootView will invoke this with incoming GestureEvents. This will invoke - // OnGestureEvent and return the result. - ui::EventResult ProcessGestureEvent(ui::GestureEvent* event); + // RootView will invoke this with incoming GestureEvents. This invokes + // OnGestureEvent. + void ProcessGestureEvent(ui::GestureEvent* event); // Accelerators -------------------------------------------------------------- diff --git a/ui/views/view_unittest.cc b/ui/views/view_unittest.cc index 363c904..2e0a98b 100644 --- a/ui/views/view_unittest.cc +++ b/ui/views/view_unittest.cc @@ -234,7 +234,7 @@ class TestView : public View { virtual ui::EventResult OnTouchEvent(ui::TouchEvent* event) OVERRIDE; // Ignores GestureEvent by default. - virtual ui::EventResult OnGestureEvent(ui::GestureEvent* event) OVERRIDE; + virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; virtual void Paint(gfx::Canvas* canvas) OVERRIDE; virtual void SchedulePaintInRect(const gfx::Rect& rect) OVERRIDE; @@ -287,10 +287,10 @@ class TestViewConsumeGesture : public TestView { virtual ~TestViewConsumeGesture() {} protected: - virtual ui::EventResult OnGestureEvent(ui::GestureEvent* event) OVERRIDE { + virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE { last_gesture_event_type_ = event->type(); location_.SetPoint(event->x(), event->y()); - return ui::ER_CONSUMED; + event->StopPropagation(); } private: @@ -304,8 +304,7 @@ class TestViewIgnoreGesture: public TestView { virtual ~TestViewIgnoreGesture() {} private: - virtual ui::EventResult OnGestureEvent(ui::GestureEvent* event) OVERRIDE { - return ui::ER_UNHANDLED; + virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE { } DISALLOW_COPY_AND_ASSIGN(TestViewIgnoreGesture); @@ -319,10 +318,10 @@ class TestViewIgnoreScrollGestures : public TestViewConsumeGesture { virtual ~TestViewIgnoreScrollGestures() {} private: - virtual ui::EventResult OnGestureEvent(ui::GestureEvent* event) OVERRIDE { + virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE { if (event->IsScrollGestureEvent()) - return ui::ER_UNHANDLED; - return TestViewConsumeGesture::OnGestureEvent(event); + return; + TestViewConsumeGesture::OnGestureEvent(event); } DISALLOW_COPY_AND_ASSIGN(TestViewIgnoreScrollGestures); @@ -594,8 +593,7 @@ TEST_F(ViewTest, TouchEvent) { widget->CloseNow(); } -ui::EventResult TestView::OnGestureEvent(ui::GestureEvent* event) { - return ui::ER_UNHANDLED; +void TestView::OnGestureEvent(ui::GestureEvent* event) { } TEST_F(ViewTest, GestureEvent) { diff --git a/ui/views/widget/desktop_aura/desktop_activation_client.cc b/ui/views/widget/desktop_aura/desktop_activation_client.cc index b53feba..a099e48 100644 --- a/ui/views/widget/desktop_aura/desktop_activation_client.cc +++ b/ui/views/widget/desktop_aura/desktop_activation_client.cc @@ -164,13 +164,11 @@ ui::EventResult DesktopActivationClient::OnTouchEvent(ui::TouchEvent* event) { return ui::ER_UNHANDLED; } -ui::EventResult DesktopActivationClient::OnGestureEvent( - ui::GestureEvent* event) { +void DesktopActivationClient::OnGestureEvent(ui::GestureEvent* event) { if (event->type() == ui::ET_GESTURE_BEGIN && event->details().touch_points() == 1) { FocusWindowWithEvent(event); } - return ui::ER_UNHANDLED; } void DesktopActivationClient::FocusWindowWithEvent(const ui::Event* event) { diff --git a/ui/views/widget/desktop_aura/desktop_activation_client.h b/ui/views/widget/desktop_aura/desktop_activation_client.h index 87b1299..55ade7f 100644 --- a/ui/views/widget/desktop_aura/desktop_activation_client.h +++ b/ui/views/widget/desktop_aura/desktop_activation_client.h @@ -62,7 +62,7 @@ class VIEWS_EXPORT DesktopActivationClient 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 ui::EventResult OnGestureEvent(ui::GestureEvent* event) OVERRIDE; + virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; private: void FocusWindowWithEvent(const ui::Event* event); diff --git a/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc b/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc index 87b8bf1..870b878 100644 --- a/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc +++ b/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc @@ -572,9 +572,8 @@ ui::EventResult DesktopNativeWidgetAura::OnTouchEvent(ui::TouchEvent* event) { return native_widget_delegate_->OnTouchEvent(event); } -ui::EventResult DesktopNativeWidgetAura::OnGestureEvent( - ui::GestureEvent* event) { - return native_widget_delegate_->OnGestureEvent(event); +void DesktopNativeWidgetAura::OnGestureEvent(ui::GestureEvent* event) { + native_widget_delegate_->OnGestureEvent(event); } //////////////////////////////////////////////////////////////////////////////// diff --git a/ui/views/widget/desktop_aura/desktop_native_widget_aura.h b/ui/views/widget/desktop_aura/desktop_native_widget_aura.h index 742b133..b3abe0f 100644 --- a/ui/views/widget/desktop_aura/desktop_native_widget_aura.h +++ b/ui/views/widget/desktop_aura/desktop_native_widget_aura.h @@ -153,7 +153,7 @@ class VIEWS_EXPORT DesktopNativeWidgetAura 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 ui::EventResult OnGestureEvent(ui::GestureEvent* event) OVERRIDE; + virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; // Overridden from aura::client::ActivationDelegate: virtual bool ShouldActivate() const OVERRIDE; diff --git a/ui/views/widget/native_widget_aura.cc b/ui/views/widget/native_widget_aura.cc index f0779c3..0d804a6 100644 --- a/ui/views/widget/native_widget_aura.cc +++ b/ui/views/widget/native_widget_aura.cc @@ -841,9 +841,9 @@ ui::EventResult NativeWidgetAura::OnTouchEvent(ui::TouchEvent* event) { return delegate_->OnTouchEvent(event); } -ui::EventResult NativeWidgetAura::OnGestureEvent(ui::GestureEvent* event) { +void NativeWidgetAura::OnGestureEvent(ui::GestureEvent* event) { DCHECK(window_->IsVisible()); - return delegate_->OnGestureEvent(event); + delegate_->OnGestureEvent(event); } //////////////////////////////////////////////////////////////////////////////// diff --git a/ui/views/widget/native_widget_aura.h b/ui/views/widget/native_widget_aura.h index 623e9b8..7a7474e 100644 --- a/ui/views/widget/native_widget_aura.h +++ b/ui/views/widget/native_widget_aura.h @@ -157,7 +157,7 @@ class VIEWS_EXPORT NativeWidgetAura : public internal::NativeWidgetPrivate, 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 ui::EventResult OnGestureEvent(ui::GestureEvent* event) OVERRIDE; + virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; // Overridden from aura::client::ActivationDelegate: virtual bool ShouldActivate() const OVERRIDE; diff --git a/ui/views/widget/native_widget_aura_unittest.cc b/ui/views/widget/native_widget_aura_unittest.cc index f0db7c2..7e06b79 100644 --- a/ui/views/widget/native_widget_aura_unittest.cc +++ b/ui/views/widget/native_widget_aura_unittest.cc @@ -216,9 +216,10 @@ class GestureTrackingView : public views::View { } // View overrides: - virtual ui::EventResult OnGestureEvent(ui::GestureEvent* event) OVERRIDE { + virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE { got_gesture_event_ = true; - return consume_gesture_event_ ? ui::ER_CONSUMED : ui::ER_UNHANDLED; + if (consume_gesture_event_) + event->StopPropagation(); } private: diff --git a/ui/views/widget/native_widget_delegate.h b/ui/views/widget/native_widget_delegate.h index 29ab54f..bc82cdc 100644 --- a/ui/views/widget/native_widget_delegate.h +++ b/ui/views/widget/native_widget_delegate.h @@ -112,7 +112,7 @@ class VIEWS_EXPORT NativeWidgetDelegate { virtual ui::EventResult OnTouchEvent(ui::TouchEvent* event) = 0; virtual ui::EventResult OnScrollEvent(ui::ScrollEvent* event) = 0; - virtual ui::EventResult OnGestureEvent(ui::GestureEvent* event) = 0; + virtual void OnGestureEvent(ui::GestureEvent* event) = 0; // Runs the specified native command. Returns true if the command is handled. virtual bool ExecuteCommand(int command_id) = 0; diff --git a/ui/views/widget/root_view.cc b/ui/views/widget/root_view.cc index 4dc3980..3593424 100644 --- a/ui/views/widget/root_view.cc +++ b/ui/views/widget/root_view.cc @@ -196,9 +196,7 @@ ui::EventResult RootView::DispatchTouchEvent(ui::TouchEvent* event) { return status; } -ui::EventResult RootView::DispatchGestureEvent(ui::GestureEvent* event) { - ui::EventResult status = ui::ER_UNHANDLED; - +void RootView::DispatchGestureEvent(ui::GestureEvent* event) { if (gesture_handler_) { // |gesture_handler_| (or |scroll_gesture_handler_|) can be deleted during // processing. @@ -206,8 +204,7 @@ ui::EventResult RootView::DispatchGestureEvent(ui::GestureEvent* event) { (event->IsScrollGestureEvent() || event->IsFlingScrollEvent()) ? scroll_gesture_handler_ : gesture_handler_; ui::GestureEvent handler_event(*event, static_cast<View*>(this), handler); - - ui::EventResult status = handler->ProcessGestureEvent(&handler_event); + handler->ProcessGestureEvent(&handler_event); if (event->type() == ui::ET_GESTURE_END && event->details().touch_points() <= 1) { @@ -225,10 +222,13 @@ ui::EventResult RootView::DispatchGestureEvent(ui::GestureEvent* event) { scroll_gesture_handler_ = NULL; } - if (status == ui::ER_CONSUMED) - return status; - - DCHECK_EQ(ui::ER_UNHANDLED, status); + if (handler_event.stopped_propagation()) { + event->StopPropagation(); + return; + } else if (handler_event.handled()) { + event->SetHandled(); + return; + } if (event->type() == ui::ET_GESTURE_SCROLL_BEGIN && !scroll_gesture_handler_) { @@ -241,14 +241,19 @@ ui::EventResult RootView::DispatchGestureEvent(ui::GestureEvent* event) { scroll_gesture_handler_ = scroll_gesture_handler_->parent()) { ui::GestureEvent gesture_event(*event, static_cast<View*>(this), scroll_gesture_handler_); - status = scroll_gesture_handler_->ProcessGestureEvent(&gesture_event); - if (status == ui::ER_CONSUMED) - return status; + scroll_gesture_handler_->ProcessGestureEvent(&gesture_event); + if (gesture_event.stopped_propagation()) { + event->StopPropagation(); + return; + } else if (gesture_event.handled()) { + event->SetHandled(); + return; + } } scroll_gesture_handler_ = NULL; } - return ui::ER_UNHANDLED; + return; } // Walk up the tree until we find a view that wants the gesture event. @@ -257,34 +262,35 @@ ui::EventResult RootView::DispatchGestureEvent(ui::GestureEvent* event) { gesture_handler_ = gesture_handler_->parent()) { if (!gesture_handler_->enabled()) { // Disabled views eat events but are treated as not handled. - return ui::ER_UNHANDLED; + return; } // See if this view wants to handle the Gesture. ui::GestureEvent gesture_event(*event, static_cast<View*>(this), gesture_handler_); - status = gesture_handler_->ProcessGestureEvent(&gesture_event); + gesture_handler_->ProcessGestureEvent(&gesture_event); // The view could have removed itself from the tree when handling // OnGestureEvent(). So handle as per OnMousePressed. NB: we // assume that the RootView itself cannot be so removed. if (!gesture_handler_) - return ui::ER_UNHANDLED; + return; - if (status == ui::ER_CONSUMED) { + if (gesture_event.handled()) { if (gesture_event.type() == ui::ET_GESTURE_SCROLL_BEGIN) scroll_gesture_handler_ = gesture_handler_; - return status; + if (gesture_event.stopped_propagation()) + event->StopPropagation(); + else + event->SetHandled(); + return; } // The gesture event wasn't processed. Go up the view hierarchy and // dispatch the gesture event. - DCHECK_EQ(ui::ER_UNHANDLED, status); } gesture_handler_ = NULL; - - return status; } // Focus ----------------------------------------------------------------------- diff --git a/ui/views/widget/root_view.h b/ui/views/widget/root_view.h index 66ff49b..c87692d 100644 --- a/ui/views/widget/root_view.h +++ b/ui/views/widget/root_view.h @@ -64,7 +64,7 @@ class VIEWS_EXPORT RootView : public View, public FocusTraversable { ui::EventResult DispatchKeyEvent(const ui::KeyEvent& event); ui::EventResult DispatchScrollEvent(ui::ScrollEvent* event); ui::EventResult DispatchTouchEvent(ui::TouchEvent* event); - virtual ui::EventResult DispatchGestureEvent(ui::GestureEvent* event); + virtual void DispatchGestureEvent(ui::GestureEvent* event); // Focus --------------------------------------------------------------------- diff --git a/ui/views/widget/widget.cc b/ui/views/widget/widget.cc index 9942c3d..457e1fe 100644 --- a/ui/views/widget/widget.cc +++ b/ui/views/widget/widget.cc @@ -1170,7 +1170,7 @@ ui::EventResult Widget::OnScrollEvent(ui::ScrollEvent* event) { DispatchScrollEvent(event); } -ui::EventResult Widget::OnGestureEvent(ui::GestureEvent* event) { +void Widget::OnGestureEvent(ui::GestureEvent* event) { ScopedEvent scoped(this, *event); switch (event->type()) { case ui::ET_GESTURE_TAP_DOWN: @@ -1191,8 +1191,7 @@ ui::EventResult Widget::OnGestureEvent(ui::GestureEvent* event) { default: break; } - return static_cast<internal::RootView*>(GetRootView())-> - DispatchGestureEvent(event); + static_cast<internal::RootView*>(GetRootView())->DispatchGestureEvent(event); } bool Widget::ExecuteCommand(int command_id) { diff --git a/ui/views/widget/widget.h b/ui/views/widget/widget.h index 139c69a..3daac12 100644 --- a/ui/views/widget/widget.h +++ b/ui/views/widget/widget.h @@ -659,7 +659,7 @@ class VIEWS_EXPORT Widget : public internal::NativeWidgetDelegate, virtual void OnMouseCaptureLost() OVERRIDE; virtual ui::EventResult OnTouchEvent(ui::TouchEvent* event) OVERRIDE; virtual ui::EventResult OnScrollEvent(ui::ScrollEvent* event) OVERRIDE; - virtual ui::EventResult OnGestureEvent(ui::GestureEvent* event) OVERRIDE; + virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; virtual bool ExecuteCommand(int command_id) OVERRIDE; virtual InputMethod* GetInputMethodDirect() OVERRIDE; virtual const std::vector<ui::Layer*>& GetRootLayers() OVERRIDE; diff --git a/ui/views/widget/widget_unittest.cc b/ui/views/widget/widget_unittest.cc index 44fa495..f4d9381 100644 --- a/ui/views/widget/widget_unittest.cc +++ b/ui/views/widget/widget_unittest.cc @@ -127,12 +127,11 @@ class GestureCaptureView : public View { private: // Overridden from View: - virtual ui::EventResult OnGestureEvent(ui::GestureEvent* event) OVERRIDE { + virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE { if (event->type() == ui::ET_GESTURE_BEGIN) { GetWidget()->SetCapture(this); - return ui::ER_CONSUMED; + event->StopPropagation(); } - return ui::ER_UNHANDLED; } DISALLOW_COPY_AND_ASSIGN(GestureCaptureView); |