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 "content/shell/renderer/test_runner/event_sender.h" | 5 #include "content/shell/renderer/test_runner/event_sender.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
(...skipping 1077 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1088 | 1088 |
1089 void EventSenderBindings::SetWmSysDeadChar(int sys_dead_char) { | 1089 void EventSenderBindings::SetWmSysDeadChar(int sys_dead_char) { |
1090 if (sender_) | 1090 if (sender_) |
1091 sender_->set_wm_sys_dead_char(sys_dead_char); | 1091 sender_->set_wm_sys_dead_char(sys_dead_char); |
1092 } | 1092 } |
1093 #endif | 1093 #endif |
1094 | 1094 |
1095 // EventSender ----------------------------------------------------------------- | 1095 // EventSender ----------------------------------------------------------------- |
1096 | 1096 |
1097 WebMouseEvent::Button EventSender::pressed_button_ = WebMouseEvent::ButtonNone; | 1097 WebMouseEvent::Button EventSender::pressed_button_ = WebMouseEvent::ButtonNone; |
| 1098 int EventSender::modifiers_ = 0; |
1098 | 1099 |
1099 WebPoint EventSender::last_mouse_pos_; | 1100 WebPoint EventSender::last_mouse_pos_; |
1100 | 1101 |
1101 WebMouseEvent::Button EventSender::last_button_type_ = | 1102 WebMouseEvent::Button EventSender::last_button_type_ = |
1102 WebMouseEvent::ButtonNone; | 1103 WebMouseEvent::ButtonNone; |
1103 | 1104 |
1104 EventSender::SavedEvent::SavedEvent() | 1105 EventSender::SavedEvent::SavedEvent() |
1105 : type(TYPE_UNSPECIFIED), | 1106 : type(TYPE_UNSPECIFIED), |
1106 button_type(WebMouseEvent::ButtonNone), | 1107 button_type(WebMouseEvent::ButtonNone), |
1107 milliseconds(0), | 1108 milliseconds(0), |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1192 } | 1193 } |
1193 | 1194 |
1194 void EventSender::DoDragDrop(const WebDragData& drag_data, | 1195 void EventSender::DoDragDrop(const WebDragData& drag_data, |
1195 WebDragOperationsMask mask) { | 1196 WebDragOperationsMask mask) { |
1196 WebMouseEvent event; | 1197 WebMouseEvent event; |
1197 InitMouseEvent(WebInputEvent::MouseDown, | 1198 InitMouseEvent(WebInputEvent::MouseDown, |
1198 pressed_button_, | 1199 pressed_button_, |
1199 last_mouse_pos_, | 1200 last_mouse_pos_, |
1200 GetCurrentEventTimeSec(), | 1201 GetCurrentEventTimeSec(), |
1201 click_count_, | 1202 click_count_, |
1202 0, | 1203 modifiers_, |
1203 &event); | 1204 &event); |
1204 WebPoint client_point(event.x, event.y); | 1205 WebPoint client_point(event.x, event.y); |
1205 WebPoint screen_point(event.globalX, event.globalY); | 1206 WebPoint screen_point(event.globalX, event.globalY); |
1206 current_drag_data_ = drag_data; | 1207 current_drag_data_ = drag_data; |
1207 current_drag_effects_allowed_ = mask; | 1208 current_drag_effects_allowed_ = mask; |
1208 current_drag_effect_ = view_->dragTargetDragEnter( | 1209 current_drag_effect_ = view_->dragTargetDragEnter( |
1209 drag_data, client_point, screen_point, current_drag_effects_allowed_, 0); | 1210 drag_data, |
| 1211 client_point, |
| 1212 screen_point, |
| 1213 current_drag_effects_allowed_, |
| 1214 modifiers_); |
1210 | 1215 |
1211 // Finish processing events. | 1216 // Finish processing events. |
1212 ReplaySavedEvents(); | 1217 ReplaySavedEvents(); |
1213 } | 1218 } |
1214 | 1219 |
1215 void EventSender::MouseDown(int button_number, int modifiers) { | 1220 void EventSender::MouseDown(int button_number, int modifiers) { |
1216 if (force_layout_on_events_) | 1221 if (force_layout_on_events_) |
1217 view_->layout(); | 1222 view_->layout(); |
1218 | 1223 |
1219 DCHECK_NE(-1, button_number); | 1224 DCHECK_NE(-1, button_number); |
1220 | 1225 |
1221 WebMouseEvent::Button button_type = | 1226 WebMouseEvent::Button button_type = |
1222 GetButtonTypeFromButtonNumber(button_number); | 1227 GetButtonTypeFromButtonNumber(button_number); |
1223 | 1228 |
1224 UpdateClickCountForButton(button_type); | 1229 UpdateClickCountForButton(button_type); |
1225 | 1230 |
1226 pressed_button_ = button_type; | 1231 pressed_button_ = button_type; |
| 1232 modifiers_ = modifiers; |
1227 | 1233 |
1228 WebMouseEvent event; | 1234 WebMouseEvent event; |
1229 InitMouseEvent(WebInputEvent::MouseDown, | 1235 InitMouseEvent(WebInputEvent::MouseDown, |
1230 button_type, | 1236 button_type, |
1231 last_mouse_pos_, | 1237 last_mouse_pos_, |
1232 GetCurrentEventTimeSec(), | 1238 GetCurrentEventTimeSec(), |
1233 click_count_, | 1239 click_count_, |
1234 modifiers, | 1240 modifiers, |
1235 &event); | 1241 &event); |
1236 HandleInputEventOnViewOrPopup(event); | 1242 HandleInputEventOnViewOrPopup(event); |
(...skipping 1174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2411 | 2417 |
2412 // If we're in a drag operation, complete it. | 2418 // If we're in a drag operation, complete it. |
2413 if (current_drag_data_.isNull()) | 2419 if (current_drag_data_.isNull()) |
2414 return; | 2420 return; |
2415 | 2421 |
2416 WebPoint client_point(e.x, e.y); | 2422 WebPoint client_point(e.x, e.y); |
2417 WebPoint screen_point(e.globalX, e.globalY); | 2423 WebPoint screen_point(e.globalX, e.globalY); |
2418 FinishDragAndDrop( | 2424 FinishDragAndDrop( |
2419 e, | 2425 e, |
2420 view_->dragTargetDragOver( | 2426 view_->dragTargetDragOver( |
2421 client_point, screen_point, current_drag_effects_allowed_, 0)); | 2427 client_point, |
| 2428 screen_point, |
| 2429 current_drag_effects_allowed_, |
| 2430 e.modifiers)); |
2422 } | 2431 } |
2423 | 2432 |
2424 void EventSender::DoMouseMove(const WebMouseEvent& e) { | 2433 void EventSender::DoMouseMove(const WebMouseEvent& e) { |
2425 last_mouse_pos_ = WebPoint(e.x, e.y); | 2434 last_mouse_pos_ = WebPoint(e.x, e.y); |
2426 | 2435 |
2427 HandleInputEventOnViewOrPopup(e); | 2436 HandleInputEventOnViewOrPopup(e); |
2428 | 2437 |
2429 if (pressed_button_ == WebMouseEvent::ButtonNone || | 2438 if (pressed_button_ == WebMouseEvent::ButtonNone || |
2430 current_drag_data_.isNull()) { | 2439 current_drag_data_.isNull()) { |
2431 return; | 2440 return; |
2432 } | 2441 } |
2433 | 2442 |
2434 WebPoint client_point(e.x, e.y); | 2443 WebPoint client_point(e.x, e.y); |
2435 WebPoint screen_point(e.globalX, e.globalY); | 2444 WebPoint screen_point(e.globalX, e.globalY); |
2436 current_drag_effect_ = view_->dragTargetDragOver( | 2445 current_drag_effect_ = view_->dragTargetDragOver( |
2437 client_point, screen_point, current_drag_effects_allowed_, 0); | 2446 client_point, screen_point, current_drag_effects_allowed_, e.modifiers); |
2438 } | 2447 } |
2439 | 2448 |
2440 void EventSender::ReplaySavedEvents() { | 2449 void EventSender::ReplaySavedEvents() { |
2441 replaying_saved_events_ = true; | 2450 replaying_saved_events_ = true; |
2442 while (!mouse_event_queue_.empty()) { | 2451 while (!mouse_event_queue_.empty()) { |
2443 SavedEvent e = mouse_event_queue_.front(); | 2452 SavedEvent e = mouse_event_queue_.front(); |
2444 mouse_event_queue_.pop_front(); | 2453 mouse_event_queue_.pop_front(); |
2445 | 2454 |
2446 switch (e.type) { | 2455 switch (e.type) { |
2447 case SavedEvent::TYPE_MOUSE_MOVE: { | 2456 case SavedEvent::TYPE_MOUSE_MOVE: { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2481 | 2490 |
2482 bool EventSender::HandleInputEventOnViewOrPopup(const WebInputEvent& event) { | 2491 bool EventSender::HandleInputEventOnViewOrPopup(const WebInputEvent& event) { |
2483 if (WebPagePopup* popup = view_->pagePopup()) { | 2492 if (WebPagePopup* popup = view_->pagePopup()) { |
2484 if (!WebInputEvent::isKeyboardEventType(event.type)) | 2493 if (!WebInputEvent::isKeyboardEventType(event.type)) |
2485 return popup->handleInputEvent(event); | 2494 return popup->handleInputEvent(event); |
2486 } | 2495 } |
2487 return view_->handleInputEvent(event); | 2496 return view_->handleInputEvent(event); |
2488 } | 2497 } |
2489 | 2498 |
2490 } // namespace content | 2499 } // namespace content |
OLD | NEW |