Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(494)

Side by Side Diff: third_party/WebKit/Source/web/tests/RootScrollerTest.cpp

Issue 2745063005: Remove document.rootScroller compositing clipping effects. (Closed)
Patch Set: Fix Rebase Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/core/paint/PaintLayer.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "bindings/core/v8/NodeOrString.h" 5 #include "bindings/core/v8/NodeOrString.h"
6 #include "core/dom/ClientRect.h" 6 #include "core/dom/ClientRect.h"
7 #include "core/frame/BrowserControls.h" 7 #include "core/frame/BrowserControls.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/RootFrameViewport.h" 10 #include "core/frame/RootFrameViewport.h"
(...skipping 724 matching lines...) Expand 10 before | Expand all | Expand 10 after
735 // ViewportScrollCallback removed. Keep the scrolls to guard crashes 735 // ViewportScrollCallback removed. Keep the scrolls to guard crashes
736 // but the expectations on when a ViewportScrollCallback have changed 736 // but the expectations on when a ViewportScrollCallback have changed
737 // and should be updated. 737 // and should be updated.
738 // EXPECT_EQ(200, container->scrollTop()); 738 // EXPECT_EQ(200, container->scrollTop());
739 } 739 }
740 740
741 // Reset explicitly to prevent lifetime issues with the RemoteFrameClient. 741 // Reset explicitly to prevent lifetime issues with the RemoteFrameClient.
742 m_helper.reset(); 742 m_helper.reset();
743 } 743 }
744 744
745 GraphicsLayer* scrollingLayer(LayoutView& layoutView) {
746 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled())
747 return layoutView.layer()->compositedLayerMapping()->scrollingLayer();
748 return layoutView.compositor()->rootContentLayer();
749 }
750
751 // Tests that clipping layers belonging to any compositors in the ancestor chain
752 // of the global root scroller have their masking bit removed.
753 TEST_F(RootScrollerTest, RemoveClippingOnCompositorLayers) {
754 initialize("root-scroller-iframe.html");
755
756 HTMLFrameOwnerElement* iframe = toHTMLFrameOwnerElement(
757 mainFrame()->document()->getElementById("iframe"));
758 Element* container = iframe->contentDocument()->getElementById("container");
759
760 RootScrollerController& mainController =
761 mainFrame()->document()->rootScrollerController();
762 RootScrollerController& childController =
763 iframe->contentDocument()->rootScrollerController();
764 TopDocumentRootScrollerController& globalController =
765 page().globalRootScrollerController();
766
767 LayoutView* mainLayoutView = mainFrameView()->layoutView();
768 LayoutView* childLayoutView = iframe->contentDocument()->layoutView();
769 PaintLayerCompositor* mainCompositor = mainLayoutView->compositor();
770 PaintLayerCompositor* childCompositor = childLayoutView->compositor();
771
772 NonThrowableExceptionState nonThrow;
773
774 // No root scroller set, on the main frame the root content layer should
775 // clip. Additionally, on the child frame, the overflow controls host and
776 // container layers should also clip.
777 {
778 EXPECT_TRUE(
779 scrollingLayer(*mainLayoutView)->platformLayer()->masksToBounds());
780 EXPECT_FALSE(
781 mainCompositor->rootGraphicsLayer()->platformLayer()->masksToBounds());
782 EXPECT_FALSE(
783 mainCompositor->containerLayer()->platformLayer()->masksToBounds());
784
785 EXPECT_TRUE(
786 scrollingLayer(*childLayoutView)->platformLayer()->masksToBounds());
787 EXPECT_TRUE(
788 childCompositor->rootGraphicsLayer()->platformLayer()->masksToBounds());
789 EXPECT_TRUE(
790 childCompositor->containerLayer()->platformLayer()->masksToBounds());
791 }
792
793 // Now set the root scrollers such that the container in the iframe is the
794 // global root scroller. All the previously clipping layers in both paint
795 // layer compositors should no longer clip.
796 {
797 iframe->contentDocument()->setRootScroller(container, nonThrow);
798 mainFrame()->document()->setRootScroller(iframe, nonThrow);
799 mainFrameView()->updateAllLifecyclePhases();
800
801 ASSERT_EQ(iframe, &mainController.effectiveRootScroller());
802 ASSERT_EQ(container, &childController.effectiveRootScroller());
803
804 EXPECT_FALSE(
805 scrollingLayer(*mainLayoutView)->platformLayer()->masksToBounds());
806 EXPECT_FALSE(
807 mainCompositor->rootGraphicsLayer()->platformLayer()->masksToBounds());
808 EXPECT_FALSE(
809 mainCompositor->containerLayer()->platformLayer()->masksToBounds());
810
811 EXPECT_FALSE(
812 scrollingLayer(*childLayoutView)->platformLayer()->masksToBounds());
813 EXPECT_FALSE(
814 childCompositor->rootGraphicsLayer()->platformLayer()->masksToBounds());
815 EXPECT_FALSE(
816 childCompositor->containerLayer()->platformLayer()->masksToBounds());
817 }
818
819 // Now reset the iframe's root scroller. Since the iframe itself is now the
820 // global root scroller we want it to behave as if it were the main frame,
821 // which means it should clip only on its root content layer.
822 {
823 iframe->contentDocument()->setRootScroller(nullptr, nonThrow);
824 mainFrameView()->updateAllLifecyclePhases();
825
826 ASSERT_EQ(iframe, &mainController.effectiveRootScroller());
827 ASSERT_EQ(iframe->contentDocument(),
828 &childController.effectiveRootScroller());
829 ASSERT_EQ(iframe->contentDocument()->documentElement(),
830 globalController.globalRootScroller());
831
832 EXPECT_FALSE(
833 scrollingLayer(*mainLayoutView)->platformLayer()->masksToBounds());
834 EXPECT_FALSE(
835 mainCompositor->rootGraphicsLayer()->platformLayer()->masksToBounds());
836 EXPECT_FALSE(
837 mainCompositor->containerLayer()->platformLayer()->masksToBounds());
838
839 EXPECT_TRUE(
840 scrollingLayer(*childLayoutView)->platformLayer()->masksToBounds());
841 EXPECT_FALSE(
842 childCompositor->rootGraphicsLayer()->platformLayer()->masksToBounds());
843 EXPECT_FALSE(
844 childCompositor->containerLayer()->platformLayer()->masksToBounds());
845 }
846
847 // Now reset the main frame's root scroller. Its compositor should go back
848 // to clipping as well. Because the iframe is now no longer the global root
849 // scroller, it should go back to clipping its overflow host and container
850 // layers. This checks that we invalidate the compositing state even though
851 // the iframe's effective root scroller hasn't changed.
852
853 {
854 mainFrame()->document()->setRootScroller(nullptr, nonThrow);
855 mainFrameView()->updateAllLifecyclePhases();
856
857 ASSERT_EQ(mainFrame()->document(), &mainController.effectiveRootScroller());
858 ASSERT_EQ(iframe->contentDocument(),
859 &childController.effectiveRootScroller());
860 ASSERT_EQ(mainFrame()->document()->documentElement(),
861 globalController.globalRootScroller());
862
863 EXPECT_TRUE(
864 scrollingLayer(*mainLayoutView)->platformLayer()->masksToBounds());
865 EXPECT_FALSE(
866 mainCompositor->rootGraphicsLayer()->platformLayer()->masksToBounds());
867 EXPECT_FALSE(
868 mainCompositor->containerLayer()->platformLayer()->masksToBounds());
869
870 EXPECT_TRUE(
871 scrollingLayer(*childLayoutView)->platformLayer()->masksToBounds());
872 EXPECT_TRUE(
873 childCompositor->rootGraphicsLayer()->platformLayer()->masksToBounds());
874 EXPECT_TRUE(
875 childCompositor->containerLayer()->platformLayer()->masksToBounds());
876 }
877
878 // Set the iframe back as the main frame's root scroller. Since its the
879 // global root scroller again, it should clip like the root frame. This
880 // checks that we invalidate the compositing state even though the iframe's
881 // effective root scroller hasn't changed.
882 {
883 mainFrame()->document()->setRootScroller(iframe, nonThrow);
884 mainFrameView()->updateAllLifecyclePhases();
885
886 ASSERT_EQ(iframe, &mainController.effectiveRootScroller());
887 ASSERT_EQ(iframe->contentDocument(),
888 &childController.effectiveRootScroller());
889 ASSERT_EQ(iframe->contentDocument()->documentElement(),
890 globalController.globalRootScroller());
891
892 EXPECT_FALSE(
893 scrollingLayer(*mainLayoutView)->platformLayer()->masksToBounds());
894 EXPECT_FALSE(
895 mainCompositor->rootGraphicsLayer()->platformLayer()->masksToBounds());
896 EXPECT_FALSE(
897 mainCompositor->containerLayer()->platformLayer()->masksToBounds());
898
899 EXPECT_TRUE(
900 scrollingLayer(*childLayoutView)->platformLayer()->masksToBounds());
901 EXPECT_FALSE(
902 childCompositor->rootGraphicsLayer()->platformLayer()->masksToBounds());
903 EXPECT_FALSE(
904 childCompositor->containerLayer()->platformLayer()->masksToBounds());
905 }
906
907 // Set just the iframe's root scroller. We should stop clipping the
908 // iframe's compositor's layers but not the main frame's.
909 {
910 mainFrame()->document()->setRootScroller(nullptr, nonThrow);
911 iframe->contentDocument()->setRootScroller(container, nonThrow);
912 mainFrameView()->updateAllLifecyclePhases();
913
914 ASSERT_EQ(mainFrame()->document(), &mainController.effectiveRootScroller());
915 ASSERT_EQ(container, &childController.effectiveRootScroller());
916
917 EXPECT_TRUE(
918 scrollingLayer(*mainLayoutView)->platformLayer()->masksToBounds());
919 EXPECT_FALSE(
920 mainCompositor->rootGraphicsLayer()->platformLayer()->masksToBounds());
921 EXPECT_FALSE(
922 mainCompositor->containerLayer()->platformLayer()->masksToBounds());
923
924 EXPECT_FALSE(
925 scrollingLayer(*childLayoutView)->platformLayer()->masksToBounds());
926 EXPECT_FALSE(
927 childCompositor->rootGraphicsLayer()->platformLayer()->masksToBounds());
928 EXPECT_FALSE(
929 childCompositor->containerLayer()->platformLayer()->masksToBounds());
930 }
931 }
932
933 // Tests that the clipping layer is resized on the root scroller element even 745 // Tests that the clipping layer is resized on the root scroller element even
934 // if the layout height doesn't change. 746 // if the layout height doesn't change.
935 TEST_F(RootScrollerTest, BrowserControlsResizeClippingLayer) { 747 TEST_F(RootScrollerTest, BrowserControlsResizeClippingLayer) {
936 bool oldInertTopControls = RuntimeEnabledFeatures::inertTopControlsEnabled(); 748 bool oldInertTopControls = RuntimeEnabledFeatures::inertTopControlsEnabled();
937 RuntimeEnabledFeatures::setInertTopControlsEnabled(true); 749 RuntimeEnabledFeatures::setInertTopControlsEnabled(true);
938 750
939 initialize("root-scroller.html"); 751 initialize("root-scroller.html");
940 Element* container = mainFrame()->document()->getElementById("container"); 752 Element* container = mainFrame()->document()->getElementById("container");
941 753
942 { 754 {
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
1309 // FrameView without a layout. 1121 // FrameView without a layout.
1310 iframe->remove(); 1122 iframe->remove();
1311 1123
1312 EXPECT_EQ(mainFrameView()->layoutViewportScrollableArea(), 1124 EXPECT_EQ(mainFrameView()->layoutViewportScrollableArea(),
1313 &mainFrameView()->getRootFrameViewport()->layoutViewport()); 1125 &mainFrameView()->getRootFrameViewport()->layoutViewport());
1314 } 1126 }
1315 1127
1316 } // namespace 1128 } // namespace
1317 1129
1318 } // namespace blink 1130 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/paint/PaintLayer.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698