Bug 15780 - WebFrameLoaderClient: WebActionElementKey wrong if view is scrolled
Summary: WebFrameLoaderClient: WebActionElementKey wrong if view is scrolled
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit Misc. (show other bugs)
Version: 523.x (Safari 3)
Hardware: Mac OS X 10.5
: P2 Major
Assignee: Nobody
URL:
Keywords:
: 16960 (view as bug list)
Depends on:
Blocks:
 
Reported: 2007-10-31 16:12 PDT by Justin Bur
Modified: 2008-01-21 19:10 PST (History)
2 users (show)

See Also:


Attachments
test app (20.86 KB, application/zip)
2007-11-01 12:08 PDT, Justin Bur
no flags Details
Patch (1.51 KB, patch)
2007-11-02 04:51 PDT, Mark Rowe (bdash)
darin: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Justin Bur 2007-10-31 16:12:22 PDT
The actionDictionary sent to various WebPolicyDelegate methods is supposed to provide the element that has been clicked, under the WebActionElementKey. If the web view is scrolled, this element is calculated incorrectly.

Reproduction: load a long document into a smallish frame. Set up a delegate that implements webView:decidePolicyForNavigationAction:request:frame:decisionListener:. Scroll down to the bottom of the page and click a link. In the delegate, examine [[actionInformation objectForKey:WebActionElementKey] WebElementDOMNodeKey]. The node returned will be distant from the actual mouse click by the same vertical amount as the view is scrolled.

In WebFrameLoaderClient.mm (line 1117 as of writing, rev. 26758), method WebFrameLoaderClient::actionDictionary(), an IntPoint is constructed using mouseEvent->clientX() and mouseEvent->clientY(). These values do not take scrolling into account. An apparently correct result can be obtained if the IntPoint is constructed using mouseEvent->layerX() and mouseEvent->layerY().

The error seems to have been present since rev. 17597.
Comment 1 Mark Rowe (bdash) 2007-10-31 18:18:12 PDT
Is there any chance you can attach a simple application that demonstrates what you have described?  It would make it a lot quicker to confirm the issue you have reported, and easier to get started on fixing it.
Comment 2 Justin Bur 2007-11-01 12:08:08 PDT
Created attachment 16984 [details]
test app

This tiny WebKit client highlights clicked links (setSelectedDOMRange:) instead of following them. It does so by using the broken WebActionElementKey. Notice the change in behavior when the WebView is scrolled. Scroll just a little to see the problem more clearly. The node returned in WebActionElementKey is also logged to console.
Comment 3 Mark Rowe (bdash) 2007-11-02 04:51:30 PDT
Created attachment 16990 [details]
Patch
Comment 4 Mark Rowe (bdash) 2007-11-02 04:54:07 PDT
Thanks for the test case Justin.
Comment 5 Darin Adler 2007-11-02 07:06:27 PDT
Comment on attachment 16990 [details]
Patch

r=me
Comment 6 Mark Rowe (bdash) 2007-11-02 07:18:36 PDT
Landed in r27376.
Comment 7 Mark Rowe (bdash) 2008-01-21 19:10:19 PST
*** Bug 16960 has been marked as a duplicate of this bug. ***