Changeset 248715 in webkit
- Timestamp:
- Aug 15, 2019 9:02:26 AM (5 years ago)
- Location:
- trunk/Source/WebKit
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r248713 r248715 1 2019-08-14 Brian Burg <bburg@apple.com> 2 3 Web Automation: mouse buttons are not correctly printed in SimulatedInputDispatcher log spew 4 https://bugs.webkit.org/show_bug.cgi?id=200729 5 6 Reviewed by Devin Rousso. 7 8 This was printing out gibberish because it was trying to decode a WebMouseEvent button 9 as an Automation protocol button. The logging was less useful because of it. 10 11 To fix this, push usage of Automation protocol-based MouseButton type alias all the way 12 to the platform-specific methods. The mouse buttons are the same for WebMouseEvent::Button 13 and the Automation protocol type, except the automation type has an auto-generated toString. 14 15 * UIProcess/Automation/SimulatedInputDispatcher.h: 16 * UIProcess/Automation/SimulatedInputDispatcher.cpp: 17 (WebKit::SimulatedInputDispatcher::transitionInputSourceToState): 18 (WebKit::SimulatedInputDispatcher::run): 19 Fix types. 20 21 * UIProcess/Automation/WebAutomationSession.h: 22 * UIProcess/Automation/WebAutomationSession.cpp: 23 (WebKit::WebAutomationSession::simulateMouseInteraction): 24 (WebKit::WebAutomationSession::performMouseInteraction): 25 (WebKit::WebAutomationSession::performInteractionSequence): 26 (WebKit::protocolMouseButtonToWebMouseEventButton): Deleted. 27 Fix types. 28 29 * UIProcess/Automation/mac/WebAutomationSessionMac.mm: 30 (WebKit::automationMouseButtonToPlatformMouseButton): 31 (WebKit::WebAutomationSession::platformSimulateMouseInteraction): 32 * UIProcess/Automation/gtk/WebAutomationSessionGtk.cpp: 33 (WebKit::mouseButtonToGdkButton): 34 (WebKit::WebAutomationSession::platformSimulateMouseInteraction): 35 * UIProcess/Automation/wpe/WebAutomationSessionWPE.cpp: 36 (WebKit::mouseButtonToWPEButton): 37 (WebKit::WebAutomationSession::platformSimulateMouseInteraction): 38 Move translation between MouseButton and native button values to platform methods. 39 1 40 2019-08-15 Simon Fraser <simon.fraser@apple.com> 2 41 -
trunk/Source/WebKit/UIProcess/Automation/SimulatedInputDispatcher.cpp
r248713 r248715 297 297 LOG(Automation, "SimulatedInputDispatcher[%p]: simulating MouseMove from (%d, %d) to (%d, %d) for transition to %d.%d", this, a.location.value().x(), a.location.value().y(), b.location.value().x(), b.location.value().y(), m_keyframeIndex, m_inputSourceStateIndex); 298 298 // FIXME: This does not interpolate mousemoves per the "perform a pointer move" algorithm (§17.4 Dispatching Actions). 299 m_client.simulateMouseInteraction(m_page, MouseInteraction::Move, b.pressedMouseButton.valueOr(MouseButton::No Button), b.location.value(), WTFMove(eventDispatchFinished));299 m_client.simulateMouseInteraction(m_page, MouseInteraction::Move, b.pressedMouseButton.valueOr(MouseButton::None), b.location.value(), WTFMove(eventDispatchFinished)); 300 300 } else 301 301 eventDispatchFinished(WTF::nullopt); … … 402 402 m_keyframes.appendVector(WTFMove(keyFrames)); 403 403 404 LOG(Automation, "SimulatedInputDispatcher[%p]: starting input simulation using % d keyframes", this, m_keyframeIndex);404 LOG(Automation, "SimulatedInputDispatcher[%p]: starting input simulation using %zu keyframes", this, m_keyframes.size()); 405 405 406 406 transitionToNextKeyFrame(); -
trunk/Source/WebKit/UIProcess/Automation/SimulatedInputDispatcher.h
r248713 r248715 42 42 enum class ErrorMessage; 43 43 enum class KeyboardInteractionType; 44 enum class MouseButton; 44 45 enum class MouseInteraction; 45 46 enum class MouseMoveOrigin; … … 58 59 using VirtualKeySet = HashSet<VirtualKey, WTF::IntHash<VirtualKey>, WTF::StrongEnumHashTraits<VirtualKey>>; 59 60 using CharKey = char; // For WebDriver, this only needs to support ASCII characters on 102-key keyboard. 60 using MouseButton = WebMouseEvent::Button;61 using MouseButton = Inspector::Protocol::Automation::MouseButton; 61 62 using MouseInteraction = Inspector::Protocol::Automation::MouseInteraction; 62 63 using MouseMoveOrigin = Inspector::Protocol::Automation::MouseMoveOrigin; … … 126 127 virtual ~Client() { } 127 128 #if ENABLE(WEBDRIVER_MOUSE_INTERACTIONS) 128 virtual void simulateMouseInteraction(WebPageProxy&, MouseInteraction, WebMouseEvent::Button, const WebCore::IntPoint& locationInView, AutomationCompletionHandler&&) = 0;129 virtual void simulateMouseInteraction(WebPageProxy&, MouseInteraction, MouseButton, const WebCore::IntPoint& locationInView, AutomationCompletionHandler&&) = 0; 129 130 #endif 130 131 #if ENABLE(WEBDRIVER_TOUCH_INTERACTIONS) -
trunk/Source/WebKit/UIProcess/Automation/WebAutomationSession.cpp
r248713 r248715 1483 1483 1484 1484 #if ENABLE(WEBDRIVER_MOUSE_INTERACTIONS) 1485 void WebAutomationSession::simulateMouseInteraction(WebPageProxy& page, MouseInteraction interaction, WebMouseEvent::Button mouseButton, const WebCore::IntPoint& locationInViewport, CompletionHandler<void(Optional<AutomationCommandError>)>&& completionHandler) 1485 1486 void WebAutomationSession::simulateMouseInteraction(WebPageProxy& page, MouseInteraction interaction, MouseButton mouseButton, const WebCore::IntPoint& locationInViewport, CompletionHandler<void(Optional<AutomationCommandError>)>&& completionHandler) 1486 1487 { 1487 1488 page.getWindowFrameWithCallback([this, protectedThis = makeRef(*this), completionHandler = WTFMove(completionHandler), page = makeRef(page), interaction, mouseButton, locationInViewport](WebCore::FloatRect windowFrame) mutable { … … 1582 1583 #endif // ENABLE(WEBDRIVER_MOUSE_INTERACTIONS) 1583 1584 1584 #if ENABLE(WEBDRIVER_ACTIONS_API)1585 static WebMouseEvent::Button protocolMouseButtonToWebMouseEventButton(Inspector::Protocol::Automation::MouseButton button)1586 {1587 switch (button) {1588 case Inspector::Protocol::Automation::MouseButton::None:1589 return WebMouseEvent::NoButton;1590 case Inspector::Protocol::Automation::MouseButton::Left:1591 return WebMouseEvent::LeftButton;1592 case Inspector::Protocol::Automation::MouseButton::Middle:1593 return WebMouseEvent::MiddleButton;1594 case Inspector::Protocol::Automation::MouseButton::Right:1595 return WebMouseEvent::RightButton;1596 }1597 1598 RELEASE_ASSERT_NOT_REACHED();1599 }1600 #endif // ENABLE(WEBDRIVER_ACTIONS_API)1601 1602 1585 void WebAutomationSession::performMouseInteraction(const String& handle, const JSON::Object& requestedPositionObject, const String& mouseButtonString, const String& mouseInteractionString, const JSON::Array& keyModifierStrings, Ref<PerformMouseInteractionCallback>&& callback) 1603 1586 { … … 1660 1643 callbackInMap = WTFMove(mouseEventsFlushedCallback); 1661 1644 1662 platformSimulateMouseInteraction(page, parsedInteraction.value(), p rotocolMouseButtonToWebMouseEventButton(parsedButton.value()), locationInViewport, keyModifiers);1645 platformSimulateMouseInteraction(page, parsedInteraction.value(), parsedButton.value(), locationInViewport, keyModifiers); 1663 1646 1664 1647 // If the event location was previously clipped and does not hit test anything in the window, then it will not be processed. … … 1902 1885 if (stateObject->getString("pressedButton"_s, pressedButtonString)) { 1903 1886 auto protocolButton = Inspector::Protocol::AutomationHelpers::parseEnumValueFromString<Inspector::Protocol::Automation::MouseButton>(pressedButtonString); 1904 sourceState.pressedMouseButton = protocol MouseButtonToWebMouseEventButton(protocolButton.valueOr(Inspector::Protocol::Automation::MouseButton::None));1887 sourceState.pressedMouseButton = protocolButton.valueOr(MouseButton::None); 1905 1888 } 1906 1889 -
trunk/Source/WebKit/UIProcess/Automation/WebAutomationSession.h
r248713 r248715 146 146 // SimulatedInputDispatcher::Client API 147 147 #if ENABLE(WEBDRIVER_MOUSE_INTERACTIONS) 148 void simulateMouseInteraction(WebPageProxy&, MouseInteraction, WebMouseEvent::Button, const WebCore::IntPoint& locationInView, AutomationCompletionHandler&&) final;148 void simulateMouseInteraction(WebPageProxy&, MouseInteraction, MouseButton, const WebCore::IntPoint& locationInView, AutomationCompletionHandler&&) final; 149 149 #endif 150 150 #if ENABLE(WEBDRIVER_TOUCH_INTERACTIONS) … … 246 246 // Platform-dependent implementations. 247 247 #if ENABLE(WEBDRIVER_MOUSE_INTERACTIONS) 248 void platformSimulateMouseInteraction(WebPageProxy&, MouseInteraction, WebMouseEvent::Button, const WebCore::IntPoint& locationInViewport, OptionSet<WebEvent::Modifier>);248 void platformSimulateMouseInteraction(WebPageProxy&, MouseInteraction, MouseButton, const WebCore::IntPoint& locationInViewport, OptionSet<WebEvent::Modifier>); 249 249 #endif 250 250 #if ENABLE(WEBDRIVER_TOUCH_INTERACTIONS) -
trunk/Source/WebKit/UIProcess/Automation/gtk/WebAutomationSessionGtk.cpp
r246677 r248715 49 49 } 50 50 51 static unsigned mouseButtonToGdkButton( WebMouseEvent::Button button)51 static unsigned mouseButtonToGdkButton(MouseButton button) 52 52 { 53 53 switch (button) { 54 case WebMouseEvent::NoButton:55 case WebMouseEvent::LeftButton:54 case MouseButton::None: 55 case MouseButton::Left: 56 56 return GDK_BUTTON_PRIMARY; 57 case WebMouseEvent::MiddleButton:57 case MouseButton::Middle: 58 58 return GDK_BUTTON_MIDDLE; 59 case WebMouseEvent::RightButton:59 case MouseButton::Right: 60 60 return GDK_BUTTON_SECONDARY; 61 61 } … … 102 102 } 103 103 104 void WebAutomationSession::platformSimulateMouseInteraction(WebPageProxy& page, MouseInteraction interaction, WebMouseEvent::Button button, const WebCore::IntPoint& locationInView, OptionSet<WebEvent::Modifier> keyModifiers)104 void WebAutomationSession::platformSimulateMouseInteraction(WebPageProxy& page, MouseInteraction interaction, MouseButton button, const WebCore::IntPoint& locationInView, OptionSet<WebEvent::Modifier> keyModifiers) 105 105 { 106 106 unsigned gdkButton = mouseButtonToGdkButton(button); -
trunk/Source/WebKit/UIProcess/Automation/mac/WebAutomationSessionMac.mm
r248696 r248715 122 122 123 123 #if ENABLE(WEBDRIVER_MOUSE_INTERACTIONS) 124 void WebAutomationSession::platformSimulateMouseInteraction(WebPageProxy& page, MouseInteraction interaction, WebMouseEvent::Button button, const WebCore::IntPoint& locationInViewport, OptionSet<WebEvent::Modifier> keyModifiers) 124 125 static WebMouseEvent::Button automationMouseButtonToPlatformMouseButton(MouseButton button) 126 { 127 switch (button) { 128 case MouseButton::Left: return WebMouseEvent::LeftButton; 129 case MouseButton::Middle: return WebMouseEvent::MiddleButton; 130 case MouseButton::Right: return WebMouseEvent::RightButton; 131 case MouseButton::None: return WebMouseEvent::NoButton; 132 default: ASSERT_NOT_REACHED(); 133 } 134 } 135 136 void WebAutomationSession::platformSimulateMouseInteraction(WebPageProxy& page, MouseInteraction interaction, MouseButton button, const WebCore::IntPoint& locationInViewport, OptionSet<WebEvent::Modifier> keyModifiers) 125 137 { 126 138 IntRect windowRect; 139 127 140 IntPoint locationInView = WebCore::IntPoint(locationInViewport.x(), locationInViewport.y() + page.topContentInset()); 128 141 page.rootViewToWindow(IntRect(locationInView, IntSize()), windowRect); … … 148 161 NSEventType dragEventType = (NSEventType)0; 149 162 NSEventType upEventType = (NSEventType)0; 150 switch ( button) {163 switch (automationMouseButtonToPlatformMouseButton(button)) { 151 164 case WebMouseEvent::NoButton: 152 165 downEventType = upEventType = dragEventType = NSEventTypeMouseMoved; -
trunk/Source/WebKit/UIProcess/Automation/wpe/WebAutomationSessionWPE.cpp
r241000 r248715 45 45 } 46 46 47 static unsigned mouseButtonToWPEButton( WebMouseEvent::Button button)47 static unsigned mouseButtonToWPEButton(MouseButton button) 48 48 { 49 49 switch (button) { 50 case WebMouseEvent::NoButton:51 case WebMouseEvent::LeftButton:50 case MouseButton::None: 51 case MouseButton::Left: 52 52 return 1; 53 case WebMouseEvent::MiddleButton:53 case MouseButton::Middle: 54 54 return 3; 55 case WebMouseEvent::RightButton:55 case MouseButton::Right: 56 56 return 2; 57 57 } … … 92 92 } 93 93 94 void WebAutomationSession::platformSimulateMouseInteraction(WebPageProxy& page, MouseInteraction interaction, WebMouseEvent::Button button, const WebCore::IntPoint& locationInView, OptionSet<WebEvent::Modifier> keyModifiers)94 void WebAutomationSession::platformSimulateMouseInteraction(WebPageProxy& page, MouseInteraction interaction, MouseButton button, const WebCore::IntPoint& locationInView, OptionSet<WebEvent::Modifier> keyModifiers) 95 95 { 96 96 unsigned wpeButton = mouseButtonToWPEButton(button);
Note: See TracChangeset
for help on using the changeset viewer.