Changeset 236271 in webkit


Ignore:
Timestamp:
Sep 20, 2018 11:20:02 AM (6 years ago)
Author:
dbates@webkit.org
Message:

[iOS] Support testing more hardware special keys
https://bugs.webkit.org/show_bug.cgi?id=189793

Reviewed by Simon Fraser.

Tools:

  • TestRunnerShared/spi/IOKitSPI.h: Add more SPI constants.
  • WebKitTestRunner/ios/HIDEventGenerator.mm:

(keyCodeForDOMFunctionKey): Extracted out logic from hidUsageCodeForCharacter() to return the
key code for the F1, F2, ..., F12 keys and extended the code to compute the key code for the
F13, F14, ..., F24 keys.
(hidUsageCodeForCharacter): Modified to call keyCodeForDOMFunctionKey().

LayoutTests:

For now, many of the DOM keydown and keyup events for special hardware keys are wrong.
We will fix this up in a subsequent commit(s).

  • fast/events/ios/keydown-keyup-special-keys-in-non-editable-element-expected.txt: Added.
  • fast/events/ios/keydown-keyup-special-keys-in-non-editable-element.html: Added.
Location:
trunk
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r236265 r236271  
     12018-09-20  Daniel Bates  <dabates@apple.com>
     2
     3        [iOS] Support testing more hardware special keys
     4        https://bugs.webkit.org/show_bug.cgi?id=189793
     5
     6        Reviewed by Simon Fraser.
     7
     8        For now, many of the DOM keydown and keyup events for special hardware keys are wrong.
     9        We will fix this up in a subsequent commit(s).
     10
     11        * fast/events/ios/keydown-keyup-special-keys-in-non-editable-element-expected.txt: Added.
     12        * fast/events/ios/keydown-keyup-special-keys-in-non-editable-element.html: Added.
     13
    1142018-09-20  Per Arne Vollan  <pvollan@apple.com>
    215
  • trunk/Tools/ChangeLog

    r236269 r236271  
     12018-09-20  Daniel Bates  <dabates@apple.com>
     2
     3        [iOS] Support testing more hardware special keys
     4        https://bugs.webkit.org/show_bug.cgi?id=189793
     5
     6        Reviewed by Simon Fraser.
     7
     8        * TestRunnerShared/spi/IOKitSPI.h: Add more SPI constants.
     9        * WebKitTestRunner/ios/HIDEventGenerator.mm:
     10        (keyCodeForDOMFunctionKey): Extracted out logic from hidUsageCodeForCharacter() to return the
     11        key code for the F1, F2, ..., F12 keys and extended the code to compute the key code for the
     12        F13, F14, ..., F24 keys.
     13        (hidUsageCodeForCharacter): Modified to call keyCodeForDOMFunctionKey().
     14
    1152018-09-20  Michael Catanzaro  <mcatanzaro@igalia.com>
    216
  • trunk/Tools/TestRunnerShared/spi/IOKitSPI.h

    r214586 r236271  
    187187    kHIDUsage_KeyboardSlash = 0x38,
    188188    kHIDUsage_KeyboardF1 = 0x3A,
     189    kHIDUsage_KeyboardPrintScreen = 0x46,
     190    kHIDUsage_KeyboardInsert = 0x49,
    189191    kHIDUsage_KeyboardHome = 0x4A,
    190192    kHIDUsage_KeyboardPageUp = 0x4B,
     193    kHIDUsage_KeyboardDeleteForward = 0x4C,
    191194    kHIDUsage_KeyboardEnd = 0x4D,
     195    kHIDUsage_KeyboardPageDown = 0x4E,
    192196    kHIDUsage_KeyboardRightArrow = 0x4F,
    193197    kHIDUsage_KeyboardLeftArrow = 0x50,
    194198    kHIDUsage_KeyboardDownArrow = 0x51,
    195199    kHIDUsage_KeyboardUpArrow = 0x52,
     200    kHIDUsage_KeyboardF13 = 0x68,
     201    kHIDUsage_KeyboardMenu = 0x76,
    196202    kHIDUsage_KeyboardLeftControl = 0xE0,
    197203    kHIDUsage_KeyboardLeftShift = 0xE1,
    198     kHIDUsage_KeyboardLeftAlt = 0xE2
     204    kHIDUsage_KeyboardLeftAlt = 0xE2,
     205    kHIDUsage_KeyboardLeftGUI = 0xE3,
     206    kHIDUsage_KeyboardRightControl = 0xE4,
     207    kHIDUsage_KeyboardRightShift = 0xE5,
     208    kHIDUsage_KeyboardRightAlt = 0xE6,
     209    kHIDUsage_KeyboardRightGUI = 0xE7,
    199210};
    200211
  • trunk/Tools/WebKitTestRunner/ios/HIDEventGenerator.mm

    r235837 r236271  
    3333#import <wtf/Assertions.h>
    3434#import <wtf/BlockPtr.h>
     35#import <wtf/Optional.h>
    3536#import <wtf/RetainPtr.h>
    3637#import <wtf/SoftLinking.h>
     
    824825    }
    825826    return false;
     827}
     828
     829static std::optional<uint32_t> keyCodeForDOMFunctionKey(NSString *key)
     830{
     831    // Compare the input string with the function-key names defined by the DOM spec (i.e. "F1",...,"F24").
     832    // If the input string is a function-key name, set its key code. On iOS the key codes for the first 12
     833    // function keys are disjoint from the key codes of the last 12 function keys.
     834    for (int i = 1; i <= 12; ++i) {
     835        if ([key isEqualToString:[NSString stringWithFormat:@"F%d", i]])
     836            return kHIDUsage_KeyboardF1 + i - 1;
     837    }
     838    for (int i = 13; i <= 24; ++i) {
     839        if ([key isEqualToString:[NSString stringWithFormat:@"F%d", i]])
     840            return kHIDUsage_KeyboardF13 + i - 1;
     841    }
     842    return std::nullopt;
    826843}
    827844
     
    908925        }
    909926    }
    910     const int functionKeyOffset = kHIDUsage_KeyboardF1;
    911     for (int functionKeyIndex = 1; functionKeyIndex <= 12; ++functionKeyIndex) {
    912         if ([key isEqualToString:[NSString stringWithFormat:@"F%d", functionKeyIndex]])
    913             return functionKeyOffset + functionKeyIndex - 1;
    914     }
     927
     928    if (auto keyCode = keyCodeForDOMFunctionKey(key))
     929        return *keyCode;
     930
     931    if ([key isEqualToString:@"pageUp"])
     932        return kHIDUsage_KeyboardPageUp;
     933    if ([key isEqualToString:@"pageDown"])
     934        return kHIDUsage_KeyboardPageDown;
     935    if ([key isEqualToString:@"home"])
     936        return kHIDUsage_KeyboardHome;
     937    if ([key isEqualToString:@"insert"])
     938        return kHIDUsage_KeyboardInsert;
     939    if ([key isEqualToString:@"end"])
     940        return kHIDUsage_KeyboardEnd;
    915941    if ([key isEqualToString:@"escape"])
    916942        return kHIDUsage_KeyboardEscape;
     
    927953    if ([key isEqualToString:@"delete"])
    928954        return kHIDUsage_KeyboardDeleteOrBackspace;
     955    if ([key isEqualToString:@"leftCommand"])
     956        return kHIDUsage_KeyboardLeftGUI;
     957    if ([key isEqualToString:@"rightCommand"])
     958        return kHIDUsage_KeyboardRightGUI;
    929959    // The simulator keyboard interprets both left and right modifier keys using the left version of the usage code.
    930960    if ([key isEqualToString:@"leftControl"] || [key isEqualToString:@"rightControl"])
Note: See TracChangeset for help on using the changeset viewer.