Commit cbcec26c authored by Liviu Tinta's avatar Liviu Tinta Committed by Commit Bot

Integer coordinates for click/contextmenu as pointerevents

There is a potential compat issue with making
click/contextmenu pointer events. The coordinates
(clientX/clientY, screenX/screenY, pageX/pageY,
offsetX/offsetY) will be returned as fractional numbers.

This is a mitigation plan for the unlikely case of breakage from
fractional coordinates. We believe this is unlikely because we
have been running a Finch experiment with ClickPointerEvent flag
enabled in Canary+Dev for 2 months and there were no related bug
reports.

Our mitigation plan would allow us to keep click/contextmenu
as pointerevents but make sure to return integer
instead of fractional coordinates.

Bug: 989958
Change-Id: I190010ab65f1e01b58480973660b4823f51a24fe
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2510931
Commit-Queue: Liviu Tinta <liviutinta@chromium.org>
Reviewed-by: default avatarMustaq Ahmed <mustaq@chromium.org>
Reviewed-by: default avatarRobert Flack <flackr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#828207}
parent 0d5873bc
......@@ -100,11 +100,22 @@ bool PointerEvent::IsMouseEvent() const {
return false;
}
bool PointerEvent::ShouldHaveIntegerCoordinates() const {
if (RuntimeEnabledFeatures::ClickPointerEventIntegerCoordinatesEnabled() &&
(type() == event_type_names::kClick ||
type() == event_type_names::kContextmenu)) {
return true;
}
return false;
}
bool PointerEvent::IsPointerEvent() const {
return true;
}
double PointerEvent::offsetX() const {
if (ShouldHaveIntegerCoordinates())
return MouseEvent::offsetX();
if (!HasPosition())
return 0;
if (!has_cached_relative_position_)
......@@ -113,6 +124,8 @@ double PointerEvent::offsetX() const {
}
double PointerEvent::offsetY() const {
if (ShouldHaveIntegerCoordinates())
return MouseEvent::offsetY();
if (!HasPosition())
return 0;
if (!has_cached_relative_position_)
......
......@@ -7,6 +7,7 @@
#include "third_party/blink/public/common/input/pointer_id.h"
#include "third_party/blink/renderer/core/events/mouse_event.h"
#include "third_party/blink/renderer/platform/runtime_enabled_features.h"
#include "third_party/blink/renderer/platform/wtf/casting.h"
namespace blink {
......@@ -56,12 +57,36 @@ class CORE_EXPORT PointerEvent final : public MouseEvent {
bool IsMouseEvent() const override;
bool IsPointerEvent() const override;
double screenX() const override { return screen_location_.X(); }
double screenY() const override { return screen_location_.Y(); }
double clientX() const override { return client_location_.X(); }
double clientY() const override { return client_location_.Y(); }
double pageX() const override { return page_location_.X(); }
double pageY() const override { return page_location_.Y(); }
double screenX() const override {
if (ShouldHaveIntegerCoordinates())
return MouseEvent::screenX();
return screen_location_.X();
}
double screenY() const override {
if (ShouldHaveIntegerCoordinates())
return MouseEvent::screenY();
return screen_location_.Y();
}
double clientX() const override {
if (ShouldHaveIntegerCoordinates())
return MouseEvent::clientX();
return client_location_.X();
}
double clientY() const override {
if (ShouldHaveIntegerCoordinates())
return MouseEvent::clientY();
return client_location_.Y();
}
double pageX() const override {
if (ShouldHaveIntegerCoordinates())
return MouseEvent::pageX();
return page_location_.X();
}
double pageY() const override {
if (ShouldHaveIntegerCoordinates())
return MouseEvent::pageY();
return page_location_.Y();
}
double offsetX() const override;
double offsetY() const override;
......@@ -82,6 +107,8 @@ class CORE_EXPORT PointerEvent final : public MouseEvent {
void Trace(Visitor*) const override;
private:
bool ShouldHaveIntegerCoordinates() const;
PointerId pointer_id_;
double width_;
double height_;
......
......@@ -337,6 +337,9 @@
name: "ClickPointerEvent",
status: "experimental",
},
{
name: "ClickPointerEventIntegerCoordinates",
},
{
name: "ClickRetargetting",
status: "experimental",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment