Diff
Modified: trunk/Source/WebDriver/ChangeLog (233130 => 233131)
--- trunk/Source/WebDriver/ChangeLog 2018-06-23 15:51:18 UTC (rev 233130)
+++ trunk/Source/WebDriver/ChangeLog 2018-06-23 19:17:09 UTC (rev 233131)
@@ -1,3 +1,16 @@
+2018-06-21 Brian Burg <bb...@apple.com>
+
+ Web Automation: key actions should support multiple pressed virtual keys
+ https://bugs.webkit.org/show_bug.cgi?id=186899
+ <rdar://problem/38222248>
+
+ Reviewed by Timothy Hatcher.
+
+ Adopt new protocol command argument types.
+
+ * Session.cpp:
+ (WebDriver::Session::performActions):
+
2018-06-23 Yusuke Suzuki <utatane....@gmail.com>
[WTF] Add user-defined literal for ASCIILiteral
Modified: trunk/Source/WebDriver/Session.cpp (233130 => 233131)
--- trunk/Source/WebDriver/Session.cpp 2018-06-23 15:51:18 UTC (rev 233130)
+++ trunk/Source/WebDriver/Session.cpp 2018-06-23 19:17:09 UTC (rev 233131)
@@ -2318,8 +2318,12 @@
}
if (currentState.pressedKey)
state->setString("pressedCharKey"_s, currentState.pressedKey.value());
- if (currentState.pressedVirtualKey)
- state->setString("pressedVirtualKey"_s, currentState.pressedVirtualKey.value());
+ if (currentState.pressedVirtualKey) {
+ // FIXME: support parsing and tracking multiple virtual keys.
+ Ref<JSON::Array> virtualKeys = JSON::Array::create();
+ virtualKeys->pushString(currentState.pressedVirtualKey.value());
+ state->setArray("pressedVirtualKeys"_s, WTFMove(virtualKeys));
+ }
break;
}
states->pushObject(WTFMove(state));
Modified: trunk/Source/WebKit/ChangeLog (233130 => 233131)
--- trunk/Source/WebKit/ChangeLog 2018-06-23 15:51:18 UTC (rev 233130)
+++ trunk/Source/WebKit/ChangeLog 2018-06-23 19:17:09 UTC (rev 233131)
@@ -1,3 +1,34 @@
+2018-06-21 Brian Burg <bb...@apple.com>
+
+ Web Automation: key actions should support multiple pressed virtual keys
+ https://bugs.webkit.org/show_bug.cgi?id=186899
+ <rdar://problem/38222248>
+
+ Reviewed by Timothy Hatcher.
+
+ This patch changes the protocol to allow multiple virtual keys per input source state.
+ Chords like Cmd-Shift-A and Shift-F12 must be represented this way as they are encoded
+ in the VirtualKey enum rather than as an ASCII char.
+
+ * UIProcess/Automation/Automation.json:
+ * UIProcess/Automation/SimulatedInputDispatcher.h:
+ * UIProcess/Automation/SimulatedInputDispatcher.cpp:
+ (WebKit::SimulatedInputDispatcher::transitionInputSourceToState):
+ * UIProcess/Automation/WebAutomationSession.cpp:
+ (WebKit::WebAutomationSession::simulateKeyboardInteraction):
+ (WebKit::WebAutomationSession::performKeyboardInteractions):
+ (WebKit::WebAutomationSession::performInteractionSequence):
+
+ * UIProcess/Automation/WebAutomationSession.h:
+ * UIProcess/Automation/gtk/WebAutomationSessionGtk.cpp:
+ (WebKit::WebAutomationSession::platformSimulateKeyboardInteraction):
+ * UIProcess/Automation/ios/WebAutomationSessionIOS.mm:
+ (WebKit::WebAutomationSession::platformSimulateKeyboardInteraction):
+ * UIProcess/Automation/mac/WebAutomationSessionMac.mm:
+ (WebKit::WebAutomationSession::platformSimulateKeyboardInteraction):
+ Also clean up the signature of WebAutomationSession::platformSimulateKeyboardInteraction
+ to use a variant instead of mutually exclusive optional values with different types.
+
2018-06-23 Yusuke Suzuki <utatane....@gmail.com>
[WTF] Add user-defined literal for ASCIILiteral
Modified: trunk/Source/WebKit/UIProcess/Automation/Automation.json (233130 => 233131)
--- trunk/Source/WebKit/UIProcess/Automation/Automation.json 2018-06-23 15:51:18 UTC (rev 233130)
+++ trunk/Source/WebKit/UIProcess/Automation/Automation.json 2018-06-23 19:17:09 UTC (rev 233131)
@@ -290,7 +290,7 @@
"properties": [
{ "name": "sourceId", "type": "string", "description": "The input source whose state is described by this object." },
{ "name": "pressedCharKey", "type": "string", "optional": true, "description": "For 'keyboard' input sources, specifies a character key that has 'pressed' state. Unmentioned character keys are assumed to have a 'released' state." },
- { "name": "pressedVirtualKey", "$ref": "VirtualKey", "optional": true, "description": "For 'keyboard' input sources, specifies a virtual key that has a 'pressed' state. Unmentioned virtual keys are assumed to have a 'released' state." },
+ { "name": "pressedVirtualKeys", "type": "array", "items": { "$ref": "VirtualKey" }, "optional": true, "description": "For 'keyboard' input sources, specifies virtual keys that have a 'pressed' state. Unmentioned virtual keys are assumed to have a 'released' state." },
{ "name": "pressedButton", "$ref": "MouseButton", "optional": true, "description": "For 'mouse' input sources, specifies which mouse button has a 'pressed' state. Unmentioned mouse buttons are assumed to have a 'released' state." },
{ "name": "origin", "$ref": "MouseMoveOrigin", "optional": true, "description": "For 'mouse' input sources, specifies the origin type of a mouse move transition. Defaults to 'Viewport' if omitted."},
{ "name": "nodeHandle", "$ref": "NodeHandle", "optional": true, "description": "The handle of the element to use as origin when origin type is 'Element'."},
Modified: trunk/Source/WebKit/UIProcess/Automation/SimulatedInputDispatcher.cpp (233130 => 233131)
--- trunk/Source/WebKit/UIProcess/Automation/SimulatedInputDispatcher.cpp 2018-06-23 15:51:18 UTC (rev 233130)
+++ trunk/Source/WebKit/UIProcess/Automation/SimulatedInputDispatcher.cpp 2018-06-23 19:17:09 UTC (rev 233131)
@@ -267,11 +267,21 @@
}
case SimulatedInputSourceType::Keyboard:
// The "dispatch a key{Down,Up} action" algorithms (ยง17.4 Dispatching Actions).
- if ((!a.pressedCharKey && b.pressedCharKey) || (!a.pressedVirtualKey && b.pressedVirtualKey))
- m_client.simulateKeyboardInteraction(m_page, KeyboardInteraction::KeyPress, b.pressedVirtualKey, b.pressedCharKey, WTFMove(eventDispatchFinished));
- else if ((a.pressedCharKey && !b.pressedCharKey) || (a.pressedVirtualKey && !b.pressedVirtualKey))
- m_client.simulateKeyboardInteraction(m_page, KeyboardInteraction::KeyRelease, a.pressedVirtualKey, a.pressedCharKey, WTFMove(eventDispatchFinished));
- else
+ if (!a.pressedCharKey && b.pressedCharKey)
+ m_client.simulateKeyboardInteraction(m_page, KeyboardInteraction::KeyPress, b.pressedCharKey.value(), WTFMove(eventDispatchFinished));
+ else if (a.pressedCharKey && !b.pressedCharKey)
+ m_client.simulateKeyboardInteraction(m_page, KeyboardInteraction::KeyRelease, b.pressedCharKey.value(), WTFMove(eventDispatchFinished));
+ else if (a.pressedVirtualKeys != b.pressedVirtualKeys) {
+ for (VirtualKey key : b.pressedVirtualKeys) {
+ if (!a.pressedVirtualKeys.contains(key))
+ m_client.simulateKeyboardInteraction(m_page, KeyboardInteraction::KeyPress, key, WTFMove(eventDispatchFinished));
+ }
+
+ for (VirtualKey key : a.pressedVirtualKeys) {
+ if (!b.pressedVirtualKeys.contains(key))
+ m_client.simulateKeyboardInteraction(m_page, KeyboardInteraction::KeyRelease, key, WTFMove(eventDispatchFinished));
+ }
+ } else
eventDispatchFinished(std::nullopt);
break;
case SimulatedInputSourceType::Touch:
Modified: trunk/Source/WebKit/UIProcess/Automation/SimulatedInputDispatcher.h (233130 => 233131)
--- trunk/Source/WebKit/UIProcess/Automation/SimulatedInputDispatcher.h 2018-06-23 15:51:18 UTC (rev 233130)
+++ trunk/Source/WebKit/UIProcess/Automation/SimulatedInputDispatcher.h 2018-06-23 19:17:09 UTC (rev 233131)
@@ -52,6 +52,7 @@
using KeyboardInteraction = Inspector::Protocol::Automation::KeyboardInteractionType;
using VirtualKey = Inspector::Protocol::Automation::VirtualKey;
+using VirtualKeySet = HashSet<VirtualKey, WTF::IntHash<VirtualKey>, WTF::StrongEnumHashTraits<VirtualKey>>;
using CharKey = char; // For WebDriver, this only needs to support ASCII characters on 102-key keyboard.
using MouseButton = WebMouseEvent::Button;
using MouseInteraction = Inspector::Protocol::Automation::MouseInteraction;
@@ -66,7 +67,7 @@
struct SimulatedInputSourceState {
std::optional<CharKey> pressedCharKey;
- std::optional<VirtualKey> pressedVirtualKey;
+ VirtualKeySet pressedVirtualKeys;
std::optional<MouseButton> pressedMouseButton;
std::optional<MouseMoveOrigin> origin;
std::optional<String> nodeHandle;
@@ -115,7 +116,7 @@
public:
virtual ~Client() { }
virtual void simulateMouseInteraction(WebPageProxy&, MouseInteraction, WebMouseEvent::Button, const WebCore::IntPoint& locationInView, AutomationCompletionHandler&&) = 0;
- virtual void simulateKeyboardInteraction(WebPageProxy&, KeyboardInteraction, std::optional<VirtualKey>, std::optional<CharKey>, AutomationCompletionHandler&&) = 0;
+ virtual void simulateKeyboardInteraction(WebPageProxy&, KeyboardInteraction, WTF::Variant<VirtualKey, CharKey>&&, AutomationCompletionHandler&&) = 0;
virtual void viewportInViewCenterPointOfElement(WebPageProxy&, uint64_t frameID, const String& nodeHandle, Function<void (std::optional<WebCore::IntPoint>, std::optional<AutomationCommandError>)>&&) = 0;
};
Modified: trunk/Source/WebKit/UIProcess/Automation/WebAutomationSession.cpp (233130 => 233131)
--- trunk/Source/WebKit/UIProcess/Automation/WebAutomationSession.cpp 2018-06-23 15:51:18 UTC (rev 233130)
+++ trunk/Source/WebKit/UIProcess/Automation/WebAutomationSession.cpp 2018-06-23 19:17:09 UTC (rev 233131)
@@ -1479,7 +1479,7 @@
});
}
-void WebAutomationSession::simulateKeyboardInteraction(WebPageProxy& page, KeyboardInteraction interaction, std::optional<VirtualKey> virtualKey, std::optional<CharKey> charKey, CompletionHandler<void(std::optional<AutomationCommandError>)>&& completionHandler)
+void WebAutomationSession::simulateKeyboardInteraction(WebPageProxy& page, KeyboardInteraction interaction, WTF::Variant<VirtualKey, CharKey>&& key, CompletionHandler<void(std::optional<AutomationCommandError>)>&& completionHandler)
{
// Bridge the flushed callback to our command's completion handler.
auto keyboardEventsFlushedCallback = [completionHandler = WTFMove(completionHandler)](std::optional<AutomationCommandError> error) {
@@ -1491,7 +1491,7 @@
callbackInMap(AUTOMATION_COMMAND_ERROR_WITH_NAME(Timeout));
callbackInMap = WTFMove(keyboardEventsFlushedCallback);
- platformSimulateKeyboardInteraction(page, interaction, virtualKey, charKey);
+ platformSimulateKeyboardInteraction(page, interaction, WTFMove(key));
// Wait for keyboardEventsFlushedCallback to run when all events are handled.
}
@@ -1637,12 +1637,12 @@
String virtualKeyString;
bool foundVirtualKey = interactionObject->getString("key"_s, virtualKeyString);
if (foundVirtualKey) {
- auto virtualKey = Inspector::Protocol::AutomationHelpers::parseEnumValueFromString<Inspector::Protocol::Automation::VirtualKey>(virtualKeyString);
+ std::optional<VirtualKey> virtualKey = Inspector::Protocol::AutomationHelpers::parseEnumValueFromString<Inspector::Protocol::Automation::VirtualKey>(virtualKeyString);
if (!virtualKey)
ASYNC_FAIL_WITH_PREDEFINED_ERROR_AND_DETAILS(InvalidParameter, "An interaction in the 'interactions' parameter has an invalid 'key' value.");
actionsToPerform.uncheckedAppend([this, page, interactionType, virtualKey] {
- platformSimulateKeyboardInteraction(*page, interactionType.value(), virtualKey, std::nullopt);
+ platformSimulateKeyboardInteraction(*page, interactionType.value(), virtualKey.value());
});
}
@@ -1795,10 +1795,25 @@
if (stateObject->getString("pressedCharKey"_s, pressedCharKeyString))
sourceState.pressedCharKey = pressedCharKeyString.characterAt(0);
- String pressedVirtualKeyString;
- if (stateObject->getString("pressedVirtualKey"_s, pressedVirtualKeyString))
- sourceState.pressedVirtualKey = Inspector::Protocol::AutomationHelpers::parseEnumValueFromString<Inspector::Protocol::Automation::VirtualKey>(pressedVirtualKeyString);
+ RefPtr<JSON::Array> pressedVirtualKeysArray;
+ if (stateObject->getArray("pressedVirtualKeys"_s, pressedVirtualKeysArray)) {
+ VirtualKeySet pressedVirtualKeys { };
+ for (auto it = pressedVirtualKeysArray->begin(); it != pressedVirtualKeysArray->end(); ++it) {
+ String pressedVirtualKeyString;
+ if (!(*it)->asString(pressedVirtualKeyString))
+ ASYNC_FAIL_WITH_PREDEFINED_ERROR_AND_DETAILS(InvalidParameter, "Encountered a non-string virtual key value.");
+
+ std::optional<VirtualKey> parsedVirtualKey = Inspector::Protocol::AutomationHelpers::parseEnumValueFromString<Inspector::Protocol::Automation::VirtualKey>(pressedVirtualKeyString);
+ if (!parsedVirtualKey)
+ ASYNC_FAIL_WITH_PREDEFINED_ERROR_AND_DETAILS(InvalidParameter, "Encountered an unknown virtual key value.");
+ else
+ pressedVirtualKeys.add(parsedVirtualKey.value());
+ }
+
+ sourceState.pressedVirtualKeys = pressedVirtualKeys;
+ }
+
String pressedButtonString;
if (stateObject->getString("pressedButton"_s, pressedButtonString)) {
auto protocolButton = Inspector::Protocol::AutomationHelpers::parseEnumValueFromString<Inspector::Protocol::Automation::MouseButton>(pressedButtonString);
@@ -1926,7 +1941,7 @@
#if !PLATFORM(COCOA) && !PLATFORM(GTK)
-void WebAutomationSession::platformSimulateKeyboardInteraction(WebPageProxy&, KeyboardInteraction, std::optional<VirtualKey>, std::optional<CharKey>)
+void WebAutomationSession::platformSimulateKeyboardInteraction(WebPageProxy&, KeyboardInteraction, WTF::Variant<VirtualKey, CharKey>&&)
{
}
#endif // !PLATFORM(COCOA) && !PLATFORM(GTK)
Modified: trunk/Source/WebKit/UIProcess/Automation/WebAutomationSession.h (233130 => 233131)
--- trunk/Source/WebKit/UIProcess/Automation/WebAutomationSession.h 2018-06-23 15:51:18 UTC (rev 233130)
+++ trunk/Source/WebKit/UIProcess/Automation/WebAutomationSession.h 2018-06-23 19:17:09 UTC (rev 233131)
@@ -137,7 +137,7 @@
// SimulatedInputDispatcher::Client API
void simulateMouseInteraction(WebPageProxy&, MouseInteraction, WebMouseEvent::Button, const WebCore::IntPoint& locationInView, AutomationCompletionHandler&&) final;
- void simulateKeyboardInteraction(WebPageProxy&, KeyboardInteraction, std::optional<VirtualKey>, std::optional<CharKey>, AutomationCompletionHandler&&) final;
+ void simulateKeyboardInteraction(WebPageProxy&, KeyboardInteraction, WTF::Variant<VirtualKey, CharKey>&&, AutomationCompletionHandler&&) final;
void viewportInViewCenterPointOfElement(WebPageProxy&, uint64_t frameID, const String& nodeHandle, Function<void (std::optional<WebCore::IntPoint>, std::optional<AutomationCommandError>)>&&) final;
// Inspector::AutomationBackendDispatcherHandler API
@@ -233,7 +233,7 @@
// Platform-dependent implementations.
void platformSimulateMouseInteraction(WebPageProxy&, MouseInteraction, WebMouseEvent::Button, const WebCore::IntPoint& locationInView, WebEvent::Modifiers keyModifiers);
// Simulates a single virtual or char key being pressed/released, such as 'a', Control, F-keys, Numpad keys, etc. as allowed by the protocol.
- void platformSimulateKeyboardInteraction(WebPageProxy&, KeyboardInteraction, std::optional<VirtualKey>, std::optional<CharKey>);
+ void platformSimulateKeyboardInteraction(WebPageProxy&, KeyboardInteraction, WTF::Variant<VirtualKey, CharKey>&&);
// Simulates key presses to produce the codepoints in a string. One or more code points are delivered atomically at grapheme cluster boundaries.
void platformSimulateKeySequence(WebPageProxy&, const String&);
// Get base64 encoded PNG data from a bitmap.
Modified: trunk/Source/WebKit/UIProcess/Automation/gtk/WebAutomationSessionGtk.cpp (233130 => 233131)
--- trunk/Source/WebKit/UIProcess/Automation/gtk/WebAutomationSessionGtk.cpp 2018-06-23 15:51:18 UTC (rev 233130)
+++ trunk/Source/WebKit/UIProcess/Automation/gtk/WebAutomationSessionGtk.cpp 2018-06-23 19:17:09 UTC (rev 233131)
@@ -294,15 +294,19 @@
return 0;
}
-void WebAutomationSession::platformSimulateKeyboardInteraction(WebPageProxy& page, KeyboardInteraction interaction, std::optional<VirtualKey> virtualKey, std::optional<CharKey> charKey)
+void WebAutomationSession::platformSimulateKeyboardInteraction(WebPageProxy& page, KeyboardInteraction interaction, WTF::Variant<VirtualKey, CharKey>&& key)
{
ASSERT(virtualKey.has_value() || charKey.has_value());
unsigned keyCode;
- if (virtualKey.has_value())
- keyCode = keyCodeForVirtualKey(virtualKey.value());
- else
- keyCode = gdk_unicode_to_keyval(g_utf8_get_char(&charKey.value()));
+ WTF::switchOn(key,
+ [&] (VirtualKey virtualKey) {
+ keyCode = keyCodeForVirtualKey(virtualKey);
+ },
+ [&] (CharKey charKey) {
+ keyCode = gdk_unicode_to_keyval(g_utf8_get_char(&charKey));
+ }
+ );
unsigned modifiers = modifiersForKeyCode(keyCode);
switch (interaction) {
Modified: trunk/Source/WebKit/UIProcess/Automation/ios/WebAutomationSessionIOS.mm (233130 => 233131)
--- trunk/Source/WebKit/UIProcess/Automation/ios/WebAutomationSessionIOS.mm 2018-06-23 15:51:18 UTC (rev 233130)
+++ trunk/Source/WebKit/UIProcess/Automation/ios/WebAutomationSessionIOS.mm 2018-06-23 19:17:09 UTC (rev 233131)
@@ -65,10 +65,8 @@
#pragma mark Commands for Platform: 'iOS'
-void WebAutomationSession::platformSimulateKeyboardInteraction(WebPageProxy& page, KeyboardInteraction interaction, std::optional<VirtualKey> virtualKey, std::optional<CharKey> charKey)
+void WebAutomationSession::platformSimulateKeyboardInteraction(WebPageProxy& page, KeyboardInteraction interaction, WTF::Variant<VirtualKey, CharKey>&& key)
{
- ASSERT(virtualKey.has_value() || charKey.has_value());
-
// The modifiers changed by the virtual key when it is pressed or released.
WebEventFlags changedModifiers = 0;
@@ -79,36 +77,37 @@
std::optional<unichar> charCodeIgnoringModifiers;
// Figure out the effects of sticky modifiers.
- if (virtualKey.has_value()) {
- charCode = charCodeForVirtualKey(virtualKey.value());
- charCodeIgnoringModifiers = charCodeIgnoringModifiersForVirtualKey(virtualKey.value());
+ WTF::switchOn(key,
+ [&] (VirtualKey virtualKey) {
+ charCode = charCodeForVirtualKey(virtualKey);
+ charCodeIgnoringModifiers = charCodeIgnoringModifiersForVirtualKey(virtualKey);
- switch (virtualKey.value()) {
- case VirtualKey::Shift:
- changedModifiers |= WebEventFlagMaskShift;
- break;
- case VirtualKey::Control:
- changedModifiers |= WebEventFlagMaskControl;
- break;
- case VirtualKey::Alternate:
- changedModifiers |= WebEventFlagMaskAlternate;
- break;
- case VirtualKey::Meta:
- // The 'meta' key does not exist on Apple keyboards and is usually
- // mapped to the Command key when using third-party keyboards.
- case VirtualKey::Command:
- changedModifiers |= WebEventFlagMaskCommand;
- break;
- default:
- break;
+ switch (virtualKey) {
+ case VirtualKey::Shift:
+ changedModifiers |= WebEventFlagMaskShift;
+ break;
+ case VirtualKey::Control:
+ changedModifiers |= WebEventFlagMaskControl;
+ break;
+ case VirtualKey::Alternate:
+ changedModifiers |= WebEventFlagMaskAlternate;
+ break;
+ case VirtualKey::Meta:
+ // The 'meta' key does not exist on Apple keyboards and is usually
+ // mapped to the Command key when using third-party keyboards.
+ case VirtualKey::Command:
+ changedModifiers |= WebEventFlagMaskCommand;
+ break;
+ default:
+ break;
+ }
+ },
+ [&] (CharKey charKey) {
+ charCode = (unichar)charKey;
+ charCodeIgnoringModifiers = (unichar)charKey;
}
- }
+ );
- if (charKey.has_value()) {
- charCode = (unichar)charKey.value();
- charCodeIgnoringModifiers = (unichar)charKey.value();
- }
-
// FIXME: consider using UIKit SPI to normalize 'characters', i.e., changing * to Shift-8,
// and passing that in to charactersIgnoringModifiers. This is probably not worth the trouble
// unless it causes an actual behavioral difference.
Modified: trunk/Source/WebKit/UIProcess/Automation/mac/WebAutomationSessionMac.mm (233130 => 233131)
--- trunk/Source/WebKit/UIProcess/Automation/mac/WebAutomationSessionMac.mm 2018-06-23 15:51:18 UTC (rev 233130)
+++ trunk/Source/WebKit/UIProcess/Automation/mac/WebAutomationSessionMac.mm 2018-06-23 19:17:09 UTC (rev 233131)
@@ -425,13 +425,11 @@
}
}
-void WebAutomationSession::platformSimulateKeyboardInteraction(WebPageProxy& page, KeyboardInteraction interaction, std::optional<VirtualKey> virtualKey, std::optional<CharKey> charKey)
+void WebAutomationSession::platformSimulateKeyboardInteraction(WebPageProxy& page, KeyboardInteraction interaction, WTF::Variant<VirtualKey, CharKey>&& key)
{
// FIXME: this function and the Automation protocol enum should probably adopt key names
// from W3C UIEvents standard. For more details: https://w3c.github.io/uievents-code/
- ASSERT(virtualKey.has_value() || charKey.has_value());
-
bool isStickyModifier = false;
NSEventModifierFlags changedModifiers = 0;
int keyCode;
@@ -438,19 +436,20 @@
std::optional<unichar> charCode;
std::optional<unichar> charCodeIgnoringModifiers;
- if (virtualKey.has_value()) {
- isStickyModifier = virtualKeyHasStickyModifier(virtualKey.value());
- changedModifiers = eventModifierFlagsForVirtualKey(virtualKey.value());
- keyCode = keyCodeForVirtualKey(virtualKey.value());
- charCode = charCodeForVirtualKey(virtualKey.value());
- charCodeIgnoringModifiers = charCodeIgnoringModifiersForVirtualKey(virtualKey.value());
- }
+ WTF::switchOn(key,
+ [&] (VirtualKey virtualKey) {
+ isStickyModifier = virtualKeyHasStickyModifier(virtualKey);
+ changedModifiers = eventModifierFlagsForVirtualKey(virtualKey);
+ keyCode = keyCodeForVirtualKey(virtualKey);
+ charCode = charCodeForVirtualKey(virtualKey);
+ charCodeIgnoringModifiers = charCodeIgnoringModifiersForVirtualKey(virtualKey);
+ },
+ [&] (CharKey charKey) {
+ charCode = (unichar)charKey;
+ charCodeIgnoringModifiers = (unichar)charKey;
+ }
+ );
- if (charKey.has_value()) {
- charCode = (unichar)charKey.value();
- charCodeIgnoringModifiers = (unichar)charKey.value();
- }
-
// FIXME: consider using AppKit SPI to normalize 'characters', i.e., changing * to Shift-8,
// and passing that in to charactersIgnoringModifiers. We could hardcode this for ASCII if needed.
NSString *characters = charCode ? [NSString stringWithCharacters:&charCode.value() length:1] : nil;