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

Unified Diff: content/browser/site_per_process_browsertest.cc

Issue 2782893002: WebMouseEvent coordinates are now fractional & private (Closed)
Patch Set: Fixed compile failures. Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/site_per_process_browsertest.cc
diff --git a/content/browser/site_per_process_browsertest.cc b/content/browser/site_per_process_browsertest.cc
index ba4b4b1c63815cc2d910232028347097cdd0f3c7..6500f27bd5ce4519aacb1a2f4f6affb88f2d75c9 100644
--- a/content/browser/site_per_process_browsertest.cc
+++ b/content/browser/site_per_process_browsertest.cc
@@ -169,8 +169,8 @@ void SimulateMouseClick(RenderWidgetHost* rwh, int x, int y) {
blink::WebInputEvent::NoModifiers,
blink::WebInputEvent::TimeStampForTesting);
mouse_event.button = blink::WebPointerProperties::Button::Left;
- mouse_event.x = x;
- mouse_event.y = y;
+ mouse_event.position.x = x;
+ mouse_event.position.y = y;
rwh->ForwardMouseEvent(mouse_event);
}
@@ -311,11 +311,11 @@ void SurfaceHitTestTestHelper(
blink::WebInputEvent::NoModifiers,
blink::WebInputEvent::TimeStampForTesting);
child_event.button = blink::WebPointerProperties::Button::Left;
- child_event.x =
+ child_event.position.x =
gfx::ToCeiledInt((bounds.x() - root_view->GetViewBounds().x()) /
scale_factor) +
3;
- child_event.y =
+ child_event.position.y =
gfx::ToCeiledInt((bounds.y() - root_view->GetViewBounds().y()) /
scale_factor) +
3;
@@ -327,12 +327,12 @@ void SurfaceHitTestTestHelper(
EXPECT_TRUE(child_frame_monitor.EventWasReceived());
// The expected result coordinates are (3, 3), but can get slightly
// different results due to rounding error with some device scale factors.
- EXPECT_TRUE(child_frame_monitor.event().x <= 5 &&
- child_frame_monitor.event().x >= 1)
- << " actual event.x: " << child_frame_monitor.event().x;
- EXPECT_TRUE(child_frame_monitor.event().y <= 5 &&
- child_frame_monitor.event().y >= 1)
- << " actual event.y: " << child_frame_monitor.event().y;
+ EXPECT_TRUE(child_frame_monitor.event().position.x <= 5 &&
+ child_frame_monitor.event().position.x >= 1)
+ << " actual event.position.x: " << child_frame_monitor.event().position.x;
+ EXPECT_TRUE(child_frame_monitor.event().position.y <= 5 &&
+ child_frame_monitor.event().position.y >= 1)
+ << " actual event.position.y: " << child_frame_monitor.event().position.y;
EXPECT_FALSE(main_frame_monitor.EventWasReceived());
child_frame_monitor.ResetEventReceived();
@@ -343,16 +343,16 @@ void SurfaceHitTestTestHelper(
blink::WebInputEvent::NoModifiers,
blink::WebInputEvent::TimeStampForTesting);
main_event.button = blink::WebPointerProperties::Button::Left;
- main_event.x = 1;
- main_event.y = 1;
+ main_event.position.x = 1;
+ main_event.position.y = 1;
main_event.clickCount = 1;
// Ladies and gentlemen, THIS is the main_event!
router->RouteMouseEvent(root_view, &main_event, ui::LatencyInfo());
EXPECT_FALSE(child_frame_monitor.EventWasReceived());
EXPECT_TRUE(main_frame_monitor.EventWasReceived());
- EXPECT_EQ(1, main_frame_monitor.event().x);
- EXPECT_EQ(1, main_frame_monitor.event().y);
+ EXPECT_EQ(1, main_frame_monitor.event().position.x);
+ EXPECT_EQ(1, main_frame_monitor.event().position.y);
}
class RedirectNotificationObserver : public NotificationObserver {
@@ -1075,9 +1075,9 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
blink::WebInputEvent::MouseWheel, blink::WebInputEvent::NoModifiers,
blink::WebInputEvent::TimeStampForTesting);
- scroll_event.x = gfx::ToFlooredInt(
+ scroll_event.position.x = gfx::ToFlooredInt(
(bounds.x() - rwhv_root->GetViewBounds().x() - 5) / scale_factor);
- scroll_event.y = gfx::ToFlooredInt(
+ scroll_event.position.y = gfx::ToFlooredInt(
(bounds.y() - rwhv_root->GetViewBounds().y() - 5) / scale_factor);
scroll_event.deltaX = 0.0f;
scroll_event.deltaY = -30.0f;
@@ -1163,8 +1163,8 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
blink::WebMouseWheelEvent scroll_event(
blink::WebInputEvent::MouseWheel, blink::WebInputEvent::NoModifiers,
blink::WebInputEvent::TimeStampForTesting);
- scroll_event.x = 1;
- scroll_event.y = 1;
+ scroll_event.position.x = 1;
+ scroll_event.position.y = 1;
scroll_event.deltaX = 0.0f;
scroll_event.deltaY = -5.0f;
rwhv_parent->ProcessMouseWheelEvent(scroll_event, ui::LatencyInfo());
@@ -1410,11 +1410,11 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
blink::WebInputEvent::NoModifiers,
blink::WebInputEvent::TimeStampForTesting);
nested_event.button = blink::WebPointerProperties::Button::Left;
- nested_event.x =
+ nested_event.position.x =
gfx::ToCeiledInt((bounds.x() - root_view->GetViewBounds().x()) /
scale_factor) +
5;
- nested_event.y =
+ nested_event.position.y =
gfx::ToCeiledInt((bounds.y() - root_view->GetViewBounds().y()) /
scale_factor) +
5;
@@ -1426,12 +1426,14 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
EXPECT_TRUE(nested_frame_monitor.EventWasReceived());
// The expected result coordinates are (5, 5), but can get slightly
// different results due to rounding error with some device scale factors.
- EXPECT_TRUE(nested_frame_monitor.event().x <= 6 &&
- nested_frame_monitor.event().x >= 4)
- << " actual event.x: " << nested_frame_monitor.event().x;
- EXPECT_TRUE(nested_frame_monitor.event().y <= 6 &&
- nested_frame_monitor.event().y >= 4)
- << " actual event.y: " << nested_frame_monitor.event().y;
+ EXPECT_TRUE(nested_frame_monitor.event().position.x <= 6 &&
+ nested_frame_monitor.event().position.x >= 4)
+ << " actual event.position.x: "
+ << nested_frame_monitor.event().position.x;
+ EXPECT_TRUE(nested_frame_monitor.event().position.y <= 6 &&
+ nested_frame_monitor.event().position.y >= 4)
+ << " actual event.position.y: "
+ << nested_frame_monitor.event().position.y;
EXPECT_FALSE(main_frame_monitor.EventWasReceived());
}
@@ -1484,16 +1486,16 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
blink::WebInputEvent::NoModifiers,
blink::WebInputEvent::TimeStampForTesting);
child_event.button = blink::WebPointerProperties::Button::Left;
- child_event.x = 75;
- child_event.y = 75;
+ child_event.position.x = 75;
+ child_event.position.y = 75;
child_event.clickCount = 1;
main_frame_monitor.ResetEventReceived();
child_frame_monitor.ResetEventReceived();
router->RouteMouseEvent(root_view, &child_event, ui::LatencyInfo());
EXPECT_TRUE(main_frame_monitor.EventWasReceived());
- EXPECT_EQ(75, main_frame_monitor.event().x);
- EXPECT_EQ(75, main_frame_monitor.event().y);
+ EXPECT_EQ(75, main_frame_monitor.event().position.x);
+ EXPECT_EQ(75, main_frame_monitor.event().position.y);
EXPECT_FALSE(child_frame_monitor.EventWasReceived());
}
@@ -1583,8 +1585,8 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
blink::WebMouseEvent mouse_event(blink::WebInputEvent::MouseMove,
blink::WebInputEvent::NoModifiers,
blink::WebInputEvent::TimeStampForTesting);
- mouse_event.x = point_in_a_frame.x();
- mouse_event.y = point_in_a_frame.y();
+ mouse_event.position.x = point_in_a_frame.x();
+ mouse_event.position.y = point_in_a_frame.y();
// Send an initial MouseMove to the root view, which shouldn't affect the
// other renderers.
@@ -1598,8 +1600,8 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
// Next send a MouseMove to B frame, which shouldn't affect C or D but
// A should receive a MouseMove event.
- mouse_event.x = point_in_b_frame.x();
- mouse_event.y = point_in_b_frame.y();
+ mouse_event.position.x = point_in_b_frame.x();
+ mouse_event.position.y = point_in_b_frame.y();
web_contents()->GetInputEventRouter()->RouteMouseEvent(rwhv_a, &mouse_event,
ui::LatencyInfo());
EXPECT_TRUE(a_frame_monitor.EventWasReceived());
@@ -1612,8 +1614,8 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
// Next send a MouseMove to D frame, which should have side effects in every
// other RenderWidgetHostView.
- mouse_event.x = point_in_d_frame.x();
- mouse_event.y = point_in_d_frame.y();
+ mouse_event.position.x = point_in_d_frame.x();
+ mouse_event.position.y = point_in_d_frame.y();
web_contents()->GetInputEventRouter()->RouteMouseEvent(rwhv_a, &mouse_event,
ui::LatencyInfo());
EXPECT_TRUE(a_frame_monitor.EventWasReceived());
@@ -1689,8 +1691,8 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
blink::WebInputEvent::NoModifiers,
blink::WebInputEvent::TimeStampForTesting);
mouse_event.button = blink::WebPointerProperties::Button::Left;
- mouse_event.x = child_frame_target_x;
- mouse_event.y = child_frame_target_y;
+ mouse_event.position.x = child_frame_target_x;
+ mouse_event.position.y = child_frame_target_y;
mouse_event.clickCount = 1;
main_frame_monitor.ResetEventReceived();
child_frame_monitor.ResetEventReceived();
@@ -1703,8 +1705,8 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
// child frame because it is now capturing mouse input.
mouse_event.setType(blink::WebInputEvent::MouseMove);
mouse_event.setModifiers(blink::WebInputEvent::LeftButtonDown);
- mouse_event.x = 1;
- mouse_event.y = 1;
+ mouse_event.position.x = 1;
+ mouse_event.position.y = 1;
// Note that this event is sent twice, with the monitors cleared after
// the first time, because the first MouseMove to the child frame
// causes a MouseMove to be sent to the main frame also, which we
@@ -1712,8 +1714,8 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
router->RouteMouseEvent(root_view, &mouse_event, ui::LatencyInfo());
main_frame_monitor.ResetEventReceived();
child_frame_monitor.ResetEventReceived();
- mouse_event.x = 1;
- mouse_event.y = 2;
+ mouse_event.position.x = 1;
+ mouse_event.position.y = 2;
router->RouteMouseEvent(root_view, &mouse_event, ui::LatencyInfo());
EXPECT_FALSE(main_frame_monitor.EventWasReceived());
@@ -1722,8 +1724,8 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
// A MouseUp to the child frame should cancel the mouse capture.
mouse_event.setType(blink::WebInputEvent::MouseUp);
mouse_event.setModifiers(blink::WebInputEvent::NoModifiers);
- mouse_event.x = child_frame_target_x;
- mouse_event.y = child_frame_target_y;
+ mouse_event.position.x = child_frame_target_x;
+ mouse_event.position.y = child_frame_target_y;
main_frame_monitor.ResetEventReceived();
child_frame_monitor.ResetEventReceived();
router->RouteMouseEvent(root_view, &mouse_event, ui::LatencyInfo());
@@ -1734,14 +1736,14 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
// Subsequent MouseMove events targeted to the main frame should be routed
// to that frame.
mouse_event.setType(blink::WebInputEvent::MouseMove);
- mouse_event.x = 1;
- mouse_event.y = 3;
+ mouse_event.position.x = 1;
+ mouse_event.position.y = 3;
// Sending the MouseMove twice for the same reason as above.
router->RouteMouseEvent(root_view, &mouse_event, ui::LatencyInfo());
main_frame_monitor.ResetEventReceived();
child_frame_monitor.ResetEventReceived();
- mouse_event.x = 1;
- mouse_event.y = 4;
+ mouse_event.position.x = 1;
+ mouse_event.position.y = 4;
router->RouteMouseEvent(root_view, &mouse_event, ui::LatencyInfo());
EXPECT_TRUE(main_frame_monitor.EventWasReceived());
@@ -1749,8 +1751,8 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
// Target MouseDown to the main frame to cause it to capture input.
mouse_event.setType(blink::WebInputEvent::MouseDown);
- mouse_event.x = 1;
- mouse_event.y = 1;
+ mouse_event.position.x = 1;
+ mouse_event.position.y = 1;
main_frame_monitor.ResetEventReceived();
child_frame_monitor.ResetEventReceived();
router->RouteMouseEvent(root_view, &mouse_event, ui::LatencyInfo());
@@ -1762,8 +1764,8 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
// frame receiving the event.
mouse_event.setType(blink::WebInputEvent::MouseMove);
mouse_event.setModifiers(blink::WebInputEvent::LeftButtonDown);
- mouse_event.x = child_frame_target_x;
- mouse_event.y = child_frame_target_y;
+ mouse_event.position.x = child_frame_target_x;
+ mouse_event.position.y = child_frame_target_y;
main_frame_monitor.ResetEventReceived();
child_frame_monitor.ResetEventReceived();
router->RouteMouseEvent(root_view, &mouse_event, ui::LatencyInfo());
@@ -5442,8 +5444,8 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
blink::WebMouseEvent mouse_event(blink::WebInputEvent::MouseMove,
blink::WebInputEvent::NoModifiers,
blink::WebInputEvent::TimeStampForTesting);
- mouse_event.x = 60;
- mouse_event.y = 60;
+ mouse_event.position.x = 60;
+ mouse_event.position.y = 60;
RenderWidgetHost* rwh_child =
root->child_at(0)->current_frame_host()->GetRenderWidgetHost();
RenderWidgetHostViewBase* root_view = static_cast<RenderWidgetHostViewBase*>(
@@ -6240,15 +6242,15 @@ void CreateContextMenuTestHelper(
blink::WebInputEvent::NoModifiers,
blink::WebInputEvent::TimeStampForTesting);
click_event.button = blink::WebPointerProperties::Button::Right;
- click_event.x = point.x();
- click_event.y = point.y();
+ click_event.position.x = point.x();
+ click_event.position.y = point.y();
click_event.clickCount = 1;
router->RouteMouseEvent(root_view, &click_event, ui::LatencyInfo());
// We also need a MouseUp event, needed by Windows.
click_event.setType(blink::WebInputEvent::MouseUp);
- click_event.x = point.x();
- click_event.y = point.y();
+ click_event.position.x = point.x();
+ click_event.position.y = point.y();
router->RouteMouseEvent(root_view, &click_event, ui::LatencyInfo());
context_menu_delegate.Wait();
@@ -6394,14 +6396,14 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, PopupMenuTest) {
blink::WebInputEvent::NoModifiers,
blink::WebInputEvent::TimeStampForTesting);
click_event.button = blink::WebPointerProperties::Button::Left;
- click_event.x = 15;
- click_event.y = 15;
+ click_event.position.x = 15;
+ click_event.position.y = 15;
click_event.clickCount = 1;
rwhv_child->ProcessMouseEvent(click_event, ui::LatencyInfo());
// Dismiss the popup.
- click_event.x = 1;
- click_event.y = 1;
+ click_event.position.x = 1;
+ click_event.position.y = 1;
rwhv_child->ProcessMouseEvent(click_event, ui::LatencyInfo());
filter->Wait();
@@ -6428,8 +6430,8 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, PopupMenuTest) {
static_cast<WebContentsImpl*>(shell()->web_contents())
->GetInputEventRouter();
// Re-open the select element.
- click_event.x = 360;
- click_event.y = 90;
+ click_event.position.x = 360;
+ click_event.position.y = 90;
click_event.clickCount = 1;
router->RouteMouseEvent(rwhv_root, &click_event, ui::LatencyInfo());
@@ -6511,14 +6513,14 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, MAYBE_NestedPopupMenuTest) {
blink::WebInputEvent::NoModifiers,
blink::WebInputEvent::TimeStampForTesting);
click_event.button = blink::WebPointerProperties::Button::Left;
- click_event.x = 15;
- click_event.y = 15;
+ click_event.position.x = 15;
+ click_event.position.y = 15;
click_event.clickCount = 1;
rwhv_c_node->ProcessMouseEvent(click_event, ui::LatencyInfo());
// Prompt the WebContents to dismiss the popup by clicking elsewhere.
- click_event.x = 1;
- click_event.y = 1;
+ click_event.position.x = 1;
+ click_event.position.y = 1;
rwhv_c_node->ProcessMouseEvent(click_event, ui::LatencyInfo());
filter->Wait();
@@ -6561,13 +6563,13 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, MAYBE_NestedPopupMenuTest) {
}
click_event.button = blink::WebPointerProperties::Button::Left;
- click_event.x = 15;
- click_event.y = 15;
+ click_event.position.x = 15;
+ click_event.position.y = 15;
click_event.clickCount = 1;
rwhv_c_node->ProcessMouseEvent(click_event, ui::LatencyInfo());
- click_event.x = 1;
- click_event.y = 1;
+ click_event.position.x = 1;
+ click_event.position.y = 1;
rwhv_c_node->ProcessMouseEvent(click_event, ui::LatencyInfo());
filter->Wait();
@@ -9402,25 +9404,25 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessNonIntegerScaleFactorBrowserTest,
blink::WebInputEvent::NoModifiers,
blink::WebInputEvent::TimeStampForTesting);
mouse_event.button = blink::WebPointerProperties::Button::Left;
- mouse_event.x = 75;
- mouse_event.y = 75;
+ mouse_event.position.x = 75;
+ mouse_event.position.y = 75;
mouse_event.clickCount = 1;
event_monitor.ResetEventReceived();
router->RouteMouseEvent(rwhv, &mouse_event, ui::LatencyInfo());
EXPECT_TRUE(event_monitor.EventWasReceived());
- gfx::Point mouse_down_coords =
- gfx::Point(event_monitor.event().x, event_monitor.event().y);
+ gfx::Point mouse_down_coords = gfx::Point(event_monitor.event().position.x,
+ event_monitor.event().position.y);
event_monitor.ResetEventReceived();
mouse_event.setType(blink::WebInputEvent::MouseUp);
- mouse_event.x = 75;
- mouse_event.y = 75;
+ mouse_event.position.x = 75;
+ mouse_event.position.y = 75;
router->RouteMouseEvent(rwhv, &mouse_event, ui::LatencyInfo());
EXPECT_TRUE(event_monitor.EventWasReceived());
- EXPECT_EQ(mouse_down_coords,
- gfx::Point(event_monitor.event().x, event_monitor.event().y));
+ EXPECT_EQ(mouse_down_coords, gfx::Point(event_monitor.event().position.x,
+ event_monitor.event().position.y));
}
// This tests that we don't hide the RenderViewHost when reusing the

Powered by Google App Engine
This is Rietveld 408576698