Bug 1871789 - Spoof mozInputSource and mozPressure for RFP. r=tjr,webidl,smaug
Differential Revision: https://phabricator.services.mozilla.com/D209543
This commit is contained in:
@@ -3291,7 +3291,7 @@ void Element::DispatchChromeOnlyLinkClickEvent(
|
|||||||
/* Cancelable */ true, nsGlobalWindowInner::Cast(doc->GetInnerWindow()),
|
/* Cancelable */ true, nsGlobalWindowInner::Cast(doc->GetInnerWindow()),
|
||||||
0, mouseEvent->CtrlKey(), mouseEvent->AltKey(), mouseEvent->ShiftKey(),
|
0, mouseEvent->CtrlKey(), mouseEvent->AltKey(), mouseEvent->ShiftKey(),
|
||||||
mouseEvent->MetaKey(), mouseEvent->Button(), mouseDOMEvent,
|
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`
|
// 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
|
// 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
|
// make that determination; doing it this way means we don't also start
|
||||||
|
|||||||
@@ -298,11 +298,22 @@ bool MouseEvent::ShiftKey() { return mEvent->AsInputEvent()->IsShift(); }
|
|||||||
|
|
||||||
bool MouseEvent::MetaKey() { return mEvent->AsInputEvent()->IsMeta(); }
|
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;
|
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;
|
return mEvent->AsMouseEventBase()->mInputSource;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -82,8 +82,8 @@ class MouseEvent : public UIEvent {
|
|||||||
const MouseEventInit& aParam);
|
const MouseEventInit& aParam);
|
||||||
int32_t MovementX() { return GetMovementPoint().x; }
|
int32_t MovementX() { return GetMovementPoint().x; }
|
||||||
int32_t MovementY() { return GetMovementPoint().y; }
|
int32_t MovementY() { return GetMovementPoint().y; }
|
||||||
float MozPressure() const;
|
float MozPressure(CallerType) const;
|
||||||
uint16_t InputSource() const;
|
uint16_t InputSource(CallerType) const;
|
||||||
void InitNSMouseEvent(const nsAString& aType, bool aCanBubble,
|
void InitNSMouseEvent(const nsAString& aType, bool aCanBubble,
|
||||||
bool aCancelable, nsGlobalWindowInner* aView,
|
bool aCancelable, nsGlobalWindowInner* aView,
|
||||||
int32_t aDetail, int32_t aScreenX, int32_t aScreenY,
|
int32_t aDetail, int32_t aScreenX, int32_t aScreenY,
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ partial interface MouseEvent
|
|||||||
// Finger or touch pressure event value
|
// Finger or touch pressure event value
|
||||||
// ranges between 0.0 and 1.0
|
// ranges between 0.0 and 1.0
|
||||||
// TODO: Remove mozPressure. (bug 1534199)
|
// TODO: Remove mozPressure. (bug 1534199)
|
||||||
[Deprecated="MouseEvent_MozPressure"]
|
[NeedsCallerType, Deprecated="MouseEvent_MozPressure"]
|
||||||
readonly attribute float mozPressure;
|
readonly attribute float mozPressure;
|
||||||
|
|
||||||
const unsigned short MOZ_SOURCE_UNKNOWN = 0;
|
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_TOUCH = 5;
|
||||||
const unsigned short MOZ_SOURCE_KEYBOARD = 6;
|
const unsigned short MOZ_SOURCE_KEYBOARD = 6;
|
||||||
|
|
||||||
[ChromeOnly]
|
[NeedsCallerType, ChromeOnly]
|
||||||
readonly attribute unsigned short inputSource;
|
readonly attribute unsigned short inputSource;
|
||||||
|
|
||||||
[Deprecated="MozInputSource", BinaryName="inputSource"]
|
[NeedsCallerType, Deprecated="MozInputSource", BinaryName="inputSource"]
|
||||||
readonly attribute unsigned short mozInputSource;
|
readonly attribute unsigned short mozInputSource;
|
||||||
|
|
||||||
// TODO: Remove initNSMouseEvent. (bug 1165213)
|
// TODO: Remove initNSMouseEvent. (bug 1165213)
|
||||||
|
|||||||
@@ -412,7 +412,10 @@ nsresult HTMLSelectEventListener::MouseDown(dom::Event* aMouseEvent) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (mIsCombobox) {
|
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()) {
|
if (mElement->OpenInParentProcess()) {
|
||||||
nsCOMPtr<nsIContent> target = do_QueryInterface(aMouseEvent->GetTarget());
|
nsCOMPtr<nsIContent> target = do_QueryInterface(aMouseEvent->GetTarget());
|
||||||
if (target && target->IsHTMLElement(nsGkAtoms::option)) {
|
if (target && target->IsHTMLElement(nsGkAtoms::option)) {
|
||||||
|
|||||||
@@ -423,7 +423,7 @@ nsBaseDragService::InvokeDragSessionWithImage(
|
|||||||
mSourceWindowContext ? mSourceWindowContext->TopWindowContext() : nullptr;
|
mSourceWindowContext ? mSourceWindowContext->TopWindowContext() : nullptr;
|
||||||
|
|
||||||
mScreenPosition = aDragEvent->ScreenPoint(CallerType::System);
|
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
|
// If dragging within a XUL tree and no custom drag image was
|
||||||
// set, the region argument to InvokeDragSessionWithImage needs
|
// set, the region argument to InvokeDragSessionWithImage needs
|
||||||
@@ -472,7 +472,7 @@ nsBaseDragService::InvokeDragSessionWithRemoteImage(
|
|||||||
mSourceTopWindowContext = mDragStartData->GetSourceTopWindowContext();
|
mSourceTopWindowContext = mDragStartData->GetSourceTopWindowContext();
|
||||||
|
|
||||||
mScreenPosition = aDragEvent->ScreenPoint(CallerType::System);
|
mScreenPosition = aDragEvent->ScreenPoint(CallerType::System);
|
||||||
mInputSource = aDragEvent->InputSource();
|
mInputSource = aDragEvent->InputSource(CallerType::System);
|
||||||
|
|
||||||
nsresult rv = InvokeDragSession(
|
nsresult rv = InvokeDragSession(
|
||||||
aDOMNode, aPrincipal, aCsp, aCookieJarSettings, aTransferableArray,
|
aDOMNode, aPrincipal, aCsp, aCookieJarSettings, aTransferableArray,
|
||||||
@@ -504,7 +504,7 @@ nsBaseDragService::InvokeDragSessionWithSelection(
|
|||||||
|
|
||||||
mScreenPosition.x = aDragEvent->ScreenX(CallerType::System);
|
mScreenPosition.x = aDragEvent->ScreenX(CallerType::System);
|
||||||
mScreenPosition.y = aDragEvent->ScreenY(CallerType::System);
|
mScreenPosition.y = aDragEvent->ScreenY(CallerType::System);
|
||||||
mInputSource = aDragEvent->InputSource();
|
mInputSource = aDragEvent->InputSource(CallerType::System);
|
||||||
|
|
||||||
// just get the focused node from the selection
|
// just get the focused node from the selection
|
||||||
// XXXndeakin this should actually be the deepest node that contains both
|
// XXXndeakin this should actually be the deepest node that contains both
|
||||||
|
|||||||
Reference in New Issue
Block a user