| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/FrameHost.h" | 5 #include "core/frame/FrameHost.h" |
| 6 #include "core/frame/FrameView.h" | 6 #include "core/frame/FrameView.h" |
| 7 #include "core/frame/TopControls.h" | 7 #include "core/frame/TopControls.h" |
| 8 #include "core/html/HTMLFrameOwnerElement.h" | 8 #include "core/html/HTMLFrameOwnerElement.h" |
| 9 #include "core/layout/LayoutBox.h" | 9 #include "core/layout/LayoutBox.h" |
| 10 #include "core/layout/api/LayoutViewItem.h" | 10 #include "core/layout/api/LayoutViewItem.h" |
| (...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 529 { | 529 { |
| 530 // TODO(bokan): The expectation and actual in the checks here are backwards. | 530 // TODO(bokan): The expectation and actual in the checks here are backwards. |
| 531 initialize("root-scroller-iframe.html"); | 531 initialize("root-scroller-iframe.html"); |
| 532 ASSERT_EQ(nullptr, mainFrame()->document()->rootScroller()); | 532 ASSERT_EQ(nullptr, mainFrame()->document()->rootScroller()); |
| 533 | 533 |
| 534 HTMLFrameOwnerElement* iframe = toHTMLFrameOwnerElement( | 534 HTMLFrameOwnerElement* iframe = toHTMLFrameOwnerElement( |
| 535 mainFrame()->document()->getElementById("iframe")); | 535 mainFrame()->document()->getElementById("iframe")); |
| 536 Element* container = | 536 Element* container = |
| 537 iframe->contentDocument()->getElementById("container"); | 537 iframe->contentDocument()->getElementById("container"); |
| 538 | 538 |
| 539 RootScrollerController* mainController = | 539 const TopDocumentRootScrollerController& mainController = |
| 540 mainFrame()->document()->rootScrollerController(); | 540 mainFrame()->document()->frameHost()->globalRootScrollerController(); |
| 541 | 541 |
| 542 NonThrowableExceptionState nonThrow; | 542 NonThrowableExceptionState nonThrow; |
| 543 | 543 |
| 544 // No root scroller set, the documentElement should be the effective root | 544 // No root scroller set, the documentElement should be the effective root |
| 545 // and the main FrameView's scroll layer should be the layer to use. | 545 // and the main FrameView's scroll layer should be the layer to use. |
| 546 { | 546 { |
| 547 EXPECT_EQ( | 547 EXPECT_EQ( |
| 548 mainController->rootScrollerLayer(), | 548 mainController.rootScrollerLayer(), |
| 549 mainFrameView()->layerForScrolling()); | 549 mainFrameView()->layerForScrolling()); |
| 550 EXPECT_TRUE(mainController->isViewportScrollCallback( | 550 EXPECT_TRUE(mainController.isViewportScrollCallback( |
| 551 mainFrame()->document()->documentElement()->getApplyScroll())); | 551 mainFrame()->document()->documentElement()->getApplyScroll())); |
| 552 } | 552 } |
| 553 | 553 |
| 554 // Set a root scroller in the iframe. Since the main document didn't set a | 554 // Set a root scroller in the iframe. Since the main document didn't set a |
| 555 // root scroller, the global root scroller shouldn't change. | 555 // root scroller, the global root scroller shouldn't change. |
| 556 { | 556 { |
| 557 | 557 |
| 558 iframe->contentDocument()->setRootScroller(container, nonThrow); | 558 iframe->contentDocument()->setRootScroller(container, nonThrow); |
| 559 mainFrameView()->updateAllLifecyclePhases(); | 559 mainFrameView()->updateAllLifecyclePhases(); |
| 560 | 560 |
| 561 EXPECT_EQ( | 561 EXPECT_EQ( |
| 562 mainController->rootScrollerLayer(), | 562 mainController.rootScrollerLayer(), |
| 563 mainFrameView()->layerForScrolling()); | 563 mainFrameView()->layerForScrolling()); |
| 564 EXPECT_TRUE(mainController->isViewportScrollCallback( | 564 EXPECT_TRUE(mainController.isViewportScrollCallback( |
| 565 mainFrame()->document()->documentElement()->getApplyScroll())); | 565 mainFrame()->document()->documentElement()->getApplyScroll())); |
| 566 } | 566 } |
| 567 | 567 |
| 568 // Setting the iframe as the root scroller in the main frame should now | 568 // Setting the iframe as the root scroller in the main frame should now |
| 569 // link the root scrollers so the container should now be the global root | 569 // link the root scrollers so the container should now be the global root |
| 570 // scroller. | 570 // scroller. |
| 571 { | 571 { |
| 572 mainFrame()->document()->setRootScroller(iframe, nonThrow); | 572 mainFrame()->document()->setRootScroller(iframe, nonThrow); |
| 573 mainFrameView()->updateAllLifecyclePhases(); | 573 mainFrameView()->updateAllLifecyclePhases(); |
| 574 | 574 |
| 575 ScrollableArea* containerScroller = | 575 ScrollableArea* containerScroller = |
| 576 static_cast<PaintInvalidationCapableScrollableArea*>( | 576 static_cast<PaintInvalidationCapableScrollableArea*>( |
| 577 toLayoutBox(container->layoutObject())->getScrollableArea()); | 577 toLayoutBox(container->layoutObject())->getScrollableArea()); |
| 578 | 578 |
| 579 EXPECT_EQ( | 579 EXPECT_EQ( |
| 580 mainController->rootScrollerLayer(), | 580 mainController.rootScrollerLayer(), |
| 581 containerScroller->layerForScrolling()); | 581 containerScroller->layerForScrolling()); |
| 582 EXPECT_FALSE(mainController->isViewportScrollCallback( | 582 EXPECT_FALSE(mainController.isViewportScrollCallback( |
| 583 mainFrame()->document()->documentElement()->getApplyScroll())); | 583 mainFrame()->document()->documentElement()->getApplyScroll())); |
| 584 EXPECT_TRUE(mainController->isViewportScrollCallback( | 584 EXPECT_TRUE(mainController.isViewportScrollCallback( |
| 585 container->getApplyScroll())); | 585 container->getApplyScroll())); |
| 586 } | 586 } |
| 587 | 587 |
| 588 // Unsetting the root scroller in the iframe should reset its effective | 588 // Unsetting the root scroller in the iframe should reset its effective |
| 589 // root scroller to the iframe's documentElement and thus the iframe's | 589 // root scroller to the iframe's documentElement and thus the iframe's |
| 590 // documentElement becomes the global root scroller. | 590 // documentElement becomes the global root scroller. |
| 591 { | 591 { |
| 592 iframe->contentDocument()->setRootScroller(nullptr, nonThrow); | 592 iframe->contentDocument()->setRootScroller(nullptr, nonThrow); |
| 593 mainFrameView()->updateAllLifecyclePhases(); | 593 mainFrameView()->updateAllLifecyclePhases(); |
| 594 EXPECT_EQ( | 594 EXPECT_EQ( |
| 595 mainController->rootScrollerLayer(), | 595 mainController.rootScrollerLayer(), |
| 596 iframe->contentDocument()->view()->layerForScrolling()); | 596 iframe->contentDocument()->view()->layerForScrolling()); |
| 597 EXPECT_FALSE(mainController->isViewportScrollCallback( | 597 EXPECT_FALSE(mainController.isViewportScrollCallback( |
| 598 container->getApplyScroll())); | 598 container->getApplyScroll())); |
| 599 EXPECT_FALSE(mainController->isViewportScrollCallback( | 599 EXPECT_FALSE(mainController.isViewportScrollCallback( |
| 600 mainFrame()->document()->documentElement()->getApplyScroll())); | 600 mainFrame()->document()->documentElement()->getApplyScroll())); |
| 601 EXPECT_TRUE(mainController->isViewportScrollCallback( | 601 EXPECT_TRUE(mainController.isViewportScrollCallback( |
| 602 iframe->contentDocument()->documentElement()->getApplyScroll())); | 602 iframe->contentDocument()->documentElement()->getApplyScroll())); |
| 603 } | 603 } |
| 604 | 604 |
| 605 // Finally, unsetting the main frame's root scroller should reset it to the | 605 // Finally, unsetting the main frame's root scroller should reset it to the |
| 606 // documentElement and corresponding layer. | 606 // documentElement and corresponding layer. |
| 607 { | 607 { |
| 608 mainFrame()->document()->setRootScroller(nullptr, nonThrow); | 608 mainFrame()->document()->setRootScroller(nullptr, nonThrow); |
| 609 mainFrameView()->updateAllLifecyclePhases(); | 609 mainFrameView()->updateAllLifecyclePhases(); |
| 610 EXPECT_EQ( | 610 EXPECT_EQ( |
| 611 mainController->rootScrollerLayer(), | 611 mainController.rootScrollerLayer(), |
| 612 mainFrameView()->layerForScrolling()); | 612 mainFrameView()->layerForScrolling()); |
| 613 EXPECT_TRUE(mainController->isViewportScrollCallback( | 613 EXPECT_TRUE(mainController.isViewportScrollCallback( |
| 614 mainFrame()->document()->documentElement()->getApplyScroll())); | 614 mainFrame()->document()->documentElement()->getApplyScroll())); |
| 615 EXPECT_FALSE(mainController->isViewportScrollCallback( | 615 EXPECT_FALSE(mainController.isViewportScrollCallback( |
| 616 container->getApplyScroll())); | 616 container->getApplyScroll())); |
| 617 EXPECT_FALSE(mainController->isViewportScrollCallback( | 617 EXPECT_FALSE(mainController.isViewportScrollCallback( |
| 618 iframe->contentDocument()->documentElement()->getApplyScroll())); | 618 iframe->contentDocument()->documentElement()->getApplyScroll())); |
| 619 } | 619 } |
| 620 } | 620 } |
| 621 | 621 |
| 622 TEST_F(RootScrollerTest, TestSetRootScrollerCausesViewportLayerChange) | 622 TEST_F(RootScrollerTest, TestSetRootScrollerCausesViewportLayerChange) |
| 623 { | 623 { |
| 624 // TODO(bokan): Need a test that changing root scrollers actually sets the | 624 // TODO(bokan): Need a test that changing root scrollers actually sets the |
| 625 // outer viewport layer on the compositor, even in the absence of other | 625 // outer viewport layer on the compositor, even in the absence of other |
| 626 // compositing changes. crbug.com/505516 | 626 // compositing changes. crbug.com/505516 |
| 627 } | 627 } |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 761 } | 761 } |
| 762 | 762 |
| 763 // Reset explicitly to prevent lifetime issues with the RemoteFrameClient. | 763 // Reset explicitly to prevent lifetime issues with the RemoteFrameClient. |
| 764 m_helper.reset(); | 764 m_helper.reset(); |
| 765 } | 765 } |
| 766 | 766 |
| 767 // Tests that clipping layers belonging to any compositors in the ancestor chain | 767 // Tests that clipping layers belonging to any compositors in the ancestor chain |
| 768 // of the global root scroller have their masking bit removed. | 768 // of the global root scroller have their masking bit removed. |
| 769 TEST_F(RootScrollerTest, RemoveClippingOnCompositorLayers) | 769 TEST_F(RootScrollerTest, RemoveClippingOnCompositorLayers) |
| 770 { | 770 { |
| 771 // TODO(bokan): Remove casts to TDRSC once follow-up patch lands separating
TDRSC | |
| 772 // from RootScrollerController. | |
| 773 | |
| 774 initialize("root-scroller-iframe.html"); | 771 initialize("root-scroller-iframe.html"); |
| 775 | 772 |
| 776 HTMLFrameOwnerElement* iframe = toHTMLFrameOwnerElement( | 773 HTMLFrameOwnerElement* iframe = toHTMLFrameOwnerElement( |
| 777 mainFrame()->document()->getElementById("iframe")); | 774 mainFrame()->document()->getElementById("iframe")); |
| 778 Element* container = | 775 Element* container = |
| 779 iframe->contentDocument()->getElementById("container"); | 776 iframe->contentDocument()->getElementById("container"); |
| 780 | 777 |
| 781 RootScrollerController* mainController = | 778 RootScrollerController* mainController = |
| 782 mainFrame()->document()->rootScrollerController(); | 779 mainFrame()->document()->rootScrollerController(); |
| 783 RootScrollerController* childController = | 780 RootScrollerController* childController = |
| 784 iframe->contentDocument()->rootScrollerController(); | 781 iframe->contentDocument()->rootScrollerController(); |
| 782 TopDocumentRootScrollerController& globalController = |
| 783 frameHost().globalRootScrollerController(); |
| 785 | 784 |
| 786 PaintLayerCompositor* mainCompositor = | 785 PaintLayerCompositor* mainCompositor = |
| 787 mainFrameView()->layoutViewItem().compositor(); | 786 mainFrameView()->layoutViewItem().compositor(); |
| 788 PaintLayerCompositor* childCompositor = | 787 PaintLayerCompositor* childCompositor = |
| 789 iframe->contentDocument()->view()->layoutViewItem().compositor(); | 788 iframe->contentDocument()->view()->layoutViewItem().compositor(); |
| 790 | 789 |
| 791 NonThrowableExceptionState nonThrow; | 790 NonThrowableExceptionState nonThrow; |
| 792 | 791 |
| 793 // No root scroller set, on the main frame the root content layer should | 792 // No root scroller set, on the main frame the root content layer should |
| 794 // clip. Additionally, on the child frame, the overflow controls host and | 793 // clip. Additionally, on the child frame, the overflow controls host and |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 839 // global root scroller we want it to behave as if it were the main frame, w
hich | 838 // global root scroller we want it to behave as if it were the main frame, w
hich |
| 840 // means it should clip only on its root content layer. | 839 // means it should clip only on its root content layer. |
| 841 { | 840 { |
| 842 iframe->contentDocument()->setRootScroller(nullptr, nonThrow); | 841 iframe->contentDocument()->setRootScroller(nullptr, nonThrow); |
| 843 mainFrameView()->updateAllLifecyclePhases(); | 842 mainFrameView()->updateAllLifecyclePhases(); |
| 844 | 843 |
| 845 ASSERT_EQ(iframe, mainController->effectiveRootScroller()); | 844 ASSERT_EQ(iframe, mainController->effectiveRootScroller()); |
| 846 ASSERT_EQ(iframe->contentDocument()->documentElement(), | 845 ASSERT_EQ(iframe->contentDocument()->documentElement(), |
| 847 childController->effectiveRootScroller()); | 846 childController->effectiveRootScroller()); |
| 848 ASSERT_EQ(iframe->contentDocument()->documentElement(), | 847 ASSERT_EQ(iframe->contentDocument()->documentElement(), |
| 849 ((TopDocumentRootScrollerController*)mainController) | 848 globalController.globalRootScroller()); |
| 850 ->globalRootScroller()); | |
| 851 | 849 |
| 852 EXPECT_FALSE(mainCompositor->rootContentLayer()->platformLayer() | 850 EXPECT_FALSE(mainCompositor->rootContentLayer()->platformLayer() |
| 853 ->masksToBounds()); | 851 ->masksToBounds()); |
| 854 EXPECT_FALSE(mainCompositor->rootGraphicsLayer()->platformLayer() | 852 EXPECT_FALSE(mainCompositor->rootGraphicsLayer()->platformLayer() |
| 855 ->masksToBounds()); | 853 ->masksToBounds()); |
| 856 EXPECT_FALSE(mainCompositor->containerLayer()->platformLayer() | 854 EXPECT_FALSE(mainCompositor->containerLayer()->platformLayer() |
| 857 ->masksToBounds()); | 855 ->masksToBounds()); |
| 858 | 856 |
| 859 EXPECT_TRUE(childCompositor->rootContentLayer()->platformLayer() | 857 EXPECT_TRUE(childCompositor->rootContentLayer()->platformLayer() |
| 860 ->masksToBounds()); | 858 ->masksToBounds()); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 872 | 870 |
| 873 { | 871 { |
| 874 mainFrame()->document()->setRootScroller(nullptr, nonThrow); | 872 mainFrame()->document()->setRootScroller(nullptr, nonThrow); |
| 875 mainFrameView()->updateAllLifecyclePhases(); | 873 mainFrameView()->updateAllLifecyclePhases(); |
| 876 | 874 |
| 877 ASSERT_EQ(mainFrame()->document()->documentElement(), | 875 ASSERT_EQ(mainFrame()->document()->documentElement(), |
| 878 mainController->effectiveRootScroller()); | 876 mainController->effectiveRootScroller()); |
| 879 ASSERT_EQ(iframe->contentDocument()->documentElement(), | 877 ASSERT_EQ(iframe->contentDocument()->documentElement(), |
| 880 childController->effectiveRootScroller()); | 878 childController->effectiveRootScroller()); |
| 881 ASSERT_EQ(mainFrame()->document()->documentElement(), | 879 ASSERT_EQ(mainFrame()->document()->documentElement(), |
| 882 ((TopDocumentRootScrollerController*)mainController) | 880 globalController.globalRootScroller()); |
| 883 ->globalRootScroller()); | |
| 884 | 881 |
| 885 EXPECT_TRUE(mainCompositor->rootContentLayer()->platformLayer() | 882 EXPECT_TRUE(mainCompositor->rootContentLayer()->platformLayer() |
| 886 ->masksToBounds()); | 883 ->masksToBounds()); |
| 887 EXPECT_FALSE(mainCompositor->rootGraphicsLayer()->platformLayer() | 884 EXPECT_FALSE(mainCompositor->rootGraphicsLayer()->platformLayer() |
| 888 ->masksToBounds()); | 885 ->masksToBounds()); |
| 889 EXPECT_FALSE(mainCompositor->containerLayer()->platformLayer() | 886 EXPECT_FALSE(mainCompositor->containerLayer()->platformLayer() |
| 890 ->masksToBounds()); | 887 ->masksToBounds()); |
| 891 | 888 |
| 892 EXPECT_TRUE(childCompositor->rootContentLayer()->platformLayer() | 889 EXPECT_TRUE(childCompositor->rootContentLayer()->platformLayer() |
| 893 ->masksToBounds()); | 890 ->masksToBounds()); |
| 894 EXPECT_TRUE(childCompositor->rootGraphicsLayer()->platformLayer() | 891 EXPECT_TRUE(childCompositor->rootGraphicsLayer()->platformLayer() |
| 895 ->masksToBounds()); | 892 ->masksToBounds()); |
| 896 EXPECT_TRUE(childCompositor->containerLayer()->platformLayer() | 893 EXPECT_TRUE(childCompositor->containerLayer()->platformLayer() |
| 897 ->masksToBounds()); | 894 ->masksToBounds()); |
| 898 } | 895 } |
| 899 | 896 |
| 900 // Set the iframe back as the main frame's root scroller. Since its the | 897 // Set the iframe back as the main frame's root scroller. Since its the |
| 901 // global root scroller again, it should clip like the root frame. This | 898 // global root scroller again, it should clip like the root frame. This |
| 902 // checks that we invalidate the compositing state even though the iframe's | 899 // checks that we invalidate the compositing state even though the iframe's |
| 903 // effective root scroller hasn't changed. | 900 // effective root scroller hasn't changed. |
| 904 { | 901 { |
| 905 mainFrame()->document()->setRootScroller(iframe, nonThrow); | 902 mainFrame()->document()->setRootScroller(iframe, nonThrow); |
| 906 mainFrameView()->updateAllLifecyclePhases(); | 903 mainFrameView()->updateAllLifecyclePhases(); |
| 907 | 904 |
| 908 ASSERT_EQ(iframe, mainController->effectiveRootScroller()); | 905 ASSERT_EQ(iframe, mainController->effectiveRootScroller()); |
| 909 ASSERT_EQ(iframe->contentDocument()->documentElement(), | 906 ASSERT_EQ(iframe->contentDocument()->documentElement(), |
| 910 childController->effectiveRootScroller()); | 907 childController->effectiveRootScroller()); |
| 911 ASSERT_EQ(iframe->contentDocument()->documentElement(), | 908 ASSERT_EQ(iframe->contentDocument()->documentElement(), |
| 912 ((TopDocumentRootScrollerController*)mainController) | 909 globalController.globalRootScroller()); |
| 913 ->globalRootScroller()); | |
| 914 | 910 |
| 915 EXPECT_FALSE(mainCompositor->rootContentLayer()->platformLayer() | 911 EXPECT_FALSE(mainCompositor->rootContentLayer()->platformLayer() |
| 916 ->masksToBounds()); | 912 ->masksToBounds()); |
| 917 EXPECT_FALSE(mainCompositor->rootGraphicsLayer()->platformLayer() | 913 EXPECT_FALSE(mainCompositor->rootGraphicsLayer()->platformLayer() |
| 918 ->masksToBounds()); | 914 ->masksToBounds()); |
| 919 EXPECT_FALSE(mainCompositor->containerLayer()->platformLayer() | 915 EXPECT_FALSE(mainCompositor->containerLayer()->platformLayer() |
| 920 ->masksToBounds()); | 916 ->masksToBounds()); |
| 921 | 917 |
| 922 EXPECT_TRUE(childCompositor->rootContentLayer()->platformLayer() | 918 EXPECT_TRUE(childCompositor->rootContentLayer()->platformLayer() |
| 923 ->masksToBounds()); | 919 ->masksToBounds()); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 950 EXPECT_FALSE(childCompositor->rootGraphicsLayer()->platformLayer() | 946 EXPECT_FALSE(childCompositor->rootGraphicsLayer()->platformLayer() |
| 951 ->masksToBounds()); | 947 ->masksToBounds()); |
| 952 EXPECT_FALSE(childCompositor->containerLayer()->platformLayer() | 948 EXPECT_FALSE(childCompositor->containerLayer()->platformLayer() |
| 953 ->masksToBounds()); | 949 ->masksToBounds()); |
| 954 } | 950 } |
| 955 } | 951 } |
| 956 | 952 |
| 957 } // namespace | 953 } // namespace |
| 958 | 954 |
| 959 } // namespace blink | 955 } // namespace blink |
| OLD | NEW |