| 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/FrameHost.h" | 8 #include "core/frame/FrameHost.h" |
| 9 #include "core/frame/FrameView.h" | 9 #include "core/frame/FrameView.h" |
| 10 #include "core/frame/LocalFrame.h" | 10 #include "core/frame/LocalFrame.h" |
| (...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 422 | 422 |
| 423 navigateTo("about:blank"); | 423 navigateTo("about:blank"); |
| 424 webViewImpl()->updateAllLifecyclePhases(); | 424 webViewImpl()->updateAllLifecyclePhases(); |
| 425 | 425 |
| 426 VisualViewport& visualViewport = | 426 VisualViewport& visualViewport = |
| 427 frame()->page()->frameHost().visualViewport(); | 427 frame()->page()->frameHost().visualViewport(); |
| 428 EXPECT_FLOAT_SIZE_EQ(FloatSize(320, 240), | 428 EXPECT_FLOAT_SIZE_EQ(FloatSize(320, 240), |
| 429 visualViewport.containerLayer()->size()); | 429 visualViewport.containerLayer()->size()); |
| 430 } | 430 } |
| 431 | 431 |
| 432 // Make sure that the visibleRect method acurately reflects the scale and scroll
location | 432 // Make sure that the visibleRect method acurately reflects the scale and scroll |
| 433 // of the viewport. | 433 // location of the viewport. |
| 434 TEST_P(ParameterizedVisualViewportTest, TestVisibleRect) { | 434 TEST_P(ParameterizedVisualViewportTest, TestVisibleRect) { |
| 435 initializeWithDesktopSettings(); | 435 initializeWithDesktopSettings(); |
| 436 webViewImpl()->resize(IntSize(320, 240)); | 436 webViewImpl()->resize(IntSize(320, 240)); |
| 437 | 437 |
| 438 navigateTo("about:blank"); | 438 navigateTo("about:blank"); |
| 439 forceFullCompositingUpdate(); | 439 forceFullCompositingUpdate(); |
| 440 | 440 |
| 441 VisualViewport& visualViewport = | 441 VisualViewport& visualViewport = |
| 442 frame()->page()->frameHost().visualViewport(); | 442 frame()->page()->frameHost().visualViewport(); |
| 443 | 443 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 491 | 491 |
| 492 VisualViewport& visualViewport = | 492 VisualViewport& visualViewport = |
| 493 frame()->page()->frameHost().visualViewport(); | 493 frame()->page()->frameHost().visualViewport(); |
| 494 | 494 |
| 495 // Scale the viewport to 2X and move it. | 495 // Scale the viewport to 2X and move it. |
| 496 visualViewport.setScale(2); | 496 visualViewport.setScale(2); |
| 497 visualViewport.setLocation(FloatPoint(10, 15)); | 497 visualViewport.setLocation(FloatPoint(10, 15)); |
| 498 EXPECT_FLOAT_RECT_EQ(FloatRect(10, 15, 50, 200), | 498 EXPECT_FLOAT_RECT_EQ(FloatRect(10, 15, 50, 200), |
| 499 visualViewport.visibleRectInDocument()); | 499 visualViewport.visibleRectInDocument()); |
| 500 | 500 |
| 501 // Scroll the layout viewport. Ensure its offset is reflected in visibleRectIn
Document(). | 501 // Scroll the layout viewport. Ensure its offset is reflected in |
| 502 // visibleRectInDocument(). |
| 502 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView(); | 503 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView(); |
| 503 frameView.layoutViewportScrollableArea()->setScrollPosition( | 504 frameView.layoutViewportScrollableArea()->setScrollPosition( |
| 504 DoublePoint(40, 100), ProgrammaticScroll); | 505 DoublePoint(40, 100), ProgrammaticScroll); |
| 505 EXPECT_FLOAT_RECT_EQ(FloatRect(50, 115, 50, 200), | 506 EXPECT_FLOAT_RECT_EQ(FloatRect(50, 115, 50, 200), |
| 506 visualViewport.visibleRectInDocument()); | 507 visualViewport.visibleRectInDocument()); |
| 507 } | 508 } |
| 508 | 509 |
| 509 TEST_P(ParameterizedVisualViewportTest, | 510 TEST_P(ParameterizedVisualViewportTest, |
| 510 TestFractionalScrollOffsetIsNotOverwritten) { | 511 TestFractionalScrollOffsetIsNotOverwritten) { |
| 511 bool origFractionalOffsetsEnabled = | 512 bool origFractionalOffsetsEnabled = |
| (...skipping 13 matching lines...) Expand all Loading... |
| 525 DoublePoint(10, 30.5), CompositorScroll); | 526 DoublePoint(10, 30.5), CompositorScroll); |
| 526 | 527 |
| 527 EXPECT_EQ( | 528 EXPECT_EQ( |
| 528 30.5, | 529 30.5, |
| 529 frameView.layoutViewportScrollableArea()->scrollPositionDouble().y()); | 530 frameView.layoutViewportScrollableArea()->scrollPositionDouble().y()); |
| 530 | 531 |
| 531 RuntimeEnabledFeatures::setFractionalScrollOffsetsEnabled( | 532 RuntimeEnabledFeatures::setFractionalScrollOffsetsEnabled( |
| 532 origFractionalOffsetsEnabled); | 533 origFractionalOffsetsEnabled); |
| 533 } | 534 } |
| 534 | 535 |
| 535 // Test that the viewport's scroll offset is always appropriately bounded such t
hat the | 536 // Test that the viewport's scroll offset is always appropriately bounded such |
| 536 // visual viewport always stays within the bounds of the main frame. | 537 // that the visual viewport always stays within the bounds of the main frame. |
| 537 TEST_P(ParameterizedVisualViewportTest, TestOffsetClamping) { | 538 TEST_P(ParameterizedVisualViewportTest, TestOffsetClamping) { |
| 538 initializeWithDesktopSettings(); | 539 initializeWithDesktopSettings(); |
| 539 webViewImpl()->resize(IntSize(320, 240)); | 540 webViewImpl()->resize(IntSize(320, 240)); |
| 540 | 541 |
| 541 navigateTo("about:blank"); | 542 navigateTo("about:blank"); |
| 542 forceFullCompositingUpdate(); | 543 forceFullCompositingUpdate(); |
| 543 | 544 |
| 544 // Visual viewport should be initialized to same size as frame so no scrolling
possible. | 545 // Visual viewport should be initialized to same size as frame so no scrolling |
| 546 // possible. |
| 545 VisualViewport& visualViewport = | 547 VisualViewport& visualViewport = |
| 546 frame()->page()->frameHost().visualViewport(); | 548 frame()->page()->frameHost().visualViewport(); |
| 547 EXPECT_FLOAT_POINT_EQ(FloatPoint(0, 0), | 549 EXPECT_FLOAT_POINT_EQ(FloatPoint(0, 0), |
| 548 visualViewport.visibleRect().location()); | 550 visualViewport.visibleRect().location()); |
| 549 | 551 |
| 550 visualViewport.setLocation(FloatPoint(-1, -2)); | 552 visualViewport.setLocation(FloatPoint(-1, -2)); |
| 551 EXPECT_FLOAT_POINT_EQ(FloatPoint(0, 0), | 553 EXPECT_FLOAT_POINT_EQ(FloatPoint(0, 0), |
| 552 visualViewport.visibleRect().location()); | 554 visualViewport.visibleRect().location()); |
| 553 | 555 |
| 554 visualViewport.setLocation(FloatPoint(100, 200)); | 556 visualViewport.setLocation(FloatPoint(100, 200)); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 566 EXPECT_FLOAT_POINT_EQ(location, visualViewport.visibleRect().location()); | 568 EXPECT_FLOAT_POINT_EQ(location, visualViewport.visibleRect().location()); |
| 567 | 569 |
| 568 visualViewport.setLocation(FloatPoint(1000, 2000)); | 570 visualViewport.setLocation(FloatPoint(1000, 2000)); |
| 569 EXPECT_FLOAT_POINT_EQ(FloatPoint(160, 120), | 571 EXPECT_FLOAT_POINT_EQ(FloatPoint(160, 120), |
| 570 visualViewport.visibleRect().location()); | 572 visualViewport.visibleRect().location()); |
| 571 | 573 |
| 572 visualViewport.setLocation(FloatPoint(-1000, -2000)); | 574 visualViewport.setLocation(FloatPoint(-1000, -2000)); |
| 573 EXPECT_FLOAT_POINT_EQ(FloatPoint(0, 0), | 575 EXPECT_FLOAT_POINT_EQ(FloatPoint(0, 0), |
| 574 visualViewport.visibleRect().location()); | 576 visualViewport.visibleRect().location()); |
| 575 | 577 |
| 576 // Make sure offset gets clamped on scale out. Scale to 1.25 so the viewport i
s 256x192. | 578 // Make sure offset gets clamped on scale out. Scale to 1.25 so the viewport |
| 579 // is 256x192. |
| 577 visualViewport.setLocation(FloatPoint(160, 120)); | 580 visualViewport.setLocation(FloatPoint(160, 120)); |
| 578 visualViewport.setScale(1.25); | 581 visualViewport.setScale(1.25); |
| 579 EXPECT_FLOAT_POINT_EQ(FloatPoint(64, 48), | 582 EXPECT_FLOAT_POINT_EQ(FloatPoint(64, 48), |
| 580 visualViewport.visibleRect().location()); | 583 visualViewport.visibleRect().location()); |
| 581 | 584 |
| 582 // Scale out smaller than 1. | 585 // Scale out smaller than 1. |
| 583 visualViewport.setScale(0.25); | 586 visualViewport.setScale(0.25); |
| 584 EXPECT_FLOAT_POINT_EQ(FloatPoint(0, 0), | 587 EXPECT_FLOAT_POINT_EQ(FloatPoint(0, 0), |
| 585 visualViewport.visibleRect().location()); | 588 visualViewport.visibleRect().location()); |
| 586 } | 589 } |
| 587 | 590 |
| 588 // Test that the viewport can be scrolled around only within the main frame in t
he presence | 591 // Test that the viewport can be scrolled around only within the main frame in |
| 589 // of viewport resizes, as would be the case if the on screen keyboard came up. | 592 // the presence of viewport resizes, as would be the case if the on screen |
| 593 // keyboard came up. |
| 590 TEST_P(ParameterizedVisualViewportTest, TestOffsetClampingWithResize) { | 594 TEST_P(ParameterizedVisualViewportTest, TestOffsetClampingWithResize) { |
| 591 initializeWithDesktopSettings(); | 595 initializeWithDesktopSettings(); |
| 592 webViewImpl()->resize(IntSize(320, 240)); | 596 webViewImpl()->resize(IntSize(320, 240)); |
| 593 | 597 |
| 594 navigateTo("about:blank"); | 598 navigateTo("about:blank"); |
| 595 forceFullCompositingUpdate(); | 599 forceFullCompositingUpdate(); |
| 596 | 600 |
| 597 // Visual viewport should be initialized to same size as frame so no scrolling
possible. | 601 // Visual viewport should be initialized to same size as frame so no scrolling |
| 602 // possible. |
| 598 VisualViewport& visualViewport = | 603 VisualViewport& visualViewport = |
| 599 frame()->page()->frameHost().visualViewport(); | 604 frame()->page()->frameHost().visualViewport(); |
| 600 EXPECT_FLOAT_POINT_EQ(FloatPoint(0, 0), | 605 EXPECT_FLOAT_POINT_EQ(FloatPoint(0, 0), |
| 601 visualViewport.visibleRect().location()); | 606 visualViewport.visibleRect().location()); |
| 602 | 607 |
| 603 // Shrink the viewport vertically. The resize shouldn't affect the location, b
ut it | 608 // Shrink the viewport vertically. The resize shouldn't affect the location, |
| 604 // should allow vertical scrolling. | 609 // but it should allow vertical scrolling. |
| 605 visualViewport.setSize(IntSize(320, 200)); | 610 visualViewport.setSize(IntSize(320, 200)); |
| 606 EXPECT_FLOAT_POINT_EQ(FloatPoint(0, 0), | 611 EXPECT_FLOAT_POINT_EQ(FloatPoint(0, 0), |
| 607 visualViewport.visibleRect().location()); | 612 visualViewport.visibleRect().location()); |
| 608 visualViewport.setLocation(FloatPoint(10, 20)); | 613 visualViewport.setLocation(FloatPoint(10, 20)); |
| 609 EXPECT_FLOAT_POINT_EQ(FloatPoint(0, 20), | 614 EXPECT_FLOAT_POINT_EQ(FloatPoint(0, 20), |
| 610 visualViewport.visibleRect().location()); | 615 visualViewport.visibleRect().location()); |
| 611 visualViewport.setLocation(FloatPoint(0, 100)); | 616 visualViewport.setLocation(FloatPoint(0, 100)); |
| 612 EXPECT_FLOAT_POINT_EQ(FloatPoint(0, 40), | 617 EXPECT_FLOAT_POINT_EQ(FloatPoint(0, 40), |
| 613 visualViewport.visibleRect().location()); | 618 visualViewport.visibleRect().location()); |
| 614 visualViewport.setLocation(FloatPoint(0, 10)); | 619 visualViewport.setLocation(FloatPoint(0, 10)); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 646 EXPECT_FLOAT_POINT_EQ(FloatPoint(40, 40), | 651 EXPECT_FLOAT_POINT_EQ(FloatPoint(40, 40), |
| 647 visualViewport.visibleRect().location()); | 652 visualViewport.visibleRect().location()); |
| 648 visualViewport.setLocation(FloatPoint(10, 3)); | 653 visualViewport.setLocation(FloatPoint(10, 3)); |
| 649 EXPECT_FLOAT_POINT_EQ(FloatPoint(10, 3), | 654 EXPECT_FLOAT_POINT_EQ(FloatPoint(10, 3), |
| 650 visualViewport.visibleRect().location()); | 655 visualViewport.visibleRect().location()); |
| 651 visualViewport.setLocation(FloatPoint(-10, -4)); | 656 visualViewport.setLocation(FloatPoint(-10, -4)); |
| 652 EXPECT_FLOAT_POINT_EQ(FloatPoint(0, 0), | 657 EXPECT_FLOAT_POINT_EQ(FloatPoint(0, 0), |
| 653 visualViewport.visibleRect().location()); | 658 visualViewport.visibleRect().location()); |
| 654 } | 659 } |
| 655 | 660 |
| 656 // Test that the viewport is scrollable but bounded appropriately within the mai
n frame | 661 // Test that the viewport is scrollable but bounded appropriately within the |
| 657 // when we apply both scaling and resizes. | 662 // main frame when we apply both scaling and resizes. |
| 658 TEST_P(ParameterizedVisualViewportTest, TestOffsetClampingWithResizeAndScale) { | 663 TEST_P(ParameterizedVisualViewportTest, TestOffsetClampingWithResizeAndScale) { |
| 659 initializeWithDesktopSettings(); | 664 initializeWithDesktopSettings(); |
| 660 webViewImpl()->resize(IntSize(320, 240)); | 665 webViewImpl()->resize(IntSize(320, 240)); |
| 661 | 666 |
| 662 navigateTo("about:blank"); | 667 navigateTo("about:blank"); |
| 663 forceFullCompositingUpdate(); | 668 forceFullCompositingUpdate(); |
| 664 | 669 |
| 665 // Visual viewport should be initialized to same size as WebView so no scrolli
ng possible. | 670 // Visual viewport should be initialized to same size as WebView so no |
| 671 // scrolling possible. |
| 666 VisualViewport& visualViewport = | 672 VisualViewport& visualViewport = |
| 667 frame()->page()->frameHost().visualViewport(); | 673 frame()->page()->frameHost().visualViewport(); |
| 668 EXPECT_FLOAT_POINT_EQ(FloatPoint(0, 0), | 674 EXPECT_FLOAT_POINT_EQ(FloatPoint(0, 0), |
| 669 visualViewport.visibleRect().location()); | 675 visualViewport.visibleRect().location()); |
| 670 | 676 |
| 671 // Zoom in to 2X so we can scroll the viewport to 160x120. | 677 // Zoom in to 2X so we can scroll the viewport to 160x120. |
| 672 visualViewport.setScale(2); | 678 visualViewport.setScale(2); |
| 673 visualViewport.setLocation(FloatPoint(200, 200)); | 679 visualViewport.setLocation(FloatPoint(200, 200)); |
| 674 EXPECT_FLOAT_POINT_EQ(FloatPoint(160, 120), | 680 EXPECT_FLOAT_POINT_EQ(FloatPoint(160, 120), |
| 675 visualViewport.visibleRect().location()); | 681 visualViewport.visibleRect().location()); |
| 676 | 682 |
| 677 // Now resize the viewport to make it 10px smaller. Since we're zoomed in by 2
X it should | 683 // Now resize the viewport to make it 10px smaller. Since we're zoomed in by |
| 678 // allow us to scroll by 5px more. | 684 // 2X it should allow us to scroll by 5px more. |
| 679 visualViewport.setSize(IntSize(310, 230)); | 685 visualViewport.setSize(IntSize(310, 230)); |
| 680 visualViewport.setLocation(FloatPoint(200, 200)); | 686 visualViewport.setLocation(FloatPoint(200, 200)); |
| 681 EXPECT_FLOAT_POINT_EQ(FloatPoint(165, 125), | 687 EXPECT_FLOAT_POINT_EQ(FloatPoint(165, 125), |
| 682 visualViewport.visibleRect().location()); | 688 visualViewport.visibleRect().location()); |
| 683 | 689 |
| 684 // The viewport can be larger than the main frame (currently 320, 240) though
typically | 690 // The viewport can be larger than the main frame (currently 320, 240) though |
| 685 // the scale will be clamped to prevent it from actually being larger. | 691 // typically the scale will be clamped to prevent it from actually being |
| 692 // larger. |
| 686 visualViewport.setSize(IntSize(330, 250)); | 693 visualViewport.setSize(IntSize(330, 250)); |
| 687 EXPECT_SIZE_EQ(IntSize(330, 250), visualViewport.size()); | 694 EXPECT_SIZE_EQ(IntSize(330, 250), visualViewport.size()); |
| 688 | 695 |
| 689 // Resize both the viewport and the frame to be larger. | 696 // Resize both the viewport and the frame to be larger. |
| 690 webViewImpl()->resize(IntSize(640, 480)); | 697 webViewImpl()->resize(IntSize(640, 480)); |
| 691 webViewImpl()->updateAllLifecyclePhases(); | 698 webViewImpl()->updateAllLifecyclePhases(); |
| 692 EXPECT_SIZE_EQ(IntSize(webViewImpl()->size()), visualViewport.size()); | 699 EXPECT_SIZE_EQ(IntSize(webViewImpl()->size()), visualViewport.size()); |
| 693 EXPECT_SIZE_EQ(IntSize(webViewImpl()->size()), | 700 EXPECT_SIZE_EQ(IntSize(webViewImpl()->size()), |
| 694 frame()->view()->frameRect().size()); | 701 frame()->view()->frameRect().size()); |
| 695 visualViewport.setLocation(FloatPoint(1000, 1000)); | 702 visualViewport.setLocation(FloatPoint(1000, 1000)); |
| 696 EXPECT_FLOAT_POINT_EQ(FloatPoint(320, 240), | 703 EXPECT_FLOAT_POINT_EQ(FloatPoint(320, 240), |
| 697 visualViewport.visibleRect().location()); | 704 visualViewport.visibleRect().location()); |
| 698 | 705 |
| 699 // Make sure resizing the viewport doesn't change its offset if the resize doe
sn't make | 706 // Make sure resizing the viewport doesn't change its offset if the resize |
| 700 // the viewport go out of bounds. | 707 // doesn't make the viewport go out of bounds. |
| 701 visualViewport.setLocation(FloatPoint(200, 200)); | 708 visualViewport.setLocation(FloatPoint(200, 200)); |
| 702 visualViewport.setSize(IntSize(880, 560)); | 709 visualViewport.setSize(IntSize(880, 560)); |
| 703 EXPECT_FLOAT_POINT_EQ(FloatPoint(200, 200), | 710 EXPECT_FLOAT_POINT_EQ(FloatPoint(200, 200), |
| 704 visualViewport.visibleRect().location()); | 711 visualViewport.visibleRect().location()); |
| 705 } | 712 } |
| 706 | 713 |
| 707 // The main FrameView's size should be set such that its the size of the visual
viewport | 714 // The main FrameView's size should be set such that its the size of the visual |
| 708 // at minimum scale. If there's no explicit minimum scale set, the FrameView sho
uld be | 715 // viewport at minimum scale. If there's no explicit minimum scale set, the |
| 709 // set to the content width and height derived by the aspect ratio. | 716 // FrameView should be set to the content width and height derived by the aspect |
| 717 // ratio. |
| 710 TEST_P(ParameterizedVisualViewportTest, TestFrameViewSizedToContent) { | 718 TEST_P(ParameterizedVisualViewportTest, TestFrameViewSizedToContent) { |
| 711 initializeWithAndroidSettings(); | 719 initializeWithAndroidSettings(); |
| 712 webViewImpl()->resize(IntSize(320, 240)); | 720 webViewImpl()->resize(IntSize(320, 240)); |
| 713 | 721 |
| 714 registerMockedHttpURLLoad("200-by-300-viewport.html"); | 722 registerMockedHttpURLLoad("200-by-300-viewport.html"); |
| 715 navigateTo(m_baseURL + "200-by-300-viewport.html"); | 723 navigateTo(m_baseURL + "200-by-300-viewport.html"); |
| 716 | 724 |
| 717 webViewImpl()->resize(IntSize(600, 800)); | 725 webViewImpl()->resize(IntSize(600, 800)); |
| 718 webViewImpl()->updateAllLifecyclePhases(); | 726 webViewImpl()->updateAllLifecyclePhases(); |
| 719 | 727 |
| 720 // Note: the size is ceiled and should match the behavior in CC's LayerImpl::b
ounds(). | 728 // Note: the size is ceiled and should match the behavior in CC's |
| 729 // LayerImpl::bounds(). |
| 721 EXPECT_SIZE_EQ( | 730 EXPECT_SIZE_EQ( |
| 722 IntSize(200, 267), | 731 IntSize(200, 267), |
| 723 webViewImpl()->mainFrameImpl()->frameView()->frameRect().size()); | 732 webViewImpl()->mainFrameImpl()->frameView()->frameRect().size()); |
| 724 } | 733 } |
| 725 | 734 |
| 726 // The main FrameView's size should be set such that its the size of the visual
viewport | 735 // The main FrameView's size should be set such that its the size of the visual |
| 727 // at minimum scale. On Desktop, the minimum scale is set at 1 so make sure the
FrameView | 736 // viewport at minimum scale. On Desktop, the minimum scale is set at 1 so make |
| 728 // is sized to the viewport. | 737 // sure the FrameView is sized to the viewport. |
| 729 TEST_P(ParameterizedVisualViewportTest, TestFrameViewSizedToMinimumScale) { | 738 TEST_P(ParameterizedVisualViewportTest, TestFrameViewSizedToMinimumScale) { |
| 730 initializeWithDesktopSettings(); | 739 initializeWithDesktopSettings(); |
| 731 webViewImpl()->resize(IntSize(320, 240)); | 740 webViewImpl()->resize(IntSize(320, 240)); |
| 732 | 741 |
| 733 registerMockedHttpURLLoad("200-by-300.html"); | 742 registerMockedHttpURLLoad("200-by-300.html"); |
| 734 navigateTo(m_baseURL + "200-by-300.html"); | 743 navigateTo(m_baseURL + "200-by-300.html"); |
| 735 | 744 |
| 736 webViewImpl()->resize(IntSize(100, 160)); | 745 webViewImpl()->resize(IntSize(100, 160)); |
| 737 webViewImpl()->updateAllLifecyclePhases(); | 746 webViewImpl()->updateAllLifecyclePhases(); |
| 738 | 747 |
| 739 EXPECT_SIZE_EQ( | 748 EXPECT_SIZE_EQ( |
| 740 IntSize(100, 160), | 749 IntSize(100, 160), |
| 741 webViewImpl()->mainFrameImpl()->frameView()->frameRect().size()); | 750 webViewImpl()->mainFrameImpl()->frameView()->frameRect().size()); |
| 742 } | 751 } |
| 743 | 752 |
| 744 // Test that attaching a new frame view resets the size of the inner viewport sc
roll | 753 // Test that attaching a new frame view resets the size of the inner viewport |
| 745 // layer. crbug.com/423189. | 754 // scroll layer. crbug.com/423189. |
| 746 TEST_P(ParameterizedVisualViewportTest, | 755 TEST_P(ParameterizedVisualViewportTest, |
| 747 TestAttachingNewFrameSetsInnerScrollLayerSize) { | 756 TestAttachingNewFrameSetsInnerScrollLayerSize) { |
| 748 initializeWithAndroidSettings(); | 757 initializeWithAndroidSettings(); |
| 749 webViewImpl()->resize(IntSize(320, 240)); | 758 webViewImpl()->resize(IntSize(320, 240)); |
| 750 | 759 |
| 751 // Load a wider page first, the navigation should resize the scroll layer to | 760 // Load a wider page first, the navigation should resize the scroll layer to |
| 752 // the smaller size on the second navigation. | 761 // the smaller size on the second navigation. |
| 753 registerMockedHttpURLLoad("content-width-1000.html"); | 762 registerMockedHttpURLLoad("content-width-1000.html"); |
| 754 navigateTo(m_baseURL + "content-width-1000.html"); | 763 navigateTo(m_baseURL + "content-width-1000.html"); |
| 755 webViewImpl()->updateAllLifecyclePhases(); | 764 webViewImpl()->updateAllLifecyclePhases(); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 768 navigateTo(m_baseURL + "viewport-device-width.html"); | 777 navigateTo(m_baseURL + "viewport-device-width.html"); |
| 769 | 778 |
| 770 // Ensure the scroll layer matches the frame view's size. | 779 // Ensure the scroll layer matches the frame view's size. |
| 771 EXPECT_SIZE_EQ(FloatSize(320, 240), visualViewport.scrollLayer()->size()); | 780 EXPECT_SIZE_EQ(FloatSize(320, 240), visualViewport.scrollLayer()->size()); |
| 772 | 781 |
| 773 // Ensure the location and scale were reset. | 782 // Ensure the location and scale were reset. |
| 774 EXPECT_POINT_EQ(FloatPoint(), visualViewport.location()); | 783 EXPECT_POINT_EQ(FloatPoint(), visualViewport.location()); |
| 775 EXPECT_EQ(1, visualViewport.scale()); | 784 EXPECT_EQ(1, visualViewport.scale()); |
| 776 } | 785 } |
| 777 | 786 |
| 778 // The main FrameView's size should be set such that its the size of the visual
viewport | 787 // The main FrameView's size should be set such that its the size of the visual |
| 779 // at minimum scale. Test that the FrameView is appropriately sized in the prese
nce | 788 // viewport at minimum scale. Test that the FrameView is appropriately sized in |
| 780 // of a viewport <meta> tag. | 789 // the presence of a viewport <meta> tag. |
| 781 TEST_P(ParameterizedVisualViewportTest, | 790 TEST_P(ParameterizedVisualViewportTest, |
| 782 TestFrameViewSizedToViewportMetaMinimumScale) { | 791 TestFrameViewSizedToViewportMetaMinimumScale) { |
| 783 initializeWithAndroidSettings(); | 792 initializeWithAndroidSettings(); |
| 784 webViewImpl()->resize(IntSize(320, 240)); | 793 webViewImpl()->resize(IntSize(320, 240)); |
| 785 | 794 |
| 786 registerMockedHttpURLLoad("200-by-300-min-scale-2.html"); | 795 registerMockedHttpURLLoad("200-by-300-min-scale-2.html"); |
| 787 navigateTo(m_baseURL + "200-by-300-min-scale-2.html"); | 796 navigateTo(m_baseURL + "200-by-300-min-scale-2.html"); |
| 788 | 797 |
| 789 webViewImpl()->resize(IntSize(100, 160)); | 798 webViewImpl()->resize(IntSize(100, 160)); |
| 790 webViewImpl()->updateAllLifecyclePhases(); | 799 webViewImpl()->updateAllLifecyclePhases(); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 805 | 814 |
| 806 webViewImpl()->enableAutoResizeMode(WebSize(10, 10), WebSize(1000, 1000)); | 815 webViewImpl()->enableAutoResizeMode(WebSize(10, 10), WebSize(1000, 1000)); |
| 807 | 816 |
| 808 registerMockedHttpURLLoad("200-by-300.html"); | 817 registerMockedHttpURLLoad("200-by-300.html"); |
| 809 navigateTo(m_baseURL + "200-by-300.html"); | 818 navigateTo(m_baseURL + "200-by-300.html"); |
| 810 | 819 |
| 811 EXPECT_SIZE_EQ(IntSize(200, 300), | 820 EXPECT_SIZE_EQ(IntSize(200, 300), |
| 812 frame()->page()->frameHost().visualViewport().size()); | 821 frame()->page()->frameHost().visualViewport().size()); |
| 813 } | 822 } |
| 814 | 823 |
| 815 // Test that the text selection handle's position accounts for the visual viewpo
rt. | 824 // Test that the text selection handle's position accounts for the visual |
| 825 // viewport. |
| 816 TEST_P(ParameterizedVisualViewportTest, TestTextSelectionHandles) { | 826 TEST_P(ParameterizedVisualViewportTest, TestTextSelectionHandles) { |
| 817 initializeWithDesktopSettings(); | 827 initializeWithDesktopSettings(); |
| 818 webViewImpl()->resize(IntSize(500, 800)); | 828 webViewImpl()->resize(IntSize(500, 800)); |
| 819 | 829 |
| 820 registerMockedHttpURLLoad("pinch-viewport-input-field.html"); | 830 registerMockedHttpURLLoad("pinch-viewport-input-field.html"); |
| 821 navigateTo(m_baseURL + "pinch-viewport-input-field.html"); | 831 navigateTo(m_baseURL + "pinch-viewport-input-field.html"); |
| 822 | 832 |
| 823 VisualViewport& visualViewport = | 833 VisualViewport& visualViewport = |
| 824 frame()->page()->frameHost().visualViewport(); | 834 frame()->page()->frameHost().visualViewport(); |
| 825 webViewImpl()->setInitialFocus(false); | 835 webViewImpl()->setInitialFocus(false); |
| 826 | 836 |
| 827 WebRect originalAnchor; | 837 WebRect originalAnchor; |
| 828 WebRect originalFocus; | 838 WebRect originalFocus; |
| 829 webViewImpl()->selectionBounds(originalAnchor, originalFocus); | 839 webViewImpl()->selectionBounds(originalAnchor, originalFocus); |
| 830 | 840 |
| 831 webViewImpl()->setPageScaleFactor(2); | 841 webViewImpl()->setPageScaleFactor(2); |
| 832 visualViewport.setLocation(FloatPoint(100, 400)); | 842 visualViewport.setLocation(FloatPoint(100, 400)); |
| 833 | 843 |
| 834 WebRect anchor; | 844 WebRect anchor; |
| 835 WebRect focus; | 845 WebRect focus; |
| 836 webViewImpl()->selectionBounds(anchor, focus); | 846 webViewImpl()->selectionBounds(anchor, focus); |
| 837 | 847 |
| 838 IntPoint expected(IntRect(originalAnchor).location()); | 848 IntPoint expected(IntRect(originalAnchor).location()); |
| 839 expected.moveBy(-flooredIntPoint(visualViewport.visibleRect().location())); | 849 expected.moveBy(-flooredIntPoint(visualViewport.visibleRect().location())); |
| 840 expected.scale(visualViewport.scale(), visualViewport.scale()); | 850 expected.scale(visualViewport.scale(), visualViewport.scale()); |
| 841 | 851 |
| 842 EXPECT_POINT_EQ(expected, IntRect(anchor).location()); | 852 EXPECT_POINT_EQ(expected, IntRect(anchor).location()); |
| 843 EXPECT_POINT_EQ(expected, IntRect(focus).location()); | 853 EXPECT_POINT_EQ(expected, IntRect(focus).location()); |
| 844 | 854 |
| 845 // FIXME(bokan) - http://crbug.com/364154 - Figure out how to test text select
ion | 855 // FIXME(bokan) - http://crbug.com/364154 - Figure out how to test text |
| 846 // as well rather than just carret. | 856 // selection as well rather than just carret. |
| 847 } | 857 } |
| 848 | 858 |
| 849 // Test that the HistoryItem for the page stores the visual viewport's offset an
d scale. | 859 // Test that the HistoryItem for the page stores the visual viewport's offset |
| 860 // and scale. |
| 850 TEST_P(ParameterizedVisualViewportTest, TestSavedToHistoryItem) { | 861 TEST_P(ParameterizedVisualViewportTest, TestSavedToHistoryItem) { |
| 851 initializeWithDesktopSettings(); | 862 initializeWithDesktopSettings(); |
| 852 webViewImpl()->resize(IntSize(200, 300)); | 863 webViewImpl()->resize(IntSize(200, 300)); |
| 853 webViewImpl()->updateAllLifecyclePhases(); | 864 webViewImpl()->updateAllLifecyclePhases(); |
| 854 | 865 |
| 855 registerMockedHttpURLLoad("200-by-300.html"); | 866 registerMockedHttpURLLoad("200-by-300.html"); |
| 856 navigateTo(m_baseURL + "200-by-300.html"); | 867 navigateTo(m_baseURL + "200-by-300.html"); |
| 857 | 868 |
| 858 EXPECT_FLOAT_POINT_EQ(FloatPoint(0, 0), | 869 EXPECT_FLOAT_POINT_EQ(FloatPoint(0, 0), |
| 859 toLocalFrame(webViewImpl()->page()->mainFrame()) | 870 toLocalFrame(webViewImpl()->page()->mainFrame()) |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 898 WebCachePolicy::UseProtocolCachePolicy); | 909 WebCachePolicy::UseProtocolCachePolicy); |
| 899 | 910 |
| 900 VisualViewport& visualViewport = | 911 VisualViewport& visualViewport = |
| 901 frame()->page()->frameHost().visualViewport(); | 912 frame()->page()->frameHost().visualViewport(); |
| 902 EXPECT_EQ(2, visualViewport.scale()); | 913 EXPECT_EQ(2, visualViewport.scale()); |
| 903 | 914 |
| 904 EXPECT_FLOAT_POINT_EQ(FloatPoint(100, 120), | 915 EXPECT_FLOAT_POINT_EQ(FloatPoint(100, 120), |
| 905 visualViewport.visibleRect().location()); | 916 visualViewport.visibleRect().location()); |
| 906 } | 917 } |
| 907 | 918 |
| 908 // Test restoring a HistoryItem without the visual viewport offset falls back to
distributing | 919 // Test restoring a HistoryItem without the visual viewport offset falls back to |
| 909 // the scroll offset between the main frame and the visual viewport. | 920 // distributing the scroll offset between the main frame and the visual |
| 921 // viewport. |
| 910 TEST_F(VisualViewportTest, TestRestoredFromLegacyHistoryItem) { | 922 TEST_F(VisualViewportTest, TestRestoredFromLegacyHistoryItem) { |
| 911 initializeWithDesktopSettings(); | 923 initializeWithDesktopSettings(); |
| 912 webViewImpl()->resize(IntSize(100, 150)); | 924 webViewImpl()->resize(IntSize(100, 150)); |
| 913 | 925 |
| 914 registerMockedHttpURLLoad("200-by-300-viewport.html"); | 926 registerMockedHttpURLLoad("200-by-300-viewport.html"); |
| 915 | 927 |
| 916 WebHistoryItem item; | 928 WebHistoryItem item; |
| 917 item.initialize(); | 929 item.initialize(); |
| 918 WebURL destinationURL( | 930 WebURL destinationURL( |
| 919 URLTestHelpers::toKURL(m_baseURL + "200-by-300-viewport.html")); | 931 URLTestHelpers::toKURL(m_baseURL + "200-by-300-viewport.html")); |
| 920 item.setURLString(destinationURL.string()); | 932 item.setURLString(destinationURL.string()); |
| 921 // (-1, -1) will be used if the HistoryItem is an older version prior to havin
g | 933 // (-1, -1) will be used if the HistoryItem is an older version prior to |
| 922 // visual viewport scroll offset. | 934 // having visual viewport scroll offset. |
| 923 item.setVisualViewportScrollOffset(WebFloatPoint(-1, -1)); | 935 item.setVisualViewportScrollOffset(WebFloatPoint(-1, -1)); |
| 924 item.setScrollOffset(WebPoint(120, 180)); | 936 item.setScrollOffset(WebPoint(120, 180)); |
| 925 item.setPageScaleFactor(2); | 937 item.setPageScaleFactor(2); |
| 926 | 938 |
| 927 FrameTestHelpers::loadHistoryItem(webViewImpl()->mainFrame(), item, | 939 FrameTestHelpers::loadHistoryItem(webViewImpl()->mainFrame(), item, |
| 928 WebHistoryDifferentDocumentLoad, | 940 WebHistoryDifferentDocumentLoad, |
| 929 WebCachePolicy::UseProtocolCachePolicy); | 941 WebCachePolicy::UseProtocolCachePolicy); |
| 930 | 942 |
| 931 VisualViewport& visualViewport = | 943 VisualViewport& visualViewport = |
| 932 frame()->page()->frameHost().visualViewport(); | 944 frame()->page()->frameHost().visualViewport(); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 994 // the range and its end). Do a sanity check that the expected text is | 1006 // the range and its end). Do a sanity check that the expected text is |
| 995 // selected | 1007 // selected |
| 996 mainFrame->executeScript(WebScriptSource("selectRange();")); | 1008 mainFrame->executeScript(WebScriptSource("selectRange();")); |
| 997 EXPECT_EQ("ir", mainFrame->toWebLocalFrame()->selectionAsText().utf8()); | 1009 EXPECT_EQ("ir", mainFrame->toWebLocalFrame()->selectionAsText().utf8()); |
| 998 | 1010 |
| 999 webViewImpl()->selectionBounds(baseRect, extentRect); | 1011 webViewImpl()->selectionBounds(baseRect, extentRect); |
| 1000 WebPoint initialPoint(baseRect.x, baseRect.y); | 1012 WebPoint initialPoint(baseRect.x, baseRect.y); |
| 1001 WebPoint endPoint(extentRect.x, extentRect.y); | 1013 WebPoint endPoint(extentRect.x, extentRect.y); |
| 1002 | 1014 |
| 1003 // Move the visual viewport over and make the selection in the same | 1015 // Move the visual viewport over and make the selection in the same |
| 1004 // screen-space location. The selection should change to two characters to | 1016 // screen-space location. The selection should change to two characters to the |
| 1005 // the right and down one line. | 1017 // right and down one line. |
| 1006 VisualViewport& visualViewport = | 1018 VisualViewport& visualViewport = |
| 1007 frame()->page()->frameHost().visualViewport(); | 1019 frame()->page()->frameHost().visualViewport(); |
| 1008 visualViewport.move(FloatPoint(60, 25)); | 1020 visualViewport.move(FloatPoint(60, 25)); |
| 1009 mainFrame->toWebLocalFrame()->moveRangeSelection(initialPoint, endPoint); | 1021 mainFrame->toWebLocalFrame()->moveRangeSelection(initialPoint, endPoint); |
| 1010 EXPECT_EQ("t ", mainFrame->toWebLocalFrame()->selectionAsText().utf8()); | 1022 EXPECT_EQ("t ", mainFrame->toWebLocalFrame()->selectionAsText().utf8()); |
| 1011 } | 1023 } |
| 1012 | 1024 |
| 1013 // Test that the scrollFocusedEditableElementIntoRect method works with the visu
al viewport. | 1025 // Test that the scrollFocusedEditableElementIntoRect method works with the |
| 1026 // visual viewport. |
| 1014 TEST_P(ParameterizedVisualViewportTest, | 1027 TEST_P(ParameterizedVisualViewportTest, |
| 1015 DISABLED_TestScrollFocusedEditableElementIntoRect) { | 1028 DISABLED_TestScrollFocusedEditableElementIntoRect) { |
| 1016 initializeWithDesktopSettings(); | 1029 initializeWithDesktopSettings(); |
| 1017 webViewImpl()->resize(IntSize(500, 300)); | 1030 webViewImpl()->resize(IntSize(500, 300)); |
| 1018 | 1031 |
| 1019 registerMockedHttpURLLoad("pinch-viewport-input-field.html"); | 1032 registerMockedHttpURLLoad("pinch-viewport-input-field.html"); |
| 1020 navigateTo(m_baseURL + "pinch-viewport-input-field.html"); | 1033 navigateTo(m_baseURL + "pinch-viewport-input-field.html"); |
| 1021 | 1034 |
| 1022 VisualViewport& visualViewport = | 1035 VisualViewport& visualViewport = |
| 1023 frame()->page()->frameHost().visualViewport(); | 1036 frame()->page()->frameHost().visualViewport(); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1036 webViewImpl()->resizeVisualViewport(IntSize(500, 300)); | 1049 webViewImpl()->resizeVisualViewport(IntSize(500, 300)); |
| 1037 visualViewport.setLocation(FloatPoint(0, 0)); | 1050 visualViewport.setLocation(FloatPoint(0, 0)); |
| 1038 | 1051 |
| 1039 webViewImpl()->setPageScaleFactor(2); | 1052 webViewImpl()->setPageScaleFactor(2); |
| 1040 webViewImpl()->scrollFocusedEditableElementIntoRect(IntRect(0, 0, 500, 200)); | 1053 webViewImpl()->scrollFocusedEditableElementIntoRect(IntRect(0, 0, 500, 200)); |
| 1041 EXPECT_POINT_EQ(IntPoint(0, frame()->view()->maximumScrollPosition().y()), | 1054 EXPECT_POINT_EQ(IntPoint(0, frame()->view()->maximumScrollPosition().y()), |
| 1042 frame()->view()->scrollPosition()); | 1055 frame()->view()->scrollPosition()); |
| 1043 EXPECT_FLOAT_POINT_EQ(FloatPoint(125, 150), | 1056 EXPECT_FLOAT_POINT_EQ(FloatPoint(125, 150), |
| 1044 visualViewport.visibleRect().location()); | 1057 visualViewport.visibleRect().location()); |
| 1045 | 1058 |
| 1046 // Once more but make sure that we don't move the visual viewport unless neces
sary. | 1059 // Once more but make sure that we don't move the visual viewport unless |
| 1060 // necessary. |
| 1047 registerMockedHttpURLLoad("pinch-viewport-input-field-long-and-wide.html"); | 1061 registerMockedHttpURLLoad("pinch-viewport-input-field-long-and-wide.html"); |
| 1048 navigateTo(m_baseURL + "pinch-viewport-input-field-long-and-wide.html"); | 1062 navigateTo(m_baseURL + "pinch-viewport-input-field-long-and-wide.html"); |
| 1049 webViewImpl()->setInitialFocus(false); | 1063 webViewImpl()->setInitialFocus(false); |
| 1050 visualViewport.setLocation(FloatPoint()); | 1064 visualViewport.setLocation(FloatPoint()); |
| 1051 frame()->view()->setScrollPosition(IntPoint(0, 0), ProgrammaticScroll); | 1065 frame()->view()->setScrollPosition(IntPoint(0, 0), ProgrammaticScroll); |
| 1052 webViewImpl()->resizeVisualViewport(IntSize(500, 300)); | 1066 webViewImpl()->resizeVisualViewport(IntSize(500, 300)); |
| 1053 visualViewport.setLocation(FloatPoint(30, 50)); | 1067 visualViewport.setLocation(FloatPoint(30, 50)); |
| 1054 | 1068 |
| 1055 webViewImpl()->setPageScaleFactor(2); | 1069 webViewImpl()->setPageScaleFactor(2); |
| 1056 webViewImpl()->scrollFocusedEditableElementIntoRect(IntRect(0, 0, 500, 200)); | 1070 webViewImpl()->scrollFocusedEditableElementIntoRect(IntRect(0, 0, 500, 200)); |
| 1057 EXPECT_POINT_EQ(IntPoint(200 - 30 - 75, 600 - 50 - 65), | 1071 EXPECT_POINT_EQ(IntPoint(200 - 30 - 75, 600 - 50 - 65), |
| 1058 frame()->view()->scrollPosition()); | 1072 frame()->view()->scrollPosition()); |
| 1059 EXPECT_FLOAT_POINT_EQ(FloatPoint(30, 50), | 1073 EXPECT_FLOAT_POINT_EQ(FloatPoint(30, 50), |
| 1060 visualViewport.visibleRect().location()); | 1074 visualViewport.visibleRect().location()); |
| 1061 } | 1075 } |
| 1062 | 1076 |
| 1063 // Test that resizing the WebView causes ViewportConstrained objects to relayout
. | 1077 // Test that resizing the WebView causes ViewportConstrained objects to |
| 1078 // relayout. |
| 1064 TEST_P(ParameterizedVisualViewportTest, | 1079 TEST_P(ParameterizedVisualViewportTest, |
| 1065 TestWebViewResizeCausesViewportConstrainedLayout) { | 1080 TestWebViewResizeCausesViewportConstrainedLayout) { |
| 1066 initializeWithDesktopSettings(); | 1081 initializeWithDesktopSettings(); |
| 1067 webViewImpl()->resize(IntSize(500, 300)); | 1082 webViewImpl()->resize(IntSize(500, 300)); |
| 1068 | 1083 |
| 1069 registerMockedHttpURLLoad("pinch-viewport-fixed-pos.html"); | 1084 registerMockedHttpURLLoad("pinch-viewport-fixed-pos.html"); |
| 1070 navigateTo(m_baseURL + "pinch-viewport-fixed-pos.html"); | 1085 navigateTo(m_baseURL + "pinch-viewport-fixed-pos.html"); |
| 1071 | 1086 |
| 1072 LayoutObject* navbar = | 1087 LayoutObject* navbar = |
| 1073 frame()->document()->getElementById("navbar")->layoutObject(); | 1088 frame()->document()->getElementById("navbar")->layoutObject(); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1127 | 1142 |
| 1128 // Do a sanity check with no scale applied. | 1143 // Do a sanity check with no scale applied. |
| 1129 webViewImpl()->mainFrameImpl()->setClient(&mockWebFrameClient); | 1144 webViewImpl()->mainFrameImpl()->setClient(&mockWebFrameClient); |
| 1130 webViewImpl()->handleInputEvent(mouseDownEvent); | 1145 webViewImpl()->handleInputEvent(mouseDownEvent); |
| 1131 webViewImpl()->handleInputEvent(mouseUpEvent); | 1146 webViewImpl()->handleInputEvent(mouseUpEvent); |
| 1132 | 1147 |
| 1133 Mock::VerifyAndClearExpectations(&mockWebFrameClient); | 1148 Mock::VerifyAndClearExpectations(&mockWebFrameClient); |
| 1134 mouseDownEvent.button = WebMouseEvent::Button::Left; | 1149 mouseDownEvent.button = WebMouseEvent::Button::Left; |
| 1135 webViewImpl()->handleInputEvent(mouseDownEvent); | 1150 webViewImpl()->handleInputEvent(mouseDownEvent); |
| 1136 | 1151 |
| 1137 // Now pinch zoom into the page and move the visual viewport. The context | 1152 // Now pinch zoom into the page and move the visual viewport. The context menu |
| 1138 // menu should still appear at the location of the event, relative to the | 1153 // should still appear at the location of the event, relative to the WebView. |
| 1139 // WebView. | |
| 1140 VisualViewport& visualViewport = | 1154 VisualViewport& visualViewport = |
| 1141 frame()->page()->frameHost().visualViewport(); | 1155 frame()->page()->frameHost().visualViewport(); |
| 1142 webViewImpl()->setPageScaleFactor(2); | 1156 webViewImpl()->setPageScaleFactor(2); |
| 1143 visualViewport.setLocation(FloatPoint(60, 80)); | 1157 visualViewport.setLocation(FloatPoint(60, 80)); |
| 1144 EXPECT_CALL(mockWebFrameClient, showContextMenu(ContextMenuAtLocation( | 1158 EXPECT_CALL(mockWebFrameClient, showContextMenu(ContextMenuAtLocation( |
| 1145 mouseDownEvent.x, mouseDownEvent.y))); | 1159 mouseDownEvent.x, mouseDownEvent.y))); |
| 1146 | 1160 |
| 1147 mouseDownEvent.button = WebMouseEvent::Button::Right; | 1161 mouseDownEvent.button = WebMouseEvent::Button::Right; |
| 1148 webViewImpl()->handleInputEvent(mouseDownEvent); | 1162 webViewImpl()->handleInputEvent(mouseDownEvent); |
| 1149 webViewImpl()->handleInputEvent(mouseUpEvent); | 1163 webViewImpl()->handleInputEvent(mouseUpEvent); |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1278 visualViewport.setScale(1); | 1292 visualViewport.setScale(1); |
| 1279 EXPECT_SIZE_EQ(IntSize(500, 450), visualViewport.visibleRect().size()); | 1293 EXPECT_SIZE_EQ(IntSize(500, 450), visualViewport.visibleRect().size()); |
| 1280 EXPECT_SIZE_EQ(IntSize(1000, 900), frameView.frameRect().size()); | 1294 EXPECT_SIZE_EQ(IntSize(1000, 900), frameView.frameRect().size()); |
| 1281 | 1295 |
| 1282 // Simulate bringing down the top controls by 20px. | 1296 // Simulate bringing down the top controls by 20px. |
| 1283 webViewImpl()->applyViewportDeltas(WebFloatSize(), WebFloatSize(), | 1297 webViewImpl()->applyViewportDeltas(WebFloatSize(), WebFloatSize(), |
| 1284 WebFloatSize(), 1, 1); | 1298 WebFloatSize(), 1, 1); |
| 1285 EXPECT_SIZE_EQ(IntSize(500, 430), visualViewport.visibleRect().size()); | 1299 EXPECT_SIZE_EQ(IntSize(500, 430), visualViewport.visibleRect().size()); |
| 1286 | 1300 |
| 1287 // Test that the scroll bounds are adjusted appropriately: the visual viewport | 1301 // Test that the scroll bounds are adjusted appropriately: the visual viewport |
| 1288 // should be shrunk by 20px to 430px. The outer viewport was shrunk to maintai
n the | 1302 // should be shrunk by 20px to 430px. The outer viewport was shrunk to |
| 1289 // aspect ratio so it's height is 860px. | 1303 // maintain the aspect ratio so it's height is 860px. |
| 1290 visualViewport.move(FloatPoint(10000, 10000)); | 1304 visualViewport.move(FloatPoint(10000, 10000)); |
| 1291 EXPECT_POINT_EQ(FloatPoint(500, 860 - 430), visualViewport.location()); | 1305 EXPECT_POINT_EQ(FloatPoint(500, 860 - 430), visualViewport.location()); |
| 1292 | 1306 |
| 1293 // The outer viewport (FrameView) should be affected as well. | 1307 // The outer viewport (FrameView) should be affected as well. |
| 1294 frameView.scrollBy(IntSize(10000, 10000), UserScroll); | 1308 frameView.scrollBy(IntSize(10000, 10000), UserScroll); |
| 1295 EXPECT_POINT_EQ(expectedMaxFrameViewScrollOffset(visualViewport, frameView), | 1309 EXPECT_POINT_EQ(expectedMaxFrameViewScrollOffset(visualViewport, frameView), |
| 1296 frameView.scrollPosition()); | 1310 frameView.scrollPosition()); |
| 1297 | 1311 |
| 1298 // Simulate bringing up the top controls by 10.5px. | 1312 // Simulate bringing up the top controls by 10.5px. |
| 1299 webViewImpl()->applyViewportDeltas(WebFloatSize(), WebFloatSize(), | 1313 webViewImpl()->applyViewportDeltas(WebFloatSize(), WebFloatSize(), |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1319 navigateTo(m_baseURL + "content-width-1000.html"); | 1333 navigateTo(m_baseURL + "content-width-1000.html"); |
| 1320 | 1334 |
| 1321 VisualViewport& visualViewport = | 1335 VisualViewport& visualViewport = |
| 1322 frame()->page()->frameHost().visualViewport(); | 1336 frame()->page()->frameHost().visualViewport(); |
| 1323 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView(); | 1337 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView(); |
| 1324 | 1338 |
| 1325 visualViewport.setScale(2); | 1339 visualViewport.setScale(2); |
| 1326 EXPECT_SIZE_EQ(IntSize(250, 225), visualViewport.visibleRect().size()); | 1340 EXPECT_SIZE_EQ(IntSize(250, 225), visualViewport.visibleRect().size()); |
| 1327 EXPECT_SIZE_EQ(IntSize(1000, 900), frameView.frameRect().size()); | 1341 EXPECT_SIZE_EQ(IntSize(1000, 900), frameView.frameRect().size()); |
| 1328 | 1342 |
| 1329 // Simulate bringing down the top controls by 20px. Since we're zoomed in, | 1343 // Simulate bringing down the top controls by 20px. Since we're zoomed in, the |
| 1330 // the top controls take up half as much space (in document-space) than | 1344 // top controls take up half as much space (in document-space) than they do at |
| 1331 // they do at an unzoomed level. | 1345 // an unzoomed level. |
| 1332 webViewImpl()->applyViewportDeltas(WebFloatSize(), WebFloatSize(), | 1346 webViewImpl()->applyViewportDeltas(WebFloatSize(), WebFloatSize(), |
| 1333 WebFloatSize(), 1, 1); | 1347 WebFloatSize(), 1, 1); |
| 1334 EXPECT_SIZE_EQ(IntSize(250, 215), visualViewport.visibleRect().size()); | 1348 EXPECT_SIZE_EQ(IntSize(250, 215), visualViewport.visibleRect().size()); |
| 1335 | 1349 |
| 1336 // Test that the scroll bounds are adjusted appropriately. | 1350 // Test that the scroll bounds are adjusted appropriately. |
| 1337 visualViewport.move(FloatPoint(10000, 10000)); | 1351 visualViewport.move(FloatPoint(10000, 10000)); |
| 1338 EXPECT_POINT_EQ(FloatPoint(750, 860 - 215), visualViewport.location()); | 1352 EXPECT_POINT_EQ(FloatPoint(750, 860 - 215), visualViewport.location()); |
| 1339 | 1353 |
| 1340 // The outer viewport (FrameView) should be affected as well. | 1354 // The outer viewport (FrameView) should be affected as well. |
| 1341 frameView.scrollBy(IntSize(10000, 10000), UserScroll); | 1355 frameView.scrollBy(IntSize(10000, 10000), UserScroll); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 1370 visualViewport.move(FloatPoint(10000, 10000)); | 1384 visualViewport.move(FloatPoint(10000, 10000)); |
| 1371 EXPECT_FLOAT_POINT_EQ(FloatPoint(375, 877.5 - 548.75), | 1385 EXPECT_FLOAT_POINT_EQ(FloatPoint(375, 877.5 - 548.75), |
| 1372 visualViewport.location()); | 1386 visualViewport.location()); |
| 1373 | 1387 |
| 1374 frameView.scrollBy(IntSize(10000, 10000), UserScroll); | 1388 frameView.scrollBy(IntSize(10000, 10000), UserScroll); |
| 1375 EXPECT_POINT_EQ(expectedMaxFrameViewScrollOffset(visualViewport, frameView), | 1389 EXPECT_POINT_EQ(expectedMaxFrameViewScrollOffset(visualViewport, frameView), |
| 1376 frameView.scrollPosition()); | 1390 frameView.scrollPosition()); |
| 1377 } | 1391 } |
| 1378 | 1392 |
| 1379 // Tests that a scroll all the way to the bottom of the page, while hiding the | 1393 // Tests that a scroll all the way to the bottom of the page, while hiding the |
| 1380 // top controls doesn't cause a clamp in the viewport scroll offset when the | 1394 // top controls doesn't cause a clamp in the viewport scroll offset when the top |
| 1381 // top controls initiated resize occurs. | 1395 // controls initiated resize occurs. |
| 1382 TEST_F(VisualViewportTest, TestTopControlsAdjustmentAndResize) { | 1396 TEST_F(VisualViewportTest, TestTopControlsAdjustmentAndResize) { |
| 1383 int topControlsHeight = 20; | 1397 int topControlsHeight = 20; |
| 1384 int visualViewportHeight = 450; | 1398 int visualViewportHeight = 450; |
| 1385 int layoutViewportHeight = 900; | 1399 int layoutViewportHeight = 900; |
| 1386 float pageScale = 2; | 1400 float pageScale = 2; |
| 1387 float minPageScale = 0.5; | 1401 float minPageScale = 0.5; |
| 1388 | 1402 |
| 1389 initializeWithAndroidSettings(); | 1403 initializeWithAndroidSettings(); |
| 1390 | 1404 |
| 1391 // Initialize with top controls showing and shrinking the Blink size. | 1405 // Initialize with top controls showing and shrinking the Blink size. |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1521 TEST_F(VisualViewportTest, TestTopControlHidingResizeDoesntClampMainFrame) { | 1535 TEST_F(VisualViewportTest, TestTopControlHidingResizeDoesntClampMainFrame) { |
| 1522 initializeWithAndroidSettings(); | 1536 initializeWithAndroidSettings(); |
| 1523 webViewImpl()->resizeWithTopControls(webViewImpl()->size(), 500, false); | 1537 webViewImpl()->resizeWithTopControls(webViewImpl()->size(), 500, false); |
| 1524 webViewImpl()->applyViewportDeltas(WebFloatSize(), WebFloatSize(), | 1538 webViewImpl()->applyViewportDeltas(WebFloatSize(), WebFloatSize(), |
| 1525 WebFloatSize(), 1, 1); | 1539 WebFloatSize(), 1, 1); |
| 1526 webViewImpl()->resizeWithTopControls(WebSize(1000, 1000), 500, true); | 1540 webViewImpl()->resizeWithTopControls(WebSize(1000, 1000), 500, true); |
| 1527 | 1541 |
| 1528 registerMockedHttpURLLoad("content-width-1000.html"); | 1542 registerMockedHttpURLLoad("content-width-1000.html"); |
| 1529 navigateTo(m_baseURL + "content-width-1000.html"); | 1543 navigateTo(m_baseURL + "content-width-1000.html"); |
| 1530 | 1544 |
| 1531 // Scroll the FrameView to the bottom of the page but "hide" the top | 1545 // Scroll the FrameView to the bottom of the page but "hide" the top controls |
| 1532 // controls on the compositor side so the max scroll position should account | 1546 // on the compositor side so the max scroll position should account for the |
| 1533 // for the full viewport height. | 1547 // full viewport height. |
| 1534 webViewImpl()->applyViewportDeltas(WebFloatSize(), WebFloatSize(), | 1548 webViewImpl()->applyViewportDeltas(WebFloatSize(), WebFloatSize(), |
| 1535 WebFloatSize(), 1, -1); | 1549 WebFloatSize(), 1, -1); |
| 1536 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView(); | 1550 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView(); |
| 1537 frameView.setScrollPosition(IntPoint(0, 10000), ProgrammaticScroll); | 1551 frameView.setScrollPosition(IntPoint(0, 10000), ProgrammaticScroll); |
| 1538 EXPECT_EQ(500, frameView.scrollPositionDouble().y()); | 1552 EXPECT_EQ(500, frameView.scrollPositionDouble().y()); |
| 1539 | 1553 |
| 1540 // Now send the resize, make sure the scroll offset doesn't change. | 1554 // Now send the resize, make sure the scroll offset doesn't change. |
| 1541 webViewImpl()->resizeWithTopControls(WebSize(1000, 1500), 500, false); | 1555 webViewImpl()->resizeWithTopControls(WebSize(1000, 1500), 500, false); |
| 1542 EXPECT_EQ(500, frameView.scrollPositionDouble().y()); | 1556 EXPECT_EQ(500, frameView.scrollPositionDouble().y()); |
| 1543 } | 1557 } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1568 initializeWithAndroidSettings(); | 1582 initializeWithAndroidSettings(); |
| 1569 webViewImpl()->resize(IntSize(100, 150)); | 1583 webViewImpl()->resize(IntSize(100, 150)); |
| 1570 navigateTo("about:blank"); | 1584 navigateTo("about:blank"); |
| 1571 | 1585 |
| 1572 VisualViewport& visualViewport = | 1586 VisualViewport& visualViewport = |
| 1573 frame()->page()->frameHost().visualViewport(); | 1587 frame()->page()->frameHost().visualViewport(); |
| 1574 EXPECT_TRUE(visualViewport.layerForHorizontalScrollbar()->parent()); | 1588 EXPECT_TRUE(visualViewport.layerForHorizontalScrollbar()->parent()); |
| 1575 EXPECT_TRUE(visualViewport.layerForVerticalScrollbar()->parent()); | 1589 EXPECT_TRUE(visualViewport.layerForVerticalScrollbar()->parent()); |
| 1576 } | 1590 } |
| 1577 | 1591 |
| 1578 // Tests that the layout viewport's scroll layer bounds are updated in a composi
ting | 1592 // Tests that the layout viewport's scroll layer bounds are updated in a |
| 1579 // change update. crbug.com/423188. | 1593 // compositing change update. crbug.com/423188. |
| 1580 TEST_P(ParameterizedVisualViewportTest, | 1594 TEST_P(ParameterizedVisualViewportTest, |
| 1581 TestChangingContentSizeAffectsScrollBounds) { | 1595 TestChangingContentSizeAffectsScrollBounds) { |
| 1582 initializeWithAndroidSettings(); | 1596 initializeWithAndroidSettings(); |
| 1583 webViewImpl()->resize(IntSize(100, 150)); | 1597 webViewImpl()->resize(IntSize(100, 150)); |
| 1584 | 1598 |
| 1585 registerMockedHttpURLLoad("content-width-1000.html"); | 1599 registerMockedHttpURLLoad("content-width-1000.html"); |
| 1586 navigateTo(m_baseURL + "content-width-1000.html"); | 1600 navigateTo(m_baseURL + "content-width-1000.html"); |
| 1587 | 1601 |
| 1588 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView(); | 1602 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView(); |
| 1589 WebLayer* scrollLayer = frameView.layerForScrolling()->platformLayer(); | 1603 WebLayer* scrollLayer = frameView.layerForScrolling()->platformLayer(); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1676 | 1690 |
| 1677 // Load page with no main frame scrolling. | 1691 // Load page with no main frame scrolling. |
| 1678 registerMockedHttpURLLoad("200-by-300-viewport.html"); | 1692 registerMockedHttpURLLoad("200-by-300-viewport.html"); |
| 1679 navigateTo(m_baseURL + "200-by-300-viewport.html"); | 1693 navigateTo(m_baseURL + "200-by-300-viewport.html"); |
| 1680 | 1694 |
| 1681 VisualViewport& visualViewport = | 1695 VisualViewport& visualViewport = |
| 1682 frame()->page()->frameHost().visualViewport(); | 1696 frame()->page()->frameHost().visualViewport(); |
| 1683 visualViewport.setScale(2); | 1697 visualViewport.setScale(2); |
| 1684 | 1698 |
| 1685 // Chrome's quirky behavior regarding viewport scrolling means we treat the | 1699 // Chrome's quirky behavior regarding viewport scrolling means we treat the |
| 1686 // body element as the viewport and don't apply scrolling to the HTML | 1700 // body element as the viewport and don't apply scrolling to the HTML element. |
| 1687 // element. | |
| 1688 RuntimeEnabledFeatures::setScrollTopLeftInteropEnabled(false); | 1701 RuntimeEnabledFeatures::setScrollTopLeftInteropEnabled(false); |
| 1689 | 1702 |
| 1690 LocalDOMWindow* window = | 1703 LocalDOMWindow* window = |
| 1691 webViewImpl()->mainFrameImpl()->frame()->localDOMWindow(); | 1704 webViewImpl()->mainFrameImpl()->frame()->localDOMWindow(); |
| 1692 window->scrollTo(100, 150); | 1705 window->scrollTo(100, 150); |
| 1693 EXPECT_EQ(100, window->scrollX()); | 1706 EXPECT_EQ(100, window->scrollX()); |
| 1694 EXPECT_EQ(150, window->scrollY()); | 1707 EXPECT_EQ(150, window->scrollY()); |
| 1695 EXPECT_FLOAT_POINT_EQ(FloatPoint(100, 150), visualViewport.location()); | 1708 EXPECT_FLOAT_POINT_EQ(FloatPoint(100, 150), visualViewport.location()); |
| 1696 | 1709 |
| 1697 HTMLElement* body = toHTMLBodyElement(window->document()->body()); | 1710 HTMLElement* body = toHTMLBodyElement(window->document()->body()); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1710 EXPECT_FLOAT_POINT_EQ(FloatPoint(50, 130), visualViewport.location()); | 1723 EXPECT_FLOAT_POINT_EQ(FloatPoint(50, 130), visualViewport.location()); |
| 1711 | 1724 |
| 1712 visualViewport.setLocation(FloatPoint(10, 20)); | 1725 visualViewport.setLocation(FloatPoint(10, 20)); |
| 1713 EXPECT_EQ(10, body->scrollLeft()); | 1726 EXPECT_EQ(10, body->scrollLeft()); |
| 1714 EXPECT_EQ(20, body->scrollTop()); | 1727 EXPECT_EQ(20, body->scrollTop()); |
| 1715 EXPECT_EQ(0, documentElement->scrollLeft()); | 1728 EXPECT_EQ(0, documentElement->scrollLeft()); |
| 1716 EXPECT_EQ(0, documentElement->scrollTop()); | 1729 EXPECT_EQ(0, documentElement->scrollTop()); |
| 1717 EXPECT_EQ(10, window->scrollX()); | 1730 EXPECT_EQ(10, window->scrollX()); |
| 1718 EXPECT_EQ(20, window->scrollY()); | 1731 EXPECT_EQ(20, window->scrollY()); |
| 1719 | 1732 |
| 1720 // Turning on the standards-compliant viewport scrolling impl should make | 1733 // Turning on the standards-compliant viewport scrolling impl should make the |
| 1721 // the document element the viewport and not body. | 1734 // document element the viewport and not body. |
| 1722 RuntimeEnabledFeatures::setScrollTopLeftInteropEnabled(true); | 1735 RuntimeEnabledFeatures::setScrollTopLeftInteropEnabled(true); |
| 1723 | 1736 |
| 1724 window->scrollTo(100, 150); | 1737 window->scrollTo(100, 150); |
| 1725 EXPECT_EQ(100, window->scrollX()); | 1738 EXPECT_EQ(100, window->scrollX()); |
| 1726 EXPECT_EQ(150, window->scrollY()); | 1739 EXPECT_EQ(150, window->scrollY()); |
| 1727 EXPECT_FLOAT_POINT_EQ(FloatPoint(100, 150), visualViewport.location()); | 1740 EXPECT_FLOAT_POINT_EQ(FloatPoint(100, 150), visualViewport.location()); |
| 1728 | 1741 |
| 1729 body->setScrollLeft(50); | 1742 body->setScrollLeft(50); |
| 1730 body->setScrollTop(130); | 1743 body->setScrollTop(130); |
| 1731 EXPECT_EQ(0, body->scrollLeft()); | 1744 EXPECT_EQ(0, body->scrollLeft()); |
| 1732 EXPECT_EQ(0, body->scrollTop()); | 1745 EXPECT_EQ(0, body->scrollTop()); |
| 1733 EXPECT_FLOAT_POINT_EQ(FloatPoint(100, 150), visualViewport.location()); | 1746 EXPECT_FLOAT_POINT_EQ(FloatPoint(100, 150), visualViewport.location()); |
| 1734 | 1747 |
| 1735 documentElement->setScrollLeft(40); | 1748 documentElement->setScrollLeft(40); |
| 1736 documentElement->setScrollTop(50); | 1749 documentElement->setScrollTop(50); |
| 1737 EXPECT_EQ(40, documentElement->scrollLeft()); | 1750 EXPECT_EQ(40, documentElement->scrollLeft()); |
| 1738 EXPECT_EQ(50, documentElement->scrollTop()); | 1751 EXPECT_EQ(50, documentElement->scrollTop()); |
| 1739 EXPECT_FLOAT_POINT_EQ(FloatPoint(40, 50), visualViewport.location()); | 1752 EXPECT_FLOAT_POINT_EQ(FloatPoint(40, 50), visualViewport.location()); |
| 1740 | 1753 |
| 1741 visualViewport.setLocation(FloatPoint(10, 20)); | 1754 visualViewport.setLocation(FloatPoint(10, 20)); |
| 1742 EXPECT_EQ(0, body->scrollLeft()); | 1755 EXPECT_EQ(0, body->scrollLeft()); |
| 1743 EXPECT_EQ(0, body->scrollTop()); | 1756 EXPECT_EQ(0, body->scrollTop()); |
| 1744 EXPECT_EQ(10, documentElement->scrollLeft()); | 1757 EXPECT_EQ(10, documentElement->scrollLeft()); |
| 1745 EXPECT_EQ(20, documentElement->scrollTop()); | 1758 EXPECT_EQ(20, documentElement->scrollTop()); |
| 1746 EXPECT_EQ(10, window->scrollX()); | 1759 EXPECT_EQ(10, window->scrollX()); |
| 1747 EXPECT_EQ(20, window->scrollY()); | 1760 EXPECT_EQ(20, window->scrollY()); |
| 1748 } | 1761 } |
| 1749 | 1762 |
| 1750 // Tests that when a new frame is created, it is created with the intended | 1763 // Tests that when a new frame is created, it is created with the intended size |
| 1751 // size (i.e. viewport at minimum scale, 100x200 / 0.5). | 1764 // (i.e. viewport at minimum scale, 100x200 / 0.5). |
| 1752 TEST_P(ParameterizedVisualViewportTest, TestMainFrameInitializationSizing) { | 1765 TEST_P(ParameterizedVisualViewportTest, TestMainFrameInitializationSizing) { |
| 1753 initializeWithAndroidSettings(); | 1766 initializeWithAndroidSettings(); |
| 1754 | 1767 |
| 1755 webViewImpl()->resize(IntSize(100, 200)); | 1768 webViewImpl()->resize(IntSize(100, 200)); |
| 1756 | 1769 |
| 1757 registerMockedHttpURLLoad("content-width-1000-min-scale.html"); | 1770 registerMockedHttpURLLoad("content-width-1000-min-scale.html"); |
| 1758 navigateTo(m_baseURL + "content-width-1000-min-scale.html"); | 1771 navigateTo(m_baseURL + "content-width-1000-min-scale.html"); |
| 1759 | 1772 |
| 1760 WebLocalFrameImpl* localFrame = webViewImpl()->mainFrameImpl(); | 1773 WebLocalFrameImpl* localFrame = webViewImpl()->mainFrameImpl(); |
| 1761 // The shutdown() calls are a hack to prevent this test | 1774 // The shutdown() calls are a hack to prevent this test from violating |
| 1762 // from violating invariants about frame state during navigation/detach. | 1775 // invariants about frame state during navigation/detach. |
| 1763 localFrame->frame()->document()->shutdown(); | 1776 localFrame->frame()->document()->shutdown(); |
| 1764 localFrame->createFrameView(); | 1777 localFrame->createFrameView(); |
| 1765 | 1778 |
| 1766 FrameView& frameView = *localFrame->frameView(); | 1779 FrameView& frameView = *localFrame->frameView(); |
| 1767 EXPECT_SIZE_EQ(IntSize(200, 400), frameView.frameRect().size()); | 1780 EXPECT_SIZE_EQ(IntSize(200, 400), frameView.frameRect().size()); |
| 1768 frameView.dispose(); | 1781 frameView.dispose(); |
| 1769 } | 1782 } |
| 1770 | 1783 |
| 1771 // Tests that the maximum scroll offset of the viewport can be fractional. | 1784 // Tests that the maximum scroll offset of the viewport can be fractional. |
| 1772 TEST_P(ParameterizedVisualViewportTest, FractionalMaxScrollOffset) { | 1785 TEST_P(ParameterizedVisualViewportTest, FractionalMaxScrollOffset) { |
| 1773 initializeWithDesktopSettings(); | 1786 initializeWithDesktopSettings(); |
| 1774 webViewImpl()->resize(IntSize(101, 201)); | 1787 webViewImpl()->resize(IntSize(101, 201)); |
| 1775 navigateTo("about:blank"); | 1788 navigateTo("about:blank"); |
| 1776 | 1789 |
| 1777 VisualViewport& visualViewport = | 1790 VisualViewport& visualViewport = |
| 1778 frame()->page()->frameHost().visualViewport(); | 1791 frame()->page()->frameHost().visualViewport(); |
| 1779 ScrollableArea* scrollableArea = &visualViewport; | 1792 ScrollableArea* scrollableArea = &visualViewport; |
| 1780 | 1793 |
| 1781 webViewImpl()->setPageScaleFactor(1.0); | 1794 webViewImpl()->setPageScaleFactor(1.0); |
| 1782 EXPECT_FLOAT_POINT_EQ(DoublePoint(), | 1795 EXPECT_FLOAT_POINT_EQ(DoublePoint(), |
| 1783 scrollableArea->maximumScrollPositionDouble()); | 1796 scrollableArea->maximumScrollPositionDouble()); |
| 1784 | 1797 |
| 1785 webViewImpl()->setPageScaleFactor(2); | 1798 webViewImpl()->setPageScaleFactor(2); |
| 1786 EXPECT_FLOAT_POINT_EQ(DoublePoint(101. / 2., 201. / 2.), | 1799 EXPECT_FLOAT_POINT_EQ(DoublePoint(101. / 2., 201. / 2.), |
| 1787 scrollableArea->maximumScrollPositionDouble()); | 1800 scrollableArea->maximumScrollPositionDouble()); |
| 1788 } | 1801 } |
| 1789 | 1802 |
| 1790 // Tests that the slow scrolling after an impl scroll on the visual viewport | 1803 // Tests that the slow scrolling after an impl scroll on the visual viewport is |
| 1791 // is continuous. crbug.com/453460 was caused by the impl-path not updating the | 1804 // continuous. crbug.com/453460 was caused by the impl-path not updating the |
| 1792 // ScrollAnimatorBase class. | 1805 // ScrollAnimatorBase class. |
| 1793 TEST_P(ParameterizedVisualViewportTest, SlowScrollAfterImplScroll) { | 1806 TEST_P(ParameterizedVisualViewportTest, SlowScrollAfterImplScroll) { |
| 1794 initializeWithDesktopSettings(); | 1807 initializeWithDesktopSettings(); |
| 1795 webViewImpl()->resize(IntSize(800, 600)); | 1808 webViewImpl()->resize(IntSize(800, 600)); |
| 1796 navigateTo("about:blank"); | 1809 navigateTo("about:blank"); |
| 1797 | 1810 |
| 1798 VisualViewport& visualViewport = | 1811 VisualViewport& visualViewport = |
| 1799 frame()->page()->frameHost().visualViewport(); | 1812 frame()->page()->frameHost().visualViewport(); |
| 1800 | 1813 |
| 1801 // Apply some scroll and scale from the impl-side. | 1814 // Apply some scroll and scale from the impl-side. |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1837 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView(); | 1850 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView(); |
| 1838 | 1851 |
| 1839 webViewImpl()->setPageScaleFactor(2); | 1852 webViewImpl()->setPageScaleFactor(2); |
| 1840 webViewImpl()->setVisualViewportOffset(WebFloatPoint(200, 230)); | 1853 webViewImpl()->setVisualViewportOffset(WebFloatPoint(200, 230)); |
| 1841 frameView.layoutViewportScrollableArea()->setScrollPosition( | 1854 frameView.layoutViewportScrollableArea()->setScrollPosition( |
| 1842 DoublePoint(400, 1100), ProgrammaticScroll); | 1855 DoublePoint(400, 1100), ProgrammaticScroll); |
| 1843 | 1856 |
| 1844 // FIXME(504057): PaintLayerScrollableArea dirties the compositing state. | 1857 // FIXME(504057): PaintLayerScrollableArea dirties the compositing state. |
| 1845 forceFullCompositingUpdate(); | 1858 forceFullCompositingUpdate(); |
| 1846 | 1859 |
| 1847 // Because of where the visual viewport is located, this should hit the bottom
right | 1860 // Because of where the visual viewport is located, this should hit the bottom |
| 1848 // target (target 4). | 1861 // right target (target 4). |
| 1849 WebAXObject hitNode = | 1862 WebAXObject hitNode = |
| 1850 webDoc.accessibilityObject().hitTest(WebPoint(154, 165)); | 1863 webDoc.accessibilityObject().hitTest(WebPoint(154, 165)); |
| 1851 WebAXNameFrom nameFrom; | 1864 WebAXNameFrom nameFrom; |
| 1852 WebVector<WebAXObject> nameObjects; | 1865 WebVector<WebAXObject> nameObjects; |
| 1853 EXPECT_EQ(std::string("Target4"), hitNode.name(nameFrom, nameObjects).utf8()); | 1866 EXPECT_EQ(std::string("Target4"), hitNode.name(nameFrom, nameObjects).utf8()); |
| 1854 } | 1867 } |
| 1855 | 1868 |
| 1856 // Tests that the maximum scroll offset of the viewport can be fractional. | 1869 // Tests that the maximum scroll offset of the viewport can be fractional. |
| 1857 TEST_P(ParameterizedVisualViewportTest, TestCoordinateTransforms) { | 1870 TEST_P(ParameterizedVisualViewportTest, TestCoordinateTransforms) { |
| 1858 initializeWithAndroidSettings(); | 1871 initializeWithAndroidSettings(); |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2047 | 2060 |
| 2048 EXPECT_POINT_EQ( | 2061 EXPECT_POINT_EQ( |
| 2049 DoublePoint(), | 2062 DoublePoint(), |
| 2050 frameView.layoutViewportScrollableArea()->scrollPositionDouble()); | 2063 frameView.layoutViewportScrollableArea()->scrollPositionDouble()); |
| 2051 EXPECT_EQ(600, scroller->scrollTop()); | 2064 EXPECT_EQ(600, scroller->scrollTop()); |
| 2052 | 2065 |
| 2053 RuntimeEnabledFeatures::setSetRootScrollerEnabled(wasRootScrollerEnabled); | 2066 RuntimeEnabledFeatures::setSetRootScrollerEnabled(wasRootScrollerEnabled); |
| 2054 } | 2067 } |
| 2055 | 2068 |
| 2056 } // namespace | 2069 } // namespace |
| OLD | NEW |