Skip to content

Commit

Permalink
Bug 1680669 - part 7: Change the type of width and height of `Poi…
Browse files Browse the repository at this point in the history
…nterEvent` to `double` r=smaug

The values may be used with the coords of `MouseEvent`.  Therefore, they need
to be `double` right now.

Differential Revision: https://phabricator.services.mozilla.com/D222729
  • Loading branch information
masayuki-nakano committed Dec 3, 2024
1 parent 71ada50 commit 0e81686
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 12 deletions.
8 changes: 4 additions & 4 deletions dom/events/PointerEvent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,12 +246,12 @@ int32_t PointerEvent::PointerId() {
: mEvent->AsPointerEvent()->pointerId;
}

int32_t PointerEvent::Width() {
return ShouldResistFingerprinting() ? 1 : mEvent->AsPointerEvent()->mWidth;
double PointerEvent::Width() const {
return ShouldResistFingerprinting() ? 1.0 : mEvent->AsPointerEvent()->mWidth;
}

int32_t PointerEvent::Height() {
return ShouldResistFingerprinting() ? 1 : mEvent->AsPointerEvent()->mHeight;
double PointerEvent::Height() const {
return ShouldResistFingerprinting() ? 1.0 : mEvent->AsPointerEvent()->mHeight;
}

float PointerEvent::Pressure() {
Expand Down
4 changes: 2 additions & 2 deletions dom/events/PointerEvent.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ class PointerEvent : public MouseEvent {
PointerEvent* AsPointerEvent() final { return this; }

int32_t PointerId();
int32_t Width();
int32_t Height();
double Width() const;
double Height() const;
float Pressure();
float TangentialPressure();
int32_t TiltX();
Expand Down
8 changes: 4 additions & 4 deletions dom/webidl/PointerEvent.webidl
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ interface PointerEvent : MouseEvent

readonly attribute long pointerId;

readonly attribute long width;
readonly attribute long height;
readonly attribute double width;
readonly attribute double height;
readonly attribute float pressure;
readonly attribute float tangentialPressure;
readonly attribute long tiltX;
Expand All @@ -35,8 +35,8 @@ interface PointerEvent : MouseEvent
dictionary PointerEventInit : MouseEventInit
{
long pointerId = 0;
long width = 1;
long height = 1;
double width = 1.0;
double height = 1.0;
float pressure = 0;
float tangentialPressure = 0;
long tiltX;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,30 @@
testFlooredMatch("-1.5 - -1.0", data.cls, event, smallerNegativeDict2);
}
}

const dictAlwaysDouble = {
width: 0.111111111111,
height: 0.222222222222,
};

function testExactlyMatchAlwaysDouble(event, dict) {
test(() => {
assert_equals(event["width"], dict["width"]);
}, `PointerEvent.${event.type}.width`);
test(() => {
assert_equals(event["height"], dict["height"]);
}, `PointerEvent.${event.type}.height`);
}

for (const type of ["pointerdown", "pointerup", "pointermove", "pointercancel",
"gotpointercapture", "lostpointercapture",
"pointerrawupdate",
"pointerover", "pointerout", "pointerenter", "pointerleave",
"foo"]) {
const event = new PointerEvent(type, dictAlwaysDouble);
testExactlyMatchAlwaysDouble(event, dictAlwaysDouble);
}

</script>
</head>
<body></body>
Expand Down
4 changes: 2 additions & 2 deletions widget/MouseEvents.h
Original file line number Diff line number Diff line change
Expand Up @@ -847,8 +847,8 @@ class WidgetPointerEvent : public WidgetMouseEvent {
return result;
}

int32_t mWidth = 1;
int32_t mHeight = 1;
double mWidth = 1.0;
double mHeight = 1.0;
bool mIsPrimary = true;
bool mFromTouchEvent = false;

Expand Down

0 comments on commit 0e81686

Please sign in to comment.