Chromium Code Reviews| 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 DecorationLayerCreatedAndDestroyedInCompositedScrolling) { | |
|
flackr
2016/11/16 21:14:20
You should probably also test that we don't create
yigu
2016/11/17 15:53:15
Test added.
| |
| 841 setBodyInnerHTML( | |
| 842 "<style>" | |
| 843 "#scroller { overflow: scroll; height: 200px; width: 200px; background: " | |
| 844 "white local content-box; outline: 1px solid blue;}" | |
| 845 "#scrolled { height: 300px; }" | |
| 846 "</style>" | |
| 847 "<div id=\"parent\">" | |
| 848 " <div id=\"scroller\"><div id=\"scrolled\"></div></div>" | |
| 849 "</div>"); | |
| 850 document().view()->updateAllLifecyclePhases(); | |
| 851 | |
| 852 Element* scroller = document().getElementById("scroller"); | |
| 853 PaintLayer* paintLayer = | |
| 854 toLayoutBoxModelObject(scroller->layoutObject())->layer(); | |
| 855 ASSERT_TRUE(paintLayer); | |
| 856 | |
| 857 CompositedLayerMapping* mapping = paintLayer->compositedLayerMapping(); | |
| 858 EXPECT_FALSE(mapping->decorationLayer()); | |
| 859 | |
| 860 // The decoration layer is created when compositing. | |
| 861 scroller->setAttribute(HTMLNames::styleAttr, "outline-offset: -2px;"); | |
| 862 document().view()->updateAllLifecyclePhases(); | |
| 863 paintLayer = toLayoutBoxModelObject(scroller->layoutObject())->layer(); | |
| 864 ASSERT_TRUE(paintLayer); | |
| 865 | |
| 866 mapping = paintLayer->compositedLayerMapping(); | |
| 867 EXPECT_TRUE(mapping->decorationLayer()); | |
| 868 | |
| 869 // The decoration layer is destroyed when not compositing. | |
| 870 scroller->removeAttribute(HTMLNames::styleAttr); | |
| 871 document().view()->updateAllLifecyclePhases(); | |
| 872 paintLayer = toLayoutBoxModelObject(scroller->layoutObject())->layer(); | |
| 873 ASSERT_TRUE(paintLayer); | |
| 874 | |
| 875 mapping = paintLayer->compositedLayerMapping(); | |
| 876 EXPECT_FALSE(mapping->decorationLayer()); | |
| 877 } | |
|
flackr
2016/11/16 21:14:20
nit: Blank line between tests.
yigu
2016/11/17 15:53:15
Done.
| |
| 878 TEST_P(CompositedLayerMappingTest, | |
| 840 BackgroundPaintedIntoGraphicsLayerIfNotCompositedScrolling) { | 879 BackgroundPaintedIntoGraphicsLayerIfNotCompositedScrolling) { |
| 841 document().frame()->settings()->setPreferCompositingToLCDTextEnabled(true); | 880 document().frame()->settings()->setPreferCompositingToLCDTextEnabled(true); |
| 842 setBodyInnerHTML( | 881 setBodyInnerHTML( |
| 843 "<div id='container' style='overflow: scroll; width: 300px; height: " | 882 "<div id='container' style='overflow: scroll; width: 300px; height: " |
| 844 "300px; border-radius: 5px; background: white; will-change: transform;'>" | 883 "300px; border-radius: 5px; background: white; will-change: transform;'>" |
| 845 " <div style='background-color: blue; width: 2000px; height: " | 884 " <div style='background-color: blue; width: 2000px; height: " |
| 846 "2000px;'></div>" | 885 "2000px;'></div>" |
| 847 "</div>"); | 886 "</div>"); |
| 848 | 887 |
| 849 PaintLayer* layer = | 888 PaintLayer* layer = |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1001 document().view()->updateAllLifecyclePhases(); | 1040 document().view()->updateAllLifecyclePhases(); |
| 1002 ASSERT_EQ(document().documentElement(), | 1041 ASSERT_EQ(document().documentElement(), |
| 1003 rootScrollerController.globalRootScroller()); | 1042 rootScrollerController.globalRootScroller()); |
| 1004 | 1043 |
| 1005 EXPECT_TRUE(mapping3->clippingLayer()); | 1044 EXPECT_TRUE(mapping3->clippingLayer()); |
| 1006 EXPECT_TRUE(mapping3->clippingLayer()->platformLayer()->masksToBounds()); | 1045 EXPECT_TRUE(mapping3->clippingLayer()->platformLayer()->masksToBounds()); |
| 1007 } | 1046 } |
| 1008 } | 1047 } |
| 1009 | 1048 |
| 1010 } // namespace blink | 1049 } // namespace blink |
| OLD | NEW |