Bug 86694 - Implement DOM_KEY_LOCATION_LEFT and RIGHT of KeyboardEvent's location property
Summary: Implement DOM_KEY_LOCATION_LEFT and RIGHT of KeyboardEvent's location property
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: UI Events (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on: 87219
Blocks: 69029
  Show dependency treegraph
 
Reported: 2012-05-16 18:35 PDT by Takashi Sakamoto
Modified: 2012-06-22 00:28 PDT (History)
7 users (show)

See Also:


Attachments
Patch (17.41 KB, patch)
2012-05-16 23:10 PDT, Takashi Sakamoto
no flags Details | Formatted Diff | Diff
Patch (17.55 KB, patch)
2012-05-17 23:07 PDT, Takashi Sakamoto
no flags Details | Formatted Diff | Diff
Patch (17.56 KB, patch)
2012-05-21 00:04 PDT, Takashi Sakamoto
no flags Details | Formatted Diff | Diff
Patch (17.58 KB, patch)
2012-05-21 23:56 PDT, Takashi Sakamoto
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Takashi Sakamoto 2012-05-16 18:35:44 PDT
Add DOM_KEY_LOCATION_LEFT and DOM_KEY_LOCATION_RIGHT to distinguish  between left-control and right-control, between left shift and right shift, and between left menu and right menu.
Currently only DOM_KEY_LOCATION_STANDARD and DOM_KEY_LOCATION_NUMPAD are implemented.

The location property is defined in the W3C DOM3 specification 
http://www.w3.org/TR/DOM-Level-3-Events/#events-keyboardevents
Comment 1 Takashi Sakamoto 2012-05-16 23:10:37 PDT
Created attachment 142419 [details]
Patch
Comment 2 Alexey Proskuryakov 2012-05-17 10:47:54 PDT
Comment on attachment 142419 [details]
Patch

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

Looks great.

> Source/WebCore/ChangeLog:25
> +        (WebCore):

Unhelpful cruft like this can be removed from ChangeLogs. This is just a bug in the script - it's meant to be helpful, not authoritative.

Thank you for providing helpful comments!

> Source/WebCore/dom/KeyboardEvent.cpp:57
> +static inline int getWindowsVirtualCodeWithoutLocation(int keycode)

In WebCore coding style, "get" prefix means that the result is returned via an out argument. So, just "windowsVirtualCodeWithoutLocation" would be right.

> Source/WebCore/dom/KeyboardEvent.cpp:74
> +static inline unsigned getKeyLocation(const PlatformKeyboardEvent& key)

Ditto.

Also, I don't understand why this returns unsigned, and not KeyboardEvent::KeyLocationCode.

> Tools/DumpRenderTree/mac/EventSendingController.mm:644
> +    } else if ([character isEqualToString:@"rightMenu"]) {

Perhaps "leftAlt" and "rightAlt" would be better for these. On Windows, the key that maps to VK_MENU is Alt, and on Mac, it's Option - calling that "Menu" is surprising and confusing, regardless of how the Windows API constant is named.

> LayoutTests/fast/events/keydown-leftright-keys.html:51
> +    testKeyEventWithLocation("rightShift", VK_SHIFT, KEY_LOCATION_RIGHT);

If you put KEY_LOCATION_RIGHT in quotes, will test output become easier to read?
Comment 3 Takashi Sakamoto 2012-05-17 23:07:57 PDT
Created attachment 142640 [details]
Patch
Comment 4 Takashi Sakamoto 2012-05-17 23:16:13 PDT
Thank you for reviewing.

(In reply to comment #2)
> (From update of attachment 142419 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=142419&action=review
> 
> Looks great.
> 
> > Source/WebCore/ChangeLog:25
> > +        (WebCore):
> 
> Unhelpful cruft like this can be removed from ChangeLogs. This is just a bug in the script - it's meant to be helpful, not authoritative.

I see. I removed.

> 
> Thank you for providing helpful comments!
> 
> > Source/WebCore/dom/KeyboardEvent.cpp:57
> > +static inline int getWindowsVirtualCodeWithoutLocation(int keycode)
> 
> In WebCore coding style, "get" prefix means that the result is returned via an out argument. So, just "windowsVirtualCodeWithoutLocation" would be right.

Done.

> > Source/WebCore/dom/KeyboardEvent.cpp:74
> > +static inline unsigned getKeyLocation(const PlatformKeyboardEvent& key)
> 
> Ditto.

Done.

> Also, I don't understand why this returns unsigned, and not KeyboardEvent::KeyLocationCode.

I see. I don't have enough reason.
Done.

> > Tools/DumpRenderTree/mac/EventSendingController.mm:644
> > +    } else if ([character isEqualToString:@"rightMenu"]) {
> 
> Perhaps "leftAlt" and "rightAlt" would be better for these. On Windows, the key that maps to VK_MENU is Alt, and on Mac, it's Option - calling that "Menu" is surprising and confusing, regardless of how the Windows API constant is named.

Done.

> 
> > LayoutTests/fast/events/keydown-leftright-keys.html:51
> > +    testKeyEventWithLocation("rightShift", VK_SHIFT, KEY_LOCATION_RIGHT);
> 
> If you put KEY_LOCATION_RIGHT in quotes, will test output become easier to read?

I agree. Done.
Comment 5 Alexey Proskuryakov 2012-05-18 10:10:02 PDT
Comment on attachment 142640 [details]
Patch

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

> Source/WebCore/dom/KeyboardEvent.cpp:74
> +static inline int keyLocationCode(const PlatformKeyboardEvent& key)

You changed the returned value to int, not to KeyboardEvent::KeyLocationCode. Is there something preventing you from using the latter?
Comment 6 Takashi Sakamoto 2012-05-21 00:04:46 PDT
Created attachment 142955 [details]
Patch
Comment 7 Takashi Sakamoto 2012-05-21 00:55:11 PDT
(In reply to comment #5)
> (From update of attachment 142640 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=142640&action=review
> 
> > Source/WebCore/dom/KeyboardEvent.cpp:74
> > +static inline int keyLocationCode(const PlatformKeyboardEvent& key)
> 
> You changed the returned value to int, not to KeyboardEvent::KeyLocationCode. Is there something preventing you from using the latter?

Sorry. I misunderstood your comment. I changed the code to use KeyboardEvent::KeyLocationCode type for returning value type of the function: WebCore::keyLocationCode.

Best regards,
Takashi Sakamoto
Comment 8 Hajime Morrita 2012-05-21 01:16:14 PDT
SInce you already got r+, you can
- Rewrite "Reviewed by" line with the reviewer's name and
- Upload the refined patch with no r?, but with cq+.
Comment 9 Takashi Sakamoto 2012-05-21 23:56:47 PDT
Created attachment 143202 [details]
Patch
Comment 10 Alexey Proskuryakov 2012-05-22 10:16:29 PDT
Comment on attachment 143202 [details]
Patch

As long as you are not a committer, you could have just set cq? on the previous patch.
Comment 11 WebKit Review Bot 2012-05-22 10:44:28 PDT
Comment on attachment 143202 [details]
Patch

Clearing flags on attachment: 143202

Committed r118001: <http://trac.webkit.org/changeset/118001>
Comment 12 WebKit Review Bot 2012-05-22 10:44:35 PDT
All reviewed patches have been landed.  Closing bug.
Comment 13 Jessie Berlin 2012-05-22 15:16:16 PDT
You updated keyDown in DRT, but forgot about WTR:

http://build.webkit.org/results/Lion%20Release%20(WebKit2%20Tests)/r118030%20(7431)/fast/events/keydown-leftright-keys-pretty-diff.html

I have a fix for this, but please try to remember about WTR in the future.
Comment 14 Jessie Berlin 2012-05-22 15:23:39 PDT
Fixed WTR in http://trac.webkit.org/changeset/118064.
Comment 15 Takashi Sakamoto 2012-05-30 21:57:52 PDT
(In reply to comment #14)
> Fixed WTR in http://trac.webkit.org/changeset/118064.

Thank you for fixing WTR, Jessie.
I didn't notice that I had to modify WTR. 

Best regards,
Takashi Sakamoto
Comment 16 Jessie Berlin 2012-05-31 08:33:51 PDT
(In reply to comment #15)
> (In reply to comment #14)
> > Fixed WTR in http://trac.webkit.org/changeset/118064.
> 
> Thank you for fixing WTR, Jessie.
> I didn't notice that I had to modify WTR. 
> 
> Best regards,
> Takashi Sakamoto

Windows also needed fixing: http://trac.webkit.org/changeset/118540
Comment 17 Yusuke Sato 2012-06-21 23:57:56 PDT
It seems that on Chrome for Windows (canary channel) the location property is still always zero.
Comment 18 Yusuke Sato 2012-06-22 00:28:04 PDT
Looks like you need to fix WebInputEventFactory::keyboardEvent() in Source/WebKit/chromium/src/win/WebInputEventFactory.cpp too:

WebKeyboardEvent WebInputEventFactory::keyboardEvent(HWND hwnd, UINT message,
                                                     WPARAM wparam, LPARAM lparam)
{
    WebKeyboardEvent result;

    // TODO(pkasting): http://b/1117926 Are we guaranteed that the message that  
    // GetMessageTime() refers to is the same one that we're passed in? Perhaps  
    // one of the construction parameters should be the time passed by the       
    // caller, who would know for sure.                                          
    result.timeStampSeconds = GetMessageTime() / 1000.0;

    result.windowsKeyCode = static_cast<int>(wparam);  // <--------------- HERE