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.
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.
Created attachment 16984 [details]
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.
Created attachment 16990 [details]
Thanks for the test case Justin.
Comment on attachment 16990 [details]
Landed in r27376.
*** Bug 16960 has been marked as a duplicate of this bug. ***