| 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 1084 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1095 | 1095 |
| 1096 void EventSenderBindings::SetWmSysDeadChar(int sys_dead_char) { | 1096 void EventSenderBindings::SetWmSysDeadChar(int sys_dead_char) { |
| 1097 if (sender_) | 1097 if (sender_) |
| 1098 sender_->set_wm_sys_dead_char(sys_dead_char); | 1098 sender_->set_wm_sys_dead_char(sys_dead_char); |
| 1099 } | 1099 } |
| 1100 #endif | 1100 #endif |
| 1101 | 1101 |
| 1102 // EventSender ----------------------------------------------------------------- | 1102 // EventSender ----------------------------------------------------------------- |
| 1103 | 1103 |
| 1104 WebMouseEvent::Button EventSender::pressed_button_ = WebMouseEvent::ButtonNone; | 1104 WebMouseEvent::Button EventSender::pressed_button_ = WebMouseEvent::ButtonNone; |
| 1105 int EventSender::modifiers_ = 0; |
| 1105 | 1106 |
| 1106 WebPoint EventSender::last_mouse_pos_; | 1107 WebPoint EventSender::last_mouse_pos_; |
| 1107 | 1108 |
| 1108 WebMouseEvent::Button EventSender::last_button_type_ = | 1109 WebMouseEvent::Button EventSender::last_button_type_ = |
| 1109 WebMouseEvent::ButtonNone; | 1110 WebMouseEvent::ButtonNone; |
| 1110 | 1111 |
| 1111 EventSender::SavedEvent::SavedEvent() | 1112 EventSender::SavedEvent::SavedEvent() |
| 1112 : type(TYPE_UNSPECIFIED), | 1113 : type(TYPE_UNSPECIFIED), |
| 1113 button_type(WebMouseEvent::ButtonNone), | 1114 button_type(WebMouseEvent::ButtonNone), |
| 1114 milliseconds(0), | 1115 milliseconds(0), |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1199 } | 1200 } |
| 1200 | 1201 |
| 1201 void EventSender::DoDragDrop(const WebDragData& drag_data, | 1202 void EventSender::DoDragDrop(const WebDragData& drag_data, |
| 1202 WebDragOperationsMask mask) { | 1203 WebDragOperationsMask mask) { |
| 1203 WebMouseEvent event; | 1204 WebMouseEvent event; |
| 1204 InitMouseEvent(WebInputEvent::MouseDown, | 1205 InitMouseEvent(WebInputEvent::MouseDown, |
| 1205 pressed_button_, | 1206 pressed_button_, |
| 1206 last_mouse_pos_, | 1207 last_mouse_pos_, |
| 1207 GetCurrentEventTimeSec(), | 1208 GetCurrentEventTimeSec(), |
| 1208 click_count_, | 1209 click_count_, |
| 1209 0, | 1210 modifiers_, |
| 1210 &event); | 1211 &event); |
| 1211 WebPoint client_point(event.x, event.y); | 1212 WebPoint client_point(event.x, event.y); |
| 1212 WebPoint screen_point(event.globalX, event.globalY); | 1213 WebPoint screen_point(event.globalX, event.globalY); |
| 1213 current_drag_data_ = drag_data; | 1214 current_drag_data_ = drag_data; |
| 1214 current_drag_effects_allowed_ = mask; | 1215 current_drag_effects_allowed_ = mask; |
| 1215 current_drag_effect_ = view_->dragTargetDragEnter( | 1216 current_drag_effect_ = view_->dragTargetDragEnter( |
| 1216 drag_data, client_point, screen_point, current_drag_effects_allowed_, 0); | 1217 drag_data, |
| 1218 client_point, |
| 1219 screen_point, |
| 1220 current_drag_effects_allowed_, |
| 1221 modifiers_); |
| 1217 | 1222 |
| 1218 // Finish processing events. | 1223 // Finish processing events. |
| 1219 ReplaySavedEvents(); | 1224 ReplaySavedEvents(); |
| 1220 } | 1225 } |
| 1221 | 1226 |
| 1222 void EventSender::MouseDown(int button_number, int modifiers) { | 1227 void EventSender::MouseDown(int button_number, int modifiers) { |
| 1223 if (force_layout_on_events_) | 1228 if (force_layout_on_events_) |
| 1224 view_->layout(); | 1229 view_->layout(); |
| 1225 | 1230 |
| 1226 DCHECK_NE(-1, button_number); | 1231 DCHECK_NE(-1, button_number); |
| 1227 | 1232 |
| 1228 WebMouseEvent::Button button_type = | 1233 WebMouseEvent::Button button_type = |
| 1229 GetButtonTypeFromButtonNumber(button_number); | 1234 GetButtonTypeFromButtonNumber(button_number); |
| 1230 | 1235 |
| 1231 UpdateClickCountForButton(button_type); | 1236 UpdateClickCountForButton(button_type); |
| 1232 | 1237 |
| 1233 pressed_button_ = button_type; | 1238 pressed_button_ = button_type; |
| 1239 modifiers_ = modifiers; |
| 1234 | 1240 |
| 1235 WebMouseEvent event; | 1241 WebMouseEvent event; |
| 1236 InitMouseEvent(WebInputEvent::MouseDown, | 1242 InitMouseEvent(WebInputEvent::MouseDown, |
| 1237 button_type, | 1243 button_type, |
| 1238 last_mouse_pos_, | 1244 last_mouse_pos_, |
| 1239 GetCurrentEventTimeSec(), | 1245 GetCurrentEventTimeSec(), |
| 1240 click_count_, | 1246 click_count_, |
| 1241 modifiers, | 1247 modifiers, |
| 1242 &event); | 1248 &event); |
| 1243 HandleInputEventOnViewOrPopup(event); | 1249 HandleInputEventOnViewOrPopup(event); |
| (...skipping 1190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2434 | 2440 |
| 2435 // If we're in a drag operation, complete it. | 2441 // If we're in a drag operation, complete it. |
| 2436 if (current_drag_data_.isNull()) | 2442 if (current_drag_data_.isNull()) |
| 2437 return; | 2443 return; |
| 2438 | 2444 |
| 2439 WebPoint client_point(e.x, e.y); | 2445 WebPoint client_point(e.x, e.y); |
| 2440 WebPoint screen_point(e.globalX, e.globalY); | 2446 WebPoint screen_point(e.globalX, e.globalY); |
| 2441 FinishDragAndDrop( | 2447 FinishDragAndDrop( |
| 2442 e, | 2448 e, |
| 2443 view_->dragTargetDragOver( | 2449 view_->dragTargetDragOver( |
| 2444 client_point, screen_point, current_drag_effects_allowed_, 0)); | 2450 client_point, |
| 2451 screen_point, |
| 2452 current_drag_effects_allowed_, |
| 2453 e.modifiers)); |
| 2445 } | 2454 } |
| 2446 | 2455 |
| 2447 void EventSender::DoMouseMove(const WebMouseEvent& e) { | 2456 void EventSender::DoMouseMove(const WebMouseEvent& e) { |
| 2448 last_mouse_pos_ = WebPoint(e.x, e.y); | 2457 last_mouse_pos_ = WebPoint(e.x, e.y); |
| 2449 | 2458 |
| 2450 HandleInputEventOnViewOrPopup(e); | 2459 HandleInputEventOnViewOrPopup(e); |
| 2451 | 2460 |
| 2452 if (pressed_button_ == WebMouseEvent::ButtonNone || | 2461 if (pressed_button_ == WebMouseEvent::ButtonNone || |
| 2453 current_drag_data_.isNull()) { | 2462 current_drag_data_.isNull()) { |
| 2454 return; | 2463 return; |
| 2455 } | 2464 } |
| 2456 | 2465 |
| 2457 WebPoint client_point(e.x, e.y); | 2466 WebPoint client_point(e.x, e.y); |
| 2458 WebPoint screen_point(e.globalX, e.globalY); | 2467 WebPoint screen_point(e.globalX, e.globalY); |
| 2459 current_drag_effect_ = view_->dragTargetDragOver( | 2468 current_drag_effect_ = view_->dragTargetDragOver( |
| 2460 client_point, screen_point, current_drag_effects_allowed_, 0); | 2469 client_point, screen_point, current_drag_effects_allowed_, e.modifiers); |
| 2461 } | 2470 } |
| 2462 | 2471 |
| 2463 void EventSender::ReplaySavedEvents() { | 2472 void EventSender::ReplaySavedEvents() { |
| 2464 replaying_saved_events_ = true; | 2473 replaying_saved_events_ = true; |
| 2465 while (!mouse_event_queue_.empty()) { | 2474 while (!mouse_event_queue_.empty()) { |
| 2466 SavedEvent e = mouse_event_queue_.front(); | 2475 SavedEvent e = mouse_event_queue_.front(); |
| 2467 mouse_event_queue_.pop_front(); | 2476 mouse_event_queue_.pop_front(); |
| 2468 | 2477 |
| 2469 switch (e.type) { | 2478 switch (e.type) { |
| 2470 case SavedEvent::TYPE_MOUSE_MOVE: { | 2479 case SavedEvent::TYPE_MOUSE_MOVE: { |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2504 | 2513 |
| 2505 bool EventSender::HandleInputEventOnViewOrPopup(const WebInputEvent& event) { | 2514 bool EventSender::HandleInputEventOnViewOrPopup(const WebInputEvent& event) { |
| 2506 if (WebPagePopup* popup = view_->pagePopup()) { | 2515 if (WebPagePopup* popup = view_->pagePopup()) { |
| 2507 if (!WebInputEvent::isKeyboardEventType(event.type)) | 2516 if (!WebInputEvent::isKeyboardEventType(event.type)) |
| 2508 return popup->handleInputEvent(event); | 2517 return popup->handleInputEvent(event); |
| 2509 } | 2518 } |
| 2510 return view_->handleInputEvent(event); | 2519 return view_->handleInputEvent(event); |
| 2511 } | 2520 } |
| 2512 | 2521 |
| 2513 } // namespace content | 2522 } // namespace content |
| OLD | NEW |