Closed Bug 692183 Opened 10 years ago Closed 10 years ago
Incorrect behavior of prevent
Default() when used with context menu
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:7.0.1) Gecko/20100101 Firefox/7.0.1 Build ID: 20110928134238 Steps to reproduce: Please visit this page: mozilla.github.com/icongrid I am overriding the press-and-hold behavior by preventDefault() on the context menu event, and substituting my own. I am using the latest nightly of Fennec. Actual results: If, and only if, the page is not scrolled at all, then press-and-hold on an icon behaves correctly. Pressing for 1 second lifts the icon from the page, allowing you to reposition it. No context menu is shown. However, if the page is scrolled up even 1 pixel, this behavior does NOT happen, but instead it appears the the coordinate system is changed out from under me, causing the press and hold to fail. Expected results: The correct behavior should happen no matter how the page is scrolled. Please note that the correct behavior is observed on every other platform tested: Firefox Chrome Safari Safari Mobile Android default webkit browser.
A testcase would be nice.
I gave you a test case. Visit the page mentioned above: mozilla.github.com/icongrid, and follow the trivial steps mentioned above.
This is probably because e.touches.clientY returns something different in Fennec. That value seems in Fennec the vertical offset in the window plus the amount scrolled. In the Android stock browser, it's the vertical offset in the window.
The github example page seems to work now? Have you fixed something on your end? Is there still a bug in Fennec that we need to address. Martjin, your problem seems different. If there's a difference, can you file a separate bug to find out which impelementation is right.
No, the github page does not work. Be sure to scroll the page slightly to see the problem. I can demonstrate it for you if you are local to MV, I'm on second floor.
Not in MV. Looked into this some more, but I think the description here is wrong and Martijn's right. In every test I can throw at it, contextmenu is fired and preventDefault works. But AFAICT, your page doesn't use the contextmenu event for anything but hiding the context menu, which works. A reduced test case would probably have made this much easier to diagnose. The page is doing its own "longtap" detection by setting a timer on touchdown. They also register to pick up mouse events. We fire a mousemove event a few hundred ms after touchdown. The page compares the coordinates of touchdown and mousemove events and they don't match. We fire mouse events using DOMWindowUtils which automatically does the correct pixel conversions for us. We fire touchdown events using our own coordinates. This just makes us correct for client offset. I'm a bit worried about iframes... may need to look at this more. Note for Dan, if you call preventDefault on the touch events, we won't fire mouse events and you won't have this cross pollination problem. You also won't see our sidebars or the urlbar in us or other browsers pan in. Glad we found the real bug though.
Assignee: nobody → wjohnston
Attachment #565109 - Flags: review?(mbrubeck)
Attachment #565109 - Flags: review?(mbrubeck) → review+
wesj: and the real bug is that the e.touches.clientY is incorrect? any chance this will make it into a soonish nightly?
Dan, you could adjust your code to circumvent this bug.
Status: NEW → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 10
Comment on attachment 565109 [details] [diff] [review] Patch nominating this for aurora. this is low risk and fixes bad behavior in our original touch events implementation.
Attachment #565109 - Flags: approval-mozilla-aurora?
Attachment #565109 - Flags: approval-mozilla-aurora? → approval-mozilla-aurora+
Build ID: Mozilla/5.0 (Android; Linux armv7l; rv:9.0a2) Gecko/20111017 Firefox/9.0a2 Fennec/9.0a2 Device: HTC Desire Z OS: Android 2.3 Verified issue on above environment: - If page is scrolled then press-and-hold on an icon behaves correctly: pressing for 1 second lifts the icon from the page, allowing you to reposition it. No context menu is shown. - OK - If page is NOT scrolled then pressing for 1 second lifts the icon from the page, allowing you to reposition it and also the entire page is scrolled up/down or left/right panels are displayed if moving icon left/right. Is this related to this bug or is it a new issue? I will reopen the bug for now. If this is a different issue I will close this bug and open a new one.
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Sounds like a new bug, seems to work for me, btw.
Status: REOPENED → RESOLVED
Closed: 10 years ago → 10 years ago
Resolution: --- → FIXED
Bug #695317 was logged for issue described in comment #14. BAsed on previous 2 comments, marking bug as verified fixed.
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.