Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1637)

Unified Diff: ui/events/gesture_detection/mock_motion_event.cc

Issue 342633003: [Android] Select text when stylus first button is pressed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: do not select text when two buttons are pressed Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/events/gesture_detection/mock_motion_event.cc
diff --git a/ui/events/gesture_detection/mock_motion_event.cc b/ui/events/gesture_detection/mock_motion_event.cc
index 609c1198769085db43fdc62681e964f980d08c92..7508b747500f26d9544a1d9778d717cf106c96bd 100644
--- a/ui/events/gesture_detection/mock_motion_event.cc
+++ b/ui/events/gesture_detection/mock_motion_event.cc
@@ -11,11 +11,13 @@ using base::TimeTicks;
namespace ui {
MockMotionEvent::MockMotionEvent()
- : action(ACTION_CANCEL), pointer_count(1), touch_major(TOUCH_MAJOR), id(0) {
+ : action(ACTION_CANCEL), pointer_count(1), touch_major(TOUCH_MAJOR), id(0),
+ button_state(0) {
}
MockMotionEvent::MockMotionEvent(Action action)
- : action(action), pointer_count(1), touch_major(TOUCH_MAJOR), id(0) {
+ : action(action), pointer_count(1), touch_major(TOUCH_MAJOR), id(0),
+ button_state(0) {
}
MockMotionEvent::MockMotionEvent(Action action,
@@ -26,8 +28,10 @@ MockMotionEvent::MockMotionEvent(Action action,
pointer_count(1),
time(time),
touch_major(TOUCH_MAJOR),
- id(0) {
+ id(0),
+ button_state(0) {
points[0].SetPoint(x, y);
+ tool_types[0] = TOOL_TYPE_UNKNOWN;
}
MockMotionEvent::MockMotionEvent(Action action,
@@ -40,9 +44,12 @@ MockMotionEvent::MockMotionEvent(Action action,
pointer_count(2),
time(time),
touch_major(TOUCH_MAJOR),
- id(0) {
+ id(0),
+ button_state(0) {
points[0].SetPoint(x0, y0);
+ tool_types[0] = TOOL_TYPE_UNKNOWN;
points[1].SetPoint(x1, y1);
+ tool_types[1] = TOOL_TYPE_UNKNOWN;
}
MockMotionEvent::MockMotionEvent(Action action,
@@ -57,10 +64,14 @@ MockMotionEvent::MockMotionEvent(Action action,
pointer_count(3),
time(time),
touch_major(TOUCH_MAJOR),
- id(0) {
+ id(0),
+ button_state(0) {
points[0].SetPoint(x0, y0);
+ tool_types[0] = TOOL_TYPE_UNKNOWN;
points[1].SetPoint(x1, y1);
+ tool_types[1] = TOOL_TYPE_UNKNOWN;
points[2].SetPoint(x2, y2);
+ tool_types[2] = TOOL_TYPE_UNKNOWN;
}
MockMotionEvent::MockMotionEvent(const MockMotionEvent& other)
@@ -68,9 +79,12 @@ MockMotionEvent::MockMotionEvent(const MockMotionEvent& other)
pointer_count(other.pointer_count),
time(other.time),
touch_major(other.touch_major),
- id(other.GetId()) {
- for (size_t i = 0; i < pointer_count; ++i)
+ id(other.GetId()),
+ button_state(other.GetButtonState()) {
+ for (size_t i = 0; i < pointer_count; ++i) {
points[i] = other.points[i];
+ tool_types[i] = other.tool_types[i];
+ }
}
MockMotionEvent::~MockMotionEvent() {}
@@ -141,11 +155,12 @@ float MockMotionEvent::GetHistoricalY(size_t pointer_index,
}
MotionEvent::ToolType MockMotionEvent::GetToolType(size_t pointer_index) const {
- return MotionEvent::TOOL_TYPE_UNKNOWN;
+ DCHECK_GT(pointer_count, pointer_index);
jdduke (slow) 2014/06/24 15:38:37 Nit: For consistency make this "DCHECK_LT(pointer_
Changwan Ryu 2014/06/25 07:26:21 Done.
+ return tool_types[pointer_index];
}
int MockMotionEvent::GetButtonState() const {
- return 0;
+ return button_state;
}
scoped_ptr<MotionEvent> MockMotionEvent::Clone() const {
@@ -174,12 +189,14 @@ void MockMotionEvent::PressPoint(float x, float y) {
DCHECK_LT(pointer_count, static_cast<size_t>(MAX_POINTERS));
points[pointer_count++] = gfx::PointF(x, y);
+ tool_types[pointer_count] = TOOL_TYPE_UNKNOWN;
action = pointer_count > 1 ? ACTION_POINTER_DOWN : ACTION_DOWN;
}
void MockMotionEvent::MovePoint(size_t index, float x, float y) {
DCHECK_LT(index, pointer_count);
points[index] = gfx::PointF(x, y);
+ tool_types[index] = TOOL_TYPE_UNKNOWN;
action = ACTION_MOVE;
}
@@ -209,4 +226,13 @@ void MockMotionEvent::SetRawOffset(float raw_offset_x, float raw_offset_y) {
raw_offset.set_y(raw_offset_y);
}
+void MockMotionEvent::SetToolType(size_t index, ToolType tool_type) {
+ DCHECK_GT(pointer_count, index);
+ tool_types[index] = tool_type;
+}
+
+void MockMotionEvent::SetButtonState(int new_button_state) {
+ button_state = new_button_state;
+}
+
} // namespace ui

Powered by Google App Engine
This is Rietveld 408576698