Changeset 118001 in webkit


Ignore:
Timestamp:
May 22, 2012 10:45:13 AM (12 years ago)
Author:
commit-queue@webkit.org
Message:

Implement DOM_KEY_LOCATION_LEFT and RIGHT of KeyboardEvent's location property
https://bugs.webkit.org/show_bug.cgi?id=86694

Source/WebCore:

As KeyboardEvent for left/right location key, e.g. left-control,
right-control, provides DOM_KEY_LOCATION_STANDARD as keyLocation property,
modified KeyCodeConversion to make PlatformKeyboardEvent
provide virtual keycodes with location information, e.g. VK_LCONTROL or
VK_RCONTROL, and modified KeyboardEvent to generate location information
from the virtual keycodes, e.g. genrating DOM_KEY_LOCATION_LEFT for
VK_LCONTROL. KeyboardEvent also removes location information from
the virtual keycodes, e.g. genrating VK_CONTROL for VK_LCONTROL.
The location property is defined in the W3C DOM3 specification:
http://www.w3.org/TR/DOM-Level-3-Events/#events-keyboardevents

Patch by Takashi Sakamoto <tasak@google.com> on 2012-05-22
Reviewed by Alexey Proskuryakov.

Test: fast/events/keydown-leftright-keys.html

  • dom/KeyboardEvent.cpp:

(WebCore::windowsVirtualKeyCodeWithoutLocation):
Added a function which removes location information from a given
keycode. For example, when VK_LCONTROL is given, returns VK_CONTROL.
(WebCore::keyLocationCode):
Added a function which provides location information from a given
keycode. For example, when VK_LCONTROL is given,
returns DOM_KEY_LOCATION_LEFT.
(WebCore::KeyboardEvent::KeyboardEvent):
Initialized m_keyLocation by using the above keyLocationCode.
(WebCore::KeyboardEvent::keyCode):
Modified to use the above two functions to initialize keycode property
and keylocation property.

  • platform/chromium/KeyCodeConversionAndroid.cpp:

(WebCore::windowsKeyCodeForKeyEvent):

  • platform/chromium/KeyCodeConversionGtk.cpp:

(WebCore::windowsKeyCodeForKeyEvent):

  • platform/cocoa/KeyEventCocoa.mm:

(WebCore::windowsKeyCodeForKeyCode):
Modified these keycode conversions to return keycodes with location
information, e.g. modified keycode conversions returns VK_LCONTROL
for left control.

Tools:

Modify keyDown to create left- and right- control, shift, and alt
keyevent for a test to check that keyLocation property can have
DOM_KEY_LOCATION_LEFT for left-control, shift, and alt, and
DOM_KEY_LOCATION_RIGHT for right-control, shift, and alt.

Patch by Takashi Sakamoto <tasak@google.com> on 2012-05-22
Reviewed by Alexey Proskuryakov.

  • DumpRenderTree/chromium/EventSender.cpp:

(EventSender::keyDown):

  • DumpRenderTree/mac/EventSendingController.mm:

(-[EventSendingController keyDown:withModifiers:withLocation:]):

LayoutTests:

Patch by Takashi Sakamoto <tasak@google.com> on 2012-05-22
Reviewed by Alexey Proskuryakov.

  • fast/events/keydown-leftright-keys-expected.txt: Added.
  • fast/events/keydown-leftright-keys.html: Added.
Location:
trunk
Files:
2 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r118000 r118001  
     12012-05-22  Takashi Sakamoto  <tasak@google.com>
     2
     3        Implement DOM_KEY_LOCATION_LEFT and RIGHT of KeyboardEvent's location property
     4        https://bugs.webkit.org/show_bug.cgi?id=86694
     5
     6        Reviewed by Alexey Proskuryakov.
     7
     8        * fast/events/keydown-leftright-keys-expected.txt: Added.
     9        * fast/events/keydown-leftright-keys.html: Added.
     10
    1112012-05-22  Christophe Dumez  <christophe.dumez@intel.com>
    212
  • trunk/Source/WebCore/ChangeLog

    r117999 r118001  
     12012-05-22  Takashi Sakamoto  <tasak@google.com>
     2
     3        Implement DOM_KEY_LOCATION_LEFT and RIGHT of KeyboardEvent's location property
     4        https://bugs.webkit.org/show_bug.cgi?id=86694
     5
     6        As KeyboardEvent for left/right location key, e.g. left-control,
     7        right-control, provides DOM_KEY_LOCATION_STANDARD as keyLocation property,
     8        modified KeyCodeConversion to make PlatformKeyboardEvent
     9        provide virtual keycodes with location information, e.g. VK_LCONTROL or
     10        VK_RCONTROL, and modified KeyboardEvent to generate location information
     11        from the virtual keycodes, e.g. genrating DOM_KEY_LOCATION_LEFT for
     12        VK_LCONTROL. KeyboardEvent also removes location information from
     13        the virtual keycodes, e.g. genrating VK_CONTROL for VK_LCONTROL.
     14        The location property is defined in the W3C DOM3 specification:
     15        http://www.w3.org/TR/DOM-Level-3-Events/#events-keyboardevents
     16
     17        Reviewed by Alexey Proskuryakov.
     18
     19        Test: fast/events/keydown-leftright-keys.html
     20
     21        * dom/KeyboardEvent.cpp:
     22        (WebCore::windowsVirtualKeyCodeWithoutLocation):
     23        Added a function which removes location information from a given
     24        keycode. For example, when VK_LCONTROL is given, returns VK_CONTROL.
     25        (WebCore::keyLocationCode):
     26        Added a function which provides location information from a given
     27        keycode. For example, when VK_LCONTROL is given,
     28        returns DOM_KEY_LOCATION_LEFT.
     29        (WebCore::KeyboardEvent::KeyboardEvent):
     30        Initialized m_keyLocation by using the above keyLocationCode.
     31        (WebCore::KeyboardEvent::keyCode):
     32        Modified to use the above two functions to initialize keycode property
     33        and keylocation property.
     34        * platform/chromium/KeyCodeConversionAndroid.cpp:
     35        (WebCore::windowsKeyCodeForKeyEvent):
     36        * platform/chromium/KeyCodeConversionGtk.cpp:
     37        (WebCore::windowsKeyCodeForKeyEvent):
     38        * platform/cocoa/KeyEventCocoa.mm:
     39        (WebCore::windowsKeyCodeForKeyCode):
     40        Modified these keycode conversions to return keycodes with location
     41        information, e.g. modified keycode conversions returns VK_LCONTROL
     42        for left control.
     43
    1442012-05-22  Pavel Feldman  <pfeldman@chromium.org>
    245
  • trunk/Source/WebCore/dom/KeyboardEvent.cpp

    r103112 r118001  
    3232#include "PlatformKeyboardEvent.h"
    3333#include "Settings.h"
     34#include "WindowsKeyboardCodes.h"
    3435
    3536namespace WebCore {
     
    5455}
    5556
     57static inline int windowsVirtualKeyCodeWithoutLocation(int keycode)
     58{
     59    switch (keycode) {
     60    case VK_LCONTROL:
     61    case VK_RCONTROL:
     62        return VK_CONTROL;
     63    case VK_LSHIFT:
     64    case VK_RSHIFT:
     65        return VK_SHIFT;
     66    case VK_LMENU:
     67    case VK_RMENU:
     68        return VK_MENU;
     69    default:
     70        return keycode;
     71    }
     72}
     73
     74static inline KeyboardEvent::KeyLocationCode keyLocationCode(const PlatformKeyboardEvent& key)
     75{
     76    if (key.isKeypad())
     77        return KeyboardEvent::DOM_KEY_LOCATION_NUMPAD;
     78
     79    switch (key.windowsVirtualKeyCode()) {
     80    case VK_LCONTROL:
     81    case VK_LSHIFT:
     82    case VK_LMENU:
     83    case VK_LWIN:
     84        return KeyboardEvent::DOM_KEY_LOCATION_LEFT;
     85    case VK_RCONTROL:
     86    case VK_RSHIFT:
     87    case VK_RMENU:
     88    case VK_RWIN:
     89        return KeyboardEvent::DOM_KEY_LOCATION_RIGHT;
     90    default:
     91        return KeyboardEvent::DOM_KEY_LOCATION_STANDARD;
     92    }
     93}
     94
    5695KeyboardEvent::KeyboardEvent()
    5796    : m_keyLocation(DOM_KEY_LOCATION_STANDARD)
     
    65104    , m_keyEvent(adoptPtr(new PlatformKeyboardEvent(key)))
    66105    , m_keyIdentifier(key.keyIdentifier())
    67     , m_keyLocation(key.isKeypad() ? DOM_KEY_LOCATION_NUMPAD : DOM_KEY_LOCATION_STANDARD) // FIXME: differentiate right/left, too
     106    , m_keyLocation(keyLocationCode(key))
    68107    , m_altGraphKey(false)
    69108{
     
    123162        return 0;
    124163    if (type() == eventNames().keydownEvent || type() == eventNames().keyupEvent)
    125         return m_keyEvent->windowsVirtualKeyCode();
     164        return windowsVirtualKeyCodeWithoutLocation(m_keyEvent->windowsVirtualKeyCode());
     165
    126166    return charCode();
    127167}
  • trunk/Source/WebCore/platform/chromium/KeyCodeConversionAndroid.cpp

    r117022 r118001  
    9797        return VKEY_RETURN;
    9898    case AKEYCODE_SHIFT_LEFT:
     99        return VKEY_LSHIFT;
    99100    case AKEYCODE_SHIFT_RIGHT:
    100         return VKEY_SHIFT;
     101        return VKEY_RSHIFT;
    101102    // Back will serve as escape, although we may not have access to it.
    102103    case AKEYCODE_BACK:
     
    228229        return VKEY_END;
    229230    case AKEYCODE_ALT_LEFT:
     231        return VKEY_LMENU;
    230232    case AKEYCODE_ALT_RIGHT:
    231         return VKEY_MENU;
     233        return VKEY_RMENU;
    232234    case AKEYCODE_GRAVE:
    233235        return VKEY_OEM_3;
     
    245247        return VKEY_DELETE;
    246248    case AKEYCODE_CTRL_LEFT:
     249        return VKEY_LCONTROL;
    247250    case AKEYCODE_CTRL_RIGHT:
    248         return VKEY_CONTROL;
     251        return VKEY_RCONTROL;
    249252    case AKEYCODE_CAPS_LOCK:
    250253        return VKEY_CAPITAL;
  • trunk/Source/WebCore/platform/chromium/KeyCodeConversionGtk.cpp

    r95901 r118001  
    103103        return VKEY_RETURN; //(0D) Return key
    104104    case GDK_Shift_L:
     105        return VKEY_LSHIFT; // (A0) Left SHIFT key
    105106    case GDK_Shift_R:
    106         return VKEY_SHIFT; // (10) SHIFT key
     107        return VKEY_RSHIFT; // (A1) Right SHIFT key
    107108    case GDK_Control_L:
     109        return VKEY_LCONTROL; // (A2) Left CTRL key
    108110    case GDK_Control_R:
    109         return VKEY_CONTROL; // (11) CTRL key
     111        return VKEY_RCONTROL; // (A3) Right CTRL key
    110112    case GDK_Menu:
    111113        return VKEY_APPS;  // (5D) Applications key (Natural keyboard)
    112114    case GDK_Alt_L:
     115        return VKEY_LMENU; // (A4) Left ALT key
    113116    case GDK_Alt_R:
    114         return VKEY_MENU; // (12) ALT key
     117        return VKEY_RMENU; // (A5) Right ALT key
    115118
    116119    case GDK_Pause:
  • trunk/Source/WebCore/platform/cocoa/KeyEventCocoa.mm

    r101867 r118001  
    389389        /* 0x36 */ VK_APPS, // Right Command
    390390        /* 0x37 */ VK_LWIN, // Left Command
    391         /* 0x38 */ VK_SHIFT, // Left Shift
     391        /* 0x38 */ VK_LSHIFT, // Left Shift
    392392        /* 0x39 */ VK_CAPITAL, // Caps Lock
    393         /* 0x3A */ VK_MENU, // Left Option
    394         /* 0x3B */ VK_CONTROL, // Left Ctrl
    395         /* 0x3C */ VK_SHIFT, // Right Shift
    396         /* 0x3D */ VK_MENU, // Right Option
    397         /* 0x3E */ VK_CONTROL, // Right Ctrl
     393        /* 0x3A */ VK_LMENU, // Left Option
     394        /* 0x3B */ VK_LCONTROL, // Left Ctrl
     395        /* 0x3C */ VK_RSHIFT, // Right Shift
     396        /* 0x3D */ VK_RMENU, // Right Option
     397        /* 0x3E */ VK_RCONTROL, // Right Ctrl
    398398        /* 0x3F */ 0, // fn
    399399        /* 0x40 */ VK_F17,
  • trunk/Tools/ChangeLog

    r118000 r118001  
     12012-05-22  Takashi Sakamoto  <tasak@google.com>
     2
     3        Implement DOM_KEY_LOCATION_LEFT and RIGHT of KeyboardEvent's location property
     4        https://bugs.webkit.org/show_bug.cgi?id=86694
     5
     6        Modify keyDown to create left- and right- control, shift, and alt
     7        keyevent for a test to check that keyLocation property can have
     8        DOM_KEY_LOCATION_LEFT for left-control, shift, and alt, and
     9        DOM_KEY_LOCATION_RIGHT for right-control, shift, and alt.
     10
     11        Reviewed by Alexey Proskuryakov.
     12
     13        * DumpRenderTree/chromium/EventSender.cpp:
     14        (EventSender::keyDown):
     15        * DumpRenderTree/mac/EventSendingController.mm:
     16        (-[EventSendingController keyDown:withModifiers:withLocation:]):
     17
    1182012-05-22  Christophe Dumez  <christophe.dumez@intel.com>
    219
  • trunk/Tools/DumpRenderTree/chromium/EventSender.cpp

    r116671 r118001  
    558558        // FIXME: Change this to webkit_support::VKEY_APPS.
    559559        code = 0x5D;
     560    else if ("leftControl" == codeStr)
     561        // FIXME: Change this to webkit_support::VKEY_LCONTROL.
     562        code = 0xA2;
     563    else if ("rightControl" == codeStr)
     564        // FIXME: Change this to webkit_support::VKEY_RCONTROL.
     565        code = 0xA3;
     566    else if ("leftShift" == codeStr)
     567        // FIXME: Change this to webkit_support::VKEY_LSHIFT.
     568        code = 0xA0;
     569    else if ("rightShift" == codeStr)
     570        // FIXME: Change this to webkit_support::VKEY_RSHIFT.
     571        code = 0xA1;
     572    else if ("leftAlt" == codeStr)
     573        // FIXME: Change this to webkit_support::VKEY_LMENU.
     574        code = 0xA4;
     575    else if ("rightAlt" == codeStr)
     576        // FIXME: Change this to webkit_support::VKEY_RMENU.
     577        code = 0xA5;
    560578    else {
    561579        // Compare the input string with the function-key names defined by the
  • trunk/Tools/DumpRenderTree/mac/EventSendingController.mm

    r107008 r118001  
    622622        eventCharacter = [NSString stringWithCharacters:&ch length:1];
    623623        keyCode = 0x3; // Shares key with "F" on Russian layout.
     624    } else if ([character isEqualToString:@"leftControl"]) {
     625        const unichar ch = 0xFFE3;
     626        eventCharacter = [NSString stringWithCharacters:&ch length:1];
     627        keyCode = 0x3B;
     628    } else if ([character isEqualToString:@"leftShift"]) {
     629        const unichar ch = 0xFFE1;
     630        eventCharacter = [NSString stringWithCharacters:&ch length:1];
     631        keyCode = 0x38;
     632    } else if ([character isEqualToString:@"leftAlt"]) {
     633        const unichar ch = 0xFFE7;
     634        eventCharacter = [NSString stringWithCharacters:&ch length:1];
     635        keyCode = 0x3A;
     636    } else if ([character isEqualToString:@"rightControl"]) {
     637        const unichar ch = 0xFFE4;
     638        eventCharacter = [NSString stringWithCharacters:&ch length:1];
     639        keyCode = 0x3E;
     640    } else if ([character isEqualToString:@"rightShift"]) {
     641        const unichar ch = 0xFFE2;
     642        eventCharacter = [NSString stringWithCharacters:&ch length:1];
     643        keyCode = 0x3C;
     644    } else if ([character isEqualToString:@"rightAlt"]) {
     645        const unichar ch = 0xFFE8;
     646        eventCharacter = [NSString stringWithCharacters:&ch length:1];
     647        keyCode = 0x3D;
    624648    }
    625649
Note: See TracChangeset for help on using the changeset viewer.