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

Side by Side Diff: content/shell/test_runner/event_sender.cc

Issue 2707183003: Move //components/test_runner back into //content/shell (Closed)
Patch Set: Trim DEPS Created 3 years, 10 months 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 "content/shell/test_runner/event_sender.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory> 9 #include <memory>
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/bind_helpers.h" 12 #include "base/bind_helpers.h"
13 #include "base/command_line.h" 13 #include "base/command_line.h"
14 #include "base/files/file_path.h" 14 #include "base/files/file_path.h"
15 #include "base/logging.h" 15 #include "base/logging.h"
16 #include "base/macros.h" 16 #include "base/macros.h"
17 #include "base/strings/string16.h" 17 #include "base/strings/string16.h"
18 #include "base/strings/string_util.h" 18 #include "base/strings/string_util.h"
19 #include "base/strings/stringprintf.h" 19 #include "base/strings/stringprintf.h"
20 #include "base/strings/utf_string_conversions.h" 20 #include "base/strings/utf_string_conversions.h"
21 #include "build/build_config.h" 21 #include "build/build_config.h"
22 #include "components/test_runner/mock_spell_check.h" 22 #include "content/shell/test_runner/mock_spell_check.h"
23 #include "components/test_runner/test_interfaces.h" 23 #include "content/shell/test_runner/test_interfaces.h"
24 #include "components/test_runner/web_test_delegate.h" 24 #include "content/shell/test_runner/web_test_delegate.h"
25 #include "components/test_runner/web_view_test_proxy.h" 25 #include "content/shell/test_runner/web_view_test_proxy.h"
26 #include "components/test_runner/web_widget_test_proxy.h" 26 #include "content/shell/test_runner/web_widget_test_proxy.h"
27 #include "gin/handle.h" 27 #include "gin/handle.h"
28 #include "gin/object_template_builder.h" 28 #include "gin/object_template_builder.h"
29 #include "gin/wrappable.h" 29 #include "gin/wrappable.h"
30 #include "net/base/filename_util.h" 30 #include "net/base/filename_util.h"
31 #include "third_party/WebKit/public/platform/URLConversion.h" 31 #include "third_party/WebKit/public/platform/URLConversion.h"
32 #include "third_party/WebKit/public/platform/WebCoalescedInputEvent.h" 32 #include "third_party/WebKit/public/platform/WebCoalescedInputEvent.h"
33 #include "third_party/WebKit/public/platform/WebGestureEvent.h" 33 #include "third_party/WebKit/public/platform/WebGestureEvent.h"
34 #include "third_party/WebKit/public/platform/WebKeyboardEvent.h" 34 #include "third_party/WebKit/public/platform/WebKeyboardEvent.h"
35 #include "third_party/WebKit/public/platform/WebPointerProperties.h" 35 #include "third_party/WebKit/public/platform/WebPointerProperties.h"
36 #include "third_party/WebKit/public/platform/WebString.h" 36 #include "third_party/WebKit/public/platform/WebString.h"
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 return 0; 185 return 0;
186 case WebMouseEvent::Button::Left: 186 case WebMouseEvent::Button::Left:
187 return WebMouseEvent::LeftButtonDown; 187 return WebMouseEvent::LeftButtonDown;
188 case WebMouseEvent::Button::Middle: 188 case WebMouseEvent::Button::Middle:
189 return WebMouseEvent::MiddleButtonDown; 189 return WebMouseEvent::MiddleButtonDown;
190 case WebMouseEvent::Button::Right: 190 case WebMouseEvent::Button::Right:
191 return WebMouseEvent::RightButtonDown; 191 return WebMouseEvent::RightButtonDown;
192 case WebPointerProperties::Button::X1: 192 case WebPointerProperties::Button::X1:
193 case WebPointerProperties::Button::X2: 193 case WebPointerProperties::Button::X2:
194 case WebPointerProperties::Button::Eraser: 194 case WebPointerProperties::Button::Eraser:
195 return 0; // Not implemented yet 195 return 0; // Not implemented yet
196 } 196 }
197 NOTREACHED(); 197 NOTREACHED();
198 return 0; 198 return 0;
199 } 199 }
200 200
201 const int kButtonsInModifiers = WebMouseEvent::LeftButtonDown 201 const int kButtonsInModifiers = WebMouseEvent::LeftButtonDown |
202 | WebMouseEvent::MiddleButtonDown | WebMouseEvent::RightButtonDown; 202 WebMouseEvent::MiddleButtonDown |
203 WebMouseEvent::RightButtonDown;
203 204
204 int modifiersWithButtons(int modifiers, int buttons) { 205 int modifiersWithButtons(int modifiers, int buttons) {
205 return (modifiers & ~kButtonsInModifiers) 206 return (modifiers & ~kButtonsInModifiers) | (buttons & kButtonsInModifiers);
206 | (buttons & kButtonsInModifiers);
207 } 207 }
208 208
209 void InitMouseEventGeneric(WebMouseEvent::Button b, 209 void InitMouseEventGeneric(WebMouseEvent::Button b,
210 int current_buttons, 210 int current_buttons,
211 const WebPoint& pos, 211 const WebPoint& pos,
212 int click_count, 212 int click_count,
213 WebPointerProperties::PointerType pointerType, 213 WebPointerProperties::PointerType pointerType,
214 int pointerId, 214 int pointerId,
215 float pressure, 215 float pressure,
216 int tiltX, 216 int tiltX,
(...skipping 30 matching lines...) Expand all
247 gesture_event->globalX = wheel_event.globalX; 247 gesture_event->globalX = wheel_event.globalX;
248 gesture_event->globalY = wheel_event.globalY; 248 gesture_event->globalY = wheel_event.globalY;
249 } 249 }
250 250
251 int GetKeyModifier(const std::string& modifier_name) { 251 int GetKeyModifier(const std::string& modifier_name) {
252 const char* characters = modifier_name.c_str(); 252 const char* characters = modifier_name.c_str();
253 if (!strcmp(characters, "ctrlKey") 253 if (!strcmp(characters, "ctrlKey")
254 #ifndef __APPLE__ 254 #ifndef __APPLE__
255 || !strcmp(characters, "addSelectionKey") 255 || !strcmp(characters, "addSelectionKey")
256 #endif 256 #endif
257 ) { 257 ) {
258 return WebInputEvent::ControlKey; 258 return WebInputEvent::ControlKey;
259 } else if (!strcmp(characters, "shiftKey") || 259 } else if (!strcmp(characters, "shiftKey") ||
260 !strcmp(characters, "rangeSelectionKey")) { 260 !strcmp(characters, "rangeSelectionKey")) {
261 return WebInputEvent::ShiftKey; 261 return WebInputEvent::ShiftKey;
262 } else if (!strcmp(characters, "altKey")) { 262 } else if (!strcmp(characters, "altKey")) {
263 return WebInputEvent::AltKey; 263 return WebInputEvent::AltKey;
264 #ifdef __APPLE__ 264 #ifdef __APPLE__
265 } else if (!strcmp(characters, "metaKey") || 265 } else if (!strcmp(characters, "metaKey") ||
266 !strcmp(characters, "addSelectionKey")) { 266 !strcmp(characters, "addSelectionKey")) {
267 return WebInputEvent::MetaKey; 267 return WebInputEvent::MetaKey;
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 modifiers |= GetKeyModifier(*it); 321 modifiers |= GetKeyModifier(*it);
322 } 322 }
323 return modifiers; 323 return modifiers;
324 } 324 }
325 325
326 int GetKeyModifiersFromV8(v8::Isolate* isolate, v8::Local<v8::Value> value) { 326 int GetKeyModifiersFromV8(v8::Isolate* isolate, v8::Local<v8::Value> value) {
327 std::vector<std::string> modifier_names; 327 std::vector<std::string> modifier_names;
328 if (value->IsString()) { 328 if (value->IsString()) {
329 modifier_names.push_back(gin::V8ToString(value)); 329 modifier_names.push_back(gin::V8ToString(value));
330 } else if (value->IsArray()) { 330 } else if (value->IsArray()) {
331 gin::Converter<std::vector<std::string> >::FromV8( 331 gin::Converter<std::vector<std::string>>::FromV8(isolate, value,
332 isolate, value, &modifier_names); 332 &modifier_names);
333 } 333 }
334 return GetKeyModifiers(modifier_names); 334 return GetKeyModifiers(modifier_names);
335 } 335 }
336 336
337 WebMouseWheelEvent::Phase GetMouseWheelEventPhase( 337 WebMouseWheelEvent::Phase GetMouseWheelEventPhase(
338 const std::string& phase_name) { 338 const std::string& phase_name) {
339 if (phase_name == "phaseNone") { 339 if (phase_name == "phaseNone") {
340 return WebMouseWheelEvent::PhaseNone; 340 return WebMouseWheelEvent::PhaseNone;
341 } else if (phase_name == "phaseBegan") { 341 } else if (phase_name == "phaseBegan") {
342 return WebMouseWheelEvent::PhaseBegan; 342 return WebMouseWheelEvent::PhaseBegan;
(...skipping 28 matching lines...) Expand all
371 const char kSeparatorIdentifier[] = "---------"; 371 const char kSeparatorIdentifier[] = "---------";
372 const char kDisabledIdentifier[] = "#"; 372 const char kDisabledIdentifier[] = "#";
373 const char kCheckedIdentifier[] = "*"; 373 const char kCheckedIdentifier[] = "*";
374 374
375 bool OutsideMultiClickRadius(const WebPoint& a, const WebPoint& b) { 375 bool OutsideMultiClickRadius(const WebPoint& a, const WebPoint& b) {
376 return ((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y)) > 376 return ((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y)) >
377 kMultipleClickRadiusPixels * kMultipleClickRadiusPixels; 377 kMultipleClickRadiusPixels * kMultipleClickRadiusPixels;
378 } 378 }
379 379
380 void PopulateCustomItems(const WebVector<WebMenuItemInfo>& customItems, 380 void PopulateCustomItems(const WebVector<WebMenuItemInfo>& customItems,
381 const std::string& prefix, std::vector<std::string>* strings) { 381 const std::string& prefix,
382 std::vector<std::string>* strings) {
382 for (size_t i = 0; i < customItems.size(); ++i) { 383 for (size_t i = 0; i < customItems.size(); ++i) {
383 std::string prefixCopy = prefix; 384 std::string prefixCopy = prefix;
384 if (!customItems[i].enabled) 385 if (!customItems[i].enabled)
385 prefixCopy = kDisabledIdentifier + prefix; 386 prefixCopy = kDisabledIdentifier + prefix;
386 if (customItems[i].checked) 387 if (customItems[i].checked)
387 prefixCopy = kCheckedIdentifier + prefix; 388 prefixCopy = kCheckedIdentifier + prefix;
388 if (customItems[i].type == blink::WebMenuItemInfo::Separator) { 389 if (customItems[i].type == blink::WebMenuItemInfo::Separator) {
389 strings->push_back(prefixCopy + kSeparatorIdentifier); 390 strings->push_back(prefixCopy + kSeparatorIdentifier);
390 } else if (customItems[i].type == blink::WebMenuItemInfo::SubMenu) { 391 } else if (customItems[i].type == blink::WebMenuItemInfo::SubMenu) {
391 strings->push_back(prefixCopy + customItems[i].label.utf8() + 392 strings->push_back(prefixCopy + customItems[i].label.utf8() +
392 customItems[i].icon.utf8() + kSubMenuIdentifier); 393 customItems[i].icon.utf8() + kSubMenuIdentifier);
393 PopulateCustomItems(customItems[i].subMenuItems, prefixCopy + 394 PopulateCustomItems(customItems[i].subMenuItems,
394 kSubMenuDepthIdentifier, strings); 395 prefixCopy + kSubMenuDepthIdentifier, strings);
395 } else { 396 } else {
396 strings->push_back(prefixCopy + customItems[i].label.utf8() + 397 strings->push_back(prefixCopy + customItems[i].label.utf8() +
397 customItems[i].icon.utf8()); 398 customItems[i].icon.utf8());
398 } 399 }
399 } 400 }
400 } 401 }
401 402
402 // Because actual context menu is implemented by the browser side, 403 // Because actual context menu is implemented by the browser side,
403 // this function does only what LayoutTests are expecting: 404 // this function does only what LayoutTests are expecting:
404 // - Many test checks the count of items. So returning non-zero value makes 405 // - Many test checks the count of items. So returning non-zero value makes
405 // sense. 406 // sense.
406 // - Some test compares the count before and after some action. So changing the 407 // - Some test compares the count before and after some action. So changing the
407 // count based on flags also makes sense. This function is doing such for some 408 // count based on flags also makes sense. This function is doing such for some
408 // flags. 409 // flags.
409 // - Some test even checks actual string content. So providing it would be also 410 // - Some test even checks actual string content. So providing it would be also
410 // helpful. 411 // helpful.
411 std::vector<std::string> MakeMenuItemStringsFor( 412 std::vector<std::string> MakeMenuItemStringsFor(
412 WebContextMenuData* context_menu, 413 WebContextMenuData* context_menu,
413 WebTestDelegate* delegate) { 414 WebTestDelegate* delegate) {
414 // These constants are based on Safari's context menu because tests are made 415 // These constants are based on Safari's context menu because tests are made
415 // for it. 416 // for it.
416 static const char* kNonEditableMenuStrings[] = { 417 static const char* kNonEditableMenuStrings[] = {
417 "Back", 418 "Back", "Reload Page", "Open in Dashbaord",
418 "Reload Page", 419 "<separator>", "View Source", "Save Page As",
419 "Open in Dashbaord", 420 "Print Page", "Inspect Element", 0};
420 "<separator>", 421 static const char* kEditableMenuStrings[] = {"Cut",
421 "View Source", 422 "Copy",
422 "Save Page As", 423 "<separator>",
423 "Print Page", 424 "Paste",
424 "Inspect Element", 425 "Spelling and Grammar",
425 0 426 "Substitutions, Transformations",
426 }; 427 "Font",
427 static const char* kEditableMenuStrings[] = { 428 "Speech",
428 "Cut", 429 "Paragraph Direction",
429 "Copy", 430 "<separator>",
430 "<separator>", 431 0};
431 "Paste",
432 "Spelling and Grammar",
433 "Substitutions, Transformations",
434 "Font",
435 "Speech",
436 "Paragraph Direction",
437 "<separator>",
438 0
439 };
440 432
441 // This is possible because mouse events are cancelleable. 433 // This is possible because mouse events are cancelleable.
442 if (!context_menu) 434 if (!context_menu)
443 return std::vector<std::string>(); 435 return std::vector<std::string>();
444 436
445 std::vector<std::string> strings; 437 std::vector<std::string> strings;
446 438
447 // Populate custom menu items if provided by blink. 439 // Populate custom menu items if provided by blink.
448 PopulateCustomItems(context_menu->customItems, "", &strings); 440 PopulateCustomItems(context_menu->customItems, "", &strings);
449 441
(...skipping 18 matching lines...) Expand all
468 460
469 // How much we should scroll per event - the value here is chosen to match the 461 // How much we should scroll per event - the value here is chosen to match the
470 // WebKit impl and layout test results. 462 // WebKit impl and layout test results.
471 const float kScrollbarPixelsPerTick = 40.0f; 463 const float kScrollbarPixelsPerTick = 40.0f;
472 464
473 // Get the edit command corresponding to a keyboard event. 465 // Get the edit command corresponding to a keyboard event.
474 // Returns true if the specified event corresponds to an edit command, the name 466 // Returns true if the specified event corresponds to an edit command, the name
475 // of the edit command will be stored in |*name|. 467 // of the edit command will be stored in |*name|.
476 bool GetEditCommand(const WebKeyboardEvent& event, std::string* name) { 468 bool GetEditCommand(const WebKeyboardEvent& event, std::string* name) {
477 #if defined(OS_MACOSX) 469 #if defined(OS_MACOSX)
478 // We only cares about Left,Right,Up,Down keys with Command or Command+Shift 470 // We only cares about Left,Right,Up,Down keys with Command or Command+Shift
479 // modifiers. These key events correspond to some special movement and 471 // modifiers. These key events correspond to some special movement and
480 // selection editor commands. These keys will be marked as system key, which 472 // selection editor commands. These keys will be marked as system key, which
481 // prevents them from being handled. Thus they must be handled specially. 473 // prevents them from being handled. Thus they must be handled specially.
482 if ((event.modifiers() & ~WebKeyboardEvent::ShiftKey) != 474 if ((event.modifiers() & ~WebKeyboardEvent::ShiftKey) !=
483 WebKeyboardEvent::MetaKey) 475 WebKeyboardEvent::MetaKey)
484 return false; 476 return false;
485 477
486 switch (event.windowsKeyCode) { 478 switch (event.windowsKeyCode) {
487 case ui::VKEY_LEFT: 479 case ui::VKEY_LEFT:
488 *name = "MoveToBeginningOfLine"; 480 *name = "MoveToBeginningOfLine";
489 break; 481 break;
490 case ui::VKEY_RIGHT: 482 case ui::VKEY_RIGHT:
491 *name = "MoveToEndOfLine"; 483 *name = "MoveToEndOfLine";
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
657 #endif 649 #endif
658 650
659 base::WeakPtr<EventSender> sender_; 651 base::WeakPtr<EventSender> sender_;
660 652
661 DISALLOW_COPY_AND_ASSIGN(EventSenderBindings); 653 DISALLOW_COPY_AND_ASSIGN(EventSenderBindings);
662 }; 654 };
663 655
664 gin::WrapperInfo EventSenderBindings::kWrapperInfo = {gin::kEmbedderNativeGin}; 656 gin::WrapperInfo EventSenderBindings::kWrapperInfo = {gin::kEmbedderNativeGin};
665 657
666 EventSenderBindings::EventSenderBindings(base::WeakPtr<EventSender> sender) 658 EventSenderBindings::EventSenderBindings(base::WeakPtr<EventSender> sender)
667 : sender_(sender) { 659 : sender_(sender) {}
668 }
669 660
670 EventSenderBindings::~EventSenderBindings() {} 661 EventSenderBindings::~EventSenderBindings() {}
671 662
672 // static 663 // static
673 void EventSenderBindings::Install(base::WeakPtr<EventSender> sender, 664 void EventSenderBindings::Install(base::WeakPtr<EventSender> sender,
674 WebLocalFrame* frame) { 665 WebLocalFrame* frame) {
675 v8::Isolate* isolate = blink::mainThreadIsolate(); 666 v8::Isolate* isolate = blink::mainThreadIsolate();
676 v8::HandleScope handle_scope(isolate); 667 v8::HandleScope handle_scope(isolate);
677 v8::Local<v8::Context> context = frame->mainWorldScriptContext(); 668 v8::Local<v8::Context> context = frame->mainWorldScriptContext();
678 if (context.IsEmpty()) 669 if (context.IsEmpty())
679 return; 670 return;
680 671
681 v8::Context::Scope context_scope(context); 672 v8::Context::Scope context_scope(context);
682 673
683 gin::Handle<EventSenderBindings> bindings = 674 gin::Handle<EventSenderBindings> bindings =
684 gin::CreateHandle(isolate, new EventSenderBindings(sender)); 675 gin::CreateHandle(isolate, new EventSenderBindings(sender));
685 if (bindings.IsEmpty()) 676 if (bindings.IsEmpty())
686 return; 677 return;
687 v8::Local<v8::Object> global = context->Global(); 678 v8::Local<v8::Object> global = context->Global();
688 global->Set(gin::StringToV8(isolate, "eventSender"), bindings.ToV8()); 679 global->Set(gin::StringToV8(isolate, "eventSender"), bindings.ToV8());
689 } 680 }
690 681
691 gin::ObjectTemplateBuilder 682 gin::ObjectTemplateBuilder EventSenderBindings::GetObjectTemplateBuilder(
692 EventSenderBindings::GetObjectTemplateBuilder(v8::Isolate* isolate) { 683 v8::Isolate* isolate) {
693 return gin::Wrappable<EventSenderBindings>::GetObjectTemplateBuilder(isolate) 684 return gin::Wrappable<EventSenderBindings>::GetObjectTemplateBuilder(isolate)
694 .SetMethod("enableDOMUIEventLogging", 685 .SetMethod("enableDOMUIEventLogging",
695 &EventSenderBindings::EnableDOMUIEventLogging) 686 &EventSenderBindings::EnableDOMUIEventLogging)
696 .SetMethod("fireKeyboardEventsToElement", 687 .SetMethod("fireKeyboardEventsToElement",
697 &EventSenderBindings::FireKeyboardEventsToElement) 688 &EventSenderBindings::FireKeyboardEventsToElement)
698 .SetMethod("clearKillRing", &EventSenderBindings::ClearKillRing) 689 .SetMethod("clearKillRing", &EventSenderBindings::ClearKillRing)
699 .SetMethod("contextClick", &EventSenderBindings::ContextClick) 690 .SetMethod("contextClick", &EventSenderBindings::ContextClick)
700 .SetMethod("textZoomIn", &EventSenderBindings::TextZoomIn) 691 .SetMethod("textZoomIn", &EventSenderBindings::TextZoomIn)
701 .SetMethod("textZoomOut", &EventSenderBindings::TextZoomOut) 692 .SetMethod("textZoomOut", &EventSenderBindings::TextZoomOut)
702 .SetMethod("zoomPageIn", &EventSenderBindings::ZoomPageIn) 693 .SetMethod("zoomPageIn", &EventSenderBindings::ZoomPageIn)
(...skipping 634 matching lines...) Expand 10 before | Expand all | Expand 10 after
1337 last_context_menu_data_.reset(new WebContextMenuData(data)); 1328 last_context_menu_data_.reset(new WebContextMenuData(data));
1338 } 1329 }
1339 1330
1340 int EventSender::ModifiersForPointer(int pointer_id) { 1331 int EventSender::ModifiersForPointer(int pointer_id) {
1341 return modifiersWithButtons( 1332 return modifiersWithButtons(
1342 current_pointer_state_[pointer_id].modifiers_, 1333 current_pointer_state_[pointer_id].modifiers_,
1343 current_pointer_state_[pointer_id].current_buttons_); 1334 current_pointer_state_[pointer_id].current_buttons_);
1344 } 1335 }
1345 1336
1346 void EventSender::DoDragDrop(const WebDragData& drag_data, 1337 void EventSender::DoDragDrop(const WebDragData& drag_data,
1347 WebDragOperationsMask mask) { 1338 WebDragOperationsMask mask) {
1348 WebMouseEvent raw_event(WebInputEvent::MouseDown, 1339 WebMouseEvent raw_event(WebInputEvent::MouseDown,
1349 ModifiersForPointer(kRawMousePointerId), 1340 ModifiersForPointer(kRawMousePointerId),
1350 GetCurrentEventTimeSec()); 1341 GetCurrentEventTimeSec());
1351 InitMouseEvent(current_pointer_state_[kRawMousePointerId].pressed_button_, 1342 InitMouseEvent(current_pointer_state_[kRawMousePointerId].pressed_button_,
1352 current_pointer_state_[kRawMousePointerId].current_buttons_, 1343 current_pointer_state_[kRawMousePointerId].current_buttons_,
1353 current_pointer_state_[kRawMousePointerId].last_pos_, 1344 current_pointer_state_[kRawMousePointerId].last_pos_,
1354 click_count_, &raw_event); 1345 click_count_, &raw_event);
1355 1346
1356 std::unique_ptr<WebInputEvent> widget_event = 1347 std::unique_ptr<WebInputEvent> widget_event =
1357 TransformScreenToWidgetCoordinates(raw_event); 1348 TransformScreenToWidgetCoordinates(raw_event);
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
1669 } 1660 }
1670 1661
1671 // For one generated keyboard event, we need to generate a keyDown/keyUp 1662 // For one generated keyboard event, we need to generate a keyDown/keyUp
1672 // pair; 1663 // pair;
1673 // On Windows, we might also need to generate a char event to mimic the 1664 // On Windows, we might also need to generate a char event to mimic the
1674 // Windows event flow; on other platforms we create a merged event and test 1665 // Windows event flow; on other platforms we create a merged event and test
1675 // the event flow that that platform provides. 1666 // the event flow that that platform provides.
1676 WebKeyboardEvent event_down(WebInputEvent::RawKeyDown, modifiers, 1667 WebKeyboardEvent event_down(WebInputEvent::RawKeyDown, modifiers,
1677 GetCurrentEventTimeSec()); 1668 GetCurrentEventTimeSec());
1678 event_down.windowsKeyCode = code; 1669 event_down.windowsKeyCode = code;
1679 event_down.domKey = static_cast<int>( 1670 event_down.domKey =
1680 ui::KeycodeConverter::KeyStringToDomKey(domKeyString)); 1671 static_cast<int>(ui::KeycodeConverter::KeyStringToDomKey(domKeyString));
1681 event_down.domCode = static_cast<int>( 1672 event_down.domCode = static_cast<int>(
1682 ui::KeycodeConverter::CodeStringToDomCode(domCodeString)); 1673 ui::KeycodeConverter::CodeStringToDomCode(domCodeString));
1683 1674
1684 if (generate_char) { 1675 if (generate_char) {
1685 event_down.text[0] = text; 1676 event_down.text[0] = text;
1686 event_down.unmodifiedText[0] = text; 1677 event_down.unmodifiedText[0] = text;
1687 } 1678 }
1688 1679
1689 if (event_down.modifiers() != 0) 1680 if (event_down.modifiers() != 0)
1690 event_down.isSystemKey = IsSystemKeyEvent(event_down); 1681 event_down.isSystemKey = IsSystemKeyEvent(event_down);
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
1869 void EventSender::CancelTouchPoint(unsigned index) { 1860 void EventSender::CancelTouchPoint(unsigned index) {
1870 if (index >= touch_points_.size()) { 1861 if (index >= touch_points_.size()) {
1871 ThrowTouchPointError(); 1862 ThrowTouchPointError();
1872 return; 1863 return;
1873 } 1864 }
1874 1865
1875 WebTouchPoint* touch_point = &touch_points_[index]; 1866 WebTouchPoint* touch_point = &touch_points_[index];
1876 touch_point->state = WebTouchPoint::StateCancelled; 1867 touch_point->state = WebTouchPoint::StateCancelled;
1877 } 1868 }
1878 1869
1879 void EventSender::SetTouchModifier(const std::string& key_name, 1870 void EventSender::SetTouchModifier(const std::string& key_name, bool set_mask) {
1880 bool set_mask) {
1881 int mask = GetKeyModifier(key_name); 1871 int mask = GetKeyModifier(key_name);
1882 1872
1883 if (set_mask) 1873 if (set_mask)
1884 touch_modifiers_ |= mask; 1874 touch_modifiers_ |= mask;
1885 else 1875 else
1886 touch_modifiers_ &= ~mask; 1876 touch_modifiers_ &= ~mask;
1887 } 1877 }
1888 1878
1889 void EventSender::SetTouchCancelable(bool cancelable) { 1879 void EventSender::SetTouchCancelable(bool cancelable) {
1890 touch_cancelable_ = cancelable; 1880 touch_cancelable_ = cancelable;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
1950 event.sourceDevice = blink::WebGestureDeviceTouchscreen; 1940 event.sourceDevice = blink::WebGestureDeviceTouchscreen;
1951 } else { 1941 } else {
1952 args->ThrowError(); 1942 args->ThrowError();
1953 return; 1943 return;
1954 } 1944 }
1955 1945
1956 float max_start_velocity = std::max(fabs(velocity_x), fabs(velocity_y)); 1946 float max_start_velocity = std::max(fabs(velocity_x), fabs(velocity_y));
1957 if (!max_start_velocity) { 1947 if (!max_start_velocity) {
1958 v8::Isolate* isolate = blink::mainThreadIsolate(); 1948 v8::Isolate* isolate = blink::mainThreadIsolate();
1959 isolate->ThrowException(v8::Exception::TypeError( 1949 isolate->ThrowException(v8::Exception::TypeError(
1960 gin::StringToV8(isolate, "Invalid max start velocity."))); 1950 gin::StringToV8(isolate, "Invalid max start velocity.")));
1961 return; 1951 return;
1962 } 1952 }
1963 1953
1964 event.x = x; 1954 event.x = x;
1965 event.y = y; 1955 event.y = y;
1966 event.globalX = event.x; 1956 event.globalX = event.x;
1967 event.globalY = event.y; 1957 event.globalY = event.y;
1968 1958
1969 event.data.flingStart.velocityX = velocity_x; 1959 event.data.flingStart.velocityX = velocity_x;
1970 event.data.flingStart.velocityY = velocity_y; 1960 event.data.flingStart.velocityY = velocity_y;
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
2018 DoLeapForward(milliseconds); 2008 DoLeapForward(milliseconds);
2019 } 2009 }
2020 } 2010 }
2021 2011
2022 void EventSender::BeginDragWithFiles(const std::vector<std::string>& files) { 2012 void EventSender::BeginDragWithFiles(const std::vector<std::string>& files) {
2023 if (!current_drag_data_.isNull()) { 2013 if (!current_drag_data_.isNull()) {
2024 // Nested dragging not supported, fuzzer code a likely culprit. 2014 // Nested dragging not supported, fuzzer code a likely culprit.
2025 // Cancel the current drag operation and throw an error. 2015 // Cancel the current drag operation and throw an error.
2026 KeyDown("Escape", 0, DOMKeyLocationStandard); 2016 KeyDown("Escape", 0, DOMKeyLocationStandard);
2027 v8::Isolate* isolate = blink::mainThreadIsolate(); 2017 v8::Isolate* isolate = blink::mainThreadIsolate();
2028 isolate->ThrowException(v8::Exception::Error( 2018 isolate->ThrowException(v8::Exception::Error(gin::StringToV8(
2029 gin::StringToV8(isolate, 2019 isolate, "Nested beginDragWithFiles() not supported.")));
2030 "Nested beginDragWithFiles() not supported.")));
2031 return; 2020 return;
2032 } 2021 }
2033 current_drag_data_.initialize(); 2022 current_drag_data_.initialize();
2034 WebVector<WebString> absolute_filenames(files.size()); 2023 WebVector<WebString> absolute_filenames(files.size());
2035 for (size_t i = 0; i < files.size(); ++i) { 2024 for (size_t i = 0; i < files.size(); ++i) {
2036 WebDragData::Item item; 2025 WebDragData::Item item;
2037 item.storageType = WebDragData::Item::StorageTypeFilename; 2026 item.storageType = WebDragData::Item::StorageTypeFilename;
2038 item.filenameData = delegate()->GetAbsoluteWebStringFromUTF8Path(files[i]); 2027 item.filenameData = delegate()->GetAbsoluteWebStringFromUTF8Path(files[i]);
2039 current_drag_data_.addItem(item); 2028 current_drag_data_.addItem(item);
2040 absolute_filenames[i] = item.filenameData; 2029 absolute_filenames[i] = item.filenameData;
2041 } 2030 }
2042 current_drag_data_.setFilesystemId( 2031 current_drag_data_.setFilesystemId(
2043 delegate()->RegisterIsolatedFileSystem(absolute_filenames)); 2032 delegate()->RegisterIsolatedFileSystem(absolute_filenames));
2044 current_drag_effects_allowed_ = blink::WebDragOperationCopy; 2033 current_drag_effects_allowed_ = blink::WebDragOperationCopy;
2045 2034
2046 const WebPoint& last_pos = 2035 const WebPoint& last_pos =
2047 current_pointer_state_[kRawMousePointerId].last_pos_; 2036 current_pointer_state_[kRawMousePointerId].last_pos_;
2048 float scale = delegate()->GetWindowToViewportScale(); 2037 float scale = delegate()->GetWindowToViewportScale();
2049 WebPoint scaled_last_pos(last_pos.x * scale, last_pos.y * scale); 2038 WebPoint scaled_last_pos(last_pos.x * scale, last_pos.y * scale);
2050 2039
2051 // Provide a drag source. 2040 // Provide a drag source.
2052 mainFrameWidget()->dragTargetDragEnter( 2041 mainFrameWidget()->dragTargetDragEnter(current_drag_data_, scaled_last_pos,
2053 current_drag_data_, scaled_last_pos, scaled_last_pos, 2042 scaled_last_pos,
2054 current_drag_effects_allowed_, 0); 2043 current_drag_effects_allowed_, 0);
2055 // |is_drag_mode_| saves events and then replays them later. We don't 2044 // |is_drag_mode_| saves events and then replays them later. We don't
2056 // need/want that. 2045 // need/want that.
2057 is_drag_mode_ = false; 2046 is_drag_mode_ = false;
2058 2047
2059 // Make the rest of eventSender think a drag is in progress. 2048 // Make the rest of eventSender think a drag is in progress.
2060 current_pointer_state_[kRawMousePointerId].pressed_button_ = 2049 current_pointer_state_[kRawMousePointerId].pressed_button_ =
2061 WebMouseEvent::Button::Left; 2050 WebMouseEvent::Button::Left;
2062 current_pointer_state_[kRawMousePointerId].current_buttons_ |= 2051 current_pointer_state_[kRawMousePointerId].current_buttons_ |=
2063 GetWebMouseEventModifierForButton( 2052 GetWebMouseEventModifierForButton(
2064 current_pointer_state_[kRawMousePointerId].pressed_button_); 2053 current_pointer_state_[kRawMousePointerId].pressed_button_);
(...skipping 11 matching lines...) Expand all
2076 if (touch_points_[i].id > highest_id) 2065 if (touch_points_[i].id > highest_id)
2077 highest_id = touch_points_[i].id; 2066 highest_id = touch_points_[i].id;
2078 } 2067 }
2079 touch_point.id = highest_id + 1; 2068 touch_point.id = highest_id + 1;
2080 2069
2081 InitPointerProperties(args, &touch_point, &touch_point.radiusX, 2070 InitPointerProperties(args, &touch_point, &touch_point.radiusX,
2082 &touch_point.radiusY); 2071 &touch_point.radiusY);
2083 2072
2084 // Set the touch point pressure to zero if it was not set by the caller 2073 // Set the touch point pressure to zero if it was not set by the caller
2085 if (std::isnan(touch_point.force)) 2074 if (std::isnan(touch_point.force))
2086 touch_point.force = 0.0; 2075 touch_point.force = 0.0;
2087 2076
2088 touch_points_.push_back(touch_point); 2077 touch_points_.push_back(touch_point);
2089 } 2078 }
2090 2079
2091 void EventSender::GestureScrollBegin(gin::Arguments* args) { 2080 void EventSender::GestureScrollBegin(gin::Arguments* args) {
2092 GestureEvent(WebInputEvent::GestureScrollBegin, args); 2081 GestureEvent(WebInputEvent::GestureScrollBegin, args);
2093 } 2082 }
2094 2083
2095 void EventSender::GestureScrollEnd(gin::Arguments* args) { 2084 void EventSender::GestureScrollEnd(gin::Arguments* args) {
2096 GestureEvent(WebInputEvent::GestureScrollEnd, args); 2085 GestureEvent(WebInputEvent::GestureScrollEnd, args);
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
2218 2207
2219 WebMouseEvent event(WebInputEvent::MouseLeave, 2208 WebMouseEvent event(WebInputEvent::MouseLeave,
2220 ModifiersForPointer(kRawMousePointerId), 2209 ModifiersForPointer(kRawMousePointerId),
2221 GetCurrentEventTimeSec()); 2210 GetCurrentEventTimeSec());
2222 InitMouseEvent(WebMouseEvent::Button::NoButton, 0, 2211 InitMouseEvent(WebMouseEvent::Button::NoButton, 0,
2223 current_pointer_state_[kRawMousePointerId].last_pos_, 2212 current_pointer_state_[kRawMousePointerId].last_pos_,
2224 click_count_, &event); 2213 click_count_, &event);
2225 HandleInputEventOnViewOrPopup(event); 2214 HandleInputEventOnViewOrPopup(event);
2226 } 2215 }
2227 2216
2228
2229 void EventSender::ScheduleAsynchronousClick(int button_number, int modifiers) { 2217 void EventSender::ScheduleAsynchronousClick(int button_number, int modifiers) {
2230 delegate()->PostTask(base::Bind(&EventSender::MouseDown, 2218 delegate()->PostTask(base::Bind(&EventSender::MouseDown,
2231 weak_factory_.GetWeakPtr(), button_number, 2219 weak_factory_.GetWeakPtr(), button_number,
2232 modifiers)); 2220 modifiers));
2233 delegate()->PostTask(base::Bind(&EventSender::MouseUp, 2221 delegate()->PostTask(base::Bind(&EventSender::MouseUp,
2234 weak_factory_.GetWeakPtr(), button_number, 2222 weak_factory_.GetWeakPtr(), button_number,
2235 modifiers)); 2223 modifiers));
2236 } 2224 }
2237 2225
2238 void EventSender::ScheduleAsynchronousKeyDown(const std::string& code_str, 2226 void EventSender::ScheduleAsynchronousKeyDown(const std::string& code_str,
2239 int modifiers, 2227 int modifiers,
2240 KeyLocationCode location) { 2228 KeyLocationCode location) {
2241 delegate()->PostTask(base::Bind(&EventSender::KeyDown, 2229 delegate()->PostTask(base::Bind(&EventSender::KeyDown,
2242 weak_factory_.GetWeakPtr(), code_str, 2230 weak_factory_.GetWeakPtr(), code_str,
2243 modifiers, location)); 2231 modifiers, location));
2244 } 2232 }
2245 2233
2246 double EventSender::GetCurrentEventTimeSec() { 2234 double EventSender::GetCurrentEventTimeSec() {
2247 return (base::TimeTicks::Now() - base::TimeTicks()).InSecondsF() + 2235 return (base::TimeTicks::Now() - base::TimeTicks()).InSecondsF() +
2248 time_offset_ms_ / 1000.0; 2236 time_offset_ms_ / 1000.0;
2249 } 2237 }
2250 2238
2251 void EventSender::DoLeapForward(int milliseconds) { 2239 void EventSender::DoLeapForward(int milliseconds) {
2252 time_offset_ms_ += milliseconds; 2240 time_offset_ms_ += milliseconds;
2253 } 2241 }
2254 2242
2255 uint32_t EventSender::GetUniqueTouchEventId(gin::Arguments* args) { 2243 uint32_t EventSender::GetUniqueTouchEventId(gin::Arguments* args) {
2256 uint32_t unique_touch_event_id; 2244 uint32_t unique_touch_event_id;
2257 if(!args->PeekNext().IsEmpty() && args->GetNext(&unique_touch_event_id)) 2245 if (!args->PeekNext().IsEmpty() && args->GetNext(&unique_touch_event_id))
2258 return unique_touch_event_id; 2246 return unique_touch_event_id;
2259 2247
2260 return 0; 2248 return 0;
2261 } 2249 }
2262 2250
2263 void EventSender::SendCurrentTouchEvent(WebInputEvent::Type type, 2251 void EventSender::SendCurrentTouchEvent(WebInputEvent::Type type,
2264 gin::Arguments* args) { 2252 gin::Arguments* args) {
2265 uint32_t unique_touch_event_id = GetUniqueTouchEventId(args); 2253 uint32_t unique_touch_event_id = GetUniqueTouchEventId(args);
2266 2254
2267 DCHECK_GT(static_cast<unsigned>(WebTouchEvent::kTouchesLengthCap), 2255 DCHECK_GT(static_cast<unsigned>(WebTouchEvent::kTouchesLengthCap),
2268 touch_points_.size()); 2256 touch_points_.size());
2269 if (force_layout_on_events_) 2257 if (force_layout_on_events_)
2270 widget()->updateAllLifecyclePhases(); 2258 widget()->updateAllLifecyclePhases();
2271 2259
2272 WebTouchEvent touch_event(type, touch_modifiers_, GetCurrentEventTimeSec()); 2260 WebTouchEvent touch_event(type, touch_modifiers_, GetCurrentEventTimeSec());
2273 touch_event.dispatchType = touch_cancelable_ 2261 touch_event.dispatchType = touch_cancelable_
2274 ? WebInputEvent::Blocking 2262 ? WebInputEvent::Blocking
2275 : WebInputEvent::EventNonBlocking; 2263 : WebInputEvent::EventNonBlocking;
2276 touch_event.movedBeyondSlopRegion = true; 2264 touch_event.movedBeyondSlopRegion = true;
2277 touch_event.uniqueTouchEventId = unique_touch_event_id; 2265 touch_event.uniqueTouchEventId = unique_touch_event_id;
2278 touch_event.touchesLength = touch_points_.size(); 2266 touch_event.touchesLength = touch_points_.size();
2279 for (size_t i = 0; i < touch_points_.size(); ++i) 2267 for (size_t i = 0; i < touch_points_.size(); ++i)
2280 touch_event.touches[i] = touch_points_[i]; 2268 touch_event.touches[i] = touch_points_[i];
2281 HandleInputEventOnViewOrPopup(touch_event); 2269 HandleInputEventOnViewOrPopup(touch_event);
2282 2270
2283 for (size_t i = 0; i < touch_points_.size(); ++i) { 2271 for (size_t i = 0; i < touch_points_.size(); ++i) {
2284 WebTouchPoint* touch_point = &touch_points_[i]; 2272 WebTouchPoint* touch_point = &touch_points_[i];
2285 if (touch_point->state == WebTouchPoint::StateReleased 2273 if (touch_point->state == WebTouchPoint::StateReleased ||
2286 || touch_point->state == WebTouchPoint::StateCancelled) { 2274 touch_point->state == WebTouchPoint::StateCancelled) {
2287 touch_points_.erase(touch_points_.begin() + i); 2275 touch_points_.erase(touch_points_.begin() + i);
2288 --i; 2276 --i;
2289 } else { 2277 } else {
2290 touch_point->state = WebTouchPoint::StateStationary; 2278 touch_point->state = WebTouchPoint::StateStationary;
2291 } 2279 }
2292 } 2280 }
2293 } 2281 }
2294 2282
2295 void EventSender::GestureEvent(WebInputEvent::Type type, 2283 void EventSender::GestureEvent(WebInputEvent::Type type, gin::Arguments* args) {
2296 gin::Arguments* args) {
2297 WebGestureEvent event(type, WebInputEvent::NoModifiers, 2284 WebGestureEvent event(type, WebInputEvent::NoModifiers,
2298 GetCurrentEventTimeSec()); 2285 GetCurrentEventTimeSec());
2299 2286
2300 // If the first argument is a string, it is to specify the device, otherwise 2287 // If the first argument is a string, it is to specify the device, otherwise
2301 // the device is assumed to be a touchscreen (since most tests were written 2288 // the device is assumed to be a touchscreen (since most tests were written
2302 // assuming this). 2289 // assuming this).
2303 event.sourceDevice = blink::WebGestureDeviceTouchscreen; 2290 event.sourceDevice = blink::WebGestureDeviceTouchscreen;
2304 if (!args->PeekNext().IsEmpty() && args->PeekNext()->IsString()) { 2291 if (!args->PeekNext().IsEmpty() && args->PeekNext()->IsString()) {
2305 std::string device_string; 2292 std::string device_string;
2306 if (!args->GetNext(&device_string)) { 2293 if (!args->GetNext(&device_string)) {
(...skipping 11 matching lines...) Expand all
2318 } 2305 }
2319 2306
2320 double x; 2307 double x;
2321 double y; 2308 double y;
2322 if (!args->GetNext(&x) || !args->GetNext(&y)) { 2309 if (!args->GetNext(&x) || !args->GetNext(&y)) {
2323 args->ThrowError(); 2310 args->ThrowError();
2324 return; 2311 return;
2325 } 2312 }
2326 2313
2327 switch (type) { 2314 switch (type) {
2328 case WebInputEvent::GestureScrollUpdate: 2315 case WebInputEvent::GestureScrollUpdate: {
2329 {
2330 bool preventPropagation = false; 2316 bool preventPropagation = false;
2331 if (!args->PeekNext().IsEmpty()) { 2317 if (!args->PeekNext().IsEmpty()) {
2332 if (!args->GetNext(&preventPropagation)) { 2318 if (!args->GetNext(&preventPropagation)) {
2333 args->ThrowError(); 2319 args->ThrowError();
2334 return; 2320 return;
2335 } 2321 }
2336 } 2322 }
2337 if (!GetScrollUnits(args, &event.data.scrollUpdate.deltaUnits)) 2323 if (!GetScrollUnits(args, &event.data.scrollUpdate.deltaUnits))
2338 return; 2324 return;
2339 2325
(...skipping 17 matching lines...) Expand all
2357 case WebInputEvent::GestureFlingStart: 2343 case WebInputEvent::GestureFlingStart:
2358 event.x = current_gesture_location_.x; 2344 event.x = current_gesture_location_.x;
2359 event.y = current_gesture_location_.y; 2345 event.y = current_gesture_location_.y;
2360 break; 2346 break;
2361 case WebInputEvent::GesturePinchBegin: 2347 case WebInputEvent::GesturePinchBegin:
2362 case WebInputEvent::GesturePinchEnd: 2348 case WebInputEvent::GesturePinchEnd:
2363 current_gesture_location_ = WebPoint(x, y); 2349 current_gesture_location_ = WebPoint(x, y);
2364 event.x = current_gesture_location_.x; 2350 event.x = current_gesture_location_.x;
2365 event.y = current_gesture_location_.y; 2351 event.y = current_gesture_location_.y;
2366 break; 2352 break;
2367 case WebInputEvent::GesturePinchUpdate: 2353 case WebInputEvent::GesturePinchUpdate: {
2368 {
2369 float scale = 1; 2354 float scale = 1;
2370 if (!args->PeekNext().IsEmpty()) { 2355 if (!args->PeekNext().IsEmpty()) {
2371 if (!args->GetNext(&scale)) { 2356 if (!args->GetNext(&scale)) {
2372 args->ThrowError(); 2357 args->ThrowError();
2373 return; 2358 return;
2374 } 2359 }
2375 } 2360 }
2376 event.data.pinchUpdate.scale = scale; 2361 event.data.pinchUpdate.scale = scale;
2377 current_gesture_location_ = WebPoint(x, y); 2362 current_gesture_location_ = WebPoint(x, y);
2378 event.x = current_gesture_location_.x; 2363 event.x = current_gesture_location_.x;
2379 event.y = current_gesture_location_.y; 2364 event.y = current_gesture_location_.y;
2380 break; 2365 break;
2381 } 2366 }
2382 case WebInputEvent::GestureTap: 2367 case WebInputEvent::GestureTap: {
2383 {
2384 float tap_count = 1; 2368 float tap_count = 1;
2385 float width = 30; 2369 float width = 30;
2386 float height = 30; 2370 float height = 30;
2387 if (!args->PeekNext().IsEmpty()) { 2371 if (!args->PeekNext().IsEmpty()) {
2388 if (!args->GetNext(&tap_count)) { 2372 if (!args->GetNext(&tap_count)) {
2389 args->ThrowError(); 2373 args->ThrowError();
2390 return; 2374 return;
2391 } 2375 }
2392 } 2376 }
2393 if (!args->PeekNext().IsEmpty()) { 2377 if (!args->PeekNext().IsEmpty()) {
(...skipping 22 matching lines...) Expand all
2416 args->ThrowError(); 2400 args->ThrowError();
2417 return; 2401 return;
2418 } 2402 }
2419 event.data.tap.tapCount = tap_count; 2403 event.data.tap.tapCount = tap_count;
2420 } else { 2404 } else {
2421 event.data.tap.tapCount = 1; 2405 event.data.tap.tapCount = 1;
2422 } 2406 }
2423 event.x = x; 2407 event.x = x;
2424 event.y = y; 2408 event.y = y;
2425 break; 2409 break;
2426 case WebInputEvent::GestureTapDown: 2410 case WebInputEvent::GestureTapDown: {
2427 {
2428 float width = 30; 2411 float width = 30;
2429 float height = 30; 2412 float height = 30;
2430 if (!args->PeekNext().IsEmpty()) { 2413 if (!args->PeekNext().IsEmpty()) {
2431 if (!args->GetNext(&width)) { 2414 if (!args->GetNext(&width)) {
2432 args->ThrowError(); 2415 args->ThrowError();
2433 return; 2416 return;
2434 } 2417 }
2435 } 2418 }
2436 if (!args->PeekNext().IsEmpty()) { 2419 if (!args->PeekNext().IsEmpty()) {
2437 if (!args->GetNext(&height)) { 2420 if (!args->GetNext(&height)) {
2438 args->ThrowError(); 2421 args->ThrowError();
2439 return; 2422 return;
2440 } 2423 }
2441 } 2424 }
2442 event.x = x; 2425 event.x = x;
2443 event.y = y; 2426 event.y = y;
2444 event.data.tapDown.width = width; 2427 event.data.tapDown.width = width;
2445 event.data.tapDown.height = height; 2428 event.data.tapDown.height = height;
2446 break; 2429 break;
2447 } 2430 }
2448 case WebInputEvent::GestureShowPress: 2431 case WebInputEvent::GestureShowPress: {
2449 {
2450 float width = 30; 2432 float width = 30;
2451 float height = 30; 2433 float height = 30;
2452 if (!args->PeekNext().IsEmpty()) { 2434 if (!args->PeekNext().IsEmpty()) {
2453 if (!args->GetNext(&width)) { 2435 if (!args->GetNext(&width)) {
2454 args->ThrowError(); 2436 args->ThrowError();
2455 return; 2437 return;
2456 } 2438 }
2457 if (!args->PeekNext().IsEmpty()) { 2439 if (!args->PeekNext().IsEmpty()) {
2458 if (!args->GetNext(&height)) { 2440 if (!args->GetNext(&height)) {
2459 args->ThrowError(); 2441 args->ThrowError();
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
2534 2516
2535 InitMouseEvent(current_pointer_state_[kRawMousePointerId].pressed_button_, 2517 InitMouseEvent(current_pointer_state_[kRawMousePointerId].pressed_button_,
2536 current_pointer_state_[kRawMousePointerId].current_buttons_, 2518 current_pointer_state_[kRawMousePointerId].current_buttons_,
2537 WebPoint(x, y), click_count_, &mouse_event); 2519 WebPoint(x, y), click_count_, &mouse_event);
2538 2520
2539 FinishDragAndDrop(mouse_event, blink::WebDragOperationNone); 2521 FinishDragAndDrop(mouse_event, blink::WebDragOperationNone);
2540 } 2522 }
2541 args->Return(result != WebInputEventResult::NotHandled); 2523 args->Return(result != WebInputEventResult::NotHandled);
2542 } 2524 }
2543 2525
2544 void EventSender::UpdateClickCountForButton( 2526 void EventSender::UpdateClickCountForButton(WebMouseEvent::Button button_type) {
2545 WebMouseEvent::Button button_type) {
2546 if ((GetCurrentEventTimeSec() - last_click_time_sec_ < 2527 if ((GetCurrentEventTimeSec() - last_click_time_sec_ <
2547 kMultipleClickTimeSec) && 2528 kMultipleClickTimeSec) &&
2548 (!OutsideMultiClickRadius( 2529 (!OutsideMultiClickRadius(
2549 current_pointer_state_[kRawMousePointerId].last_pos_, 2530 current_pointer_state_[kRawMousePointerId].last_pos_,
2550 last_click_pos_)) && 2531 last_click_pos_)) &&
2551 (button_type == last_button_type_)) { 2532 (button_type == last_button_type_)) {
2552 ++click_count_; 2533 ++click_count_;
2553 } else { 2534 } else {
2554 click_count_ = 1; 2535 click_count_ = 1;
2555 last_button_type_ = button_type; 2536 last_button_type_ = button_type;
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
2900 return view()->mainFrame()->toWebLocalFrame()->frameWidget(); 2881 return view()->mainFrame()->toWebLocalFrame()->frameWidget();
2901 } 2882 }
2902 2883
2903 std::unique_ptr<WebInputEvent> EventSender::TransformScreenToWidgetCoordinates( 2884 std::unique_ptr<WebInputEvent> EventSender::TransformScreenToWidgetCoordinates(
2904 const WebInputEvent& event) { 2885 const WebInputEvent& event) {
2905 return delegate()->TransformScreenToWidgetCoordinates( 2886 return delegate()->TransformScreenToWidgetCoordinates(
2906 web_widget_test_proxy_base_, event); 2887 web_widget_test_proxy_base_, event);
2907 } 2888 }
2908 2889
2909 } // namespace test_runner 2890 } // namespace test_runner
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698