Open Bug 1680669 Opened 4 years ago Updated 2 months ago

New wpt failures in /pointerevents/pointerevent_fractional_coordinates.html

Categories

(Core :: DOM: Events, defect)

defect

Tracking

()

ASSIGNED

People

(Reporter: wpt-sync, Assigned: masayuki)

References

(Depends on 1 open bug, Blocks 2 open bugs)

Details

(Whiteboard: [wpt])

Attachments

(7 files)

48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review

Syncing wpt PR 26728 found new untriaged test failures in CI

Tests Affected

Firefox-only failures

/pointerevents/pointerevent_fractional_coordinates.html: ERROR

CI Results

Missing results from treeherder
GitHub PR Head

Notes

These updates will be on mozilla-central once bug 1680370 lands.

Note: this bug is for tracking fixing the issues and is not
owned by the wpt sync bot.

This bug is linked to the relevant tests by an annotation in
https://github.com/web-platform-tests/wpt-metadata. These annotations
can be edited using the wpt interop dashboard
https://jgraham.github.io/wptdash/

If this bug is split into multiple bugs, please also update the
annotations, otherwise we are unable to track which wpt issues are
already triaged. Resolving as duplicate or closing this issue should
be cause the bot to automatically update or remove the annotation.

Severity: -- → S3
Depends on: 1644307

It seems that there is no way to make the type switchable in our WebIDL.

So, I wonder, I should change related event types directly to double. Then, at first step, they return integral values. Finally, I add a pref to make them return fractional values. Smaug, what do you think these steps to fix this bug?

Flags: needinfo?(smaug)

Changing type to double but still internally use integer (at least for trusted events) sounds reasonable.

Flags: needinfo?(smaug)
Assignee: nobody → masayuki
Status: NEW → ASSIGNED

Okay, as far as I've investigated the expected results of WPT, trusted events should return integer values in most cases. Only the exception is, transform changed the coordinates. So, this may be safer than what I've thought.

mDefaultClientPoint, mMovementPoint and mPagePoint are used only in
MouseEvent. Therefore, they can be moved to MouseEvent.

MouseEvent and its subclasses need to treat screen/client coordinates with
double variables. Although for the backward compatibility, we'll keep
rounding the value to integer, but we need to support lossless untrusted
event creation. Therefore, they need to store the points with the new point
types.

Depends on D222723

Currently, they use given values or computed values as-is. Therefore, if the
values are fractional values, they are truncated when calling
nsIDOMWindowUtils methods. However, in the most cases, they should be
rounded instead.

Unfortunately, correcting this issue causes that synthesizeNativeMouseEvent
on macOS may cause a mouse event 1-pixel below than expected if offset in an
element is specified. It seems that there is a hidden bug of converting
coordinates somewhere, however, I couldn't find it and this occurs only with
synthesizing native mouse events according to the test results. So, this does
not affect to most tests (no web-platform tests). Let's make this in the
backlog for now.

Depends on D222725

This patch makes the following patch simpler. Therefore, this patch just cast
double coordinates to int32_t points at initializing untrusted events.
Therefore, this does not change any behavior.

Depends on D222726

screenX, screenY, clientX, clientY, x, y, offsetX and offsetY
are now double. This patch makes the event classes aware of DOM events.

Note that screenX and screenY are always integers if the event is trusted
one because WidgetEvent::mRefPoint is LayoutDeviceIntPoint. The other
properties of trusted events may return fractional values.

Currently, Chrome allows fractional values only for pointer events whose type
is not click, auxclick nor contextmenu (this exception is defined by the
Pointer Events). Therefore, this patch does not replace MouseEvent::*Point()
methods with new ones, i.e., keeping the traditional methods to keep the
backward compatibility completely.

I'm not sure about the untrusted events of non-pointer events, click,
auxclick and contextmenu. Chrome does check whether it's trusted or not
before applying std::floor or std::round at getter methods (I think that
using std::round in offsetX and offsetY is their bug at least for
untrusted events). This patch follows them for now but has a pref to allow
for all untrusted events.

Finally, this patch does NOT make the computation completely lossless. I
tried it first, but that causes most pointer event coordinates became fractional
values but such behavior is not expected by webdriver tests in WPT nor some
mochitests. WPTs expect that fractional values are used only when the pointer
event target is on an element which is transformed by CSS. Therefore, this
patch keeps using integer points if a trusted pointer event which is not
click, auxclick nor contextmenu and:

  • the document is transformed or zoomed in the parent document or,
  • the PresShell or DeviceContext is zoomed or,
  • an inclusive ancestor of the primary frame of the event target is transformed
    only when computing offsetX or offsetY

So, if the root frame of the PresShell or the primary frame of the event
target is not transformed nor scaled by any features/settings, clientX,
clientY, pageX, pageY, offsetX and offsetY keep returning integer.

Depends on D222727

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

Depends on D222728

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: