Closed
Bug 630811
Opened 14 years ago
Closed 13 years ago
Implement DOM3 KeyboardEvent.getModifierState()
Categories
(Core :: DOM: Events, defect)
Core
DOM: Events
Tracking
()
RESOLVED
FIXED
mozilla15
People
(Reporter: masayuki, Assigned: masayuki)
References
(Depends on 2 open bugs, Blocks 1 open bug, )
Details
(Keywords: dev-doc-complete)
Attachments
(8 files, 5 obsolete files)
21.75 KB,
patch
|
smaug
:
review+
|
Details | Diff | Splinter Review |
78.68 KB,
patch
|
smaug
:
review+
|
Details | Diff | Splinter Review |
15.69 KB,
patch
|
smaug
:
review+
|
Details | Diff | Splinter Review |
6.10 KB,
patch
|
jimm
:
review+
|
Details | Diff | Splinter Review |
9.80 KB,
patch
|
karlt
:
review+
|
Details | Diff | Splinter Review |
9.75 KB,
patch
|
Details | Diff | Splinter Review | |
20.93 KB,
patch
|
jst
:
superreview+
|
Details | Diff | Splinter Review |
1.83 KB,
text/html
|
Details |
We cannot know whether some modifier keys are pressed or not:
1. Windows key on Windows
2. Windows key which is mapped to Super key on Linux
3. Hyper key on Linux.
For them, we should implement KeyboardEvent.getModifierState().
Updated•13 years ago
|
Assignee | ||
Comment 1•13 years ago
|
||
Assignee | ||
Comment 2•13 years ago
|
||
Attachment #616428 -
Flags: review?(bugs)
Assignee | ||
Comment 3•13 years ago
|
||
This replaces is* with Is*() or just removes them. Not changing any logic.
Assignee | ||
Updated•13 years ago
|
Attachment #616432 -
Flags: review?(bugs)
Assignee | ||
Comment 4•13 years ago
|
||
Attachment #616436 -
Flags: review?(bugs)
Assignee | ||
Comment 5•13 years ago
|
||
Attachment #616437 -
Flags: review?(jmathies)
Assignee | ||
Comment 6•13 years ago
|
||
Attachment #616438 -
Flags: review?(karlt)
Assignee | ||
Comment 7•13 years ago
|
||
> - nsDragEvent geckoEvent(true, aMessage, nsnull);
> - [self convertGenericCocoaEvent:[NSApp currentEvent] toGeckoEvent:&geckoEvent];
> + nsDragEvent geckoEvent(true, aMessage, mGeckoChild);
> + nsCocoaUtils::InitInputEvent(geckoEvent, [NSApp currentEvent]);
I realized that this always fails to initialize modifiers. I think that we should store latest modifiers by other events and use it. But I think we should do it in another bug.
Attachment #616440 -
Flags: review?(smichaud)
Assignee | ||
Comment 8•13 years ago
|
||
Attachment #616441 -
Flags: review?(bugs)
Assignee | ||
Updated•13 years ago
|
Status: NEW → ASSIGNED
Assignee | ||
Comment 9•13 years ago
|
||
This works with IE9 too.
Attachment #616410 -
Attachment is obsolete: true
Assignee | ||
Updated•13 years ago
|
Attachment #616448 -
Attachment is patch: false
Attachment #616448 -
Attachment mime type: text/plain → text/html
Comment 10•13 years ago
|
||
Comment on attachment 616437 [details] [diff] [review]
part.4 Support new modifiers on all events derived from nsInputEvent on Windows
Functionality looks fine. r+ assuming this fits with the new spec.
Attachment #616437 -
Flags: review?(jmathies) → review+
Comment 11•13 years ago
|
||
Comment on attachment 616440 [details] [diff] [review]
part.6 Support new modifiers on all events derived from nsInputEvent on Cocoa
This looks fine to me.
I do have one question, though.
+ // Remove basic modifiers from keypress event because if they are included,
+ // nsPlaintextEditor ignores the event.
+ keypressEvent.modifiers &= ~(widget::MODIFIER_CONTROL |
+ widget::MODIFIER_ALT |
+ widget::MODIFIER_META);
Wouldn't it make better sense to move this to just before the
following lines?
// TODO:
// If mCurrentKeyEvent.mKeyEvent is null and when we implement textInput
// event of DOM3 Events, we should dispatch it instead of keypress event.
bool keyPressHandled = DispatchEvent(keypressEvent);
'keypressEvent' will get initialized with modifiers (by
nsCocoaUtils::InitInputEvent()) whether or not 'currentKeyEvent' is
nil. Currently you only remove them if if 'currentKeyEvent' is
non-nil.
Attachment #616440 -
Flags: review?(smichaud) → review+
Assignee | ||
Comment 12•13 years ago
|
||
(In reply to Steven Michaud from comment #11)
> Comment on attachment 616440 [details] [diff] [review]
> part.6 Support new modifiers on all events derived from nsInputEvent on Cocoa
>
> This looks fine to me.
>
> I do have one question, though.
>
> + // Remove basic modifiers from keypress event because if they are
> included,
> + // nsPlaintextEditor ignores the event.
> + keypressEvent.modifiers &= ~(widget::MODIFIER_CONTROL |
> + widget::MODIFIER_ALT |
> + widget::MODIFIER_META);
>
> Wouldn't it make better sense to move this to just before the
> following lines?
>
> // TODO:
> // If mCurrentKeyEvent.mKeyEvent is null and when we implement textInput
> // event of DOM3 Events, we should dispatch it instead of keypress event.
> bool keyPressHandled = DispatchEvent(keypressEvent);
>
> 'keypressEvent' will get initialized with modifiers (by
> nsCocoaUtils::InitInputEvent()) whether or not 'currentKeyEvent' is
> nil. Currently you only remove them if if 'currentKeyEvent' is
> non-nil.
Oh, you're right. Thank you, I'll update it.
Updated•13 years ago
|
Attachment #616438 -
Flags: review?(karlt) → review+
Assignee | ||
Comment 13•13 years ago
|
||
updated for the review comment.
Attachment #616440 -
Attachment is obsolete: true
Comment 14•13 years ago
|
||
Comment on attachment 616428 [details] [diff] [review]
part.1 Move modifiers from nsMouseEvent_base to nsInputEvent
> NS_IMETHODIMP
> nsDOMKeyboardEvent::GetAltKey(bool* aIsDown)
> {
> NS_ENSURE_ARG_POINTER(aIsDown);
>- *aIsDown = ((nsInputEvent*)mEvent)->isAlt;
>+ *aIsDown = ((nsInputEvent*)mEvent)->IsAlt();
While you're here, could you change the C style casting to
C++ static_cast
>+ widget::Modifiers modifiers = static_cast<nsInputEvent*>(mEvent)->modifiers;
> if (aKey.EqualsLiteral(NS_DOM_KEYNAME_SHIFT)) {
>- return static_cast<nsInputEvent*>(mEvent)->isShift;
>+ return (modifiers & widget::MODIFIER_SHIFT) != 0;
> }
> if (aKey.EqualsLiteral(NS_DOM_KEYNAME_CONTROL)) {
>- return static_cast<nsInputEvent*>(mEvent)->isControl;
>+ return (modifiers & widget::MODIFIER_CONTROL) != 0;
> }
> if (aKey.EqualsLiteral(NS_DOM_KEYNAME_META)) {
>- return static_cast<nsInputEvent*>(mEvent)->isMeta;
>+ return (modifiers & widget::MODIFIER_META) != 0;
> }
> if (aKey.EqualsLiteral(NS_DOM_KEYNAME_ALT)) {
>- return static_cast<nsInputEvent*>(mEvent)->isAlt;
>+ return (modifiers & widget::MODIFIER_ALT) != 0;
> }
>
> if (aKey.EqualsLiteral(NS_DOM_KEYNAME_ALTGRAPH)) {
> return (modifiers & widget::MODIFIER_ALTGRAPH) != 0;
> }
> if (aKey.EqualsLiteral(NS_DOM_KEYNAME_WIN)) {
> return (modifiers & widget::MODIFIER_WIN) != 0;
> }
So why use modifiers & foo here, and not the helper methods, isAlt() etc. ?
I'd prefer using the methods. Perhaps there should be helpers for altgr and win modifiers too.
Attachment #616428 -
Flags: review?(bugs) → review+
Updated•13 years ago
|
Attachment #616432 -
Flags: review?(bugs) → review+
Comment 15•13 years ago
|
||
Comment on attachment 616436 [details] [diff] [review]
part.3 Improve nsDOMWindowUtils::send*Event() for new modifiers
> nsMouseEvent event(true, msg, widget, nsMouseEvent::eReal,
> contextMenuKey ?
> nsMouseEvent::eContextMenuKey : nsMouseEvent::eNormal);
>- event.isShift = (aModifiers & nsIDOMNSEvent::SHIFT_MASK) ? true : false;
>- event.isControl = (aModifiers & nsIDOMNSEvent::CONTROL_MASK) ? true : false;
>- event.isAlt = (aModifiers & nsIDOMNSEvent::ALT_MASK) ? true : false;
>- event.isMeta = (aModifiers & nsIDOMNSEvent::META_MASK) ? true : false;
>+ event.modifiers =GetWidgetModifiers(aModifiers);
space after =
Attachment #616436 -
Flags: review?(bugs) → review+
Updated•13 years ago
|
Attachment #616441 -
Flags: review?(bugs) → review+
Assignee | ||
Comment 16•13 years ago
|
||
Thank you for the quick review, smaug!
(In reply to Olli Pettay [:smaug] from comment #14)
> Comment on attachment 616428 [details] [diff] [review]
> part.1 Move modifiers from nsMouseEvent_base to nsInputEvent
> So why use modifiers & foo here, and not the helper methods, isAlt() etc. ?
> I'd prefer using the methods. Perhaps there should be helpers for altgr and
> win modifiers too.
Did you mean only for AltGraph and Win? How about the others, i.e., CapsLock, NumLock, Scroll, Fn, and SymbolLock? Currently, we will support only CapsLock, NumLock and Scroll at dispatching native event. Fn and SymbolLock are supported only for untrusted events. I think that the former 3 might be used in the future.
Assignee | ||
Comment 17•13 years ago
|
||
Attachment #616441 -
Attachment is obsolete: true
Attachment #617731 -
Flags: superreview?(jst)
Updated•13 years ago
|
Attachment #617731 -
Flags: superreview?(jst) → superreview+
Comment 18•13 years ago
|
||
(In reply to Masayuki Nakano (:masayuki) (Mozilla Japan) (away: 4/29 - 5/6) from comment #16)
> (In reply to Olli Pettay [:smaug] from comment #14)
>
> Did you mean only for AltGraph and Win? How about the others, i.e.,
> CapsLock, NumLock, Scroll, Fn, and SymbolLock?
I mean all. Adding helper methods to get the value would be nice.
Assignee | ||
Comment 19•13 years ago
|
||
https://hg.mozilla.org/integration/mozilla-inbound/rev/bf567dc0cd5b
https://hg.mozilla.org/integration/mozilla-inbound/rev/c3dfd5f66400
https://hg.mozilla.org/integration/mozilla-inbound/rev/1d4b48e5f7e0
https://hg.mozilla.org/integration/mozilla-inbound/rev/fe8112c0b9de
https://hg.mozilla.org/integration/mozilla-inbound/rev/575e562a8898
https://hg.mozilla.org/integration/mozilla-inbound/rev/f38b80d2743d
https://hg.mozilla.org/integration/mozilla-inbound/rev/b032eb5936c1
Target Milestone: --- → mozilla15
Comment 20•13 years ago
|
||
https://hg.mozilla.org/mozilla-central/rev/bf567dc0cd5b
https://hg.mozilla.org/mozilla-central/rev/c3dfd5f66400
https://hg.mozilla.org/mozilla-central/rev/1d4b48e5f7e0
https://hg.mozilla.org/mozilla-central/rev/fe8112c0b9de
https://hg.mozilla.org/mozilla-central/rev/575e562a8898
https://hg.mozilla.org/mozilla-central/rev/f38b80d2743d
https://hg.mozilla.org/mozilla-central/rev/b032eb5936c1
Status: ASSIGNED → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
Updated•13 years ago
|
Keywords: dev-doc-needed
Assignee | ||
Comment 21•13 years ago
|
||
Assignee | ||
Comment 22•13 years ago
|
||
Attachment #616448 -
Attachment is obsolete: true
Assignee | ||
Comment 23•11 years ago
|
||
Attachment #640488 -
Attachment is obsolete: true
Comment 24•10 years ago
|
||
Documentation:
https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent.getModifierState
and
https://developer.mozilla.org/en-US/Firefox/Releases/15#DOM
Keywords: dev-doc-needed → dev-doc-complete
You need to log in
before you can comment on or make changes to this bug.
Description
•