| OLD | NEW |
| 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 1108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1119 TEST_P(VisualViewportTest, TestContextMenuShownInCorrectLocation) { | 1119 TEST_P(VisualViewportTest, TestContextMenuShownInCorrectLocation) { |
| 1120 initializeWithDesktopSettings(); | 1120 initializeWithDesktopSettings(); |
| 1121 webViewImpl()->resize(IntSize(200, 300)); | 1121 webViewImpl()->resize(IntSize(200, 300)); |
| 1122 | 1122 |
| 1123 registerMockedHttpURLLoad("200-by-300.html"); | 1123 registerMockedHttpURLLoad("200-by-300.html"); |
| 1124 navigateTo(m_baseURL + "200-by-300.html"); | 1124 navigateTo(m_baseURL + "200-by-300.html"); |
| 1125 | 1125 |
| 1126 WebMouseEvent mouseDownEvent(WebInputEvent::MouseDown, | 1126 WebMouseEvent mouseDownEvent(WebInputEvent::MouseDown, |
| 1127 WebInputEvent::NoModifiers, | 1127 WebInputEvent::NoModifiers, |
| 1128 WebInputEvent::TimeStampForTesting); | 1128 WebInputEvent::TimeStampForTesting); |
| 1129 mouseDownEvent.x = 10; | 1129 mouseDownEvent.position.x = 10; |
| 1130 mouseDownEvent.y = 10; | 1130 mouseDownEvent.position.y = 10; |
| 1131 mouseDownEvent.globalX = 110; | 1131 mouseDownEvent.screenPosition.x = 110; |
| 1132 mouseDownEvent.globalY = 210; | 1132 mouseDownEvent.screenPosition.y = 210; |
| 1133 mouseDownEvent.clickCount = 1; | 1133 mouseDownEvent.clickCount = 1; |
| 1134 mouseDownEvent.button = WebMouseEvent::Button::Right; | 1134 mouseDownEvent.button = WebMouseEvent::Button::Right; |
| 1135 | 1135 |
| 1136 // Corresponding release event (Windows shows context menu on release). | 1136 // Corresponding release event (Windows shows context menu on release). |
| 1137 WebMouseEvent mouseUpEvent(mouseDownEvent); | 1137 WebMouseEvent mouseUpEvent(mouseDownEvent); |
| 1138 mouseUpEvent.setType(WebInputEvent::MouseUp); | 1138 mouseUpEvent.setType(WebInputEvent::MouseUp); |
| 1139 | 1139 |
| 1140 WebFrameClient* oldClient = webViewImpl()->mainFrameImpl()->client(); | 1140 WebFrameClient* oldClient = webViewImpl()->mainFrameImpl()->client(); |
| 1141 MockWebFrameClient mockWebFrameClient; | 1141 MockWebFrameClient mockWebFrameClient; |
| 1142 EXPECT_CALL(mockWebFrameClient, showContextMenu(ContextMenuAtLocation( | 1142 EXPECT_CALL(mockWebFrameClient, |
| 1143 mouseDownEvent.x, mouseDownEvent.y))); | 1143 showContextMenu(ContextMenuAtLocation( |
| 1144 mouseDownEvent.position.x, mouseDownEvent.position.y))); |
| 1144 | 1145 |
| 1145 // Do a sanity check with no scale applied. | 1146 // Do a sanity check with no scale applied. |
| 1146 webViewImpl()->mainFrameImpl()->setClient(&mockWebFrameClient); | 1147 webViewImpl()->mainFrameImpl()->setClient(&mockWebFrameClient); |
| 1147 webViewImpl()->handleInputEvent(WebCoalescedInputEvent(mouseDownEvent)); | 1148 webViewImpl()->handleInputEvent(WebCoalescedInputEvent(mouseDownEvent)); |
| 1148 webViewImpl()->handleInputEvent(WebCoalescedInputEvent(mouseUpEvent)); | 1149 webViewImpl()->handleInputEvent(WebCoalescedInputEvent(mouseUpEvent)); |
| 1149 | 1150 |
| 1150 Mock::VerifyAndClearExpectations(&mockWebFrameClient); | 1151 Mock::VerifyAndClearExpectations(&mockWebFrameClient); |
| 1151 mouseDownEvent.button = WebMouseEvent::Button::Left; | 1152 mouseDownEvent.button = WebMouseEvent::Button::Left; |
| 1152 webViewImpl()->handleInputEvent(WebCoalescedInputEvent(mouseDownEvent)); | 1153 webViewImpl()->handleInputEvent(WebCoalescedInputEvent(mouseDownEvent)); |
| 1153 | 1154 |
| 1154 // Now pinch zoom into the page and move the visual viewport. The context menu | 1155 // Now pinch zoom into the page and move the visual viewport. The context menu |
| 1155 // should still appear at the location of the event, relative to the WebView. | 1156 // should still appear at the location of the event, relative to the WebView. |
| 1156 VisualViewport& visualViewport = frame()->page()->visualViewport(); | 1157 VisualViewport& visualViewport = frame()->page()->visualViewport(); |
| 1157 webViewImpl()->setPageScaleFactor(2); | 1158 webViewImpl()->setPageScaleFactor(2); |
| 1158 EXPECT_CALL(mockWebFrameClient, didChangeScrollOffset(_)); | 1159 EXPECT_CALL(mockWebFrameClient, didChangeScrollOffset(_)); |
| 1159 visualViewport.setLocation(FloatPoint(60, 80)); | 1160 visualViewport.setLocation(FloatPoint(60, 80)); |
| 1160 EXPECT_CALL(mockWebFrameClient, showContextMenu(ContextMenuAtLocation( | 1161 EXPECT_CALL(mockWebFrameClient, |
| 1161 mouseDownEvent.x, mouseDownEvent.y))); | 1162 showContextMenu(ContextMenuAtLocation( |
| 1163 mouseDownEvent.position.x, mouseDownEvent.position.y))); |
| 1162 | 1164 |
| 1163 mouseDownEvent.button = WebMouseEvent::Button::Right; | 1165 mouseDownEvent.button = WebMouseEvent::Button::Right; |
| 1164 webViewImpl()->handleInputEvent(WebCoalescedInputEvent(mouseDownEvent)); | 1166 webViewImpl()->handleInputEvent(WebCoalescedInputEvent(mouseDownEvent)); |
| 1165 webViewImpl()->handleInputEvent(WebCoalescedInputEvent(mouseUpEvent)); | 1167 webViewImpl()->handleInputEvent(WebCoalescedInputEvent(mouseUpEvent)); |
| 1166 | 1168 |
| 1167 // Reset the old client so destruction can occur naturally. | 1169 // Reset the old client so destruction can occur naturally. |
| 1168 webViewImpl()->mainFrameImpl()->setClient(oldClient); | 1170 webViewImpl()->mainFrameImpl()->setClient(oldClient); |
| 1169 } | 1171 } |
| 1170 | 1172 |
| 1171 // Test that the client is notified if page scroll events. | 1173 // Test that the client is notified if page scroll events. |
| (...skipping 1258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2430 " body {" | 2432 " body {" |
| 2431 " margin: 0px;" | 2433 " margin: 0px;" |
| 2432 " }" | 2434 " }" |
| 2433 " div { height:110vh; width: 110vw; }" | 2435 " div { height:110vh; width: 110vw; }" |
| 2434 "</style>" | 2436 "</style>" |
| 2435 "<div></div>", | 2437 "<div></div>", |
| 2436 baseURL); | 2438 baseURL); |
| 2437 } | 2439 } |
| 2438 | 2440 |
| 2439 } // namespace | 2441 } // namespace |
| OLD | NEW |