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

Issue 10790019: Add gesture target fuzzing to views (Closed)

Created:
8 years, 5 months ago by tdanderson
Modified:
7 years ago
Reviewers:
rjkroege, sadrul, sky
CC:
chromium-reviews, tfarina, ben+watch_chromium.org, sky, kevers
Base URL:
http://git.chromium.org/chromium/src.git@master
Visibility:
Public.

Description

Add gesture target fuzzing to views This CL appears to make gesture targeting in views significantly easier. Currently RootView::OnGestureEvent selects a tap target by using only the center point of the touch, which can lead to annoying unsuccessful tap gestures when the user attempts to target small views (e.g. closing a tab, bookmark star, opening a tab, etc.) This CL uses the bounding box information stored in a gesture event which is used for more accurate targeting in the following way: - Traverse the views tree looking for views that are overlapped by the touch region by at least 70%. - If there is at least one overlapped view: Among all such overlapped views, pick the one that is closest to the center of the touch region using a distance-to-center-line metric. This metric removes the bias of wide/tall rectangles to give a better notion of which view is closest to the center of the touch region. Set |gesture_handler_| to be this view. - Otherwise: Set |gesture_handler_| to be the return value of GetEventHandlerForPoint. Note that the bookmark star still seems slightly hard to touch at certain times. This is because some taps will fuzz to the 3px-wide resizer view located to the right of the bookmark star. To fix this, I can adjust the algorithm to try targeting all overlapped views in descending order of their distance to the touch center until the event is handled. I will address this in a separate CL if we feel that it is needed. BUG=129794 TEST=GestureEventWithFuzzing and GetEventHandlerForRect in view_unittest.cc

Patch Set 1 #

Total comments: 35

Patch Set 2 : New approach using GetEventHandlerForRect #

Total comments: 19

Patch Set 3 : Fuzzing performed on ET_GESTURE_BEGIN #

Total comments: 6

Patch Set 4 : sadrul's comments addressed #

Patch Set 5 : Patch with unit tests #

Total comments: 2

Patch Set 6 : sadrul's comments about testing addressed #

Total comments: 16

Patch Set 7 : sky's comments addressed, some further feedback needed #

Patch Set 8 : No longer using screen coordinates #

Total comments: 11
Unified diffs Side-by-side diffs Delta from patch set Stats (+575 lines, -8 lines) Patch
M ui/views/events/event.h View 1 2 3 4 5 6 2 chunks +4 lines, -0 lines 0 comments Download
M ui/views/events/event.cc View 1 2 3 4 5 2 chunks +8 lines, -5 lines 0 comments Download
M ui/views/view.h View 1 2 3 4 5 6 7 2 chunks +18 lines, -0 lines 0 comments Download
M ui/views/view.cc View 1 2 3 4 5 6 7 4 chunks +88 lines, -0 lines 11 comments Download
M ui/views/view_constants.h View 5 6 1 chunk +5 lines, -0 lines 0 comments Download
M ui/views/view_constants.cc View 1 chunk +1 line, -0 lines 0 comments Download
M ui/views/view_unittest.cc View 1 2 3 4 5 6 7 2 chunks +445 lines, -0 lines 0 comments Download
M ui/views/widget/root_view.cc View 1 2 3 4 5 6 7 1 chunk +6 lines, -3 lines 0 comments Download

Messages

Total messages: 38 (0 generated)
sadrul
http://codereview.chromium.org/10790019/diff/1/ui/views/view.cc File ui/views/view.cc (right): http://codereview.chromium.org/10790019/diff/1/ui/views/view.cc#newcode90 ui/views/view.cc:90: } I think this is fine ... but perhaps ...
8 years, 5 months ago (2012-07-16 22:16:14 UTC) #1
rjkroege
And I think the targeting logic should have unit tests. http://codereview.chromium.org/10790019/diff/1/ui/views/view.cc File ui/views/view.cc (right): http://codereview.chromium.org/10790019/diff/1/ui/views/view.cc#newcode106 ...
8 years, 5 months ago (2012-07-16 23:35:47 UTC) #2
tdanderson
https://chromiumcodereview.appspot.com/10790019/diff/1/ui/views/view.cc File ui/views/view.cc (right): https://chromiumcodereview.appspot.com/10790019/diff/1/ui/views/view.cc#newcode90 ui/views/view.cc:90: } On 2012/07/16 22:16:14, sadrul wrote: > I think ...
8 years, 5 months ago (2012-07-17 19:07:07 UTC) #3
sadrul
http://codereview.chromium.org/10790019/diff/1/ui/views/view.cc File ui/views/view.cc (right): http://codereview.chromium.org/10790019/diff/1/ui/views/view.cc#newcode1316 ui/views/view.cc:1316: gfx::Rect childRect(child->GetScreenBounds()); On 2012/07/17 19:07:07, tdanderson wrote: > On ...
8 years, 5 months ago (2012-07-17 19:26:45 UTC) #4
sky
I'm fine with doing something like this as it makes a lot of sense. That ...
8 years, 5 months ago (2012-07-17 19:54:32 UTC) #5
sky
Also, we may need to further scrutinize event handlers. With this patch it's more likely ...
8 years, 5 months ago (2012-07-17 21:28:42 UTC) #6
tdanderson
I have uploaded a new CL for your comments. https://chromiumcodereview.appspot.com/10790019/diff/1/ui/views/view.cc File ui/views/view.cc (right): https://chromiumcodereview.appspot.com/10790019/diff/1/ui/views/view.cc#newcode1316 ui/views/view.cc:1316: ...
8 years, 5 months ago (2012-07-18 22:35:41 UTC) #7
tdanderson
On 2012/07/17 19:54:32, sky wrote: > I'm fine with doing something like this as it ...
8 years, 5 months ago (2012-07-18 22:36:45 UTC) #8
sadrul
http://codereview.chromium.org/10790019/diff/7001/ui/views/view.cc File ui/views/view.cc (right): http://codereview.chromium.org/10790019/diff/7001/ui/views/view.cc#newcode811 ui/views/view.cc:811: return NULL; I think as long as the intersection ...
8 years, 5 months ago (2012-07-18 23:42:31 UTC) #9
sky
https://chromiumcodereview.appspot.com/10790019/diff/1/ui/views/widget/root_view.cc File ui/views/widget/root_view.cc (right): https://chromiumcodereview.appspot.com/10790019/diff/1/ui/views/widget/root_view.cc#newcode459 ui/views/widget/root_view.cc:459: bool useFuzzing = event.type() == ui::ET_GESTURE_TAP; On 2012/07/18 22:35:42, ...
8 years, 5 months ago (2012-07-19 00:06:38 UTC) #10
rjkroege
http://codereview.chromium.org/10790019/diff/7001/ui/views/view.cc File ui/views/view.cc (right): http://codereview.chromium.org/10790019/diff/7001/ui/views/view.cc#newcode100 ui/views/view.cc:100: // Returns the distance from |point| to the center ...
8 years, 5 months ago (2012-07-19 00:51:57 UTC) #11
sadrul
On 2012/07/19 00:06:38, sky wrote: > https://chromiumcodereview.appspot.com/10790019/diff/1/ui/views/widget/root_view.cc > File ui/views/widget/root_view.cc (right): > > https://chromiumcodereview.appspot.com/10790019/diff/1/ui/views/widget/root_view.cc#newcode459 > ...
8 years, 5 months ago (2012-07-19 17:53:29 UTC) #12
rjkroege
On 2012/07/19 17:53:29, sadrul wrote: > On 2012/07/19 00:06:38, sky wrote: > > > https://chromiumcodereview.appspot.com/10790019/diff/1/ui/views/widget/root_view.cc ...
8 years, 5 months ago (2012-07-19 18:25:39 UTC) #13
sky
On Thu, Jul 19, 2012 at 10:53 AM, <sadrul@chromium.org> wrote: > On 2012/07/19 00:06:38, sky ...
8 years, 5 months ago (2012-07-19 20:15:18 UTC) #14
sky
FWIW I spoke with one of the guys on the Android framework team and he ...
8 years, 5 months ago (2012-07-20 17:11:03 UTC) #15
rjkroege
On 2012/07/19 20:15:18, sky wrote: > On Thu, Jul 19, 2012 at 10:53 AM, <mailto:sadrul@chromium.org> ...
8 years, 5 months ago (2012-07-20 19:28:11 UTC) #16
tdanderson
https://chromiumcodereview.appspot.com/10790019/diff/7001/ui/views/view.cc File ui/views/view.cc (right): https://chromiumcodereview.appspot.com/10790019/diff/7001/ui/views/view.cc#newcode100 ui/views/view.cc:100: // Returns the distance from |point| to the center ...
8 years, 5 months ago (2012-07-25 23:08:57 UTC) #17
tdanderson
I have uploaded a third patch set for your comments.
8 years, 5 months ago (2012-07-25 23:16:36 UTC) #18
sadrul
I think this is looking good. (and there should be tests before it lands) http://codereview.chromium.org/10790019/diff/16001/ui/views/view.cc ...
8 years, 5 months ago (2012-07-26 18:41:28 UTC) #19
tdanderson
https://chromiumcodereview.appspot.com/10790019/diff/16001/ui/views/view.cc File ui/views/view.cc (right): https://chromiumcodereview.appspot.com/10790019/diff/16001/ui/views/view.cc#newcode811 ui/views/view.cc:811: return NULL; On 2012/07/26 18:41:28, sadrul wrote: > I ...
8 years, 4 months ago (2012-07-27 15:27:04 UTC) #20
tdanderson
Patch set 4 up for your comments. In the meanwhile I will create unit tests.
8 years, 4 months ago (2012-07-27 15:41:03 UTC) #21
sadrul
This change looks good to me. I think this can land once you add the ...
8 years, 4 months ago (2012-07-27 17:07:56 UTC) #22
tdanderson
Patch set 5 is up now and has unit tests. Please let me know if ...
8 years, 4 months ago (2012-07-30 22:34:36 UTC) #23
sadrul
The test looks good. One comment: http://codereview.chromium.org/10790019/diff/26001/ui/views/events/event.h File ui/views/events/event.h (right): http://codereview.chromium.org/10790019/diff/26001/ui/views/events/event.h#newcode444 ui/views/events/event.h:444: private: Instead of ...
8 years, 4 months ago (2012-08-01 16:05:33 UTC) #24
tdanderson
New patch up: sadrul's comments about testing have been addressed. Please let me know if ...
8 years, 4 months ago (2012-08-01 18:22:39 UTC) #25
rjkroege
lgtm
8 years, 4 months ago (2012-08-01 18:32:33 UTC) #26
sadrul
LGTM We might have to do additional work for views with hit-test masks, but let's ...
8 years, 4 months ago (2012-08-01 18:33:24 UTC) #27
sky
I'll look at this first thing tomorrow. I still strongly believe this functionality is an ...
8 years, 4 months ago (2012-08-01 20:00:47 UTC) #28
sky
Ben convinced me no switch, and this is just a result of having a ui ...
8 years, 4 months ago (2012-08-01 20:17:34 UTC) #29
sky
Please update the subject/description of this cl.
8 years, 4 months ago (2012-08-02 15:23:44 UTC) #30
tdanderson
On 2012/08/02 15:23:44, sky wrote: > Please update the subject/description of this cl. Done.
8 years, 4 months ago (2012-08-02 15:35:20 UTC) #31
sky
You're going to need to update all views that override GetEventhandleForPoint to override GetEventHandlerForRect too. ...
8 years, 4 months ago (2012-08-02 15:52:08 UTC) #32
tdanderson
sky@'s comments addressed, some still needing additional feedback. I am also uploading patch set 7 ...
8 years, 4 months ago (2012-08-02 18:11:37 UTC) #33
sky
On Thu, Aug 2, 2012 at 11:11 AM, <tdanderson@chromium.org> wrote: > sky@'s comments addressed, some ...
8 years, 4 months ago (2012-08-02 20:02:22 UTC) #34
tdanderson
On 2012/08/02 20:02:22, sky wrote: > On Thu, Aug 2, 2012 at 11:11 AM, <mailto:tdanderson@chromium.org> ...
8 years, 4 months ago (2012-08-03 22:46:31 UTC) #35
tdanderson
My latest changes are uploaded now. sky, could you please clarify the changes you suggested ...
8 years, 4 months ago (2012-08-03 22:57:32 UTC) #36
sky
Here's what I was thinking. But, after writing this I think it's harder to understand ...
8 years, 4 months ago (2012-08-03 23:46:36 UTC) #37
sky
8 years, 4 months ago (2012-08-03 23:52:57 UTC) #38
There would need to be some more changes, but you get the idea. I like this in
that we only have one method for figuring out the best candidate.

That said, there is a problem with how all of this is set up. It doesn't invoke
HitTest at all. That'll cause problems. I suspect this means we need to change
HitTest to take a rect, but I don't have time to investigate that.

https://chromiumcodereview.appspot.com/10790019/diff/25006/ui/views/view.cc
File ui/views/view.cc (right):

https://chromiumcodereview.appspot.com/10790019/diff/25006/ui/views/view.cc#n...
ui/views/view.cc:816: View* View::GetEventHandlerForRect(const gfx::Rect& rect)
{
On 2012/08/03 23:46:36, sky wrote:
> I'm hoping its possible to combine this and GetEventHandlerForPoint. Less
error
> prone that way. I'm thinking something like this:
> 
> struct EventHandlerResult {
>   View* view_at_center;
>   View* best_view;
> };
> 
> bool GetEventHandlerForRect(..., EventHandlerResult* result) {
> }

Gah, I guess I can't nuke my comments.
Here's my second thought. This requires two passes, but combines the two methods
into a single one:

enum EventType {
  MOUSE,
  TOUCH
};
name this GetEventHandler(const gfx::Rect& rect, EventType type);

https://chromiumcodereview.appspot.com/10790019/diff/25006/ui/views/view.cc#n...
ui/views/view.cc:831: if (!cur_view)
On 2012/08/03 23:46:36, sky wrote:
> between 830-831 something like:
> 
> if (rect.IsEmpty() && result->view_at_center)
>   return true;
> cur_view becomes result->best_view.

if (type == MOUSE)
  return cur_view;

https://chromiumcodereview.appspot.com/10790019/diff/25006/ui/views/view.cc#n...
ui/views/view.cc:851: return NULL;
On 2012/08/03 23:46:36, sky wrote:
> return false;

return type == MOUSE ? this : NULL;

Powered by Google App Engine
This is Rietveld 408576698