Add support for rect-based event targeting in views
Views currently only supports point-based event targeting,
meaning that the center point is the only location used
when determining the target of a touch region. This can
lead to a poor experience for touchscreen users because
a touch can overlap many more possible targets than a
mouse cursor and it is difficult to ensure that the center
of the touch region is over the intended target (especially
if that target is small, such as the tab close button).
The goal of this patch is to add support for rect-based
event targeting ("touch fuzzing") by using a heuristic
to determine the most probable target of a rectangular
region.
This heuristic is implemented in
View::GetEventHandlerForRect() by recursively looking for
targets among the descendants of |this| which the
touch region overlaps by at least 60% (and then returning
the one that is closest to the location of the touch). If
no such targets exist, instead return the target that would
have been returned if point-based event targeting were
used with the center point of the touch. The idea behind
this approach is that small targets are more difficult to
touch reliably than large targets, so small targets
should get priority when determining the most probable
target of a touch.
In this patch, all of the overrides of
View::GetEventHandlerForRect() (formerly
View::GetEventHandlerForPoint()) simply call
View::GetEventHandlerForPoint() directly if rect-based
event targeting is to be used. The two exceptions are
NotificationView and AutofillDialogViews::SectionContainer,
for which I have preserved the existing point-based
behavior for the time being (and have added TODOs to
implement rect-based targeting in a follow up patch).
BUG=129794,131208
TEST=ViewTest.GetEventHandlerForRect
[email protected]
Review URL: https://codereview.chromium.org/22891016
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@232891 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc
index 1fe5e77..4ef2cce 100644
--- a/chrome/browser/about_flags.cc
+++ b/chrome/browser/about_flags.cc
@@ -36,6 +36,7 @@
#include "ui/keyboard/keyboard_switches.h"
#include "ui/message_center/message_center_switches.h"
#include "ui/surface/surface_switches.h"
+#include "ui/views/views_switches.h"
#if defined(USE_ASH)
#include "ash/ash_switches.h"
@@ -1836,6 +1837,15 @@
kOsDesktop,
SINGLE_VALUE_TYPE(switches::kEnableTranslateNewUX)
},
+#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,
+ kOsCrOS | kOsWin,
+ SINGLE_VALUE_TYPE(views::switches::kViewsUseRectBasedTargeting)
+ },
+#endif
};
const Experiment* experiments = kExperiments;