| 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/FrameHost.h" | 9 #include "core/frame/FrameHost.h" |
| 10 #include "core/frame/FrameView.h" | 10 #include "core/frame/FrameView.h" |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 | 101 |
| 102 namespace blink { | 102 namespace blink { |
| 103 ::std::ostream& operator<<(::std::ostream& os, const WebContextMenuData& data) { | 103 ::std::ostream& operator<<(::std::ostream& os, const WebContextMenuData& data) { |
| 104 return os << "Context menu location: [" << data.mousePosition.x << ", " | 104 return os << "Context menu location: [" << data.mousePosition.x << ", " |
| 105 << data.mousePosition.y << "]"; | 105 << data.mousePosition.y << "]"; |
| 106 } | 106 } |
| 107 } | 107 } |
| 108 | 108 |
| 109 namespace { | 109 namespace { |
| 110 | 110 |
| 111 typedef bool TestParamRootLayerScrolling; | 111 class VisualViewportTest : public testing::Test { |
| 112 class VisualViewportTest | |
| 113 : public testing::Test, | |
| 114 public testing::WithParamInterface<TestParamRootLayerScrolling>, | |
| 115 private ScopedRootLayerScrollingForTest { | |
| 116 public: | 112 public: |
| 117 VisualViewportTest() | 113 VisualViewportTest() : m_baseURL("http://www.test.com/") {} |
| 118 : ScopedRootLayerScrollingForTest(GetParam()), | |
| 119 m_baseURL("http://www.test.com/") {} | |
| 120 | 114 |
| 121 void initializeWithDesktopSettings( | 115 void initializeWithDesktopSettings( |
| 122 void (*overrideSettingsFunc)(WebSettings*) = 0) { | 116 void (*overrideSettingsFunc)(WebSettings*) = 0) { |
| 123 if (!overrideSettingsFunc) | 117 if (!overrideSettingsFunc) |
| 124 overrideSettingsFunc = &configureSettings; | 118 overrideSettingsFunc = &configureSettings; |
| 125 m_helper.initialize(true, nullptr, &m_mockWebViewClient, nullptr, | 119 m_helper.initialize(true, nullptr, &m_mockWebViewClient, nullptr, |
| 126 overrideSettingsFunc); | 120 overrideSettingsFunc); |
| 127 webViewImpl()->setDefaultPageScaleLimits(1, 4); | 121 webViewImpl()->setDefaultPageScaleLimits(1, 4); |
| 128 } | 122 } |
| 129 | 123 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 } | 178 } |
| 185 | 179 |
| 186 protected: | 180 protected: |
| 187 std::string m_baseURL; | 181 std::string m_baseURL; |
| 188 FrameTestHelpers::TestWebViewClient m_mockWebViewClient; | 182 FrameTestHelpers::TestWebViewClient m_mockWebViewClient; |
| 189 | 183 |
| 190 private: | 184 private: |
| 191 FrameTestHelpers::WebViewHelper m_helper; | 185 FrameTestHelpers::WebViewHelper m_helper; |
| 192 }; | 186 }; |
| 193 | 187 |
| 194 INSTANTIATE_TEST_CASE_P(All, VisualViewportTest, ::testing::Bool()); | 188 typedef bool TestParamRootLayerScrolling; |
| 189 class ParameterizedVisualViewportTest |
| 190 : public testing::WithParamInterface<TestParamRootLayerScrolling>, |
| 191 private ScopedRootLayerScrollingForTest, |
| 192 public VisualViewportTest { |
| 193 public: |
| 194 ParameterizedVisualViewportTest() |
| 195 : ScopedRootLayerScrollingForTest(GetParam()) {} |
| 196 }; |
| 197 |
| 198 INSTANTIATE_TEST_CASE_P(All, |
| 199 ParameterizedVisualViewportTest, |
| 200 ::testing::Bool()); |
| 195 | 201 |
| 196 // Test that resizing the VisualViewport works as expected and that resizing the | 202 // Test that resizing the VisualViewport works as expected and that resizing the |
| 197 // WebView resizes the VisualViewport. | 203 // WebView resizes the VisualViewport. |
| 198 TEST_P(VisualViewportTest, TestResize) { | 204 TEST_P(ParameterizedVisualViewportTest, TestResize) { |
| 199 initializeWithDesktopSettings(); | 205 initializeWithDesktopSettings(); |
| 200 webViewImpl()->resize(IntSize(320, 240)); | 206 webViewImpl()->resize(IntSize(320, 240)); |
| 201 | 207 |
| 202 navigateTo("about:blank"); | 208 navigateTo("about:blank"); |
| 203 forceFullCompositingUpdate(); | 209 forceFullCompositingUpdate(); |
| 204 | 210 |
| 205 VisualViewport& visualViewport = | 211 VisualViewport& visualViewport = |
| 206 frame()->page()->frameHost().visualViewport(); | 212 frame()->page()->frameHost().visualViewport(); |
| 207 | 213 |
| 208 IntSize webViewSize = webViewImpl()->size(); | 214 IntSize webViewSize = webViewImpl()->size(); |
| 209 | 215 |
| 210 // Make sure the visual viewport was initialized. | 216 // Make sure the visual viewport was initialized. |
| 211 EXPECT_SIZE_EQ(webViewSize, visualViewport.size()); | 217 EXPECT_SIZE_EQ(webViewSize, visualViewport.size()); |
| 212 | 218 |
| 213 // Resizing the WebView should change the VisualViewport. | 219 // Resizing the WebView should change the VisualViewport. |
| 214 webViewSize = IntSize(640, 480); | 220 webViewSize = IntSize(640, 480); |
| 215 webViewImpl()->resize(webViewSize); | 221 webViewImpl()->resize(webViewSize); |
| 216 EXPECT_SIZE_EQ(webViewSize, IntSize(webViewImpl()->size())); | 222 EXPECT_SIZE_EQ(webViewSize, IntSize(webViewImpl()->size())); |
| 217 EXPECT_SIZE_EQ(webViewSize, visualViewport.size()); | 223 EXPECT_SIZE_EQ(webViewSize, visualViewport.size()); |
| 218 | 224 |
| 219 // Resizing the visual viewport shouldn't affect the WebView. | 225 // Resizing the visual viewport shouldn't affect the WebView. |
| 220 IntSize newViewportSize = IntSize(320, 200); | 226 IntSize newViewportSize = IntSize(320, 200); |
| 221 visualViewport.setSize(newViewportSize); | 227 visualViewport.setSize(newViewportSize); |
| 222 EXPECT_SIZE_EQ(webViewSize, IntSize(webViewImpl()->size())); | 228 EXPECT_SIZE_EQ(webViewSize, IntSize(webViewImpl()->size())); |
| 223 EXPECT_SIZE_EQ(newViewportSize, visualViewport.size()); | 229 EXPECT_SIZE_EQ(newViewportSize, visualViewport.size()); |
| 224 } | 230 } |
| 225 | 231 |
| 226 // Make sure that the visibleContentRect method acurately reflects the scale and | 232 // Make sure that the visibleContentRect method acurately reflects the scale and |
| 227 // scroll location of the viewport with and without scrollbars. | 233 // scroll location of the viewport with and without scrollbars. |
| 228 TEST_P(VisualViewportTest, TestVisibleContentRect) { | 234 TEST_P(ParameterizedVisualViewportTest, TestVisibleContentRect) { |
| 229 RuntimeEnabledFeatures::setOverlayScrollbarsEnabled(false); | 235 RuntimeEnabledFeatures::setOverlayScrollbarsEnabled(false); |
| 230 initializeWithDesktopSettings(); | 236 initializeWithDesktopSettings(); |
| 231 | 237 |
| 232 registerMockedHttpURLLoad("200-by-300.html"); | 238 registerMockedHttpURLLoad("200-by-300.html"); |
| 233 navigateTo(m_baseURL + "200-by-300.html"); | 239 navigateTo(m_baseURL + "200-by-300.html"); |
| 234 | 240 |
| 235 IntSize size = IntSize(150, 100); | 241 IntSize size = IntSize(150, 100); |
| 236 // Vertical scrollbar width and horizontal scrollbar height. | 242 // Vertical scrollbar width and horizontal scrollbar height. |
| 237 IntSize scrollbarSize = IntSize(15, 15); | 243 IntSize scrollbarSize = IntSize(15, 15); |
| 238 | 244 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 258 visualViewport.visibleContentRect(ExcludeScrollbars)); | 264 visualViewport.visibleContentRect(ExcludeScrollbars)); |
| 259 EXPECT_EQ(IntRect(IntPoint(10, 10), size), | 265 EXPECT_EQ(IntRect(IntPoint(10, 10), size), |
| 260 visualViewport.visibleContentRect(IncludeScrollbars)); | 266 visualViewport.visibleContentRect(IncludeScrollbars)); |
| 261 } | 267 } |
| 262 | 268 |
| 263 // This tests that shrinking the WebView while the page is fully scrolled | 269 // This tests that shrinking the WebView while the page is fully scrolled |
| 264 // doesn't move the viewport up/left, it should keep the visible viewport | 270 // doesn't move the viewport up/left, it should keep the visible viewport |
| 265 // unchanged from the user's perspective (shrinking the FrameView will clamp | 271 // unchanged from the user's perspective (shrinking the FrameView will clamp |
| 266 // the VisualViewport so we need to counter scroll the FrameView to make it | 272 // the VisualViewport so we need to counter scroll the FrameView to make it |
| 267 // appear to stay still). This caused bugs like crbug.com/453859. | 273 // appear to stay still). This caused bugs like crbug.com/453859. |
| 268 TEST_P(VisualViewportTest, TestResizeAtFullyScrolledPreservesViewportLocation) { | 274 TEST_P(ParameterizedVisualViewportTest, |
| 275 TestResizeAtFullyScrolledPreservesViewportLocation) { |
| 269 initializeWithDesktopSettings(); | 276 initializeWithDesktopSettings(); |
| 270 webViewImpl()->resize(IntSize(800, 600)); | 277 webViewImpl()->resize(IntSize(800, 600)); |
| 271 | 278 |
| 272 registerMockedHttpURLLoad("content-width-1000.html"); | 279 registerMockedHttpURLLoad("content-width-1000.html"); |
| 273 navigateTo(m_baseURL + "content-width-1000.html"); | 280 navigateTo(m_baseURL + "content-width-1000.html"); |
| 274 | 281 |
| 275 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView(); | 282 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView(); |
| 276 VisualViewport& visualViewport = | 283 VisualViewport& visualViewport = |
| 277 frame()->page()->frameHost().visualViewport(); | 284 frame()->page()->frameHost().visualViewport(); |
| 278 | 285 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 300 expectedLocation, | 307 expectedLocation, |
| 301 frameView.getScrollableArea()->visibleContentRect().location()); | 308 frameView.getScrollableArea()->visibleContentRect().location()); |
| 302 | 309 |
| 303 webViewImpl()->resize(IntSize(800, 600)); | 310 webViewImpl()->resize(IntSize(800, 600)); |
| 304 | 311 |
| 305 EXPECT_POINT_EQ( | 312 EXPECT_POINT_EQ( |
| 306 expectedLocation, | 313 expectedLocation, |
| 307 frameView.getScrollableArea()->visibleContentRect().location()); | 314 frameView.getScrollableArea()->visibleContentRect().location()); |
| 308 } | 315 } |
| 309 | 316 |
| 317 // Test the main frame scrollbars take visual viewport into account. |
| 318 TEST_F(VisualViewportTest, VerifyScrollbarBehavior) { |
| 319 initializeWithDesktopSettings(); |
| 320 |
| 321 registerMockedHttpURLLoad("200-by-800-viewport.html"); |
| 322 navigateTo(m_baseURL + "200-by-800-viewport.html"); |
| 323 |
| 324 webViewImpl()->resize(IntSize(300, 200)); |
| 325 |
| 326 ScrollableArea* scroller = frame()->view()->getScrollableArea(); |
| 327 |
| 328 // Initially, there is no horizontal scrollbar since the content fits. |
| 329 EXPECT_FALSE(scroller->horizontalScrollbar()); |
| 330 EXPECT_TRUE(scroller->verticalScrollbar()); |
| 331 |
| 332 // Scroll layout viewport. |
| 333 webViewImpl()->mainFrame()->setScrollOffset(WebSize(0, 200)); |
| 334 EXPECT_SIZE_EQ(ScrollOffset(0, 200), scroller->scrollOffset()); |
| 335 |
| 336 webViewImpl()->setPageScaleFactor(2.0); |
| 337 |
| 338 // Pinch-zooming should add horizontal scrollbar. |
| 339 EXPECT_TRUE(scroller->horizontalScrollbar()); |
| 340 EXPECT_TRUE(scroller->verticalScrollbar()); |
| 341 |
| 342 // Scroll visual viewport. |
| 343 VisualViewport& visualViewport = |
| 344 frame()->page()->frameHost().visualViewport(); |
| 345 visualViewport.setLocation(FloatPoint(100, 100)); |
| 346 EXPECT_FLOAT_SIZE_EQ(FloatSize(100, 100), visualViewport.scrollOffset()); |
| 347 |
| 348 // Scrollbar offset should take visual viewport into account. |
| 349 EXPECT_FLOAT_EQ(100, scroller->horizontalScrollbar()->currentPos()); |
| 350 EXPECT_FLOAT_EQ(300, scroller->verticalScrollbar()->currentPos()); |
| 351 } |
| 352 |
| 310 // Test that the VisualViewport works as expected in case of a scaled | 353 // Test that the VisualViewport works as expected in case of a scaled |
| 311 // and scrolled viewport - scroll down. | 354 // and scrolled viewport - scroll down. |
| 312 TEST_P(VisualViewportTest, TestResizeAfterVerticalScroll) { | 355 TEST_P(ParameterizedVisualViewportTest, TestResizeAfterVerticalScroll) { |
| 313 /* | 356 /* |
| 314 200 200 | 357 200 200 |
| 315 | | | | | 358 | | | | |
| 316 | | | | | 359 | | | | |
| 317 | | 800 | | 800 | 360 | | 800 | | 800 |
| 318 |-------------------| | | | 361 |-------------------| | | |
| 319 | | | | | 362 | | | | |
| 320 | | | | | 363 | | | | |
| 321 | | | | | 364 | | | | |
| 322 | | --------> | | | 365 | | --------> | | |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 372 EXPECT_FLOAT_SIZE_EQ(FloatSize(50, 25), visualViewport.visibleRect().size()); | 415 EXPECT_FLOAT_SIZE_EQ(FloatSize(50, 25), visualViewport.visibleRect().size()); |
| 373 | 416 |
| 374 EXPECT_SIZE_EQ( | 417 EXPECT_SIZE_EQ( |
| 375 ScrollOffset(0, 625), | 418 ScrollOffset(0, 625), |
| 376 frame()->view()->layoutViewportScrollableArea()->scrollOffset()); | 419 frame()->view()->layoutViewportScrollableArea()->scrollOffset()); |
| 377 EXPECT_FLOAT_SIZE_EQ(FloatSize(0, 75), visualViewport.scrollOffset()); | 420 EXPECT_FLOAT_SIZE_EQ(FloatSize(0, 75), visualViewport.scrollOffset()); |
| 378 } | 421 } |
| 379 | 422 |
| 380 // Test that the VisualViewport works as expected in case if a scaled | 423 // Test that the VisualViewport works as expected in case if a scaled |
| 381 // and scrolled viewport - scroll right. | 424 // and scrolled viewport - scroll right. |
| 382 TEST_P(VisualViewportTest, TestResizeAfterHorizontalScroll) { | 425 TEST_P(ParameterizedVisualViewportTest, TestResizeAfterHorizontalScroll) { |
| 383 /* | 426 /* |
| 384 200 200 | 427 200 200 |
| 385 ---------------o----- ---------------o----- | 428 ---------------o----- ---------------o----- |
| 386 | | | | 25| | | 429 | | | | 25| | |
| 387 | | | | -----| | 430 | | | | -----| |
| 388 | 100| | |100 50 | | 431 | 100| | |100 50 | |
| 389 | | | | | | 432 | | | | | |
| 390 | ---- | |-------------------| | 433 | ---- | |-------------------| |
| 391 | | | | | 434 | | | | |
| 392 | | | | | 435 | | | | |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 437 | 480 |
| 438 // After resizing the scale changes 2.0 -> 4.0 | 481 // After resizing the scale changes 2.0 -> 4.0 |
| 439 EXPECT_FLOAT_SIZE_EQ(FloatSize(50, 25), visualViewport.visibleRect().size()); | 482 EXPECT_FLOAT_SIZE_EQ(FloatSize(50, 25), visualViewport.visibleRect().size()); |
| 440 | 483 |
| 441 EXPECT_SIZE_EQ(ScrollOffset(0, 0), frame()->view()->scrollOffset()); | 484 EXPECT_SIZE_EQ(ScrollOffset(0, 0), frame()->view()->scrollOffset()); |
| 442 EXPECT_FLOAT_SIZE_EQ(FloatSize(150, 0), visualViewport.scrollOffset()); | 485 EXPECT_FLOAT_SIZE_EQ(FloatSize(150, 0), visualViewport.scrollOffset()); |
| 443 } | 486 } |
| 444 | 487 |
| 445 // Test that the container layer gets sized properly if the WebView is resized | 488 // Test that the container layer gets sized properly if the WebView is resized |
| 446 // prior to the VisualViewport being attached to the layer tree. | 489 // prior to the VisualViewport being attached to the layer tree. |
| 447 TEST_P(VisualViewportTest, TestWebViewResizedBeforeAttachment) { | 490 TEST_P(ParameterizedVisualViewportTest, TestWebViewResizedBeforeAttachment) { |
| 448 initializeWithDesktopSettings(); | 491 initializeWithDesktopSettings(); |
| 449 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView(); | 492 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView(); |
| 450 GraphicsLayer* rootGraphicsLayer = | 493 GraphicsLayer* rootGraphicsLayer = |
| 451 frameView.layoutViewItem().compositor()->rootGraphicsLayer(); | 494 frameView.layoutViewItem().compositor()->rootGraphicsLayer(); |
| 452 | 495 |
| 453 // Make sure that a resize that comes in while there's no root layer is | 496 // Make sure that a resize that comes in while there's no root layer is |
| 454 // honoured when we attach to the layer tree. | 497 // honoured when we attach to the layer tree. |
| 455 WebFrameWidgetBase* mainFrameWidget = | 498 WebFrameWidgetBase* mainFrameWidget = |
| 456 webViewImpl()->mainFrameImpl()->frameWidget(); | 499 webViewImpl()->mainFrameImpl()->frameWidget(); |
| 457 mainFrameWidget->setRootGraphicsLayer(nullptr); | 500 mainFrameWidget->setRootGraphicsLayer(nullptr); |
| 458 webViewImpl()->resize(IntSize(320, 240)); | 501 webViewImpl()->resize(IntSize(320, 240)); |
| 459 mainFrameWidget->setRootGraphicsLayer(rootGraphicsLayer); | 502 mainFrameWidget->setRootGraphicsLayer(rootGraphicsLayer); |
| 460 | 503 |
| 461 navigateTo("about:blank"); | 504 navigateTo("about:blank"); |
| 462 webViewImpl()->updateAllLifecyclePhases(); | 505 webViewImpl()->updateAllLifecyclePhases(); |
| 463 | 506 |
| 464 VisualViewport& visualViewport = | 507 VisualViewport& visualViewport = |
| 465 frame()->page()->frameHost().visualViewport(); | 508 frame()->page()->frameHost().visualViewport(); |
| 466 EXPECT_FLOAT_SIZE_EQ(FloatSize(320, 240), | 509 EXPECT_FLOAT_SIZE_EQ(FloatSize(320, 240), |
| 467 visualViewport.containerLayer()->size()); | 510 visualViewport.containerLayer()->size()); |
| 468 } | 511 } |
| 469 | 512 |
| 470 // Make sure that the visibleRect method acurately reflects the scale and scroll | 513 // Make sure that the visibleRect method acurately reflects the scale and scroll |
| 471 // location of the viewport. | 514 // location of the viewport. |
| 472 TEST_P(VisualViewportTest, TestVisibleRect) { | 515 TEST_P(ParameterizedVisualViewportTest, TestVisibleRect) { |
| 473 initializeWithDesktopSettings(); | 516 initializeWithDesktopSettings(); |
| 474 webViewImpl()->resize(IntSize(320, 240)); | 517 webViewImpl()->resize(IntSize(320, 240)); |
| 475 | 518 |
| 476 navigateTo("about:blank"); | 519 navigateTo("about:blank"); |
| 477 forceFullCompositingUpdate(); | 520 forceFullCompositingUpdate(); |
| 478 | 521 |
| 479 VisualViewport& visualViewport = | 522 VisualViewport& visualViewport = |
| 480 frame()->page()->frameHost().visualViewport(); | 523 frame()->page()->frameHost().visualViewport(); |
| 481 | 524 |
| 482 // Initial visible rect should be the whole frame. | 525 // Initial visible rect should be the whole frame. |
| (...skipping 30 matching lines...) Expand all Loading... |
| 513 visualViewport.setScale(3); | 556 visualViewport.setScale(3); |
| 514 EXPECT_FLOAT_RECT_EQ(expectedRect, visualViewport.visibleRect()); | 557 EXPECT_FLOAT_RECT_EQ(expectedRect, visualViewport.visibleRect()); |
| 515 | 558 |
| 516 expectedRect.setLocation(FloatPoint(0.25f, 0.333f)); | 559 expectedRect.setLocation(FloatPoint(0.25f, 0.333f)); |
| 517 visualViewport.setLocation(expectedRect.location()); | 560 visualViewport.setLocation(expectedRect.location()); |
| 518 EXPECT_FLOAT_RECT_EQ(expectedRect, visualViewport.visibleRect()); | 561 EXPECT_FLOAT_RECT_EQ(expectedRect, visualViewport.visibleRect()); |
| 519 } | 562 } |
| 520 | 563 |
| 521 // Make sure that the visibleRectInDocument method acurately reflects the scale | 564 // Make sure that the visibleRectInDocument method acurately reflects the scale |
| 522 // and scroll location of the viewport relative to the document. | 565 // and scroll location of the viewport relative to the document. |
| 523 TEST_P(VisualViewportTest, TestVisibleRectInDocument) { | 566 TEST_P(ParameterizedVisualViewportTest, TestVisibleRectInDocument) { |
| 524 initializeWithDesktopSettings(); | 567 initializeWithDesktopSettings(); |
| 525 webViewImpl()->resize(IntSize(100, 400)); | 568 webViewImpl()->resize(IntSize(100, 400)); |
| 526 | 569 |
| 527 registerMockedHttpURLLoad("200-by-800-viewport.html"); | 570 registerMockedHttpURLLoad("200-by-800-viewport.html"); |
| 528 navigateTo(m_baseURL + "200-by-800-viewport.html"); | 571 navigateTo(m_baseURL + "200-by-800-viewport.html"); |
| 529 | 572 |
| 530 VisualViewport& visualViewport = | 573 VisualViewport& visualViewport = |
| 531 frame()->page()->frameHost().visualViewport(); | 574 frame()->page()->frameHost().visualViewport(); |
| 532 | 575 |
| 533 // Scale the viewport to 2X and move it. | 576 // Scale the viewport to 2X and move it. |
| 534 visualViewport.setScale(2); | 577 visualViewport.setScale(2); |
| 535 visualViewport.setLocation(FloatPoint(10, 15)); | 578 visualViewport.setLocation(FloatPoint(10, 15)); |
| 536 EXPECT_FLOAT_RECT_EQ(FloatRect(10, 15, 50, 200), | 579 EXPECT_FLOAT_RECT_EQ(FloatRect(10, 15, 50, 200), |
| 537 visualViewport.visibleRectInDocument()); | 580 visualViewport.visibleRectInDocument()); |
| 538 | 581 |
| 539 // Scroll the layout viewport. Ensure its offset is reflected in | 582 // Scroll the layout viewport. Ensure its offset is reflected in |
| 540 // visibleRectInDocument(). | 583 // visibleRectInDocument(). |
| 541 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView(); | 584 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView(); |
| 542 frameView.layoutViewportScrollableArea()->setScrollOffset( | 585 frameView.layoutViewportScrollableArea()->setScrollOffset( |
| 543 ScrollOffset(40, 100), ProgrammaticScroll); | 586 ScrollOffset(40, 100), ProgrammaticScroll); |
| 544 EXPECT_FLOAT_RECT_EQ(FloatRect(50, 115, 50, 200), | 587 EXPECT_FLOAT_RECT_EQ(FloatRect(50, 115, 50, 200), |
| 545 visualViewport.visibleRectInDocument()); | 588 visualViewport.visibleRectInDocument()); |
| 546 } | 589 } |
| 547 | 590 |
| 548 TEST_P(VisualViewportTest, TestFractionalScrollOffsetIsNotOverwritten) { | 591 TEST_P(ParameterizedVisualViewportTest, |
| 592 TestFractionalScrollOffsetIsNotOverwritten) { |
| 549 bool origFractionalOffsetsEnabled = | 593 bool origFractionalOffsetsEnabled = |
| 550 RuntimeEnabledFeatures::fractionalScrollOffsetsEnabled(); | 594 RuntimeEnabledFeatures::fractionalScrollOffsetsEnabled(); |
| 551 RuntimeEnabledFeatures::setFractionalScrollOffsetsEnabled(true); | 595 RuntimeEnabledFeatures::setFractionalScrollOffsetsEnabled(true); |
| 552 | 596 |
| 553 initializeWithAndroidSettings(); | 597 initializeWithAndroidSettings(); |
| 554 webViewImpl()->resize(IntSize(200, 250)); | 598 webViewImpl()->resize(IntSize(200, 250)); |
| 555 | 599 |
| 556 registerMockedHttpURLLoad("200-by-800-viewport.html"); | 600 registerMockedHttpURLLoad("200-by-800-viewport.html"); |
| 557 navigateTo(m_baseURL + "200-by-800-viewport.html"); | 601 navigateTo(m_baseURL + "200-by-800-viewport.html"); |
| 558 | 602 |
| 559 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView(); | 603 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView(); |
| 560 frameView.layoutViewportScrollableArea()->setScrollOffset( | 604 frameView.layoutViewportScrollableArea()->setScrollOffset( |
| 561 ScrollOffset(0, 10.5), ProgrammaticScroll); | 605 ScrollOffset(0, 10.5), ProgrammaticScroll); |
| 562 frameView.layoutViewportScrollableArea()->ScrollableArea::setScrollOffset( | 606 frameView.layoutViewportScrollableArea()->ScrollableArea::setScrollOffset( |
| 563 ScrollOffset(10, 30.5), CompositorScroll); | 607 ScrollOffset(10, 30.5), CompositorScroll); |
| 564 | 608 |
| 565 EXPECT_EQ(30.5, | 609 EXPECT_EQ(30.5, |
| 566 frameView.layoutViewportScrollableArea()->scrollOffset().height()); | 610 frameView.layoutViewportScrollableArea()->scrollOffset().height()); |
| 567 | 611 |
| 568 RuntimeEnabledFeatures::setFractionalScrollOffsetsEnabled( | 612 RuntimeEnabledFeatures::setFractionalScrollOffsetsEnabled( |
| 569 origFractionalOffsetsEnabled); | 613 origFractionalOffsetsEnabled); |
| 570 } | 614 } |
| 571 | 615 |
| 572 // Test that the viewport's scroll offset is always appropriately bounded such | 616 // Test that the viewport's scroll offset is always appropriately bounded such |
| 573 // that the visual viewport always stays within the bounds of the main frame. | 617 // that the visual viewport always stays within the bounds of the main frame. |
| 574 TEST_P(VisualViewportTest, TestOffsetClamping) { | 618 TEST_P(ParameterizedVisualViewportTest, TestOffsetClamping) { |
| 575 initializeWithDesktopSettings(); | 619 initializeWithDesktopSettings(); |
| 576 webViewImpl()->resize(IntSize(320, 240)); | 620 webViewImpl()->resize(IntSize(320, 240)); |
| 577 | 621 |
| 578 navigateTo("about:blank"); | 622 navigateTo("about:blank"); |
| 579 forceFullCompositingUpdate(); | 623 forceFullCompositingUpdate(); |
| 580 | 624 |
| 581 // Visual viewport should be initialized to same size as frame so no scrolling | 625 // Visual viewport should be initialized to same size as frame so no scrolling |
| 582 // possible. | 626 // possible. |
| 583 VisualViewport& visualViewport = | 627 VisualViewport& visualViewport = |
| 584 frame()->page()->frameHost().visualViewport(); | 628 frame()->page()->frameHost().visualViewport(); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 620 | 664 |
| 621 // Scale out smaller than 1. | 665 // Scale out smaller than 1. |
| 622 visualViewport.setScale(0.25); | 666 visualViewport.setScale(0.25); |
| 623 EXPECT_FLOAT_POINT_EQ(FloatPoint(0, 0), | 667 EXPECT_FLOAT_POINT_EQ(FloatPoint(0, 0), |
| 624 visualViewport.visibleRect().location()); | 668 visualViewport.visibleRect().location()); |
| 625 } | 669 } |
| 626 | 670 |
| 627 // Test that the viewport can be scrolled around only within the main frame in | 671 // Test that the viewport can be scrolled around only within the main frame in |
| 628 // the presence of viewport resizes, as would be the case if the on screen | 672 // the presence of viewport resizes, as would be the case if the on screen |
| 629 // keyboard came up. | 673 // keyboard came up. |
| 630 TEST_P(VisualViewportTest, TestOffsetClampingWithResize) { | 674 TEST_P(ParameterizedVisualViewportTest, TestOffsetClampingWithResize) { |
| 631 initializeWithDesktopSettings(); | 675 initializeWithDesktopSettings(); |
| 632 webViewImpl()->resize(IntSize(320, 240)); | 676 webViewImpl()->resize(IntSize(320, 240)); |
| 633 | 677 |
| 634 navigateTo("about:blank"); | 678 navigateTo("about:blank"); |
| 635 forceFullCompositingUpdate(); | 679 forceFullCompositingUpdate(); |
| 636 | 680 |
| 637 // Visual viewport should be initialized to same size as frame so no scrolling | 681 // Visual viewport should be initialized to same size as frame so no scrolling |
| 638 // possible. | 682 // possible. |
| 639 VisualViewport& visualViewport = | 683 VisualViewport& visualViewport = |
| 640 frame()->page()->frameHost().visualViewport(); | 684 frame()->page()->frameHost().visualViewport(); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 689 visualViewport.setLocation(FloatPoint(10, 3)); | 733 visualViewport.setLocation(FloatPoint(10, 3)); |
| 690 EXPECT_FLOAT_POINT_EQ(FloatPoint(10, 3), | 734 EXPECT_FLOAT_POINT_EQ(FloatPoint(10, 3), |
| 691 visualViewport.visibleRect().location()); | 735 visualViewport.visibleRect().location()); |
| 692 visualViewport.setLocation(FloatPoint(-10, -4)); | 736 visualViewport.setLocation(FloatPoint(-10, -4)); |
| 693 EXPECT_FLOAT_POINT_EQ(FloatPoint(0, 0), | 737 EXPECT_FLOAT_POINT_EQ(FloatPoint(0, 0), |
| 694 visualViewport.visibleRect().location()); | 738 visualViewport.visibleRect().location()); |
| 695 } | 739 } |
| 696 | 740 |
| 697 // Test that the viewport is scrollable but bounded appropriately within the | 741 // Test that the viewport is scrollable but bounded appropriately within the |
| 698 // main frame when we apply both scaling and resizes. | 742 // main frame when we apply both scaling and resizes. |
| 699 TEST_P(VisualViewportTest, TestOffsetClampingWithResizeAndScale) { | 743 TEST_P(ParameterizedVisualViewportTest, TestOffsetClampingWithResizeAndScale) { |
| 700 initializeWithDesktopSettings(); | 744 initializeWithDesktopSettings(); |
| 701 webViewImpl()->resize(IntSize(320, 240)); | 745 webViewImpl()->resize(IntSize(320, 240)); |
| 702 | 746 |
| 703 navigateTo("about:blank"); | 747 navigateTo("about:blank"); |
| 704 forceFullCompositingUpdate(); | 748 forceFullCompositingUpdate(); |
| 705 | 749 |
| 706 // Visual viewport should be initialized to same size as WebView so no | 750 // Visual viewport should be initialized to same size as WebView so no |
| 707 // scrolling possible. | 751 // scrolling possible. |
| 708 VisualViewport& visualViewport = | 752 VisualViewport& visualViewport = |
| 709 frame()->page()->frameHost().visualViewport(); | 753 frame()->page()->frameHost().visualViewport(); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 744 visualViewport.setLocation(FloatPoint(200, 200)); | 788 visualViewport.setLocation(FloatPoint(200, 200)); |
| 745 visualViewport.setSize(IntSize(880, 560)); | 789 visualViewport.setSize(IntSize(880, 560)); |
| 746 EXPECT_FLOAT_POINT_EQ(FloatPoint(200, 200), | 790 EXPECT_FLOAT_POINT_EQ(FloatPoint(200, 200), |
| 747 visualViewport.visibleRect().location()); | 791 visualViewport.visibleRect().location()); |
| 748 } | 792 } |
| 749 | 793 |
| 750 // The main FrameView's size should be set such that its the size of the visual | 794 // The main FrameView's size should be set such that its the size of the visual |
| 751 // viewport at minimum scale. If there's no explicit minimum scale set, the | 795 // viewport at minimum scale. If there's no explicit minimum scale set, the |
| 752 // FrameView should be set to the content width and height derived by the aspect | 796 // FrameView should be set to the content width and height derived by the aspect |
| 753 // ratio. | 797 // ratio. |
| 754 TEST_P(VisualViewportTest, TestFrameViewSizedToContent) { | 798 TEST_P(ParameterizedVisualViewportTest, TestFrameViewSizedToContent) { |
| 755 initializeWithAndroidSettings(); | 799 initializeWithAndroidSettings(); |
| 756 webViewImpl()->resize(IntSize(320, 240)); | 800 webViewImpl()->resize(IntSize(320, 240)); |
| 757 | 801 |
| 758 registerMockedHttpURLLoad("200-by-300-viewport.html"); | 802 registerMockedHttpURLLoad("200-by-300-viewport.html"); |
| 759 navigateTo(m_baseURL + "200-by-300-viewport.html"); | 803 navigateTo(m_baseURL + "200-by-300-viewport.html"); |
| 760 | 804 |
| 761 webViewImpl()->resize(IntSize(600, 800)); | 805 webViewImpl()->resize(IntSize(600, 800)); |
| 762 webViewImpl()->updateAllLifecyclePhases(); | 806 webViewImpl()->updateAllLifecyclePhases(); |
| 763 | 807 |
| 764 // Note: the size is ceiled and should match the behavior in CC's | 808 // Note: the size is ceiled and should match the behavior in CC's |
| 765 // LayerImpl::bounds(). | 809 // LayerImpl::bounds(). |
| 766 EXPECT_SIZE_EQ( | 810 EXPECT_SIZE_EQ( |
| 767 IntSize(200, 267), | 811 IntSize(200, 267), |
| 768 webViewImpl()->mainFrameImpl()->frameView()->frameRect().size()); | 812 webViewImpl()->mainFrameImpl()->frameView()->frameRect().size()); |
| 769 } | 813 } |
| 770 | 814 |
| 771 // The main FrameView's size should be set such that its the size of the visual | 815 // The main FrameView's size should be set such that its the size of the visual |
| 772 // viewport at minimum scale. On Desktop, the minimum scale is set at 1 so make | 816 // viewport at minimum scale. On Desktop, the minimum scale is set at 1 so make |
| 773 // sure the FrameView is sized to the viewport. | 817 // sure the FrameView is sized to the viewport. |
| 774 TEST_P(VisualViewportTest, TestFrameViewSizedToMinimumScale) { | 818 TEST_P(ParameterizedVisualViewportTest, TestFrameViewSizedToMinimumScale) { |
| 775 initializeWithDesktopSettings(); | 819 initializeWithDesktopSettings(); |
| 776 webViewImpl()->resize(IntSize(320, 240)); | 820 webViewImpl()->resize(IntSize(320, 240)); |
| 777 | 821 |
| 778 registerMockedHttpURLLoad("200-by-300.html"); | 822 registerMockedHttpURLLoad("200-by-300.html"); |
| 779 navigateTo(m_baseURL + "200-by-300.html"); | 823 navigateTo(m_baseURL + "200-by-300.html"); |
| 780 | 824 |
| 781 webViewImpl()->resize(IntSize(100, 160)); | 825 webViewImpl()->resize(IntSize(100, 160)); |
| 782 webViewImpl()->updateAllLifecyclePhases(); | 826 webViewImpl()->updateAllLifecyclePhases(); |
| 783 | 827 |
| 784 EXPECT_SIZE_EQ( | 828 EXPECT_SIZE_EQ( |
| 785 IntSize(100, 160), | 829 IntSize(100, 160), |
| 786 webViewImpl()->mainFrameImpl()->frameView()->frameRect().size()); | 830 webViewImpl()->mainFrameImpl()->frameView()->frameRect().size()); |
| 787 } | 831 } |
| 788 | 832 |
| 789 // Test that attaching a new frame view resets the size of the inner viewport | 833 // Test that attaching a new frame view resets the size of the inner viewport |
| 790 // scroll layer. crbug.com/423189. | 834 // scroll layer. crbug.com/423189. |
| 791 TEST_P(VisualViewportTest, TestAttachingNewFrameSetsInnerScrollLayerSize) { | 835 TEST_P(ParameterizedVisualViewportTest, |
| 836 TestAttachingNewFrameSetsInnerScrollLayerSize) { |
| 792 initializeWithAndroidSettings(); | 837 initializeWithAndroidSettings(); |
| 793 webViewImpl()->resize(IntSize(320, 240)); | 838 webViewImpl()->resize(IntSize(320, 240)); |
| 794 | 839 |
| 795 // Load a wider page first, the navigation should resize the scroll layer to | 840 // Load a wider page first, the navigation should resize the scroll layer to |
| 796 // the smaller size on the second navigation. | 841 // the smaller size on the second navigation. |
| 797 registerMockedHttpURLLoad("content-width-1000.html"); | 842 registerMockedHttpURLLoad("content-width-1000.html"); |
| 798 navigateTo(m_baseURL + "content-width-1000.html"); | 843 navigateTo(m_baseURL + "content-width-1000.html"); |
| 799 webViewImpl()->updateAllLifecyclePhases(); | 844 webViewImpl()->updateAllLifecyclePhases(); |
| 800 | 845 |
| 801 VisualViewport& visualViewport = | 846 VisualViewport& visualViewport = |
| (...skipping 16 matching lines...) Expand all Loading... |
| 818 visualViewport.scrollLayer()->elementId().secondaryId); | 863 visualViewport.scrollLayer()->elementId().secondaryId); |
| 819 | 864 |
| 820 // Ensure the location and scale were reset. | 865 // Ensure the location and scale were reset. |
| 821 EXPECT_SIZE_EQ(FloatSize(), visualViewport.scrollOffset()); | 866 EXPECT_SIZE_EQ(FloatSize(), visualViewport.scrollOffset()); |
| 822 EXPECT_EQ(1, visualViewport.scale()); | 867 EXPECT_EQ(1, visualViewport.scale()); |
| 823 } | 868 } |
| 824 | 869 |
| 825 // The main FrameView's size should be set such that its the size of the visual | 870 // The main FrameView's size should be set such that its the size of the visual |
| 826 // viewport at minimum scale. Test that the FrameView is appropriately sized in | 871 // viewport at minimum scale. Test that the FrameView is appropriately sized in |
| 827 // the presence of a viewport <meta> tag. | 872 // the presence of a viewport <meta> tag. |
| 828 TEST_P(VisualViewportTest, TestFrameViewSizedToViewportMetaMinimumScale) { | 873 TEST_P(ParameterizedVisualViewportTest, |
| 874 TestFrameViewSizedToViewportMetaMinimumScale) { |
| 829 initializeWithAndroidSettings(); | 875 initializeWithAndroidSettings(); |
| 830 webViewImpl()->resize(IntSize(320, 240)); | 876 webViewImpl()->resize(IntSize(320, 240)); |
| 831 | 877 |
| 832 registerMockedHttpURLLoad("200-by-300-min-scale-2.html"); | 878 registerMockedHttpURLLoad("200-by-300-min-scale-2.html"); |
| 833 navigateTo(m_baseURL + "200-by-300-min-scale-2.html"); | 879 navigateTo(m_baseURL + "200-by-300-min-scale-2.html"); |
| 834 | 880 |
| 835 webViewImpl()->resize(IntSize(100, 160)); | 881 webViewImpl()->resize(IntSize(100, 160)); |
| 836 webViewImpl()->updateAllLifecyclePhases(); | 882 webViewImpl()->updateAllLifecyclePhases(); |
| 837 | 883 |
| 838 EXPECT_SIZE_EQ( | 884 EXPECT_SIZE_EQ( |
| 839 IntSize(50, 80), | 885 IntSize(50, 80), |
| 840 webViewImpl()->mainFrameImpl()->frameView()->frameRect().size()); | 886 webViewImpl()->mainFrameImpl()->frameView()->frameRect().size()); |
| 841 } | 887 } |
| 842 | 888 |
| 843 // Test that the visual viewport still gets sized in AutoSize/AutoResize mode. | 889 // Test that the visual viewport still gets sized in AutoSize/AutoResize mode. |
| 844 TEST_P(VisualViewportTest, TestVisualViewportGetsSizeInAutoSizeMode) { | 890 TEST_P(ParameterizedVisualViewportTest, |
| 891 TestVisualViewportGetsSizeInAutoSizeMode) { |
| 845 initializeWithDesktopSettings(); | 892 initializeWithDesktopSettings(); |
| 846 | 893 |
| 847 EXPECT_SIZE_EQ(IntSize(0, 0), IntSize(webViewImpl()->size())); | 894 EXPECT_SIZE_EQ(IntSize(0, 0), IntSize(webViewImpl()->size())); |
| 848 EXPECT_SIZE_EQ(IntSize(0, 0), | 895 EXPECT_SIZE_EQ(IntSize(0, 0), |
| 849 frame()->page()->frameHost().visualViewport().size()); | 896 frame()->page()->frameHost().visualViewport().size()); |
| 850 | 897 |
| 851 webViewImpl()->enableAutoResizeMode(WebSize(10, 10), WebSize(1000, 1000)); | 898 webViewImpl()->enableAutoResizeMode(WebSize(10, 10), WebSize(1000, 1000)); |
| 852 | 899 |
| 853 registerMockedHttpURLLoad("200-by-300.html"); | 900 registerMockedHttpURLLoad("200-by-300.html"); |
| 854 navigateTo(m_baseURL + "200-by-300.html"); | 901 navigateTo(m_baseURL + "200-by-300.html"); |
| 855 | 902 |
| 856 EXPECT_SIZE_EQ(IntSize(200, 300), | 903 EXPECT_SIZE_EQ(IntSize(200, 300), |
| 857 frame()->page()->frameHost().visualViewport().size()); | 904 frame()->page()->frameHost().visualViewport().size()); |
| 858 } | 905 } |
| 859 | 906 |
| 860 // Test that the text selection handle's position accounts for the visual | 907 // Test that the text selection handle's position accounts for the visual |
| 861 // viewport. | 908 // viewport. |
| 862 TEST_P(VisualViewportTest, TestTextSelectionHandles) { | 909 TEST_P(ParameterizedVisualViewportTest, TestTextSelectionHandles) { |
| 863 initializeWithDesktopSettings(); | 910 initializeWithDesktopSettings(); |
| 864 webViewImpl()->resize(IntSize(500, 800)); | 911 webViewImpl()->resize(IntSize(500, 800)); |
| 865 | 912 |
| 866 registerMockedHttpURLLoad("pinch-viewport-input-field.html"); | 913 registerMockedHttpURLLoad("pinch-viewport-input-field.html"); |
| 867 navigateTo(m_baseURL + "pinch-viewport-input-field.html"); | 914 navigateTo(m_baseURL + "pinch-viewport-input-field.html"); |
| 868 | 915 |
| 869 VisualViewport& visualViewport = | 916 VisualViewport& visualViewport = |
| 870 frame()->page()->frameHost().visualViewport(); | 917 frame()->page()->frameHost().visualViewport(); |
| 871 webViewImpl()->setInitialFocus(false); | 918 webViewImpl()->setInitialFocus(false); |
| 872 | 919 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 887 | 934 |
| 888 EXPECT_POINT_EQ(expected, IntRect(anchor).location()); | 935 EXPECT_POINT_EQ(expected, IntRect(anchor).location()); |
| 889 EXPECT_POINT_EQ(expected, IntRect(focus).location()); | 936 EXPECT_POINT_EQ(expected, IntRect(focus).location()); |
| 890 | 937 |
| 891 // FIXME(bokan) - http://crbug.com/364154 - Figure out how to test text | 938 // FIXME(bokan) - http://crbug.com/364154 - Figure out how to test text |
| 892 // selection as well rather than just carret. | 939 // selection as well rather than just carret. |
| 893 } | 940 } |
| 894 | 941 |
| 895 // Test that the HistoryItem for the page stores the visual viewport's offset | 942 // Test that the HistoryItem for the page stores the visual viewport's offset |
| 896 // and scale. | 943 // and scale. |
| 897 TEST_P(VisualViewportTest, TestSavedToHistoryItem) { | 944 TEST_P(ParameterizedVisualViewportTest, TestSavedToHistoryItem) { |
| 898 initializeWithDesktopSettings(); | 945 initializeWithDesktopSettings(); |
| 899 webViewImpl()->resize(IntSize(200, 300)); | 946 webViewImpl()->resize(IntSize(200, 300)); |
| 900 webViewImpl()->updateAllLifecyclePhases(); | 947 webViewImpl()->updateAllLifecyclePhases(); |
| 901 | 948 |
| 902 registerMockedHttpURLLoad("200-by-300.html"); | 949 registerMockedHttpURLLoad("200-by-300.html"); |
| 903 navigateTo(m_baseURL + "200-by-300.html"); | 950 navigateTo(m_baseURL + "200-by-300.html"); |
| 904 | 951 |
| 905 EXPECT_SIZE_EQ(ScrollOffset(0, 0), | 952 EXPECT_SIZE_EQ(ScrollOffset(0, 0), |
| 906 toLocalFrame(webViewImpl()->page()->mainFrame()) | 953 toLocalFrame(webViewImpl()->page()->mainFrame()) |
| 907 ->loader() | 954 ->loader() |
| (...skipping 12 matching lines...) Expand all Loading... |
| 920 visualViewport.setLocation(FloatPoint(10, 20)); | 967 visualViewport.setLocation(FloatPoint(10, 20)); |
| 921 | 968 |
| 922 EXPECT_SIZE_EQ(ScrollOffset(10, 20), | 969 EXPECT_SIZE_EQ(ScrollOffset(10, 20), |
| 923 toLocalFrame(webViewImpl()->page()->mainFrame()) | 970 toLocalFrame(webViewImpl()->page()->mainFrame()) |
| 924 ->loader() | 971 ->loader() |
| 925 .currentItem() | 972 .currentItem() |
| 926 ->visualViewportScrollOffset()); | 973 ->visualViewportScrollOffset()); |
| 927 } | 974 } |
| 928 | 975 |
| 929 // Test restoring a HistoryItem properly restores the visual viewport's state. | 976 // Test restoring a HistoryItem properly restores the visual viewport's state. |
| 930 TEST_P(VisualViewportTest, TestRestoredFromHistoryItem) { | 977 TEST_P(ParameterizedVisualViewportTest, TestRestoredFromHistoryItem) { |
| 931 initializeWithDesktopSettings(); | 978 initializeWithDesktopSettings(); |
| 932 webViewImpl()->resize(IntSize(200, 300)); | 979 webViewImpl()->resize(IntSize(200, 300)); |
| 933 | 980 |
| 934 registerMockedHttpURLLoad("200-by-300.html"); | 981 registerMockedHttpURLLoad("200-by-300.html"); |
| 935 | 982 |
| 936 WebHistoryItem item; | 983 WebHistoryItem item; |
| 937 item.initialize(); | 984 item.initialize(); |
| 938 WebURL destinationURL(URLTestHelpers::toKURL(m_baseURL + "200-by-300.html")); | 985 WebURL destinationURL(URLTestHelpers::toKURL(m_baseURL + "200-by-300.html")); |
| 939 item.setURLString(destinationURL.string()); | 986 item.setURLString(destinationURL.string()); |
| 940 item.setVisualViewportScrollOffset(WebFloatPoint(100, 120)); | 987 item.setVisualViewportScrollOffset(WebFloatPoint(100, 120)); |
| 941 item.setPageScaleFactor(2); | 988 item.setPageScaleFactor(2); |
| 942 | 989 |
| 943 FrameTestHelpers::loadHistoryItem(webViewImpl()->mainFrame(), item, | 990 FrameTestHelpers::loadHistoryItem(webViewImpl()->mainFrame(), item, |
| 944 WebHistoryDifferentDocumentLoad, | 991 WebHistoryDifferentDocumentLoad, |
| 945 WebCachePolicy::UseProtocolCachePolicy); | 992 WebCachePolicy::UseProtocolCachePolicy); |
| 946 | 993 |
| 947 VisualViewport& visualViewport = | 994 VisualViewport& visualViewport = |
| 948 frame()->page()->frameHost().visualViewport(); | 995 frame()->page()->frameHost().visualViewport(); |
| 949 EXPECT_EQ(2, visualViewport.scale()); | 996 EXPECT_EQ(2, visualViewport.scale()); |
| 950 | 997 |
| 951 EXPECT_FLOAT_POINT_EQ(FloatPoint(100, 120), | 998 EXPECT_FLOAT_POINT_EQ(FloatPoint(100, 120), |
| 952 visualViewport.visibleRect().location()); | 999 visualViewport.visibleRect().location()); |
| 953 } | 1000 } |
| 954 | 1001 |
| 955 // Test restoring a HistoryItem without the visual viewport offset falls back to | 1002 // Test restoring a HistoryItem without the visual viewport offset falls back to |
| 956 // distributing the scroll offset between the main frame and the visual | 1003 // distributing the scroll offset between the main frame and the visual |
| 957 // viewport. | 1004 // viewport. |
| 958 TEST_P(VisualViewportTest, TestRestoredFromLegacyHistoryItem) { | 1005 TEST_P(ParameterizedVisualViewportTest, TestRestoredFromLegacyHistoryItem) { |
| 959 initializeWithDesktopSettings(); | 1006 initializeWithDesktopSettings(); |
| 960 webViewImpl()->resize(IntSize(100, 150)); | 1007 webViewImpl()->resize(IntSize(100, 150)); |
| 961 | 1008 |
| 962 registerMockedHttpURLLoad("200-by-300-viewport.html"); | 1009 registerMockedHttpURLLoad("200-by-300-viewport.html"); |
| 963 | 1010 |
| 964 WebHistoryItem item; | 1011 WebHistoryItem item; |
| 965 item.initialize(); | 1012 item.initialize(); |
| 966 WebURL destinationURL( | 1013 WebURL destinationURL( |
| 967 URLTestHelpers::toKURL(m_baseURL + "200-by-300-viewport.html")); | 1014 URLTestHelpers::toKURL(m_baseURL + "200-by-300-viewport.html")); |
| 968 item.setURLString(destinationURL.string()); | 1015 item.setURLString(destinationURL.string()); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 981 EXPECT_EQ(2, visualViewport.scale()); | 1028 EXPECT_EQ(2, visualViewport.scale()); |
| 982 EXPECT_SIZE_EQ( | 1029 EXPECT_SIZE_EQ( |
| 983 ScrollOffset(100, 150), | 1030 ScrollOffset(100, 150), |
| 984 frame()->view()->layoutViewportScrollableArea()->scrollOffset()); | 1031 frame()->view()->layoutViewportScrollableArea()->scrollOffset()); |
| 985 EXPECT_FLOAT_POINT_EQ(FloatPoint(20, 30), | 1032 EXPECT_FLOAT_POINT_EQ(FloatPoint(20, 30), |
| 986 visualViewport.visibleRect().location()); | 1033 visualViewport.visibleRect().location()); |
| 987 } | 1034 } |
| 988 | 1035 |
| 989 // Test that navigation to a new page with a different sized main frame doesn't | 1036 // Test that navigation to a new page with a different sized main frame doesn't |
| 990 // clobber the history item's main frame scroll offset. crbug.com/371867 | 1037 // clobber the history item's main frame scroll offset. crbug.com/371867 |
| 991 TEST_P(VisualViewportTest, | 1038 TEST_P(ParameterizedVisualViewportTest, |
| 992 TestNavigateToSmallerFrameViewHistoryItemClobberBug) { | 1039 TestNavigateToSmallerFrameViewHistoryItemClobberBug) { |
| 993 initializeWithAndroidSettings(); | 1040 initializeWithAndroidSettings(); |
| 994 webViewImpl()->resize(IntSize(400, 400)); | 1041 webViewImpl()->resize(IntSize(400, 400)); |
| 995 webViewImpl()->updateAllLifecyclePhases(); | 1042 webViewImpl()->updateAllLifecyclePhases(); |
| 996 | 1043 |
| 997 registerMockedHttpURLLoad("content-width-1000.html"); | 1044 registerMockedHttpURLLoad("content-width-1000.html"); |
| 998 navigateTo(m_baseURL + "content-width-1000.html"); | 1045 navigateTo(m_baseURL + "content-width-1000.html"); |
| 999 | 1046 |
| 1000 FrameView* frameView = webViewImpl()->mainFrameImpl()->frameView(); | 1047 FrameView* frameView = webViewImpl()->mainFrameImpl()->frameView(); |
| 1001 frameView->layoutViewportScrollableArea()->setScrollOffset( | 1048 frameView->layoutViewportScrollableArea()->setScrollOffset( |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1019 frameView = webViewImpl()->mainFrameImpl()->frameView(); | 1066 frameView = webViewImpl()->mainFrameImpl()->frameView(); |
| 1020 | 1067 |
| 1021 EXPECT_NE(firstItem, | 1068 EXPECT_NE(firstItem, |
| 1022 webViewImpl()->mainFrameImpl()->frame()->loader().currentItem()); | 1069 webViewImpl()->mainFrameImpl()->frame()->loader().currentItem()); |
| 1023 EXPECT_LT(frameView->frameRect().size().width(), 1000); | 1070 EXPECT_LT(frameView->frameRect().size().width(), 1000); |
| 1024 EXPECT_SIZE_EQ(ScrollOffset(0, 1000), firstItem->scrollOffset()); | 1071 EXPECT_SIZE_EQ(ScrollOffset(0, 1000), firstItem->scrollOffset()); |
| 1025 } | 1072 } |
| 1026 | 1073 |
| 1027 // Test that the coordinates sent into moveRangeSelection are offset by the | 1074 // Test that the coordinates sent into moveRangeSelection are offset by the |
| 1028 // visual viewport's location. | 1075 // visual viewport's location. |
| 1029 TEST_P(VisualViewportTest, | 1076 TEST_P(ParameterizedVisualViewportTest, |
| 1030 DISABLED_TestWebFrameRangeAccountsForVisualViewportScroll) { | 1077 DISABLED_TestWebFrameRangeAccountsForVisualViewportScroll) { |
| 1031 initializeWithDesktopSettings(); | 1078 initializeWithDesktopSettings(); |
| 1032 webViewImpl()->settings()->setDefaultFontSize(12); | 1079 webViewImpl()->settings()->setDefaultFontSize(12); |
| 1033 webViewImpl()->resize(WebSize(640, 480)); | 1080 webViewImpl()->resize(WebSize(640, 480)); |
| 1034 registerMockedHttpURLLoad("move_range.html"); | 1081 registerMockedHttpURLLoad("move_range.html"); |
| 1035 navigateTo(m_baseURL + "move_range.html"); | 1082 navigateTo(m_baseURL + "move_range.html"); |
| 1036 | 1083 |
| 1037 WebRect baseRect; | 1084 WebRect baseRect; |
| 1038 WebRect extentRect; | 1085 WebRect extentRect; |
| 1039 | 1086 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1055 // right and down one line. | 1102 // right and down one line. |
| 1056 VisualViewport& visualViewport = | 1103 VisualViewport& visualViewport = |
| 1057 frame()->page()->frameHost().visualViewport(); | 1104 frame()->page()->frameHost().visualViewport(); |
| 1058 visualViewport.move(ScrollOffset(60, 25)); | 1105 visualViewport.move(ScrollOffset(60, 25)); |
| 1059 mainFrame->toWebLocalFrame()->moveRangeSelection(initialPoint, endPoint); | 1106 mainFrame->toWebLocalFrame()->moveRangeSelection(initialPoint, endPoint); |
| 1060 EXPECT_EQ("t ", mainFrame->toWebLocalFrame()->selectionAsText().utf8()); | 1107 EXPECT_EQ("t ", mainFrame->toWebLocalFrame()->selectionAsText().utf8()); |
| 1061 } | 1108 } |
| 1062 | 1109 |
| 1063 // Test that the scrollFocusedEditableElementIntoRect method works with the | 1110 // Test that the scrollFocusedEditableElementIntoRect method works with the |
| 1064 // visual viewport. | 1111 // visual viewport. |
| 1065 TEST_P(VisualViewportTest, DISABLED_TestScrollFocusedEditableElementIntoRect) { | 1112 TEST_P(ParameterizedVisualViewportTest, |
| 1113 DISABLED_TestScrollFocusedEditableElementIntoRect) { |
| 1066 initializeWithDesktopSettings(); | 1114 initializeWithDesktopSettings(); |
| 1067 webViewImpl()->resize(IntSize(500, 300)); | 1115 webViewImpl()->resize(IntSize(500, 300)); |
| 1068 | 1116 |
| 1069 registerMockedHttpURLLoad("pinch-viewport-input-field.html"); | 1117 registerMockedHttpURLLoad("pinch-viewport-input-field.html"); |
| 1070 navigateTo(m_baseURL + "pinch-viewport-input-field.html"); | 1118 navigateTo(m_baseURL + "pinch-viewport-input-field.html"); |
| 1071 | 1119 |
| 1072 VisualViewport& visualViewport = | 1120 VisualViewport& visualViewport = |
| 1073 frame()->page()->frameHost().visualViewport(); | 1121 frame()->page()->frameHost().visualViewport(); |
| 1074 webViewImpl()->resizeVisualViewport(IntSize(200, 100)); | 1122 webViewImpl()->resizeVisualViewport(IntSize(200, 100)); |
| 1075 webViewImpl()->setInitialFocus(false); | 1123 webViewImpl()->setInitialFocus(false); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1108 webViewImpl()->setPageScaleFactor(2); | 1156 webViewImpl()->setPageScaleFactor(2); |
| 1109 webViewImpl()->scrollFocusedEditableElementIntoRect(IntRect(0, 0, 500, 200)); | 1157 webViewImpl()->scrollFocusedEditableElementIntoRect(IntRect(0, 0, 500, 200)); |
| 1110 EXPECT_SIZE_EQ(ScrollOffset(200 - 30 - 75, 600 - 50 - 65), | 1158 EXPECT_SIZE_EQ(ScrollOffset(200 - 30 - 75, 600 - 50 - 65), |
| 1111 frame()->view()->scrollOffset()); | 1159 frame()->view()->scrollOffset()); |
| 1112 EXPECT_FLOAT_POINT_EQ(FloatPoint(30, 50), | 1160 EXPECT_FLOAT_POINT_EQ(FloatPoint(30, 50), |
| 1113 visualViewport.visibleRect().location()); | 1161 visualViewport.visibleRect().location()); |
| 1114 } | 1162 } |
| 1115 | 1163 |
| 1116 // Test that resizing the WebView causes ViewportConstrained objects to | 1164 // Test that resizing the WebView causes ViewportConstrained objects to |
| 1117 // relayout. | 1165 // relayout. |
| 1118 TEST_P(VisualViewportTest, TestWebViewResizeCausesViewportConstrainedLayout) { | 1166 TEST_P(ParameterizedVisualViewportTest, |
| 1167 TestWebViewResizeCausesViewportConstrainedLayout) { |
| 1119 initializeWithDesktopSettings(); | 1168 initializeWithDesktopSettings(); |
| 1120 webViewImpl()->resize(IntSize(500, 300)); | 1169 webViewImpl()->resize(IntSize(500, 300)); |
| 1121 | 1170 |
| 1122 registerMockedHttpURLLoad("pinch-viewport-fixed-pos.html"); | 1171 registerMockedHttpURLLoad("pinch-viewport-fixed-pos.html"); |
| 1123 navigateTo(m_baseURL + "pinch-viewport-fixed-pos.html"); | 1172 navigateTo(m_baseURL + "pinch-viewport-fixed-pos.html"); |
| 1124 | 1173 |
| 1125 LayoutObject* navbar = | 1174 LayoutObject* navbar = |
| 1126 frame()->document()->getElementById("navbar")->layoutObject(); | 1175 frame()->document()->getElementById("navbar")->layoutObject(); |
| 1127 | 1176 |
| 1128 EXPECT_FALSE(navbar->needsLayout()); | 1177 EXPECT_FALSE(navbar->needsLayout()); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1144 std::string(negation ? "is" : "isn't") + " at expected location [" + | 1193 std::string(negation ? "is" : "isn't") + " at expected location [" + |
| 1145 PrintToString(x) + | 1194 PrintToString(x) + |
| 1146 ", " + | 1195 ", " + |
| 1147 PrintToString(y) + | 1196 PrintToString(y) + |
| 1148 "]") { | 1197 "]") { |
| 1149 return arg.mousePosition.x == x && arg.mousePosition.y == y; | 1198 return arg.mousePosition.x == x && arg.mousePosition.y == y; |
| 1150 } | 1199 } |
| 1151 | 1200 |
| 1152 // Test that the context menu's location is correct in the presence of visual | 1201 // Test that the context menu's location is correct in the presence of visual |
| 1153 // viewport offset. | 1202 // viewport offset. |
| 1154 TEST_P(VisualViewportTest, TestContextMenuShownInCorrectLocation) { | 1203 TEST_P(ParameterizedVisualViewportTest, TestContextMenuShownInCorrectLocation) { |
| 1155 initializeWithDesktopSettings(); | 1204 initializeWithDesktopSettings(); |
| 1156 webViewImpl()->resize(IntSize(200, 300)); | 1205 webViewImpl()->resize(IntSize(200, 300)); |
| 1157 | 1206 |
| 1158 registerMockedHttpURLLoad("200-by-300.html"); | 1207 registerMockedHttpURLLoad("200-by-300.html"); |
| 1159 navigateTo(m_baseURL + "200-by-300.html"); | 1208 navigateTo(m_baseURL + "200-by-300.html"); |
| 1160 | 1209 |
| 1161 WebMouseEvent mouseDownEvent; | 1210 WebMouseEvent mouseDownEvent; |
| 1162 mouseDownEvent.type = WebInputEvent::MouseDown; | 1211 mouseDownEvent.type = WebInputEvent::MouseDown; |
| 1163 mouseDownEvent.x = 10; | 1212 mouseDownEvent.x = 10; |
| 1164 mouseDownEvent.y = 10; | 1213 mouseDownEvent.y = 10; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1199 | 1248 |
| 1200 mouseDownEvent.button = WebMouseEvent::Button::Right; | 1249 mouseDownEvent.button = WebMouseEvent::Button::Right; |
| 1201 webViewImpl()->handleInputEvent(mouseDownEvent); | 1250 webViewImpl()->handleInputEvent(mouseDownEvent); |
| 1202 webViewImpl()->handleInputEvent(mouseUpEvent); | 1251 webViewImpl()->handleInputEvent(mouseUpEvent); |
| 1203 | 1252 |
| 1204 // Reset the old client so destruction can occur naturally. | 1253 // Reset the old client so destruction can occur naturally. |
| 1205 webViewImpl()->mainFrameImpl()->setClient(oldClient); | 1254 webViewImpl()->mainFrameImpl()->setClient(oldClient); |
| 1206 } | 1255 } |
| 1207 | 1256 |
| 1208 // Test that the client is notified if page scroll events. | 1257 // Test that the client is notified if page scroll events. |
| 1209 TEST_P(VisualViewportTest, TestClientNotifiedOfScrollEvents) { | 1258 TEST_P(ParameterizedVisualViewportTest, TestClientNotifiedOfScrollEvents) { |
| 1210 initializeWithAndroidSettings(); | 1259 initializeWithAndroidSettings(); |
| 1211 webViewImpl()->resize(IntSize(200, 300)); | 1260 webViewImpl()->resize(IntSize(200, 300)); |
| 1212 | 1261 |
| 1213 registerMockedHttpURLLoad("200-by-300.html"); | 1262 registerMockedHttpURLLoad("200-by-300.html"); |
| 1214 navigateTo(m_baseURL + "200-by-300.html"); | 1263 navigateTo(m_baseURL + "200-by-300.html"); |
| 1215 | 1264 |
| 1216 WebFrameClient* oldClient = webViewImpl()->mainFrameImpl()->client(); | 1265 WebFrameClient* oldClient = webViewImpl()->mainFrameImpl()->client(); |
| 1217 MockWebFrameClient mockWebFrameClient; | 1266 MockWebFrameClient mockWebFrameClient; |
| 1218 webViewImpl()->mainFrameImpl()->setClient(&mockWebFrameClient); | 1267 webViewImpl()->mainFrameImpl()->setClient(&mockWebFrameClient); |
| 1219 | 1268 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1233 // Scroll horizontally. | 1282 // Scroll horizontally. |
| 1234 EXPECT_CALL(mockWebFrameClient, didChangeScrollOffset(_)); | 1283 EXPECT_CALL(mockWebFrameClient, didChangeScrollOffset(_)); |
| 1235 visualViewport.setLocation(FloatPoint(70, 90)); | 1284 visualViewport.setLocation(FloatPoint(70, 90)); |
| 1236 | 1285 |
| 1237 // Reset the old client so destruction can occur naturally. | 1286 // Reset the old client so destruction can occur naturally. |
| 1238 webViewImpl()->mainFrameImpl()->setClient(oldClient); | 1287 webViewImpl()->mainFrameImpl()->setClient(oldClient); |
| 1239 } | 1288 } |
| 1240 | 1289 |
| 1241 // Tests that calling scroll into view on a visible element doesn't cause | 1290 // Tests that calling scroll into view on a visible element doesn't cause |
| 1242 // a scroll due to a fractional offset. Bug crbug.com/463356. | 1291 // a scroll due to a fractional offset. Bug crbug.com/463356. |
| 1243 TEST_P(VisualViewportTest, ScrollIntoViewFractionalOffset) { | 1292 TEST_P(ParameterizedVisualViewportTest, ScrollIntoViewFractionalOffset) { |
| 1244 initializeWithAndroidSettings(); | 1293 initializeWithAndroidSettings(); |
| 1245 | 1294 |
| 1246 webViewImpl()->resize(IntSize(1000, 1000)); | 1295 webViewImpl()->resize(IntSize(1000, 1000)); |
| 1247 | 1296 |
| 1248 registerMockedHttpURLLoad("scroll-into-view.html"); | 1297 registerMockedHttpURLLoad("scroll-into-view.html"); |
| 1249 navigateTo(m_baseURL + "scroll-into-view.html"); | 1298 navigateTo(m_baseURL + "scroll-into-view.html"); |
| 1250 | 1299 |
| 1251 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView(); | 1300 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView(); |
| 1252 ScrollableArea* layoutViewportScrollableArea = | 1301 ScrollableArea* layoutViewportScrollableArea = |
| 1253 frameView.layoutViewportScrollableArea(); | 1302 frameView.layoutViewportScrollableArea(); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1311 VisualViewport& visualViewport, | 1360 VisualViewport& visualViewport, |
| 1312 FrameView& frameView) { | 1361 FrameView& frameView) { |
| 1313 float aspectRatio = visualViewport.visibleRect().width() / | 1362 float aspectRatio = visualViewport.visibleRect().width() / |
| 1314 visualViewport.visibleRect().height(); | 1363 visualViewport.visibleRect().height(); |
| 1315 float newHeight = frameView.frameRect().width() / aspectRatio; | 1364 float newHeight = frameView.frameRect().width() / aspectRatio; |
| 1316 return ScrollOffset( | 1365 return ScrollOffset( |
| 1317 frameView.contentsSize().width() - frameView.frameRect().width(), | 1366 frameView.contentsSize().width() - frameView.frameRect().width(), |
| 1318 frameView.contentsSize().height() - newHeight); | 1367 frameView.contentsSize().height() - newHeight); |
| 1319 } | 1368 } |
| 1320 | 1369 |
| 1321 TEST_P(VisualViewportTest, TestBrowserControlsAdjustment) { | 1370 TEST_P(ParameterizedVisualViewportTest, TestBrowserControlsAdjustment) { |
| 1322 initializeWithAndroidSettings(); | 1371 initializeWithAndroidSettings(); |
| 1323 webViewImpl()->resizeWithBrowserControls(IntSize(500, 450), 20, false); | 1372 webViewImpl()->resizeWithBrowserControls(IntSize(500, 450), 20, false); |
| 1324 | 1373 |
| 1325 registerMockedHttpURLLoad("content-width-1000.html"); | 1374 registerMockedHttpURLLoad("content-width-1000.html"); |
| 1326 navigateTo(m_baseURL + "content-width-1000.html"); | 1375 navigateTo(m_baseURL + "content-width-1000.html"); |
| 1327 | 1376 |
| 1328 VisualViewport& visualViewport = | 1377 VisualViewport& visualViewport = |
| 1329 frame()->page()->frameHost().visualViewport(); | 1378 frame()->page()->frameHost().visualViewport(); |
| 1330 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView(); | 1379 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView(); |
| 1331 | 1380 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1362 EXPECT_FLOAT_SIZE_EQ(FloatSize(500, 881 - 441), | 1411 EXPECT_FLOAT_SIZE_EQ(FloatSize(500, 881 - 441), |
| 1363 visualViewport.scrollOffset()); | 1412 visualViewport.scrollOffset()); |
| 1364 | 1413 |
| 1365 // The outer viewport (FrameView) should be affected as well. | 1414 // The outer viewport (FrameView) should be affected as well. |
| 1366 frameView.layoutViewportScrollableArea()->scrollBy(ScrollOffset(10000, 10000), | 1415 frameView.layoutViewportScrollableArea()->scrollBy(ScrollOffset(10000, 10000), |
| 1367 UserScroll); | 1416 UserScroll); |
| 1368 EXPECT_SIZE_EQ(expectedMaxFrameViewScrollOffset(visualViewport, frameView), | 1417 EXPECT_SIZE_EQ(expectedMaxFrameViewScrollOffset(visualViewport, frameView), |
| 1369 frameView.layoutViewportScrollableArea()->scrollOffset()); | 1418 frameView.layoutViewportScrollableArea()->scrollOffset()); |
| 1370 } | 1419 } |
| 1371 | 1420 |
| 1372 TEST_P(VisualViewportTest, TestBrowserControlsAdjustmentWithScale) { | 1421 TEST_P(ParameterizedVisualViewportTest, |
| 1422 TestBrowserControlsAdjustmentWithScale) { |
| 1373 initializeWithAndroidSettings(); | 1423 initializeWithAndroidSettings(); |
| 1374 webViewImpl()->resizeWithBrowserControls(IntSize(500, 450), 20, false); | 1424 webViewImpl()->resizeWithBrowserControls(IntSize(500, 450), 20, false); |
| 1375 | 1425 |
| 1376 registerMockedHttpURLLoad("content-width-1000.html"); | 1426 registerMockedHttpURLLoad("content-width-1000.html"); |
| 1377 navigateTo(m_baseURL + "content-width-1000.html"); | 1427 navigateTo(m_baseURL + "content-width-1000.html"); |
| 1378 | 1428 |
| 1379 VisualViewport& visualViewport = | 1429 VisualViewport& visualViewport = |
| 1380 frame()->page()->frameHost().visualViewport(); | 1430 frame()->page()->frameHost().visualViewport(); |
| 1381 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView(); | 1431 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView(); |
| 1382 | 1432 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1436 | 1486 |
| 1437 frameView.layoutViewportScrollableArea()->scrollBy(ScrollOffset(10000, 10000), | 1487 frameView.layoutViewportScrollableArea()->scrollBy(ScrollOffset(10000, 10000), |
| 1438 UserScroll); | 1488 UserScroll); |
| 1439 EXPECT_SIZE_EQ(expectedMaxFrameViewScrollOffset(visualViewport, frameView), | 1489 EXPECT_SIZE_EQ(expectedMaxFrameViewScrollOffset(visualViewport, frameView), |
| 1440 frameView.layoutViewportScrollableArea()->scrollOffset()); | 1490 frameView.layoutViewportScrollableArea()->scrollOffset()); |
| 1441 } | 1491 } |
| 1442 | 1492 |
| 1443 // Tests that a scroll all the way to the bottom of the page, while hiding the | 1493 // Tests that a scroll all the way to the bottom of the page, while hiding the |
| 1444 // browser controls doesn't cause a clamp in the viewport scroll offset when the | 1494 // browser controls doesn't cause a clamp in the viewport scroll offset when the |
| 1445 // top controls initiated resize occurs. | 1495 // top controls initiated resize occurs. |
| 1446 TEST_P(VisualViewportTest, TestBrowserControlsAdjustmentAndResize) { | 1496 TEST_P(ParameterizedVisualViewportTest, |
| 1497 TestBrowserControlsAdjustmentAndResize) { |
| 1447 int browserControlsHeight = 20; | 1498 int browserControlsHeight = 20; |
| 1448 int visualViewportHeight = 450; | 1499 int visualViewportHeight = 450; |
| 1449 int layoutViewportHeight = 900; | 1500 int layoutViewportHeight = 900; |
| 1450 float pageScale = 2; | 1501 float pageScale = 2; |
| 1451 float minPageScale = 0.5; | 1502 float minPageScale = 0.5; |
| 1452 | 1503 |
| 1453 initializeWithAndroidSettings(); | 1504 initializeWithAndroidSettings(); |
| 1454 | 1505 |
| 1455 // Initialize with browser controls showing and shrinking the Blink size. | 1506 // Initialize with browser controls showing and shrinking the Blink size. |
| 1456 webViewImpl()->resizeWithBrowserControls( | 1507 webViewImpl()->resizeWithBrowserControls( |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1507 EXPECT_SIZE_EQ(IntSize(1000, layoutViewportHeight), | 1558 EXPECT_SIZE_EQ(IntSize(1000, layoutViewportHeight), |
| 1508 frameView.frameRect().size()); | 1559 frameView.frameRect().size()); |
| 1509 EXPECT_SIZE_EQ(totalExpected, | 1560 EXPECT_SIZE_EQ(totalExpected, |
| 1510 visualViewport.scrollOffset() + | 1561 visualViewport.scrollOffset() + |
| 1511 frameView.layoutViewportScrollableArea()->scrollOffset()); | 1562 frameView.layoutViewportScrollableArea()->scrollOffset()); |
| 1512 } | 1563 } |
| 1513 | 1564 |
| 1514 // Tests that a scroll all the way to the bottom while showing the browser | 1565 // Tests that a scroll all the way to the bottom while showing the browser |
| 1515 // controls doesn't cause a clamp to the viewport scroll offset when the browser | 1566 // controls doesn't cause a clamp to the viewport scroll offset when the browser |
| 1516 // controls initiated resize occurs. | 1567 // controls initiated resize occurs. |
| 1517 TEST_P(VisualViewportTest, TestBrowserControlsShrinkAdjustmentAndResize) { | 1568 TEST_P(ParameterizedVisualViewportTest, |
| 1569 TestBrowserControlsShrinkAdjustmentAndResize) { |
| 1518 int browserControlsHeight = 20; | 1570 int browserControlsHeight = 20; |
| 1519 int visualViewportHeight = 500; | 1571 int visualViewportHeight = 500; |
| 1520 int layoutViewportHeight = 1000; | 1572 int layoutViewportHeight = 1000; |
| 1521 int contentHeight = 2000; | 1573 int contentHeight = 2000; |
| 1522 float pageScale = 2; | 1574 float pageScale = 2; |
| 1523 float minPageScale = 0.5; | 1575 float minPageScale = 0.5; |
| 1524 | 1576 |
| 1525 initializeWithAndroidSettings(); | 1577 initializeWithAndroidSettings(); |
| 1526 | 1578 |
| 1527 // Initialize with browser controls hidden and not shrinking the Blink size. | 1579 // Initialize with browser controls hidden and not shrinking the Blink size. |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1582 EXPECT_SIZE_EQ(IntSize(1000, layoutViewportHeight - | 1634 EXPECT_SIZE_EQ(IntSize(1000, layoutViewportHeight - |
| 1583 browserControlsHeight / minPageScale), | 1635 browserControlsHeight / minPageScale), |
| 1584 frameView.frameRect().size()); | 1636 frameView.frameRect().size()); |
| 1585 EXPECT_SIZE_EQ(totalExpected, | 1637 EXPECT_SIZE_EQ(totalExpected, |
| 1586 visualViewport.scrollOffset() + | 1638 visualViewport.scrollOffset() + |
| 1587 frameView.layoutViewportScrollableArea()->scrollOffset()); | 1639 frameView.layoutViewportScrollableArea()->scrollOffset()); |
| 1588 } | 1640 } |
| 1589 | 1641 |
| 1590 // Tests that a resize due to browser controls hiding doesn't incorrectly clamp | 1642 // Tests that a resize due to browser controls hiding doesn't incorrectly clamp |
| 1591 // the main frame's scroll offset. crbug.com/428193. | 1643 // the main frame's scroll offset. crbug.com/428193. |
| 1592 TEST_P(VisualViewportTest, TestTopControlHidingResizeDoesntClampMainFrame) { | 1644 TEST_P(ParameterizedVisualViewportTest, |
| 1645 TestTopControlHidingResizeDoesntClampMainFrame) { |
| 1593 initializeWithAndroidSettings(); | 1646 initializeWithAndroidSettings(); |
| 1594 webViewImpl()->resizeWithBrowserControls(webViewImpl()->size(), 500, false); | 1647 webViewImpl()->resizeWithBrowserControls(webViewImpl()->size(), 500, false); |
| 1595 webViewImpl()->applyViewportDeltas(WebFloatSize(), WebFloatSize(), | 1648 webViewImpl()->applyViewportDeltas(WebFloatSize(), WebFloatSize(), |
| 1596 WebFloatSize(), 1, 1); | 1649 WebFloatSize(), 1, 1); |
| 1597 webViewImpl()->resizeWithBrowserControls(WebSize(1000, 1000), 500, true); | 1650 webViewImpl()->resizeWithBrowserControls(WebSize(1000, 1000), 500, true); |
| 1598 | 1651 |
| 1599 registerMockedHttpURLLoad("content-width-1000.html"); | 1652 registerMockedHttpURLLoad("content-width-1000.html"); |
| 1600 navigateTo(m_baseURL + "content-width-1000.html"); | 1653 navigateTo(m_baseURL + "content-width-1000.html"); |
| 1601 | 1654 |
| 1602 // Scroll the FrameView to the bottom of the page but "hide" the browser | 1655 // Scroll the FrameView to the bottom of the page but "hide" the browser |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1616 frameView.layoutViewportScrollableArea()->scrollOffset().height()); | 1669 frameView.layoutViewportScrollableArea()->scrollOffset().height()); |
| 1617 } | 1670 } |
| 1618 | 1671 |
| 1619 static void configureHiddenScrollbarsSettings(WebSettings* settings) { | 1672 static void configureHiddenScrollbarsSettings(WebSettings* settings) { |
| 1620 VisualViewportTest::configureAndroidSettings(settings); | 1673 VisualViewportTest::configureAndroidSettings(settings); |
| 1621 settings->setHideScrollbars(true); | 1674 settings->setHideScrollbars(true); |
| 1622 } | 1675 } |
| 1623 | 1676 |
| 1624 // Tests that scrollbar layers are not attached to the inner viewport container | 1677 // Tests that scrollbar layers are not attached to the inner viewport container |
| 1625 // layer when hideScrollbars WebSetting is true. | 1678 // layer when hideScrollbars WebSetting is true. |
| 1626 TEST_P(VisualViewportTest, | 1679 TEST_P(ParameterizedVisualViewportTest, |
| 1627 TestScrollbarsNotAttachedWhenHideScrollbarsSettingIsTrue) { | 1680 TestScrollbarsNotAttachedWhenHideScrollbarsSettingIsTrue) { |
| 1628 initializeWithAndroidSettings(configureHiddenScrollbarsSettings); | 1681 initializeWithAndroidSettings(configureHiddenScrollbarsSettings); |
| 1629 webViewImpl()->resize(IntSize(100, 150)); | 1682 webViewImpl()->resize(IntSize(100, 150)); |
| 1630 navigateTo("about:blank"); | 1683 navigateTo("about:blank"); |
| 1631 | 1684 |
| 1632 VisualViewport& visualViewport = | 1685 VisualViewport& visualViewport = |
| 1633 frame()->page()->frameHost().visualViewport(); | 1686 frame()->page()->frameHost().visualViewport(); |
| 1634 EXPECT_FALSE(visualViewport.layerForHorizontalScrollbar()->parent()); | 1687 EXPECT_FALSE(visualViewport.layerForHorizontalScrollbar()->parent()); |
| 1635 EXPECT_FALSE(visualViewport.layerForVerticalScrollbar()->parent()); | 1688 EXPECT_FALSE(visualViewport.layerForVerticalScrollbar()->parent()); |
| 1636 } | 1689 } |
| 1637 | 1690 |
| 1638 // Tests that scrollbar layers are attached to the inner viewport container | 1691 // Tests that scrollbar layers are attached to the inner viewport container |
| 1639 // layer when hideScrollbars WebSetting is false. | 1692 // layer when hideScrollbars WebSetting is false. |
| 1640 TEST_P(VisualViewportTest, | 1693 TEST_P(ParameterizedVisualViewportTest, |
| 1641 TestScrollbarsAttachedWhenHideScrollbarsSettingIsFalse) { | 1694 TestScrollbarsAttachedWhenHideScrollbarsSettingIsFalse) { |
| 1642 initializeWithAndroidSettings(); | 1695 initializeWithAndroidSettings(); |
| 1643 webViewImpl()->resize(IntSize(100, 150)); | 1696 webViewImpl()->resize(IntSize(100, 150)); |
| 1644 navigateTo("about:blank"); | 1697 navigateTo("about:blank"); |
| 1645 | 1698 |
| 1646 VisualViewport& visualViewport = | 1699 VisualViewport& visualViewport = |
| 1647 frame()->page()->frameHost().visualViewport(); | 1700 frame()->page()->frameHost().visualViewport(); |
| 1648 EXPECT_TRUE(visualViewport.layerForHorizontalScrollbar()->parent()); | 1701 EXPECT_TRUE(visualViewport.layerForHorizontalScrollbar()->parent()); |
| 1649 EXPECT_TRUE(visualViewport.layerForVerticalScrollbar()->parent()); | 1702 EXPECT_TRUE(visualViewport.layerForVerticalScrollbar()->parent()); |
| 1650 } | 1703 } |
| 1651 | 1704 |
| 1652 // Tests that the layout viewport's scroll layer bounds are updated in a | 1705 // Tests that the layout viewport's scroll layer bounds are updated in a |
| 1653 // compositing change update. crbug.com/423188. | 1706 // compositing change update. crbug.com/423188. |
| 1654 TEST_P(VisualViewportTest, TestChangingContentSizeAffectsScrollBounds) { | 1707 TEST_P(ParameterizedVisualViewportTest, |
| 1708 TestChangingContentSizeAffectsScrollBounds) { |
| 1655 initializeWithAndroidSettings(); | 1709 initializeWithAndroidSettings(); |
| 1656 webViewImpl()->resize(IntSize(100, 150)); | 1710 webViewImpl()->resize(IntSize(100, 150)); |
| 1657 | 1711 |
| 1658 registerMockedHttpURLLoad("content-width-1000.html"); | 1712 registerMockedHttpURLLoad("content-width-1000.html"); |
| 1659 navigateTo(m_baseURL + "content-width-1000.html"); | 1713 navigateTo(m_baseURL + "content-width-1000.html"); |
| 1660 | 1714 |
| 1661 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView(); | 1715 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView(); |
| 1662 WebLayer* scrollLayer = frameView.layerForScrolling()->platformLayer(); | 1716 WebLayer* scrollLayer = frameView.layerForScrolling()->platformLayer(); |
| 1663 | 1717 |
| 1664 webViewImpl()->mainFrame()->executeScript( | 1718 webViewImpl()->mainFrame()->executeScript( |
| 1665 WebScriptSource("var content = document.getElementById(\"content\");" | 1719 WebScriptSource("var content = document.getElementById(\"content\");" |
| 1666 "content.style.width = \"1500px\";" | 1720 "content.style.width = \"1500px\";" |
| 1667 "content.style.height = \"2400px\";")); | 1721 "content.style.height = \"2400px\";")); |
| 1668 frameView.updateAllLifecyclePhases(); | 1722 frameView.updateAllLifecyclePhases(); |
| 1669 | 1723 |
| 1670 EXPECT_SIZE_EQ(IntSize(1500, 2400), IntSize(scrollLayer->bounds())); | 1724 EXPECT_SIZE_EQ(IntSize(1500, 2400), IntSize(scrollLayer->bounds())); |
| 1671 } | 1725 } |
| 1672 | 1726 |
| 1673 // Tests that resizing the visual viepwort keeps its bounds within the outer | 1727 // Tests that resizing the visual viepwort keeps its bounds within the outer |
| 1674 // viewport. | 1728 // viewport. |
| 1675 TEST_P(VisualViewportTest, ResizeVisualViewportStaysWithinOuterViewport) { | 1729 TEST_P(ParameterizedVisualViewportTest, |
| 1730 ResizeVisualViewportStaysWithinOuterViewport) { |
| 1676 initializeWithDesktopSettings(); | 1731 initializeWithDesktopSettings(); |
| 1677 webViewImpl()->resize(IntSize(100, 200)); | 1732 webViewImpl()->resize(IntSize(100, 200)); |
| 1678 | 1733 |
| 1679 navigateTo("about:blank"); | 1734 navigateTo("about:blank"); |
| 1680 webViewImpl()->updateAllLifecyclePhases(); | 1735 webViewImpl()->updateAllLifecyclePhases(); |
| 1681 | 1736 |
| 1682 webViewImpl()->resizeVisualViewport(IntSize(100, 100)); | 1737 webViewImpl()->resizeVisualViewport(IntSize(100, 100)); |
| 1683 | 1738 |
| 1684 VisualViewport& visualViewport = | 1739 VisualViewport& visualViewport = |
| 1685 frame()->page()->frameHost().visualViewport(); | 1740 frame()->page()->frameHost().visualViewport(); |
| 1686 visualViewport.move(ScrollOffset(0, 100)); | 1741 visualViewport.move(ScrollOffset(0, 100)); |
| 1687 | 1742 |
| 1688 EXPECT_EQ(100, visualViewport.scrollOffset().height()); | 1743 EXPECT_EQ(100, visualViewport.scrollOffset().height()); |
| 1689 | 1744 |
| 1690 webViewImpl()->resizeVisualViewport(IntSize(100, 200)); | 1745 webViewImpl()->resizeVisualViewport(IntSize(100, 200)); |
| 1691 | 1746 |
| 1692 EXPECT_EQ(0, visualViewport.scrollOffset().height()); | 1747 EXPECT_EQ(0, visualViewport.scrollOffset().height()); |
| 1693 } | 1748 } |
| 1694 | 1749 |
| 1695 TEST_P(VisualViewportTest, ElementBoundsInViewportSpaceAccountsForViewport) { | 1750 TEST_P(ParameterizedVisualViewportTest, |
| 1751 ElementBoundsInViewportSpaceAccountsForViewport) { |
| 1696 initializeWithAndroidSettings(); | 1752 initializeWithAndroidSettings(); |
| 1697 | 1753 |
| 1698 webViewImpl()->resize(IntSize(500, 800)); | 1754 webViewImpl()->resize(IntSize(500, 800)); |
| 1699 | 1755 |
| 1700 registerMockedHttpURLLoad("pinch-viewport-input-field.html"); | 1756 registerMockedHttpURLLoad("pinch-viewport-input-field.html"); |
| 1701 navigateTo(m_baseURL + "pinch-viewport-input-field.html"); | 1757 navigateTo(m_baseURL + "pinch-viewport-input-field.html"); |
| 1702 | 1758 |
| 1703 webViewImpl()->setInitialFocus(false); | 1759 webViewImpl()->setInitialFocus(false); |
| 1704 Element* inputElement = webViewImpl()->focusedElement(); | 1760 Element* inputElement = webViewImpl()->focusedElement(); |
| 1705 | 1761 |
| 1706 IntRect bounds = inputElement->layoutObject()->absoluteBoundingBoxRect(); | 1762 IntRect bounds = inputElement->layoutObject()->absoluteBoundingBoxRect(); |
| 1707 | 1763 |
| 1708 VisualViewport& visualViewport = | 1764 VisualViewport& visualViewport = |
| 1709 frame()->page()->frameHost().visualViewport(); | 1765 frame()->page()->frameHost().visualViewport(); |
| 1710 IntPoint scrollDelta(250, 400); | 1766 IntPoint scrollDelta(250, 400); |
| 1711 visualViewport.setScale(2); | 1767 visualViewport.setScale(2); |
| 1712 visualViewport.setLocation(scrollDelta); | 1768 visualViewport.setLocation(scrollDelta); |
| 1713 | 1769 |
| 1714 const IntRect boundsInViewport = inputElement->boundsInViewport(); | 1770 const IntRect boundsInViewport = inputElement->boundsInViewport(); |
| 1715 IntRect expectedBounds = bounds; | 1771 IntRect expectedBounds = bounds; |
| 1716 expectedBounds.scale(2.f); | 1772 expectedBounds.scale(2.f); |
| 1717 IntPoint expectedScrollDelta = scrollDelta; | 1773 IntPoint expectedScrollDelta = scrollDelta; |
| 1718 expectedScrollDelta.scale(2.f, 2.f); | 1774 expectedScrollDelta.scale(2.f, 2.f); |
| 1719 | 1775 |
| 1720 EXPECT_POINT_EQ(IntPoint(expectedBounds.location() - expectedScrollDelta), | 1776 EXPECT_POINT_EQ(IntPoint(expectedBounds.location() - expectedScrollDelta), |
| 1721 boundsInViewport.location()); | 1777 boundsInViewport.location()); |
| 1722 EXPECT_SIZE_EQ(expectedBounds.size(), boundsInViewport.size()); | 1778 EXPECT_SIZE_EQ(expectedBounds.size(), boundsInViewport.size()); |
| 1723 } | 1779 } |
| 1724 | 1780 |
| 1725 TEST_P(VisualViewportTest, ElementVisibleBoundsInVisualViewport) { | 1781 TEST_P(ParameterizedVisualViewportTest, ElementVisibleBoundsInVisualViewport) { |
| 1726 initializeWithAndroidSettings(); | 1782 initializeWithAndroidSettings(); |
| 1727 webViewImpl()->resize(IntSize(640, 1080)); | 1783 webViewImpl()->resize(IntSize(640, 1080)); |
| 1728 registerMockedHttpURLLoad("viewport-select.html"); | 1784 registerMockedHttpURLLoad("viewport-select.html"); |
| 1729 navigateTo(m_baseURL + "viewport-select.html"); | 1785 navigateTo(m_baseURL + "viewport-select.html"); |
| 1730 | 1786 |
| 1731 ASSERT_EQ(2.0f, webViewImpl()->pageScaleFactor()); | 1787 ASSERT_EQ(2.0f, webViewImpl()->pageScaleFactor()); |
| 1732 webViewImpl()->setInitialFocus(false); | 1788 webViewImpl()->setInitialFocus(false); |
| 1733 Element* element = webViewImpl()->focusedElement(); | 1789 Element* element = webViewImpl()->focusedElement(); |
| 1734 EXPECT_FALSE(element->visibleBoundsInVisualViewport().isEmpty()); | 1790 EXPECT_FALSE(element->visibleBoundsInVisualViewport().isEmpty()); |
| 1735 | 1791 |
| 1736 webViewImpl()->setPageScaleFactor(4.0); | 1792 webViewImpl()->setPageScaleFactor(4.0); |
| 1737 EXPECT_TRUE(element->visibleBoundsInVisualViewport().isEmpty()); | 1793 EXPECT_TRUE(element->visibleBoundsInVisualViewport().isEmpty()); |
| 1738 } | 1794 } |
| 1739 | 1795 |
| 1740 // Test that the various window.scroll and document.body.scroll properties and | 1796 // Test that the various window.scroll and document.body.scroll properties and |
| 1741 // methods work unchanged from the pre-virtual viewport mode. | 1797 // methods work unchanged from the pre-virtual viewport mode. |
| 1742 TEST_P(VisualViewportTest, bodyAndWindowScrollPropertiesAccountForViewport) { | 1798 TEST_P(ParameterizedVisualViewportTest, |
| 1799 bodyAndWindowScrollPropertiesAccountForViewport) { |
| 1743 initializeWithAndroidSettings(); | 1800 initializeWithAndroidSettings(); |
| 1744 | 1801 |
| 1745 webViewImpl()->resize(IntSize(200, 300)); | 1802 webViewImpl()->resize(IntSize(200, 300)); |
| 1746 | 1803 |
| 1747 // Load page with no main frame scrolling. | 1804 // Load page with no main frame scrolling. |
| 1748 registerMockedHttpURLLoad("200-by-300-viewport.html"); | 1805 registerMockedHttpURLLoad("200-by-300-viewport.html"); |
| 1749 navigateTo(m_baseURL + "200-by-300-viewport.html"); | 1806 navigateTo(m_baseURL + "200-by-300-viewport.html"); |
| 1750 | 1807 |
| 1751 VisualViewport& visualViewport = | 1808 VisualViewport& visualViewport = |
| 1752 frame()->page()->frameHost().visualViewport(); | 1809 frame()->page()->frameHost().visualViewport(); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1811 EXPECT_EQ(0, body->scrollLeft()); | 1868 EXPECT_EQ(0, body->scrollLeft()); |
| 1812 EXPECT_EQ(0, body->scrollTop()); | 1869 EXPECT_EQ(0, body->scrollTop()); |
| 1813 EXPECT_EQ(10, documentElement->scrollLeft()); | 1870 EXPECT_EQ(10, documentElement->scrollLeft()); |
| 1814 EXPECT_EQ(20, documentElement->scrollTop()); | 1871 EXPECT_EQ(20, documentElement->scrollTop()); |
| 1815 EXPECT_EQ(10, window->scrollX()); | 1872 EXPECT_EQ(10, window->scrollX()); |
| 1816 EXPECT_EQ(20, window->scrollY()); | 1873 EXPECT_EQ(20, window->scrollY()); |
| 1817 } | 1874 } |
| 1818 | 1875 |
| 1819 // Tests that when a new frame is created, it is created with the intended size | 1876 // Tests that when a new frame is created, it is created with the intended size |
| 1820 // (i.e. viewport at minimum scale, 100x200 / 0.5). | 1877 // (i.e. viewport at minimum scale, 100x200 / 0.5). |
| 1821 TEST_P(VisualViewportTest, TestMainFrameInitializationSizing) { | 1878 TEST_P(ParameterizedVisualViewportTest, TestMainFrameInitializationSizing) { |
| 1822 initializeWithAndroidSettings(); | 1879 initializeWithAndroidSettings(); |
| 1823 | 1880 |
| 1824 webViewImpl()->resize(IntSize(100, 200)); | 1881 webViewImpl()->resize(IntSize(100, 200)); |
| 1825 | 1882 |
| 1826 registerMockedHttpURLLoad("content-width-1000-min-scale.html"); | 1883 registerMockedHttpURLLoad("content-width-1000-min-scale.html"); |
| 1827 navigateTo(m_baseURL + "content-width-1000-min-scale.html"); | 1884 navigateTo(m_baseURL + "content-width-1000-min-scale.html"); |
| 1828 | 1885 |
| 1829 WebLocalFrameImpl* localFrame = webViewImpl()->mainFrameImpl(); | 1886 WebLocalFrameImpl* localFrame = webViewImpl()->mainFrameImpl(); |
| 1830 // The shutdown() calls are a hack to prevent this test from violating | 1887 // The shutdown() calls are a hack to prevent this test from violating |
| 1831 // invariants about frame state during navigation/detach. | 1888 // invariants about frame state during navigation/detach. |
| 1832 localFrame->frame()->document()->shutdown(); | 1889 localFrame->frame()->document()->shutdown(); |
| 1833 localFrame->createFrameView(); | 1890 localFrame->createFrameView(); |
| 1834 | 1891 |
| 1835 FrameView& frameView = *localFrame->frameView(); | 1892 FrameView& frameView = *localFrame->frameView(); |
| 1836 EXPECT_SIZE_EQ(IntSize(200, 400), frameView.frameRect().size()); | 1893 EXPECT_SIZE_EQ(IntSize(200, 400), frameView.frameRect().size()); |
| 1837 frameView.dispose(); | 1894 frameView.dispose(); |
| 1838 } | 1895 } |
| 1839 | 1896 |
| 1840 // Tests that the maximum scroll offset of the viewport can be fractional. | 1897 // Tests that the maximum scroll offset of the viewport can be fractional. |
| 1841 TEST_P(VisualViewportTest, FractionalMaxScrollOffset) { | 1898 TEST_P(ParameterizedVisualViewportTest, FractionalMaxScrollOffset) { |
| 1842 initializeWithDesktopSettings(); | 1899 initializeWithDesktopSettings(); |
| 1843 webViewImpl()->resize(IntSize(101, 201)); | 1900 webViewImpl()->resize(IntSize(101, 201)); |
| 1844 navigateTo("about:blank"); | 1901 navigateTo("about:blank"); |
| 1845 | 1902 |
| 1846 VisualViewport& visualViewport = | 1903 VisualViewport& visualViewport = |
| 1847 frame()->page()->frameHost().visualViewport(); | 1904 frame()->page()->frameHost().visualViewport(); |
| 1848 ScrollableArea* scrollableArea = &visualViewport; | 1905 ScrollableArea* scrollableArea = &visualViewport; |
| 1849 | 1906 |
| 1850 webViewImpl()->setPageScaleFactor(1.0); | 1907 webViewImpl()->setPageScaleFactor(1.0); |
| 1851 EXPECT_SIZE_EQ(ScrollOffset(), scrollableArea->maximumScrollOffset()); | 1908 EXPECT_SIZE_EQ(ScrollOffset(), scrollableArea->maximumScrollOffset()); |
| 1852 | 1909 |
| 1853 webViewImpl()->setPageScaleFactor(2); | 1910 webViewImpl()->setPageScaleFactor(2); |
| 1854 EXPECT_SIZE_EQ(ScrollOffset(101. / 2., 201. / 2.), | 1911 EXPECT_SIZE_EQ(ScrollOffset(101. / 2., 201. / 2.), |
| 1855 scrollableArea->maximumScrollOffset()); | 1912 scrollableArea->maximumScrollOffset()); |
| 1856 } | 1913 } |
| 1857 | 1914 |
| 1858 // Tests that the slow scrolling after an impl scroll on the visual viewport is | 1915 // Tests that the slow scrolling after an impl scroll on the visual viewport is |
| 1859 // continuous. crbug.com/453460 was caused by the impl-path not updating the | 1916 // continuous. crbug.com/453460 was caused by the impl-path not updating the |
| 1860 // ScrollAnimatorBase class. | 1917 // ScrollAnimatorBase class. |
| 1861 TEST_P(VisualViewportTest, SlowScrollAfterImplScroll) { | 1918 TEST_P(ParameterizedVisualViewportTest, SlowScrollAfterImplScroll) { |
| 1862 initializeWithDesktopSettings(); | 1919 initializeWithDesktopSettings(); |
| 1863 webViewImpl()->resize(IntSize(800, 600)); | 1920 webViewImpl()->resize(IntSize(800, 600)); |
| 1864 navigateTo("about:blank"); | 1921 navigateTo("about:blank"); |
| 1865 | 1922 |
| 1866 VisualViewport& visualViewport = | 1923 VisualViewport& visualViewport = |
| 1867 frame()->page()->frameHost().visualViewport(); | 1924 frame()->page()->frameHost().visualViewport(); |
| 1868 | 1925 |
| 1869 // Apply some scroll and scale from the impl-side. | 1926 // Apply some scroll and scale from the impl-side. |
| 1870 webViewImpl()->applyViewportDeltas(WebFloatSize(300, 200), WebFloatSize(0, 0), | 1927 webViewImpl()->applyViewportDeltas(WebFloatSize(300, 200), WebFloatSize(0, 0), |
| 1871 WebFloatSize(0, 0), 2, 0); | 1928 WebFloatSize(0, 0), 2, 0); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1885 | 1942 |
| 1886 // The scroll sent from the impl-side must not be overwritten. | 1943 // The scroll sent from the impl-side must not be overwritten. |
| 1887 EXPECT_SIZE_EQ(FloatSize(350, 260), visualViewport.scrollOffset()); | 1944 EXPECT_SIZE_EQ(FloatSize(350, 260), visualViewport.scrollOffset()); |
| 1888 } | 1945 } |
| 1889 | 1946 |
| 1890 static void accessibilitySettings(WebSettings* settings) { | 1947 static void accessibilitySettings(WebSettings* settings) { |
| 1891 VisualViewportTest::configureSettings(settings); | 1948 VisualViewportTest::configureSettings(settings); |
| 1892 settings->setAccessibilityEnabled(true); | 1949 settings->setAccessibilityEnabled(true); |
| 1893 } | 1950 } |
| 1894 | 1951 |
| 1895 TEST_P(VisualViewportTest, AccessibilityHitTestWhileZoomedIn) { | 1952 TEST_P(ParameterizedVisualViewportTest, AccessibilityHitTestWhileZoomedIn) { |
| 1896 initializeWithDesktopSettings(accessibilitySettings); | 1953 initializeWithDesktopSettings(accessibilitySettings); |
| 1897 | 1954 |
| 1898 registerMockedHttpURLLoad("hit-test.html"); | 1955 registerMockedHttpURLLoad("hit-test.html"); |
| 1899 navigateTo(m_baseURL + "hit-test.html"); | 1956 navigateTo(m_baseURL + "hit-test.html"); |
| 1900 | 1957 |
| 1901 webViewImpl()->resize(IntSize(500, 500)); | 1958 webViewImpl()->resize(IntSize(500, 500)); |
| 1902 webViewImpl()->updateAllLifecyclePhases(); | 1959 webViewImpl()->updateAllLifecyclePhases(); |
| 1903 | 1960 |
| 1904 WebDocument webDoc = webViewImpl()->mainFrame()->document(); | 1961 WebDocument webDoc = webViewImpl()->mainFrame()->document(); |
| 1905 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView(); | 1962 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView(); |
| 1906 | 1963 |
| 1907 webViewImpl()->setPageScaleFactor(2); | 1964 webViewImpl()->setPageScaleFactor(2); |
| 1908 webViewImpl()->setVisualViewportOffset(WebFloatPoint(200, 230)); | 1965 webViewImpl()->setVisualViewportOffset(WebFloatPoint(200, 230)); |
| 1909 frameView.layoutViewportScrollableArea()->setScrollOffset( | 1966 frameView.layoutViewportScrollableArea()->setScrollOffset( |
| 1910 ScrollOffset(400, 1100), ProgrammaticScroll); | 1967 ScrollOffset(400, 1100), ProgrammaticScroll); |
| 1911 | 1968 |
| 1912 // FIXME(504057): PaintLayerScrollableArea dirties the compositing state. | 1969 // FIXME(504057): PaintLayerScrollableArea dirties the compositing state. |
| 1913 forceFullCompositingUpdate(); | 1970 forceFullCompositingUpdate(); |
| 1914 | 1971 |
| 1915 // Because of where the visual viewport is located, this should hit the bottom | 1972 // Because of where the visual viewport is located, this should hit the bottom |
| 1916 // right target (target 4). | 1973 // right target (target 4). |
| 1917 WebAXObject hitNode = | 1974 WebAXObject hitNode = |
| 1918 webDoc.accessibilityObject().hitTest(WebPoint(154, 165)); | 1975 webDoc.accessibilityObject().hitTest(WebPoint(154, 165)); |
| 1919 WebAXNameFrom nameFrom; | 1976 WebAXNameFrom nameFrom; |
| 1920 WebVector<WebAXObject> nameObjects; | 1977 WebVector<WebAXObject> nameObjects; |
| 1921 EXPECT_EQ(std::string("Target4"), hitNode.name(nameFrom, nameObjects).utf8()); | 1978 EXPECT_EQ(std::string("Target4"), hitNode.name(nameFrom, nameObjects).utf8()); |
| 1922 } | 1979 } |
| 1923 | 1980 |
| 1924 // Tests that the maximum scroll offset of the viewport can be fractional. | 1981 // Tests that the maximum scroll offset of the viewport can be fractional. |
| 1925 TEST_P(VisualViewportTest, TestCoordinateTransforms) { | 1982 TEST_P(ParameterizedVisualViewportTest, TestCoordinateTransforms) { |
| 1926 initializeWithAndroidSettings(); | 1983 initializeWithAndroidSettings(); |
| 1927 webViewImpl()->resize(IntSize(800, 600)); | 1984 webViewImpl()->resize(IntSize(800, 600)); |
| 1928 registerMockedHttpURLLoad("content-width-1000.html"); | 1985 registerMockedHttpURLLoad("content-width-1000.html"); |
| 1929 navigateTo(m_baseURL + "content-width-1000.html"); | 1986 navigateTo(m_baseURL + "content-width-1000.html"); |
| 1930 | 1987 |
| 1931 VisualViewport& visualViewport = | 1988 VisualViewport& visualViewport = |
| 1932 webViewImpl()->page()->frameHost().visualViewport(); | 1989 webViewImpl()->page()->frameHost().visualViewport(); |
| 1933 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView(); | 1990 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView(); |
| 1934 | 1991 |
| 1935 // At scale = 1 the transform should be a no-op. | 1992 // At scale = 1 the transform should be a no-op. |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1969 EXPECT_FLOAT_POINT_EQ(FloatPoint(50, 62), visualViewport.viewportToRootFrame( | 2026 EXPECT_FLOAT_POINT_EQ(FloatPoint(50, 62), visualViewport.viewportToRootFrame( |
| 1970 FloatPoint(80, 100))); | 2027 FloatPoint(80, 100))); |
| 1971 EXPECT_FLOAT_POINT_EQ(FloatPoint(80, 100), | 2028 EXPECT_FLOAT_POINT_EQ(FloatPoint(80, 100), |
| 1972 visualViewport.rootFrameToViewport(FloatPoint(50, 62))); | 2029 visualViewport.rootFrameToViewport(FloatPoint(50, 62))); |
| 1973 } | 2030 } |
| 1974 | 2031 |
| 1975 // Tests that the window dimensions are available before a full layout occurs. | 2032 // Tests that the window dimensions are available before a full layout occurs. |
| 1976 // More specifically, it checks that the innerWidth and innerHeight window | 2033 // More specifically, it checks that the innerWidth and innerHeight window |
| 1977 // properties will trigger a layout which will cause an update to viewport | 2034 // properties will trigger a layout which will cause an update to viewport |
| 1978 // constraints and a refreshed initial scale. crbug.com/466718 | 2035 // constraints and a refreshed initial scale. crbug.com/466718 |
| 1979 TEST_P(VisualViewportTest, WindowDimensionsOnLoad) { | 2036 TEST_P(ParameterizedVisualViewportTest, WindowDimensionsOnLoad) { |
| 1980 initializeWithAndroidSettings(); | 2037 initializeWithAndroidSettings(); |
| 1981 registerMockedHttpURLLoad("window_dimensions.html"); | 2038 registerMockedHttpURLLoad("window_dimensions.html"); |
| 1982 webViewImpl()->resize(IntSize(800, 600)); | 2039 webViewImpl()->resize(IntSize(800, 600)); |
| 1983 navigateTo(m_baseURL + "window_dimensions.html"); | 2040 navigateTo(m_baseURL + "window_dimensions.html"); |
| 1984 | 2041 |
| 1985 Element* output = frame()->document()->getElementById("output"); | 2042 Element* output = frame()->document()->getElementById("output"); |
| 1986 DCHECK(output); | 2043 DCHECK(output); |
| 1987 EXPECT_EQ(std::string("1600x1200"), | 2044 EXPECT_EQ(std::string("1600x1200"), |
| 1988 std::string(output->innerHTML().ascii().data())); | 2045 std::string(output->innerHTML().ascii().data())); |
| 1989 } | 2046 } |
| 1990 | 2047 |
| 1991 // Similar to above but make sure the initial scale is updated with the content | 2048 // Similar to above but make sure the initial scale is updated with the content |
| 1992 // width for a very wide page. That is, make that innerWidth/Height actually | 2049 // width for a very wide page. That is, make that innerWidth/Height actually |
| 1993 // trigger a layout of the content, and not just an update of the viepwort. | 2050 // trigger a layout of the content, and not just an update of the viepwort. |
| 1994 // crbug.com/466718 | 2051 // crbug.com/466718 |
| 1995 TEST_P(VisualViewportTest, WindowDimensionsOnLoadWideContent) { | 2052 TEST_P(ParameterizedVisualViewportTest, WindowDimensionsOnLoadWideContent) { |
| 1996 initializeWithAndroidSettings(); | 2053 initializeWithAndroidSettings(); |
| 1997 registerMockedHttpURLLoad("window_dimensions_wide_div.html"); | 2054 registerMockedHttpURLLoad("window_dimensions_wide_div.html"); |
| 1998 webViewImpl()->resize(IntSize(800, 600)); | 2055 webViewImpl()->resize(IntSize(800, 600)); |
| 1999 navigateTo(m_baseURL + "window_dimensions_wide_div.html"); | 2056 navigateTo(m_baseURL + "window_dimensions_wide_div.html"); |
| 2000 | 2057 |
| 2001 Element* output = frame()->document()->getElementById("output"); | 2058 Element* output = frame()->document()->getElementById("output"); |
| 2002 DCHECK(output); | 2059 DCHECK(output); |
| 2003 EXPECT_EQ(std::string("2000x1500"), | 2060 EXPECT_EQ(std::string("2000x1500"), |
| 2004 std::string(output->innerHTML().ascii().data())); | 2061 std::string(output->innerHTML().ascii().data())); |
| 2005 } | 2062 } |
| 2006 | 2063 |
| 2007 TEST_P(VisualViewportTest, PinchZoomGestureScrollsVisualViewportOnly) { | 2064 TEST_P(ParameterizedVisualViewportTest, |
| 2065 PinchZoomGestureScrollsVisualViewportOnly) { |
| 2008 initializeWithDesktopSettings(); | 2066 initializeWithDesktopSettings(); |
| 2009 webViewImpl()->resize(IntSize(100, 100)); | 2067 webViewImpl()->resize(IntSize(100, 100)); |
| 2010 | 2068 |
| 2011 registerMockedHttpURLLoad("200-by-800-viewport.html"); | 2069 registerMockedHttpURLLoad("200-by-800-viewport.html"); |
| 2012 navigateTo(m_baseURL + "200-by-800-viewport.html"); | 2070 navigateTo(m_baseURL + "200-by-800-viewport.html"); |
| 2013 | 2071 |
| 2014 WebGestureEvent pinchUpdate; | 2072 WebGestureEvent pinchUpdate; |
| 2015 pinchUpdate.type = WebInputEvent::GesturePinchUpdate; | 2073 pinchUpdate.type = WebInputEvent::GesturePinchUpdate; |
| 2016 pinchUpdate.sourceDevice = WebGestureDeviceTouchpad; | 2074 pinchUpdate.sourceDevice = WebGestureDeviceTouchpad; |
| 2017 pinchUpdate.x = 100; | 2075 pinchUpdate.x = 100; |
| 2018 pinchUpdate.y = 100; | 2076 pinchUpdate.y = 100; |
| 2019 pinchUpdate.data.pinchUpdate.scale = 2; | 2077 pinchUpdate.data.pinchUpdate.scale = 2; |
| 2020 pinchUpdate.data.pinchUpdate.zoomDisabled = false; | 2078 pinchUpdate.data.pinchUpdate.zoomDisabled = false; |
| 2021 | 2079 |
| 2022 webViewImpl()->handleInputEvent(pinchUpdate); | 2080 webViewImpl()->handleInputEvent(pinchUpdate); |
| 2023 | 2081 |
| 2024 VisualViewport& visualViewport = | 2082 VisualViewport& visualViewport = |
| 2025 webViewImpl()->page()->frameHost().visualViewport(); | 2083 webViewImpl()->page()->frameHost().visualViewport(); |
| 2026 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView(); | 2084 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView(); |
| 2027 | 2085 |
| 2028 EXPECT_FLOAT_SIZE_EQ(FloatSize(50, 50), visualViewport.scrollOffset()); | 2086 EXPECT_FLOAT_SIZE_EQ(FloatSize(50, 50), visualViewport.scrollOffset()); |
| 2029 EXPECT_SIZE_EQ(ScrollOffset(0, 0), | 2087 EXPECT_SIZE_EQ(ScrollOffset(0, 0), |
| 2030 frameView.layoutViewportScrollableArea()->scrollOffset()); | 2088 frameView.layoutViewportScrollableArea()->scrollOffset()); |
| 2031 } | 2089 } |
| 2032 | 2090 |
| 2033 TEST_P(VisualViewportTest, ResizeWithScrollAnchoring) { | 2091 TEST_P(ParameterizedVisualViewportTest, ResizeWithScrollAnchoring) { |
| 2034 bool wasScrollAnchoringEnabled = | 2092 bool wasScrollAnchoringEnabled = |
| 2035 RuntimeEnabledFeatures::scrollAnchoringEnabled(); | 2093 RuntimeEnabledFeatures::scrollAnchoringEnabled(); |
| 2036 RuntimeEnabledFeatures::setScrollAnchoringEnabled(true); | 2094 RuntimeEnabledFeatures::setScrollAnchoringEnabled(true); |
| 2037 | 2095 |
| 2038 initializeWithDesktopSettings(); | 2096 initializeWithDesktopSettings(); |
| 2039 webViewImpl()->resize(IntSize(800, 600)); | 2097 webViewImpl()->resize(IntSize(800, 600)); |
| 2040 | 2098 |
| 2041 registerMockedHttpURLLoad("icb-relative-content.html"); | 2099 registerMockedHttpURLLoad("icb-relative-content.html"); |
| 2042 navigateTo(m_baseURL + "icb-relative-content.html"); | 2100 navigateTo(m_baseURL + "icb-relative-content.html"); |
| 2043 | 2101 |
| 2044 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView(); | 2102 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView(); |
| 2045 frameView.layoutViewportScrollableArea()->setScrollOffset( | 2103 frameView.layoutViewportScrollableArea()->setScrollOffset( |
| 2046 ScrollOffset(700, 500), ProgrammaticScroll); | 2104 ScrollOffset(700, 500), ProgrammaticScroll); |
| 2047 webViewImpl()->updateAllLifecyclePhases(); | 2105 webViewImpl()->updateAllLifecyclePhases(); |
| 2048 | 2106 |
| 2049 webViewImpl()->resize(IntSize(800, 300)); | 2107 webViewImpl()->resize(IntSize(800, 300)); |
| 2050 EXPECT_SIZE_EQ(ScrollOffset(700, 200), | 2108 EXPECT_SIZE_EQ(ScrollOffset(700, 200), |
| 2051 frameView.layoutViewportScrollableArea()->scrollOffset()); | 2109 frameView.layoutViewportScrollableArea()->scrollOffset()); |
| 2052 | 2110 |
| 2053 RuntimeEnabledFeatures::setScrollAnchoringEnabled(wasScrollAnchoringEnabled); | 2111 RuntimeEnabledFeatures::setScrollAnchoringEnabled(wasScrollAnchoringEnabled); |
| 2054 } | 2112 } |
| 2055 | 2113 |
| 2056 // Ensure that resize anchoring as happens when browser controls hide/show | 2114 // Ensure that resize anchoring as happens when browser controls hide/show |
| 2057 // affects the scrollable area that's currently set as the root scroller. | 2115 // affects the scrollable area that's currently set as the root scroller. |
| 2058 TEST_P(VisualViewportTest, ResizeAnchoringWithRootScroller) { | 2116 TEST_P(ParameterizedVisualViewportTest, ResizeAnchoringWithRootScroller) { |
| 2059 bool wasRootScrollerEnabled = | 2117 bool wasRootScrollerEnabled = |
| 2060 RuntimeEnabledFeatures::setRootScrollerEnabled(); | 2118 RuntimeEnabledFeatures::setRootScrollerEnabled(); |
| 2061 RuntimeEnabledFeatures::setSetRootScrollerEnabled(true); | 2119 RuntimeEnabledFeatures::setSetRootScrollerEnabled(true); |
| 2062 | 2120 |
| 2063 initializeWithAndroidSettings(); | 2121 initializeWithAndroidSettings(); |
| 2064 webViewImpl()->resize(IntSize(800, 600)); | 2122 webViewImpl()->resize(IntSize(800, 600)); |
| 2065 | 2123 |
| 2066 registerMockedHttpURLLoad("root-scroller-div.html"); | 2124 registerMockedHttpURLLoad("root-scroller-div.html"); |
| 2067 navigateTo(m_baseURL + "root-scroller-div.html"); | 2125 navigateTo(m_baseURL + "root-scroller-div.html"); |
| 2068 | 2126 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 2083 webViewImpl()->resize(IntSize(800, 500)); | 2141 webViewImpl()->resize(IntSize(800, 500)); |
| 2084 | 2142 |
| 2085 EXPECT_SIZE_EQ(ScrollOffset(), | 2143 EXPECT_SIZE_EQ(ScrollOffset(), |
| 2086 frameView.layoutViewportScrollableArea()->scrollOffset()); | 2144 frameView.layoutViewportScrollableArea()->scrollOffset()); |
| 2087 | 2145 |
| 2088 RuntimeEnabledFeatures::setSetRootScrollerEnabled(wasRootScrollerEnabled); | 2146 RuntimeEnabledFeatures::setSetRootScrollerEnabled(wasRootScrollerEnabled); |
| 2089 } | 2147 } |
| 2090 | 2148 |
| 2091 // Ensure that resize anchoring as happens when the device is rotated affects | 2149 // Ensure that resize anchoring as happens when the device is rotated affects |
| 2092 // the scrollable area that's currently set as the root scroller. | 2150 // the scrollable area that's currently set as the root scroller. |
| 2093 TEST_P(VisualViewportTest, RotationAnchoringWithRootScroller) { | 2151 TEST_P(ParameterizedVisualViewportTest, RotationAnchoringWithRootScroller) { |
| 2094 bool wasRootScrollerEnabled = | 2152 bool wasRootScrollerEnabled = |
| 2095 RuntimeEnabledFeatures::setRootScrollerEnabled(); | 2153 RuntimeEnabledFeatures::setRootScrollerEnabled(); |
| 2096 RuntimeEnabledFeatures::setSetRootScrollerEnabled(true); | 2154 RuntimeEnabledFeatures::setSetRootScrollerEnabled(true); |
| 2097 | 2155 |
| 2098 initializeWithAndroidSettings(); | 2156 initializeWithAndroidSettings(); |
| 2099 webViewImpl()->resize(IntSize(800, 600)); | 2157 webViewImpl()->resize(IntSize(800, 600)); |
| 2100 | 2158 |
| 2101 registerMockedHttpURLLoad("root-scroller-div.html"); | 2159 registerMockedHttpURLLoad("root-scroller-div.html"); |
| 2102 navigateTo(m_baseURL + "root-scroller-div.html"); | 2160 navigateTo(m_baseURL + "root-scroller-div.html"); |
| 2103 | 2161 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 2123 settings->setAcceleratedCompositingEnabled(true); | 2181 settings->setAcceleratedCompositingEnabled(true); |
| 2124 settings->setPreferCompositingToLCDTextEnabled(true); | 2182 settings->setPreferCompositingToLCDTextEnabled(true); |
| 2125 settings->setViewportMetaEnabled(true); | 2183 settings->setViewportMetaEnabled(true); |
| 2126 settings->setViewportEnabled(true); | 2184 settings->setViewportEnabled(true); |
| 2127 settings->setMainFrameResizesAreOrientationChanges(true); | 2185 settings->setMainFrameResizesAreOrientationChanges(true); |
| 2128 settings->setShrinksViewportContentToFit(true); | 2186 settings->setShrinksViewportContentToFit(true); |
| 2129 } | 2187 } |
| 2130 | 2188 |
| 2131 // Make sure a composited background-attachment:fixed background gets resized | 2189 // Make sure a composited background-attachment:fixed background gets resized |
| 2132 // when using inert (non-layout affecting) browser controls. | 2190 // when using inert (non-layout affecting) browser controls. |
| 2133 TEST_P(VisualViewportTest, ResizeCompositedAndFixedBackground) { | 2191 TEST_P(ParameterizedVisualViewportTest, ResizeCompositedAndFixedBackground) { |
| 2134 bool originalInertTopControls = | 2192 bool originalInertTopControls = |
| 2135 RuntimeEnabledFeatures::inertTopControlsEnabled(); | 2193 RuntimeEnabledFeatures::inertTopControlsEnabled(); |
| 2136 RuntimeEnabledFeatures::setInertTopControlsEnabled(true); | 2194 RuntimeEnabledFeatures::setInertTopControlsEnabled(true); |
| 2137 | 2195 |
| 2138 std::unique_ptr<FrameTestHelpers::TestWebViewClient> | 2196 std::unique_ptr<FrameTestHelpers::TestWebViewClient> |
| 2139 fakeCompositingWebViewClient = | 2197 fakeCompositingWebViewClient = |
| 2140 wrapUnique(new FrameTestHelpers::TestWebViewClient()); | 2198 wrapUnique(new FrameTestHelpers::TestWebViewClient()); |
| 2141 FrameTestHelpers::WebViewHelper webViewHelper; | 2199 FrameTestHelpers::WebViewHelper webViewHelper; |
| 2142 WebViewImpl* webViewImpl = webViewHelper.initialize( | 2200 WebViewImpl* webViewImpl = webViewHelper.initialize( |
| 2143 true, nullptr, fakeCompositingWebViewClient.get(), nullptr, | 2201 true, nullptr, fakeCompositingWebViewClient.get(), nullptr, |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2210 settings->setAcceleratedCompositingEnabled(true); | 2268 settings->setAcceleratedCompositingEnabled(true); |
| 2211 settings->setPreferCompositingToLCDTextEnabled(false); | 2269 settings->setPreferCompositingToLCDTextEnabled(false); |
| 2212 settings->setViewportMetaEnabled(true); | 2270 settings->setViewportMetaEnabled(true); |
| 2213 settings->setViewportEnabled(true); | 2271 settings->setViewportEnabled(true); |
| 2214 settings->setMainFrameResizesAreOrientationChanges(true); | 2272 settings->setMainFrameResizesAreOrientationChanges(true); |
| 2215 settings->setShrinksViewportContentToFit(true); | 2273 settings->setShrinksViewportContentToFit(true); |
| 2216 } | 2274 } |
| 2217 | 2275 |
| 2218 // Make sure a non-composited background-attachment:fixed background gets | 2276 // Make sure a non-composited background-attachment:fixed background gets |
| 2219 // resized when using inert (non-layout affecting) browser controls. | 2277 // resized when using inert (non-layout affecting) browser controls. |
| 2220 TEST_P(VisualViewportTest, ResizeNonCompositedAndFixedBackground) { | 2278 TEST_P(ParameterizedVisualViewportTest, ResizeNonCompositedAndFixedBackground) { |
| 2221 bool originalInertTopControls = | 2279 bool originalInertTopControls = |
| 2222 RuntimeEnabledFeatures::inertTopControlsEnabled(); | 2280 RuntimeEnabledFeatures::inertTopControlsEnabled(); |
| 2223 RuntimeEnabledFeatures::setInertTopControlsEnabled(true); | 2281 RuntimeEnabledFeatures::setInertTopControlsEnabled(true); |
| 2224 | 2282 |
| 2225 FrameTestHelpers::WebViewHelper webViewHelper; | 2283 FrameTestHelpers::WebViewHelper webViewHelper; |
| 2226 WebViewImpl* webViewImpl = webViewHelper.initialize( | 2284 WebViewImpl* webViewImpl = webViewHelper.initialize( |
| 2227 true, nullptr, nullptr, nullptr, &configureAndroidNonCompositing); | 2285 true, nullptr, nullptr, nullptr, &configureAndroidNonCompositing); |
| 2228 | 2286 |
| 2229 int pageWidth = 640; | 2287 int pageWidth = 640; |
| 2230 int pageHeight = 480; | 2288 int pageHeight = 480; |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2313 expectedHeight = rootLayerScrolling ? 480 : 1000; | 2371 expectedHeight = rootLayerScrolling ? 480 : 1000; |
| 2314 EXPECT_EQ(1u, rasterInvalidations->size()); | 2372 EXPECT_EQ(1u, rasterInvalidations->size()); |
| 2315 EXPECT_EQ(IntRect(0, 0, 640, expectedHeight), (*rasterInvalidations)[0].rect); | 2373 EXPECT_EQ(IntRect(0, 0, 640, expectedHeight), (*rasterInvalidations)[0].rect); |
| 2316 | 2374 |
| 2317 document->view()->setTracksPaintInvalidations(false); | 2375 document->view()->setTracksPaintInvalidations(false); |
| 2318 RuntimeEnabledFeatures::setInertTopControlsEnabled(originalInertTopControls); | 2376 RuntimeEnabledFeatures::setInertTopControlsEnabled(originalInertTopControls); |
| 2319 } | 2377 } |
| 2320 | 2378 |
| 2321 // Make sure a browser control resize with background-attachment:not-fixed | 2379 // Make sure a browser control resize with background-attachment:not-fixed |
| 2322 // background doesn't cause invalidation or layout. | 2380 // background doesn't cause invalidation or layout. |
| 2323 TEST_P(VisualViewportTest, ResizeNonFixedBackgroundNoLayoutOrInvalidation) { | 2381 TEST_P(ParameterizedVisualViewportTest, |
| 2382 ResizeNonFixedBackgroundNoLayoutOrInvalidation) { |
| 2324 bool originalInertTopControls = | 2383 bool originalInertTopControls = |
| 2325 RuntimeEnabledFeatures::inertTopControlsEnabled(); | 2384 RuntimeEnabledFeatures::inertTopControlsEnabled(); |
| 2326 RuntimeEnabledFeatures::setInertTopControlsEnabled(true); | 2385 RuntimeEnabledFeatures::setInertTopControlsEnabled(true); |
| 2327 | 2386 |
| 2328 std::unique_ptr<FrameTestHelpers::TestWebViewClient> | 2387 std::unique_ptr<FrameTestHelpers::TestWebViewClient> |
| 2329 fakeCompositingWebViewClient = | 2388 fakeCompositingWebViewClient = |
| 2330 wrapUnique(new FrameTestHelpers::TestWebViewClient()); | 2389 wrapUnique(new FrameTestHelpers::TestWebViewClient()); |
| 2331 FrameTestHelpers::WebViewHelper webViewHelper; | 2390 FrameTestHelpers::WebViewHelper webViewHelper; |
| 2332 WebViewImpl* webViewImpl = webViewHelper.initialize( | 2391 WebViewImpl* webViewImpl = webViewHelper.initialize( |
| 2333 true, nullptr, fakeCompositingWebViewClient.get(), nullptr, | 2392 true, nullptr, fakeCompositingWebViewClient.get(), nullptr, |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2397 if (rootLayerScrolling) | 2456 if (rootLayerScrolling) |
| 2398 EXPECT_TRUE(invalidationTracking); | 2457 EXPECT_TRUE(invalidationTracking); |
| 2399 else | 2458 else |
| 2400 EXPECT_FALSE(invalidationTracking); | 2459 EXPECT_FALSE(invalidationTracking); |
| 2401 | 2460 |
| 2402 document->view()->setTracksPaintInvalidations(false); | 2461 document->view()->setTracksPaintInvalidations(false); |
| 2403 RuntimeEnabledFeatures::setInertTopControlsEnabled(originalInertTopControls); | 2462 RuntimeEnabledFeatures::setInertTopControlsEnabled(originalInertTopControls); |
| 2404 } | 2463 } |
| 2405 | 2464 |
| 2406 } // namespace | 2465 } // namespace |
| OLD | NEW |