Bug 96593 - [Chromium] REGRESSION(r127457): Context menu on textarea is displayed in the wrong place
Summary: [Chromium] REGRESSION(r127457): Context menu on textarea is displayed in the ...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: UI Events (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Julien Chaffraix
URL:
Keywords: NeedsReduction, Regression
Depends on:
Blocks:
 
Reported: 2012-09-12 19:51 PDT by Julien Chaffraix
Modified: 2012-09-14 16:15 PDT (History)
7 users (show)

See Also:


Attachments
Screenshot of the issue (378.48 KB, image/png)
2012-09-12 19:51 PDT, Julien Chaffraix
no flags Details
Proposed fix. Tested on Chromium Linux, need testing on Chromium Mac. Would love to test that. (1.82 KB, patch)
2012-09-13 10:58 PDT, Julien Chaffraix
no flags Details | Formatted Diff | Diff
Proposed fix: Same as previously, ChangeLog updated, passes Mac testing. (1.94 KB, patch)
2012-09-13 11:42 PDT, Julien Chaffraix
no flags Details | Formatted Diff | Diff
Patch for landing (1.94 KB, patch)
2012-09-13 13:29 PDT, Julien Chaffraix
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Julien Chaffraix 2012-09-12 19:51:43 PDT
Created attachment 163765 [details]
Screenshot of the issue

How to reproduce:

* Open http://www.google.com/transliterate on Chromium on Linux or Windows.
* Right click on the textarea, and check the context menu.

Issue:

The context menu doesn't come up next to the mouse cursor. Please see attached image. 

Rolling out r127457 (and the following refactoring) locally fixes the issue. Not sure if other platforms are impacted, for some reason Safari and Chromium Mac don't show the issue.

Allan, could you have a look?
Comment 1 Allan Sandfeld Jensen 2012-09-13 02:19:01 PDT
I can not reproduce the issue on Qt either.

I have a guess on the cause though. EventHandler::hitTestResultAtPoint used to have a quirk/bug where it changed the result.point() so that after the function it was in the coordinates of the last frame it hit-tested. It no longer does that, if you use that position for the context menu have code that corrects for the old bug, it might be wrong now that it is no longer necessary.
Comment 2 Allan Sandfeld Jensen 2012-09-13 02:35:10 PDT
(In reply to comment #1)
> I can not reproduce the issue on Qt either.
> 
> I have a guess on the cause though. EventHandler::hitTestResultAtPoint used to have a quirk/bug where it changed the result.point() so that after the function it was in the coordinates of the last frame it hit-tested. It no longer does that, if you use that position for the context menu have code that corrects for the old bug, it might be wrong now that it is no longer necessary.

No, I have checked the chromium code now, and the only place that uses the returned position hitTestResultAtPoint is WebFrameImpl::characterIndexForPoint, and that one should work more correctly now.
Comment 3 Allan Sandfeld Jensen 2012-09-13 07:56:55 PDT
Possibly related to bug #96541
Comment 4 Julien Chaffraix 2012-09-13 08:27:52 PDT
(In reply to comment #3)
> Possibly related to bug #96541

Tried the fix locally but it didn't solve the issue AFAICT.

(In reply to comment #2)
> (In reply to comment #1)
> > I can not reproduce the issue on Qt either.
> > 
> > I have a guess on the cause though. EventHandler::hitTestResultAtPoint used to have a quirk/bug where it changed the result.point() so that after the function it was in the coordinates of the last frame it hit-tested. It no longer does that, if you use that position for the context menu have code that corrects for the old bug, it might be wrong now that it is no longer necessary.

Toying with the example, this is exactly the issue. We seem to be converting the result of hitTestResultAtPoint to the window coordinates, therefore adding the iframe's position twice to the context menu's top left point.

> No, I have checked the chromium code now, and the only place that uses the returned position hitTestResultAtPoint is WebFrameImpl::characterIndexForPoint, and that one should work more correctly now.

After your change, anything that manipulates the returned position from hitTestResultAtPoint across frames can be wrong. I am not super happy that this was completely overlooked. Debugging the issue, ContextMenuController is doing exactly that and would be my bet for what is wrong.
Comment 5 Allan Sandfeld Jensen 2012-09-13 08:40:53 PDT
(In reply to comment #4)
> (In reply to comment #3)
> > Possibly related to bug #96541
> 
> Tried the fix locally but it didn't solve the issue AFAICT.
> 
> (In reply to comment #2)
> > (In reply to comment #1)
> > > I can not reproduce the issue on Qt either.
> > > 
> > > I have a guess on the cause though. EventHandler::hitTestResultAtPoint used to have a quirk/bug where it changed the result.point() so that after the function it was in the coordinates of the last frame it hit-tested. It no longer does that, if you use that position for the context menu have code that corrects for the old bug, it might be wrong now that it is no longer necessary.
> 
> Toying with the example, this is exactly the issue. We seem to be converting the result of hitTestResultAtPoint to the window coordinates, therefore adding the iframe's position twice to the context menu's top left point.
> 
Okay, at least that is better than not knowing the source.

> > No, I have checked the chromium code now, and the only place that uses the returned position hitTestResultAtPoint is WebFrameImpl::characterIndexForPoint, and that one should work more correctly now.
> 
> After your change, anything that manipulates the returned position from hitTestResultAtPoint across frames can be wrong. I am not super happy that this was completely overlooked. Debugging the issue, ContextMenuController is doing exactly that and would be my bet for what is wrong.

It wasn't overlooked, I checked all the call sites I could find of the function, and in the places I found that used the position it would either not make a difference, or would actually fix rare corner cases. I will take a deeper look at the contextMenuController. In general though the point in hitTestResult should probably be deprecated, it is just a left-over from when HitTestPoint and HitTestResult were the same.
Comment 6 Julien Chaffraix 2012-09-13 10:58:20 PDT
Created attachment 163909 [details]
Proposed fix. Tested on Chromium Linux, need testing on Chromium Mac. Would love to test that.
Comment 7 Julien Chaffraix 2012-09-13 11:42:55 PDT
Created attachment 163920 [details]
Proposed fix: Same as previously, ChangeLog updated, passes Mac testing.
Comment 8 Julien Chaffraix 2012-09-13 11:43:40 PDT
CC'ing some people who have reviewed this code in the past.
Comment 9 Adam Barth 2012-09-13 13:10:24 PDT
Comment on attachment 163920 [details]
Proposed fix: Same as previously, ChangeLog updated, passes Mac testing.

ok
Comment 10 Julien Chaffraix 2012-09-13 13:25:07 PDT
Comment on attachment 163920 [details]
Proposed fix: Same as previously, ChangeLog updated, passes Mac testing.

Actually need to update the bug title.
Comment 11 Julien Chaffraix 2012-09-13 13:29:18 PDT
Created attachment 163950 [details]
Patch for landing
Comment 12 WebKit Review Bot 2012-09-13 14:05:32 PDT
Comment on attachment 163950 [details]
Patch for landing

Clearing flags on attachment: 163950

Committed r128505: <http://trac.webkit.org/changeset/128505>
Comment 13 WebKit Review Bot 2012-09-13 14:05:38 PDT
All reviewed patches have been landed.  Closing bug.
Comment 14 Allan Sandfeld Jensen 2012-09-13 15:49:11 PDT
I believe from reading the source code that the webkit1 win-platform (I guess Safari on Windows?), have the same issue. It would be great if someone could confirm it, and we could fix it.
Comment 15 Jessie Berlin 2012-09-14 16:03:25 PDT
http://trac.webkit.org/changeset/127457 also broke Apple Mac context menus, not just Chromium context menus.

The fix in http://trac.webkit.org/changeset/128505 only fixed Chromium.
Comment 16 Julien Chaffraix 2012-09-14 16:15:24 PDT
(In reply to comment #15)
> http://trac.webkit.org/changeset/127457 also broke Apple Mac context menus, not just Chromium context menus.
> 
> The fix in http://trac.webkit.org/changeset/128505 only fixed Chromium.

Yes, my apologies for just fixing one platform without looking at the others. For the record, the fix in this bug will be rolled out along r127457 in bug 96830 as the approach has caused (at least) another regression.