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

Side by Side Diff: third_party/WebKit/Source/web/tests/VisualViewportTest.cpp

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 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 "core/frame/VisualViewport.h" 5 #include "core/frame/VisualViewport.h"
6 6
7 #include "core/dom/Document.h" 7 #include "core/dom/Document.h"
8 #include "core/frame/BrowserControls.h" 8 #include "core/frame/BrowserControls.h"
9 #include "core/frame/FrameView.h" 9 #include "core/frame/FrameView.h"
10 #include "core/frame/LocalFrame.h" 10 #include "core/frame/LocalFrame.h"
(...skipping 1120 matching lines...) Expand 10 before | Expand all | Expand 10 after
1131 TEST_P(VisualViewportTest, TestContextMenuShownInCorrectLocation) { 1131 TEST_P(VisualViewportTest, TestContextMenuShownInCorrectLocation) {
1132 initializeWithDesktopSettings(); 1132 initializeWithDesktopSettings();
1133 webViewImpl()->resize(IntSize(200, 300)); 1133 webViewImpl()->resize(IntSize(200, 300));
1134 1134
1135 registerMockedHttpURLLoad("200-by-300.html"); 1135 registerMockedHttpURLLoad("200-by-300.html");
1136 navigateTo(m_baseURL + "200-by-300.html"); 1136 navigateTo(m_baseURL + "200-by-300.html");
1137 1137
1138 WebMouseEvent mouseDownEvent(WebInputEvent::MouseDown, 1138 WebMouseEvent mouseDownEvent(WebInputEvent::MouseDown,
1139 WebInputEvent::NoModifiers, 1139 WebInputEvent::NoModifiers,
1140 WebInputEvent::TimeStampForTesting); 1140 WebInputEvent::TimeStampForTesting);
1141 mouseDownEvent.x = 10; 1141 mouseDownEvent.setPositionInWidget(10, 10);
1142 mouseDownEvent.y = 10; 1142 mouseDownEvent.setPositionInScreen(110, 210);
1143 mouseDownEvent.globalX = 110;
1144 mouseDownEvent.globalY = 210;
1145 mouseDownEvent.clickCount = 1; 1143 mouseDownEvent.clickCount = 1;
1146 mouseDownEvent.button = WebMouseEvent::Button::Right; 1144 mouseDownEvent.button = WebMouseEvent::Button::Right;
1147 1145
1148 // Corresponding release event (Windows shows context menu on release). 1146 // Corresponding release event (Windows shows context menu on release).
1149 WebMouseEvent mouseUpEvent(mouseDownEvent); 1147 WebMouseEvent mouseUpEvent(mouseDownEvent);
1150 mouseUpEvent.setType(WebInputEvent::MouseUp); 1148 mouseUpEvent.setType(WebInputEvent::MouseUp);
1151 1149
1152 WebFrameClient* oldClient = webViewImpl()->mainFrameImpl()->client(); 1150 WebFrameClient* oldClient = webViewImpl()->mainFrameImpl()->client();
1153 MockWebFrameClient mockWebFrameClient; 1151 MockWebFrameClient mockWebFrameClient;
1154 EXPECT_CALL(mockWebFrameClient, showContextMenu(ContextMenuAtLocation( 1152 EXPECT_CALL(mockWebFrameClient, showContextMenu(ContextMenuAtLocation(
1155 mouseDownEvent.x, mouseDownEvent.y))); 1153 mouseDownEvent.positionInWidget().x,
1154 mouseDownEvent.positionInWidget().y)));
1156 1155
1157 // Do a sanity check with no scale applied. 1156 // Do a sanity check with no scale applied.
1158 webViewImpl()->mainFrameImpl()->setClient(&mockWebFrameClient); 1157 webViewImpl()->mainFrameImpl()->setClient(&mockWebFrameClient);
1159 webViewImpl()->handleInputEvent(WebCoalescedInputEvent(mouseDownEvent)); 1158 webViewImpl()->handleInputEvent(WebCoalescedInputEvent(mouseDownEvent));
1160 webViewImpl()->handleInputEvent(WebCoalescedInputEvent(mouseUpEvent)); 1159 webViewImpl()->handleInputEvent(WebCoalescedInputEvent(mouseUpEvent));
1161 1160
1162 Mock::VerifyAndClearExpectations(&mockWebFrameClient); 1161 Mock::VerifyAndClearExpectations(&mockWebFrameClient);
1163 mouseDownEvent.button = WebMouseEvent::Button::Left; 1162 mouseDownEvent.button = WebMouseEvent::Button::Left;
1164 webViewImpl()->handleInputEvent(WebCoalescedInputEvent(mouseDownEvent)); 1163 webViewImpl()->handleInputEvent(WebCoalescedInputEvent(mouseDownEvent));
1165 1164
1166 // Now pinch zoom into the page and move the visual viewport. The context menu 1165 // Now pinch zoom into the page and move the visual viewport. The context menu
1167 // should still appear at the location of the event, relative to the WebView. 1166 // should still appear at the location of the event, relative to the WebView.
1168 VisualViewport& visualViewport = frame()->page()->visualViewport(); 1167 VisualViewport& visualViewport = frame()->page()->visualViewport();
1169 webViewImpl()->setPageScaleFactor(2); 1168 webViewImpl()->setPageScaleFactor(2);
1170 EXPECT_CALL(mockWebFrameClient, didChangeScrollOffset(_)); 1169 EXPECT_CALL(mockWebFrameClient, didChangeScrollOffset(_));
1171 visualViewport.setLocation(FloatPoint(60, 80)); 1170 visualViewport.setLocation(FloatPoint(60, 80));
1172 EXPECT_CALL(mockWebFrameClient, showContextMenu(ContextMenuAtLocation( 1171 EXPECT_CALL(mockWebFrameClient, showContextMenu(ContextMenuAtLocation(
1173 mouseDownEvent.x, mouseDownEvent.y))); 1172 mouseDownEvent.positionInWidget().x,
1173 mouseDownEvent.positionInWidget().y)));
1174 1174
1175 mouseDownEvent.button = WebMouseEvent::Button::Right; 1175 mouseDownEvent.button = WebMouseEvent::Button::Right;
1176 webViewImpl()->handleInputEvent(WebCoalescedInputEvent(mouseDownEvent)); 1176 webViewImpl()->handleInputEvent(WebCoalescedInputEvent(mouseDownEvent));
1177 webViewImpl()->handleInputEvent(WebCoalescedInputEvent(mouseUpEvent)); 1177 webViewImpl()->handleInputEvent(WebCoalescedInputEvent(mouseUpEvent));
1178 1178
1179 // Reset the old client so destruction can occur naturally. 1179 // Reset the old client so destruction can occur naturally.
1180 webViewImpl()->mainFrameImpl()->setClient(oldClient); 1180 webViewImpl()->mainFrameImpl()->setClient(oldClient);
1181 } 1181 }
1182 1182
1183 // Test that the client is notified if page scroll events. 1183 // Test that the client is notified if page scroll events.
(...skipping 1258 matching lines...) Expand 10 before | Expand all | Expand 10 after
2442 " body {" 2442 " body {"
2443 " margin: 0px;" 2443 " margin: 0px;"
2444 " }" 2444 " }"
2445 " div { height:110vh; width: 110vw; }" 2445 " div { height:110vh; width: 110vw; }"
2446 "</style>" 2446 "</style>"
2447 "<div></div>", 2447 "<div></div>",
2448 baseURL); 2448 baseURL);
2449 } 2449 }
2450 2450
2451 } // namespace 2451 } // namespace
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/tests/FrameTestHelpers.cpp ('k') | third_party/WebKit/Source/web/tests/WebFrameTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698