WebKit Bugzilla
Attachment 343289 Details for
Bug 186899
: Web Automation: key actions should support multiple pressed virtual keys
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Proposed Fix
bug-186899-20180621164612.patch (text/plain), 24.48 KB, created by
BJ Burg
on 2018-06-21 16:46:12 PDT
(
hide
)
Description:
Proposed Fix
Filename:
MIME Type:
Creator:
BJ Burg
Created:
2018-06-21 16:46:12 PDT
Size:
24.48 KB
patch
obsolete
>Subversion Revision: 233066 >diff --git a/Source/WebDriver/ChangeLog b/Source/WebDriver/ChangeLog >index 3fb27dc398be12f358203f0d58485b54574d2880..aacc67b21fd863dbc75f207479dac79b3d1ff09d 100644 >--- a/Source/WebDriver/ChangeLog >+++ b/Source/WebDriver/ChangeLog >@@ -1,3 +1,16 @@ >+2018-06-21 Brian Burg <bburg@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 NOBODY (OOPS!). >+ >+ Adopt new protocol command argument types. >+ >+ * Session.cpp: >+ (WebDriver::Session::performActions): >+ > 2018-06-21 Zan Dobersek <zdobersek@igalia.com> > > [GTK] WebDriver: allow applying host-specific TLS certificates for automated sessions >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index ffc8db064a636e1118919dd28d90e43eb957210c..e04913beb2e71d3f999e97b4bcddb6bb05d66052 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,34 @@ >+2018-06-21 Brian Burg <bburg@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 NOBODY (OOPS!). >+ >+ 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-15 Jer Noble <jer.noble@apple.com> > > Address fullscreen api CSS env feedback >diff --git a/Source/WebDriver/Session.cpp b/Source/WebDriver/Session.cpp >index 53356965fb1d7a95de51d31fc3fd6bc0ceb0cbfa..3d58c8b1c4321664dbe50459b2955c27ada83713 100644 >--- a/Source/WebDriver/Session.cpp >+++ b/Source/WebDriver/Session.cpp >@@ -2318,8 +2318,12 @@ void Session::performActions(Vector<Vector<Action>>&& actionsByTick, Function<vo > } > if (currentState.pressedKey) > state->setString(ASCIILiteral("pressedCharKey"), currentState.pressedKey.value()); >- if (currentState.pressedVirtualKey) >- state->setString(ASCIILiteral("pressedVirtualKey"), 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(ASCIILiteral("pressedVirtualKeys"), WTFMove(virtualKeys)); >+ } > break; > } > states->pushObject(WTFMove(state)); >diff --git a/Source/WebKit/UIProcess/Automation/Automation.json b/Source/WebKit/UIProcess/Automation/Automation.json >index 78ee2ac91df4baed378341595c09a9b9b86a2d08..31e0d9ce3adfadf6dc036bdbb6d18522809bf84e 100644 >--- a/Source/WebKit/UIProcess/Automation/Automation.json >+++ b/Source/WebKit/UIProcess/Automation/Automation.json >@@ -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'."}, >diff --git a/Source/WebKit/UIProcess/Automation/SimulatedInputDispatcher.cpp b/Source/WebKit/UIProcess/Automation/SimulatedInputDispatcher.cpp >index 912118ce2263fb449482faa451c4e662f11d4809..1cac17cdacda16da3ea15b141775225c0fffeea3 100644 >--- a/Source/WebKit/UIProcess/Automation/SimulatedInputDispatcher.cpp >+++ b/Source/WebKit/UIProcess/Automation/SimulatedInputDispatcher.cpp >@@ -267,11 +267,21 @@ void SimulatedInputDispatcher::transitionInputSourceToState(SimulatedInputSource > } > 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: >diff --git a/Source/WebKit/UIProcess/Automation/SimulatedInputDispatcher.h b/Source/WebKit/UIProcess/Automation/SimulatedInputDispatcher.h >index e451ebbee2ee6bbf19b2cb29dbdb07c293798884..dd3d04f38d1d991044aa8f5cbe28801aff1cf18a 100644 >--- a/Source/WebKit/UIProcess/Automation/SimulatedInputDispatcher.h >+++ b/Source/WebKit/UIProcess/Automation/SimulatedInputDispatcher.h >@@ -52,6 +52,7 @@ class WebPageProxy; > > 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 @@ enum class SimulatedInputSourceType { > > 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: > 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; > }; > >diff --git a/Source/WebKit/UIProcess/Automation/WebAutomationSession.cpp b/Source/WebKit/UIProcess/Automation/WebAutomationSession.cpp >index 149d02c5c8df3365334d321bf0e9a2a1a7348f2d..404c8c885eb17feff3514742b6a1b357dcdf0530 100644 >--- a/Source/WebKit/UIProcess/Automation/WebAutomationSession.cpp >+++ b/Source/WebKit/UIProcess/Automation/WebAutomationSession.cpp >@@ -1479,7 +1479,7 @@ void WebAutomationSession::simulateMouseInteraction(WebPageProxy& page, MouseInt > }); > } > >-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 @@ void WebAutomationSession::simulateKeyboardInteraction(WebPageProxy& page, Keybo > 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 @@ void WebAutomationSession::performKeyboardInteractions(const String& handle, con > String virtualKeyString; > bool foundVirtualKey = interactionObject->getString(ASCIILiteral("key"), 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,9 +1795,24 @@ void WebAutomationSession::performInteractionSequence(const String& handle, cons > if (stateObject->getString(ASCIILiteral("pressedCharKey"), pressedCharKeyString)) > sourceState.pressedCharKey = pressedCharKeyString.characterAt(0); > >- String pressedVirtualKeyString; >- if (stateObject->getString(ASCIILiteral("pressedVirtualKey"), pressedVirtualKeyString)) >- sourceState.pressedVirtualKey = Inspector::Protocol::AutomationHelpers::parseEnumValueFromString<Inspector::Protocol::Automation::VirtualKey>(pressedVirtualKeyString); >+ RefPtr<JSON::Array> pressedVirtualKeysArray; >+ if (stateObject->getArray(ASCIILiteral("pressedVirtualKeys"), 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(ASCIILiteral("pressedButton"), pressedButtonString)) { >diff --git a/Source/WebKit/UIProcess/Automation/WebAutomationSession.h b/Source/WebKit/UIProcess/Automation/WebAutomationSession.h >index 12b7335b863a9c29123b82946ecd2e9527661073..2690c77880eb9f290be5a155c870483f9e82ab7b 100644 >--- a/Source/WebKit/UIProcess/Automation/WebAutomationSession.h >+++ b/Source/WebKit/UIProcess/Automation/WebAutomationSession.h >@@ -137,7 +137,7 @@ public: > > // 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 @@ private: > // 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. >diff --git a/Source/WebKit/UIProcess/Automation/gtk/WebAutomationSessionGtk.cpp b/Source/WebKit/UIProcess/Automation/gtk/WebAutomationSessionGtk.cpp >index 594a8130b53723b2eb83d3dd855dc8d7442c5ec6..027555ad9e3e294184914ea273097f29b9922932 100644 >--- a/Source/WebKit/UIProcess/Automation/gtk/WebAutomationSessionGtk.cpp >+++ b/Source/WebKit/UIProcess/Automation/gtk/WebAutomationSessionGtk.cpp >@@ -294,15 +294,19 @@ static unsigned modifiersForKeyCode(unsigned keyCode) > 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.value())); >+ } >+ ); > unsigned modifiers = modifiersForKeyCode(keyCode); > > switch (interaction) { >diff --git a/Source/WebKit/UIProcess/Automation/ios/WebAutomationSessionIOS.mm b/Source/WebKit/UIProcess/Automation/ios/WebAutomationSessionIOS.mm >index c11c0346ed03e82e7c73243fa6f27a3fc1d6f675..39cf660f312741416c585dd1320ccb10c3e1f0c2 100644 >--- a/Source/WebKit/UIProcess/Automation/ios/WebAutomationSessionIOS.mm >+++ b/Source/WebKit/UIProcess/Automation/ios/WebAutomationSessionIOS.mm >@@ -65,10 +65,8 @@ void WebAutomationSession::sendSynthesizedEventsToPage(WebPageProxy& page, NSArr > > #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,35 +77,36 @@ void WebAutomationSession::platformSimulateKeyboardInteraction(WebPageProxy& pag > std::optional<unichar> charCodeIgnoringModifiers; > > // Figure out the effects of sticky modifiers. >- if (virtualKey.has_value()) { >- charCode = charCodeForVirtualKey(virtualKey.value()); >- charCodeIgnoringModifiers = charCodeIgnoringModifiersForVirtualKey(virtualKey.value()); >- >- 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; >+ WTF::switchOn(key, >+ [&] (VirtualKey virtualKey) { >+ charCode = charCodeForVirtualKey(virtualKey); >+ charCodeIgnoringModifiers = charCodeIgnoringModifiersForVirtualKey(virtualKey); >+ >+ 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 >diff --git a/Source/WebKit/UIProcess/Automation/mac/WebAutomationSessionMac.mm b/Source/WebKit/UIProcess/Automation/mac/WebAutomationSessionMac.mm >index bd471fc9ad90736bf23eda19744573419cb70170..2f2245c4d973917bc7502cdb5a0935068919814f 100644 >--- a/Source/WebKit/UIProcess/Automation/mac/WebAutomationSessionMac.mm >+++ b/Source/WebKit/UIProcess/Automation/mac/WebAutomationSessionMac.mm >@@ -425,31 +425,30 @@ static NSEventModifierFlags eventModifierFlagsForVirtualKey(VirtualKey key) > } > } > >-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; > 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()); >- } >- >- if (charKey.has_value()) { >- charCode = (unichar)charKey.value(); >- charCodeIgnoringModifiers = (unichar)charKey.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; >+ } >+ ); > > // 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.
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 186899
:
343289
|
343331
|
343346