From f18298c006fde4154a8612cc1e954d836c0c5083 Mon Sep 17 00:00:00 2001 From: Olli Pettay Date: Mon, 2 Jan 2023 12:31:40 +0000 Subject: [PATCH] Bug 1807812 - Remove WidgetEventTime::mTime, r=masayuki,geckoview-reviewers,m_kato HTMLSelectEventListener changes are needed, since currently that code works somewhat by accident given that mTime often contains totally bogus values, like PR_IntervalNow(). Those changes then reveal issues also in browser_editAddressDialog.js. Differential Revision: https://phabricator.services.mozilla.com/D165618 --- accessible/base/nsCoreUtils.cpp | 3 - .../test/browser/browser_editAddressDialog.js | 5 ++ dom/base/nsContentUtils.cpp | 10 --- dom/base/nsDOMWindowUtils.cpp | 5 -- dom/events/AnimationEvent.cpp | 1 - dom/events/ClipboardEvent.cpp | 1 - dom/events/CommandEvent.cpp | 1 - dom/events/CompositionEvent.cpp | 1 - dom/events/DeviceMotionEvent.cpp | 2 - dom/events/DragEvent.cpp | 1 - dom/events/Event.cpp | 1 - dom/events/EventStateManager.cpp | 3 - dom/events/FocusEvent.cpp | 1 - dom/events/InputEvent.cpp | 1 - dom/events/KeyboardEvent.cpp | 1 - dom/events/MouseEvent.cpp | 1 - dom/events/MouseScrollEvent.cpp | 1 - dom/events/PointerEvent.cpp | 1 - dom/events/PointerEventHandler.cpp | 1 - dom/events/SimpleGestureEvent.cpp | 1 - dom/events/TextComposition.cpp | 1 - dom/events/TouchEvent.cpp | 1 - dom/events/TransitionEvent.cpp | 1 - dom/events/UIEvent.cpp | 1 - dom/events/WheelEvent.cpp | 1 - dom/events/XULCommandEvent.cpp | 1 - gfx/layers/apz/src/APZCTreeManager.cpp | 11 +-- gfx/layers/apz/src/APZInputBridge.cpp | 2 +- gfx/layers/apz/src/GestureEventListener.cpp | 37 ++++----- gfx/layers/apz/test/gtest/APZTestCommon.h | 6 +- gfx/layers/apz/test/gtest/InputUtils.h | 19 ++--- gfx/layers/apz/test/gtest/TestHitTesting.cpp | 9 +- gfx/layers/apz/test/gtest/TestOverscroll.cpp | 6 +- .../apz/test/gtest/TestScrollHandoff.cpp | 3 +- gfx/layers/apz/test/gtest/TestTreeManager.cpp | 3 +- gfx/layers/apz/util/APZCCallbackHelper.cpp | 16 ++-- gfx/layers/apz/util/APZCCallbackHelper.h | 2 +- gfx/layers/apz/util/APZEventState.cpp | 8 +- layout/base/PresShell.cpp | 1 - layout/base/TouchManager.cpp | 1 - layout/forms/HTMLSelectEventListener.cpp | 13 ++- layout/xul/nsMenuFrame.cpp | 2 +- layout/xul/nsMenuPopupFrame.cpp | 4 +- layout/xul/nsMenuPopupFrame.h | 10 ++- widget/BasicEvents.h | 12 +-- widget/InputData.cpp | 68 ++++++--------- widget/InputData.h | 30 +++---- widget/PuppetWidget.cpp | 1 - widget/TextEventDispatcher.cpp | 1 - widget/TouchEvents.h | 1 - widget/android/GeckoEditableSupport.cpp | 3 - widget/android/nsWindow.cpp | 10 +-- widget/cocoa/nsChildView.mm | 45 +++++----- widget/cocoa/nsCocoaUtils.h | 2 +- widget/cocoa/nsCocoaUtils.mm | 11 +-- widget/gtk/IMContextWrapper.cpp | 6 -- widget/gtk/IMContextWrapper.h | 3 - widget/gtk/nsGtkKeyUtils.cpp | 1 - widget/gtk/nsWindow.cpp | 66 ++------------- widget/gtk/nsWindow.h | 4 - widget/headless/HeadlessWidget.cpp | 12 ++- widget/nsBaseWidget.cpp | 8 +- widget/nsBaseWidget.h | 13 +-- widget/nsGUIEventIPC.h | 4 - widget/nsIWidget.h | 7 -- widget/windows/DirectManipulationOwner.cpp | 11 +-- widget/windows/nsWindow.cpp | 82 +++---------------- widget/windows/nsWindow.h | 3 - 68 files changed, 175 insertions(+), 430 deletions(-) diff --git a/accessible/base/nsCoreUtils.cpp b/accessible/base/nsCoreUtils.cpp index 917ede93bf2f..e5611d30e05b 100644 --- a/accessible/base/nsCoreUtils.cpp +++ b/accessible/base/nsCoreUtils.cpp @@ -133,7 +133,6 @@ void nsCoreUtils::DispatchMouseEvent(EventMessage aMessage, int32_t aX, event.mClickCount = 1; event.mButton = MouseButton::ePrimary; - event.mTime = PR_IntervalNow(); event.mInputSource = dom::MouseEvent_Binding::MOZ_SOURCE_UNKNOWN; nsEventStatus status = nsEventStatus_eIgnore; @@ -154,8 +153,6 @@ void nsCoreUtils::DispatchTouchEvent(EventMessage aMessage, int32_t aX, WidgetTouchEvent event(true, aMessage, aRootWidget); - event.mTime = PR_IntervalNow(); - // XXX: Touch has an identifier of -1 to hint that it is synthesized. RefPtr t = new dom::Touch(-1, LayoutDeviceIntPoint(aX, aY), LayoutDeviceIntPoint(1, 1), 0.0f, 1.0f); diff --git a/browser/extensions/formautofill/test/browser/browser_editAddressDialog.js b/browser/extensions/formautofill/test/browser/browser_editAddressDialog.js index 555de50154de..e1e4a73d8af9 100644 --- a/browser/extensions/formautofill/test/browser/browser_editAddressDialog.js +++ b/browser/extensions/formautofill/test/browser/browser_editAddressDialog.js @@ -603,6 +603,8 @@ add_task(async function test_countryAndStateFieldLabels() { ); } } + // Dispatch a dummy key event so that 's incremental search is cleared. + EventUtils.synthesizeKey("VK_ACCEPT", {}, win); + doc.querySelector("#country").focus(); EventUtils.synthesizeKey("Romania", {}, win); diff --git a/dom/base/nsContentUtils.cpp b/dom/base/nsContentUtils.cpp index 49eb47629683..0c51b7728cf8 100644 --- a/dom/base/nsContentUtils.cpp +++ b/dom/base/nsContentUtils.cpp @@ -4610,8 +4610,6 @@ nsresult nsContentUtils::DispatchEvent(Document* aDoc, nsISupports* aTarget, nsCOMPtr target(do_QueryInterface(aTarget)); - aEvent.mTime = PR_Now(); - aEvent.mSpecifiedEventType = GetEventTypeFromMessage(aEventMessage); aEvent.SetDefaultComposed(); aEvent.SetDefaultComposedInNativeAnonymousContent(); @@ -4686,9 +4684,6 @@ nsresult nsContentUtils::DispatchInputEvent( widgetEvent.mSpecifiedEventType = nsGkAtoms::oninput; widgetEvent.mFlags.mCancelable = false; widgetEvent.mFlags.mComposed = true; - // Using same time as nsContentUtils::DispatchEvent() for backward - // compatibility. - widgetEvent.mTime = PR_Now(); (new AsyncEventDispatcher(aEventTargetElement, widgetEvent)) ->RunDOMEventWhenSafe(); return NS_OK; @@ -4734,10 +4729,6 @@ nsresult nsContentUtils::DispatchInputEvent( IsCancelableBeforeInputEvent(aEditorInputType); MOZ_ASSERT(!inputEvent.mFlags.mCancelable || aEventStatus); - // Using same time as old event dispatcher in EditorBase for backward - // compatibility. - inputEvent.mTime = static_cast(PR_Now() / 1000); - // If there is an editor, set isComposing to true when it has composition. // Note that EditorBase::IsIMEComposing() may return false even when we // need to set it to true. @@ -8477,7 +8468,6 @@ nsresult nsContentUtils::SendMouseEvent( event.mPressure = aPressure; event.mInputSource = aInputSourceArg; event.mClickCount = aClickCount; - event.mTime = PR_IntervalNow(); event.mFlags.mIsSynthesizedForTests = aIsDOMEventSynthesized; event.mExitFrom = exitFrom; diff --git a/dom/base/nsDOMWindowUtils.cpp b/dom/base/nsDOMWindowUtils.cpp index e2cc2300c6a2..5c6c4a44c2da 100644 --- a/dom/base/nsDOMWindowUtils.cpp +++ b/dom/base/nsDOMWindowUtils.cpp @@ -768,8 +768,6 @@ nsDOMWindowUtils::SendWheelEvent(float aX, float aY, double aDeltaX, wheelEvent.mLineOrPageDeltaX = aLineOrPageDeltaX; wheelEvent.mLineOrPageDeltaY = aLineOrPageDeltaY; - wheelEvent.mTime = PR_Now() / 1000; - nsPresContext* presContext = GetPresContext(); NS_ENSURE_TRUE(presContext, NS_ERROR_FAILURE); @@ -891,7 +889,6 @@ nsresult nsDOMWindowUtils::SendTouchEventCommon( } WidgetTouchEvent event(true, msg, widget); event.mModifiers = nsContentUtils::GetWidgetModifiers(aModifiers); - event.mTime = PR_Now(); nsPresContext* presContext = GetPresContext(); if (!presContext) { @@ -1454,7 +1451,6 @@ nsDOMWindowUtils::SendSimpleGestureEvent(const nsAString& aType, float aX, event.mDirection = aDirection; event.mDelta = aDelta; event.mClickCount = aClickCount; - event.mTime = PR_IntervalNow(); nsPresContext* presContext = GetPresContext(); if (!presContext) return NS_ERROR_FAILURE; @@ -2302,7 +2298,6 @@ static void InitEvent(WidgetGUIEvent& aEvent, if (aPt) { aEvent.mRefPoint = *aPt; } - aEvent.mTime = PR_IntervalNow(); } NS_IMETHODIMP diff --git a/dom/events/AnimationEvent.cpp b/dom/events/AnimationEvent.cpp index 1c3e0043fe98..62a4c5196cb9 100644 --- a/dom/events/AnimationEvent.cpp +++ b/dom/events/AnimationEvent.cpp @@ -18,7 +18,6 @@ AnimationEvent::AnimationEvent(EventTarget* aOwner, nsPresContext* aPresContext, mEventIsInternal = false; } else { mEventIsInternal = true; - mEvent->mTime = PR_Now(); } } diff --git a/dom/events/ClipboardEvent.cpp b/dom/events/ClipboardEvent.cpp index 38bca006112f..e678f7c9fd56 100644 --- a/dom/events/ClipboardEvent.cpp +++ b/dom/events/ClipboardEvent.cpp @@ -20,7 +20,6 @@ ClipboardEvent::ClipboardEvent(EventTarget* aOwner, nsPresContext* aPresContext, mEventIsInternal = false; } else { mEventIsInternal = true; - mEvent->mTime = PR_Now(); } } diff --git a/dom/events/CommandEvent.cpp b/dom/events/CommandEvent.cpp index 17db047b6265..b048a959f8d7 100644 --- a/dom/events/CommandEvent.cpp +++ b/dom/events/CommandEvent.cpp @@ -13,7 +13,6 @@ namespace mozilla::dom { CommandEvent::CommandEvent(EventTarget* aOwner, nsPresContext* aPresContext, WidgetCommandEvent* aEvent) : Event(aOwner, aPresContext, aEvent ? aEvent : new WidgetCommandEvent()) { - mEvent->mTime = PR_Now(); if (aEvent) { mEventIsInternal = false; } else { diff --git a/dom/events/CompositionEvent.cpp b/dom/events/CompositionEvent.cpp index 826e420b55ab..7e52b9e1615c 100644 --- a/dom/events/CompositionEvent.cpp +++ b/dom/events/CompositionEvent.cpp @@ -22,7 +22,6 @@ CompositionEvent::CompositionEvent(EventTarget* aOwner, mEventIsInternal = false; } else { mEventIsInternal = true; - mEvent->mTime = PR_Now(); // XXX compositionstart is cancelable in draft of DOM3 Events. // However, it doesn't make sence for us, we cannot cancel composition diff --git a/dom/events/DeviceMotionEvent.cpp b/dom/events/DeviceMotionEvent.cpp index 11808ac4cfad..73fcc308673b 100644 --- a/dom/events/DeviceMotionEvent.cpp +++ b/dom/events/DeviceMotionEvent.cpp @@ -54,8 +54,6 @@ void DeviceMotionEvent::InitDeviceMotionEvent( this, aRotationRate.mAlpha, aRotationRate.mBeta, aRotationRate.mGamma); mInterval = aInterval; if (!aTimeStamp.IsNull()) { - mEvent->mTime = aTimeStamp.Value(); - static mozilla::TimeStamp sInitialNow = mozilla::TimeStamp::Now(); static uint64_t sInitialEventTime = aTimeStamp.Value(); mEvent->mTimeStamp = diff --git a/dom/events/DragEvent.cpp b/dom/events/DragEvent.cpp index 37d6a9df75f0..aa576e2f8e9f 100644 --- a/dom/events/DragEvent.cpp +++ b/dom/events/DragEvent.cpp @@ -21,7 +21,6 @@ DragEvent::DragEvent(EventTarget* aOwner, nsPresContext* aPresContext, mEventIsInternal = false; } else { mEventIsInternal = true; - mEvent->mTime = PR_Now(); mEvent->mRefPoint = LayoutDeviceIntPoint(0, 0); mEvent->AsMouseEvent()->mInputSource = MouseEvent_Binding::MOZ_SOURCE_UNKNOWN; diff --git a/dom/events/Event.cpp b/dom/events/Event.cpp index f96bafa3b5f9..1ba37f0d8233 100644 --- a/dom/events/Event.cpp +++ b/dom/events/Event.cpp @@ -95,7 +95,6 @@ void Event::ConstructorInit(EventTarget* aOwner, nsPresContext* aPresContext, } */ mEvent = new WidgetEvent(false, eVoidEvent); - mEvent->mTime = PR_Now(); } InitPresContextData(aPresContext); diff --git a/dom/events/EventStateManager.cpp b/dom/events/EventStateManager.cpp index 0d0fcf6f0c5e..5d619b9ac9dc 100644 --- a/dom/events/EventStateManager.cpp +++ b/dom/events/EventStateManager.cpp @@ -2641,7 +2641,6 @@ void EventStateManager::SendLineScrollEvent(nsIFrame* aTargetFrame, event.mFlags.mDefaultPrevented = aState.mDefaultPrevented; event.mFlags.mDefaultPreventedByContent = aState.mDefaultPreventedByContent; event.mRefPoint = aEvent->mRefPoint; - event.mTime = aEvent->mTime; event.mTimeStamp = aEvent->mTimeStamp; event.mModifiers = aEvent->mModifiers; event.mButtons = aEvent->mButtons; @@ -2680,7 +2679,6 @@ void EventStateManager::SendPixelScrollEvent(nsIFrame* aTargetFrame, event.mFlags.mDefaultPrevented = aState.mDefaultPrevented; event.mFlags.mDefaultPreventedByContent = aState.mDefaultPreventedByContent; event.mRefPoint = aEvent->mRefPoint; - event.mTime = aEvent->mTime; event.mTimeStamp = aEvent->mTimeStamp; event.mModifiers = aEvent->mModifiers; event.mButtons = aEvent->mButtons; @@ -5276,7 +5274,6 @@ nsresult EventStateManager::InitAndDispatchClickEvent( event.mClickCount = aMouseUpEvent->mClickCount; event.mModifiers = aMouseUpEvent->mModifiers; event.mButtons = aMouseUpEvent->mButtons; - event.mTime = aMouseUpEvent->mTime; event.mTimeStamp = aMouseUpEvent->mTimeStamp; event.mFlags.mOnlyChromeDispatch = aNoContentDispatch && !aMouseUpEvent->mUseLegacyNonPrimaryDispatch; diff --git a/dom/events/FocusEvent.cpp b/dom/events/FocusEvent.cpp index 1e801cf4ff05..e00ce5ae327a 100644 --- a/dom/events/FocusEvent.cpp +++ b/dom/events/FocusEvent.cpp @@ -18,7 +18,6 @@ FocusEvent::FocusEvent(EventTarget* aOwner, nsPresContext* aPresContext, mEventIsInternal = false; } else { mEventIsInternal = true; - mEvent->mTime = PR_Now(); } } diff --git a/dom/events/InputEvent.cpp b/dom/events/InputEvent.cpp index 9fb87936dea1..45754b1d820d 100644 --- a/dom/events/InputEvent.cpp +++ b/dom/events/InputEvent.cpp @@ -23,7 +23,6 @@ InputEvent::InputEvent(EventTarget* aOwner, nsPresContext* aPresContext, mEventIsInternal = false; } else { mEventIsInternal = true; - mEvent->mTime = PR_Now(); } } diff --git a/dom/events/KeyboardEvent.cpp b/dom/events/KeyboardEvent.cpp index 08355c67782e..40e87d485192 100644 --- a/dom/events/KeyboardEvent.cpp +++ b/dom/events/KeyboardEvent.cpp @@ -28,7 +28,6 @@ KeyboardEvent::KeyboardEvent(EventTarget* aOwner, nsPresContext* aPresContext, mEventIsInternal = false; } else { mEventIsInternal = true; - mEvent->mTime = PR_Now(); mEvent->AsKeyboardEvent()->mKeyNameIndex = KEY_NAME_INDEX_USE_STRING; } } diff --git a/dom/events/MouseEvent.cpp b/dom/events/MouseEvent.cpp index c18aea91f629..66a266a44374 100644 --- a/dom/events/MouseEvent.cpp +++ b/dom/events/MouseEvent.cpp @@ -28,7 +28,6 @@ MouseEvent::MouseEvent(EventTarget* aOwner, nsPresContext* aPresContext, mEventIsInternal = false; } else { mEventIsInternal = true; - mEvent->mTime = PR_Now(); mEvent->mRefPoint = LayoutDeviceIntPoint(0, 0); mouseEvent->mInputSource = MouseEvent_Binding::MOZ_SOURCE_UNKNOWN; } diff --git a/dom/events/MouseScrollEvent.cpp b/dom/events/MouseScrollEvent.cpp index cf98f4e5a127..58bc0b2dbb77 100644 --- a/dom/events/MouseScrollEvent.cpp +++ b/dom/events/MouseScrollEvent.cpp @@ -22,7 +22,6 @@ MouseScrollEvent::MouseScrollEvent(EventTarget* aOwner, mEventIsInternal = false; } else { mEventIsInternal = true; - mEvent->mTime = PR_Now(); mEvent->mRefPoint = LayoutDeviceIntPoint(0, 0); static_cast(mEvent)->mInputSource = MouseEvent_Binding::MOZ_SOURCE_UNKNOWN; diff --git a/dom/events/PointerEvent.cpp b/dom/events/PointerEvent.cpp index b3039c516cc2..19b301621cb4 100644 --- a/dom/events/PointerEvent.cpp +++ b/dom/events/PointerEvent.cpp @@ -29,7 +29,6 @@ PointerEvent::PointerEvent(EventTarget* aOwner, nsPresContext* aPresContext, mEventIsInternal = false; } else { mEventIsInternal = true; - mEvent->mTime = PR_Now(); mEvent->mRefPoint = LayoutDeviceIntPoint(0, 0); mouseEvent->mInputSource = MouseEvent_Binding::MOZ_SOURCE_UNKNOWN; } diff --git a/dom/events/PointerEventHandler.cpp b/dom/events/PointerEventHandler.cpp index f2a20fd5159b..cb25e6a997b2 100644 --- a/dom/events/PointerEventHandler.cpp +++ b/dom/events/PointerEventHandler.cpp @@ -552,7 +552,6 @@ void PointerEventHandler::InitPointerEventFromTouch( aPointerEvent.tiltX = aTouch.tiltX; aPointerEvent.tiltY = aTouch.tiltY; aPointerEvent.twist = aTouch.twist; - aPointerEvent.mTime = aTouchEvent.mTime; aPointerEvent.mTimeStamp = aTouchEvent.mTimeStamp; aPointerEvent.mFlags = aTouchEvent.mFlags; aPointerEvent.mButton = button; diff --git a/dom/events/SimpleGestureEvent.cpp b/dom/events/SimpleGestureEvent.cpp index 402b1f669128..3395cb7dbbb2 100644 --- a/dom/events/SimpleGestureEvent.cpp +++ b/dom/events/SimpleGestureEvent.cpp @@ -25,7 +25,6 @@ SimpleGestureEvent::SimpleGestureEvent(EventTarget* aOwner, mEventIsInternal = false; } else { mEventIsInternal = true; - mEvent->mTime = PR_Now(); mEvent->mRefPoint = LayoutDeviceIntPoint(0, 0); static_cast(mEvent)->mInputSource = MouseEvent_Binding::MOZ_SOURCE_UNKNOWN; diff --git a/dom/events/TextComposition.cpp b/dom/events/TextComposition.cpp index 3b4fb7743528..12a375bdb20e 100644 --- a/dom/events/TextComposition.cpp +++ b/dom/events/TextComposition.cpp @@ -202,7 +202,6 @@ BaseEventFlags TextComposition::CloneAndDispatchAs( WidgetCompositionEvent compositionEvent(aCompositionEvent->IsTrusted(), aMessage, aCompositionEvent->mWidget); - compositionEvent.mTime = aCompositionEvent->mTime; compositionEvent.mTimeStamp = aCompositionEvent->mTimeStamp; compositionEvent.mData = aCompositionEvent->mData; compositionEvent.mNativeIMEContext = aCompositionEvent->mNativeIMEContext; diff --git a/dom/events/TouchEvent.cpp b/dom/events/TouchEvent.cpp index c48a0da60a33..24068703be62 100644 --- a/dom/events/TouchEvent.cpp +++ b/dom/events/TouchEvent.cpp @@ -61,7 +61,6 @@ TouchEvent::TouchEvent(EventTarget* aOwner, nsPresContext* aPresContext, } } else { mEventIsInternal = true; - mEvent->mTime = PR_Now(); } } diff --git a/dom/events/TransitionEvent.cpp b/dom/events/TransitionEvent.cpp index 67b0071c2b3d..696f54ce496d 100644 --- a/dom/events/TransitionEvent.cpp +++ b/dom/events/TransitionEvent.cpp @@ -19,7 +19,6 @@ TransitionEvent::TransitionEvent(EventTarget* aOwner, mEventIsInternal = false; } else { mEventIsInternal = true; - mEvent->mTime = PR_Now(); } } diff --git a/dom/events/UIEvent.cpp b/dom/events/UIEvent.cpp index 0309f6e60ac3..2f4dd914b883 100644 --- a/dom/events/UIEvent.cpp +++ b/dom/events/UIEvent.cpp @@ -40,7 +40,6 @@ UIEvent::UIEvent(EventTarget* aOwner, nsPresContext* aPresContext, mEventIsInternal = false; } else { mEventIsInternal = true; - mEvent->mTime = PR_Now(); } // Fill mDetail and mView according to the mEvent (widget-generated diff --git a/dom/events/WheelEvent.cpp b/dom/events/WheelEvent.cpp index bab045b2f6b4..56cfe113ea5d 100644 --- a/dom/events/WheelEvent.cpp +++ b/dom/events/WheelEvent.cpp @@ -29,7 +29,6 @@ WheelEvent::WheelEvent(EventTarget* aOwner, nsPresContext* aPresContext, } } else { mEventIsInternal = true; - mEvent->mTime = PR_Now(); mEvent->mRefPoint = LayoutDeviceIntPoint(0, 0); mEvent->AsWheelEvent()->mInputSource = MouseEvent_Binding::MOZ_SOURCE_UNKNOWN; diff --git a/dom/events/XULCommandEvent.cpp b/dom/events/XULCommandEvent.cpp index ffbc64251280..b561cd3fb698 100644 --- a/dom/events/XULCommandEvent.cpp +++ b/dom/events/XULCommandEvent.cpp @@ -20,7 +20,6 @@ XULCommandEvent::XULCommandEvent(EventTarget* aOwner, mEventIsInternal = false; } else { mEventIsInternal = true; - mEvent->mTime = PR_Now(); } } diff --git a/gfx/layers/apz/src/APZCTreeManager.cpp b/gfx/layers/apz/src/APZCTreeManager.cpp index 552fd946554f..00cc62152b12 100644 --- a/gfx/layers/apz/src/APZCTreeManager.cpp +++ b/gfx/layers/apz/src/APZCTreeManager.cpp @@ -1612,9 +1612,9 @@ APZEventResult APZCTreeManager::ReceiveInputEvent( // becasue we might no longer receive any events which will be // handled by the APZC. PanGestureInput panInterrupted( - PanGestureInput::PANGESTURE_INTERRUPTED, panInput.mTime, - panInput.mTimeStamp, panInput.mPanStartPoint, - panInput.mPanDisplacement, panInput.modifiers); + PanGestureInput::PANGESTURE_INTERRUPTED, panInput.mTimeStamp, + panInput.mPanStartPoint, panInput.mPanDisplacement, + panInput.modifiers); Unused << mInputQueue->ReceiveInputEvent( state.mHit.mTargetApzc, TargetConfirmationFlags{state.mHit.mHitResult}, panInterrupted); @@ -2128,7 +2128,6 @@ APZEventResult APZCTreeManager::ProcessTouchInputForScrollbarDrag( dom::MouseEvent_Binding::MOZ_SOURCE_TOUCH, MouseButtonsFlag::ePrimaryFlag, aTouchInput.mTouches[0].mScreenPoint, - aTouchInput.mTime, aTouchInput.mTimeStamp, aTouchInput.modifiers}; mouseInput.mHandledByAPZ = true; @@ -2240,7 +2239,6 @@ void APZCTreeManager::SynthesizePinchGestureFromMouseWheel( PinchGestureInput pinchStart{PinchGestureInput::PINCHGESTURE_START, PinchGestureInput::MOUSEWHEEL, - aWheelInput.mTime, aWheelInput.mTimeStamp, ExternalPoint(0, 0), focusPoint, @@ -2249,7 +2247,6 @@ void APZCTreeManager::SynthesizePinchGestureFromMouseWheel( aWheelInput.modifiers}; PinchGestureInput pinchScale1{PinchGestureInput::PINCHGESTURE_SCALE, PinchGestureInput::MOUSEWHEEL, - aWheelInput.mTime, aWheelInput.mTimeStamp, ExternalPoint(0, 0), focusPoint, @@ -2258,7 +2255,6 @@ void APZCTreeManager::SynthesizePinchGestureFromMouseWheel( aWheelInput.modifiers}; PinchGestureInput pinchScale2{PinchGestureInput::PINCHGESTURE_SCALE, PinchGestureInput::MOUSEWHEEL, - aWheelInput.mTime, aWheelInput.mTimeStamp, ExternalPoint(0, 0), focusPoint, @@ -2267,7 +2263,6 @@ void APZCTreeManager::SynthesizePinchGestureFromMouseWheel( aWheelInput.modifiers}; PinchGestureInput pinchEnd{PinchGestureInput::PINCHGESTURE_END, PinchGestureInput::MOUSEWHEEL, - aWheelInput.mTime, aWheelInput.mTimeStamp, ExternalPoint(0, 0), focusPoint, diff --git a/gfx/layers/apz/src/APZInputBridge.cpp b/gfx/layers/apz/src/APZInputBridge.cpp index 2310ca79dfd4..bb5b42d2622b 100644 --- a/gfx/layers/apz/src/APZInputBridge.cpp +++ b/gfx/layers/apz/src/APZInputBridge.cpp @@ -255,7 +255,7 @@ APZEventResult APZInputBridge::ReceiveInputEvent( if (wheelEvent.mDeltaX || wheelEvent.mDeltaY) { ScreenPoint origin(wheelEvent.mRefPoint.x, wheelEvent.mRefPoint.y); ScrollWheelInput input( - wheelEvent.mTime, wheelEvent.mTimeStamp, 0, scrollMode, + wheelEvent.mTimeStamp, 0, scrollMode, ScrollWheelInput::DeltaTypeForDeltaMode(wheelEvent.mDeltaMode), origin, wheelEvent.mDeltaX, wheelEvent.mDeltaY, wheelEvent.mAllowToOverrideSystemScrollSpeed, strategy); diff --git a/gfx/layers/apz/src/GestureEventListener.cpp b/gfx/layers/apz/src/GestureEventListener.cpp index c21dc11ba4e9..b54674b593cb 100644 --- a/gfx/layers/apz/src/GestureEventListener.cpp +++ b/gfx/layers/apz/src/GestureEventListener.cpp @@ -63,7 +63,7 @@ ScreenCoord GestureEventListener::GetYSpanFromGestureStartPoint() { static TapGestureInput CreateTapEvent(const MultiTouchInput& aTouch, TapGestureInput::TapGestureType aType) { - return TapGestureInput(aType, aTouch.mTime, aTouch.mTimeStamp, + return TapGestureInput(aType, aTouch.mTimeStamp, aTouch.mTouches[0].mScreenPoint, aTouch.modifiers); } @@ -327,9 +327,8 @@ nsEventStatus GestureEventListener::HandleInputTouchMove() { PinchGestureInput pinchEvent( PinchGestureInput::PINCHGESTURE_START, PinchGestureInput::ONE_TOUCH, - mLastTouchInput.mTime, mLastTouchInput.mTimeStamp, - mLastTouchInput.mScreenOffset, currentFocus, currentSpan, - currentSpan, mLastTouchInput.modifiers); + mLastTouchInput.mTimeStamp, mLastTouchInput.mScreenOffset, + currentFocus, currentSpan, currentSpan, mLastTouchInput.modifiers); rv = mAsyncPanZoomController->HandleGestureEvent(pinchEvent); @@ -357,9 +356,8 @@ nsEventStatus GestureEventListener::HandleInputTouchMove() { SetState(GESTURE_PINCH); PinchGestureInput pinchEvent( PinchGestureInput::PINCHGESTURE_START, PinchGestureInput::TOUCH, - mLastTouchInput.mTime, mLastTouchInput.mTimeStamp, - mLastTouchInput.mScreenOffset, currentFocus, currentSpan, - currentSpan, mLastTouchInput.modifiers); + mLastTouchInput.mTimeStamp, mLastTouchInput.mScreenOffset, + currentFocus, currentSpan, currentSpan, mLastTouchInput.modifiers); rv = mAsyncPanZoomController->HandleGestureEvent(pinchEvent); } else { @@ -386,9 +384,9 @@ nsEventStatus GestureEventListener::HandleInputTouchMove() { PinchGestureInput pinchEvent( PinchGestureInput::PINCHGESTURE_SCALE, PinchGestureInput::TOUCH, - mLastTouchInput.mTime, mLastTouchInput.mTimeStamp, - mLastTouchInput.mScreenOffset, GetCurrentFocus(mLastTouchInput), - currentSpan, mPreviousSpan, mLastTouchInput.modifiers); + mLastTouchInput.mTimeStamp, mLastTouchInput.mScreenOffset, + GetCurrentFocus(mLastTouchInput), currentSpan, mPreviousSpan, + mLastTouchInput.modifiers); rv = mAsyncPanZoomController->HandleGestureEvent(pinchEvent); mPreviousSpan = currentSpan; @@ -409,9 +407,9 @@ nsEventStatus GestureEventListener::HandleInputTouchMove() { PinchGestureInput pinchEvent( PinchGestureInput::PINCHGESTURE_SCALE, PinchGestureInput::ONE_TOUCH, - mLastTouchInput.mTime, mLastTouchInput.mTimeStamp, - mLastTouchInput.mScreenOffset, currentFocus, effectiveSpan, - mPreviousSpan, mLastTouchInput.modifiers); + mLastTouchInput.mTimeStamp, mLastTouchInput.mScreenOffset, + currentFocus, effectiveSpan, mPreviousSpan, + mLastTouchInput.modifiers); rv = mAsyncPanZoomController->HandleGestureEvent(pinchEvent); mPreviousSpan = effectiveSpan; @@ -495,10 +493,10 @@ nsEventStatus GestureEventListener::HandleInputTouchEnd() { type = PinchGestureInput::PINCHGESTURE_FINGERLIFTED; point = mTouches[0].mScreenPoint; } - PinchGestureInput pinchEvent( - type, PinchGestureInput::TOUCH, mLastTouchInput.mTime, - mLastTouchInput.mTimeStamp, mLastTouchInput.mScreenOffset, point, - 1.0f, 1.0f, mLastTouchInput.modifiers); + PinchGestureInput pinchEvent(type, PinchGestureInput::TOUCH, + mLastTouchInput.mTimeStamp, + mLastTouchInput.mScreenOffset, point, 1.0f, + 1.0f, mLastTouchInput.modifiers); mAsyncPanZoomController->HandleGestureEvent(pinchEvent); } @@ -510,9 +508,8 @@ nsEventStatus GestureEventListener::HandleInputTouchEnd() { SetState(GESTURE_NONE); PinchGestureInput pinchEvent( PinchGestureInput::PINCHGESTURE_END, PinchGestureInput::ONE_TOUCH, - mLastTouchInput.mTime, mLastTouchInput.mTimeStamp, - mLastTouchInput.mScreenOffset, ScreenPoint(), 1.0f, 1.0f, - mLastTouchInput.modifiers); + mLastTouchInput.mTimeStamp, mLastTouchInput.mScreenOffset, + ScreenPoint(), 1.0f, 1.0f, mLastTouchInput.modifiers); mAsyncPanZoomController->HandleGestureEvent(pinchEvent); rv = nsEventStatus_eConsumeNoDefault; diff --git a/gfx/layers/apz/test/gtest/APZTestCommon.h b/gfx/layers/apz/test/gtest/APZTestCommon.h index 15e70f7dba32..de47d0d6a542 100644 --- a/gfx/layers/apz/test/gtest/APZTestCommon.h +++ b/gfx/layers/apz/test/gtest/APZTestCommon.h @@ -73,9 +73,9 @@ inline PinchGestureInput CreatePinchGestureInput( PinchGestureInput::PinchGestureType aType, const ScreenPoint& aFocus, float aCurrentSpan, float aPreviousSpan, TimeStamp timestamp) { ParentLayerPoint localFocus(aFocus.x, aFocus.y); - PinchGestureInput result( - aType, PinchGestureInput::UNKNOWN, MillisecondsSinceStartup(timestamp), - timestamp, ExternalPoint(0, 0), aFocus, aCurrentSpan, aPreviousSpan, 0); + PinchGestureInput result(aType, PinchGestureInput::UNKNOWN, timestamp, + ExternalPoint(0, 0), aFocus, aCurrentSpan, + aPreviousSpan, 0); return result; } diff --git a/gfx/layers/apz/test/gtest/InputUtils.h b/gfx/layers/apz/test/gtest/InputUtils.h index 58a5255a8e60..a654369a610a 100644 --- a/gfx/layers/apz/test/gtest/InputUtils.h +++ b/gfx/layers/apz/test/gtest/InputUtils.h @@ -77,8 +77,7 @@ template APZEventResult Wheel(const RefPtr& aTarget, const ScreenIntPoint& aPoint, const ScreenPoint& aDelta, TimeStamp aTime) { - ScrollWheelInput input(MillisecondsSinceStartup(aTime), aTime, 0, - ScrollWheelInput::SCROLLMODE_INSTANT, + ScrollWheelInput input(aTime, 0, ScrollWheelInput::SCROLLMODE_INSTANT, ScrollWheelInput::SCROLLDELTA_PIXEL, aPoint, aDelta.x, aDelta.y, false, WheelDeltaAdjustmentStrategy::eNone); return aTarget->ReceiveInputEvent(input); @@ -88,8 +87,7 @@ template APZEventResult SmoothWheel(const RefPtr& aTarget, const ScreenIntPoint& aPoint, const ScreenPoint& aDelta, TimeStamp aTime) { - ScrollWheelInput input(MillisecondsSinceStartup(aTime), aTime, 0, - ScrollWheelInput::SCROLLMODE_SMOOTH, + ScrollWheelInput input(aTime, 0, ScrollWheelInput::SCROLLMODE_SMOOTH, ScrollWheelInput::SCROLLDELTA_LINE, aPoint, aDelta.x, aDelta.y, false, WheelDeltaAdjustmentStrategy::eNone); return aTarget->ReceiveInputEvent(input); @@ -99,8 +97,8 @@ template APZEventResult MouseDown(const RefPtr& aTarget, const ScreenIntPoint& aPoint, TimeStamp aTime) { MouseInput input(MouseInput::MOUSE_DOWN, - MouseInput::ButtonType::PRIMARY_BUTTON, 0, 0, aPoint, - MillisecondsSinceStartup(aTime), aTime, 0); + MouseInput::ButtonType::PRIMARY_BUTTON, 0, 0, aPoint, aTime, + 0); return aTarget->ReceiveInputEvent(input); } @@ -108,8 +106,8 @@ template APZEventResult MouseMove(const RefPtr& aTarget, const ScreenIntPoint& aPoint, TimeStamp aTime) { MouseInput input(MouseInput::MOUSE_MOVE, - MouseInput::ButtonType::PRIMARY_BUTTON, 0, 0, aPoint, - MillisecondsSinceStartup(aTime), aTime, 0); + MouseInput::ButtonType::PRIMARY_BUTTON, 0, 0, aPoint, aTime, + 0); return aTarget->ReceiveInputEvent(input); } @@ -117,7 +115,7 @@ template APZEventResult MouseUp(const RefPtr& aTarget, const ScreenIntPoint& aPoint, TimeStamp aTime) { MouseInput input(MouseInput::MOUSE_UP, MouseInput::ButtonType::PRIMARY_BUTTON, - 0, 0, aPoint, MillisecondsSinceStartup(aTime), aTime, 0); + 0, 0, aPoint, aTime, 0); return aTarget->ReceiveInputEvent(input); } @@ -128,8 +126,7 @@ APZEventResult PanGesture(PanGestureInput::PanGestureType aType, const ScreenPoint& aDelta, TimeStamp aTime, Modifiers aModifiers = MODIFIER_NONE, bool aSimulateMomentum = false) { - PanGestureInput input(aType, MillisecondsSinceStartup(aTime), aTime, aPoint, - aDelta, aModifiers); + PanGestureInput input(aType, aTime, aPoint, aDelta, aModifiers); input.mSimulateMomentum = aSimulateMomentum; if constexpr (std::is_same_v) { // In the case of TestAsyncPanZoomController we know for sure that the diff --git a/gfx/layers/apz/test/gtest/TestHitTesting.cpp b/gfx/layers/apz/test/gtest/TestHitTesting.cpp index 1ee6a667d168..04f1e40f5d95 100644 --- a/gfx/layers/apz/test/gtest/TestHitTesting.cpp +++ b/gfx/layers/apz/test/gtest/TestHitTesting.cpp @@ -248,8 +248,7 @@ TEST_F(APZHitTestingTester, TestRepaintFlushOnWheelEvents) { EXPECT_CALL(*mcc, RequestContentRepaint(_)).Times(AtLeast(3)); ScreenPoint origin(100, 50); for (int i = 0; i < 3; i++) { - ScrollWheelInput swi(MillisecondsSinceStartup(mcc->Time()), mcc->Time(), 0, - ScrollWheelInput::SCROLLMODE_INSTANT, + ScrollWheelInput swi(mcc->Time(), 0, ScrollWheelInput::SCROLLMODE_INSTANT, ScrollWheelInput::SCROLLDELTA_PIXEL, origin, 0, 10, false, WheelDeltaAdjustmentStrategy::eNone); EXPECT_EQ(nsEventStatus_eConsumeDoDefault, @@ -276,8 +275,7 @@ TEST_F(APZHitTestingTester, TestForceDisableApz) { TestAsyncPanZoomController* apzcroot = ApzcOf(root); ScreenPoint origin(100, 50); - ScrollWheelInput swi(MillisecondsSinceStartup(mcc->Time()), mcc->Time(), 0, - ScrollWheelInput::SCROLLMODE_INSTANT, + ScrollWheelInput swi(mcc->Time(), 0, ScrollWheelInput::SCROLLMODE_INSTANT, ScrollWheelInput::SCROLLDELTA_PIXEL, origin, 0, 10, false, WheelDeltaAdjustmentStrategy::eNone); EXPECT_EQ(nsEventStatus_eConsumeDoDefault, @@ -307,8 +305,7 @@ TEST_F(APZHitTestingTester, TestForceDisableApz) { // With untransforming events we should get normal behaviour (in this case, // no noticeable untransform, because the repaint request already got // flushed). - swi = ScrollWheelInput(MillisecondsSinceStartup(mcc->Time()), mcc->Time(), 0, - ScrollWheelInput::SCROLLMODE_INSTANT, + swi = ScrollWheelInput(mcc->Time(), 0, ScrollWheelInput::SCROLLMODE_INSTANT, ScrollWheelInput::SCROLLDELTA_PIXEL, origin, 0, 0, false, WheelDeltaAdjustmentStrategy::eNone); EXPECT_EQ(nsEventStatus_eConsumeDoDefault, diff --git a/gfx/layers/apz/test/gtest/TestOverscroll.cpp b/gfx/layers/apz/test/gtest/TestOverscroll.cpp index a11015916d8d..10327871fb4b 100644 --- a/gfx/layers/apz/test/gtest/TestOverscroll.cpp +++ b/gfx/layers/apz/test/gtest/TestOverscroll.cpp @@ -1280,9 +1280,9 @@ TEST_F(APZCOverscrollTester, OverscrollByPanGesturesInterruptedByReflowZoom) { // A sanity check that pan gestures with ctrl modifier will not be handled by // APZ. - PanGestureInput panInput( - PanGestureInput::PANGESTURE_START, MillisecondsSinceStartup(mcc->Time()), - mcc->Time(), ScreenIntPoint(5, 5), ScreenPoint(0, -2), MODIFIER_CONTROL); + PanGestureInput panInput(PanGestureInput::PANGESTURE_START, mcc->Time(), + ScreenIntPoint(5, 5), ScreenPoint(0, -2), + MODIFIER_CONTROL); WidgetWheelEvent wheelEvent = panInput.ToWidgetEvent(nullptr); EXPECT_FALSE(APZInputBridge::ActionForWheelEvent(&wheelEvent).isSome()); diff --git a/gfx/layers/apz/test/gtest/TestScrollHandoff.cpp b/gfx/layers/apz/test/gtest/TestScrollHandoff.cpp index 7fc54d536378..8f497dabe642 100644 --- a/gfx/layers/apz/test/gtest/TestScrollHandoff.cpp +++ b/gfx/layers/apz/test/gtest/TestScrollHandoff.cpp @@ -745,8 +745,7 @@ TEST_F(APZScrollHandoffTesterMock, WheelHandoffNonscrollable) { mcc->AdvanceByMillis(100); MouseInput mouseInput(MouseInput::MOUSE_MOVE, MouseInput::ButtonType::PRIMARY_BUTTON, 0, 0, - scrollableLocation, - MillisecondsSinceStartup(mcc->Time()), mcc->Time(), 0); + scrollableLocation, mcc->Time(), 0); WidgetMouseEvent mouseEvent = mouseInput.ToWidgetEvent(nullptr); QueueMockHitResult(ScrollableLayerGuid::START_SCROLL_ID + 1); ((APZInputBridge*)manager.get())->ReceiveInputEvent(mouseEvent); diff --git a/gfx/layers/apz/test/gtest/TestTreeManager.cpp b/gfx/layers/apz/test/gtest/TestTreeManager.cpp index 4ab559ffa38e..963a400cb8e0 100644 --- a/gfx/layers/apz/test/gtest/TestTreeManager.cpp +++ b/gfx/layers/apz/test/gtest/TestTreeManager.cpp @@ -219,8 +219,7 @@ TEST_F(APZCTreeManagerGenericTesterMock, Bug1198900) { UpdateHitTestingTree(); ScreenPoint origin(100, 50); - ScrollWheelInput swi(MillisecondsSinceStartup(mcc->Time()), mcc->Time(), 0, - ScrollWheelInput::SCROLLMODE_INSTANT, + ScrollWheelInput swi(mcc->Time(), 0, ScrollWheelInput::SCROLLMODE_INSTANT, ScrollWheelInput::SCROLLDELTA_PIXEL, origin, 0, 10, false, WheelDeltaAdjustmentStrategy::eNone); uint64_t blockId; diff --git a/gfx/layers/apz/util/APZCCallbackHelper.cpp b/gfx/layers/apz/util/APZCCallbackHelper.cpp index 38dcf697d2ef..8aeee6f24551 100644 --- a/gfx/layers/apz/util/APZCCallbackHelper.cpp +++ b/gfx/layers/apz/util/APZCCallbackHelper.cpp @@ -512,15 +512,14 @@ nsEventStatus APZCCallbackHelper::DispatchWidgetEvent(WidgetGUIEvent& aEvent) { } nsEventStatus APZCCallbackHelper::DispatchSynthesizedMouseEvent( - EventMessage aMsg, uint64_t aTime, const LayoutDevicePoint& aRefPoint, - Modifiers aModifiers, int32_t aClickCount, nsIWidget* aWidget) { + EventMessage aMsg, const LayoutDevicePoint& aRefPoint, Modifiers aModifiers, + int32_t aClickCount, nsIWidget* aWidget) { MOZ_ASSERT(aMsg == eMouseMove || aMsg == eMouseDown || aMsg == eMouseUp || aMsg == eMouseLongTap); WidgetMouseEvent event(true, aMsg, aWidget, WidgetMouseEvent::eReal, WidgetMouseEvent::eNormal); event.mRefPoint = LayoutDeviceIntPoint::Truncate(aRefPoint.x, aRefPoint.y); - event.mTime = aTime; event.mButton = MouseButton::ePrimary; event.mButtons |= MouseButtonsFlag::ePrimaryFlag; event.mInputSource = dom::MouseEvent_Binding::MOZ_SOURCE_TOUCH; @@ -563,12 +562,11 @@ void APZCCallbackHelper::FireSingleTapEvent(const LayoutDevicePoint& aPoint, } APZCCH_LOG("Dispatching single-tap component events to %s\n", ToString(aPoint).c_str()); - int time = 0; - DispatchSynthesizedMouseEvent(eMouseMove, time, aPoint, aModifiers, - aClickCount, aWidget); - DispatchSynthesizedMouseEvent(eMouseDown, time, aPoint, aModifiers, - aClickCount, aWidget); - DispatchSynthesizedMouseEvent(eMouseUp, time, aPoint, aModifiers, aClickCount, + DispatchSynthesizedMouseEvent(eMouseMove, aPoint, aModifiers, aClickCount, + aWidget); + DispatchSynthesizedMouseEvent(eMouseDown, aPoint, aModifiers, aClickCount, + aWidget); + DispatchSynthesizedMouseEvent(eMouseUp, aPoint, aModifiers, aClickCount, aWidget); } diff --git a/gfx/layers/apz/util/APZCCallbackHelper.h b/gfx/layers/apz/util/APZCCallbackHelper.h index 2048bdde1502..7b1f7cb88beb 100644 --- a/gfx/layers/apz/util/APZCCallbackHelper.h +++ b/gfx/layers/apz/util/APZCCallbackHelper.h @@ -105,7 +105,7 @@ class APZCCallbackHelper { /* Synthesize a mouse event with the given parameters, and dispatch it * via the given widget. */ static nsEventStatus DispatchSynthesizedMouseEvent( - EventMessage aMsg, uint64_t aTime, const LayoutDevicePoint& aRefPoint, + EventMessage aMsg, const LayoutDevicePoint& aRefPoint, Modifiers aModifiers, int32_t aClickCount, nsIWidget* aWidget); /* Dispatch a mouse event with the given parameters. diff --git a/gfx/layers/apz/util/APZEventState.cpp b/gfx/layers/apz/util/APZEventState.cpp index 63d497f2c25b..82b48a97ada4 100644 --- a/gfx/layers/apz/util/APZEventState.cpp +++ b/gfx/layers/apz/util/APZEventState.cpp @@ -213,8 +213,7 @@ PreventDefaultResult APZEventState::FireContextmenuEvents( // Note that we don't need to check whether mousemove event is consumed or // not because Chrome also ignores the result. APZCCallbackHelper::DispatchSynthesizedMouseEvent( - eMouseMove, 0 /* time */, aPoint * aScale, aModifiers, 0 /* clickCount */, - aWidget); + eMouseMove, aPoint * aScale, aModifiers, 0 /* clickCount */, aWidget); // Converting the modifiers to DOM format for the DispatchMouseEvent call // is the most useless thing ever because nsDOMWindowUtils::SendMouseEvent @@ -238,7 +237,7 @@ PreventDefaultResult APZEventState::FireContextmenuEvents( } else { // If the contextmenu wasn't consumed, fire the eMouseLongTap event. nsEventStatus status = APZCCallbackHelper::DispatchSynthesizedMouseEvent( - eMouseLongTap, /*time*/ 0, aPoint * aScale, aModifiers, + eMouseLongTap, aPoint * aScale, aModifiers, /*clickCount*/ 1, aWidget); if (status == nsEventStatus_eConsumeNoDefault) { // Assuming no JS actor listens eMouseLongTap events. @@ -275,8 +274,7 @@ void APZEventState::ProcessLongTap(PresShell* aPresShell, // at this time, because things like text selection or dragging may want // to know about it. nsEventStatus status = APZCCallbackHelper::DispatchSynthesizedMouseEvent( - eMouseLongTap, /*time*/ 0, aPoint * aScale, aModifiers, /*clickCount*/ 1, - widget); + eMouseLongTap, aPoint * aScale, aModifiers, /*clickCount*/ 1, widget); PreventDefaultResult preventDefaultResult = (status == nsEventStatus_eConsumeNoDefault) diff --git a/layout/base/PresShell.cpp b/layout/base/PresShell.cpp index 6ec7d1e1ebe1..66637f061381 100644 --- a/layout/base/PresShell.cpp +++ b/layout/base/PresShell.cpp @@ -5858,7 +5858,6 @@ void PresShell::ProcessSynthMouseMoveEvent(bool aFromScroll) { WidgetMouseEvent::eSynthesized); event.mRefPoint = LayoutDeviceIntPoint::FromAppUnitsToNearest(refpoint, viewAPD); - event.mTime = PR_IntervalNow(); // XXX set event.mModifiers ? // XXX mnakano I think that we should get the latest information from widget. diff --git a/layout/base/TouchManager.cpp b/layout/base/TouchManager.cpp index ee7d747626e4..ff6eecbaa891 100644 --- a/layout/base/TouchManager.cpp +++ b/layout/base/TouchManager.cpp @@ -72,7 +72,6 @@ void TouchManager::EvictTouchPoint(RefPtr& aTouch, nsCOMPtr widget = frame->GetView()->GetNearestWidget(&pt); if (widget) { WidgetTouchEvent event(true, eTouchEnd, widget); - event.mTime = PR_IntervalNow(); event.mTouches.AppendElement(aTouch); nsEventStatus status; widget->DispatchEvent(&event, status); diff --git a/layout/forms/HTMLSelectEventListener.cpp b/layout/forms/HTMLSelectEventListener.cpp index 317fdb8f7404..dffabe1bc745 100644 --- a/layout/forms/HTMLSelectEventListener.cpp +++ b/layout/forms/HTMLSelectEventListener.cpp @@ -53,7 +53,7 @@ static bool IsOptionInteractivelySelectable(HTMLSelectElement& aSelect, namespace mozilla { static StaticAutoPtr sIncrementalString; -static DOMTimeStamp gLastKeyTime = 0; +static TimeStamp gLastKeyTime; static uintptr_t sLastKeyListener = 0; static constexpr int32_t kNothingSelected = -1; @@ -72,6 +72,11 @@ class MOZ_RAII AutoIncrementalSearchHandler { if (sLastKeyListener != uintptr_t(&aListener)) { sLastKeyListener = uintptr_t(&aListener); GetIncrementalString().Truncate(); + // To make it easier to handle time comparisons in the other methods, + // initialize gLastKeyTime to a value in the past. + gLastKeyTime = TimeStamp::Now() - + TimeDuration::FromMilliseconds( + StaticPrefs::ui_menu_incremental_search_timeout() * 2); } } ~AutoIncrementalSearchHandler() { @@ -556,7 +561,7 @@ nsresult HTMLSelectEventListener::KeyPress(dom::Event* aKeyEvent) { // string we will use to find options and start searching at the current // keystroke. Otherwise, Truncate the string if it's been a long time // since our last keypress. - if (keyEvent->mTime - gLastKeyTime > + if ((keyEvent->mTimeStamp - gLastKeyTime).ToMilliseconds() > StaticPrefs::ui_menu_incremental_search_timeout()) { // If this is ' ' and we are at the beginning of the string, treat it as // "select this option" (bug 191543) @@ -572,7 +577,7 @@ nsresult HTMLSelectEventListener::KeyPress(dom::Event* aKeyEvent) { GetIncrementalString().Truncate(); } - gLastKeyTime = keyEvent->mTime; + gLastKeyTime = keyEvent->mTimeStamp; // Append this keystroke to the search string. char16_t uniChar = ToLowerCase(static_cast(keyEvent->mCharCode)); @@ -677,7 +682,7 @@ nsresult HTMLSelectEventListener::KeyDown(dom::Event* aKeyEvent) { dropDownMenuOnSpace = mIsCombobox && !mElement->OpenInParentProcess(); #endif bool withinIncrementalSearchTime = - keyEvent->mTime - gLastKeyTime <= + (keyEvent->mTimeStamp - gLastKeyTime).ToMilliseconds() <= StaticPrefs::ui_menu_incremental_search_timeout(); if ((dropDownMenuOnUpDown && (keyEvent->mKeyCode == NS_VK_UP || keyEvent->mKeyCode == NS_VK_DOWN)) || diff --git a/layout/xul/nsMenuFrame.cpp b/layout/xul/nsMenuFrame.cpp index c556e99798b2..67067cdd69a6 100644 --- a/layout/xul/nsMenuFrame.cpp +++ b/layout/xul/nsMenuFrame.cpp @@ -364,7 +364,7 @@ nsresult nsMenuFrame::HandleEvent(nsPresContext* aPresContext, // When pressing space, don't open the menu if performing an incremental // search. if (keyEvent->mCharCode != ' ' || - !nsMenuPopupFrame::IsWithinIncrementalTime(keyEvent->mTime)) { + !nsMenuPopupFrame::IsWithinIncrementalTime(keyEvent->mTimeStamp)) { *aEventStatus = nsEventStatus_eConsumeNoDefault; OpenMenu(false); } diff --git a/layout/xul/nsMenuPopupFrame.cpp b/layout/xul/nsMenuPopupFrame.cpp index d514bbfdf2fb..db4d666222ed 100644 --- a/layout/xul/nsMenuPopupFrame.cpp +++ b/layout/xul/nsMenuPopupFrame.cpp @@ -68,7 +68,7 @@ using mozilla::dom::KeyboardEvent; int8_t nsMenuPopupFrame::sDefaultLevelIsTop = -1; -DOMTimeStamp nsMenuPopupFrame::sLastKeyTime = 0; +TimeStamp nsMenuPopupFrame::sLastKeyTime; #ifdef MOZ_WAYLAND # include "mozilla/WidgetUtilsGtk.h" @@ -2128,7 +2128,7 @@ nsMenuFrame* nsMenuPopupFrame::FindMenuWithShortcut(KeyboardEvent* aKeyEvent, bool isMenu = parentContent && !parentContent->NodeInfo()->Equals( nsGkAtoms::menulist, kNameSpaceID_XUL); - DOMTimeStamp keyTime = aKeyEvent->TimeStamp(); + TimeStamp keyTime = aKeyEvent->WidgetEventPtr()->mTimeStamp; if (charCode == 0) { if (keyCode == dom::KeyboardEvent_Binding::DOM_VK_BACK_SPACE) { diff --git a/layout/xul/nsMenuPopupFrame.h b/layout/xul/nsMenuPopupFrame.h index 9c4ee513e8f4..5433bd031c35 100644 --- a/layout/xul/nsMenuPopupFrame.h +++ b/layout/xul/nsMenuPopupFrame.h @@ -14,6 +14,7 @@ #include "mozilla/Attributes.h" #include "mozilla/gfx/Types.h" #include "mozilla/StaticPrefs_ui.h" +#include "mozilla/TimeStamp.h" #include "nsAtom.h" #include "nsGkAtoms.h" #include "nsCOMPtr.h" @@ -306,9 +307,10 @@ class nsMenuPopupFrame final : public nsBoxFrame, bool& doAction); void ClearIncrementalString() { mIncrementalString.Truncate(); } - static bool IsWithinIncrementalTime(DOMTimeStamp time) { - return time - sLastKeyTime <= - mozilla::StaticPrefs::ui_menu_incremental_search_timeout(); + static bool IsWithinIncrementalTime(mozilla::TimeStamp time) { + return !sLastKeyTime.IsNull() && + ((time - sLastKeyTime).ToMilliseconds() <= + mozilla::StaticPrefs::ui_menu_incremental_search_timeout()); } #ifdef DEBUG_FRAME_DUMP @@ -647,7 +649,7 @@ class nsMenuPopupFrame final : public nsBoxFrame, static int8_t sDefaultLevelIsTop; - static DOMTimeStamp sLastKeyTime; + static mozilla::TimeStamp sLastKeyTime; }; // class nsMenuPopupFrame diff --git a/widget/BasicEvents.h b/widget/BasicEvents.h index bc4a34bbfc6a..267725aa6973 100644 --- a/widget/BasicEvents.h +++ b/widget/BasicEvents.h @@ -419,20 +419,14 @@ struct EventFlags : public BaseEventFlags { class WidgetEventTime { public: - // Elapsed time, in milliseconds, from a platform-specific zero time - // to the time the message was created - uint64_t mTime; - // Timestamp when the message was created. Set in parallel to 'time' until we - // determine if it is safe to drop 'time' (see bug 77992). + // Timestamp when the message was created. TimeStamp mTimeStamp; - WidgetEventTime() : mTime(0), mTimeStamp(TimeStamp::Now()) {} + WidgetEventTime() : mTimeStamp(TimeStamp::Now()) {} - WidgetEventTime(uint64_t aTime, TimeStamp aTimeStamp) - : mTime(aTime), mTimeStamp(aTimeStamp) {} + explicit WidgetEventTime(TimeStamp aTimeStamp) : mTimeStamp(aTimeStamp) {} void AssignEventTime(const WidgetEventTime& aOther) { - mTime = aOther.mTime; mTimeStamp = aOther.mTimeStamp; } }; diff --git a/widget/InputData.cpp b/widget/InputData.cpp index d43e6dd4397b..0265aab5a815 100644 --- a/widget/InputData.cpp +++ b/widget/InputData.cpp @@ -25,15 +25,13 @@ InputData::~InputData() = default; InputData::InputData(InputType aInputType) : mInputType(aInputType), - mTime(0), mFocusSequenceNumber(0), mLayersId{0}, modifiers(0) {} -InputData::InputData(InputType aInputType, uint32_t aTime, TimeStamp aTimeStamp, +InputData::InputData(InputType aInputType, TimeStamp aTimeStamp, Modifiers aModifiers) : mInputType(aInputType), - mTime(aTime), mTimeStamp(aTimeStamp), mFocusSequenceNumber(0), mLayersId{0}, @@ -78,7 +76,7 @@ already_AddRefed SingleTouchData::ToNewDOMTouch() const { MultiTouchInput::MultiTouchInput(MultiTouchType aType, uint32_t aTime, TimeStamp aTimeStamp, Modifiers aModifiers) - : InputData(MULTITOUCH_INPUT, aTime, aTimeStamp, aModifiers), + : InputData(MULTITOUCH_INPUT, aTimeStamp, aModifiers), mType(aType), mHandledByAPZ(false) {} @@ -88,7 +86,7 @@ MultiTouchInput::MultiTouchInput() mHandledByAPZ(false) {} MultiTouchInput::MultiTouchInput(const WidgetTouchEvent& aTouchEvent) - : InputData(MULTITOUCH_INPUT, aTouchEvent.mTime, aTouchEvent.mTimeStamp, + : InputData(MULTITOUCH_INPUT, aTouchEvent.mTimeStamp, aTouchEvent.mModifiers), mHandledByAPZ(aTouchEvent.mFlags.mHandledByAPZ), mButton(aTouchEvent.mButton), @@ -185,7 +183,6 @@ WidgetTouchEvent MultiTouchInput::ToWidgetEvent(nsIWidget* aWidget, } event.mModifiers = this->modifiers; - event.mTime = this->mTime; event.mTimeStamp = this->mTimeStamp; event.mFlags.mHandledByAPZ = mHandledByAPZ; event.mFocusSequenceNumber = mFocusSequenceNumber; @@ -242,9 +239,9 @@ MouseInput::MouseInput() MouseInput::MouseInput(MouseType aType, ButtonType aButtonType, uint16_t aInputSource, int16_t aButtons, - const ScreenPoint& aPoint, uint32_t aTime, - TimeStamp aTimeStamp, Modifiers aModifiers) - : InputData(MOUSE_INPUT, aTime, aTimeStamp, aModifiers), + const ScreenPoint& aPoint, TimeStamp aTimeStamp, + Modifiers aModifiers) + : InputData(MOUSE_INPUT, aTimeStamp, aModifiers), mType(aType), mButtonType(aButtonType), mInputSource(aInputSource), @@ -254,8 +251,7 @@ MouseInput::MouseInput(MouseType aType, ButtonType aButtonType, mPreventClickEvent(false) {} MouseInput::MouseInput(const WidgetMouseEventBase& aMouseEvent) - : InputData(MOUSE_INPUT, aMouseEvent.mTime, aMouseEvent.mTimeStamp, - aMouseEvent.mModifiers), + : InputData(MOUSE_INPUT, aMouseEvent.mTimeStamp, aMouseEvent.mModifiers), mType(MOUSE_NONE), mButtonType(NONE), mInputSource(aMouseEvent.mInputSource), @@ -399,7 +395,6 @@ WidgetMouseEvent MouseInput::ToWidgetEvent(nsIWidget* aWidget) const { event.mButtons = mButtons; event.mModifiers = modifiers; - event.mTime = mTime; event.mTimeStamp = mTimeStamp; event.mLayersId = mLayersId; event.mFlags.mHandledByAPZ = mHandledByAPZ; @@ -428,12 +423,11 @@ PanGestureInput::PanGestureInput() mIsNoLineOrPageDelta(true), mMayTriggerSwipe(false) {} -PanGestureInput::PanGestureInput(PanGestureType aType, uint32_t aTime, - TimeStamp aTimeStamp, +PanGestureInput::PanGestureInput(PanGestureType aType, TimeStamp aTimeStamp, const ScreenPoint& aPanStartPoint, const ScreenPoint& aPanDisplacement, Modifiers aModifiers) - : InputData(PANGESTURE_INPUT, aTime, aTimeStamp, aModifiers), + : InputData(PANGESTURE_INPUT, aTimeStamp, aModifiers), mType(aType), mPanStartPoint(aPanStartPoint), mPanDisplacement(aPanDisplacement), @@ -448,14 +442,13 @@ PanGestureInput::PanGestureInput(PanGestureType aType, uint32_t aTime, mMayTriggerSwipe = SwipeTracker::CanTriggerSwipe(*this); } -PanGestureInput::PanGestureInput(PanGestureType aType, uint32_t aTime, - TimeStamp aTimeStamp, +PanGestureInput::PanGestureInput(PanGestureType aType, TimeStamp aTimeStamp, const ScreenPoint& aPanStartPoint, const ScreenPoint& aPanDisplacement, Modifiers aModifiers, IsEligibleForSwipe aIsEligibleForSwipe) - : PanGestureInput(aType, aTime, aTimeStamp, aPanStartPoint, - aPanDisplacement, aModifiers) { + : PanGestureInput(aType, aTimeStamp, aPanStartPoint, aPanDisplacement, + aModifiers) { mMayTriggerSwipe &= bool(aIsEligibleForSwipe); } @@ -480,7 +473,6 @@ bool PanGestureInput::IsMomentum() const { WidgetWheelEvent PanGestureInput::ToWidgetEvent(nsIWidget* aWidget) const { WidgetWheelEvent wheelEvent(true, eWheel, aWidget); wheelEvent.mModifiers = this->modifiers; - wheelEvent.mTime = mTime; wheelEvent.mTimeStamp = mTimeStamp; wheelEvent.mLayersId = mLayersId; wheelEvent.mRefPoint = RoundedToInt(ViewAs( @@ -571,11 +563,10 @@ PinchGestureInput::PinchGestureInput() mHandledByAPZ(false) {} PinchGestureInput::PinchGestureInput( - PinchGestureType aType, PinchGestureSource aSource, uint32_t aTime, - TimeStamp aTimeStamp, const ExternalPoint& aScreenOffset, - const ScreenPoint& aFocusPoint, ScreenCoord aCurrentSpan, - ScreenCoord aPreviousSpan, Modifiers aModifiers) - : InputData(PINCHGESTURE_INPUT, aTime, aTimeStamp, aModifiers), + PinchGestureType aType, PinchGestureSource aSource, TimeStamp aTimeStamp, + const ExternalPoint& aScreenOffset, const ScreenPoint& aFocusPoint, + ScreenCoord aCurrentSpan, ScreenCoord aPreviousSpan, Modifiers aModifiers) + : InputData(PINCHGESTURE_INPUT, aTimeStamp, aModifiers), mType(aType), mSource(aSource), mFocusPoint(aFocusPoint), @@ -598,7 +589,6 @@ bool PinchGestureInput::TransformToLocal( WidgetWheelEvent PinchGestureInput::ToWidgetEvent(nsIWidget* aWidget) const { WidgetWheelEvent wheelEvent(true, eWheel, aWidget); wheelEvent.mModifiers = this->modifiers | MODIFIER_CONTROL; - wheelEvent.mTime = mTime; wheelEvent.mTimeStamp = mTimeStamp; wheelEvent.mLayersId = mLayersId; wheelEvent.mRefPoint = RoundedToInt(ViewAs( @@ -713,19 +703,17 @@ bool PinchGestureInput::SetLineOrPageDeltaY(nsIWidget* aWidget) { TapGestureInput::TapGestureInput() : InputData(TAPGESTURE_INPUT), mType(TAPGESTURE_LONG) {} -TapGestureInput::TapGestureInput(TapGestureType aType, uint32_t aTime, - TimeStamp aTimeStamp, +TapGestureInput::TapGestureInput(TapGestureType aType, TimeStamp aTimeStamp, const ScreenIntPoint& aPoint, Modifiers aModifiers) - : InputData(TAPGESTURE_INPUT, aTime, aTimeStamp, aModifiers), + : InputData(TAPGESTURE_INPUT, aTimeStamp, aModifiers), mType(aType), mPoint(aPoint) {} -TapGestureInput::TapGestureInput(TapGestureType aType, uint32_t aTime, - TimeStamp aTimeStamp, +TapGestureInput::TapGestureInput(TapGestureType aType, TimeStamp aTimeStamp, const ParentLayerPoint& aLocalPoint, Modifiers aModifiers) - : InputData(TAPGESTURE_INPUT, aTime, aTimeStamp, aModifiers), + : InputData(TAPGESTURE_INPUT, aTimeStamp, aModifiers), mType(aType), mLocalPoint(aLocalPoint) {} @@ -743,7 +731,6 @@ WidgetSimpleGestureEvent TapGestureInput::ToWidgetEvent( nsIWidget* aWidget) const { WidgetSimpleGestureEvent event(true, eTapGesture, aWidget); - event.mTime = mTime; event.mTimeStamp = mTimeStamp; event.mLayersId = mLayersId; event.mRefPoint = ViewAs( @@ -773,12 +760,11 @@ ScrollWheelInput::ScrollWheelInput() mAPZAction(APZWheelAction::Scroll) {} ScrollWheelInput::ScrollWheelInput( - uint32_t aTime, TimeStamp aTimeStamp, Modifiers aModifiers, - ScrollMode aScrollMode, ScrollDeltaType aDeltaType, - const ScreenPoint& aOrigin, double aDeltaX, double aDeltaY, - bool aAllowToOverrideSystemScrollSpeed, + TimeStamp aTimeStamp, Modifiers aModifiers, ScrollMode aScrollMode, + ScrollDeltaType aDeltaType, const ScreenPoint& aOrigin, double aDeltaX, + double aDeltaY, bool aAllowToOverrideSystemScrollSpeed, WheelDeltaAdjustmentStrategy aWheelDeltaAdjustmentStrategy) - : InputData(SCROLLWHEEL_INPUT, aTime, aTimeStamp, aModifiers), + : InputData(SCROLLWHEEL_INPUT, aTimeStamp, aModifiers), mDeltaType(aDeltaType), mScrollMode(aScrollMode), mOrigin(aOrigin), @@ -797,7 +783,7 @@ ScrollWheelInput::ScrollWheelInput( mAPZAction(APZWheelAction::Scroll) {} ScrollWheelInput::ScrollWheelInput(const WidgetWheelEvent& aWheelEvent) - : InputData(SCROLLWHEEL_INPUT, aWheelEvent.mTime, aWheelEvent.mTimeStamp, + : InputData(SCROLLWHEEL_INPUT, aWheelEvent.mTimeStamp, aWheelEvent.mModifiers), mDeltaType(DeltaTypeForDeltaMode(aWheelEvent.mDeltaMode)), mScrollMode(SCROLLMODE_INSTANT), @@ -867,7 +853,6 @@ ScrollUnit ScrollWheelInput::ScrollUnitForDeltaType( WidgetWheelEvent ScrollWheelInput::ToWidgetEvent(nsIWidget* aWidget) const { WidgetWheelEvent wheelEvent(true, eWheel, aWidget); wheelEvent.mModifiers = this->modifiers; - wheelEvent.mTime = mTime; wheelEvent.mTimeStamp = mTimeStamp; wheelEvent.mLayersId = mLayersId; wheelEvent.mRefPoint = RoundedToInt(ViewAs( @@ -905,8 +890,7 @@ bool ScrollWheelInput::IsCustomizedByUserPrefs() const { } KeyboardInput::KeyboardInput(const WidgetKeyboardEvent& aEvent) - : InputData(KEYBOARD_INPUT, aEvent.mTime, aEvent.mTimeStamp, - aEvent.mModifiers), + : InputData(KEYBOARD_INPUT, aEvent.mTimeStamp, aEvent.mModifiers), mKeyCode(aEvent.mKeyCode), mCharCode(aEvent.mCharCode), mHandledByAPZ(false) { diff --git a/widget/InputData.h b/widget/InputData.h index bb90f6ca9387..5a49b18e218c 100644 --- a/widget/InputData.h +++ b/widget/InputData.h @@ -76,14 +76,8 @@ class InputData { // Warning, this class is serialized and sent over IPC. Any change to its // fields must be reflected in its ParamTraits<>, in nsGUIEventIPC.h InputType mInputType; - // Time in milliseconds that this data is relevant to. This only really - // matters when this data is used as an event. We use uint32_t instead of - // TimeStamp because it is easier to convert from WidgetInputEvent. The time - // is platform-specific but it in the case of B2G and Fennec it is since - // startup. - uint32_t mTime; - // Set in parallel to mTime until we determine it is safe to drop - // platform-specific event times (see bug 77992). + // Time that this data is relevant to. This only really matters when this data + // is used as an event. TimeStamp mTimeStamp; // The sequence number of the last potentially focus changing event handled // by APZ. This is used to track when that event has been processed by @@ -108,8 +102,7 @@ class InputData { explicit InputData(InputType aInputType); protected: - InputData(InputType aInputType, uint32_t aTime, TimeStamp aTimeStamp, - Modifiers aModifiers); + InputData(InputType aInputType, TimeStamp aTimeStamp, Modifiers aModifiers); }; /** @@ -293,8 +286,8 @@ class MouseInput : public InputData { // clang-format on MouseInput(MouseType aType, ButtonType aButtonType, uint16_t aInputSource, - int16_t aButtons, const ScreenPoint& aPoint, uint32_t aTime, - TimeStamp aTimeStamp, Modifiers aModifiers); + int16_t aButtons, const ScreenPoint& aPoint, TimeStamp aTimeStamp, + Modifiers aModifiers); explicit MouseInput(const WidgetMouseEventBase& aMouseEvent); bool IsLeftButton() const; @@ -396,12 +389,12 @@ class PanGestureInput : public InputData { )); // clang-format on - PanGestureInput(PanGestureType aType, uint32_t aTime, TimeStamp aTimeStamp, + PanGestureInput(PanGestureType aType, TimeStamp aTimeStamp, const ScreenPoint& aPanStartPoint, const ScreenPoint& aPanDisplacement, Modifiers aModifiers); enum class IsEligibleForSwipe : bool { No, Yes }; - PanGestureInput(PanGestureType aType, uint32_t aTime, TimeStamp aTimeStamp, + PanGestureInput(PanGestureType aType, TimeStamp aTimeStamp, const ScreenPoint& aPanStartPoint, const ScreenPoint& aPanDisplacement, Modifiers aModifiers, IsEligibleForSwipe aIsEligibleForSwipe); @@ -540,8 +533,7 @@ class PinchGestureInput : public InputData { // Construct a pinch gesture from a Screen point. PinchGestureInput(PinchGestureType aType, PinchGestureSource aSource, - uint32_t aTime, TimeStamp aTimeStamp, - const ExternalPoint& aScreenOffset, + TimeStamp aTimeStamp, const ExternalPoint& aScreenOffset, const ScreenPoint& aFocusPoint, ScreenCoord aCurrentSpan, ScreenCoord aPreviousSpan, Modifiers aModifiers); @@ -637,12 +629,12 @@ class TapGestureInput : public InputData { // Construct a tap gesture from a Screen point. // mLocalPoint remains (0,0) unless it's set later. - TapGestureInput(TapGestureType aType, uint32_t aTime, TimeStamp aTimeStamp, + TapGestureInput(TapGestureType aType, TimeStamp aTimeStamp, const ScreenIntPoint& aPoint, Modifiers aModifiers); // Construct a tap gesture from a ParentLayer point. // mPoint remains (0,0) unless it's set later. - TapGestureInput(TapGestureType aType, uint32_t aTime, TimeStamp aTimeStamp, + TapGestureInput(TapGestureType aType, TimeStamp aTimeStamp, const ParentLayerPoint& aLocalPoint, Modifiers aModifiers); bool TransformToLocal(const ScreenToParentLayerMatrix4x4& aTransform); @@ -692,7 +684,7 @@ class ScrollWheelInput : public InputData { ); // clang-format on - ScrollWheelInput(uint32_t aTime, TimeStamp aTimeStamp, Modifiers aModifiers, + ScrollWheelInput(TimeStamp aTimeStamp, Modifiers aModifiers, ScrollMode aScrollMode, ScrollDeltaType aDeltaType, const ScreenPoint& aOrigin, double aDeltaX, double aDeltaY, bool aAllowToOverrideSystemScrollSpeed, diff --git a/widget/PuppetWidget.cpp b/widget/PuppetWidget.cpp index 78708375966e..e61039e58f02 100644 --- a/widget/PuppetWidget.cpp +++ b/widget/PuppetWidget.cpp @@ -265,7 +265,6 @@ void PuppetWidget::InitEvent(WidgetGUIEvent& aEvent, // use the point override if provided aEvent.mRefPoint = *aPoint; } - aEvent.mTime = PR_Now() / 1000; } nsresult PuppetWidget::DispatchEvent(WidgetGUIEvent* aEvent, diff --git a/widget/TextEventDispatcher.cpp b/widget/TextEventDispatcher.cpp index b9ec2f553f24..6ecd5d355cf1 100644 --- a/widget/TextEventDispatcher.cpp +++ b/widget/TextEventDispatcher.cpp @@ -209,7 +209,6 @@ nsresult TextEventDispatcher::GetState() const { } void TextEventDispatcher::InitEvent(WidgetGUIEvent& aEvent) const { - aEvent.mTime = PR_IntervalNow(); aEvent.mRefPoint = LayoutDeviceIntPoint(0, 0); aEvent.mFlags.mIsSynthesizedForTests = IsForTests(); if (aEvent.mClass != eCompositionEventClass) { diff --git a/widget/TouchEvents.h b/widget/TouchEvents.h index 22ec8beea85a..5d2fe881aa8f 100644 --- a/widget/TouchEvents.h +++ b/widget/TouchEvents.h @@ -153,7 +153,6 @@ class WidgetTouchEvent : public WidgetInputEvent { eTouchEventClass) { MOZ_COUNT_CTOR(WidgetTouchEvent); mModifiers = aOther.mModifiers; - mTime = aOther.mTime; mTimeStamp = aOther.mTimeStamp; mTouches.AppendElements(aOther.mTouches); mInputSource = aOther.mInputSource; diff --git a/widget/android/GeckoEditableSupport.cpp b/widget/android/GeckoEditableSupport.cpp index 4605762972a3..8c21a0ff7311 100644 --- a/widget/android/GeckoEditableSupport.cpp +++ b/widget/android/GeckoEditableSupport.cpp @@ -402,7 +402,6 @@ static void InitKeyEvent(WidgetKeyboardEvent& aEvent, int32_t aAction, aEvent.mLocation = WidgetKeyboardEvent::ComputeLocationFromCodeValue(aEvent.mCodeNameIndex); - aEvent.mTime = aTime; aEvent.mTimeStamp = nsWindow::GetEventTimeStamp(aTime); } @@ -560,7 +559,6 @@ void GeckoEditableSupport::SendIMEDummyKeyEvent(nsIWidget* aWidget, MOZ_ASSERT(mDispatcher); WidgetKeyboardEvent event(true, msg, aWidget); - event.mTime = PR_Now() / 1000; // TODO: If we can know scan code of the key event which caused replacing // composition string, we should set mCodeNameIndex here. Then, // we should rename this method because it becomes not a "dummy" @@ -1013,7 +1011,6 @@ bool GeckoEditableSupport::DoReplaceText(int32_t aStart, int32_t aEnd, } } else if (performDeletion) { WidgetContentCommandEvent event(true, eContentCommandDelete, widget); - event.mTime = PR_Now() / 1000; widget->DispatchEvent(&event, status); if (!mDispatcher || widget->Destroyed()) { return false; diff --git a/widget/android/nsWindow.cpp b/widget/android/nsWindow.cpp index 169e5caeb69b..dd7eb4390eca 100644 --- a/widget/android/nsWindow.cpp +++ b/widget/android/nsWindow.cpp @@ -413,8 +413,8 @@ class NPZCSupport final } ScrollWheelInput input( - aTime, nsWindow::GetEventTimeStamp(aTime), - nsWindow::GetModifiers(aMetaState), ScrollWheelInput::SCROLLMODE_SMOOTH, + nsWindow::GetEventTimeStamp(aTime), nsWindow::GetModifiers(aMetaState), + ScrollWheelInput::SCROLLMODE_SMOOTH, ScrollWheelInput::SCROLLDELTA_PIXEL, origin, aHScroll, aVScroll, false, // XXX Do we need to support auto-dir scrolling // for Android widgets with a wheel device? @@ -597,8 +597,8 @@ class NPZCSupport final MouseInput input( mouseType, buttonType, MouseEvent_Binding::MOZ_SOURCE_MOUSE, - ConvertButtons(buttons), origin, aTime, - nsWindow::GetEventTimeStamp(aTime), nsWindow::GetModifiers(aMetaState)); + ConvertButtons(buttons), origin, nsWindow::GetEventTimeStamp(aTime), + nsWindow::GetModifiers(aMetaState)); APZEventResult result = controller->InputBridge()->ReceiveInputEvent(input); if (result.GetStatus() == nsEventStatus_eConsumeNoDefault) { @@ -2513,8 +2513,6 @@ void nsWindow::InitEvent(WidgetGUIEvent& event, LayoutDeviceIntPoint* aPoint) { } else { event.mRefPoint = LayoutDeviceIntPoint(0, 0); } - - event.mTime = PR_Now() / 1000; } void nsWindow::UpdateOverscrollVelocity(const float aX, const float aY) { diff --git a/widget/cocoa/nsChildView.mm b/widget/cocoa/nsChildView.mm index 4fba4976602f..96416b844d80 100644 --- a/widget/cocoa/nsChildView.mm +++ b/widget/cocoa/nsChildView.mm @@ -1021,8 +1021,8 @@ nsresult nsChildView::SynthesizeNativeTouchPoint( LayoutDeviceIntPoint pointInWindow = aPoint - WidgetToScreenOffset(); MultiTouchInput inputToDispatch = UpdateSynthesizedTouchState( - mSynthesizedTouchInput.get(), PR_IntervalNow(), TimeStamp::Now(), aPointerId, aPointerState, - pointInWindow, aPointerPressure, aPointerOrientation); + mSynthesizedTouchInput.get(), TimeStamp::Now(), aPointerId, aPointerState, pointInWindow, + aPointerPressure, aPointerOrientation); DispatchTouchInput(inputToDispatch); return NS_OK; @@ -1953,10 +1953,8 @@ void nsChildView::DispatchDoubleTapGesture(TimeStamp aEventTimeStamp, LayoutDeviceIntPoint aScreenPosition, mozilla::Modifiers aModifiers) { if (StaticPrefs::apz_mac_enable_double_tap_zoom_touchpad_gesture()) { - PRIntervalTime eventIntervalTime = PR_IntervalNow(); - TapGestureInput event{ - TapGestureInput::TAPGESTURE_DOUBLE, eventIntervalTime, aEventTimeStamp, + TapGestureInput::TAPGESTURE_DOUBLE, aEventTimeStamp, ViewAs(aScreenPosition, PixelCastJustification::LayoutDeviceIsScreenForUntransformedEvent), aModifiers}; @@ -1968,7 +1966,6 @@ void nsChildView::DispatchDoubleTapGesture(TimeStamp aEventTimeStamp, // do what convertCocoaMouseEvent does basically. geckoEvent.mRefPoint = aScreenPosition; geckoEvent.mModifiers = aModifiers; - geckoEvent.mTime = PR_IntervalNow(); geckoEvent.mTimeStamp = aEventTimeStamp; geckoEvent.mClickCount = 1; @@ -2520,7 +2517,6 @@ NSEvent* gLastDragMouseDownEvent = nil; // [strong] ViewAs(mGeckoChild->WidgetToScreenOffset(), PixelCastJustification::LayoutDeviceIsScreenForUntransformedEvent); - PRIntervalTime eventIntervalTime = PR_IntervalNow(); TimeStamp eventTimeStamp = nsCocoaUtils::GetEventTimeStamp([anEvent timestamp]); NSEventPhase eventPhase = [anEvent phase]; PinchGestureInput::PinchGestureType pinchGestureType; @@ -2547,7 +2543,6 @@ NSEvent* gLastDragMouseDownEvent = nil; // [strong] PinchGestureInput event{pinchGestureType, PinchGestureInput::TRACKPAD, - eventIntervalTime, eventTimeStamp, screenOffset, position, @@ -3153,7 +3148,6 @@ static gfx::IntPoint GetIntegerDeltaForEvent(NSEvent* aEvent) { Modifiers modifiers = nsCocoaUtils::ModifiersForEvent(theEvent); - PRIntervalTime eventIntervalTime = PR_IntervalNow(); TimeStamp eventTimeStamp = nsCocoaUtils::GetEventTimeStamp([theEvent timestamp]); ScreenPoint preciseDelta; @@ -3165,26 +3159,25 @@ static gfx::IntPoint GetIntegerDeltaForEvent(NSEvent* aEvent) { } if (usePreciseDeltas && hasPhaseInformation) { - PanGestureInput panEvent = - nsCocoaUtils::CreatePanGestureEvent(theEvent, eventIntervalTime, eventTimeStamp, position, - preciseDelta, lineOrPageDelta, modifiers); + PanGestureInput panEvent = nsCocoaUtils::CreatePanGestureEvent( + theEvent, eventTimeStamp, position, preciseDelta, lineOrPageDelta, modifiers); geckoChildDeathGrip->DispatchAPZWheelInputEvent(panEvent); } else if (usePreciseDeltas) { // This is on 10.6 or old touchpads that don't have any phase information. - ScrollWheelInput wheelEvent( - eventIntervalTime, eventTimeStamp, modifiers, ScrollWheelInput::SCROLLMODE_INSTANT, - ScrollWheelInput::SCROLLDELTA_PIXEL, position, preciseDelta.x, preciseDelta.y, false, - // This parameter is used for wheel delta - // adjustment, such as auto-dir scrolling, - // but we do't need to do anything special here - // since this wheel event is sent to - // DispatchAPZWheelInputEvent, which turns this - // ScrollWheelInput back into a WidgetWheelEvent - // and then it goes through the regular handling - // in APZInputBridge. So passing |eNone| won't - // pass up the necessary wheel delta adjustment. - WheelDeltaAdjustmentStrategy::eNone); + ScrollWheelInput wheelEvent(eventTimeStamp, modifiers, ScrollWheelInput::SCROLLMODE_INSTANT, + ScrollWheelInput::SCROLLDELTA_PIXEL, position, preciseDelta.x, + preciseDelta.y, false, + // This parameter is used for wheel delta + // adjustment, such as auto-dir scrolling, + // but we do't need to do anything special here + // since this wheel event is sent to + // DispatchAPZWheelInputEvent, which turns this + // ScrollWheelInput back into a WidgetWheelEvent + // and then it goes through the regular handling + // in APZInputBridge. So passing |eNone| won't + // pass up the necessary wheel delta adjustment. + WheelDeltaAdjustmentStrategy::eNone); wheelEvent.mLineOrPageDeltaX = lineOrPageDelta.x; wheelEvent.mLineOrPageDeltaY = lineOrPageDelta.y; wheelEvent.mIsMomentum = nsCocoaUtils::IsMomentumScrollEvent(theEvent); @@ -3194,7 +3187,7 @@ static gfx::IntPoint GetIntegerDeltaForEvent(NSEvent* aEvent) { if (StaticPrefs::general_smoothScroll() && StaticPrefs::general_smoothScroll_mouseWheel()) { scrollMode = ScrollWheelInput::SCROLLMODE_SMOOTH; } - ScrollWheelInput wheelEvent(eventIntervalTime, eventTimeStamp, modifiers, scrollMode, + ScrollWheelInput wheelEvent(eventTimeStamp, modifiers, scrollMode, ScrollWheelInput::SCROLLDELTA_LINE, position, lineOrPageDelta.x, lineOrPageDelta.y, false, // This parameter is used for wheel delta diff --git a/widget/cocoa/nsCocoaUtils.h b/widget/cocoa/nsCocoaUtils.h index 28756135bb20..092b6b393582 100644 --- a/widget/cocoa/nsCocoaUtils.h +++ b/widget/cocoa/nsCocoaUtils.h @@ -457,7 +457,7 @@ class nsCocoaUtils { static void InvalidateHiDPIState(); static mozilla::PanGestureInput CreatePanGestureEvent( - NSEvent* aNativeEvent, uint32_t aTime, mozilla::TimeStamp aTimeStamp, + NSEvent* aNativeEvent, mozilla::TimeStamp aTimeStamp, const mozilla::ScreenPoint& aPanStartPoint, const mozilla::ScreenPoint& aPreciseDelta, const mozilla::gfx::IntPoint& aLineOrPageDelta, mozilla::Modifiers aModifiers); diff --git a/widget/cocoa/nsCocoaUtils.mm b/widget/cocoa/nsCocoaUtils.mm index 46e72fe8ee76..839e0c3daa96 100644 --- a/widget/cocoa/nsCocoaUtils.mm +++ b/widget/cocoa/nsCocoaUtils.mm @@ -625,7 +625,6 @@ void nsCocoaUtils::InitInputEvent(WidgetInputEvent& aInputEvent, NSEvent* aNativ NS_OBJC_BEGIN_TRY_IGNORE_BLOCK; aInputEvent.mModifiers = ModifiersForEvent(aNativeEvent); - aInputEvent.mTime = PR_IntervalNow(); aInputEvent.mTimeStamp = GetEventTimeStamp([aNativeEvent timestamp]); NS_OBJC_END_TRY_IGNORE_BLOCK; @@ -1494,9 +1493,11 @@ bool static ShouldConsiderStartingSwipeFromEvent(NSEvent* anEvent) { [anEvent hasPreciseScrollingDeltas] && [NSEvent isSwipeTrackingFromScrollEventsEnabled]; } -PanGestureInput nsCocoaUtils::CreatePanGestureEvent( - NSEvent* aNativeEvent, uint32_t aTime, TimeStamp aTimeStamp, const ScreenPoint& aPanStartPoint, - const ScreenPoint& aPreciseDelta, const gfx::IntPoint& aLineOrPageDelta, Modifiers aModifiers) { +PanGestureInput nsCocoaUtils::CreatePanGestureEvent(NSEvent* aNativeEvent, TimeStamp aTimeStamp, + const ScreenPoint& aPanStartPoint, + const ScreenPoint& aPreciseDelta, + const gfx::IntPoint& aLineOrPageDelta, + Modifiers aModifiers) { PanGestureInput::PanGestureType type = PanGestureTypeForEvent(aNativeEvent); // Always force zero deltas on event types that shouldn't cause any scrolling, // so that we don't dispatch DOM wheel events for them. @@ -1504,7 +1505,7 @@ PanGestureInput nsCocoaUtils::CreatePanGestureEvent( type == PanGestureInput::PANGESTURE_MAYSTART || type == PanGestureInput::PANGESTURE_CANCELLED; PanGestureInput panEvent( - type, aTime, aTimeStamp, aPanStartPoint, !shouldIgnoreDeltas ? aPreciseDelta : ScreenPoint(), + type, aTimeStamp, aPanStartPoint, !shouldIgnoreDeltas ? aPreciseDelta : ScreenPoint(), aModifiers, PanGestureInput::IsEligibleForSwipe(ShouldConsiderStartingSwipeFromEvent(aNativeEvent))); diff --git a/widget/gtk/IMContextWrapper.cpp b/widget/gtk/IMContextWrapper.cpp index ecbc2eeef563..25dfeb7c486e 100644 --- a/widget/gtk/IMContextWrapper.cpp +++ b/widget/gtk/IMContextWrapper.cpp @@ -2925,7 +2925,6 @@ void IMContextWrapper::SetCursorPosition(GtkIMContext* aContext) { mCompositionTargetRange.mOffset, 1); } } - InitEvent(queryCaretOrTextRectEvent); nsEventStatus status; mLastFocusedWindow->DispatchEvent(&queryCaretOrTextRectEvent, status); if (queryCaretOrTextRectEvent.Failed()) { @@ -3235,10 +3234,6 @@ nsresult IMContextWrapper::DeleteText(GtkIMContext* aContext, int32_t aOffset, return NS_OK; } -void IMContextWrapper::InitEvent(WidgetGUIEvent& aEvent) { - aEvent.mTime = PR_Now() / 1000; -} - bool IMContextWrapper::EnsureToCacheContentSelection( nsAString* aSelectedString) { if (aSelectedString) { @@ -3265,7 +3260,6 @@ bool IMContextWrapper::EnsureToCacheContentSelection( nsEventStatus status; WidgetQueryContentEvent querySelectedTextEvent(true, eQuerySelectedText, dispatcherWindow); - InitEvent(querySelectedTextEvent); dispatcherWindow->DispatchEvent(&querySelectedTextEvent, status); if (NS_WARN_IF(querySelectedTextEvent.Failed())) { MOZ_LOG(gIMELog, LogLevel::Error, diff --git a/widget/gtk/IMContextWrapper.h b/widget/gtk/IMContextWrapper.h index 8792bc84c6b3..81fa861b225d 100644 --- a/widget/gtk/IMContextWrapper.h +++ b/widget/gtk/IMContextWrapper.h @@ -599,9 +599,6 @@ class IMContextWrapper final : public TextEventDispatcherListener { nsresult DeleteText(GtkIMContext* aContext, int32_t aOffset, uint32_t aNChars); - // Initializes the GUI event. - void InitEvent(WidgetGUIEvent& aEvent); - // Called before destroying the context to work around some platform bugs. void PrepareToDestroyContext(GtkIMContext* aContext); diff --git a/widget/gtk/nsGtkKeyUtils.cpp b/widget/gtk/nsGtkKeyUtils.cpp index 212101262652..1ef4d62bf6f4 100644 --- a/widget/gtk/nsGtkKeyUtils.cpp +++ b/widget/gtk/nsGtkKeyUtils.cpp @@ -1879,7 +1879,6 @@ void KeymapWrapper::InitKeyEvent(WidgetKeyboardEvent& aKeyEvent, // so link to the GdkEvent (which will vanish soon after return from the // event callback) to give plugins access to hardware_keycode and state. // (An XEvent would be nice but the GdkEvent is good enough.) - aKeyEvent.mTime = aGdkKeyEvent->time; aKeyEvent.mNativeKeyEvent = static_cast(aGdkKeyEvent); aKeyEvent.mIsRepeat = sRepeatState == REPEATING && diff --git a/widget/gtk/nsWindow.cpp b/widget/gtk/nsWindow.cpp index 70f27f3d552e..d7d2ef6b0bf1 100644 --- a/widget/gtk/nsWindow.cpp +++ b/widget/gtk/nsWindow.cpp @@ -4858,7 +4858,7 @@ bool nsWindow::DispatchContentCommandEvent(EventMessage aMsg) { } WidgetEventTime nsWindow::GetWidgetEventTime(guint32 aEventTime) { - return WidgetEventTime(aEventTime, GetEventTimeStamp(aEventTime)); + return WidgetEventTime(GetEventTimeStamp(aEventTime)); } TimeStamp nsWindow::GetEventTimeStamp(guint32 aEventTime) { @@ -5007,7 +5007,7 @@ void nsWindow::OnScrollEvent(GdkEventScroll* aEvent) { LayoutDeviceIntPoint touchPoint = GetRefPoint(this, aEvent); PanGestureInput panEvent( - eventType, aEvent->time, GetEventTimeStamp(aEvent->time), + eventType, GetEventTimeStamp(aEvent->time), ScreenPoint(touchPoint.x, touchPoint.y), deltas, KeymapWrapper::ComputeKeyModifiers(aEvent->state)); panEvent.mDeltaType = isPageMode ? PanGestureInput::PANDELTA_PAGE @@ -5418,7 +5418,7 @@ gboolean nsWindow::OnTouchpadPinchEvent(GdkEventTouchpadPinch* aEvent) { } PinchGestureInput event( - pinchGestureType, PinchGestureInput::TRACKPAD, aEvent->time, + pinchGestureType, PinchGestureInput::TRACKPAD, GetEventTimeStamp(aEvent->time), ExternalPoint(0, 0), mCurrentTouchpadFocus, 100.0 * ((aEvent->phase == GDK_TOUCHPAD_GESTURE_PHASE_END) @@ -5511,7 +5511,6 @@ gboolean nsWindow::OnTouchEvent(GdkEventTouch* aEvent) { WidgetTouchEvent event(true, msg, this); KeymapWrapper::InitInputEvent(event, aEvent->state); - event.mTime = aEvent->time; if (msg == eTouchStart || msg == eTouchMove) { mTouches.InsertOrUpdate(aEvent->sequence, std::move(touch)); @@ -8593,7 +8592,6 @@ void nsWindow::EndRemoteDrawingInRegion( mSurfaceProvider.EndRemoteDrawingInRegion(aDrawTarget, aInvalidRegion); } -// Code shared begin BeginMoveDrag and BeginResizeDrag bool nsWindow::GetDragInfo(WidgetMouseEvent* aMouseEvent, GdkWindow** aWindow, gint* aButton, gint* aRootX, gint* aRootY) { if (aMouseEvent->mButton != MouseButton::ePrimary) { @@ -8630,12 +8628,13 @@ bool nsWindow::GetDragInfo(WidgetMouseEvent* aMouseEvent, GdkWindow** aWindow, // Workaround for https://bugzilla.gnome.org/show_bug.cgi?id=789054 // To avoid crashes disable double-click on WM without _NET_WM_MOVERESIZE. // See _should_perform_ewmh_drag() at gdkwindow-x11.c + // XXXsmaug remove this old hack. gtk should be fixed now. GdkScreen* screen = gdk_window_get_screen(gdk_window); GdkAtom atom = gdk_atom_intern("_NET_WM_MOVERESIZE", FALSE); if (!gdk_x11_screen_supports_net_wm_hint(screen, atom)) { - static unsigned int lastTimeStamp = 0; - if (lastTimeStamp != aMouseEvent->mTime) { - lastTimeStamp = aMouseEvent->mTime; + static TimeStamp lastTimeStamp; + if (lastTimeStamp != aMouseEvent->mTimeStamp) { + lastTimeStamp = aMouseEvent->mTimeStamp; } else { return false; } @@ -8655,57 +8654,6 @@ bool nsWindow::GetDragInfo(WidgetMouseEvent* aMouseEvent, GdkWindow** aWindow, return true; } -nsresult nsWindow::BeginResizeDrag(WidgetGUIEvent* aEvent, int32_t aHorizontal, - int32_t aVertical) { - NS_ENSURE_ARG_POINTER(aEvent); - - if (aEvent->mClass != eMouseEventClass) { - // you can only begin a resize drag with a mouse event - return NS_ERROR_INVALID_ARG; - } - - GdkWindow* gdk_window; - gint button, screenX, screenY; - if (!GetDragInfo(aEvent->AsMouseEvent(), &gdk_window, &button, &screenX, - &screenY)) { - return NS_ERROR_FAILURE; - } - - // work out what GdkWindowEdge we're talking about - GdkWindowEdge window_edge; - if (aVertical < 0) { - if (aHorizontal < 0) { - window_edge = GDK_WINDOW_EDGE_NORTH_WEST; - } else if (aHorizontal == 0) { - window_edge = GDK_WINDOW_EDGE_NORTH; - } else { - window_edge = GDK_WINDOW_EDGE_NORTH_EAST; - } - } else if (aVertical == 0) { - if (aHorizontal < 0) { - window_edge = GDK_WINDOW_EDGE_WEST; - } else if (aHorizontal == 0) { - return NS_ERROR_INVALID_ARG; - } else { - window_edge = GDK_WINDOW_EDGE_EAST; - } - } else { - if (aHorizontal < 0) { - window_edge = GDK_WINDOW_EDGE_SOUTH_WEST; - } else if (aHorizontal == 0) { - window_edge = GDK_WINDOW_EDGE_SOUTH; - } else { - window_edge = GDK_WINDOW_EDGE_SOUTH_EAST; - } - } - - // tell the window manager to start the resize - gdk_window_begin_resize_drag(gdk_window, window_edge, button, screenX, - screenY, aEvent->mTime); - - return NS_OK; -} - nsIWidget::WindowRenderer* nsWindow::GetWindowRenderer() { if (mIsDestroyed) { // Prevent external code from triggering the re-creation of the diff --git a/widget/gtk/nsWindow.h b/widget/gtk/nsWindow.h index 863be27d22a5..772aa326ffb6 100644 --- a/widget/gtk/nsWindow.h +++ b/widget/gtk/nsWindow.h @@ -271,10 +271,6 @@ class nsWindow final : public nsBaseWidget { static guint32 sLastButtonPressTime; - [[nodiscard]] nsresult BeginResizeDrag(mozilla::WidgetGUIEvent* aEvent, - int32_t aHorizontal, - int32_t aVertical) override; - MozContainer* GetMozContainer() { return mContainer; } LayoutDeviceIntSize GetMozContainerSize(); GdkWindow* GetGdkWindow() const { return mGdkWindow; }; diff --git a/widget/headless/HeadlessWidget.cpp b/widget/headless/HeadlessWidget.cpp index d9befb6a2d27..54d9625e5ec0 100644 --- a/widget/headless/HeadlessWidget.cpp +++ b/widget/headless/HeadlessWidget.cpp @@ -512,9 +512,8 @@ nsresult HeadlessWidget::SynthesizeNativeTouchPoint( LayoutDeviceIntPoint pointInWindow = aPoint - WidgetToScreenOffset(); MultiTouchInput inputToDispatch = UpdateSynthesizedTouchState( - mSynthesizedTouchInput.get(), PR_IntervalNow(), TimeStamp::Now(), - aPointerId, aPointerState, pointInWindow, aPointerPressure, - aPointerOrientation); + mSynthesizedTouchInput.get(), TimeStamp::Now(), aPointerId, aPointerState, + pointInWindow, aPointerPressure, aPointerOrientation); DispatchTouchInput(inputToDispatch); return NS_OK; } @@ -560,8 +559,8 @@ nsresult HeadlessWidget::SynthesizeNativeTouchPadPinch( // The headless widget does not support modifiers. // Do not pass `aModifierFlags` because it contains native modifier values. PinchGestureInput inputToDispatch( - pinchGestureType, PinchGestureInput::TRACKPAD, PR_IntervalNow(), - TimeStamp::Now(), ExternalPoint(0, 0), touchpadPoint, + pinchGestureType, PinchGestureInput::TRACKPAD, TimeStamp::Now(), + ExternalPoint(0, 0), touchpadPoint, 100.0 * ((aEventPhase == PHASE_END) ? ScreenCoord(1.f) : CurrentSpan), 100.0 * ((aEventPhase == PHASE_END) ? ScreenCoord(1.f) : PreviousSpan), 0); @@ -601,8 +600,7 @@ nsresult HeadlessWidget::SynthesizeNativeTouchpadPan( ScreenPoint touchpadPoint = ViewAs( aPoint - WidgetToScreenOffset(), PixelCastJustification::LayoutDeviceIsScreenForUntransformedEvent); - PanGestureInput input(eventType, PR_IntervalNow(), TimeStamp::Now(), - touchpadPoint, + PanGestureInput input(eventType, TimeStamp::Now(), touchpadPoint, ScreenPoint(float(aDeltaX), float(aDeltaY)), // Same as SynthesizeNativeTouchPadPinch case we ignore // aModifierFlags. diff --git a/widget/nsBaseWidget.cpp b/widget/nsBaseWidget.cpp index 8fc04d8346b2..990aa8532e34 100644 --- a/widget/nsBaseWidget.cpp +++ b/widget/nsBaseWidget.cpp @@ -2135,10 +2135,9 @@ nsresult nsIWidget::ClearNativeTouchSequence(nsIObserver* aObserver) { } MultiTouchInput nsBaseWidget::UpdateSynthesizedTouchState( - MultiTouchInput* aState, uint32_t aTime, mozilla::TimeStamp aTimeStamp, - uint32_t aPointerId, TouchPointerState aPointerState, - LayoutDeviceIntPoint aPoint, double aPointerPressure, - uint32_t aPointerOrientation) { + MultiTouchInput* aState, mozilla::TimeStamp aTimeStamp, uint32_t aPointerId, + TouchPointerState aPointerState, LayoutDeviceIntPoint aPoint, + double aPointerPressure, uint32_t aPointerOrientation) { ScreenIntPoint pointerScreenPoint = ViewAs( aPoint, PixelCastJustification::LayoutDeviceIsScreenForBounds); @@ -2149,7 +2148,6 @@ MultiTouchInput nsBaseWidget::UpdateSynthesizedTouchState( // touch(es). We use |inputToDispatch| for this purpose. MultiTouchInput inputToDispatch; inputToDispatch.mInputType = MULTITOUCH_INPUT; - inputToDispatch.mTime = aTime; inputToDispatch.mTimeStamp = aTimeStamp; int32_t index = aState->IndexOfTouch((int32_t)aPointerId); diff --git a/widget/nsBaseWidget.h b/widget/nsBaseWidget.h index 08b8a79cf7d6..c86b6fd1cd37 100644 --- a/widget/nsBaseWidget.h +++ b/widget/nsBaseWidget.h @@ -274,11 +274,6 @@ class nsBaseWidget : public nsIWidget, public nsSupportsWeakReference { void SetDrawsInTitlebar(bool aState) override {} bool ShowsResizeIndicator(LayoutDeviceIntRect* aResizerRect) override; void FreeNativeData(void* data, uint32_t aDataType) override {} - [[nodiscard]] nsresult BeginResizeDrag(mozilla::WidgetGUIEvent* aEvent, - int32_t aHorizontal, - int32_t aVertical) override { - return NS_ERROR_NOT_IMPLEMENTED; - } nsresult ActivateNativeMenuItemAt(const nsAString& indexString) override { return NS_ERROR_NOT_IMPLEMENTED; } @@ -638,10 +633,10 @@ class nsBaseWidget : public nsIWidget, public nsSupportsWeakReference { * a new MultiTouchInput object that is ready to be dispatched. */ mozilla::MultiTouchInput UpdateSynthesizedTouchState( - mozilla::MultiTouchInput* aState, uint32_t aTime, - mozilla::TimeStamp aTimeStamp, uint32_t aPointerId, - TouchPointerState aPointerState, LayoutDeviceIntPoint aPoint, - double aPointerPressure, uint32_t aPointerOrientation); + mozilla::MultiTouchInput* aState, mozilla::TimeStamp aTimeStamp, + uint32_t aPointerId, TouchPointerState aPointerState, + LayoutDeviceIntPoint aPoint, double aPointerPressure, + uint32_t aPointerOrientation); /** * Dispatch the given MultiTouchInput through APZ to Gecko (if APZ is enabled) diff --git a/widget/nsGUIEventIPC.h b/widget/nsGUIEventIPC.h index f23a142a08c9..ad9c1887c6c9 100644 --- a/widget/nsGUIEventIPC.h +++ b/widget/nsGUIEventIPC.h @@ -55,7 +55,6 @@ struct ParamTraits { WriteParam(aWriter, aParam.mMessage); WriteParam(aWriter, aParam.mRefPoint); WriteParam(aWriter, aParam.mFocusSequenceNumber); - WriteParam(aWriter, aParam.mTime); WriteParam(aWriter, aParam.mTimeStamp); WriteParam(aWriter, aParam.mFlags); WriteParam(aWriter, aParam.mLayersId); @@ -67,7 +66,6 @@ struct ParamTraits { ReadParam(aReader, &aResult->mMessage) && ReadParam(aReader, &aResult->mRefPoint) && ReadParam(aReader, &aResult->mFocusSequenceNumber) && - ReadParam(aReader, &aResult->mTime) && ReadParam(aReader, &aResult->mTimeStamp) && ReadParam(aReader, &aResult->mFlags) && ReadParam(aReader, &aResult->mLayersId); @@ -998,7 +996,6 @@ struct ParamTraits { static void Write(MessageWriter* aWriter, const paramType& aParam) { WriteParam(aWriter, aParam.mInputType); - WriteParam(aWriter, aParam.mTime); WriteParam(aWriter, aParam.mTimeStamp); WriteParam(aWriter, aParam.modifiers); WriteParam(aWriter, aParam.mFocusSequenceNumber); @@ -1007,7 +1004,6 @@ struct ParamTraits { static bool Read(MessageReader* aReader, paramType* aResult) { return ReadParam(aReader, &aResult->mInputType) && - ReadParam(aReader, &aResult->mTime) && ReadParam(aReader, &aResult->mTimeStamp) && ReadParam(aReader, &aResult->modifiers) && ReadParam(aReader, &aResult->mFocusSequenceNumber) && diff --git a/widget/nsIWidget.h b/widget/nsIWidget.h index 47e7bd3ba149..6ebdf2ef34a6 100644 --- a/widget/nsIWidget.h +++ b/widget/nsIWidget.h @@ -1459,13 +1459,6 @@ class nsIWidget : public nsISupports { */ virtual bool ShowsResizeIndicator(LayoutDeviceIntRect* aResizerRect) = 0; - /** - * Begin a window resizing drag, based on the event passed in. - */ - [[nodiscard]] virtual nsresult BeginResizeDrag( - mozilla::WidgetGUIEvent* aEvent, int32_t aHorizontal, - int32_t aVertical) = 0; - // TODO: Make this an enum class with MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS or // EnumSet class. enum Modifiers : uint32_t { diff --git a/widget/windows/DirectManipulationOwner.cpp b/widget/windows/DirectManipulationOwner.cpp index bd56ed132b99..340024a911f3 100644 --- a/widget/windows/DirectManipulationOwner.cpp +++ b/widget/windows/DirectManipulationOwner.cpp @@ -424,7 +424,6 @@ bool DManipEventHandler::SendPinch(Phase aPhase, float aScale) { MOZ_ASSERT_UNREACHABLE("handle all enum values"); } - PRIntervalTime eventIntervalTime = PR_IntervalNow(); TimeStamp eventTimeStamp = TimeStamp::Now(); ModifierKeyState modifierKeyState; @@ -442,7 +441,6 @@ bool DManipEventHandler::SendPinch(Phase aPhase, float aScale) { PinchGestureInput event{pinchGestureType, PinchGestureInput::TRACKPAD, - eventIntervalTime, eventTimeStamp, screenOffset, position, @@ -518,15 +516,10 @@ void DManipEventHandler::SendPanCommon(nsWindow* aWindow, Phase aPhase, } } - PRIntervalTime eventIntervalTime = PR_IntervalNow(); TimeStamp eventTimeStamp = TimeStamp::Now(); - PanGestureInput event{panGestureType, - eventIntervalTime, - eventTimeStamp, - aPosition, - ScreenPoint(aDeltaX, aDeltaY), - aMods}; + PanGestureInput event{panGestureType, eventTimeStamp, aPosition, + ScreenPoint(aDeltaX, aDeltaY), aMods}; aWindow->SendAnAPZEvent(event); } diff --git a/widget/windows/nsWindow.cpp b/widget/windows/nsWindow.cpp index 6ba5460f24bb..a58cb1e83fe2 100644 --- a/widget/windows/nsWindow.cpp +++ b/widget/windows/nsWindow.cpp @@ -1937,8 +1937,7 @@ void nsWindow::SetInputRegion(const InputRegion& aInputRegion) { /************************************************************** * - * SECTION: nsIWidget::Move, nsIWidget::Resize, - * nsIWidget::Size, nsIWidget::BeginResizeDrag + * SECTION: nsIWidget::Move, nsIWidget::Resize, nsIWidget::Size * * Repositioning and sizing a window. * @@ -2249,61 +2248,6 @@ mozilla::Maybe nsWindow::IsResizingNativeWidget() { return Some(false); } -nsresult nsWindow::BeginResizeDrag(WidgetGUIEvent* aEvent, int32_t aHorizontal, - int32_t aVertical) { - NS_ENSURE_ARG_POINTER(aEvent); - - if (aEvent->mClass != eMouseEventClass) { - // you can only begin a resize drag with a mouse event - return NS_ERROR_INVALID_ARG; - } - - if (aEvent->AsMouseEvent()->mButton != MouseButton::ePrimary) { - // you can only begin a resize drag with the left mouse button - return NS_ERROR_INVALID_ARG; - } - - // work out what sizemode we're talking about - WPARAM syscommand; - if (aVertical < 0) { - if (aHorizontal < 0) { - syscommand = SC_SIZE | WMSZ_TOPLEFT; - } else if (aHorizontal == 0) { - syscommand = SC_SIZE | WMSZ_TOP; - } else { - syscommand = SC_SIZE | WMSZ_TOPRIGHT; - } - } else if (aVertical == 0) { - if (aHorizontal < 0) { - syscommand = SC_SIZE | WMSZ_LEFT; - } else if (aHorizontal == 0) { - return NS_ERROR_INVALID_ARG; - } else { - syscommand = SC_SIZE | WMSZ_RIGHT; - } - } else { - if (aHorizontal < 0) { - syscommand = SC_SIZE | WMSZ_BOTTOMLEFT; - } else if (aHorizontal == 0) { - syscommand = SC_SIZE | WMSZ_BOTTOM; - } else { - syscommand = SC_SIZE | WMSZ_BOTTOMRIGHT; - } - } - - // resizing doesn't work if the mouse is already captured - CaptureMouse(false); - - // find the top-level window - HWND toplevelWnd = WinUtils::GetTopLevelHWND(mWnd, true); - - // tell Windows to start the resize - ::PostMessage(toplevelWnd, WM_SYSCOMMAND, syscommand, - POINTTOPOINTS(aEvent->mRefPoint)); - - return NS_OK; -} - /************************************************************** * * SECTION: Window Z-order and state. @@ -4325,7 +4269,7 @@ void nsWindow::InitEvent(WidgetGUIEvent& event, LayoutDeviceIntPoint* aPoint) { WidgetEventTime nsWindow::CurrentMessageWidgetEventTime() const { LONG messageTime = ::GetMessageTime(); - return WidgetEventTime(messageTime, GetMessageTimeStamp(messageTime)); + return WidgetEventTime(GetMessageTimeStamp(messageTime)); } /************************************************************** @@ -7291,8 +7235,8 @@ Maybe nsWindow::ConvertTouchToPanGesture( // We need to negate the displacement because for a touch event, moving the // fingers down results in scrolling up, but for a touchpad gesture, we want // moving the fingers down to result in scrolling down. - PanGestureInput result(eventType, aTouchInput.mTime, aTouchInput.mTimeStamp, - focusPoint, -displacement, aTouchInput.modifiers); + PanGestureInput result(eventType, aTouchInput.mTimeStamp, focusPoint, + -displacement, aTouchInput.modifiers); result.mSimulateMomentum = true; return Some(result); @@ -7335,8 +7279,7 @@ bool nsWindow::OnTouch(WPARAM wParam, LPARAM lParam) { if (touchInput.mTimeStamp.IsNull()) { // Initialize a touch event to send. touchInput.mType = MultiTouchInput::MULTITOUCH_MOVE; - touchInput.mTime = ::GetMessageTime(); - touchInput.mTimeStamp = GetMessageTimeStamp(touchInput.mTime); + touchInput.mTimeStamp = GetMessageTimeStamp(::GetMessageTime()); ModifierKeyState modifierKeyState; touchInput.modifiers = modifierKeyState.GetModifiers(); } @@ -7354,8 +7297,7 @@ bool nsWindow::OnTouch(WPARAM wParam, LPARAM lParam) { if (touchEndInput.mTimeStamp.IsNull()) { // Initialize a touch event to send. touchEndInput.mType = MultiTouchInput::MULTITOUCH_END; - touchEndInput.mTime = ::GetMessageTime(); - touchEndInput.mTimeStamp = GetMessageTimeStamp(touchEndInput.mTime); + touchEndInput.mTimeStamp = GetMessageTimeStamp(::GetMessageTime()); ModifierKeyState modifierKeyState; touchEndInput.modifiers = modifierKeyState.GetModifiers(); } @@ -7429,8 +7371,7 @@ bool nsWindow::OnGesture(WPARAM wParam, LPARAM lParam) { modifierKeyState.InitInputEvent(wheelEvent); wheelEvent.mButton = 0; - wheelEvent.mTime = ::GetMessageTime(); - wheelEvent.mTimeStamp = GetMessageTimeStamp(wheelEvent.mTime); + wheelEvent.mTimeStamp = GetMessageTimeStamp(::GetMessageTime()); wheelEvent.mInputSource = MouseEvent_Binding::MOZ_SOURCE_TOUCH; bool endFeedback = true; @@ -7464,8 +7405,7 @@ bool nsWindow::OnGesture(WPARAM wParam, LPARAM lParam) { ModifierKeyState modifierKeyState; modifierKeyState.InitInputEvent(event); event.mButton = 0; - event.mTime = ::GetMessageTime(); - event.mTimeStamp = GetMessageTimeStamp(event.mTime); + event.mTimeStamp = GetMessageTimeStamp(::GetMessageTime()); event.mInputSource = MouseEvent_Binding::MOZ_SOURCE_TOUCH; nsEventStatus status; @@ -8804,9 +8744,7 @@ bool nsWindow::DispatchTouchEventFromWMPointer( MultiTouchInput touchInput; touchInput.mType = touchType; - touchInput.mTime = ::GetMessageTime(); - touchInput.mTimeStamp = - GetMessageTimeStamp(static_cast(touchInput.mTime)); + touchInput.mTimeStamp = GetMessageTimeStamp(::GetMessageTime()); touchInput.mTouches.AppendElement(touchData); touchInput.mButton = aButton; touchInput.mButtons = aPointerInfo.mButtons; @@ -9129,7 +9067,7 @@ nsresult nsWindow::SynthesizeNativeTouchPoint( WidgetEventTime time = CurrentMessageWidgetEventTime(); LayoutDeviceIntPoint pointInWindow = aPoint - WidgetToScreenOffset(); MultiTouchInput inputToDispatch = UpdateSynthesizedTouchState( - mSynthesizedTouchInput.get(), time.mTime, time.mTimeStamp, aPointerId, + mSynthesizedTouchInput.get(), time.mTimeStamp, aPointerId, aPointerState, pointInWindow, aPointerPressure, aPointerOrientation); DispatchTouchInput(inputToDispatch); return NS_OK; diff --git a/widget/windows/nsWindow.h b/widget/windows/nsWindow.h index cfb1548ad35b..782867945db4 100644 --- a/widget/windows/nsWindow.h +++ b/widget/windows/nsWindow.h @@ -190,9 +190,6 @@ class nsWindow final : public nsBaseWidget { void Resize(double aX, double aY, double aWidth, double aHeight, bool aRepaint) override; mozilla::Maybe IsResizingNativeWidget() override; - [[nodiscard]] nsresult BeginResizeDrag(mozilla::WidgetGUIEvent* aEvent, - int32_t aHorizontal, - int32_t aVertical) override; void PlaceBehind(nsTopLevelWidgetZPlacement aPlacement, nsIWidget* aWidget, bool aActivate) override; void SetSizeMode(nsSizeMode aMode) override;