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

Side by Side Diff: components/test_runner/event_sender.cc

Issue 1463823003: Return a enumeration of the state of handling of InputEvents. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years 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 unified diff | Download patch
OLDNEW
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 "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 15 matching lines...) Expand all
26 #include "ui/events/keycodes/keyboard_codes.h" 26 #include "ui/events/keycodes/keyboard_codes.h"
27 #include "v8/include/v8.h" 27 #include "v8/include/v8.h"
28 28
29 using blink::WebContextMenuData; 29 using blink::WebContextMenuData;
30 using blink::WebDragData; 30 using blink::WebDragData;
31 using blink::WebDragOperationsMask; 31 using blink::WebDragOperationsMask;
32 using blink::WebFloatPoint; 32 using blink::WebFloatPoint;
33 using blink::WebFrame; 33 using blink::WebFrame;
34 using blink::WebGestureEvent; 34 using blink::WebGestureEvent;
35 using blink::WebInputEvent; 35 using blink::WebInputEvent;
36 using blink::WebInputEventResult;
36 using blink::WebKeyboardEvent; 37 using blink::WebKeyboardEvent;
37 using blink::WebMenuItemInfo; 38 using blink::WebMenuItemInfo;
38 using blink::WebMouseEvent; 39 using blink::WebMouseEvent;
39 using blink::WebMouseWheelEvent; 40 using blink::WebMouseWheelEvent;
40 using blink::WebPagePopup; 41 using blink::WebPagePopup;
41 using blink::WebPoint; 42 using blink::WebPoint;
42 using blink::WebString; 43 using blink::WebString;
43 using blink::WebTouchEvent; 44 using blink::WebTouchEvent;
44 using blink::WebTouchPoint; 45 using blink::WebTouchPoint;
45 using blink::WebVector; 46 using blink::WebVector;
(...skipping 2240 matching lines...) Expand 10 before | Expand all | Expand 10 after
2286 NOTREACHED(); 2287 NOTREACHED();
2287 } 2288 }
2288 2289
2289 event.globalX = event.x; 2290 event.globalX = event.x;
2290 event.globalY = event.y; 2291 event.globalY = event.y;
2291 event.timeStampSeconds = GetCurrentEventTimeSec(); 2292 event.timeStampSeconds = GetCurrentEventTimeSec();
2292 2293
2293 if (force_layout_on_events_) 2294 if (force_layout_on_events_)
2294 view_->updateAllLifecyclePhases(); 2295 view_->updateAllLifecyclePhases();
2295 2296
2296 bool result = HandleInputEventOnViewOrPopup(event); 2297 WebInputEventResult result = HandleInputEventOnViewOrPopup(event);
2297 2298
2298 // Long press might start a drag drop session. Complete it if so. 2299 // Long press might start a drag drop session. Complete it if so.
2299 if (type == WebInputEvent::GestureLongPress && !current_drag_data_.isNull()) { 2300 if (type == WebInputEvent::GestureLongPress && !current_drag_data_.isNull()) {
2300 WebMouseEvent mouse_event; 2301 WebMouseEvent mouse_event;
2301 InitMouseEvent(WebInputEvent::MouseDown, 2302 InitMouseEvent(WebInputEvent::MouseDown,
2302 pressed_button_, 2303 pressed_button_,
2303 WebPoint(x, y), 2304 WebPoint(x, y),
2304 GetCurrentEventTimeSec(), 2305 GetCurrentEventTimeSec(),
2305 click_count_, 2306 click_count_,
2306 0, 2307 0,
2307 &mouse_event); 2308 &mouse_event);
2308 2309
2309 FinishDragAndDrop(mouse_event, blink::WebDragOperationNone); 2310 FinishDragAndDrop(mouse_event, blink::WebDragOperationNone);
2310 } 2311 }
2311 args->Return(result); 2312 args->Return(result != WebInputEventResult::NotHandled);
2312 } 2313 }
2313 2314
2314 void EventSender::UpdateClickCountForButton( 2315 void EventSender::UpdateClickCountForButton(
2315 WebMouseEvent::Button button_type) { 2316 WebMouseEvent::Button button_type) {
2316 if ((GetCurrentEventTimeSec() - last_click_time_sec_ < 2317 if ((GetCurrentEventTimeSec() - last_click_time_sec_ <
2317 kMultipleClickTimeSec) && 2318 kMultipleClickTimeSec) &&
2318 (!OutsideMultiClickRadius(last_mouse_pos_, last_click_pos_)) && 2319 (!OutsideMultiClickRadius(last_mouse_pos_, last_click_pos_)) &&
2319 (button_type == last_button_type_)) { 2320 (button_type == last_button_type_)) {
2320 ++click_count_; 2321 ++click_count_;
2321 } else { 2322 } else {
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
2542 break; 2543 break;
2543 } 2544 }
2544 default: 2545 default:
2545 NOTREACHED(); 2546 NOTREACHED();
2546 } 2547 }
2547 } 2548 }
2548 2549
2549 replaying_saved_events_ = false; 2550 replaying_saved_events_ = false;
2550 } 2551 }
2551 2552
2552 bool EventSender::HandleInputEventOnViewOrPopup(const WebInputEvent& event) { 2553 WebInputEventResult EventSender::HandleInputEventOnViewOrPopup(
2554 const WebInputEvent& event) {
2553 last_event_timestamp_ = event.timeStampSeconds; 2555 last_event_timestamp_ = event.timeStampSeconds;
2554 2556
2555 if (WebPagePopup* popup = view_->pagePopup()) { 2557 if (WebPagePopup* popup = view_->pagePopup()) {
2556 if (!WebInputEvent::isKeyboardEventType(event.type)) 2558 if (!WebInputEvent::isKeyboardEventType(event.type))
2557 return popup->handleInputEvent(event); 2559 return popup->handleInputEvent(event);
2558 } 2560 }
2559 return view_->handleInputEvent(event); 2561 return view_->handleInputEvent(event);
2560 } 2562 }
2561 2563
2562 } // namespace test_runner 2564 } // namespace test_runner
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698