[Android] preventDefault() in contextmenu listener cancels touch event generation (sends touchcancel)
Categories
(Core :: Panning and Zooming, defect, P2)
Tracking
()
Tracking | Status | |
---|---|---|
firefox91 | --- | fixed |
People
(Reporter: CoolCmd, Assigned: hiro)
References
()
Details
Attachments
(2 files, 1 obsolete file)
Comment 2•6 years ago
|
||
Comment 3•6 years ago
|
||
Comment 5•6 years ago
|
||
Comment 6•6 years ago
|
||
Comment 7•6 years ago
|
||
Updated•6 years ago
|
Updated•6 years ago
|
Updated•6 years ago
|
Comment 9•4 years ago
|
||
Hi Guys :)
This behavior has turned out to be a serious problem while implementing logic which is based on touch and hold interaction for a web based framework I'm working on. Calling preventDefault from the touchstart event handler causes further problems, as other defaults are prevented too in addition to the context menu approach. And its working fine with all major Desktop Browser (including Firefox) and the most (haven't tested with a lot of smaller mobile browser packages so far) important mobile browsers.
So i decided to try my luck and bump that issue item up again :)
I would appreciate if someone of you could give an estimate if this issue will be fixed in foreseeable future or if i have to live with this issue for longer.
Comment 10•4 years ago
|
||
The touchcancel is from https://searchfox.org/mozilla-central/rev/0dfbe5a699cc6c73cf8c14d1aa10ba10ef3ec8fa/gfx/layers/apz/util/APZEventState.cpp#282-291.
Updated•4 years ago
|
Comment 11•4 years ago
|
||
The original behavoir was added in Bug 1231570 where we found a webpage did some
tricky things on touchend that causes navigation while we long-tap on a link.
However, other browsers doesn't send touchcancel event anymore when we prevent-default
a contextmenu event, so remove this as well for web compatibility. If we encounter
the similar issue as Bug 1231570 again, we probably need to check how does the
page behave on other browsers, and does the page do different things via UA Sniffing.
Assignee | ||
Comment 13•3 years ago
|
||
CCing Karl since I believe this is a sort of webcompat issue. I wonder whether he has ever seen this kind of issue.
Updated•3 years ago
|
Assignee | ||
Comment 14•3 years ago
|
||
kats left a very important comment in that bug from bug 1231570 comment 14;
After long-pressing on the link, the context menu popup makes Android send us a touchup, we should figure out a way to detect that and turn it into a touchcancel.
And there is another interesting comment we should care (from bug bug 1231570 comment 15);
Yeah, pre-APZ fennec and Chrome both send touchcancel after a handled contextmenu event, so we should be doing the same, probably in C++ code somewhere. I'm just not sure where the right place to do it is. Randall, any thoughts?
So, I believe the original case in bug 1231570 still applicable, but what we should really do is to fire a touchcancel even only if context menu opens. That means we need to differentiate the preventDefault() call in GeckoView when opening context menu. Luckily in the GeckoView's preventDefault() call, mDefaultPreventedByChrome flag is true, so that we can tell the difference.
Comment 15•3 years ago
|
||
So from the top of my head, I don't remember webcompat issues about this but I agree that this should be fixed.
And the differences create headaches for devs. Now the risk is that if Mozilla fixes it, will it break sites. The first step would be to try in Nightly and sees if there are any webcompat issues reported.
There is also an open issue about it.
Define interactions with contextmenu event?
Comment 16•3 years ago
|
||
Using https://codepen.io/webcompat/pen/gOmRKee
On Mobile
- Firefox Nightly 90.0a1 Build #2015812491
- Chrome Canary 92.0.4506.0
- Safari 14.1
Firefox
- touchstart
- contextmenu (no vibration)
- touchcancel
Chrome
- touchstart
- contextmenu (vibration)
- touchend
Safari
- touchstart
- (text selection is showed then removed + vibration. no contextmenu event)
- touchend
Assignee | ||
Comment 17•3 years ago
|
||
On a long press touch event we fire a contextmenu event and if the contextmenu
is opening, we fire a touchcancel event. Unfortunately we had been checking
the return value, nsEventStatus, from nsIWidget::DispatchInputEvent via
nsContentUtils::SendMouseEvent to tell whether the context menu is opening or
not. So, we unintentionally fire the touchcancel event if the context menu is
NOT going to be opened because of preventDefault() in a contextmenu event
listener in the content itself.
NOTE: The oparator<< for the new PreventDefaultResult enum will be used in
APZ logging code.
Assignee | ||
Comment 18•3 years ago
|
||
This approach is applicable for Android only since Android is the only one
platform we call preventDefault() [1] when opening context menu.
Depends on D115963
Assignee | ||
Comment 19•3 years ago
|
||
Though I've finished writing a reasonable fix, firing a touchcancel event only if context menu is opened. That said, I am not yet convinced whether we should fire the touchcancel event when the web site opens its own context menu such as Google Docs or something like that. We also need to check what Chrome does on Google Docs at least. Note that with the fix I posted we probably no longer fire the touchcancel when opening the Google Doc's context menu (I haven't checked though).
(In reply to Karl Dubost💡 :karlcow from comment #15)
So from the top of my head, I don't remember webcompat issues about this but I agree that this should be fixed.
And the differences create headaches for devs. Now the risk is that if Mozilla fixes it, will it break sites. The first step would be to try in Nightly and sees if there are any webcompat issues reported.
Yeah, agree. we should try it in Nightly first.
Assignee | ||
Comment 20•3 years ago
|
||
I just checked a Google document on Fenix, and it looks like they don't allow editing documents on browsers (I've also checked on mobile Chrome), so we can't see their own context menu. And Karl also tried to see it on Microsoft Office sites, he said it's the same situation as what Google Docs does.
So I suppose presumably it doesn't much matter even if we no longer fire touchcancel events when preventDefailt() was called in contextmenu eventhandlers in contents, since it will also mach Chrome and Safari behaviors as Karl described in comment 16.
Updated•3 years ago
|
Updated•3 years ago
|
Updated•3 years ago
|
Comment 21•3 years ago
|
||
Thanks for looking into this, :hiro. I think your solution is more reasonable than mine :)
Since you already have a patch, hand this bug to you.
Updated•3 years ago
|
Comment 22•3 years ago
|
||
Comment 23•3 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/2cdf4ddd5141
https://hg.mozilla.org/mozilla-central/rev/83495e0289f9
Description
•