From 09f456b2808224e7707e51bfab8957ef067154e4 Mon Sep 17 00:00:00 2001 From: janekptacijarabaci Date: Fri, 20 Apr 2018 22:18:52 +0200 Subject: moebius#71: DOM - Pointer Events - improvements https://github.com/MoonchildProductions/moebius/pull/71 --- dom/events/EventStateManager.cpp | 52 +++++------- dom/events/PointerEvent.cpp | 14 ++++ dom/events/PointerEvent.h | 2 + dom/events/test/pointerevents/mochitest.ini | 1 + ...ercapture_events_to_original_target-manual.html | 38 +++++---- dom/events/test/pointerevents/test_bug1285128.html | 7 +- dom/events/test/pointerevents/test_bug1323158.html | 93 ++++++++++++++++++++++ ...nterevent_capture_suppressing_mouse-manual.html | 1 + ...ercapture_events_to_original_target-manual.html | 27 ++++++- ...ent_setpointercapture_relatedtarget-manual.html | 4 +- dom/webidl/PointerEvent.webidl | 4 + 11 files changed, 186 insertions(+), 57 deletions(-) create mode 100644 dom/events/test/pointerevents/test_bug1323158.html (limited to 'dom') diff --git a/dom/events/EventStateManager.cpp b/dom/events/EventStateManager.cpp index f66cf3f90..c6b304183 100644 --- a/dom/events/EventStateManager.cpp +++ b/dom/events/EventStateManager.cpp @@ -731,6 +731,9 @@ EventStateManager::PreHandleEvent(nsPresContext* aPresContext, FlushPendingEvents(aPresContext); break; } + case ePointerGotCapture: + GenerateMouseEnterExit(mouseEvent); + break; case eDragStart: if (Prefs::ClickHoldContextMenu()) { // an external drag gesture event came in, not generated internally @@ -3890,10 +3893,7 @@ CreateMouseOrPointerWidgetEvent(WidgetMouseEvent* aMouseEvent, newPointerEvent->mWidth = sourcePointer->mWidth; newPointerEvent->mHeight = sourcePointer->mHeight; newPointerEvent->inputSource = sourcePointer->inputSource; - newPointerEvent->relatedTarget = - nsIPresShell::GetPointerCapturingContent(sourcePointer->pointerId) - ? nullptr - : aRelatedContent; + newPointerEvent->relatedTarget = aRelatedContent; aNewEvent = newPointerEvent.forget(); } else { aNewEvent = @@ -4106,14 +4106,8 @@ EventStateManager::NotifyMouseOut(WidgetMouseEvent* aMouseEvent, SetContentState(nullptr, NS_EVENT_STATE_HOVER); } - // In case we go out from capturing element (retargetedByPointerCapture is true) - // we should dispatch ePointerLeave event and only for capturing element. - RefPtr movingInto = aMouseEvent->retargetedByPointerCapture - ? wrapper->mLastOverElement->GetParent() - : aMovingInto; - EnterLeaveDispatcher leaveDispatcher(this, wrapper->mLastOverElement, - movingInto, aMouseEvent, + aMovingInto, aMouseEvent, isPointer ? ePointerLeave : eMouseLeave); // Fire mouseout @@ -4134,13 +4128,9 @@ EventStateManager::NotifyMouseOver(WidgetMouseEvent* aMouseEvent, { NS_ASSERTION(aContent, "Mouse must be over something"); - // If pointer capture is set, we should suppress pointerover/pointerenter events - // for all elements except element which have pointer capture. - bool dispatch = !aMouseEvent->retargetedByPointerCapture; - OverOutElementsWrapper* wrapper = GetWrapperByEventID(aMouseEvent); - if (wrapper->mLastOverElement == aContent && dispatch) + if (wrapper->mLastOverElement == aContent) return; // Before firing mouseover, check for recursion @@ -4163,7 +4153,7 @@ EventStateManager::NotifyMouseOver(WidgetMouseEvent* aMouseEvent, } // Firing the DOM event in the parent document could cause all kinds // of havoc. Reverify and take care. - if (wrapper->mLastOverElement == aContent && dispatch) + if (wrapper->mLastOverElement == aContent) return; // Remember mLastOverElement as the related content for the @@ -4172,11 +4162,9 @@ EventStateManager::NotifyMouseOver(WidgetMouseEvent* aMouseEvent, bool isPointer = aMouseEvent->mClass == ePointerEventClass; - Maybe enterDispatcher; - if (dispatch) { - enterDispatcher.emplace(this, aContent, lastOverElement, aMouseEvent, - isPointer ? ePointerEnter : eMouseEnter); - } + EnterLeaveDispatcher enterDispatcher(this, aContent, lastOverElement, + aMouseEvent, + isPointer ? ePointerEnter : eMouseEnter); NotifyMouseOut(aMouseEvent, aContent); @@ -4188,18 +4176,13 @@ EventStateManager::NotifyMouseOver(WidgetMouseEvent* aMouseEvent, SetContentState(aContent, NS_EVENT_STATE_HOVER); } - if (dispatch) { - // Fire mouseover - wrapper->mLastOverFrame = - DispatchMouseOrPointerEvent(aMouseEvent, - isPointer ? ePointerOver : eMouseOver, - aContent, lastOverElement); - enterDispatcher->Dispatch(); - wrapper->mLastOverElement = aContent; - } else { - wrapper->mLastOverFrame = nullptr; - wrapper->mLastOverElement = nullptr; - } + // Fire mouseover + wrapper->mLastOverFrame = + DispatchMouseOrPointerEvent(aMouseEvent, + isPointer ? ePointerOver : eMouseOver, + aContent, lastOverElement); + enterDispatcher.Dispatch(); + wrapper->mLastOverElement = aContent; // Turn recursion protection back off wrapper->mFirstOverEventElement = nullptr; @@ -4292,6 +4275,7 @@ EventStateManager::GenerateMouseEnterExit(WidgetMouseEvent* aMouseEvent) MOZ_FALLTHROUGH; case ePointerMove: case ePointerDown: + case ePointerGotCapture: { // Get the target content target (mousemove target == mouseover target) nsCOMPtr targetElement = GetEventTargetContent(aMouseEvent); diff --git a/dom/events/PointerEvent.cpp b/dom/events/PointerEvent.cpp index f53739863..fbaa0f737 100644 --- a/dom/events/PointerEvent.cpp +++ b/dom/events/PointerEvent.cpp @@ -93,8 +93,10 @@ PointerEvent::Constructor(EventTarget* aOwner, widgetEvent->mWidth = aParam.mWidth; widgetEvent->mHeight = aParam.mHeight; widgetEvent->pressure = aParam.mPressure; + widgetEvent->tangentialPressure = aParam.mTangentialPressure; widgetEvent->tiltX = aParam.mTiltX; widgetEvent->tiltY = aParam.mTiltY; + widgetEvent->twist = aParam.mTwist; widgetEvent->inputSource = ConvertStringToPointerType(aParam.mPointerType); widgetEvent->mIsPrimary = aParam.mIsPrimary; widgetEvent->buttons = aParam.mButtons; @@ -145,6 +147,12 @@ PointerEvent::Pressure() return mEvent->AsPointerEvent()->pressure; } +float +PointerEvent::TangentialPressure() +{ + return mEvent->AsPointerEvent()->tangentialPressure; +} + int32_t PointerEvent::TiltX() { @@ -157,6 +165,12 @@ PointerEvent::TiltY() return mEvent->AsPointerEvent()->tiltY; } +int32_t +PointerEvent::Twist() +{ + return mEvent->AsPointerEvent()->twist; +} + bool PointerEvent::IsPrimary() { diff --git a/dom/events/PointerEvent.h b/dom/events/PointerEvent.h index 62c5a0c36..12d4941dc 100644 --- a/dom/events/PointerEvent.h +++ b/dom/events/PointerEvent.h @@ -44,8 +44,10 @@ public: int32_t Width(); int32_t Height(); float Pressure(); + float TangentialPressure(); int32_t TiltX(); int32_t TiltY(); + int32_t Twist(); bool IsPrimary(); void GetPointerType(nsAString& aPointerType); }; diff --git a/dom/events/test/pointerevents/mochitest.ini b/dom/events/test/pointerevents/mochitest.ini index 58eae12fe..5de7f27ea 100644 --- a/dom/events/test/pointerevents/mochitest.ini +++ b/dom/events/test/pointerevents/mochitest.ini @@ -148,5 +148,6 @@ support-files = support-files = bug1293174_implicit_pointer_capture_for_touch_1.html [test_bug1293174_implicit_pointer_capture_for_touch_2.html] support-files = bug1293174_implicit_pointer_capture_for_touch_2.html +[test_bug1323158.html] [test_empty_file.html] disabled = disabled # Bug 1150091 - Issue with support-files diff --git a/dom/events/test/pointerevents/pointerevent_releasepointercapture_events_to_original_target-manual.html b/dom/events/test/pointerevents/pointerevent_releasepointercapture_events_to_original_target-manual.html index 31fe919af..2614790f3 100644 --- a/dom/events/test/pointerevents/pointerevent_releasepointercapture_events_to_original_target-manual.html +++ b/dom/events/test/pointerevents/pointerevent_releasepointercapture_events_to_original_target-manual.html @@ -12,20 +12,24 @@ +

Pointer Event: releasePointerCapture() - subsequent events follow normal hitting testing mechanisms

- Use mouse, touch or pen to contact here and move around.

Test complete: Scroll to Summary to view Pass/Fail Results.

diff --git a/dom/events/test/pointerevents/test_bug1285128.html b/dom/events/test/pointerevents/test_bug1285128.html index f7f1eb698..9577940c1 100644 --- a/dom/events/test/pointerevents/test_bug1285128.html +++ b/dom/events/test/pointerevents/test_bug1285128.html @@ -13,7 +13,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1285128 Mozilla Bug 1285128

-
+
+
+ + + + +

+ + + diff --git a/dom/events/test/pointerevents/test_pointerevent_capture_suppressing_mouse-manual.html b/dom/events/test/pointerevents/test_pointerevent_capture_suppressing_mouse-manual.html index 5eb631f6a..2b08e2bb8 100644 --- a/dom/events/test/pointerevents/test_pointerevent_capture_suppressing_mouse-manual.html +++ b/dom/events/test/pointerevents/test_pointerevent_capture_suppressing_mouse-manual.html @@ -19,6 +19,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1000870 function executeTest(int_win) { sendMouseEvent(int_win, "target0", "mousemove"); sendMouseEvent(int_win, "target1", "mousemove"); + sendMouseEvent(int_win, "btnCapture", "mousemove"); sendMouseEvent(int_win, "btnCapture", "mousedown"); sendMouseEvent(int_win, "target1", "mousemove"); sendMouseEvent(int_win, "target0", "mousemove"); diff --git a/dom/events/test/pointerevents/test_pointerevent_releasepointercapture_events_to_original_target-manual.html b/dom/events/test/pointerevents/test_pointerevent_releasepointercapture_events_to_original_target-manual.html index cbf91df74..35350e016 100644 --- a/dom/events/test/pointerevents/test_pointerevent_releasepointercapture_events_to_original_target-manual.html +++ b/dom/events/test/pointerevents/test_pointerevent_releasepointercapture_events_to_original_target-manual.html @@ -17,9 +17,30 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1000870 runTestInNewWindow("pointerevent_releasepointercapture_events_to_original_target-manual.html"); } function executeTest(int_win) { - sendTouchEvent(int_win, "target0", "touchstart"); - sendTouchEvent(int_win, "target0", "touchmove"); - sendTouchEvent(int_win, "target0", "touchend"); + // Synthesize mouse events to run this test. + sendMouseEvent(int_win, "target0", "mousemove"); + sendMouseEvent(int_win, "target0", "mousedown"); + sendMouseEvent(int_win, "target0", "mousemove", {buttons: 1}); + sendMouseEvent(int_win, "target0", "mousemove", {buttons: 1}); + sendMouseEvent(int_win, "target0", "mouseup"); + + window.addEventListener("message", function(aEvent) { + if (aEvent.data == "Test Touch") { + // Synthesize touch events to run this test. + sendTouchEvent(int_win, "target0", "touchstart"); + sendTouchEvent(int_win, "target0", "touchmove"); + sendTouchEvent(int_win, "target0", "touchend"); + window.postMessage("Test Pen", "*"); + } else if (aEvent.data == "Test Pen") { + // Synthesize pen events to run this test. + sendMouseEvent(int_win, "target0", "mousemove", {inputSource:MouseEvent.MOZ_SOURCE_PEN}); + sendMouseEvent(int_win, "target0", "mousedown", {inputSource:MouseEvent.MOZ_SOURCE_PEN}); + sendMouseEvent(int_win, "target0", "mousemove", {inputSource:MouseEvent.MOZ_SOURCE_PEN, buttons: 1}); + sendMouseEvent(int_win, "target0", "mousemove", {inputSource:MouseEvent.MOZ_SOURCE_PEN, buttons: 1}); + sendMouseEvent(int_win, "target0", "mouseup", {inputSource:MouseEvent.MOZ_SOURCE_PEN}); + } + }); + window.postMessage("Test Touch", "*"); } diff --git a/dom/events/test/pointerevents/test_pointerevent_setpointercapture_relatedtarget-manual.html b/dom/events/test/pointerevents/test_pointerevent_setpointercapture_relatedtarget-manual.html index 0883d616b..09e97ec97 100644 --- a/dom/events/test/pointerevents/test_pointerevent_setpointercapture_relatedtarget-manual.html +++ b/dom/events/test/pointerevents/test_pointerevent_setpointercapture_relatedtarget-manual.html @@ -19,8 +19,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1000870 function executeTest(int_win) { sendMouseEvent(int_win, "target1", "mousemove"); sendMouseEvent(int_win, "btnCapture", "mousedown"); - sendMouseEvent(int_win, "target1", "mousemove"); - sendMouseEvent(int_win, "target1", "mouseup"); + sendMouseEvent(int_win, "btnCapture", "mousemove"); + sendMouseEvent(int_win, "btnCapture", "mouseup"); } diff --git a/dom/webidl/PointerEvent.webidl b/dom/webidl/PointerEvent.webidl index 2e83922c8..4e8a0eb90 100644 --- a/dom/webidl/PointerEvent.webidl +++ b/dom/webidl/PointerEvent.webidl @@ -17,8 +17,10 @@ interface PointerEvent : MouseEvent readonly attribute long width; readonly attribute long height; readonly attribute float pressure; + readonly attribute float tangentialPressure; readonly attribute long tiltX; readonly attribute long tiltY; + readonly attribute long twist; readonly attribute DOMString pointerType; readonly attribute boolean isPrimary; }; @@ -29,8 +31,10 @@ dictionary PointerEventInit : MouseEventInit long width = 1; long height = 1; float pressure = 0; + float tangentialPressure = 0; long tiltX = 0; long tiltY = 0; + long twist = 0; DOMString pointerType = ""; boolean isPrimary = false; }; -- cgit v1.2.3