WK1 mouse events are missing movementX and movementY for pointerlock.
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 4 Feb 2017 03:03:39 +0000 (03:03 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 4 Feb 2017 03:03:39 +0000 (03:03 +0000)
https://bugs.webkit.org/show_bug.cgi?id=167775
rdar://problem/30343810

Patch by Jeremy Jones <jeremyj@apple.com> on 2017-02-03
Reviewed by Alexey Proskuryakov.

Source/WebCore:

pointer-lock/mouse-event-delivery.html

Improve mouse-event-delivery.html test to mouse move and check for valid movementX and movementY.

* platform/mac/PlatformEventFactoryMac.mm:
(WebCore::PlatformMouseEventBuilder::PlatformMouseEventBuilder): WK1 plumb throuhg movementX and movementY

Tools:

Set kCGMouseEventDeltaX and kCGMouseEventDeltaY when synthesizing mouse move events.

* DumpRenderTree/mac/EventSendingController.mm:
(-[EventSendingController mouseMoveToX:Y:]):
* WebKitTestRunner/mac/EventSenderProxy.mm:
(WTR::EventSenderProxy::mouseMoveTo):

LayoutTests:

Enable pointer-lock/mouse-event-delivery.html for mac.

* platform/mac/TestExpectations:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@211663 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/pointer-lock/mouse-event-delivery-expected.txt
LayoutTests/pointer-lock/mouse-event-delivery.html
Source/WebCore/ChangeLog
Source/WebCore/platform/mac/PlatformEventFactoryMac.mm
Tools/ChangeLog
Tools/DumpRenderTree/mac/EventSendingController.mm
Tools/WebKitTestRunner/mac/EventSenderProxy.mm

index 8d69a0c..b2aff1d 100644 (file)
@@ -1,3 +1,15 @@
+2017-02-03  Jeremy Jones  <jeremyj@apple.com>
+
+        WK1 mouse events are missing movementX and movementY for pointerlock.
+        https://bugs.webkit.org/show_bug.cgi?id=167775
+        rdar://problem/30343810
+
+        Reviewed by Alexey Proskuryakov.
+
+        Enable pointer-lock/mouse-event-delivery.html for mac.
+
+        * platform/mac/TestExpectations:
+
 2017-02-03  Simon Fraser  <simon.fraser@apple.com>
 
         Correctly set the "inWindow" flag for TileControllers that aren't the page tiles, and clarify "usingTiledBacking" logic
index 7f5459c..55cdab8 100644 (file)
@@ -8,6 +8,9 @@ PASS document.pointerLockElement is targetdiv1
      With a lock in place send a wheel event.
 PASS event type: wheel, target: target1, received on: target1
 PASS event type: wheel, target: target1, received on: body
+     With a lock in place move the mouse.
+PASS event type: mousemove, movementX: 25, movementY: -30, target: target1, received on: target1
+PASS event type: mousemove, movementX: 25, movementY: -30, target: target1, received on: body
      With a lock in place send a click.
 PASS event type: mousedown, target: target1, received on: target1
 PASS event type: mousedown, target: target1, received on: body
index 11fd10e..ede1e82 100644 (file)
       testPassed("event type: " + e.type + ", target: " + e.target.id + ", received on: " + e.currentTarget.id);
       doNextStep();
     }
+    function eventDeltaExpected(e) {
+      testPassed("event type: " + e.type + ", movementX: " + e.movementX + ", movementY: " + e.movementY + ", target: " + e.target.id + ", received on: " + e.currentTarget.id);
+    }
+    function eventDeltaExpectedThenNextStep(e) {
+      testPassed("event type: " + e.type + ", movementX: " + e.movementX + ", movementY: " + e.movementY + ", target: " + e.target.id + ", received on: " + e.currentTarget.id);
+      doNextStep();
+    }
 
     todo = [
         function () {
             }
         },
         function () {
+            debug("     With a lock in place move the mouse.")
+            targetdiv1.onmousemove = eventDeltaExpectedThenNextStep;
+            targetdiv2.onmousemove = eventNotExpected;
+            document.body.onmousemove = eventDeltaExpected;
+            if (window.eventSender) {
+                window.eventSender.mouseMoveTo(45,50);
+            }
+        },
+        function () {
             debug("     With a lock in place send a click.")
+            targetdiv1.onmousemove = null;
+            targetdiv2.onmousemove = null;
+            document.body.onmousemove = null;
+
             targetdiv1.onmousedown = eventExpected;
             targetdiv2.onmousedown = eventNotExpected;
             document.body.onmousedown = eventExpected;
index 65fbd45..b50f6a5 100644 (file)
@@ -1,3 +1,18 @@
+2017-02-03  Jeremy Jones  <jeremyj@apple.com>
+
+        WK1 mouse events are missing movementX and movementY for pointerlock.
+        https://bugs.webkit.org/show_bug.cgi?id=167775
+        rdar://problem/30343810
+
+        Reviewed by Alexey Proskuryakov.
+
+        pointer-lock/mouse-event-delivery.html
+
+        Improve mouse-event-delivery.html test to mouse move and check for valid movementX and movementY.
+        
+        * platform/mac/PlatformEventFactoryMac.mm:
+        (WebCore::PlatformMouseEventBuilder::PlatformMouseEventBuilder): WK1 plumb throuhg movementX and movementY
+
 2017-02-03  Simon Fraser  <simon.fraser@apple.com>
 
         Correctly set the "inWindow" flag for TileControllers that aren't the page tiles, and clarify "usingTiledBacking" logic
index 7705d16..a9a99f3 100644 (file)
@@ -714,6 +714,9 @@ public:
         m_globalPosition = IntPoint(globalPointForEvent(event));
         m_button = mouseButtonForEvent(event);
         m_clickCount = clickCountForEvent(event);
+#if ENABLE(POINTER_LOCK)
+        m_movementDelta = IntPoint(event.deltaX, event.deltaY);
+#endif
 
         m_force = 0;
 #if defined(__LP64__) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 101003
index a1326b1..e8d0c5d 100644 (file)
@@ -1,3 +1,18 @@
+2017-02-03  Jeremy Jones  <jeremyj@apple.com>
+
+        WK1 mouse events are missing movementX and movementY for pointerlock.
+        https://bugs.webkit.org/show_bug.cgi?id=167775
+        rdar://problem/30343810
+
+        Reviewed by Alexey Proskuryakov.
+
+        Set kCGMouseEventDeltaX and kCGMouseEventDeltaY when synthesizing mouse move events.
+
+        * DumpRenderTree/mac/EventSendingController.mm:
+        (-[EventSendingController mouseMoveToX:Y:]):
+        * WebKitTestRunner/mac/EventSenderProxy.mm:
+        (WTR::EventSenderProxy::mouseMoveTo):
+
 2017-02-03  Simon Fraser  <simon.fraser@apple.com>
 
         Correctly set the "inWindow" flag for TileControllers that aren't the page tiles, and clarify "usingTiledBacking" logic
index 65e2c1f..cfd5641 100644 (file)
@@ -643,9 +643,9 @@ static int buildModifierFlags(const WebScriptObject* modifiers)
 
     NSView *view = [mainFrame webView];
 #if !PLATFORM(IOS)
-    lastMousePosition = [view convertPoint:NSMakePoint(x, [view frame].size.height - y) toView:nil];
+    NSPoint newMousePosition = [view convertPoint:NSMakePoint(x, [view frame].size.height - y) toView:nil];
     NSEvent *event = [NSEvent mouseEventWithType:(leftMouseButtonDown ? NSEventTypeLeftMouseDragged : NSEventTypeMouseMoved)
-                                        location:lastMousePosition 
+                                        location:newMousePosition
                                    modifierFlags:0 
                                        timestamp:[self currentEventTime]
                                     windowNumber:[[view window] windowNumber] 
@@ -653,6 +653,11 @@ static int buildModifierFlags(const WebScriptObject* modifiers)
                                      eventNumber:++eventNumber 
                                       clickCount:(leftMouseButtonDown ? clickCount : 0) 
                                         pressure:0.0];
+    CGEventRef cgEvent = event.CGEvent;
+    CGEventSetIntegerValueField(cgEvent, kCGMouseEventDeltaX, newMousePosition.x - lastMousePosition.x);
+    CGEventSetIntegerValueField(cgEvent, kCGMouseEventDeltaY, newMousePosition.y - lastMousePosition.y);
+    event = [NSEvent eventWithCGEvent:cgEvent];
+    lastMousePosition = newMousePosition;
 #else
     lastMousePosition = [view convertPoint:NSMakePoint(x, y) toView:nil];
     WebEvent *event = [[WebEvent alloc] initWithMouseEventType:WebEventMouseMoved
index 4c19542..ee4eb0c 100644 (file)
@@ -600,12 +600,10 @@ void EventSenderProxy::startAndCancelMouseForceClick()
 void EventSenderProxy::mouseMoveTo(double x, double y)
 {
     NSView *view = m_testController->mainWebView()->platformView();
-    NSPoint position = [view convertPoint:NSMakePoint(x, y) toView:nil];
-    m_position.x = position.x;
-    m_position.y = position.y;
+    NSPoint newMousePosition = [view convertPoint:NSMakePoint(x, y) toView:nil];
     bool isDrag = m_leftMouseButtonDown;
     NSEvent *event = [NSEvent mouseEventWithType:(isDrag ? NSEventTypeLeftMouseDragged : NSEventTypeMouseMoved)
-                                        location:position
+                                        location:newMousePosition
                                    modifierFlags:0 
                                        timestamp:absoluteTimeForEventTime(currentEventTime())
                                     windowNumber:view.window.windowNumber
@@ -614,6 +612,13 @@ void EventSenderProxy::mouseMoveTo(double x, double y)
                                       clickCount:(m_leftMouseButtonDown ? m_clickCount : 0) 
                                         pressure:0];
 
+    CGEventRef cgEvent = event.CGEvent;
+    CGEventSetIntegerValueField(cgEvent, kCGMouseEventDeltaX, newMousePosition.x - m_position.x);
+    CGEventSetIntegerValueField(cgEvent, kCGMouseEventDeltaY, newMousePosition.y - m_position.y);
+    event = [NSEvent eventWithCGEvent:cgEvent];
+    m_position.x = newMousePosition.x;
+    m_position.y = newMousePosition.y;
+
     NSPoint windowLocation = event.locationInWindow;
     // Always target drags at the WKWebView to allow for drag-scrolling outside the view.
     NSView *targetView = isDrag ? m_testController->mainWebView()->platformView() : [m_testController->mainWebView()->platformView() hitTest:windowLocation];