Bug 1809774: Simplify PointerEvent.webidl because RFP doesn't need the callertype r=edgar

Differential Revision: https://phabricator.services.mozilla.com/D166625
This commit is contained in:
Tom Ritter 2023-02-07 23:53:19 +00:00
Родитель 357a4ffe21
Коммит 41db83c9f3
3 изменённых файлов: 33 добавлений и 54 удалений

Просмотреть файл

@ -138,14 +138,13 @@ NS_INTERFACE_MAP_END_INHERITING(MouseEvent)
NS_IMPL_ADDREF_INHERITED(PointerEvent, MouseEvent)
NS_IMPL_RELEASE_INHERITED(PointerEvent, MouseEvent)
void PointerEvent::GetPointerType(nsAString& aPointerType,
CallerType aCallerType) {
void PointerEvent::GetPointerType(nsAString& aPointerType) {
if (mPointerType.isSome()) {
aPointerType = mPointerType.value();
return;
}
if (ShouldResistFingerprinting(aCallerType)) {
if (ShouldResistFingerprinting()) {
aPointerType.AssignLiteral("mouse");
return;
}
@ -154,27 +153,22 @@ void PointerEvent::GetPointerType(nsAString& aPointerType,
aPointerType);
}
int32_t PointerEvent::PointerId(CallerType aCallerType) {
return ShouldResistFingerprinting(aCallerType)
int32_t PointerEvent::PointerId() {
return ShouldResistFingerprinting()
? PointerEventHandler::GetSpoofedPointerIdForRFP()
: mEvent->AsPointerEvent()->pointerId;
}
int32_t PointerEvent::Width(CallerType aCallerType) {
return ShouldResistFingerprinting(aCallerType)
? 1
: mEvent->AsPointerEvent()->mWidth;
int32_t PointerEvent::Width() {
return ShouldResistFingerprinting() ? 1 : mEvent->AsPointerEvent()->mWidth;
}
int32_t PointerEvent::Height(CallerType aCallerType) {
return ShouldResistFingerprinting(aCallerType)
? 1
: mEvent->AsPointerEvent()->mHeight;
int32_t PointerEvent::Height() {
return ShouldResistFingerprinting() ? 1 : mEvent->AsPointerEvent()->mHeight;
}
float PointerEvent::Pressure(CallerType aCallerType) {
if (mEvent->mMessage == ePointerUp ||
!ShouldResistFingerprinting(aCallerType)) {
float PointerEvent::Pressure() {
if (mEvent->mMessage == ePointerUp || !ShouldResistFingerprinting()) {
return mEvent->AsPointerEvent()->mPressure;
}
@ -191,28 +185,22 @@ float PointerEvent::Pressure(CallerType aCallerType) {
return spoofedPressure;
}
float PointerEvent::TangentialPressure(CallerType aCallerType) {
return ShouldResistFingerprinting(aCallerType)
float PointerEvent::TangentialPressure() {
return ShouldResistFingerprinting()
? 0
: mEvent->AsPointerEvent()->tangentialPressure;
}
int32_t PointerEvent::TiltX(CallerType aCallerType) {
return ShouldResistFingerprinting(aCallerType)
? 0
: mEvent->AsPointerEvent()->tiltX;
int32_t PointerEvent::TiltX() {
return ShouldResistFingerprinting() ? 0 : mEvent->AsPointerEvent()->tiltX;
}
int32_t PointerEvent::TiltY(CallerType aCallerType) {
return ShouldResistFingerprinting(aCallerType)
? 0
: mEvent->AsPointerEvent()->tiltY;
int32_t PointerEvent::TiltY() {
return ShouldResistFingerprinting() ? 0 : mEvent->AsPointerEvent()->tiltY;
}
int32_t PointerEvent::Twist(CallerType aCallerType) {
return ShouldResistFingerprinting(aCallerType)
? 0
: mEvent->AsPointerEvent()->twist;
int32_t PointerEvent::Twist() {
return ShouldResistFingerprinting() ? 0 : mEvent->AsPointerEvent()->twist;
}
bool PointerEvent::IsPrimary() { return mEvent->AsPointerEvent()->mIsPrimary; }
@ -275,17 +263,17 @@ void PointerEvent::GetPredictedEvents(
aPointerEvents.AppendElements(mPredictedEvents);
}
bool PointerEvent::ShouldResistFingerprinting(CallerType aCallerType) {
// There are four situations we don't need to spoof this pointer event.
bool PointerEvent::ShouldResistFingerprinting() {
// There are three simple situations we don't need to spoof this pointer
// event.
// 1. The pref privcy.resistFingerprinting' is false, we fast return here
// since we don't need to do any QI of following codes.
// 2. This event is generated by scripts.
// 3. This event is a mouse pointer event.
// 4. The caller type is system.
// We don't need to check for the system group since pointer events won't be
// dispatched to the system group.
if (!nsContentUtils::ShouldResistFingerprinting() || !mEvent->IsTrusted() ||
aCallerType == CallerType::System ||
if (!nsContentUtils::ShouldResistFingerprinting("Efficiency Check") ||
!mEvent->IsTrusted() ||
mEvent->AsPointerEvent()->mInputSource ==
MouseEvent_Binding::MOZ_SOURCE_MOUSE) {
return false;

Просмотреть файл

@ -38,16 +38,16 @@ class PointerEvent : public MouseEvent {
EventTarget* aOwner, const nsAString& aType,
const PointerEventInit& aParam);
int32_t PointerId(CallerType aCallerType);
int32_t Width(CallerType aCallerType);
int32_t Height(CallerType aCallerType);
float Pressure(CallerType aCallerType);
float TangentialPressure(CallerType aCallerType);
int32_t TiltX(CallerType aCallerType);
int32_t TiltY(CallerType aCallerType);
int32_t Twist(CallerType aCallerType);
int32_t PointerId();
int32_t Width();
int32_t Height();
float Pressure();
float TangentialPressure();
int32_t TiltX();
int32_t TiltY();
int32_t Twist();
bool IsPrimary();
void GetPointerType(nsAString& aPointerType, CallerType aCallerType);
void GetPointerType(nsAString& aPointerType);
void GetCoalescedEvents(nsTArray<RefPtr<PointerEvent>>& aPointerEvents);
void GetPredictedEvents(nsTArray<RefPtr<PointerEvent>>& aPointerEvents);
@ -57,7 +57,7 @@ class PointerEvent : public MouseEvent {
private:
// This method returns the boolean to indicate whether spoofing pointer
// event for fingerprinting resistance.
bool ShouldResistFingerprinting(CallerType aCallerType);
bool ShouldResistFingerprinting();
nsTArray<RefPtr<PointerEvent>> mCoalescedEvents;
nsTArray<RefPtr<PointerEvent>> mPredictedEvents;

Просмотреть файл

@ -14,25 +14,16 @@ interface PointerEvent : MouseEvent
{
constructor(DOMString type, optional PointerEventInit eventInitDict = {});
[NeedsCallerType]
readonly attribute long pointerId;
[NeedsCallerType]
readonly attribute long width;
[NeedsCallerType]
readonly attribute long height;
[NeedsCallerType]
readonly attribute float pressure;
[NeedsCallerType]
readonly attribute float tangentialPressure;
[NeedsCallerType]
readonly attribute long tiltX;
[NeedsCallerType]
readonly attribute long tiltY;
[NeedsCallerType]
readonly attribute long twist;
[NeedsCallerType]
readonly attribute DOMString pointerType;
readonly attribute boolean isPrimary;
sequence<PointerEvent> getCoalescedEvents();