Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(305)

Issue 22891016: Add support for rect-based event targeting in views (Closed)

Created:
7 years, 4 months ago by tdanderson
Modified:
7 years, 1 month ago
CC:
chromium-reviews, tfarina, cc-bugs_chromium.org, James Su, ben+watch_chromium.org, danakj+watch_chromium.org
Visibility:
Public.

Description

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 R=sky@chromium.org Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=232891

Patch Set 1 #

Patch Set 2 : Still a WIP, not for review #

Patch Set 3 : Still a WIP, not for review #

Patch Set 4 : Still a WIP, not for review #

Patch Set 5 : WIP #

Total comments: 13

Patch Set 6 : comments addressed #

Total comments: 2

Patch Set 7 : hit test mask WIP, not for review #

Patch Set 8 : tab strip problems addressed #

Total comments: 15

Patch Set 9 : comments addressed, moved fuzzing utility functions to new file #

Total comments: 4

Patch Set 10 : HitTestSource added #

Patch Set 11 : rect_based_targeting_utils landed in r228916 #

Patch Set 12 : rect conversion utilities landed in r229711 #

Patch Set 13 : call ToEnclosingRect() after ConvertRectToTarget() #

Patch Set 14 : switch added #

Patch Set 15 : switch with proper ifdefs #

Patch Set 16 : double to float truncation error #

Patch Set 17 : ViewTest.HitTestMasks should pass #

Patch Set 18 : WIP, not for review #

Patch Set 19 : tests added #

Total comments: 6

Patch Set 20 : switch ifdefs removed, patch tested on Windows #

Patch Set 21 : rebase after hit test mask patch landed (r232797) #

Patch Set 22 : removed redefinition of HitTestSource #

Patch Set 23 : patch for landing #

Unified diffs Side-by-side diffs Delta from patch set Stats (+514 lines, -98 lines) Patch
M chrome/app/generated_resources.grd View 1 chunk +6 lines, -0 lines 0 comments Download
M chrome/browser/about_flags.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 2 chunks +10 lines, -0 lines 0 comments Download
M chrome/browser/ui/views/autofill/autofill_dialog_views.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 1 chunk +1 line, -1 line 0 comments Download
M chrome/browser/ui/views/autofill/autofill_dialog_views.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 1 chunk +7 lines, -4 lines 0 comments Download
M chrome/browser/ui/views/autofill/decorated_textfield.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 1 chunk +1 line, -2 lines 0 comments Download
M chrome/browser/ui/views/autofill/decorated_textfield.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 1 chunk +1 line, -2 lines 0 comments Download
M chrome/browser/ui/views/frame/browser_non_client_frame_view_ash.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 3 chunks +12 lines, -17 lines 0 comments Download
M chrome/browser/ui/views/frame/opaque_browser_frame_view.cc View 1 2 3 4 5 6 7 8 9 10 11 12 5 chunks +16 lines, -22 lines 0 comments Download
M chrome/browser/ui/views/omnibox/omnibox_popup_contents_view.h View 1 2 3 4 5 6 1 chunk +2 lines, -2 lines 0 comments Download
M chrome/browser/ui/views/omnibox/omnibox_popup_contents_view.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 1 chunk +2 lines, -2 lines 0 comments Download
M chrome/browser/ui/views/tabs/tab.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 2 chunks +11 lines, -5 lines 0 comments Download
M chrome/browser/ui/views/tabs/tab_strip.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 2 chunks +5 lines, -2 lines 0 comments Download
M chrome/browser/ui/views/tabs/tab_strip.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 3 chunks +20 lines, -9 lines 0 comments Download
M ui/message_center/views/notification_view.h View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +1 line, -2 lines 0 comments Download
M ui/message_center/views/notification_view.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 1 chunk +6 lines, -2 lines 0 comments Download
M ui/views/view.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 1 chunk +14 lines, -6 lines 0 comments Download
M ui/views/view.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 2 chunks +71 lines, -7 lines 0 comments Download
M ui/views/view_unittest.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 1 chunk +246 lines, -0 lines 0 comments Download
M ui/views/views.gyp View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 1 chunk +2 lines, -0 lines 0 comments Download
A ui/views/views_switches.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 1 chunk +24 lines, -0 lines 0 comments Download
A ui/views/views_switches.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 1 chunk +24 lines, -0 lines 0 comments Download
M ui/views/widget/root_view.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 2 chunks +16 lines, -3 lines 0 comments Download
M ui/views/window/non_client_view.h View 1 2 3 1 chunk +1 line, -2 lines 0 comments Download
M ui/views/window/non_client_view.cc View 1 2 3 4 5 6 7 8 9 10 11 12 3 chunks +15 lines, -8 lines 0 comments Download

Messages

Total messages: 32 (0 generated)
tdanderson
@sky, would you mind taking a look at Patch Set 5? I'm not looking for ...
7 years, 3 months ago (2013-09-04 21:48:12 UTC) #1
danakj
https://codereview.chromium.org/22891016/diff/26001/ui/gfx/point_conversions.h File ui/gfx/point_conversions.h (right): https://codereview.chromium.org/22891016/diff/26001/ui/gfx/point_conversions.h#newcode19 ui/gfx/point_conversions.h:19: UI_EXPORT Rect ToFlooredRect(const RectF& rect); not lgtm on this. ...
7 years, 3 months ago (2013-09-05 19:10:07 UTC) #2
sky
On Wed, Sep 4, 2013 at 2:48 PM, <tdanderson@chromium.org> wrote: > A large code review. ...
7 years, 3 months ago (2013-09-06 19:56:39 UTC) #3
sky
Here's an additional couple of comments for you. https://codereview.chromium.org/22891016/diff/26001/ui/views/view.cc File ui/views/view.cc (right): https://codereview.chromium.org/22891016/diff/26001/ui/views/view.cc#newcode859 ui/views/view.cc:859: View* ...
7 years, 3 months ago (2013-09-06 19:56:47 UTC) #4
tdanderson
My replies to sky's and danakj's comments along with an updated patch set 6. I ...
7 years, 3 months ago (2013-09-09 22:15:39 UTC) #5
danakj
Thanks Terry. Removing myself from reviewers in hopes that undoes my previous comment.
7 years, 3 months ago (2013-09-09 22:17:33 UTC) #6
danakj
Seems not, so LGTM on the zero changes to ui/gfx/
7 years, 3 months ago (2013-09-09 22:18:00 UTC) #7
tdanderson
> > > > My main concerns: > > - As a result of patch ...
7 years, 3 months ago (2013-09-09 22:30:51 UTC) #8
sky
AFAICT this approach has a couple of flaws for tabs, which if I understand is ...
7 years, 3 months ago (2013-09-10 16:47:41 UTC) #9
tdanderson
> AFAICT this approach has a couple of flaws for tabs, which if I understand ...
7 years, 2 months ago (2013-10-03 23:16:07 UTC) #10
tdanderson
Scott, can you please have a look at my changes in patch set 8 (specifically ...
7 years, 2 months ago (2013-10-03 23:17:42 UTC) #11
sky
On Thu, Oct 3, 2013 at 4:16 PM, <tdanderson@chromium.org> wrote: >> AFAICT this approach has ...
7 years, 2 months ago (2013-10-04 16:57:02 UTC) #12
sky
You need to write some tests too. I go back and forth on whether it's ...
7 years, 2 months ago (2013-10-04 17:03:48 UTC) #13
sky
https://codereview.chromium.org/22891016/diff/45001/chrome/browser/ui/views/tabs/tab.cc File chrome/browser/ui/views/tabs/tab.cc (right): https://codereview.chromium.org/22891016/diff/45001/chrome/browser/ui/views/tabs/tab.cc#newcode444 chrome/browser/ui/views/tabs/tab.cc:444: #if defined(USE_ASH) On 2013/10/03 23:17:42, tdanderson wrote: > If ...
7 years, 2 months ago (2013-10-04 17:05:13 UTC) #14
tdanderson
On 2013/10/04 16:57:02, sky wrote: > On Thu, Oct 3, 2013 at 4:16 PM, <mailto:tdanderson@chromium.org> ...
7 years, 2 months ago (2013-10-07 21:22:44 UTC) #15
tdanderson
On 2013/10/04 17:03:48, sky wrote: > You need to write some tests too. I definitely ...
7 years, 2 months ago (2013-10-07 21:28:52 UTC) #16
tdanderson
Please have a look at my changes and comments in Patch Set 9. https://codereview.chromium.org/22891016/diff/45001/chrome/browser/ui/views/tabs/tab.cc File ...
7 years, 2 months ago (2013-10-07 21:35:20 UTC) #17
Ben Goodger (Google)
i'd like some of the utility functions here to be relocated to ui/events, since I ...
7 years, 2 months ago (2013-10-07 22:59:55 UTC) #18
sky
On Mon, Oct 7, 2013 at 2:22 PM, <tdanderson@chromium.org> wrote: > On 2013/10/04 16:57:02, sky ...
7 years, 2 months ago (2013-10-07 23:01:24 UTC) #19
sky
https://codereview.chromium.org/22891016/diff/45001/chrome/browser/ui/views/tabs/tab.cc File chrome/browser/ui/views/tabs/tab.cc (right): https://codereview.chromium.org/22891016/diff/45001/chrome/browser/ui/views/tabs/tab.cc#newcode444 chrome/browser/ui/views/tabs/tab.cc:444: #if defined(USE_ASH) On 2013/10/07 21:35:21, tdanderson wrote: > On ...
7 years, 2 months ago (2013-10-08 15:39:06 UTC) #20
sky
https://codereview.chromium.org/22891016/diff/57001/ui/views/rect_based_targeting_utils.cc File ui/views/rect_based_targeting_utils.cc (right): https://codereview.chromium.org/22891016/diff/57001/ui/views/rect_based_targeting_utils.cc#newcode33 ui/views/rect_based_targeting_utils.cc:33: return rect_1_area ? (float)intersection_area / (float)rect_1_area : 0; use ...
7 years, 2 months ago (2013-10-08 20:01:11 UTC) #21
tdanderson
On 2013/10/07 22:59:55, Ben Goodger (Google) wrote: > i'd like some of the utility functions ...
7 years, 2 months ago (2013-10-09 21:20:36 UTC) #22
tdanderson
On 2013/10/07 23:01:24, sky wrote: > On Mon, Oct 7, 2013 at 2:22 PM, <mailto:tdanderson@chromium.org> ...
7 years, 2 months ago (2013-10-09 21:31:05 UTC) #23
tdanderson
On 2013/10/08 15:39:06, sky wrote: > https://codereview.chromium.org/22891016/diff/45001/chrome/browser/ui/views/tabs/tab.cc > File chrome/browser/ui/views/tabs/tab.cc (right): > > https://codereview.chromium.org/22891016/diff/45001/chrome/browser/ui/views/tabs/tab.cc#newcode444 > ...
7 years, 2 months ago (2013-10-09 21:32:23 UTC) #24
tdanderson
I will now start the process of splitting this up into smaller patches and adding ...
7 years, 2 months ago (2013-10-09 21:42:06 UTC) #25
tdanderson
Scott, would you mind having a look at Patch Set 19? Specifically, please look at: ...
7 years, 1 month ago (2013-10-29 23:36:56 UTC) #26
sky
https://codereview.chromium.org/22891016/diff/537001/chrome/browser/about_flags.cc File chrome/browser/about_flags.cc (right): https://codereview.chromium.org/22891016/diff/537001/chrome/browser/about_flags.cc#newcode1833 chrome/browser/about_flags.cc:1833: #if defined(OS_CHROMEOS) This should be TOOLKIT_VIEWS https://codereview.chromium.org/22891016/diff/537001/ui/views/views_switches.h File ui/views/views_switches.h ...
7 years, 1 month ago (2013-10-30 14:03:47 UTC) #27
tdanderson
Scott, can you please take another look? I have addressed your latest comments and have ...
7 years, 1 month ago (2013-10-30 20:55:47 UTC) #28
sky
I'm sure these are fine now. The bigger issue is addressing the concerns Ben has. ...
7 years, 1 month ago (2013-10-30 20:57:57 UTC) #29
sky
LGTM
7 years, 1 month ago (2013-11-04 22:16:21 UTC) #30
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/tdanderson@chromium.org/22891016/917001
7 years, 1 month ago (2013-11-04 23:22:56 UTC) #31
tdanderson
7 years, 1 month ago (2013-11-05 03:11:30 UTC) #32
Message was sent while issue was closed.
Committed patchset #23 manually as r232891 (presubmit successful).

Powered by Google App Engine
This is Rietveld 408576698