diff --git a/dom/base/Element.cpp b/dom/base/Element.cpp index 02488cb791d4..081fc5337cf2 100644 --- a/dom/base/Element.cpp +++ b/dom/base/Element.cpp @@ -3291,7 +3291,7 @@ void Element::DispatchChromeOnlyLinkClickEvent( /* Cancelable */ true, nsGlobalWindowInner::Cast(doc->GetInnerWindow()), 0, mouseEvent->CtrlKey(), mouseEvent->AltKey(), mouseEvent->ShiftKey(), mouseEvent->MetaKey(), mouseEvent->Button(), mouseDOMEvent, - mouseEvent->InputSource(), IgnoreErrors()); + mouseEvent->InputSource(CallerType::System), IgnoreErrors()); // Note: we're always trusted, but the event we pass as the `sourceEvent` // might not be. Frontend code will check that event's trusted property to // make that determination; doing it this way means we don't also start diff --git a/dom/events/MouseEvent.cpp b/dom/events/MouseEvent.cpp index 0a50a5c7296b..ccd71922619f 100644 --- a/dom/events/MouseEvent.cpp +++ b/dom/events/MouseEvent.cpp @@ -298,11 +298,22 @@ bool MouseEvent::ShiftKey() { return mEvent->AsInputEvent()->IsShift(); } bool MouseEvent::MetaKey() { return mEvent->AsInputEvent()->IsMeta(); } -float MouseEvent::MozPressure() const { +float MouseEvent::MozPressure(CallerType aCallerType) const { + if (nsContentUtils::ShouldResistFingerprinting(aCallerType, GetParentObject(), + RFPTarget::PointerEvents)) { + // Use the spoofed value from PointerEvent::Pressure + return 0.5; + } + return mEvent->AsMouseEventBase()->mPressure; } -uint16_t MouseEvent::InputSource() const { +uint16_t MouseEvent::InputSource(CallerType aCallerType) const { + if (nsContentUtils::ShouldResistFingerprinting(aCallerType, GetParentObject(), + RFPTarget::PointerEvents)) { + return MouseEvent_Binding::MOZ_SOURCE_MOUSE; + } + return mEvent->AsMouseEventBase()->mInputSource; } diff --git a/dom/events/MouseEvent.h b/dom/events/MouseEvent.h index 0695c1e264b4..bb0f63bad007 100644 --- a/dom/events/MouseEvent.h +++ b/dom/events/MouseEvent.h @@ -82,8 +82,8 @@ class MouseEvent : public UIEvent { const MouseEventInit& aParam); int32_t MovementX() { return GetMovementPoint().x; } int32_t MovementY() { return GetMovementPoint().y; } - float MozPressure() const; - uint16_t InputSource() const; + float MozPressure(CallerType) const; + uint16_t InputSource(CallerType) const; void InitNSMouseEvent(const nsAString& aType, bool aCanBubble, bool aCancelable, nsGlobalWindowInner* aView, int32_t aDetail, int32_t aScreenX, int32_t aScreenY, diff --git a/dom/webidl/MouseEvent.webidl b/dom/webidl/MouseEvent.webidl index 979c05ca4961..a5fbb8b38dc8 100644 --- a/dom/webidl/MouseEvent.webidl +++ b/dom/webidl/MouseEvent.webidl @@ -92,7 +92,7 @@ partial interface MouseEvent // Finger or touch pressure event value // ranges between 0.0 and 1.0 // TODO: Remove mozPressure. (bug 1534199) - [Deprecated="MouseEvent_MozPressure"] + [NeedsCallerType, Deprecated="MouseEvent_MozPressure"] readonly attribute float mozPressure; const unsigned short MOZ_SOURCE_UNKNOWN = 0; @@ -103,10 +103,10 @@ partial interface MouseEvent const unsigned short MOZ_SOURCE_TOUCH = 5; const unsigned short MOZ_SOURCE_KEYBOARD = 6; - [ChromeOnly] + [NeedsCallerType, ChromeOnly] readonly attribute unsigned short inputSource; - [Deprecated="MozInputSource", BinaryName="inputSource"] + [NeedsCallerType, Deprecated="MozInputSource", BinaryName="inputSource"] readonly attribute unsigned short mozInputSource; // TODO: Remove initNSMouseEvent. (bug 1165213) diff --git a/layout/forms/HTMLSelectEventListener.cpp b/layout/forms/HTMLSelectEventListener.cpp index 8c74c57cc009..10ed410ee0eb 100644 --- a/layout/forms/HTMLSelectEventListener.cpp +++ b/layout/forms/HTMLSelectEventListener.cpp @@ -412,7 +412,10 @@ nsresult HTMLSelectEventListener::MouseDown(dom::Event* aMouseEvent) { } if (mIsCombobox) { - uint16_t inputSource = mouseEvent->InputSource(); + // inputSource is used to apply padding for touch events, but + // the dropdown is rendered in another process, the webpage won't + // have access to it. It is fine to use CallerType::System here. + uint16_t inputSource = mouseEvent->InputSource(CallerType::System); if (mElement->OpenInParentProcess()) { nsCOMPtr target = do_QueryInterface(aMouseEvent->GetTarget()); if (target && target->IsHTMLElement(nsGkAtoms::option)) { diff --git a/widget/nsBaseDragService.cpp b/widget/nsBaseDragService.cpp index 98c77b4bbe3d..26d23f2f56dc 100644 --- a/widget/nsBaseDragService.cpp +++ b/widget/nsBaseDragService.cpp @@ -423,7 +423,7 @@ nsBaseDragService::InvokeDragSessionWithImage( mSourceWindowContext ? mSourceWindowContext->TopWindowContext() : nullptr; mScreenPosition = aDragEvent->ScreenPoint(CallerType::System); - mInputSource = aDragEvent->InputSource(); + mInputSource = aDragEvent->InputSource(CallerType::System); // If dragging within a XUL tree and no custom drag image was // set, the region argument to InvokeDragSessionWithImage needs @@ -472,7 +472,7 @@ nsBaseDragService::InvokeDragSessionWithRemoteImage( mSourceTopWindowContext = mDragStartData->GetSourceTopWindowContext(); mScreenPosition = aDragEvent->ScreenPoint(CallerType::System); - mInputSource = aDragEvent->InputSource(); + mInputSource = aDragEvent->InputSource(CallerType::System); nsresult rv = InvokeDragSession( aDOMNode, aPrincipal, aCsp, aCookieJarSettings, aTransferableArray, @@ -504,7 +504,7 @@ nsBaseDragService::InvokeDragSessionWithSelection( mScreenPosition.x = aDragEvent->ScreenX(CallerType::System); mScreenPosition.y = aDragEvent->ScreenY(CallerType::System); - mInputSource = aDragEvent->InputSource(); + mInputSource = aDragEvent->InputSource(CallerType::System); // just get the focused node from the selection // XXXndeakin this should actually be the deepest node that contains both