| 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/layout/compositing/CompositedLayerMapping.h" | 5 #include "core/layout/compositing/CompositedLayerMapping.h" |
| 6 | 6 |
| 7 #include "core/frame/FrameView.h" | 7 #include "core/frame/FrameView.h" |
| 8 #include "core/layout/LayoutBoxModelObject.h" | 8 #include "core/layout/LayoutBoxModelObject.h" |
| 9 #include "core/layout/LayoutTestHelper.h" | 9 #include "core/layout/LayoutTestHelper.h" |
| 10 #include "core/layout/api/LayoutViewItem.h" | 10 #include "core/layout/api/LayoutViewItem.h" |
| (...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 646 EXPECT_EQ(static_cast<GraphicsLayerPaintingPhase>(GraphicsLayerPaintOverflow
Contents | GraphicsLayerPaintCompositedScroll | GraphicsLayerPaintForeground), m
apping->scrollingContentsLayer()->paintingPhase()); | 646 EXPECT_EQ(static_cast<GraphicsLayerPaintingPhase>(GraphicsLayerPaintOverflow
Contents | GraphicsLayerPaintCompositedScroll | GraphicsLayerPaintForeground), m
apping->scrollingContentsLayer()->paintingPhase()); |
| 647 EXPECT_FALSE(mapping->foregroundLayer()); | 647 EXPECT_FALSE(mapping->foregroundLayer()); |
| 648 } | 648 } |
| 649 | 649 |
| 650 // Make sure that clipping layers are removed or their masking bit turned off | 650 // Make sure that clipping layers are removed or their masking bit turned off |
| 651 // when they're an ancestor of the root scroller element. | 651 // when they're an ancestor of the root scroller element. |
| 652 TEST_F(CompositedLayerMappingTest, RootScrollerAncestorsNotClipped) | 652 TEST_F(CompositedLayerMappingTest, RootScrollerAncestorsNotClipped) |
| 653 { | 653 { |
| 654 NonThrowableExceptionState nonThrow; | 654 NonThrowableExceptionState nonThrow; |
| 655 | 655 |
| 656 // TODO(bokan): Avoid cast once follow-up patch separates TDRSC from | 656 TopDocumentRootScrollerController& rootScrollerController = |
| 657 // RootScrollerController. | 657 document().frameHost()->globalRootScrollerController(); |
| 658 TopDocumentRootScrollerController* rootScrollerController = | |
| 659 (TopDocumentRootScrollerController*)document().rootScrollerController(); | |
| 660 | 658 |
| 661 setBodyInnerHTML( | 659 setBodyInnerHTML( |
| 662 // The container DIV is composited with scrolling contents and a | 660 // The container DIV is composited with scrolling contents and a |
| 663 // non-composited parent that clips it. | 661 // non-composited parent that clips it. |
| 664 "<div id='clip' style='overflow: hidden; width: 200px; height: 200px; po
sition: absolute; left: 0px; top: 0px;'>" | 662 "<div id='clip' style='overflow: hidden; width: 200px; height: 200px; po
sition: absolute; left: 0px; top: 0px;'>" |
| 665 " <div id='container' style='transform: translateZ(0); overflow: scro
ll; width: 300px; height: 300px'>" | 663 " <div id='container' style='transform: translateZ(0); overflow: scro
ll; width: 300px; height: 300px'>" |
| 666 " <div style='width: 2000px; height: 2000px;'>lorem ipsum</div>" | 664 " <div style='width: 2000px; height: 2000px;'>lorem ipsum</div>" |
| 667 " <div id='innerScroller' style='width: 800px; height: 600px; lef
t: 0px; top: 0px; position: absolute; overflow: scroll'>" | 665 " <div id='innerScroller' style='width: 800px; height: 600px; lef
t: 0px; top: 0px; position: absolute; overflow: scroll'>" |
| 668 " <div style='height: 2000px; width: 2000px'></div>" | 666 " <div style='height: 2000px; width: 2000px'></div>" |
| 669 " </div>" | 667 " </div>" |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 725 EXPECT_TRUE(mapping2->scrollingLayer()->platformLayer()->masksToBounds()
); | 723 EXPECT_TRUE(mapping2->scrollingLayer()->platformLayer()->masksToBounds()
); |
| 726 EXPECT_TRUE(mapping3->clippingLayer()->platformLayer()->masksToBounds())
; | 724 EXPECT_TRUE(mapping3->clippingLayer()->platformLayer()->masksToBounds())
; |
| 727 } | 725 } |
| 728 | 726 |
| 729 // Set the inner scroller in the first container as the root scroller. Its | 727 // Set the inner scroller in the first container as the root scroller. Its |
| 730 // clipping layer should be removed and the scrolling layer should not | 728 // clipping layer should be removed and the scrolling layer should not |
| 731 // mask. | 729 // mask. |
| 732 { | 730 { |
| 733 document().setRootScroller(innerScroller, nonThrow); | 731 document().setRootScroller(innerScroller, nonThrow); |
| 734 document().view()->updateAllLifecyclePhases(); | 732 document().view()->updateAllLifecyclePhases(); |
| 735 ASSERT_EQ(innerScroller, rootScrollerController->globalRootScroller()); | 733 ASSERT_EQ(innerScroller, rootScrollerController.globalRootScroller()); |
| 736 | 734 |
| 737 EXPECT_FALSE(mapping->ancestorClippingLayer()); | 735 EXPECT_FALSE(mapping->ancestorClippingLayer()); |
| 738 EXPECT_FALSE(mapping->scrollingLayer()->platformLayer()->masksToBounds()
); | 736 EXPECT_FALSE(mapping->scrollingLayer()->platformLayer()->masksToBounds()
); |
| 739 } | 737 } |
| 740 | 738 |
| 741 // Set the inner scroller in the second container as the root scroller. Its | 739 // Set the inner scroller in the second container as the root scroller. Its |
| 742 // scrolling layer should no longer mask. The clipping and scrolling layers | 740 // scrolling layer should no longer mask. The clipping and scrolling layers |
| 743 // on the first container should now reset back. | 741 // on the first container should now reset back. |
| 744 { | 742 { |
| 745 document().setRootScroller(innerScroller2, nonThrow); | 743 document().setRootScroller(innerScroller2, nonThrow); |
| 746 document().view()->updateAllLifecyclePhases(); | 744 document().view()->updateAllLifecyclePhases(); |
| 747 ASSERT_EQ(innerScroller2, rootScrollerController->globalRootScroller()); | 745 ASSERT_EQ(innerScroller2, rootScrollerController.globalRootScroller()); |
| 748 | 746 |
| 749 EXPECT_TRUE(mapping->ancestorClippingLayer()); | 747 EXPECT_TRUE(mapping->ancestorClippingLayer()); |
| 750 EXPECT_TRUE(mapping->ancestorClippingLayer()->platformLayer()->masksToBo
unds()); | 748 EXPECT_TRUE(mapping->ancestorClippingLayer()->platformLayer()->masksToBo
unds()); |
| 751 EXPECT_TRUE(mapping->scrollingLayer()->platformLayer()->masksToBounds())
; | 749 EXPECT_TRUE(mapping->scrollingLayer()->platformLayer()->masksToBounds())
; |
| 752 | 750 |
| 753 EXPECT_FALSE(mapping2->scrollingLayer()->platformLayer()->masksToBounds(
)); | 751 EXPECT_FALSE(mapping2->scrollingLayer()->platformLayer()->masksToBounds(
)); |
| 754 } | 752 } |
| 755 | 753 |
| 756 // Set the inner scroller in the third container as the root scroller. Its | 754 // Set the inner scroller in the third container as the root scroller. Its |
| 757 // clipping layer should be removed. | 755 // clipping layer should be removed. |
| 758 { | 756 { |
| 759 document().setRootScroller(innerScroller3, nonThrow); | 757 document().setRootScroller(innerScroller3, nonThrow); |
| 760 document().view()->updateAllLifecyclePhases(); | 758 document().view()->updateAllLifecyclePhases(); |
| 761 ASSERT_EQ(innerScroller3, rootScrollerController->globalRootScroller()); | 759 ASSERT_EQ(innerScroller3, rootScrollerController.globalRootScroller()); |
| 762 | 760 |
| 763 EXPECT_TRUE(mapping2->scrollingLayer()->platformLayer()->masksToBounds()
); | 761 EXPECT_TRUE(mapping2->scrollingLayer()->platformLayer()->masksToBounds()
); |
| 764 | 762 |
| 765 EXPECT_FALSE(mapping3->clippingLayer()); | 763 EXPECT_FALSE(mapping3->clippingLayer()); |
| 766 } | 764 } |
| 767 | 765 |
| 768 // Unset the root scroller. The clipping layer on the third container should | 766 // Unset the root scroller. The clipping layer on the third container should |
| 769 // be restored. | 767 // be restored. |
| 770 { | 768 { |
| 771 document().setRootScroller(nullptr, nonThrow); | 769 document().setRootScroller(nullptr, nonThrow); |
| 772 document().view()->updateAllLifecyclePhases(); | 770 document().view()->updateAllLifecyclePhases(); |
| 773 ASSERT_EQ(document().documentElement(), rootScrollerController->globalRo
otScroller()); | 771 ASSERT_EQ(document().documentElement(), rootScrollerController.globalRoo
tScroller()); |
| 774 | 772 |
| 775 EXPECT_TRUE(mapping3->clippingLayer()); | 773 EXPECT_TRUE(mapping3->clippingLayer()); |
| 776 EXPECT_TRUE(mapping3->clippingLayer()->platformLayer()->masksToBounds())
; | 774 EXPECT_TRUE(mapping3->clippingLayer()->platformLayer()->masksToBounds())
; |
| 777 } | 775 } |
| 778 } | 776 } |
| 779 | 777 |
| 780 } // namespace blink | 778 } // namespace blink |
| OLD | NEW |