OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "components/test_runner/event_sender.h" | 5 #include "components/test_runner/event_sender.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
51 using blink::WebString; | 51 using blink::WebString; |
52 using blink::WebTouchEvent; | 52 using blink::WebTouchEvent; |
53 using blink::WebTouchPoint; | 53 using blink::WebTouchPoint; |
54 using blink::WebVector; | 54 using blink::WebVector; |
55 using blink::WebView; | 55 using blink::WebView; |
56 | 56 |
57 namespace test_runner { | 57 namespace test_runner { |
58 | 58 |
59 namespace { | 59 namespace { |
60 | 60 |
61 const char* kPointerTypeStringUnknown = ""; | |
62 const char* kPointerTypeStringMouse = "mouse"; | |
63 const char* kPointerTypeStringPen = "pen"; | |
64 const char* kPointerTypeStringTouch = "touch"; | |
65 | |
66 bool getPointerType(gin::Arguments* args, | |
67 blink::WebPointerProperties::PointerType &t) { | |
68 if (!args->PeekNext().IsEmpty()) { | |
69 std::string pointer_type_string; | |
70 if (!args->GetNext(&pointer_type_string)) { | |
71 args->ThrowError(); | |
72 return true; | |
73 } | |
74 if (pointer_type_string == kPointerTypeStringUnknown) { | |
75 t = WebMouseEvent::PointerType::Unknown; | |
76 } else if (pointer_type_string == kPointerTypeStringMouse) { | |
77 t = WebMouseEvent::PointerType::Mouse; | |
78 } else if (pointer_type_string == kPointerTypeStringPen) { | |
79 t = WebMouseEvent::PointerType::Pen; | |
80 } else if (pointer_type_string == kPointerTypeStringTouch) { | |
81 t = WebMouseEvent::PointerType::Touch; | |
82 } else { | |
83 args->ThrowError(); | |
84 return true; | |
85 } | |
86 } | |
87 return false; | |
88 } | |
89 | |
61 WebMouseEvent::Button GetButtonTypeFromButtonNumber(int button_code) { | 90 WebMouseEvent::Button GetButtonTypeFromButtonNumber(int button_code) { |
62 switch (button_code) { | 91 switch (button_code) { |
63 case -1: | 92 case -1: |
64 return WebMouseEvent::ButtonNone; | 93 return WebMouseEvent::ButtonNone; |
65 case 0: | 94 case 0: |
66 return WebMouseEvent::ButtonLeft; | 95 return WebMouseEvent::ButtonLeft; |
67 case 1: | 96 case 1: |
68 return WebMouseEvent::ButtonMiddle; | 97 return WebMouseEvent::ButtonMiddle; |
69 case 2: | 98 case 2: |
70 return WebMouseEvent::ButtonRight; | 99 return WebMouseEvent::ButtonRight; |
(...skipping 25 matching lines...) Expand all Loading... | |
96 | (buttons & kButtonsInModifiers); | 125 | (buttons & kButtonsInModifiers); |
97 } | 126 } |
98 | 127 |
99 void InitMouseEvent(WebInputEvent::Type t, | 128 void InitMouseEvent(WebInputEvent::Type t, |
100 WebMouseEvent::Button b, | 129 WebMouseEvent::Button b, |
101 int current_buttons, | 130 int current_buttons, |
102 const WebPoint& pos, | 131 const WebPoint& pos, |
103 double time_stamp, | 132 double time_stamp, |
104 int click_count, | 133 int click_count, |
105 int modifiers, | 134 int modifiers, |
135 blink::WebPointerProperties::PointerType pointerType, | |
136 int pointerId, | |
106 WebMouseEvent* e) { | 137 WebMouseEvent* e) { |
107 e->type = t; | 138 e->type = t; |
108 e->button = b; | 139 e->button = b; |
109 e->modifiers = modifiersWithButtons(modifiers, current_buttons); | 140 e->modifiers = modifiersWithButtons(modifiers, current_buttons); |
110 e->x = pos.x; | 141 e->x = pos.x; |
111 e->y = pos.y; | 142 e->y = pos.y; |
112 e->globalX = pos.x; | 143 e->globalX = pos.x; |
113 e->globalY = pos.y; | 144 e->globalY = pos.y; |
114 e->pointerType = blink::WebPointerProperties::PointerType::Mouse; | 145 e->pointerType = pointerType; |
146 e->id = pointerId; | |
115 e->timeStampSeconds = time_stamp; | 147 e->timeStampSeconds = time_stamp; |
116 e->clickCount = click_count; | 148 e->clickCount = click_count; |
117 } | 149 } |
118 | 150 |
119 void InitGestureEventFromMouseWheel(WebInputEvent::Type type, | 151 void InitGestureEventFromMouseWheel(WebInputEvent::Type type, |
120 double time_stamp, | 152 double time_stamp, |
121 const WebMouseWheelEvent& wheel_event, | 153 const WebMouseWheelEvent& wheel_event, |
122 WebGestureEvent* gesture_event) { | 154 WebGestureEvent* gesture_event) { |
123 gesture_event->type = type; | 155 gesture_event->type = type; |
124 gesture_event->sourceDevice = blink::WebGestureDeviceTouchpad; | 156 gesture_event->sourceDevice = blink::WebGestureDeviceTouchpad; |
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
448 } | 480 } |
449 } else { | 481 } else { |
450 *units = WebGestureEvent::PrecisePixels; | 482 *units = WebGestureEvent::PrecisePixels; |
451 return true; | 483 return true; |
452 } | 484 } |
453 } | 485 } |
454 | 486 |
455 const char* kSourceDeviceStringTouchpad = "touchpad"; | 487 const char* kSourceDeviceStringTouchpad = "touchpad"; |
456 const char* kSourceDeviceStringTouchscreen = "touchscreen"; | 488 const char* kSourceDeviceStringTouchscreen = "touchscreen"; |
457 | 489 |
458 const char* kPointerTypeStringUnknown = ""; | |
459 const char* kPointerTypeStringMouse = "mouse"; | |
460 const char* kPointerTypeStringPen = "pen"; | |
461 const char* kPointerTypeStringTouch = "touch"; | |
462 | |
463 } // namespace | 490 } // namespace |
464 | 491 |
465 class EventSenderBindings : public gin::Wrappable<EventSenderBindings> { | 492 class EventSenderBindings : public gin::Wrappable<EventSenderBindings> { |
466 public: | 493 public: |
467 static gin::WrapperInfo kWrapperInfo; | 494 static gin::WrapperInfo kWrapperInfo; |
468 | 495 |
469 static void Install(base::WeakPtr<EventSender> sender, | 496 static void Install(base::WeakPtr<EventSender> sender, |
470 blink::WebFrame* frame); | 497 blink::WebFrame* frame); |
471 | 498 |
472 private: | 499 private: |
(...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
971 sender_->ScheduleAsynchronousKeyDown(code_str, modifiers, | 998 sender_->ScheduleAsynchronousKeyDown(code_str, modifiers, |
972 static_cast<KeyLocationCode>(location)); | 999 static_cast<KeyLocationCode>(location)); |
973 } | 1000 } |
974 | 1001 |
975 void EventSenderBindings::MouseDown(gin::Arguments* args) { | 1002 void EventSenderBindings::MouseDown(gin::Arguments* args) { |
976 if (!sender_) | 1003 if (!sender_) |
977 return; | 1004 return; |
978 | 1005 |
979 int button_number = 0; | 1006 int button_number = 0; |
980 int modifiers = 0; | 1007 int modifiers = 0; |
1008 blink::WebPointerProperties::PointerType type = | |
1009 blink::WebPointerProperties::PointerType::Mouse; | |
1010 int pointerId = 0; | |
981 if (!args->PeekNext().IsEmpty()) { | 1011 if (!args->PeekNext().IsEmpty()) { |
982 args->GetNext(&button_number); | 1012 args->GetNext(&button_number); |
983 if (!args->PeekNext().IsEmpty()) | 1013 if (!args->PeekNext().IsEmpty()) { |
984 modifiers = GetKeyModifiersFromV8(args->isolate(), args->PeekNext()); | 1014 modifiers = GetKeyModifiersFromV8(args->isolate(), args->PeekNext()); |
1015 args->Skip(); | |
1016 } | |
985 } | 1017 } |
986 sender_->MouseDown(button_number, modifiers); | 1018 getPointerType(args, type); |
1019 if (!args->PeekNext().IsEmpty()) | |
1020 args->GetNext(&pointerId); | |
1021 | |
1022 // Only allow pen or mouse through this API; | |
1023 if (type != blink::WebPointerProperties::PointerType::Mouse | |
1024 && type != blink::WebPointerProperties::PointerType::Pen) | |
1025 type = blink::WebPointerProperties::PointerType::Mouse; | |
1026 | |
1027 sender_->MouseDown(button_number, modifiers, type, pointerId); | |
987 } | 1028 } |
988 | 1029 |
989 void EventSenderBindings::MouseUp(gin::Arguments* args) { | 1030 void EventSenderBindings::MouseUp(gin::Arguments* args) { |
990 if (!sender_) | 1031 if (!sender_) |
991 return; | 1032 return; |
992 | 1033 |
993 int button_number = 0; | 1034 int button_number = 0; |
994 int modifiers = 0; | 1035 int modifiers = 0; |
1036 blink::WebPointerProperties::PointerType type = | |
1037 blink::WebPointerProperties::PointerType::Mouse; | |
1038 int pointerId = 0; | |
995 if (!args->PeekNext().IsEmpty()) { | 1039 if (!args->PeekNext().IsEmpty()) { |
996 args->GetNext(&button_number); | 1040 args->GetNext(&button_number); |
997 if (!args->PeekNext().IsEmpty()) | 1041 if (!args->PeekNext().IsEmpty()) { |
998 modifiers = GetKeyModifiersFromV8(args->isolate(), args->PeekNext()); | 1042 modifiers = GetKeyModifiersFromV8(args->isolate(), args->PeekNext()); |
1043 args->Skip(); | |
1044 } | |
999 } | 1045 } |
1000 sender_->MouseUp(button_number, modifiers); | 1046 getPointerType(args, type); |
dtapuska
2016/04/05 19:21:25
This API returns a bool... should we handle the re
Navid Zolghadr
2016/04/05 20:17:25
I wanted to do that too. However this function was
dtapuska
2016/04/05 20:30:40
looks good.
| |
1047 if (!args->PeekNext().IsEmpty()) | |
1048 args->GetNext(&pointerId); | |
1049 | |
1050 // Only allow pen or mouse through this API; | |
1051 if (type != blink::WebPointerProperties::PointerType::Mouse | |
dtapuska
2016/04/05 19:21:24
Personally I think a switch is easier to read. Als
Navid Zolghadr
2016/04/05 20:17:25
I changed the way I handle this. I moved it to get
dtapuska
2016/04/05 20:30:40
Seems reasonable to me.
| |
1052 && type != blink::WebPointerProperties::PointerType::Pen) | |
1053 type = blink::WebPointerProperties::PointerType::Mouse; | |
1054 | |
1055 sender_->MouseUp(button_number, modifiers, type, pointerId); | |
1001 } | 1056 } |
1002 | 1057 |
1003 void EventSenderBindings::SetMouseButtonState(gin::Arguments* args) { | 1058 void EventSenderBindings::SetMouseButtonState(gin::Arguments* args) { |
1004 if (!sender_) | 1059 if (!sender_) |
1005 return; | 1060 return; |
1006 | 1061 |
1007 int button_number; | 1062 int button_number; |
1008 if (!args->GetNext(&button_number)) { | 1063 if (!args->GetNext(&button_number)) { |
1009 args->ThrowError(); | 1064 args->ThrowError(); |
1010 return; | 1065 return; |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1196 | 1251 |
1197 EventSender::~EventSender() {} | 1252 EventSender::~EventSender() {} |
1198 | 1253 |
1199 void EventSender::Reset() { | 1254 void EventSender::Reset() { |
1200 DCHECK(current_drag_data_.isNull()); | 1255 DCHECK(current_drag_data_.isNull()); |
1201 current_drag_data_.reset(); | 1256 current_drag_data_.reset(); |
1202 current_drag_effect_ = blink::WebDragOperationNone; | 1257 current_drag_effect_ = blink::WebDragOperationNone; |
1203 current_drag_effects_allowed_ = blink::WebDragOperationNone; | 1258 current_drag_effects_allowed_ = blink::WebDragOperationNone; |
1204 if (view_ && pressed_button_ != WebMouseEvent::ButtonNone) | 1259 if (view_ && pressed_button_ != WebMouseEvent::ButtonNone) |
1205 view_->mouseCaptureLost(); | 1260 view_->mouseCaptureLost(); |
1261 stateOfPen.clear(); | |
1206 pressed_button_ = WebMouseEvent::ButtonNone; | 1262 pressed_button_ = WebMouseEvent::ButtonNone; |
1207 current_buttons_ = 0; | 1263 current_buttons_ = 0; |
1208 modifiers_ = 0; | 1264 modifiers_ = 0; |
1209 is_drag_mode_ = true; | 1265 is_drag_mode_ = true; |
1210 force_layout_on_events_ = true; | 1266 force_layout_on_events_ = true; |
1211 | 1267 |
1212 #if defined(OS_WIN) | 1268 #if defined(OS_WIN) |
1213 wm_key_down_ = WM_KEYDOWN; | 1269 wm_key_down_ = WM_KEYDOWN; |
1214 wm_key_up_ = WM_KEYUP; | 1270 wm_key_up_ = WM_KEYUP; |
1215 wm_char_ = WM_CHAR; | 1271 wm_char_ = WM_CHAR; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1257 void EventSender::DoDragDrop(const WebDragData& drag_data, | 1313 void EventSender::DoDragDrop(const WebDragData& drag_data, |
1258 WebDragOperationsMask mask) { | 1314 WebDragOperationsMask mask) { |
1259 WebMouseEvent event; | 1315 WebMouseEvent event; |
1260 InitMouseEvent(WebInputEvent::MouseDown, | 1316 InitMouseEvent(WebInputEvent::MouseDown, |
1261 pressed_button_, | 1317 pressed_button_, |
1262 current_buttons_, | 1318 current_buttons_, |
1263 last_mouse_pos_, | 1319 last_mouse_pos_, |
1264 GetCurrentEventTimeSec(), | 1320 GetCurrentEventTimeSec(), |
1265 click_count_, | 1321 click_count_, |
1266 modifiers_, | 1322 modifiers_, |
1323 blink::WebPointerProperties::PointerType::Mouse, | |
1324 0, | |
1267 &event); | 1325 &event); |
1268 WebPoint client_point(event.x, event.y); | 1326 WebPoint client_point(event.x, event.y); |
1269 WebPoint screen_point(event.globalX, event.globalY); | 1327 WebPoint screen_point(event.globalX, event.globalY); |
1270 current_drag_data_ = drag_data; | 1328 current_drag_data_ = drag_data; |
1271 current_drag_effects_allowed_ = mask; | 1329 current_drag_effects_allowed_ = mask; |
1272 current_drag_effect_ = view_->dragTargetDragEnter( | 1330 current_drag_effect_ = view_->dragTargetDragEnter( |
1273 drag_data, | 1331 drag_data, |
1274 client_point, | 1332 client_point, |
1275 screen_point, | 1333 screen_point, |
1276 current_drag_effects_allowed_, | 1334 current_drag_effects_allowed_, |
1277 modifiersWithButtons(modifiers_, current_buttons_)); | 1335 modifiersWithButtons(modifiers_, current_buttons_)); |
1278 | 1336 |
1279 // Finish processing events. | 1337 // Finish processing events. |
1280 ReplaySavedEvents(); | 1338 ReplaySavedEvents(); |
1281 } | 1339 } |
1282 | 1340 |
1283 void EventSender::MouseDown(int button_number, int modifiers) { | 1341 void EventSender::MouseDown(int button_number, int modifiers, |
1342 blink::WebPointerProperties::PointerType pointerType, int pointerId) { | |
1284 if (force_layout_on_events_) | 1343 if (force_layout_on_events_) |
1285 view_->updateAllLifecyclePhases(); | 1344 view_->updateAllLifecyclePhases(); |
1286 | 1345 |
1287 DCHECK_NE(-1, button_number); | 1346 DCHECK_NE(-1, button_number); |
1288 | 1347 |
1289 WebMouseEvent::Button button_type = | 1348 WebMouseEvent::Button button_type = |
1290 GetButtonTypeFromButtonNumber(button_number); | 1349 GetButtonTypeFromButtonNumber(button_number); |
1291 | 1350 |
1292 UpdateClickCountForButton(button_type); | 1351 WebMouseEvent event; |
1352 if (pointerType == blink::WebPointerProperties::PointerType::Mouse) { | |
1353 UpdateClickCountForButton(button_type); | |
1293 | 1354 |
1294 pressed_button_ = button_type; | 1355 pressed_button_ = button_type; |
1295 current_buttons_ |= GetWebMouseEventModifierForButton(pressed_button_); | 1356 current_buttons_ |= GetWebMouseEventModifierForButton(pressed_button_); |
1296 modifiers_ = modifiers; | 1357 modifiers_ = modifiers; |
1358 InitMouseEvent(WebInputEvent::MouseDown, | |
1359 pressed_button_, | |
dtapuska
2016/04/05 19:21:25
Would it make sense to store some of this in the s
Navid Zolghadr
2016/04/05 20:17:25
I'd like to do that too as it is pretty much the s
dtapuska
2016/04/05 20:30:40
The current_pen_state_ is a unordered_map; so I'd
| |
1360 current_buttons_, | |
1361 last_mouse_pos_, | |
1362 GetCurrentEventTimeSec(), | |
1363 click_count_, | |
1364 modifiers_, | |
1365 pointerType, | |
1366 0, | |
1367 &event); | |
1368 } else { | |
1369 stateOfPen[pointerId].pressed_button_ = button_type; | |
1370 stateOfPen[pointerId].current_buttons_ |= | |
1371 GetWebMouseEventModifierForButton(pressed_button_); | |
1372 stateOfPen[pointerId].modifiers_ = modifiers; | |
1373 InitMouseEvent(WebInputEvent::MouseDown, | |
1374 stateOfPen[pointerId].pressed_button_, | |
1375 stateOfPen[pointerId].current_buttons_, | |
1376 stateOfPen[pointerId].last_pos_, | |
1377 GetCurrentEventTimeSec(), | |
1378 0, | |
1379 modifiers_, | |
1380 pointerType, | |
1381 pointerId, | |
1382 &event); | |
1383 } | |
1297 | 1384 |
1298 WebMouseEvent event; | |
1299 InitMouseEvent(WebInputEvent::MouseDown, | |
1300 pressed_button_, | |
1301 current_buttons_, | |
1302 last_mouse_pos_, | |
1303 GetCurrentEventTimeSec(), | |
1304 click_count_, | |
1305 modifiers_, | |
1306 &event); | |
1307 HandleInputEventOnViewOrPopup(event); | 1385 HandleInputEventOnViewOrPopup(event); |
1308 } | 1386 } |
1309 | 1387 |
1310 void EventSender::MouseUp(int button_number, int modifiers) { | 1388 void EventSender::MouseUp(int button_number, int modifiers, |
1389 blink::WebPointerProperties::PointerType pointerType, int pointerId) { | |
1311 if (force_layout_on_events_) | 1390 if (force_layout_on_events_) |
1312 view_->updateAllLifecyclePhases(); | 1391 view_->updateAllLifecyclePhases(); |
1313 | 1392 |
1314 DCHECK_NE(-1, button_number); | 1393 DCHECK_NE(-1, button_number); |
1315 | 1394 |
1316 WebMouseEvent::Button button_type = | 1395 WebMouseEvent::Button button_type = |
1317 GetButtonTypeFromButtonNumber(button_number); | 1396 GetButtonTypeFromButtonNumber(button_number); |
1318 | 1397 |
1319 if (is_drag_mode_ && !replaying_saved_events_) { | 1398 if (pointerType == blink::WebPointerProperties::PointerType::Mouse) { |
1320 SavedEvent saved_event; | 1399 if (is_drag_mode_ && !replaying_saved_events_) { |
1321 saved_event.type = SavedEvent::TYPE_MOUSE_UP; | 1400 SavedEvent saved_event; |
1322 saved_event.button_type = button_type; | 1401 saved_event.type = SavedEvent::TYPE_MOUSE_UP; |
1323 saved_event.modifiers = modifiers; | 1402 saved_event.button_type = button_type; |
1324 mouse_event_queue_.push_back(saved_event); | 1403 saved_event.modifiers = modifiers; |
1325 ReplaySavedEvents(); | 1404 mouse_event_queue_.push_back(saved_event); |
1405 ReplaySavedEvents(); | |
1406 } else { | |
1407 current_buttons_ &= ~GetWebMouseEventModifierForButton(button_type); | |
1408 pressed_button_ = WebMouseEvent::ButtonNone; | |
1409 | |
1410 WebMouseEvent event; | |
1411 InitMouseEvent(WebInputEvent::MouseUp, | |
1412 button_type, | |
1413 current_buttons_, | |
1414 last_mouse_pos_, | |
1415 GetCurrentEventTimeSec(), | |
1416 click_count_, | |
1417 modifiers, | |
1418 pointerType, | |
1419 0, | |
1420 &event); | |
1421 DoMouseUp(event); | |
1422 } | |
1326 } else { | 1423 } else { |
1327 current_buttons_ &= ~GetWebMouseEventModifierForButton(button_type); | 1424 stateOfPen[pointerId].current_buttons_ &= |
1328 pressed_button_ = WebMouseEvent::ButtonNone; | 1425 ~GetWebMouseEventModifierForButton(button_type); |
1426 stateOfPen[pointerId].pressed_button_ = WebMouseEvent::ButtonNone; | |
1329 | 1427 |
1330 WebMouseEvent event; | 1428 WebMouseEvent event; |
1331 InitMouseEvent(WebInputEvent::MouseUp, | 1429 InitMouseEvent(WebInputEvent::MouseUp, |
1332 button_type, | 1430 button_type, |
1333 current_buttons_, | 1431 stateOfPen[pointerId].current_buttons_, |
1334 last_mouse_pos_, | 1432 stateOfPen[pointerId].last_pos_, |
1335 GetCurrentEventTimeSec(), | 1433 GetCurrentEventTimeSec(), |
1336 click_count_, | 1434 0, |
1337 modifiers, | 1435 modifiers, |
1338 &event); | 1436 pointerType, |
1339 DoMouseUp(event); | 1437 pointerId, |
1438 &event); | |
1439 HandleInputEventOnViewOrPopup(event); | |
1340 } | 1440 } |
1341 } | 1441 } |
1342 | 1442 |
1343 void EventSender::SetMouseButtonState(int button_number, int modifiers) { | 1443 void EventSender::SetMouseButtonState(int button_number, int modifiers) { |
1344 pressed_button_ = GetButtonTypeFromButtonNumber(button_number); | 1444 pressed_button_ = GetButtonTypeFromButtonNumber(button_number); |
1345 current_buttons_ = (modifiers == -1) ? | 1445 current_buttons_ = (modifiers == -1) ? |
1346 GetWebMouseEventModifierForButton(pressed_button_) : | 1446 GetWebMouseEventModifierForButton(pressed_button_) : |
1347 modifiers & kButtonsInModifiers; | 1447 modifiers & kButtonsInModifiers; |
1348 } | 1448 } |
1349 | 1449 |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1543 | 1643 |
1544 if (code == ui::VKEY_ESCAPE && !current_drag_data_.isNull()) { | 1644 if (code == ui::VKEY_ESCAPE && !current_drag_data_.isNull()) { |
1545 WebMouseEvent event; | 1645 WebMouseEvent event; |
1546 InitMouseEvent(WebInputEvent::MouseDown, | 1646 InitMouseEvent(WebInputEvent::MouseDown, |
1547 pressed_button_, | 1647 pressed_button_, |
1548 current_buttons_, | 1648 current_buttons_, |
1549 last_mouse_pos_, | 1649 last_mouse_pos_, |
1550 GetCurrentEventTimeSec(), | 1650 GetCurrentEventTimeSec(), |
1551 click_count_, | 1651 click_count_, |
1552 0, | 1652 0, |
1653 blink::WebPointerProperties::PointerType::Mouse, | |
1654 0, | |
1553 &event); | 1655 &event); |
1554 FinishDragAndDrop(event, blink::WebDragOperationNone); | 1656 FinishDragAndDrop(event, blink::WebDragOperationNone); |
1555 } | 1657 } |
1556 | 1658 |
1557 delegate_->ClearEditCommand(); | 1659 delegate_->ClearEditCommand(); |
1558 | 1660 |
1559 if (generate_char) { | 1661 if (generate_char) { |
1560 WebKeyboardEvent event_char = event_up; | 1662 WebKeyboardEvent event_char = event_up; |
1561 event_char.type = WebInputEvent::Char; | 1663 event_char.type = WebInputEvent::Char; |
1562 // keyIdentifier is an empty string, unless the Enter key was pressed. | 1664 // keyIdentifier is an empty string, unless the Enter key was pressed. |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1598 pressed_button_ = WebMouseEvent::ButtonRight; | 1700 pressed_button_ = WebMouseEvent::ButtonRight; |
1599 current_buttons_ |= GetWebMouseEventModifierForButton(pressed_button_); | 1701 current_buttons_ |= GetWebMouseEventModifierForButton(pressed_button_); |
1600 } | 1702 } |
1601 InitMouseEvent(WebInputEvent::MouseDown, | 1703 InitMouseEvent(WebInputEvent::MouseDown, |
1602 WebMouseEvent::ButtonRight, | 1704 WebMouseEvent::ButtonRight, |
1603 current_buttons_, | 1705 current_buttons_, |
1604 last_mouse_pos_, | 1706 last_mouse_pos_, |
1605 GetCurrentEventTimeSec(), | 1707 GetCurrentEventTimeSec(), |
1606 click_count_, | 1708 click_count_, |
1607 0, | 1709 0, |
1710 blink::WebPointerProperties::PointerType::Mouse, | |
1711 0, | |
1608 &event); | 1712 &event); |
1609 HandleInputEventOnViewOrPopup(event); | 1713 HandleInputEventOnViewOrPopup(event); |
1610 | 1714 |
1611 #if defined(OS_WIN) | 1715 #if defined(OS_WIN) |
1612 current_buttons_ &= | 1716 current_buttons_ &= |
1613 ~GetWebMouseEventModifierForButton(WebMouseEvent::ButtonRight); | 1717 ~GetWebMouseEventModifierForButton(WebMouseEvent::ButtonRight); |
1614 pressed_button_ = WebMouseEvent::ButtonNone; | 1718 pressed_button_ = WebMouseEvent::ButtonNone; |
1615 | 1719 |
1616 InitMouseEvent(WebInputEvent::MouseUp, | 1720 InitMouseEvent(WebInputEvent::MouseUp, |
1617 WebMouseEvent::ButtonRight, | 1721 WebMouseEvent::ButtonRight, |
1618 current_buttons_, | 1722 current_buttons_, |
1619 last_mouse_pos_, | 1723 last_mouse_pos_, |
1620 GetCurrentEventTimeSec(), | 1724 GetCurrentEventTimeSec(), |
1621 click_count_, | 1725 click_count_, |
1622 0, | 1726 0, |
1727 blink::WebPointerProperties::PointerType::Mouse, | |
1728 0, | |
1623 &event); | 1729 &event); |
1624 HandleInputEventOnViewOrPopup(event); | 1730 HandleInputEventOnViewOrPopup(event); |
1625 #endif | 1731 #endif |
1626 | 1732 |
1627 std::vector<std::string> menu_items = | 1733 std::vector<std::string> menu_items = |
1628 MakeMenuItemStringsFor(last_context_menu_data_.get(), delegate_); | 1734 MakeMenuItemStringsFor(last_context_menu_data_.get(), delegate_); |
1629 last_context_menu_data_.reset(); | 1735 last_context_menu_data_.reset(); |
1630 return menu_items; | 1736 return menu_items; |
1631 } | 1737 } |
1632 | 1738 |
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1966 SendGesturesForMouseWheelEvent(wheel_event); | 2072 SendGesturesForMouseWheelEvent(wheel_event); |
1967 } | 2073 } |
1968 } | 2074 } |
1969 | 2075 |
1970 void EventSender::MouseMoveTo(gin::Arguments* args) { | 2076 void EventSender::MouseMoveTo(gin::Arguments* args) { |
1971 if (force_layout_on_events_) | 2077 if (force_layout_on_events_) |
1972 view_->updateAllLifecyclePhases(); | 2078 view_->updateAllLifecyclePhases(); |
1973 | 2079 |
1974 double x; | 2080 double x; |
1975 double y; | 2081 double y; |
2082 blink::WebPointerProperties::PointerType pointerType = | |
2083 blink::WebPointerProperties::PointerType::Mouse; | |
2084 int pointerId = 0; | |
1976 if (!args->GetNext(&x) || !args->GetNext(&y)) { | 2085 if (!args->GetNext(&x) || !args->GetNext(&y)) { |
1977 args->ThrowError(); | 2086 args->ThrowError(); |
1978 return; | 2087 return; |
1979 } | 2088 } |
1980 WebPoint mouse_pos(static_cast<int>(x), static_cast<int>(y)); | 2089 WebPoint mouse_pos(static_cast<int>(x), static_cast<int>(y)); |
1981 | 2090 |
1982 int modifiers = 0; | 2091 int modifiers = 0; |
2092 if (!args->PeekNext().IsEmpty()) { | |
2093 modifiers = GetKeyModifiersFromV8(args->isolate(), args->PeekNext()); | |
2094 args->Skip(); | |
2095 } | |
2096 | |
2097 getPointerType(args, pointerType); | |
dtapuska
2016/04/05 19:21:25
same comments regarding return type.
Navid Zolghadr
2016/04/05 20:17:25
Done.
| |
2098 | |
1983 if (!args->PeekNext().IsEmpty()) | 2099 if (!args->PeekNext().IsEmpty()) |
1984 modifiers = GetKeyModifiersFromV8(args->isolate(), args->PeekNext()); | 2100 args->GetNext(&pointerId); |
1985 | 2101 |
1986 if (is_drag_mode_ && pressed_button_ == WebMouseEvent::ButtonLeft && | 2102 if (pointerType == blink::WebPointerProperties::PointerType::Mouse) { |
1987 !replaying_saved_events_) { | 2103 if (is_drag_mode_ && pressed_button_ == WebMouseEvent::ButtonLeft && |
1988 SavedEvent saved_event; | 2104 !replaying_saved_events_) { |
1989 saved_event.type = SavedEvent::TYPE_MOUSE_MOVE; | 2105 SavedEvent saved_event; |
1990 saved_event.pos = mouse_pos; | 2106 saved_event.type = SavedEvent::TYPE_MOUSE_MOVE; |
1991 saved_event.modifiers = modifiers; | 2107 saved_event.pos = mouse_pos; |
1992 mouse_event_queue_.push_back(saved_event); | 2108 saved_event.modifiers = modifiers; |
2109 mouse_event_queue_.push_back(saved_event); | |
2110 } else { | |
2111 WebMouseEvent event; | |
2112 InitMouseEvent(WebInputEvent::MouseMove, | |
2113 pressed_button_, | |
2114 current_buttons_, | |
2115 mouse_pos, | |
2116 GetCurrentEventTimeSec(), | |
2117 click_count_, | |
2118 modifiers, | |
2119 pointerType, | |
2120 0, | |
2121 &event); | |
2122 DoMouseMove(event); | |
2123 } | |
1993 } else { | 2124 } else { |
1994 WebMouseEvent event; | 2125 stateOfPen[pointerId].last_pos_ = mouse_pos; |
1995 InitMouseEvent(WebInputEvent::MouseMove, | 2126 |
1996 pressed_button_, | 2127 WebMouseEvent event; |
1997 current_buttons_, | 2128 InitMouseEvent(WebInputEvent::MouseMove, |
1998 mouse_pos, | 2129 stateOfPen[pointerId].pressed_button_, |
1999 GetCurrentEventTimeSec(), | 2130 stateOfPen[pointerId].current_buttons_, |
2000 click_count_, | 2131 mouse_pos, |
2001 modifiers, | 2132 GetCurrentEventTimeSec(), |
2002 &event); | 2133 0, |
2003 DoMouseMove(event); | 2134 modifiers, |
2135 pointerType, | |
2136 pointerId, | |
2137 &event); | |
2138 HandleInputEventOnViewOrPopup(event); | |
2004 } | 2139 } |
2005 } | 2140 } |
2006 | 2141 |
2007 void EventSender::MouseLeave() { | 2142 void EventSender::MouseLeave() { |
2008 if (force_layout_on_events_) | 2143 if (force_layout_on_events_) |
2009 view_->updateAllLifecyclePhases(); | 2144 view_->updateAllLifecyclePhases(); |
2010 | 2145 |
2011 WebMouseEvent event; | 2146 WebMouseEvent event; |
2012 InitMouseEvent(WebInputEvent::MouseLeave, | 2147 InitMouseEvent(WebInputEvent::MouseLeave, |
2013 WebMouseEvent::ButtonNone, | 2148 WebMouseEvent::ButtonNone, |
2014 0, | 2149 0, |
2015 last_mouse_pos_, | 2150 last_mouse_pos_, |
2016 GetCurrentEventTimeSec(), | 2151 GetCurrentEventTimeSec(), |
2017 click_count_, | 2152 click_count_, |
2018 0, | 2153 0, |
2154 blink::WebPointerProperties::PointerType::Mouse, | |
2155 0, | |
2019 &event); | 2156 &event); |
2020 HandleInputEventOnViewOrPopup(event); | 2157 HandleInputEventOnViewOrPopup(event); |
2021 } | 2158 } |
2022 | 2159 |
2023 | 2160 |
2024 void EventSender::ScheduleAsynchronousClick(int button_number, int modifiers) { | 2161 void EventSender::ScheduleAsynchronousClick(int button_number, int modifiers) { |
2025 delegate_->PostTask(new MouseDownTask(this, button_number, modifiers)); | 2162 delegate_->PostTask(new MouseDownTask(this, button_number, modifiers)); |
2026 delegate_->PostTask(new MouseUpTask(this, button_number, modifiers)); | 2163 delegate_->PostTask(new MouseUpTask(this, button_number, modifiers)); |
2027 } | 2164 } |
2028 | 2165 |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2326 // Long press might start a drag drop session. Complete it if so. | 2463 // Long press might start a drag drop session. Complete it if so. |
2327 if (type == WebInputEvent::GestureLongPress && !current_drag_data_.isNull()) { | 2464 if (type == WebInputEvent::GestureLongPress && !current_drag_data_.isNull()) { |
2328 WebMouseEvent mouse_event; | 2465 WebMouseEvent mouse_event; |
2329 InitMouseEvent(WebInputEvent::MouseDown, | 2466 InitMouseEvent(WebInputEvent::MouseDown, |
2330 pressed_button_, | 2467 pressed_button_, |
2331 current_buttons_, | 2468 current_buttons_, |
2332 WebPoint(x, y), | 2469 WebPoint(x, y), |
2333 GetCurrentEventTimeSec(), | 2470 GetCurrentEventTimeSec(), |
2334 click_count_, | 2471 click_count_, |
2335 modifiers_, | 2472 modifiers_, |
2473 blink::WebPointerProperties::PointerType::Mouse, | |
2474 0, | |
2336 &mouse_event); | 2475 &mouse_event); |
2337 | 2476 |
2338 FinishDragAndDrop(mouse_event, blink::WebDragOperationNone); | 2477 FinishDragAndDrop(mouse_event, blink::WebDragOperationNone); |
2339 } | 2478 } |
2340 args->Return(result != WebInputEventResult::NotHandled); | 2479 args->Return(result != WebInputEventResult::NotHandled); |
2341 } | 2480 } |
2342 | 2481 |
2343 void EventSender::UpdateClickCountForButton( | 2482 void EventSender::UpdateClickCountForButton( |
2344 WebMouseEvent::Button button_type) { | 2483 WebMouseEvent::Button button_type) { |
2345 if ((GetCurrentEventTimeSec() - last_click_time_sec_ < | 2484 if ((GetCurrentEventTimeSec() - last_click_time_sec_ < |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2397 *send_gestures = true; | 2536 *send_gestures = true; |
2398 } | 2537 } |
2399 | 2538 |
2400 InitMouseEvent(WebInputEvent::MouseWheel, | 2539 InitMouseEvent(WebInputEvent::MouseWheel, |
2401 pressed_button_, | 2540 pressed_button_, |
2402 current_buttons_, | 2541 current_buttons_, |
2403 last_mouse_pos_, | 2542 last_mouse_pos_, |
2404 GetCurrentEventTimeSec(), | 2543 GetCurrentEventTimeSec(), |
2405 click_count_, | 2544 click_count_, |
2406 modifiers, | 2545 modifiers, |
2546 blink::WebPointerProperties::PointerType::Mouse, | |
2547 0, | |
2407 event); | 2548 event); |
2408 event->wheelTicksX = static_cast<float>(horizontal); | 2549 event->wheelTicksX = static_cast<float>(horizontal); |
2409 event->wheelTicksY = static_cast<float>(vertical); | 2550 event->wheelTicksY = static_cast<float>(vertical); |
2410 event->deltaX = event->wheelTicksX; | 2551 event->deltaX = event->wheelTicksX; |
2411 event->deltaY = event->wheelTicksY; | 2552 event->deltaY = event->wheelTicksY; |
2412 event->scrollByPage = paged; | 2553 event->scrollByPage = paged; |
2413 event->hasPreciseScrollingDeltas = has_precise_scrolling_deltas; | 2554 event->hasPreciseScrollingDeltas = has_precise_scrolling_deltas; |
2414 event->canScroll = can_scroll; | 2555 event->canScroll = can_scroll; |
2415 if (scroll_type == MouseScrollType::PIXEL) { | 2556 if (scroll_type == MouseScrollType::PIXEL) { |
2416 event->wheelTicksX /= kScrollbarPixelsPerTick; | 2557 event->wheelTicksX /= kScrollbarPixelsPerTick; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2459 if (!args->PeekNext().IsEmpty()) { | 2600 if (!args->PeekNext().IsEmpty()) { |
2460 int tiltX, tiltY; | 2601 int tiltX, tiltY; |
2461 if (!args->GetNext(&tiltX) || !args->GetNext(&tiltY)) { | 2602 if (!args->GetNext(&tiltX) || !args->GetNext(&tiltY)) { |
2462 args->ThrowError(); | 2603 args->ThrowError(); |
2463 return; | 2604 return; |
2464 } | 2605 } |
2465 e->tiltX = tiltX; | 2606 e->tiltX = tiltX; |
2466 e->tiltY = tiltY; | 2607 e->tiltY = tiltY; |
2467 } | 2608 } |
2468 | 2609 |
2469 if (!args->PeekNext().IsEmpty()) { | 2610 if (getPointerType(args, e->pointerType)) { |
2470 std::string pointer_type_string; | |
2471 if (!args->GetNext(&pointer_type_string)) { | |
2472 args->ThrowError(); | |
2473 return; | 2611 return; |
2474 } | |
2475 if (pointer_type_string == kPointerTypeStringUnknown) { | |
2476 e->pointerType = WebMouseEvent::PointerType::Unknown; | |
2477 } else if (pointer_type_string == kPointerTypeStringMouse) { | |
2478 e->pointerType = WebMouseEvent::PointerType::Mouse; | |
2479 } else if (pointer_type_string == kPointerTypeStringPen) { | |
2480 e->pointerType = WebMouseEvent::PointerType::Pen; | |
2481 } else if (pointer_type_string == kPointerTypeStringTouch) { | |
2482 e->pointerType = WebMouseEvent::PointerType::Touch; | |
2483 } else { | |
2484 args->ThrowError(); | |
2485 return; | |
2486 } | |
2487 } | 2612 } |
2488 } | 2613 } |
2489 | 2614 |
2490 void EventSender::FinishDragAndDrop(const WebMouseEvent& e, | 2615 void EventSender::FinishDragAndDrop(const WebMouseEvent& e, |
2491 blink::WebDragOperation drag_effect) { | 2616 blink::WebDragOperation drag_effect) { |
2492 WebPoint client_point(e.x, e.y); | 2617 WebPoint client_point(e.x, e.y); |
2493 WebPoint screen_point(e.globalX, e.globalY); | 2618 WebPoint screen_point(e.globalX, e.globalY); |
2494 current_drag_effect_ = drag_effect; | 2619 current_drag_effect_ = drag_effect; |
2495 if (current_drag_effect_) { | 2620 if (current_drag_effect_) { |
2496 // Specifically pass any keyboard modifiers to the drop method. This allows | 2621 // Specifically pass any keyboard modifiers to the drop method. This allows |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2555 switch (e.type) { | 2680 switch (e.type) { |
2556 case SavedEvent::TYPE_MOUSE_MOVE: { | 2681 case SavedEvent::TYPE_MOUSE_MOVE: { |
2557 WebMouseEvent event; | 2682 WebMouseEvent event; |
2558 InitMouseEvent(WebInputEvent::MouseMove, | 2683 InitMouseEvent(WebInputEvent::MouseMove, |
2559 pressed_button_, | 2684 pressed_button_, |
2560 current_buttons_, | 2685 current_buttons_, |
2561 e.pos, | 2686 e.pos, |
2562 GetCurrentEventTimeSec(), | 2687 GetCurrentEventTimeSec(), |
2563 click_count_, | 2688 click_count_, |
2564 e.modifiers, | 2689 e.modifiers, |
2690 blink::WebPointerProperties::PointerType::Mouse, | |
2691 0, | |
2565 &event); | 2692 &event); |
2566 DoMouseMove(event); | 2693 DoMouseMove(event); |
2567 break; | 2694 break; |
2568 } | 2695 } |
2569 case SavedEvent::TYPE_LEAP_FORWARD: | 2696 case SavedEvent::TYPE_LEAP_FORWARD: |
2570 DoLeapForward(e.milliseconds); | 2697 DoLeapForward(e.milliseconds); |
2571 break; | 2698 break; |
2572 case SavedEvent::TYPE_MOUSE_UP: { | 2699 case SavedEvent::TYPE_MOUSE_UP: { |
2573 current_buttons_ &= ~GetWebMouseEventModifierForButton(e.button_type); | 2700 current_buttons_ &= ~GetWebMouseEventModifierForButton(e.button_type); |
2574 pressed_button_ = WebMouseEvent::ButtonNone; | 2701 pressed_button_ = WebMouseEvent::ButtonNone; |
2575 | 2702 |
2576 WebMouseEvent event; | 2703 WebMouseEvent event; |
2577 InitMouseEvent(WebInputEvent::MouseUp, | 2704 InitMouseEvent(WebInputEvent::MouseUp, |
2578 e.button_type, | 2705 e.button_type, |
2579 current_buttons_, | 2706 current_buttons_, |
2580 last_mouse_pos_, | 2707 last_mouse_pos_, |
2581 GetCurrentEventTimeSec(), | 2708 GetCurrentEventTimeSec(), |
2582 click_count_, | 2709 click_count_, |
2583 e.modifiers, | 2710 e.modifiers, |
2711 blink::WebPointerProperties::PointerType::Mouse, | |
2712 0, | |
2584 &event); | 2713 &event); |
2585 DoMouseUp(event); | 2714 DoMouseUp(event); |
2586 break; | 2715 break; |
2587 } | 2716 } |
2588 default: | 2717 default: |
2589 NOTREACHED(); | 2718 NOTREACHED(); |
2590 } | 2719 } |
2591 } | 2720 } |
2592 | 2721 |
2593 replaying_saved_events_ = false; | 2722 replaying_saved_events_ = false; |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2655 &end_event); | 2784 &end_event); |
2656 end_event.data.scrollEnd.deltaUnits = | 2785 end_event.data.scrollEnd.deltaUnits = |
2657 begin_event.data.scrollBegin.deltaHintUnits; | 2786 begin_event.data.scrollBegin.deltaHintUnits; |
2658 | 2787 |
2659 if (force_layout_on_events_) | 2788 if (force_layout_on_events_) |
2660 view_->updateAllLifecyclePhases(); | 2789 view_->updateAllLifecyclePhases(); |
2661 HandleInputEventOnViewOrPopup(end_event); | 2790 HandleInputEventOnViewOrPopup(end_event); |
2662 } | 2791 } |
2663 | 2792 |
2664 } // namespace test_runner | 2793 } // namespace test_runner |
OLD | NEW |