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

Side by Side Diff: content/public/test/browser_test_utils.cc

Issue 2782893002: WebMouseEvent coordinates are now fractional & private (Closed)
Patch Set: Rebased, fixed a comment in web_input_event_builders_mac.mm Created 3 years, 8 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/public/test/browser_test_utils.h" 5 #include "content/public/test/browser_test_utils.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <tuple> 8 #include <tuple>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 } 530 }
531 531
532 void SimulateMouseClickAt(WebContents* web_contents, 532 void SimulateMouseClickAt(WebContents* web_contents,
533 int modifiers, 533 int modifiers,
534 blink::WebMouseEvent::Button button, 534 blink::WebMouseEvent::Button button,
535 const gfx::Point& point) { 535 const gfx::Point& point) {
536 blink::WebMouseEvent mouse_event( 536 blink::WebMouseEvent mouse_event(
537 blink::WebInputEvent::MouseDown, modifiers, 537 blink::WebInputEvent::MouseDown, modifiers,
538 ui::EventTimeStampToSeconds(ui::EventTimeForNow())); 538 ui::EventTimeStampToSeconds(ui::EventTimeForNow()));
539 mouse_event.button = button; 539 mouse_event.button = button;
540 mouse_event.x = point.x(); 540 mouse_event.setPositionInWidget(point.x(), point.y());
541 mouse_event.y = point.y(); 541 // Mac needs positionInScreen for events to plugins.
542 // Mac needs globalX/globalY for events to plugins.
543 gfx::Rect offset = web_contents->GetContainerBounds(); 542 gfx::Rect offset = web_contents->GetContainerBounds();
544 mouse_event.globalX = point.x() + offset.x(); 543 mouse_event.setPositionInScreen(point.x() + offset.x(),
545 mouse_event.globalY = point.y() + offset.y(); 544 point.y() + offset.y());
546 mouse_event.clickCount = 1; 545 mouse_event.clickCount = 1;
547 web_contents->GetRenderViewHost()->GetWidget()->ForwardMouseEvent( 546 web_contents->GetRenderViewHost()->GetWidget()->ForwardMouseEvent(
548 mouse_event); 547 mouse_event);
549 mouse_event.setType(blink::WebInputEvent::MouseUp); 548 mouse_event.setType(blink::WebInputEvent::MouseUp);
550 web_contents->GetRenderViewHost()->GetWidget()->ForwardMouseEvent( 549 web_contents->GetRenderViewHost()->GetWidget()->ForwardMouseEvent(
551 mouse_event); 550 mouse_event);
552 } 551 }
553 552
554 void SimulateMouseEvent(WebContents* web_contents, 553 void SimulateMouseEvent(WebContents* web_contents,
555 blink::WebInputEvent::Type type, 554 blink::WebInputEvent::Type type,
556 const gfx::Point& point) { 555 const gfx::Point& point) {
557 blink::WebMouseEvent mouse_event( 556 blink::WebMouseEvent mouse_event(
558 type, blink::WebInputEvent::NoModifiers, 557 type, blink::WebInputEvent::NoModifiers,
559 ui::EventTimeStampToSeconds(ui::EventTimeForNow())); 558 ui::EventTimeStampToSeconds(ui::EventTimeForNow()));
560 mouse_event.x = point.x(); 559 mouse_event.setPositionInWidget(point.x(), point.y());
561 mouse_event.y = point.y();
562 web_contents->GetRenderViewHost()->GetWidget()->ForwardMouseEvent( 560 web_contents->GetRenderViewHost()->GetWidget()->ForwardMouseEvent(
563 mouse_event); 561 mouse_event);
564 } 562 }
565 563
566 void SimulateMouseWheelEvent(WebContents* web_contents, 564 void SimulateMouseWheelEvent(WebContents* web_contents,
567 const gfx::Point& point, 565 const gfx::Point& point,
568 const gfx::Vector2d& delta) { 566 const gfx::Vector2d& delta) {
569 blink::WebMouseWheelEvent wheel_event( 567 blink::WebMouseWheelEvent wheel_event(
570 blink::WebInputEvent::MouseWheel, blink::WebInputEvent::NoModifiers, 568 blink::WebInputEvent::MouseWheel, blink::WebInputEvent::NoModifiers,
571 ui::EventTimeStampToSeconds(ui::EventTimeForNow())); 569 ui::EventTimeStampToSeconds(ui::EventTimeForNow()));
572 570
573 wheel_event.x = point.x(); 571 wheel_event.setPositionInWidget(point.x(), point.y());
574 wheel_event.y = point.y();
575 wheel_event.deltaX = delta.x(); 572 wheel_event.deltaX = delta.x();
576 wheel_event.deltaY = delta.y(); 573 wheel_event.deltaY = delta.y();
577 RenderWidgetHostImpl* widget_host = RenderWidgetHostImpl::From( 574 RenderWidgetHostImpl* widget_host = RenderWidgetHostImpl::From(
578 web_contents->GetRenderViewHost()->GetWidget()); 575 web_contents->GetRenderViewHost()->GetWidget());
579 widget_host->ForwardWheelEvent(wheel_event); 576 widget_host->ForwardWheelEvent(wheel_event);
580 } 577 }
581 578
582 void SimulateGestureScrollSequence(WebContents* web_contents, 579 void SimulateGestureScrollSequence(WebContents* web_contents,
583 const gfx::Point& point, 580 const gfx::Point& point,
584 const gfx::Vector2dF& delta) { 581 const gfx::Vector2dF& delta) {
(...skipping 1378 matching lines...) Expand 10 before | Expand all | Expand 10 after
1963 bool user_gesture, 1960 bool user_gesture,
1964 bool last_unlocked_by_target, 1961 bool last_unlocked_by_target,
1965 bool privileged) { 1962 bool privileged) {
1966 IPC::IpcSecurityTestUtil::PwnMessageReceived( 1963 IPC::IpcSecurityTestUtil::PwnMessageReceived(
1967 process->GetChannel(), 1964 process->GetChannel(),
1968 ViewHostMsg_LockMouse(routing_id, user_gesture, last_unlocked_by_target, 1965 ViewHostMsg_LockMouse(routing_id, user_gesture, last_unlocked_by_target,
1969 privileged)); 1966 privileged));
1970 } 1967 }
1971 1968
1972 } // namespace content 1969 } // namespace content
OLDNEW
« no previous file with comments | « content/common/input/synthetic_web_input_event_builders.cc ('k') | content/public/test/render_view_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698