Commit 3b538d76 authored by Lan Wei's avatar Lan Wei Committed by Commit Bot

Add touch point attributes to synthetic pointer action

In order to allow users to set radiusX, radiusY, rotationAngle and
force for touch points in devtool protocol Input.dispatchTouchEvent, we
should add these attributes to SyntheticPointerAction class as well for
touch inputs.

Bug: 606367
Change-Id: I2aaa43746c5c812ecabc675dadd7927f14a3f31c
Reviewed-on: https://chromium-review.googlesource.com/c/1431313Reviewed-by: default avatarDave Tapuska <dtapuska@chromium.org>
Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Reviewed-by: default avatarNavid Zolghadr <nzolghadr@chromium.org>
Commit-Queue: Lan Wei <lanwei@chromium.org>
Cr-Commit-Position: refs/heads/master@{#628342}
parent 43117a40
...@@ -356,10 +356,12 @@ class InputRouterImplTestBase : public testing::Test { ...@@ -356,10 +356,12 @@ class InputRouterImplTestBase : public testing::Test {
return touch_event_id; return touch_event_id;
} }
int PressTouchPoint(int x, int y) { return touch_event_.PressPoint(x, y); } int PressTouchPoint(int x, int y) {
return touch_event_.PressPoint(x, y, radius_x_, radius_y_);
}
void MoveTouchPoint(int index, int x, int y) { void MoveTouchPoint(int index, int x, int y) {
touch_event_.MovePoint(index, x, y); touch_event_.MovePoint(index, x, y, radius_x_, radius_y_);
} }
void ReleaseTouchPoint(int index) { touch_event_.ReleasePoint(index); } void ReleaseTouchPoint(int index) { touch_event_.ReleasePoint(index); }
...@@ -474,6 +476,8 @@ class InputRouterImplTestBase : public testing::Test { ...@@ -474,6 +476,8 @@ class InputRouterImplTestBase : public testing::Test {
EXPECT_EQ(input_router_->AllowedTouchAction(), expected_touch_action); EXPECT_EQ(input_router_->AllowedTouchAction(), expected_touch_action);
} }
const float radius_x_ = 20.0f;
const float radius_y_ = 20.0f;
InputRouter::Config config_; InputRouter::Config config_;
std::unique_ptr<MockInputRouterImplClient> client_; std::unique_ptr<MockInputRouterImplClient> client_;
std::unique_ptr<InputRouterImpl> input_router_; std::unique_ptr<InputRouterImpl> input_router_;
...@@ -2207,15 +2211,15 @@ class InputRouterImplScaleTouchEventTest ...@@ -2207,15 +2211,15 @@ class InputRouterImplScaleTouchEventTest
EXPECT_EQ(40, sent_event->touches[0].PositionInWidget().y); EXPECT_EQ(40, sent_event->touches[0].PositionInWidget().y);
EXPECT_EQ(10, sent_event->touches[0].PositionInScreen().x); EXPECT_EQ(10, sent_event->touches[0].PositionInScreen().x);
EXPECT_EQ(20, sent_event->touches[0].PositionInScreen().y); EXPECT_EQ(20, sent_event->touches[0].PositionInScreen().y);
EXPECT_EQ(40, sent_event->touches[0].radius_x); EXPECT_EQ(2 * radius_x_, sent_event->touches[0].radius_x);
EXPECT_EQ(40, sent_event->touches[0].radius_y); EXPECT_EQ(2 * radius_x_, sent_event->touches[0].radius_y);
EXPECT_EQ(200, sent_event->touches[1].PositionInWidget().x); EXPECT_EQ(200, sent_event->touches[1].PositionInWidget().x);
EXPECT_EQ(400, sent_event->touches[1].PositionInWidget().y); EXPECT_EQ(400, sent_event->touches[1].PositionInWidget().y);
EXPECT_EQ(100, sent_event->touches[1].PositionInScreen().x); EXPECT_EQ(100, sent_event->touches[1].PositionInScreen().x);
EXPECT_EQ(200, sent_event->touches[1].PositionInScreen().y); EXPECT_EQ(200, sent_event->touches[1].PositionInScreen().y);
EXPECT_EQ(40, sent_event->touches[1].radius_x); EXPECT_EQ(2 * radius_x_, sent_event->touches[1].radius_x);
EXPECT_EQ(40, sent_event->touches[1].radius_y); EXPECT_EQ(2 * radius_x_, sent_event->touches[1].radius_y);
const WebTouchEvent* filter_event = GetFilterWebInputEvent<WebTouchEvent>(); const WebTouchEvent* filter_event = GetFilterWebInputEvent<WebTouchEvent>();
ASSERT_EQ(2u, filter_event->touches_length); ASSERT_EQ(2u, filter_event->touches_length);
...@@ -2223,15 +2227,15 @@ class InputRouterImplScaleTouchEventTest ...@@ -2223,15 +2227,15 @@ class InputRouterImplScaleTouchEventTest
EXPECT_EQ(20, filter_event->touches[0].PositionInWidget().y); EXPECT_EQ(20, filter_event->touches[0].PositionInWidget().y);
EXPECT_EQ(10, filter_event->touches[0].PositionInScreen().x); EXPECT_EQ(10, filter_event->touches[0].PositionInScreen().x);
EXPECT_EQ(20, filter_event->touches[0].PositionInScreen().y); EXPECT_EQ(20, filter_event->touches[0].PositionInScreen().y);
EXPECT_EQ(20, filter_event->touches[0].radius_x); EXPECT_EQ(radius_x_, filter_event->touches[0].radius_x);
EXPECT_EQ(20, filter_event->touches[0].radius_y); EXPECT_EQ(radius_x_, filter_event->touches[0].radius_y);
EXPECT_EQ(100, filter_event->touches[1].PositionInWidget().x); EXPECT_EQ(100, filter_event->touches[1].PositionInWidget().x);
EXPECT_EQ(200, filter_event->touches[1].PositionInWidget().y); EXPECT_EQ(200, filter_event->touches[1].PositionInWidget().y);
EXPECT_EQ(100, filter_event->touches[1].PositionInScreen().x); EXPECT_EQ(100, filter_event->touches[1].PositionInScreen().x);
EXPECT_EQ(200, filter_event->touches[1].PositionInScreen().y); EXPECT_EQ(200, filter_event->touches[1].PositionInScreen().y);
EXPECT_EQ(20, filter_event->touches[1].radius_x); EXPECT_EQ(radius_x_, filter_event->touches[1].radius_x);
EXPECT_EQ(20, filter_event->touches[1].radius_y); EXPECT_EQ(radius_x_, filter_event->touches[1].radius_y);
} }
void FlushTouchEvent(WebInputEvent::Type type) { void FlushTouchEvent(WebInputEvent::Type type) {
......
...@@ -183,12 +183,12 @@ class PassthroughTouchEventQueueTest : public testing::Test, ...@@ -183,12 +183,12 @@ class PassthroughTouchEventQueueTest : public testing::Test,
} }
void PressTouchPoint(float x, float y) { void PressTouchPoint(float x, float y) {
touch_event_.PressPoint(x, y); touch_event_.PressPoint(x, y, radius_x_, radius_y_);
SendTouchEvent(); SendTouchEvent();
} }
void MoveTouchPoint(int index, float x, float y) { void MoveTouchPoint(int index, float x, float y) {
touch_event_.MovePoint(index, x, y); touch_event_.MovePoint(index, x, y, radius_x_, radius_y_);
SendTouchEvent(); SendTouchEvent();
} }
...@@ -324,6 +324,9 @@ class PassthroughTouchEventQueueTest : public testing::Test, ...@@ -324,6 +324,9 @@ class PassthroughTouchEventQueueTest : public testing::Test,
int GetUniqueTouchEventID() { return sent_events_ids_.back(); } int GetUniqueTouchEventID() { return sent_events_ids_.back(); }
const float radius_x_ = 20.0f;
const float radius_y_ = 20.0f;
private: private:
void SendTouchEvent() { void SendTouchEvent() {
SendTouchEvent(touch_event_); SendTouchEvent(touch_event_);
...@@ -1630,8 +1633,8 @@ TEST_F(PassthroughTouchEventQueueTest, ...@@ -1630,8 +1633,8 @@ TEST_F(PassthroughTouchEventQueueTest,
PressTouchPoint(1, 1); PressTouchPoint(1, 1);
SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED); SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED);
// Default initial radiusX/Y is (1.f, 1.f). // Default initial radiusX/Y is (20.f, 20.f).
// Default initial rotationAngle is 1.f. // Default initial rotationAngle is 0.f.
// Default initial force is 1.f. // Default initial force is 1.f.
// Change touch point radius only. // Change touch point radius only.
...@@ -1690,7 +1693,7 @@ TEST_F(PassthroughTouchEventQueueTest, FilterTouchMovesWhenNoPointerChanged) { ...@@ -1690,7 +1693,7 @@ TEST_F(PassthroughTouchEventQueueTest, FilterTouchMovesWhenNoPointerChanged) {
// Do not really move any touch points, but use previous values. // Do not really move any touch points, but use previous values.
MoveTouchPoint(0, 10, 10); MoveTouchPoint(0, 10, 10);
ChangeTouchPointRadius(1, 20, 20); ChangeTouchPointRadius(1, radius_x_, radius_y_);
MoveTouchPoint(1, 2, 2); MoveTouchPoint(1, 2, 2);
EXPECT_EQ(4U, queued_event_count()); EXPECT_EQ(4U, queued_event_count());
EXPECT_EQ(0U, GetAndResetSentEventCount()); EXPECT_EQ(0U, GetAndResetSentEventCount());
......
...@@ -27,7 +27,11 @@ void SyntheticMouseDriver::Press(float x, ...@@ -27,7 +27,11 @@ void SyntheticMouseDriver::Press(float x,
float y, float y,
int index, int index,
SyntheticPointerActionParams::Button button, SyntheticPointerActionParams::Button button,
int key_modifiers) { int key_modifiers,
float width,
float height,
float rotation_angle,
float force) {
DCHECK_EQ(index, 0); DCHECK_EQ(index, 0);
int modifiers = int modifiers =
SyntheticPointerActionParams::GetWebMouseEventModifier(button); SyntheticPointerActionParams::GetWebMouseEventModifier(button);
...@@ -43,7 +47,11 @@ void SyntheticMouseDriver::Press(float x, ...@@ -43,7 +47,11 @@ void SyntheticMouseDriver::Press(float x,
void SyntheticMouseDriver::Move(float x, void SyntheticMouseDriver::Move(float x,
float y, float y,
int index, int index,
int key_modifiers) { int key_modifiers,
float width,
float height,
float rotation_angle,
float force) {
DCHECK_EQ(index, 0); DCHECK_EQ(index, 0);
mouse_event_ = SyntheticWebMouseEventBuilder::Build( mouse_event_ = SyntheticWebMouseEventBuilder::Build(
blink::WebInputEvent::kMouseMove, x, y, key_modifiers | last_modifiers_, blink::WebInputEvent::kMouseMove, x, y, key_modifiers | last_modifiers_,
......
...@@ -25,8 +25,19 @@ class CONTENT_EXPORT SyntheticMouseDriver : public SyntheticPointerDriver { ...@@ -25,8 +25,19 @@ class CONTENT_EXPORT SyntheticMouseDriver : public SyntheticPointerDriver {
int index = 0, int index = 0,
SyntheticPointerActionParams::Button button = SyntheticPointerActionParams::Button button =
SyntheticPointerActionParams::Button::LEFT, SyntheticPointerActionParams::Button::LEFT,
int key_modifiers = 0) override; int key_modifiers = 0,
void Move(float x, float y, int index = 0, int key_modifiers = 0) override; float width = 1.f,
float height = 1.f,
float rotation_angle = 0.f,
float force = 1.f) override;
void Move(float x,
float y,
int index = 0,
int key_modifiers = 0,
float width = 1.f,
float height = 1.f,
float rotation_angle = 0.f,
float force = 1.f) override;
void Release(int index = 0, void Release(int index = 0,
SyntheticPointerActionParams::Button button = SyntheticPointerActionParams::Button button =
SyntheticPointerActionParams::Button::LEFT, SyntheticPointerActionParams::Button::LEFT,
......
...@@ -75,12 +75,14 @@ SyntheticPointerAction::ForwardTouchOrMouseInputEvents( ...@@ -75,12 +75,14 @@ SyntheticPointerAction::ForwardTouchOrMouseInputEvents(
case SyntheticPointerActionParams::PointerActionType::PRESS: case SyntheticPointerActionParams::PointerActionType::PRESS:
synthetic_pointer_driver_->Press( synthetic_pointer_driver_->Press(
param.position().x(), param.position().y(), param.pointer_id(), param.position().x(), param.position().y(), param.pointer_id(),
param.button(), param.key_modifiers()); param.button(), param.key_modifiers(), param.width(),
param.height(), param.rotation_angle(), param.force());
break; break;
case SyntheticPointerActionParams::PointerActionType::MOVE: case SyntheticPointerActionParams::PointerActionType::MOVE:
synthetic_pointer_driver_->Move( synthetic_pointer_driver_->Move(
param.position().x(), param.position().y(), param.pointer_id(), param.position().x(), param.position().y(), param.pointer_id(),
param.key_modifiers()); param.key_modifiers(), param.width(), param.height(),
param.rotation_angle(), param.force());
break; break;
case SyntheticPointerActionParams::PointerActionType::RELEASE: case SyntheticPointerActionParams::PointerActionType::RELEASE:
synthetic_pointer_driver_->Release(param.pointer_id(), param.button(), synthetic_pointer_driver_->Release(param.pointer_id(), param.button(),
......
...@@ -142,6 +142,13 @@ class MockSyntheticPointerTouchActionTarget ...@@ -142,6 +142,13 @@ class MockSyntheticPointerTouchActionTarget
positions_[num_dispatched_pointer_actions_] = positions_[num_dispatched_pointer_actions_] =
gfx::PointF(touch_event.touches[i].PositionInWidget()); gfx::PointF(touch_event.touches[i].PositionInWidget());
states_[num_dispatched_pointer_actions_] = touch_event.touches[i].state; states_[num_dispatched_pointer_actions_] = touch_event.touches[i].state;
widths_[num_dispatched_pointer_actions_] =
2 * touch_event.touches[i].radius_x;
heights_[num_dispatched_pointer_actions_] =
2 * touch_event.touches[i].radius_y;
rotation_angles_[num_dispatched_pointer_actions_] =
touch_event.touches[i].rotation_angle;
forces_[num_dispatched_pointer_actions_] = touch_event.touches[i].force;
num_dispatched_pointer_actions_++; num_dispatched_pointer_actions_++;
} }
} }
...@@ -166,6 +173,31 @@ class MockSyntheticPointerTouchActionTarget ...@@ -166,6 +173,31 @@ class MockSyntheticPointerTouchActionTarget
<< positions_[index].ToString() << ", expected " << positions_[index].ToString() << ", expected "
<< param.position().ToString() << "."; << param.position().ToString() << ".";
} }
if (widths_[index] != param.width()) {
return testing::AssertionFailure()
<< "Pointer width at index " << index << " was "
<< widths_[index] << ", expected " << param.width() << ".";
}
if (heights_[index] != param.height()) {
return testing::AssertionFailure()
<< "Pointer height at index " << index << " was "
<< heights_[index] << ", expected " << param.height() << ".";
}
if (rotation_angles_[index] != param.rotation_angle()) {
return testing::AssertionFailure()
<< "Pointer rotation_angle at index " << index << " was "
<< rotation_angles_[index] << ", expected "
<< param.rotation_angle() << ".";
}
if (forces_[index] != param.force()) {
return testing::AssertionFailure()
<< "Pointer force at index " << index << " was "
<< forces_[index] << ", expected " << param.force() << ".";
}
} }
if (states_[index] != ToWebTouchPointState(param.pointer_action_type())) { if (states_[index] != ToWebTouchPointState(param.pointer_action_type())) {
...@@ -204,6 +236,10 @@ class MockSyntheticPointerTouchActionTarget ...@@ -204,6 +236,10 @@ class MockSyntheticPointerTouchActionTarget
gfx::PointF positions_[WebTouchEvent::kTouchesLengthCap]; gfx::PointF positions_[WebTouchEvent::kTouchesLengthCap];
uint32_t indexes_[WebTouchEvent::kTouchesLengthCap]; uint32_t indexes_[WebTouchEvent::kTouchesLengthCap];
WebTouchPoint::State states_[WebTouchEvent::kTouchesLengthCap]; WebTouchPoint::State states_[WebTouchEvent::kTouchesLengthCap];
float widths_[WebTouchEvent::kTouchesLengthCap];
float heights_[WebTouchEvent::kTouchesLengthCap];
float rotation_angles_[WebTouchEvent::kTouchesLengthCap];
float forces_[WebTouchEvent::kTouchesLengthCap];
}; };
class MockSyntheticPointerMouseActionTarget class MockSyntheticPointerMouseActionTarget
...@@ -369,6 +405,10 @@ TEST_F(SyntheticPointerActionTest, PointerTouchAction) { ...@@ -369,6 +405,10 @@ TEST_F(SyntheticPointerActionTest, PointerTouchAction) {
SyntheticPointerActionParams::PointerActionType::PRESS); SyntheticPointerActionParams::PointerActionType::PRESS);
param1.set_pointer_id(0); param1.set_pointer_id(0);
param1.set_position(gfx::PointF(54, 89)); param1.set_position(gfx::PointF(54, 89));
param1.set_width(30);
param1.set_height(45);
param1.set_rotation_angle(10);
param1.set_force(15);
SyntheticPointerActionListParams::ParamList param_list1; SyntheticPointerActionListParams::ParamList param_list1;
param_list1.push_back(param1); param_list1.push_back(param1);
params_.PushPointerActionParamsList(param_list1); params_.PushPointerActionParamsList(param_list1);
...@@ -382,6 +422,10 @@ TEST_F(SyntheticPointerActionTest, PointerTouchAction) { ...@@ -382,6 +422,10 @@ TEST_F(SyntheticPointerActionTest, PointerTouchAction) {
SyntheticPointerActionParams::PointerActionType::PRESS); SyntheticPointerActionParams::PointerActionType::PRESS);
param2.set_pointer_id(1); param2.set_pointer_id(1);
param2.set_position(gfx::PointF(79, 132)); param2.set_position(gfx::PointF(79, 132));
param2.set_width(10);
param2.set_height(35);
param2.set_rotation_angle(30);
param2.set_force(10);
SyntheticPointerActionListParams::ParamList param_list2; SyntheticPointerActionListParams::ParamList param_list2;
param_list2.push_back(param1); param_list2.push_back(param1);
param_list2.push_back(param2); param_list2.push_back(param2);
......
...@@ -33,8 +33,19 @@ class CONTENT_EXPORT SyntheticPointerDriver { ...@@ -33,8 +33,19 @@ class CONTENT_EXPORT SyntheticPointerDriver {
int index = 0, int index = 0,
SyntheticPointerActionParams::Button button = SyntheticPointerActionParams::Button button =
SyntheticPointerActionParams::Button::LEFT, SyntheticPointerActionParams::Button::LEFT,
int key_modifiers = 0) = 0; int key_modifiers = 0,
virtual void Move(float x, float y, int index = 0, int key_modifiers = 0) = 0; float width = 1.f,
float height = 1.f,
float rotation_angle = 0.f,
float force = 1.f) = 0;
virtual void Move(float x,
float y,
int index = 0,
int key_modifiers = 0,
float width = 1.f,
float height = 1.f,
float rotation_angle = 0.f,
float force = 1.f) = 0;
virtual void Release(int index = 0, virtual void Release(int index = 0,
SyntheticPointerActionParams::Button button = SyntheticPointerActionParams::Button button =
SyntheticPointerActionParams::Button::LEFT, SyntheticPointerActionParams::Button::LEFT,
......
...@@ -28,10 +28,15 @@ void SyntheticTouchDriver::Press(float x, ...@@ -28,10 +28,15 @@ void SyntheticTouchDriver::Press(float x,
float y, float y,
int index, int index,
SyntheticPointerActionParams::Button button, SyntheticPointerActionParams::Button button,
int key_modifiers) { int key_modifiers,
float width,
float height,
float rotation_angle,
float force) {
DCHECK_GE(index, 0); DCHECK_GE(index, 0);
DCHECK(pointer_id_map_.find(index) == pointer_id_map_.end()); DCHECK(pointer_id_map_.find(index) == pointer_id_map_.end());
int touch_index = touch_event_.PressPoint(x, y); int touch_index = touch_event_.PressPoint(x, y, width / 2.f, height / 2.f,
rotation_angle, force);
touch_event_.touches[touch_index].id = index; touch_event_.touches[touch_index].id = index;
pointer_id_map_[index] = touch_index; pointer_id_map_[index] = touch_index;
} }
...@@ -39,10 +44,15 @@ void SyntheticTouchDriver::Press(float x, ...@@ -39,10 +44,15 @@ void SyntheticTouchDriver::Press(float x,
void SyntheticTouchDriver::Move(float x, void SyntheticTouchDriver::Move(float x,
float y, float y,
int index, int index,
int key_modifiers) { int key_modifiers,
float width,
float height,
float rotation_angle,
float force) {
DCHECK_GE(index, 0); DCHECK_GE(index, 0);
DCHECK(pointer_id_map_.find(index) != pointer_id_map_.end()); DCHECK(pointer_id_map_.find(index) != pointer_id_map_.end());
touch_event_.MovePoint(pointer_id_map_[index], x, y); touch_event_.MovePoint(pointer_id_map_[index], x, y, width / 2.f,
height / 2.f, rotation_angle, force);
} }
void SyntheticTouchDriver::Release(int index, void SyntheticTouchDriver::Release(int index,
......
...@@ -27,8 +27,19 @@ class CONTENT_EXPORT SyntheticTouchDriver : public SyntheticPointerDriver { ...@@ -27,8 +27,19 @@ class CONTENT_EXPORT SyntheticTouchDriver : public SyntheticPointerDriver {
int index, int index,
SyntheticPointerActionParams::Button button = SyntheticPointerActionParams::Button button =
SyntheticPointerActionParams::Button::LEFT, SyntheticPointerActionParams::Button::LEFT,
int key_modifiers = 0) override; int key_modifiers = 0,
void Move(float x, float y, int index, int key_modifiers = 0) override; float width = 40.f,
float height = 40.f,
float rotation_angle = 0.f,
float force = 1.f) override;
void Move(float x,
float y,
int index,
int key_modifiers = 0,
float width = 40.f,
float height = 40.f,
float rotation_angle = 0.f,
float force = 1.f) override;
void Release(int index, void Release(int index,
SyntheticPointerActionParams::Button button = SyntheticPointerActionParams::Button button =
SyntheticPointerActionParams::Button::LEFT, SyntheticPointerActionParams::Button::LEFT,
......
...@@ -6,20 +6,13 @@ ...@@ -6,20 +6,13 @@
namespace content { namespace content {
SyntheticPointerActionParams::SyntheticPointerActionParams() SyntheticPointerActionParams::SyntheticPointerActionParams() = default;
: pointer_action_type_(PointerActionType::NOT_INITIALIZED),
pointer_id_(0),
button_(Button::LEFT),
key_modifiers_(0) {}
SyntheticPointerActionParams::SyntheticPointerActionParams( SyntheticPointerActionParams::SyntheticPointerActionParams(
PointerActionType action_type) PointerActionType action_type)
: pointer_action_type_(action_type), : pointer_action_type_(action_type) {}
pointer_id_(0),
button_(Button::LEFT),
key_modifiers_(0) {}
SyntheticPointerActionParams::~SyntheticPointerActionParams() {} SyntheticPointerActionParams::~SyntheticPointerActionParams() = default;
// static // static
unsigned SyntheticPointerActionParams::GetWebMouseEventModifier( unsigned SyntheticPointerActionParams::GetWebMouseEventModifier(
......
...@@ -46,7 +46,7 @@ struct CONTENT_EXPORT SyntheticPointerActionParams { ...@@ -46,7 +46,7 @@ struct CONTENT_EXPORT SyntheticPointerActionParams {
}; };
SyntheticPointerActionParams(); SyntheticPointerActionParams();
SyntheticPointerActionParams(PointerActionType action_type); explicit SyntheticPointerActionParams(PointerActionType action_type);
~SyntheticPointerActionParams(); ~SyntheticPointerActionParams();
void set_pointer_action_type(PointerActionType pointer_action_type) { void set_pointer_action_type(PointerActionType pointer_action_type) {
...@@ -72,6 +72,30 @@ struct CONTENT_EXPORT SyntheticPointerActionParams { ...@@ -72,6 +72,30 @@ struct CONTENT_EXPORT SyntheticPointerActionParams {
key_modifiers_ = key_modifiers; key_modifiers_ = key_modifiers;
} }
void set_width(float width) {
DCHECK(pointer_action_type_ == PointerActionType::PRESS ||
pointer_action_type_ == PointerActionType::MOVE);
width_ = width;
}
void set_height(float height) {
DCHECK(pointer_action_type_ == PointerActionType::PRESS ||
pointer_action_type_ == PointerActionType::MOVE);
height_ = height;
}
void set_rotation_angle(float rotation_angle) {
DCHECK(pointer_action_type_ == PointerActionType::PRESS ||
pointer_action_type_ == PointerActionType::MOVE);
rotation_angle_ = rotation_angle;
}
void set_force(float force) {
DCHECK(pointer_action_type_ == PointerActionType::PRESS ||
pointer_action_type_ == PointerActionType::MOVE);
force_ = force;
}
PointerActionType pointer_action_type() const { return pointer_action_type_; } PointerActionType pointer_action_type() const { return pointer_action_type_; }
uint32_t pointer_id() const { return pointer_id_; } uint32_t pointer_id() const { return pointer_id_; }
...@@ -93,6 +117,30 @@ struct CONTENT_EXPORT SyntheticPointerActionParams { ...@@ -93,6 +117,30 @@ struct CONTENT_EXPORT SyntheticPointerActionParams {
return key_modifiers_; return key_modifiers_;
} }
float width() const {
DCHECK(pointer_action_type_ == PointerActionType::PRESS ||
pointer_action_type_ == PointerActionType::MOVE);
return width_;
}
float height() const {
DCHECK(pointer_action_type_ == PointerActionType::PRESS ||
pointer_action_type_ == PointerActionType::MOVE);
return height_;
}
float rotation_angle() const {
DCHECK(pointer_action_type_ == PointerActionType::PRESS ||
pointer_action_type_ == PointerActionType::MOVE);
return rotation_angle_;
}
float force() const {
DCHECK(pointer_action_type_ == PointerActionType::PRESS ||
pointer_action_type_ == PointerActionType::MOVE);
return force_;
}
static unsigned GetWebMouseEventModifier( static unsigned GetWebMouseEventModifier(
SyntheticPointerActionParams::Button button); SyntheticPointerActionParams::Button button);
static blink::WebMouseEvent::Button GetWebMouseEventButton( static blink::WebMouseEvent::Button GetWebMouseEventButton(
...@@ -104,16 +152,20 @@ struct CONTENT_EXPORT SyntheticPointerActionParams { ...@@ -104,16 +152,20 @@ struct CONTENT_EXPORT SyntheticPointerActionParams {
friend struct IPC::ParamTraits<content::SyntheticPointerActionParams>; friend struct IPC::ParamTraits<content::SyntheticPointerActionParams>;
friend struct ipc_fuzzer::FuzzTraits<content::SyntheticPointerActionParams>; friend struct ipc_fuzzer::FuzzTraits<content::SyntheticPointerActionParams>;
PointerActionType pointer_action_type_; PointerActionType pointer_action_type_ = PointerActionType::NOT_INITIALIZED;
// The position of the pointer, where it presses or moves to. // The position of the pointer, where it presses or moves to.
gfx::PointF position_; gfx::PointF position_;
// The id of the pointer given by the users. // The id of the pointer given by the users.
uint32_t pointer_id_; uint32_t pointer_id_ = 0;
Button button_; Button button_ = Button::LEFT;
// “Alt“, ”Control“, ”Meta“, ”Shift“, ”CapsLock“, ”NumLock“, ”AltGraph” // “Alt“, ”Control“, ”Meta“, ”Shift“, ”CapsLock“, ”NumLock“, ”AltGraph”
// buttons are supported right now. It stores a matching modifiers defined // buttons are supported right now. It stores a matching modifiers defined
// in WebInputEvent class. // in WebInputEvent class.
int key_modifiers_; int key_modifiers_ = 0;
float width_ = 40.f;
float height_ = 40.f;
float rotation_angle_ = 0.f;
float force_ = 1.f;
}; };
} // namespace content } // namespace content
......
...@@ -202,7 +202,12 @@ void SyntheticWebTouchEvent::ResetPoints() { ...@@ -202,7 +202,12 @@ void SyntheticWebTouchEvent::ResetPoints() {
unique_touch_event_id = ui::GetNextTouchEventId(); unique_touch_event_id = ui::GetNextTouchEventId();
} }
int SyntheticWebTouchEvent::PressPoint(float x, float y) { int SyntheticWebTouchEvent::PressPoint(float x,
float y,
float radius_x,
float radius_y,
float rotation_angle,
float force) {
int index = FirstFreeIndex(); int index = FirstFreeIndex();
if (index == -1) if (index == -1)
return -1; return -1;
...@@ -211,10 +216,10 @@ int SyntheticWebTouchEvent::PressPoint(float x, float y) { ...@@ -211,10 +216,10 @@ int SyntheticWebTouchEvent::PressPoint(float x, float y) {
point.SetPositionInWidget(x, y); point.SetPositionInWidget(x, y);
point.SetPositionInScreen(x, y); point.SetPositionInScreen(x, y);
point.state = WebTouchPoint::kStatePressed; point.state = WebTouchPoint::kStatePressed;
// Use radius != default(25.f) to test the value is propagated correctly point.radius_x = radius_x;
point.radius_x = point.radius_y = 20.f; point.radius_y = radius_y;
point.rotation_angle = 1.f; point.rotation_angle = rotation_angle;
point.force = 1.f; point.force = force;
point.tilt_x = point.tilt_y = 0; point.tilt_x = point.tilt_y = 0;
point.pointer_type = blink::WebPointerProperties::PointerType::kTouch; point.pointer_type = blink::WebPointerProperties::PointerType::kTouch;
++touches_length; ++touches_length;
...@@ -222,7 +227,13 @@ int SyntheticWebTouchEvent::PressPoint(float x, float y) { ...@@ -222,7 +227,13 @@ int SyntheticWebTouchEvent::PressPoint(float x, float y) {
return index; return index;
} }
void SyntheticWebTouchEvent::MovePoint(int index, float x, float y) { void SyntheticWebTouchEvent::MovePoint(int index,
float x,
float y,
float radius_x,
float radius_y,
float rotation_angle,
float force) {
CHECK_GE(index, 0); CHECK_GE(index, 0);
CHECK_LT(index, kTouchesLengthCap); CHECK_LT(index, kTouchesLengthCap);
// Always set this bit to avoid otherwise unexpected touchmove suppression. // Always set this bit to avoid otherwise unexpected touchmove suppression.
...@@ -231,7 +242,11 @@ void SyntheticWebTouchEvent::MovePoint(int index, float x, float y) { ...@@ -231,7 +242,11 @@ void SyntheticWebTouchEvent::MovePoint(int index, float x, float y) {
WebTouchPoint& point = touches[index]; WebTouchPoint& point = touches[index];
point.SetPositionInWidget(x, y); point.SetPositionInWidget(x, y);
point.SetPositionInScreen(x, y); point.SetPositionInScreen(x, y);
touches[index].state = WebTouchPoint::kStateMoved; point.state = WebTouchPoint::kStateMoved;
point.radius_x = radius_x;
point.radius_y = radius_y;
point.rotation_angle = rotation_angle;
point.force = force;
WebTouchEventTraits::ResetType(WebInputEvent::kTouchMove, TimeStamp(), this); WebTouchEventTraits::ResetType(WebInputEvent::kTouchMove, TimeStamp(), this);
} }
......
...@@ -91,8 +91,19 @@ class CONTENT_EXPORT SyntheticWebTouchEvent : public blink::WebTouchEvent { ...@@ -91,8 +91,19 @@ class CONTENT_EXPORT SyntheticWebTouchEvent : public blink::WebTouchEvent {
void ResetPoints(); void ResetPoints();
// Adds an additional point to the touch list, returning the point's index. // Adds an additional point to the touch list, returning the point's index.
int PressPoint(float x, float y); int PressPoint(float x,
void MovePoint(int index, float x, float y); float y,
float radius_x = 20.f,
float radius_y = 20.f,
float rotation_angle = 0.f,
float force = 1.f);
void MovePoint(int index,
float x,
float y,
float radius_x = 20.f,
float radius_y = 20.f,
float rotation_angle = 0.f,
float force = 1.f);
void ReleasePoint(int index); void ReleasePoint(int index);
void CancelPoint(int index); void CancelPoint(int index);
......
...@@ -145,6 +145,10 @@ IPC_STRUCT_TRAITS_BEGIN(content::SyntheticPointerActionParams) ...@@ -145,6 +145,10 @@ IPC_STRUCT_TRAITS_BEGIN(content::SyntheticPointerActionParams)
IPC_STRUCT_TRAITS_MEMBER(position_) IPC_STRUCT_TRAITS_MEMBER(position_)
IPC_STRUCT_TRAITS_MEMBER(button_) IPC_STRUCT_TRAITS_MEMBER(button_)
IPC_STRUCT_TRAITS_MEMBER(key_modifiers_) IPC_STRUCT_TRAITS_MEMBER(key_modifiers_)
IPC_STRUCT_TRAITS_MEMBER(width_)
IPC_STRUCT_TRAITS_MEMBER(height_)
IPC_STRUCT_TRAITS_MEMBER(rotation_angle_)
IPC_STRUCT_TRAITS_MEMBER(force_)
IPC_STRUCT_TRAITS_END() IPC_STRUCT_TRAITS_END()
IPC_STRUCT_TRAITS_BEGIN(content::SyntheticPointerActionListParams) IPC_STRUCT_TRAITS_BEGIN(content::SyntheticPointerActionListParams)
......
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