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 819 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
830 ASSERT_TRUE(mapping->scrollingContentsLayer()); | 830 ASSERT_TRUE(mapping->scrollingContentsLayer()); |
831 EXPECT_EQ( | 831 EXPECT_EQ( |
832 static_cast<GraphicsLayerPaintingPhase>( | 832 static_cast<GraphicsLayerPaintingPhase>( |
833 GraphicsLayerPaintOverflowContents | | 833 GraphicsLayerPaintOverflowContents | |
834 GraphicsLayerPaintCompositedScroll | GraphicsLayerPaintForeground), | 834 GraphicsLayerPaintCompositedScroll | GraphicsLayerPaintForeground), |
835 mapping->scrollingContentsLayer()->paintingPhase()); | 835 mapping->scrollingContentsLayer()->paintingPhase()); |
836 EXPECT_FALSE(mapping->foregroundLayer()); | 836 EXPECT_FALSE(mapping->foregroundLayer()); |
837 } | 837 } |
838 | 838 |
839 TEST_P(CompositedLayerMappingTest, | 839 TEST_P(CompositedLayerMappingTest, |
| 840 DecorationLayerOnlyCreatedInCompositedScrolling) { |
| 841 setBodyInnerHTML( |
| 842 "<div id='target' style='overflow: scroll; height: 200px; background: " |
| 843 "white; will-change: transform; " |
| 844 "outline: 1px solid blue; outline-offset: -2px; '>" |
| 845 " <div style ='height: 300px; '></div>" |
| 846 "</div>"); |
| 847 document().view()->updateAllLifecyclePhases(); |
| 848 |
| 849 Element* element = document().getElementById("target"); |
| 850 PaintLayer* paintLayer = |
| 851 toLayoutBoxModelObject(element->layoutObject())->layer(); |
| 852 ASSERT_TRUE(paintLayer); |
| 853 |
| 854 // Decoration layer is created when composited scrolling. |
| 855 EXPECT_TRUE(paintLayer->hasCompositedLayerMapping()); |
| 856 EXPECT_TRUE(paintLayer->needsCompositedScrolling()); |
| 857 |
| 858 CompositedLayerMapping* mapping = paintLayer->compositedLayerMapping(); |
| 859 EXPECT_TRUE(mapping->decorationLayer()); |
| 860 |
| 861 // No decoration layer is created when not composited scrolling. |
| 862 element->setAttribute(HTMLNames::styleAttr, "overflow: visible;"); |
| 863 document().view()->updateAllLifecyclePhases(); |
| 864 |
| 865 EXPECT_FALSE(paintLayer->needsCompositedScrolling()); |
| 866 EXPECT_FALSE(mapping->decorationLayer()); |
| 867 } |
| 868 |
| 869 TEST_P(CompositedLayerMappingTest, |
| 870 DecorationLayerCreatedAndDestroyedInCompositedScrolling) { |
| 871 setBodyInnerHTML( |
| 872 "<style>" |
| 873 "#scroller { overflow: scroll; height: 200px; width: 200px; background: " |
| 874 "white local content-box; outline: 1px solid blue;}" |
| 875 "#scrolled { height: 300px; }" |
| 876 "</style>" |
| 877 "<div id=\"parent\">" |
| 878 " <div id=\"scroller\"><div id=\"scrolled\"></div></div>" |
| 879 "</div>"); |
| 880 document().view()->updateAllLifecyclePhases(); |
| 881 |
| 882 Element* scroller = document().getElementById("scroller"); |
| 883 PaintLayer* paintLayer = |
| 884 toLayoutBoxModelObject(scroller->layoutObject())->layer(); |
| 885 ASSERT_TRUE(paintLayer); |
| 886 |
| 887 CompositedLayerMapping* mapping = paintLayer->compositedLayerMapping(); |
| 888 EXPECT_FALSE(mapping->decorationLayer()); |
| 889 |
| 890 // The decoration layer is created when composited scrolling |
| 891 // with an outline drawn over the composited scrolling region. |
| 892 scroller->setAttribute(HTMLNames::styleAttr, "outline-offset: -2px;"); |
| 893 document().view()->updateAllLifecyclePhases(); |
| 894 paintLayer = toLayoutBoxModelObject(scroller->layoutObject())->layer(); |
| 895 ASSERT_TRUE(paintLayer); |
| 896 |
| 897 mapping = paintLayer->compositedLayerMapping(); |
| 898 EXPECT_TRUE(paintLayer->needsCompositedScrolling()); |
| 899 EXPECT_TRUE(mapping->decorationLayer()); |
| 900 |
| 901 // The decoration layer is destroyed when the scrolling region |
| 902 // will not be covered up by the outline. |
| 903 scroller->removeAttribute(HTMLNames::styleAttr); |
| 904 document().view()->updateAllLifecyclePhases(); |
| 905 paintLayer = toLayoutBoxModelObject(scroller->layoutObject())->layer(); |
| 906 ASSERT_TRUE(paintLayer); |
| 907 |
| 908 mapping = paintLayer->compositedLayerMapping(); |
| 909 EXPECT_FALSE(mapping->decorationLayer()); |
| 910 } |
| 911 |
| 912 TEST_P(CompositedLayerMappingTest, |
840 BackgroundPaintedIntoGraphicsLayerIfNotCompositedScrolling) { | 913 BackgroundPaintedIntoGraphicsLayerIfNotCompositedScrolling) { |
841 document().frame()->settings()->setPreferCompositingToLCDTextEnabled(true); | 914 document().frame()->settings()->setPreferCompositingToLCDTextEnabled(true); |
842 setBodyInnerHTML( | 915 setBodyInnerHTML( |
843 "<div id='container' style='overflow: scroll; width: 300px; height: " | 916 "<div id='container' style='overflow: scroll; width: 300px; height: " |
844 "300px; border-radius: 5px; background: white; will-change: transform;'>" | 917 "300px; border-radius: 5px; background: white; will-change: transform;'>" |
845 " <div style='background-color: blue; width: 2000px; height: " | 918 " <div style='background-color: blue; width: 2000px; height: " |
846 "2000px;'></div>" | 919 "2000px;'></div>" |
847 "</div>"); | 920 "</div>"); |
848 | 921 |
849 PaintLayer* layer = | 922 PaintLayer* layer = |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1001 document().view()->updateAllLifecyclePhases(); | 1074 document().view()->updateAllLifecyclePhases(); |
1002 ASSERT_EQ(document().documentElement(), | 1075 ASSERT_EQ(document().documentElement(), |
1003 rootScrollerController.globalRootScroller()); | 1076 rootScrollerController.globalRootScroller()); |
1004 | 1077 |
1005 EXPECT_TRUE(mapping3->clippingLayer()); | 1078 EXPECT_TRUE(mapping3->clippingLayer()); |
1006 EXPECT_TRUE(mapping3->clippingLayer()->platformLayer()->masksToBounds()); | 1079 EXPECT_TRUE(mapping3->clippingLayer()->platformLayer()->masksToBounds()); |
1007 } | 1080 } |
1008 } | 1081 } |
1009 | 1082 |
1010 } // namespace blink | 1083 } // namespace blink |
OLD | NEW |