| 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/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
| 10 #include "content/public/common/page_zoom.h" | 10 #include "content/public/common/page_zoom.h" |
| (...skipping 1067 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1078 | 1078 |
| 1079 void EventSenderBindings::SetWmSysDeadChar(int sys_dead_char) { | 1079 void EventSenderBindings::SetWmSysDeadChar(int sys_dead_char) { |
| 1080 if (sender_) | 1080 if (sender_) |
| 1081 sender_->set_wm_sys_dead_char(sys_dead_char); | 1081 sender_->set_wm_sys_dead_char(sys_dead_char); |
| 1082 } | 1082 } |
| 1083 #endif | 1083 #endif |
| 1084 | 1084 |
| 1085 // EventSender ----------------------------------------------------------------- | 1085 // EventSender ----------------------------------------------------------------- |
| 1086 | 1086 |
| 1087 WebMouseEvent::Button EventSender::pressed_button_ = WebMouseEvent::ButtonNone; | 1087 WebMouseEvent::Button EventSender::pressed_button_ = WebMouseEvent::ButtonNone; |
| 1088 int EventSender::modifiers_ = 0; |
| 1088 | 1089 |
| 1089 WebPoint EventSender::last_mouse_pos_; | 1090 WebPoint EventSender::last_mouse_pos_; |
| 1090 | 1091 |
| 1091 WebMouseEvent::Button EventSender::last_button_type_ = | 1092 WebMouseEvent::Button EventSender::last_button_type_ = |
| 1092 WebMouseEvent::ButtonNone; | 1093 WebMouseEvent::ButtonNone; |
| 1093 | 1094 |
| 1094 EventSender::SavedEvent::SavedEvent() | 1095 EventSender::SavedEvent::SavedEvent() |
| 1095 : type(TYPE_UNSPECIFIED), | 1096 : type(TYPE_UNSPECIFIED), |
| 1096 button_type(WebMouseEvent::ButtonNone), | 1097 button_type(WebMouseEvent::ButtonNone), |
| 1097 milliseconds(0), | 1098 milliseconds(0), |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1182 } | 1183 } |
| 1183 | 1184 |
| 1184 void EventSender::DoDragDrop(const WebDragData& drag_data, | 1185 void EventSender::DoDragDrop(const WebDragData& drag_data, |
| 1185 WebDragOperationsMask mask) { | 1186 WebDragOperationsMask mask) { |
| 1186 WebMouseEvent event; | 1187 WebMouseEvent event; |
| 1187 InitMouseEvent(WebInputEvent::MouseDown, | 1188 InitMouseEvent(WebInputEvent::MouseDown, |
| 1188 pressed_button_, | 1189 pressed_button_, |
| 1189 last_mouse_pos_, | 1190 last_mouse_pos_, |
| 1190 GetCurrentEventTimeSec(), | 1191 GetCurrentEventTimeSec(), |
| 1191 click_count_, | 1192 click_count_, |
| 1192 0, | 1193 modifiers_, |
| 1193 &event); | 1194 &event); |
| 1194 WebPoint client_point(event.x, event.y); | 1195 WebPoint client_point(event.x, event.y); |
| 1195 WebPoint screen_point(event.globalX, event.globalY); | 1196 WebPoint screen_point(event.globalX, event.globalY); |
| 1196 current_drag_data_ = drag_data; | 1197 current_drag_data_ = drag_data; |
| 1197 current_drag_effects_allowed_ = mask; | 1198 current_drag_effects_allowed_ = mask; |
| 1198 current_drag_effect_ = view_->dragTargetDragEnter( | 1199 current_drag_effect_ = view_->dragTargetDragEnter( |
| 1199 drag_data, client_point, screen_point, current_drag_effects_allowed_, 0); | 1200 drag_data, |
| 1201 client_point, |
| 1202 screen_point, |
| 1203 current_drag_effects_allowed_, |
| 1204 modifiers_); |
| 1200 | 1205 |
| 1201 // Finish processing events. | 1206 // Finish processing events. |
| 1202 ReplaySavedEvents(); | 1207 ReplaySavedEvents(); |
| 1203 } | 1208 } |
| 1204 | 1209 |
| 1205 void EventSender::MouseDown(int button_number, int modifiers) { | 1210 void EventSender::MouseDown(int button_number, int modifiers) { |
| 1206 if (force_layout_on_events_) | 1211 if (force_layout_on_events_) |
| 1207 view_->layout(); | 1212 view_->layout(); |
| 1208 | 1213 |
| 1209 DCHECK_NE(-1, button_number); | 1214 DCHECK_NE(-1, button_number); |
| 1210 | 1215 |
| 1211 WebMouseEvent::Button button_type = | 1216 WebMouseEvent::Button button_type = |
| 1212 GetButtonTypeFromButtonNumber(button_number); | 1217 GetButtonTypeFromButtonNumber(button_number); |
| 1213 | 1218 |
| 1214 UpdateClickCountForButton(button_type); | 1219 UpdateClickCountForButton(button_type); |
| 1215 | 1220 |
| 1216 pressed_button_ = button_type; | 1221 pressed_button_ = button_type; |
| 1222 modifiers_ = modifiers; |
| 1217 | 1223 |
| 1218 WebMouseEvent event; | 1224 WebMouseEvent event; |
| 1219 InitMouseEvent(WebInputEvent::MouseDown, | 1225 InitMouseEvent(WebInputEvent::MouseDown, |
| 1220 button_type, | 1226 button_type, |
| 1221 last_mouse_pos_, | 1227 last_mouse_pos_, |
| 1222 GetCurrentEventTimeSec(), | 1228 GetCurrentEventTimeSec(), |
| 1223 click_count_, | 1229 click_count_, |
| 1224 modifiers, | 1230 modifiers, |
| 1225 &event); | 1231 &event); |
| 1226 HandleInputEventOnViewOrPopup(event); | 1232 HandleInputEventOnViewOrPopup(event); |
| (...skipping 1123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2350 | 2356 |
| 2351 // If we're in a drag operation, complete it. | 2357 // If we're in a drag operation, complete it. |
| 2352 if (current_drag_data_.isNull()) | 2358 if (current_drag_data_.isNull()) |
| 2353 return; | 2359 return; |
| 2354 | 2360 |
| 2355 WebPoint client_point(e.x, e.y); | 2361 WebPoint client_point(e.x, e.y); |
| 2356 WebPoint screen_point(e.globalX, e.globalY); | 2362 WebPoint screen_point(e.globalX, e.globalY); |
| 2357 FinishDragAndDrop( | 2363 FinishDragAndDrop( |
| 2358 e, | 2364 e, |
| 2359 view_->dragTargetDragOver( | 2365 view_->dragTargetDragOver( |
| 2360 client_point, screen_point, current_drag_effects_allowed_, 0)); | 2366 client_point, |
| 2367 screen_point, |
| 2368 current_drag_effects_allowed_, |
| 2369 e.modifiers)); |
| 2361 } | 2370 } |
| 2362 | 2371 |
| 2363 void EventSender::DoMouseMove(const WebMouseEvent& e) { | 2372 void EventSender::DoMouseMove(const WebMouseEvent& e) { |
| 2364 last_mouse_pos_ = WebPoint(e.x, e.y); | 2373 last_mouse_pos_ = WebPoint(e.x, e.y); |
| 2365 | 2374 |
| 2366 HandleInputEventOnViewOrPopup(e); | 2375 HandleInputEventOnViewOrPopup(e); |
| 2367 | 2376 |
| 2368 if (pressed_button_ == WebMouseEvent::ButtonNone || | 2377 if (pressed_button_ == WebMouseEvent::ButtonNone || |
| 2369 current_drag_data_.isNull()) { | 2378 current_drag_data_.isNull()) { |
| 2370 return; | 2379 return; |
| 2371 } | 2380 } |
| 2372 | 2381 |
| 2373 WebPoint client_point(e.x, e.y); | 2382 WebPoint client_point(e.x, e.y); |
| 2374 WebPoint screen_point(e.globalX, e.globalY); | 2383 WebPoint screen_point(e.globalX, e.globalY); |
| 2375 current_drag_effect_ = view_->dragTargetDragOver( | 2384 current_drag_effect_ = view_->dragTargetDragOver( |
| 2376 client_point, screen_point, current_drag_effects_allowed_, 0); | 2385 client_point, screen_point, current_drag_effects_allowed_, e.modifiers); |
| 2377 } | 2386 } |
| 2378 | 2387 |
| 2379 void EventSender::ReplaySavedEvents() { | 2388 void EventSender::ReplaySavedEvents() { |
| 2380 replaying_saved_events_ = true; | 2389 replaying_saved_events_ = true; |
| 2381 while (!mouse_event_queue_.empty()) { | 2390 while (!mouse_event_queue_.empty()) { |
| 2382 SavedEvent e = mouse_event_queue_.front(); | 2391 SavedEvent e = mouse_event_queue_.front(); |
| 2383 mouse_event_queue_.pop_front(); | 2392 mouse_event_queue_.pop_front(); |
| 2384 | 2393 |
| 2385 switch (e.type) { | 2394 switch (e.type) { |
| 2386 case SavedEvent::TYPE_MOUSE_MOVE: { | 2395 case SavedEvent::TYPE_MOUSE_MOVE: { |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2420 | 2429 |
| 2421 bool EventSender::HandleInputEventOnViewOrPopup(const WebInputEvent& event) { | 2430 bool EventSender::HandleInputEventOnViewOrPopup(const WebInputEvent& event) { |
| 2422 if (WebPagePopup* popup = view_->pagePopup()) { | 2431 if (WebPagePopup* popup = view_->pagePopup()) { |
| 2423 if (!WebInputEvent::isKeyboardEventType(event.type)) | 2432 if (!WebInputEvent::isKeyboardEventType(event.type)) |
| 2424 return popup->handleInputEvent(event); | 2433 return popup->handleInputEvent(event); |
| 2425 } | 2434 } |
| 2426 return view_->handleInputEvent(event); | 2435 return view_->handleInputEvent(event); |
| 2427 } | 2436 } |
| 2428 | 2437 |
| 2429 } // namespace content | 2438 } // namespace content |
| OLD | NEW |