Bug 188913

Summary: Add getModifierState to MouseEvent
Product: WebKit Reporter: Ryosuke Niwa <rniwa>
Component: UI EventsAssignee: Ryosuke Niwa <rniwa>
Status: RESOLVED FIXED    
Severity: Normal CC: cdumez, darin, dbates, esprehn+autocc, ews-watchlist, kangil.han, kondapallykalyan, sam, simon.fraser, thorton, webkit-bug-importer, wenson_hsieh
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Adds the method
none
Fixed iOS tests simon.fraser: review+

Description Ryosuke Niwa 2018-08-23 19:13:41 PDT
Right now, getModifierState only exists on KeyboardEvent but it's also supposed to be on MouseEvent.
Comment 1 Radar WebKit Bug Importer 2018-08-23 19:13:58 PDT
<rdar://problem/43668772>
Comment 2 Ryosuke Niwa 2018-08-23 20:35:18 PDT
Created attachment 347985 [details]
Adds the method
Comment 3 Ryosuke Niwa 2018-08-23 22:21:42 PDT
Created attachment 347989 [details]
Fixed iOS tests
Comment 4 Simon Fraser (smfr) 2018-08-24 10:33:43 PDT
Comment on attachment 347989 [details]
Fixed iOS tests

View in context: https://bugs.webkit.org/attachment.cgi?id=347989&action=review

> Source/WebCore/ChangeLog:13
> +        This patch also fixes the bug r235158 purposefully preserved that initMouseEvent was not clearing
> +        AltGraph and CapsLock states.

This is not a readable sentence.

> Source/WebCore/dom/UIEventWithKeyState.cpp:57
> +    if (keyIdentifier == "Control")
> +        return ctrlKey();
> +    if (keyIdentifier == "Shift")
> +        return shiftKey();
> +    if (keyIdentifier == "Alt")
> +        return altKey();
> +    if (keyIdentifier == "Meta")
> +        return metaKey();
> +    if (keyIdentifier == "AltGraph")
> +        return altGraphKey();
> +    if (keyIdentifier == "CapsLock")
> +        return capsLockKey();

Are these supposed to be case-sensitive comparisons? Can we use AtomicStrings here? Should the standard names be constants in the code?

> LayoutTests/ChangeLog:10
> +        Added two tests for getModifierState: one manually setting modifier key states in MouseEvent's constructor,
> +        and another one for dblclick inheriting modifier key states from the click event.

Are there really no WPT tests for these?
Comment 5 Ryosuke Niwa 2018-08-24 13:04:33 PDT
(In reply to Simon Fraser (smfr) from comment #4)
> Comment on attachment 347989 [details]
> Fixed iOS tests
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=347989&action=review
> 
> > Source/WebCore/ChangeLog:13
> > +        This patch also fixes the bug r235158 purposefully preserved that initMouseEvent was not clearing
> > +        AltGraph and CapsLock states.
> 
> This is not a readable sentence.

Fixed per in-person discussion.

> > Source/WebCore/dom/UIEventWithKeyState.cpp:57
> > +    if (keyIdentifier == "Control")
> > +        return ctrlKey();
> > +    if (keyIdentifier == "Shift")
> > +        return shiftKey();
> > +    if (keyIdentifier == "Alt")
> > +        return altKey();
> > +    if (keyIdentifier == "Meta")
> > +        return metaKey();
> > +    if (keyIdentifier == "AltGraph")
> > +        return altGraphKey();
> > +    if (keyIdentifier == "CapsLock")
> > +        return capsLockKey();
> 
> Are these supposed to be case-sensitive comparisons? Can we use
> AtomicStrings here? Should the standard names be constants in the code?

The spec doesn't specify but both Chrome & Firefox does case-sensitive comparison as we do. I don't think it makes senes to use AtomicString her since the input to getModifierState isn't necessarily AtomicString.

> > LayoutTests/ChangeLog:10
> > +        Added two tests for getModifierState: one manually setting modifier key states in MouseEvent's constructor,
> > +        and another one for dblclick inheriting modifier key states from the click event.
> 
> Are there really no WPT tests for these?

Unfortunately not. There are literally no getModifierState tests other than IDL and one test Microsoft added.
Comment 6 Ryosuke Niwa 2018-08-24 13:07:30 PDT
Filed https://github.com/w3c/uievents/issues/211 to the case sensitive comparison in the spec.
Comment 7 Ryosuke Niwa 2018-08-24 13:07:38 PDT
Committed r235329: <https://trac.webkit.org/changeset/235329>
Comment 8 Lucas Forschler 2019-02-06 09:18:38 PST
Mass move bugs into the DOM component.