Closed
Bug 1338369
Opened 9 years ago
Closed 9 years ago
Shift+F10 not throwing contextmenu event in javascript
Categories
(Core :: DOM: UI Events & Focus Handling, defect)
Tracking
()
RESOLVED
FIXED
mozilla55
Tracking | Status | |
---|---|---|
firefox55 | --- | fixed |
People
(Reporter: MSAOfficeWebApps, Assigned: masayuki)
References
Details
Attachments
(3 files)
User Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:51.0) Gecko/20100101 Firefox/51.0
Build ID: 20170125094131
Steps to reproduce:
On an html page that has an input element and javascript that attaches a custom function that prevents the default behavior to handle the "contextmenu" events in the input element type Shift+F10 as suggested in https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/PopupGuide/ContextMenus to run the handler function of the context menu.
Actual results:
The handler function is not called so the default behavior is not prevented.
The default browser's menu is displayed in the input element.
Expected results:
The handler function should have been called, preventing the default behavior of the browser.
Comment 1•9 years ago
|
||
Olli, are we just not intercepting the key events like we should?
Flags: needinfo?(bugs)
Comment hidden (obsolete) |
Reporter | ||
Comment 3•9 years ago
|
||
(In reply to Andrew Overholt [:overholt] from comment #1)
> Olli, are we just not intercepting the key events like we should?
Andrew, actually replying to your comment:
The Shift+F10 combination is displaying the default context menu of the browser instead of throwing the "contextmenu" event so it can be handled/prevented by the registered handler in the html page that's being displayed which should be the seen behavior according to the ContextMenus page at Mozilla's developer web site.
Yes, the browser is not intercepting the key events like it should.
Comment 4•9 years ago
|
||
Thanks for clarifying.
Masayuki knows lots about this kind of thing so maybe he can chime in.
Flags: needinfo?(bugs) → needinfo?(masayuki)
Comment 5•9 years ago
|
||
Silly me, I thought this was e10s specific, but looks like not, happens in non-e10s too
Assignee | ||
Comment 6•9 years ago
|
||
Ah, we must hit this path:
https://dxr.mozilla.org/mozilla-central/rev/32dcdde1fc64fc39a9065dc4218265dbc727673f/layout/base/PresShell.cpp#8035,8041-8042
I think that when Shift+F10 causes context menu event, its Shift key state should be consumed before dispatch like when Ctrl/Alt+foo causes inputting text.
Assignee: nobody → masayuki
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
Flags: needinfo?(masayuki)
Assignee | ||
Comment 7•9 years ago
|
||
Comment hidden (mozreview-request) |
Comment hidden (mozreview-request) |
Comment 10•9 years ago
|
||
mozreview-review |
Comment on attachment 8840966 [details]
Bug 1338369 part.1 nsWindow for Windows should consume Shift key state at dispatching eContextMenu event if it's caused by Shift+F10
https://reviewboard.mozilla.org/r/115346/#review116886
I guess we can do this. I would perhaps just changed the presshell code a bit, but I don't object this approach.
Attachment #8840966 -
Flags: review?(bugs) → review+
Comment 11•9 years ago
|
||
mozreview-review |
Comment on attachment 8840967 [details]
Bug 1338369 part.2 nsWindow for GTK should consume Shift key state of eContextMenu event if it's caused by Shift+F10
https://reviewboard.mozilla.org/r/115348/#review116888
Attachment #8840967 -
Flags: review?(bugs) → review+
Assignee | ||
Comment 12•9 years ago
|
||
(In reply to Olli Pettay [:smaug] (pto-ish for couple of days) from comment #10)
> I would perhaps just changed the presshell code a bit
Well, I though that if we fix this in PresShell side, we can do:
* Ignore Shift key immediately after F10
- This makes PresShell member too messy and not good approach because Shift+F10 is platform specific.
* Always ignore Shift key if eContextMenu caused by a key
- This makes users inconvenient if they use only keyboard.
Therefore, (I didn't want to change each widget, though,) I changed each widget.
But there is another issue.
ContextMenu key may not be in keyboard. For example, HHK (*1) doesn't have ContextMenu key but it's major product especially for such users who like to navigate browser without pointing device. And also MacBook series don't have ContextMenu key, so, when user installs Win or Linux to Mac, they cannot use ContextMenu key too. Thus, some users may open context menu only with Shift+F10, but they cannot override web pages which block to open context menu.
Do you have a good idea to solve this issue? Ctrl+Shift+F10 or Alt+Shift+F10 might be an option to fix this issue. But perhaps, these combinations are not easy to press and I worry about conflict with DevTools because DevTools team like Ctrl+Shift+Foo.
1: https://www.google.co.jp/search?q=HHK&client=firefox-b&source=lnms&tbm=isch&sa=X&ved=0ahUKEwid_e2ckKrSAhXMzLwKHc0TD0YQ_AUICCgB&biw=1296&bih=759#imgrc=cebh-lk5_Pk03M:
Flags: needinfo?(bugs)
Comment 13•9 years ago
|
||
(In reply to Masayuki Nakano [:masayuki] from comment #12)
> Do you have a good idea to solve this issue? Ctrl+Shift+F10 or Alt+Shift+F10
> might be an option to fix this issue. But perhaps, these combinations are
> not easy to press and I worry about conflict with DevTools because DevTools
> team like Ctrl+Shift+Foo.
Indeed. And also, how does anyone know about these shortcut keys.
But if devtools use Ctrl+Shift+foo rather often, perhaps Alt is fine.
How do other browsers deal with this? I couldn't figure out how to prevent contextmenu event (and just show the context menu) in Chrome/linux
Flags: needinfo?(bugs)
Assignee | ||
Comment 14•9 years ago
|
||
(In reply to Olli Pettay [:smaug] (high review load, queue closed for couple of days) from comment #13)
> (In reply to Masayuki Nakano [:masayuki] from comment #12)
>
> > Do you have a good idea to solve this issue? Ctrl+Shift+F10 or Alt+Shift+F10
> > might be an option to fix this issue. But perhaps, these combinations are
> > not easy to press and I worry about conflict with DevTools because DevTools
> > team like Ctrl+Shift+Foo.
> Indeed. And also, how does anyone know about these shortcut keys.
Honestly, Shift+Right-Click isn't so major. When I tweeted it, I see some tweets which are surprised at such function.
> But if devtools use Ctrl+Shift+foo rather often, perhaps Alt is fine.
Yeah, anyway, 3 keys are necessary though.
> How do other browsers deal with this? I couldn't figure out how to prevent
> contextmenu event (and just show the context menu) in Chrome/linux
I installed Chromium into my Ubuntu 16.10. However, I cannot override the context menu with mouse nor keyboard. (Same with Google Chrome on Windows)
Assignee | ||
Comment 15•9 years ago
|
||
jimm, karlt:
ping... If you don't want to review each patch or don't have much time, I'll land them without your review.
Flags: needinfo?(karlt)
Flags: needinfo?(jmathies)
Comment 16•9 years ago
|
||
mozreview-review |
Comment on attachment 8840967 [details]
Bug 1338369 part.2 nsWindow for GTK should consume Shift key state of eContextMenu event if it's caused by Shift+F10
https://reviewboard.mozilla.org/r/115348/#review120298
::: widget/gtk/nsWindow.cpp:3199
(Diff revision 1)
> + if (contextMenuEvent.IsControl() || contextMenuEvent.IsMeta() ||
> + contextMenuEvent.IsAlt()) {
> + return false;
> + }
> +
> + // If the key is ContextMenu key, we should not check its Shift state
Do you mean "we should not *change* its Shift state"?
::: widget/gtk/nsWindow.cpp:3200
(Diff revision 1)
> + // because when it's pressed without Shift state, web page should be able
> + // to prevent its default. Otherwise, with Shift state, web page shouldn't
> + // be able to prevent its default.
Can you name the function that implements this behavior in a comment here, please?
Otherwise someone might read this comment to mean that the code below implements this.
Attachment #8840967 -
Flags: review?(karlt) → review+
Comment 17•9 years ago
|
||
mozreview-review-reply |
Comment on attachment 8840967 [details]
Bug 1338369 part.2 nsWindow for GTK should consume Shift key state of eContextMenu event if it's caused by Shift+F10
https://reviewboard.mozilla.org/r/115348/#review120298
> Do you mean "we should not *change* its Shift state"?
Or perhaps "If the key is ContextMenu, then an eContextMenu mouse event is dispatched regardless of the state of the Shift modifier. When it is pressed without the Shift modifier, a web page can prevent the default context menu action. When pressed with the Shift modifier, the web page cannot prevent the default context menu action."
Updated•9 years ago
|
Flags: needinfo?(karlt)
Assignee | ||
Comment 18•9 years ago
|
||
mozreview-review |
Comment on attachment 8840967 [details]
Bug 1338369 part.2 nsWindow for GTK should consume Shift key state of eContextMenu event if it's caused by Shift+F10
https://reviewboard.mozilla.org/r/115348/#review120416
::: widget/gtk/nsWindow.cpp:3199
(Diff revision 1)
> + if (contextMenuEvent.IsControl() || contextMenuEvent.IsMeta() ||
> + contextMenuEvent.IsAlt()) {
> + return false;
> + }
> +
> + // If the key is ContextMenu key, we should not check its Shift state
Thank you, I'll take your suggestion!
::: widget/gtk/nsWindow.cpp:3200
(Diff revision 1)
> + // because when it's pressed without Shift state, web page should be able
> + // to prevent its default. Otherwise, with Shift state, web page shouldn't
> + // be able to prevent its default.
I'll add |(PresShell::HandleEventInternal() sets mOnlyChromeDispatch to true.)| here.
Comment hidden (mozreview-request) |
Comment hidden (mozreview-request) |
Assignee | ||
Comment 21•9 years ago
|
||
Okay, no response from jimm. He must be busy and I usually hack around keyboard layout on Windows too. So, I bet he doesn't have any objection about this patch. If there were, it should be fixed in follow up bug.
Flags: needinfo?(jmathies)
Assignee | ||
Updated•9 years ago
|
Attachment #8840966 -
Flags: review?(jmathies)
Comment 22•9 years ago
|
||
Pushed by masayuki@d-toybox.com:
https://hg.mozilla.org/integration/autoland/rev/6413896b93ff
part.1 nsWindow for Windows should consume Shift key state at dispatching eContextMenu event if it's caused by Shift+F10 r=smaug
https://hg.mozilla.org/integration/autoland/rev/c20235d9b540
part.2 nsWindow for GTK should consume Shift key state of eContextMenu event if it's caused by Shift+F10 r=karlt,smaug
![]() |
||
Comment 23•9 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/6413896b93ff
https://hg.mozilla.org/mozilla-central/rev/c20235d9b540
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
status-firefox55:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla55
Updated•7 years ago
|
Component: Event Handling → User events and focus handling
You need to log in
before you can comment on or make changes to this bug.
Description
•