From 88b47ad70d6e80ffbb0368a2b4ab9026761dbb66 Mon Sep 17 00:00:00 2001 From: "tdanderson@chromium.org" Date: Thu, 21 Nov 2013 03:34:38 +0000 Subject: [PATCH] Enable rect-based targeting in views by default Enables rect-based targeting in views by default for ChromeOS and Windows. BUG=321327 Review URL: https://codereview.chromium.org/76063008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@236387 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/app/generated_resources.grd | 8 ++++---- chrome/browser/about_flags.cc | 8 ++++---- ui/views/views_switches.cc | 13 +++++++++---- ui/views/views_switches.h | 4 ++-- ui/views/widget/root_view.cc | 3 ++- 5 files changed, 21 insertions(+), 15 deletions(-) diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd index 32fd3c237f11..fb77e71a54ae 100644 --- a/chrome/app/generated_resources.grd +++ b/chrome/app/generated_resources.grd @@ -6966,11 +6966,11 @@ Keep your key file in a safe place. You will need it to create new versions of y Enable the new Translate bubble UX is offered instead of the infobar. - - Rect-based targeting in views + + Disable rect-based targeting in views - - Use a heuristic to determine the most probable target of a gesture, where the touch region is represented by a rectangle. + + Disables rect-based targeting in views. Rect-based targeting uses a heuristic to determine the most probable target of a gesture, where the touch region is represented by a rectangle. Enable show-on-first-paint for apps. diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc index 365f982b0414..e6aef05b2063 100644 --- a/chrome/browser/about_flags.cc +++ b/chrome/browser/about_flags.cc @@ -1815,11 +1815,11 @@ const Experiment kExperiments[] = { }, #if defined(TOOLKIT_VIEWS) { - "views-use-rect-based-targeting", // FLAGS:RECORD_UMA - IDS_FLAGS_VIEWS_USE_RECT_BASED_TARGETING_NAME, - IDS_FLAGS_VIEWS_USE_RECT_BASED_TARGETING_DESCRIPTION, + "disable-views-rect-based-targeting", // FLAGS:RECORD_UMA + IDS_FLAGS_DISABLE_VIEWS_RECT_BASED_TARGETING_NAME, + IDS_FLAGS_DISABLE_VIEWS_RECT_BASED_TARGETING_DESCRIPTION, kOsCrOS | kOsWin, - SINGLE_VALUE_TYPE(views::switches::kViewsUseRectBasedTargeting) + SINGLE_VALUE_TYPE(views::switches::kDisableViewsRectBasedTargeting) }, #endif { diff --git a/ui/views/views_switches.cc b/ui/views/views_switches.cc index 819d39060cce..c62e83d1d8bc 100644 --- a/ui/views/views_switches.cc +++ b/ui/views/views_switches.cc @@ -13,11 +13,16 @@ namespace switches { // Specifies if a heuristic should be used to determine the most probable // target of a gesture, where the touch region is represented by a rectangle. -const char kViewsUseRectBasedTargeting[] = "views-use-rect-based-targeting"; +const char kDisableViewsRectBasedTargeting[] = + "disable-views-rect-based-targeting"; -bool UseRectBasedTargeting() { - return CommandLine::ForCurrentProcess()-> - HasSwitch(kViewsUseRectBasedTargeting); +bool IsRectBasedTargetingEnabled() { +#if defined(OS_CHROMEOS) || defined(OS_WIN) + return !CommandLine::ForCurrentProcess()-> + HasSwitch(kDisableViewsRectBasedTargeting); +#else + return false; +#endif } } // namespace switches diff --git a/ui/views/views_switches.h b/ui/views/views_switches.h index 67a2c8809c0b..9e5029476efa 100644 --- a/ui/views/views_switches.h +++ b/ui/views/views_switches.h @@ -13,10 +13,10 @@ namespace views { namespace switches { // Please keep alphabetized. -VIEWS_EXPORT extern const char kViewsUseRectBasedTargeting[]; +VIEWS_EXPORT extern const char kDisableViewsRectBasedTargeting[]; // Returns true if rect-based targeting in views should be used. -VIEWS_EXPORT bool UseRectBasedTargeting(); +VIEWS_EXPORT bool IsRectBasedTargetingEnabled(); } // namespace switches } // namespace views diff --git a/ui/views/widget/root_view.cc b/ui/views/widget/root_view.cc index 5f23bf6e516f..c825998d9144 100644 --- a/ui/views/widget/root_view.cc +++ b/ui/views/widget/root_view.cc @@ -288,7 +288,8 @@ void RootView::DispatchGestureEvent(ui::GestureEvent* event) { } View* gesture_handler = NULL; - if (views::switches::UseRectBasedTargeting()) { + if (views::switches::IsRectBasedTargetingEnabled() && + !event->details().bounding_box().IsEmpty()) { // TODO(tdanderson): Pass in the bounding box to GetEventHandlerForRect() // once crbug.com/313392 is resolved. gfx::Rect touch_rect(event->details().bounding_box()); -- 2.11.4.GIT