Bug 1382499 - Enhance fingerprinting resistance for Touch API r=arthuredelstein,bz

MozReview-Commit-ID: 8nzOkvIvwrD

--HG--
extra : rebase_source : 15cfa77ffc639838d6345fa4bffc7079d8d198e7
This commit is contained in:
Chung-Sheng Fu 2017-07-31 17:30:38 +08:00
Родитель 45b152f637
Коммит c28d4be7b3
5 изменённых файлов: 59 добавлений и 14 удалений

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

@ -160,6 +160,46 @@ Touch::ScreenY(CallerType aCallerType) const
return mScreenPoint.y;
}
int32_t
Touch::RadiusX(CallerType aCallerType) const
{
if (nsContentUtils::ResistFingerprinting(aCallerType)) {
return 0;
}
return mRadius.x;
}
int32_t
Touch::RadiusY(CallerType aCallerType) const
{
if (nsContentUtils::ResistFingerprinting(aCallerType)) {
return 0;
}
return mRadius.y;
}
float
Touch::RotationAngle(CallerType aCallerType) const
{
if (nsContentUtils::ResistFingerprinting(aCallerType)) {
return 0.0f;
}
return mRotationAngle;
}
float
Touch::Force(CallerType aCallerType) const
{
if (nsContentUtils::ResistFingerprinting(aCallerType)) {
return 0.0f;
}
return mForce;
}
void
Touch::InitializePoints(nsPresContext* aPresContext, WidgetEvent* aEvent)
{
@ -184,10 +224,10 @@ bool
Touch::Equals(Touch* aTouch)
{
return mRefPoint == aTouch->mRefPoint &&
mForce == aTouch->Force() &&
mRotationAngle == aTouch->RotationAngle() &&
mRadius.x == aTouch->RadiusX() &&
mRadius.y == aTouch->RadiusY();
mForce == aTouch->mForce &&
mRotationAngle == aTouch->mRotationAngle &&
mRadius.x == aTouch->mRadius.x &&
mRadius.y == aTouch->mRadius.y;
}
JSObject*

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

@ -74,10 +74,10 @@ public:
int32_t ClientY() const { return mClientPoint.y; }
int32_t PageX() const { return mPagePoint.x; }
int32_t PageY() const { return mPagePoint.y; }
int32_t RadiusX() const { return mRadius.x; }
int32_t RadiusY() const { return mRadius.y; }
float RotationAngle() const { return mRotationAngle; }
float Force() const { return mForce; }
int32_t RadiusX(CallerType aCallerType) const;
int32_t RadiusY(CallerType aCallerType) const;
float RotationAngle(CallerType aCallerType) const;
float Force(CallerType aCallerType) const;
nsCOMPtr<EventTarget> mTarget;
LayoutDeviceIntPoint mRefPoint;

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

@ -38,8 +38,12 @@ interface Touch {
readonly attribute long clientY;
readonly attribute long pageX;
readonly attribute long pageY;
[NeedsCallerType]
readonly attribute long radiusX;
[NeedsCallerType]
readonly attribute long radiusY;
[NeedsCallerType]
readonly attribute float rotationAngle;
[NeedsCallerType]
readonly attribute float force;
};

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

@ -7107,8 +7107,8 @@ DispatchPointerFromMouseOrTouch(PresShell* aShell,
event.pointerId = touch->Identifier();
event.mRefPoint = touch->mRefPoint;
event.mModifiers = touchEvent->mModifiers;
event.mWidth = touch->RadiusX();
event.mHeight = touch->RadiusY();
event.mWidth = touch->RadiusX(CallerType::System);
event.mHeight = touch->RadiusY(CallerType::System);
event.tiltX = touch->tiltX;
event.tiltY = touch->tiltY;
event.mTime = touchEvent->mTime;

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

@ -6,6 +6,7 @@
#include "InputData.h"
#include "mozilla/dom/Touch.h"
#include "nsContentUtils.h"
#include "nsDebug.h"
#include "nsThreadUtils.h"
#include "mozilla/MouseEvents.h"
@ -130,10 +131,10 @@ MultiTouchInput::MultiTouchInput(const WidgetTouchEvent& aTouchEvent)
// Extract data from weird interfaces.
int32_t identifier = domTouch->Identifier();
int32_t radiusX = domTouch->RadiusX();
int32_t radiusY = domTouch->RadiusY();
float rotationAngle = domTouch->RotationAngle();
float force = domTouch->Force();
int32_t radiusX = domTouch->RadiusX(CallerType::System);
int32_t radiusY = domTouch->RadiusY(CallerType::System);
float rotationAngle = domTouch->RotationAngle(CallerType::System);
float force = domTouch->Force(CallerType::System);
SingleTouchData data(identifier,
ViewAs<ScreenPixel>(domTouch->mRefPoint,