Skip to content

Commit

Permalink
DevTools: use floating point to pass input coordinates in CSS space.
Browse files Browse the repository at this point in the history
Bug: 
Change-Id: Id828c8df4eed5d104b4ce311bf7aa1f4bcd6411c
Reviewed-on: https://chromium-review.googlesource.com/568701
Commit-Queue: Pavel Feldman <pfeldman@chromium.org>
Reviewed-by: Dmitry Gozman <dgozman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#486161}
  • Loading branch information
pavelfeldman authored and Commit Bot committed Jul 12, 2017
1 parent 631445b commit 04e776d
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 50 deletions.
30 changes: 16 additions & 14 deletions content/browser/devtools/protocol/input_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,13 @@ namespace protocol {

namespace {

gfx::PointF CssPixelsToPointF(int x, int y, float page_scale_factor) {
gfx::PointF CssPixelsToPointF(double x, double y, float page_scale_factor) {
return gfx::PointF(x * page_scale_factor, y * page_scale_factor);
}

gfx::Vector2dF CssPixelsToVector2dF(int x, int y, float page_scale_factor) {
gfx::Vector2dF CssPixelsToVector2dF(double x,
double y,
float page_scale_factor) {
return gfx::Vector2dF(x * page_scale_factor, y * page_scale_factor);
}

Expand Down Expand Up @@ -344,8 +346,8 @@ void InputHandler::DispatchKeyEvent(

void InputHandler::DispatchMouseEvent(
const std::string& type,
int x,
int y,
double x,
double y,
Maybe<int> modifiers,
Maybe<double> timestamp,
Maybe<std::string> button,
Expand Down Expand Up @@ -476,8 +478,8 @@ Response InputHandler::SetIgnoreInputEvents(bool ignore) {
}

void InputHandler::SynthesizePinchGesture(
int x,
int y,
double x,
double y,
double scale_factor,
Maybe<int> relative_speed,
Maybe<std::string> gesture_source_type,
Expand Down Expand Up @@ -515,12 +517,12 @@ void InputHandler::SynthesizePinchGesture(
}

void InputHandler::SynthesizeScrollGesture(
int x,
int y,
Maybe<int> x_distance,
Maybe<int> y_distance,
Maybe<int> x_overscroll,
Maybe<int> y_overscroll,
double x,
double y,
Maybe<double> x_distance,
Maybe<double> y_distance,
Maybe<double> x_overscroll,
Maybe<double> y_overscroll,
Maybe<bool> prevent_fling,
Maybe<int> speed,
Maybe<std::string> gesture_source_type,
Expand Down Expand Up @@ -621,8 +623,8 @@ void InputHandler::OnScrollFinished(
}

void InputHandler::SynthesizeTapGesture(
int x,
int y,
double x,
double y,
Maybe<int> duration,
Maybe<int> tap_count,
Maybe<std::string> gesture_source_type,
Expand Down
24 changes: 12 additions & 12 deletions content/browser/devtools/protocol/input_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ class InputHandler : public DevToolsDomainHandler,

void DispatchMouseEvent(
const std::string& type,
int x,
int y,
double x,
double y,
Maybe<int> modifiers,
Maybe<double> timestamp,
Maybe<std::string> button,
Expand All @@ -78,20 +78,20 @@ class InputHandler : public DevToolsDomainHandler,
Response SetIgnoreInputEvents(bool ignore) override;

void SynthesizePinchGesture(
int x,
int y,
double x,
double y,
double scale_factor,
Maybe<int> relative_speed,
Maybe<std::string> gesture_source_type,
std::unique_ptr<SynthesizePinchGestureCallback> callback) override;

void SynthesizeScrollGesture(
int x,
int y,
Maybe<int> x_distance,
Maybe<int> y_distance,
Maybe<int> x_overscroll,
Maybe<int> y_overscroll,
double x,
double y,
Maybe<double> x_distance,
Maybe<double> y_distance,
Maybe<double> x_overscroll,
Maybe<double> y_overscroll,
Maybe<bool> prevent_fling,
Maybe<int> speed,
Maybe<std::string> gesture_source_type,
Expand All @@ -101,8 +101,8 @@ class InputHandler : public DevToolsDomainHandler,
std::unique_ptr<SynthesizeScrollGestureCallback> callback) override;

void SynthesizeTapGesture(
int x,
int y,
double x,
double y,
Maybe<int> duration,
Maybe<int> tap_count,
Maybe<std::string> gesture_source_type,
Expand Down
24 changes: 12 additions & 12 deletions third_party/WebKit/Source/core/inspector/browser_protocol-1.2.json
Original file line number Diff line number Diff line change
Expand Up @@ -3571,8 +3571,8 @@
"name": "dispatchMouseEvent",
"parameters": [
{ "name": "type", "type": "string", "enum": ["mousePressed", "mouseReleased", "mouseMoved"], "description": "Type of the mouse event." },
{ "name": "x", "type": "integer", "description": "X coordinate of the event relative to the main frame's viewport."},
{ "name": "y", "type": "integer", "description": "Y coordinate of the event relative to the main frame's viewport. 0 refers to the top of the viewport and Y increases as it proceeds towards the bottom of the viewport."},
{ "name": "x", "type": "number", "description": "X coordinate of the event relative to the main frame's viewport."},
{ "name": "y", "type": "number", "description": "Y coordinate of the event relative to the main frame's viewport. 0 refers to the top of the viewport and Y increases as it proceeds towards the bottom of the viewport."},
{ "name": "modifiers", "type": "integer", "optional": true, "description": "Bit field representing pressed modifier keys. Alt=1, Ctrl=2, Meta/Command=4, Shift=8 (default: 0)." },
{ "name": "timestamp", "type": "number", "optional": true, "description": "Time at which the event occurred. Measured in UTC time in seconds since January 1, 1970 (default: current time)." },
{ "name": "button", "type": "string", "enum": ["none", "left", "middle", "right"], "optional": true, "description": "Mouse button (default: \"none\")." },
Expand Down Expand Up @@ -3613,8 +3613,8 @@
"name": "synthesizePinchGesture",
"async": true,
"parameters": [
{ "name": "x", "type": "integer", "description": "X coordinate of the start of the gesture in CSS pixels." },
{ "name": "y", "type": "integer", "description": "Y coordinate of the start of the gesture in CSS pixels." },
{ "name": "x", "type": "number", "description": "X coordinate of the start of the gesture in CSS pixels." },
{ "name": "y", "type": "number", "description": "Y coordinate of the start of the gesture in CSS pixels." },
{ "name": "scaleFactor", "type": "number", "description": "Relative scale factor after zooming (>1.0 zooms in, <1.0 zooms out)." },
{ "name": "relativeSpeed", "type": "integer", "optional": true, "description": "Relative pointer speed in pixels per second (default: 800)." },
{ "name": "gestureSourceType", "$ref": "GestureSourceType", "optional": true, "description": "Which type of input events to be generated (default: 'default', which queries the platform for the preferred input type)." }
Expand All @@ -3627,12 +3627,12 @@
"name": "synthesizeScrollGesture",
"async": true,
"parameters": [
{ "name": "x", "type": "integer", "description": "X coordinate of the start of the gesture in CSS pixels." },
{ "name": "y", "type": "integer", "description": "Y coordinate of the start of the gesture in CSS pixels." },
{ "name": "xDistance", "type": "integer", "optional": true, "description": "The distance to scroll along the X axis (positive to scroll left)." },
{ "name": "yDistance", "type": "integer", "optional": true, "description": "The distance to scroll along the Y axis (positive to scroll up)." },
{ "name": "xOverscroll", "type": "integer", "optional": true, "description": "The number of additional pixels to scroll back along the X axis, in addition to the given distance." },
{ "name": "yOverscroll", "type": "integer", "optional": true, "description": "The number of additional pixels to scroll back along the Y axis, in addition to the given distance." },
{ "name": "x", "type": "number", "description": "X coordinate of the start of the gesture in CSS pixels." },
{ "name": "y", "type": "number", "description": "Y coordinate of the start of the gesture in CSS pixels." },
{ "name": "xDistance", "type": "number", "optional": true, "description": "The distance to scroll along the X axis (positive to scroll left)." },
{ "name": "yDistance", "type": "number", "optional": true, "description": "The distance to scroll along the Y axis (positive to scroll up)." },
{ "name": "xOverscroll", "type": "number", "optional": true, "description": "The number of additional pixels to scroll back along the X axis, in addition to the given distance." },
{ "name": "yOverscroll", "type": "number", "optional": true, "description": "The number of additional pixels to scroll back along the Y axis, in addition to the given distance." },
{ "name": "preventFling", "type": "boolean", "optional": true, "description": "Prevent fling (default: true)." },
{ "name": "speed", "type": "integer", "optional": true, "description": "Swipe speed in pixels per second (default: 800)." },
{ "name": "gestureSourceType", "$ref": "GestureSourceType", "optional": true, "description": "Which type of input events to be generated (default: 'default', which queries the platform for the preferred input type)." },
Expand All @@ -3648,8 +3648,8 @@
"name": "synthesizeTapGesture",
"async": true,
"parameters": [
{ "name": "x", "type": "integer", "description": "X coordinate of the start of the gesture in CSS pixels." },
{ "name": "y", "type": "integer", "description": "Y coordinate of the start of the gesture in CSS pixels." },
{ "name": "x", "type": "number", "description": "X coordinate of the start of the gesture in CSS pixels." },
{ "name": "y", "type": "number", "description": "Y coordinate of the start of the gesture in CSS pixels." },
{ "name": "duration", "type": "integer", "optional": true, "description": "Duration between touchdown and touchup events in ms (default: 50)." },
{ "name": "tapCount", "type": "integer", "optional": true, "description": "Number of times to perform the tap (e.g. 2 for double tap, default: 1)." },
{ "name": "gestureSourceType", "$ref": "GestureSourceType", "optional": true, "description": "Which type of input events to be generated (default: 'default', which queries the platform for the preferred input type)." }
Expand Down
24 changes: 12 additions & 12 deletions third_party/WebKit/Source/core/inspector/browser_protocol.json
Original file line number Diff line number Diff line change
Expand Up @@ -3982,8 +3982,8 @@
"name": "dispatchMouseEvent",
"parameters": [
{ "name": "type", "type": "string", "enum": ["mousePressed", "mouseReleased", "mouseMoved"], "description": "Type of the mouse event." },
{ "name": "x", "type": "integer", "description": "X coordinate of the event relative to the main frame's viewport."},
{ "name": "y", "type": "integer", "description": "Y coordinate of the event relative to the main frame's viewport. 0 refers to the top of the viewport and Y increases as it proceeds towards the bottom of the viewport."},
{ "name": "x", "type": "number", "description": "X coordinate of the event relative to the main frame's viewport in CSS pixels."},
{ "name": "y", "type": "number", "description": "Y coordinate of the event relative to the main frame's viewport in CSS pixels. 0 refers to the top of the viewport and Y increases as it proceeds towards the bottom of the viewport."},
{ "name": "modifiers", "type": "integer", "optional": true, "description": "Bit field representing pressed modifier keys. Alt=1, Ctrl=2, Meta/Command=4, Shift=8 (default: 0)." },
{ "name": "timestamp", "$ref": "TimeSinceEpoch", "optional": true, "description": "Time at which the event occurred." },
{ "name": "button", "type": "string", "enum": ["none", "left", "middle", "right"], "optional": true, "description": "Mouse button (default: \"none\")." },
Expand Down Expand Up @@ -4021,8 +4021,8 @@
{
"name": "synthesizePinchGesture",
"parameters": [
{ "name": "x", "type": "integer", "description": "X coordinate of the start of the gesture in CSS pixels." },
{ "name": "y", "type": "integer", "description": "Y coordinate of the start of the gesture in CSS pixels." },
{ "name": "x", "type": "number", "description": "X coordinate of the start of the gesture in CSS pixels." },
{ "name": "y", "type": "number", "description": "Y coordinate of the start of the gesture in CSS pixels." },
{ "name": "scaleFactor", "type": "number", "description": "Relative scale factor after zooming (>1.0 zooms in, <1.0 zooms out)." },
{ "name": "relativeSpeed", "type": "integer", "optional": true, "description": "Relative pointer speed in pixels per second (default: 800)." },
{ "name": "gestureSourceType", "$ref": "GestureSourceType", "optional": true, "description": "Which type of input events to be generated (default: 'default', which queries the platform for the preferred input type)." }
Expand All @@ -4033,12 +4033,12 @@
{
"name": "synthesizeScrollGesture",
"parameters": [
{ "name": "x", "type": "integer", "description": "X coordinate of the start of the gesture in CSS pixels." },
{ "name": "y", "type": "integer", "description": "Y coordinate of the start of the gesture in CSS pixels." },
{ "name": "xDistance", "type": "integer", "optional": true, "description": "The distance to scroll along the X axis (positive to scroll left)." },
{ "name": "yDistance", "type": "integer", "optional": true, "description": "The distance to scroll along the Y axis (positive to scroll up)." },
{ "name": "xOverscroll", "type": "integer", "optional": true, "description": "The number of additional pixels to scroll back along the X axis, in addition to the given distance." },
{ "name": "yOverscroll", "type": "integer", "optional": true, "description": "The number of additional pixels to scroll back along the Y axis, in addition to the given distance." },
{ "name": "x", "type": "number", "description": "X coordinate of the start of the gesture in CSS pixels." },
{ "name": "y", "type": "number", "description": "Y coordinate of the start of the gesture in CSS pixels." },
{ "name": "xDistance", "type": "number", "optional": true, "description": "The distance to scroll along the X axis (positive to scroll left)." },
{ "name": "yDistance", "type": "number", "optional": true, "description": "The distance to scroll along the Y axis (positive to scroll up)." },
{ "name": "xOverscroll", "type": "number", "optional": true, "description": "The number of additional pixels to scroll back along the X axis, in addition to the given distance." },
{ "name": "yOverscroll", "type": "number", "optional": true, "description": "The number of additional pixels to scroll back along the Y axis, in addition to the given distance." },
{ "name": "preventFling", "type": "boolean", "optional": true, "description": "Prevent fling (default: true)." },
{ "name": "speed", "type": "integer", "optional": true, "description": "Swipe speed in pixels per second (default: 800)." },
{ "name": "gestureSourceType", "$ref": "GestureSourceType", "optional": true, "description": "Which type of input events to be generated (default: 'default', which queries the platform for the preferred input type)." },
Expand All @@ -4052,8 +4052,8 @@
{
"name": "synthesizeTapGesture",
"parameters": [
{ "name": "x", "type": "integer", "description": "X coordinate of the start of the gesture in CSS pixels." },
{ "name": "y", "type": "integer", "description": "Y coordinate of the start of the gesture in CSS pixels." },
{ "name": "x", "type": "number", "description": "X coordinate of the start of the gesture in CSS pixels." },
{ "name": "y", "type": "number", "description": "Y coordinate of the start of the gesture in CSS pixels." },
{ "name": "duration", "type": "integer", "optional": true, "description": "Duration between touchdown and touchup events in ms (default: 50)." },
{ "name": "tapCount", "type": "integer", "optional": true, "description": "Number of times to perform the tap (e.g. 2 for double tap, default: 1)." },
{ "name": "gestureSourceType", "$ref": "GestureSourceType", "optional": true, "description": "Which type of input events to be generated (default: 'default', which queries the platform for the preferred input type)." }
Expand Down

0 comments on commit 04e776d

Please sign in to comment.