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