Bug 44088 - [Qt] Add API to QWebSettings for setting/getting the padding of HitTestResult
Summary: [Qt] Add API to QWebSettings for setting/getting the padding of HitTestResult
Status: RESOLVED INVALID
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit Qt (show other bugs)
Version: 528+ (Nightly build)
Hardware: PC All
: P2 Enhancement
Assignee: Antonio Gomes
URL:
Keywords: Qt, QtTriaged
Depends on:
Blocks: 44089 46039
  Show dependency treegraph
 
Reported: 2010-08-16 20:29 PDT by Antonio Gomes
Modified: 2010-11-07 23:34 PST (History)
12 users (show)

See Also:


Attachments
patch v1. (5.61 KB, patch)
2010-08-16 20:32 PDT, Antonio Gomes
no flags Details | Formatted Diff | Diff
patch v2 (5.64 KB, patch)
2010-09-02 14:56 PDT, Antonio Gomes
no flags Details | Formatted Diff | Diff
Usability test on netbook with touch screen (10.09 MB, video/mp4)
2010-09-20 01:59 PDT, Benjamin Poulain
no flags Details
Usability test on a netbook with touch screen (9.29 MB, video/mp4)
2010-09-20 02:01 PDT, Benjamin Poulain
no flags Details
Problem when the rect intersect the link on top of the touch point (deleted)
2010-09-20 07:59 PDT, Benjamin Poulain
no flags Details
Another quick test on netbook (deleted)
2010-09-22 08:11 PDT, Benjamin Poulain
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Antonio Gomes 2010-08-16 20:29:26 PDT
Bug is about adding setter and getter methods to QWebSettings for set/get HitTestResult's fudge factor (aka padding).

Details:
In order to make use of the newly added rect-based extension of the hit testing system (bug 40197), ports need a way to set the 'padding' value used by HitTestResult class  to build up the hit area. This is a first step for a Qt-followup bug on it.
Comment 1 Antonio Gomes 2010-08-16 20:32:49 PDT
Created attachment 64548 [details]
patch v1.
Comment 2 Kenneth Rohde Christiansen 2010-08-17 01:09:52 PDT
Comment on attachment 64548 [details]
patch v1.

WebKit/qt/Api/qwebsettings.cpp:1108
 +      specially useful for touch devices, once heuristics can be used internally by
I think it is called especially.

WebKit/qt/Api/qwebsettings.cpp:1103
 +      Specifies the fuzzy range in pixels for accepting mouse events for a given
what is the page is scaled?

WebKit/qt/Api/qwebsettings.cpp:1132
 +  void QWebSettings::setHitTestPadding(Qt::Orientation orientation, int padding)
how can a hit test have padding? setPaddingForHitTesting?
Comment 3 Antonio Gomes 2010-08-17 07:31:19 PDT
> WebKit/qt/Api/qwebsettings.cpp:1103
>  +      Specifies the fuzzy range in pixels for accepting mouse events for a given
> what is the page is scaled?

The padding value itself does not need to care about scaling: if patch if zoomed in, for example, you finger (i.e. the tapping area) would not change.
 
> WebKit/qt/Api/qwebsettings.cpp:1132
>  +  void QWebSettings::setHitTestPadding(Qt::Orientation orientation, int padding)
> how can a hit test have padding? setPaddingForHitTesting?

I like setPaddingForHitTesting, but maybe the term 'padding' is non intuitive here, anyways. Maybe something more descriptive like setFuzzyRangeForAcceptingEvents or setExpansionAreaForClicking (just thinking lound here)?
Comment 4 Antonio Gomes 2010-08-17 07:34:25 PDT
> > what is the page is scaled?
> 
> The padding value itself does not need to care about scaling: if patch if zoomed in, for example, you finger (i.e. the tapping area) would not change.

err, in English now:

The padding value itself does not need to care about scaling: if page is zoomed in, for example, your finger (i.e. the tapping area) would not change.
Comment 5 Antonio Gomes 2010-08-17 07:37:55 PDT
(In reply to comment #2)
> (From update of attachment 64548 [details])
> WebKit/qt/Api/qwebsettings.cpp:1108
>  +      specially useful for touch devices, once heuristics can be used internally by
> I think it is called especially.

accordinging to http://englishplus.com/grammar/00000287.htm 'especially' is also apropriated here. Do you agree?
Comment 6 Kenneth Rohde Christiansen 2010-08-18 00:45:55 PDT
Simon you are the API guy :-) We need your input!
Comment 7 Benjamin Poulain 2010-08-25 08:01:46 PDT
I suggest to have padding top/left/right/bottom instead of same padding everywhere.

The reason is that the rect touching the screen is not exactly the rect the user expect to interact with.

When you click on something, you look at your finger from the top, and expect to click on the area under your nail. If you look sideway on a finger pressing a button, the area touching the screen if offset down from the nail position.

For this reason, the rect created from a touch point need to be offset to the top by a few pixels. The exact offset depends on the screen technology.

If you don't understand what I am talking about, I suggest you to write a app where you have to click on points and display the rect your pressed. You'll see the rect is down from where you expected to click.
Comment 8 Simon Hausmann 2010-08-25 13:20:09 PDT
Comment on attachment 64548 [details]
patch v1.

WebKit/qt/Api/qwebsettings.h:142
 +      void setHitTestPadding(Qt::Orientation, int padding);
Hmm, this is a member function of QWebSettings, but it actually doesn't change any members but reads/writes directly to the global settings. I think it should either be a static function or the setting should propagate correct from global settings to page specific settings.
Comment 9 Simon Hausmann 2010-08-25 13:23:55 PDT
Antonio, can you explain where in a Qt/Meegotouch application these padding values would come from?

I like how this keeps things actually simple, it doesn't require changing all the APIs. I'm just curious where the values would come from and if they come from a system library like libmeegotouch, can we perhaps provide defaults?

What about pure touch events? Should WebCore/page/EventHandler.cpp: EventHandler::handleTouchEvent() use your new internal functions for better accuracy?
Comment 10 Antonio Gomes 2010-08-30 21:06:18 PDT
Hi Benjamin.

(In reply to comment #7)
> I suggest to have padding top/left/right/bottom instead of same padding everywhere.
> 
> When you click on something, you look at your finger from the top, and expect to click on the area under your nail. If you look sideway on a finger pressing a button, the area touching the screen if offset down from the nail position.
> 
> For this reason, the rect created from a touch point need to be offset to the top by a few pixels. The exact offset depends on the screen technology.

Yes, I totally understand your suggestion. In fact, the rect-based hit testing idea was inspired of Mozilla's SmartTap, which on its turns, exposes a more flexible API, just like you said:

nsIDOMNodeList nodesFromRect(in long aX,
                             in long aY,
                             in long aTopSize,
                             in long aRightSize,
                             in long aBottomSize,
                             in long aLeftSize,
                             in boolean aIgnoreRootScrollFrame,
                             in boolean aFlushLayout);

Mark Finkle, from the mozilla mobile team, explains that nicely in a blog post: http://starkravingfinkle.org/blog/2010/05/smart-tapping-in-mobile-firefox/ , including why their values also benefit the TOP direction.

"Firefox Mobile uses a region that is offset more above the touch point. This has the affect of favoring elements above the touch point – which is based on our observations that people tend to “tap” below elements."

Making that change, would be very logic to me, yes, but would need changes in the underlying WebCore HitTestResult and Hit Testing system implementations.
Comment 11 Antonio Gomes 2010-08-30 21:20:36 PDT
@Grace: We are trying to define a nice API for setting the padding values for QtWebKit. But it turns out that horizontal and vertical paddings *might* not be the best way to specify the paddings. We might end up needing separeted "up, right, down and left" paddings properties (comment #10).

Could you please explain how android is making use of the rect-based hit testing we added? Is that through a public API or hardcoded values?

Also, would changing from the rect-based hit testing padding from "horizontal + vertical paddings" to "up + left + down + left paddings" interest/impact for you?

Please comment.
Comment 12 Grace Kloba 2010-08-30 21:31:50 PDT
(In reply to comment #11)
> @Grace: We are trying to define a nice API for setting the padding values for QtWebKit. But it turns out that horizontal and vertical paddings *might* not be the best way to specify the paddings. We might end up needing separeted "up, right, down and left" paddings properties (comment #10).
> 
> Could you please explain how android is making use of the rect-based hit testing we added? Is that through a public API or hardcoded values?
> 
> Also, would changing from the rect-based hit testing padding from "horizontal + vertical paddings" to "up + left + down + left paddings" interest/impact for you?
> 
> Please comment.

Android currently is experimenting a simple padding. We are ok with the fine tuned api if it is needed for the other port.
Comment 13 Antonio Gomes 2010-08-30 21:36:44 PDT
(In reply to comment #8)
> (From update of attachment 64548 [details])
> WebKit/qt/Api/qwebsettings.h:142
>  +      void setHitTestPadding(Qt::Orientation, int padding);
> Hmm, this is a member function of QWebSettings, but it actually doesn't change any members but reads/writes directly to the global settings. I think it should either be a static function or the setting should propagate correct from global settings to page specific settings.

Good point, simon. I can fix that.

(In reply to comment #9)
> Antonio, can you explain where in a Qt/Meegotouch application these padding values would come from?
> 
> I like how this keeps things actually simple, it doesn't require changing all the APIs. I'm just curious where the values would come from and if they come from a system library like libmeegotouch, can we perhaps provide defaults?

Applications should be the setters here, I think simon.

About the defaults, we could either set defaults *or* document good values. I particularly prefer the later. I will check when mozilla values came from, and what interfer to them (resolution, dpi, etc).

> What about pure touch events? Should WebCore/page/EventHandler.cpp: EventHandler::handleTouchEvent() use your new internal functions for better accuracy?

I think for touch events, things could work similarly to mouse events: before submitting a touch event (click) to WebCore::EventHandler::handleTouchEvent, we would use similar heuristic to the one proposed in bug 44089 to "find" the clickable target user more likely aimed to tap. Then we'd adjust the QTouchEvent::TouchPoint::setPos(x,y) accordingly, and finally submit this adjusted position to webcore.

If hardware provided an accurate rect through the QTouchEvent::TouchPoint::rect() we could just use it as the rect input. However, currently Qt is only passing the right touchpoint::rect for Windows-based devices. On linux (e.g. maemo6) it is wrong. As a fallback, we would build up the rect from the paddings.

What to do?
Comment 14 Antonio Gomes 2010-08-30 21:39:11 PDT
> Android currently is experimenting a simple padding. We are ok with the fine tuned api if it is needed for the other port.

@Grace, just to be sure: what would be a simple padding? Same padding value for both horizontal and vertical orientations?
Comment 15 Grace Kloba 2010-08-30 21:48:37 PDT
(In reply to comment #14)
> > Android currently is experimenting a simple padding. We are ok with the fine tuned api if it is needed for the other port.
> 
> @Grace, just to be sure: what would be a simple padding? Same padding value for both horizontal and vertical orientations?

Yes. We currently use the same value for horizontal and vertical.

I understand Ben's example of tapping on a link. But users have adjusted to it. And some of them are tapping sideways. So arbitrary adjust the size may not help. Of course, this needs a lot of user testing.
Comment 16 Antonio Gomes 2010-09-02 14:56:50 PDT
Created attachment 66414 [details]
patch v2

(In reply to comment #8)
> (From update of attachment 64548 [details])
> WebKit/qt/Api/qwebsettings.h:142
>  +      void setHitTestPadding(Qt::Orientation, int padding);
>
> Hmm, this is a member function of QWebSettings, but it actually doesn't change any members but reads/writes directly to the global settings. I think it should either be a static function or the setting should propagate correct from global settings to page specific settings.

Addressed with Simon's first suggestion here: made methods static functions.

@Simon: at the moment I did not have a maemo6 device to test it, but n900 (maemo5). It would be great if it could get tested together with patch in bug 44089. Touch interaction result should be really better.

@Benjamin: I understand your concern that we could be favoring elements above the touch point, as mozilla makes it possible to set with their API, but would the gain be a difference. API would be simpler as is, and it'd be great with we could keep it as is.

Again, real testing would answer these questions.
Comment 17 Antonio Gomes 2010-09-02 14:57:35 PDT
> Android currently is experimenting a simple padding. We are ok with the fine tuned api if it is needed for the other port.

@Grace, are you guys getting good TAP interaction improvements with using same padding value for UP and DOWN paddings?
Comment 18 Grace Kloba 2010-09-02 15:26:12 PDT
(In reply to comment #17)
> > Android currently is experimenting a simple padding. We are ok with the fine tuned api if it is needed for the other port.
> 
> @Grace, are you guys getting good TAP interaction improvements with using same padding value for UP and DOWN paddings?

This is very subjective. I think for a right hand person, tap touch point is normally at the bottom right relative to the finger tip. But people have been adjusted to this gesture when they tap. So we currently increase the touch area evenly.
Comment 19 Antonio Gomes 2010-09-04 17:21:58 PDT
Benjamin, please share result you got from testing on meego handset, if you got that far.

Thank you in advance.
Comment 20 Benjamin Poulain 2010-09-05 08:53:09 PDT
(In reply to comment #19)
> Benjamin, please share result you got from testing on meego handset, if you got that far.

I had been distracted by another problem on Friday, I have not tested your branch yet.
Comment 21 Benjamin Poulain 2010-09-20 01:59:02 PDT
Created attachment 68060 [details]
Usability test on netbook with touch screen

This show the result of the patch on a MeeGo netbook with touchscreen. This video is with the 10x15 pad area.
Comment 22 Benjamin Poulain 2010-09-20 02:01:14 PDT
Created attachment 68061 [details]
Usability test on a netbook with touch screen

This show the result of the patch on a MeeGo netbook with touchscreen. This video is with the 10x10 pad area.
Comment 23 Benjamin Poulain 2010-09-20 07:59:52 PDT
Created attachment 68084 [details]
Problem when the rect intersect the link on top of the touch point
Comment 24 Antonio Gomes 2010-09-20 19:33:49 PDT
(In reply to comment #23)
> Created an attachment (id=68084) [details]
> Problem when the rect intersect the link on top of the touch point

Benjamin, I just found we work perfectly with the default zoom factor. Once I zoom in it stops working. 
I will fix that.

In your experiments (specially in video _006), do you zoom in/out the page?
Comment 25 Benjamin Poulain 2010-09-21 05:39:45 PDT
(In reply to comment #24)
> In your experiments (specially in video _006), do you zoom in/out the page?

Yep, it was zoomed out.
Comment 26 Antonio Gomes 2010-09-21 05:41:29 PDT
(In reply to comment #25)
> (In reply to comment #24)
> > In your experiments (specially in video _006), do you zoom in/out the page?
> 
> Yep, it was zoomed out.

Ah ha! we got our bug, then. I will fix it in bug 44089. Thanks much again, Ben.
Comment 27 Benjamin Poulain 2010-09-22 08:11:16 PDT
Created attachment 68373 [details]
Another quick test on netbook

This video show another quick test of the feature with the last update of Antonio.

This shows the usability is now very good.

The only issue I had while testing is from https://bugs.webkit.org/show_bug.cgi?id=44089 : the linked are not clicked when the cursor is not hitting the same RenderBlock as the link.
Comment 28 Antonio Gomes 2010-09-22 21:41:39 PDT
This might interest here: https://lists.webkit.org/pipermail/webkit-dev/2010-September/014457.html

We should opine if we would prefer to keep the API as simple as possible, i.e. keep set the padding per orientation (vertical and horizontal) as proposed by attachment 66414 [details], or if we are going to wait the webcore related change in bug 46336, and set the paddings per direction (top, right, bottom, left)?

In summary:

void QWebSettings::setHitTestPadding(Qt::Orientation orientation, int padding)

                                          X

void QWebSettings::setHitTestPaddings(int top, int right, int bottom, int left)
 
Thoughts?
Comment 29 Antonio Gomes 2010-09-22 21:43:22 PDT
(In reply to comment #27)
> The only issue I had while testing is from https://bugs.webkit.org/show_bug.cgi?id=44089 : the linked are not clicked when the cursor is not hitting the same RenderBlock as the link.

That is a great catch! Fix should go in WebCore. Will file a bug a paste here for the record.
Comment 30 Benjamin Poulain 2010-09-27 09:04:02 PDT
We discussed this API today.

We could not find use cases where application developers want to change that. We would prefer the platform to provide reasonable values.

So what do you think about extending the platform plugin APIs to provide the numbers?
Comment 31 Kenneth Rohde Christiansen 2010-09-27 09:29:55 PDT
Sounds good to me!
Comment 32 Antonio Gomes 2010-09-27 10:05:31 PDT
(In reply to comment #30)
> We discussed this API today.
> 
> We could not find use cases where application developers want to change that. We would prefer the platform to provide reasonable values.
> 
> So what do you think about extending the platform plugin APIs to provide the numbers?

I am not very familiar with that, but can try.
Comment 33 Yael 2010-09-27 11:22:25 PDT
(In reply to comment #30)
> We discussed this API today.
> 
> We could not find use cases where application developers want to change that. We would prefer the platform to provide reasonable values.
> 
> So what do you think about extending the platform plugin APIs to provide the numbers?

Sounds good to me too
Comment 34 Antonio Gomes 2010-09-27 17:33:25 PDT
Alright. So I am going to close this one as INVALID, and open a fresh new one :)

Thanks for all feedback and testing.
Comment 35 Antonio Gomes 2010-09-27 21:49:20 PDT
(In reply to comment #26)
> (In reply to comment #25)
> > (In reply to comment #24)
> > > In your experiments (specially in video _006), do you zoom in/out the page?
> > 
> > Yep, it was zoomed out.
> 
> Ah ha! we got our bug, then. I will fix it in bug 44089. Thanks much again, Ben.

Bug 46696 filed about it.
Comment 36 Antonio Gomes 2010-10-04 07:54:21 PDT
(In reply to comment #33)
> (In reply to comment #30)
> > We discussed this API today.
> > 
> > We could not find use cases where application developers want to change that. We would prefer the platform to provide reasonable values.
> > 
> > So what do you think about extending the platform plugin APIs to provide the numbers?
> 
> Sounds good to me too

Benjamin, yael, kenneth: should it go with the platform plugin approach? (kenneth and yael said YES, but benjamin pointed out something negative about it on IRC).
Comment 37 Benjamin Poulain 2010-10-04 09:29:01 PDT
(In reply to comment #36)
> Benjamin, yael, kenneth: should it go with the platform plugin approach? (kenneth and yael said YES, but benjamin pointed out something negative about it on IRC).

I have been thinking about this while running :)

The problem we have with the rect are the zoom factors:
-scaled QGraphicsWebView
-QGraphicsView with arbitrary transforms.

The web frame are not aware of painter transformations above WebKit so the informations must be provided somehow.

We could do 2 kind of APIs:
1) use the platform plugin to define a rect. Modify this rect on the fly by looking at the transforms of the item and the view from which the event comes (I guess we could use QGraphicsSceneEvent::widget()::parent(), this is unfortunately hackish).
2) let the use provide the scale factor per event.

(2) is the complete solution since it allow arbitrary manipulations (like manually scaled painters on a QWebView).
(1) will give a simpler API, and will be less error prone for developers using QtWebKit. I am in favor (1) since I think it is a more Qt-ish API (simple yet powerful :)).

Kenneth, Yael, any suggestion? Do you agree what I describe above?
Comment 38 Kenneth Rohde Christiansen 2010-10-04 10:56:03 PDT
(In reply to comment #37)
> (In reply to comment #36)
> > Benjamin, yael, kenneth: should it go with the platform plugin approach? (kenneth and yael said YES, but benjamin pointed out something negative about it on IRC).
> 
> I have been thinking about this while running :)
> 
> The problem we have with the rect are the zoom factors:
> -scaled QGraphicsWebView
> -QGraphicsView with arbitrary transforms.
> 
> The web frame are not aware of painter transformations above WebKit so the informations must be provided somehow.
> 
> We could do 2 kind of APIs:
> 1) use the platform plugin to define a rect. Modify this rect on the fly by looking at the transforms of the item and the view from which the event comes (I guess we could use QGraphicsSceneEvent::widget()::parent(), this is unfortunately hackish).
> 2) let the use provide the scale factor per event.
> 
> (2) is the complete solution since it allow arbitrary manipulations (like manually scaled painters on a QWebView).
> (1) will give a simpler API, and will be less error prone for developers using QtWebKit. I am in favor (1) since I think it is a more Qt-ish API (simple yet powerful :)).
> 
> Kenneth, Yael, any suggestion? Do you agree what I describe above?

I'm OK with number 1. It should just work out of the box if possible.
Comment 39 Ademar Reis 2010-10-06 08:35:54 PDT
invalid ==> remove block from release and API meta-bugs
Comment 40 Andre Pedralho 2010-10-20 13:47:23 PDT
I had a brief talk with Antonio and figured out that we have two different open bugs here:

1) Consider the eventual transformations in the QGraphicsWebView before looking for the click candidate nodes in the HitTestResult process which is bug #46696.

2) And the former one: to provide the padding values to be used in the HitTestResult hit area. As far as I could understand it should use *constant* values provided by the Platform Plugin. I mean, each platform should specify its preferred padding values and this value will not change even if a transformation in QGraphicsWebView occurs.

Am I correct?

May I reopen it and solve the item 2?
Comment 41 Antonio Gomes 2010-10-20 14:00:18 PDT
> 2) And the former one: to provide the padding values to be used in the HitTestResult hit area. As far as I could understand it should use *constant* values provided by the Platform Plugin. I mean, each platform should specify its preferred padding values and this value will not change even if a transformation in QGraphicsWebView occurs.
> 
> May I reopen it and solve the item 2?

Lets make a fresh new one for addressing this. You can refer to this one in the description.
Comment 42 Antonio Gomes 2010-10-27 13:25:20 PDT
(In reply to comment #41)
> > 2) And the former one: to provide the padding values to be used in the HitTestResult hit area. As far as I could understand it should use *constant* values provided by the Platform Plugin. I mean, each platform should specify its preferred padding values and this value will not change even if a transformation in QGraphicsWebView occurs.
> > 
> > May I reopen it and solve the item 2?
> 
> Lets make a fresh new one for addressing this. You can refer to this one in the description.

Pedralho filed it: bug 48450.
Comment 43 Eric Seidel (no email) 2010-11-07 23:34:15 PST
Comment on attachment 66414 [details]
patch v2

Cleared review? from attachment 66414 [details] so that this bug does not appear in http://webkit.org/pending-review.  If you would like this patch reviewed, please attach it to a new bug (or re-open this bug before marking it for review again).