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

Side by Side Diff: third_party/WebKit/Source/core/layout/compositing/CompositedLayerMappingTest.cpp

Issue 2439113003: Fix the bug that negative outline-offset is covered up by composited (Closed)
Patch Set: Rename decorationLayer to decorationOutlineLayer Created 4 years, 1 month 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
OLDNEW
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
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 DecorationOutlineLayerOnlyCreatedInCompositedScrolling) {
841 setBodyInnerHTML(
842 "<style>"
843 "#target { overflow: scroll; height: 200px; width: 200px; will-change: "
844 "transform; background: white local content-box; "
845 "outline: 1px solid blue; outline-offset: -2px;}"
846 "#scrolled { height: 300px; }"
847 "</style>"
848 "<div id=\"parent\">"
849 " <div id=\"target\"><div id=\"scrolled\"></div></div>"
850 "</div>");
851 document().view()->updateAllLifecyclePhases();
852
853 Element* element = document().getElementById("target");
854 PaintLayer* paintLayer =
855 toLayoutBoxModelObject(element->layoutObject())->layer();
856 ASSERT_TRUE(paintLayer);
857
858 // Decoration outline layer is created when composited scrolling.
859 EXPECT_TRUE(paintLayer->hasCompositedLayerMapping());
860 EXPECT_TRUE(paintLayer->needsCompositedScrolling());
861
862 CompositedLayerMapping* mapping = paintLayer->compositedLayerMapping();
863 EXPECT_TRUE(mapping->decorationOutlineLayer());
864
865 // No decoration outline layer is created when not composited scrolling.
866 element->setAttribute(HTMLNames::styleAttr, "overflow: visible;");
867 document().view()->updateAllLifecyclePhases();
868 paintLayer = toLayoutBoxModelObject(element->layoutObject())->layer();
869 ASSERT_TRUE(paintLayer);
870
871 mapping = paintLayer->compositedLayerMapping();
872 EXPECT_FALSE(paintLayer->needsCompositedScrolling());
873 EXPECT_FALSE(mapping->decorationOutlineLayer());
874 }
875
876 TEST_P(CompositedLayerMappingTest,
877 DecorationOutlineLayerCreatedAndDestroyedInCompositedScrolling) {
878 setBodyInnerHTML(
879 "<style>"
880 "#scroller { overflow: scroll; height: 200px; width: 200px; background: "
881 "white local content-box; outline: 1px solid blue;}"
882 "#scrolled { height: 300px; }"
883 "</style>"
884 "<div id=\"parent\">"
885 " <div id=\"scroller\"><div id=\"scrolled\"></div></div>"
886 "</div>");
887 document().view()->updateAllLifecyclePhases();
888
889 Element* scroller = document().getElementById("scroller");
890 PaintLayer* paintLayer =
891 toLayoutBoxModelObject(scroller->layoutObject())->layer();
892 ASSERT_TRUE(paintLayer);
893
894 CompositedLayerMapping* mapping = paintLayer->compositedLayerMapping();
895 EXPECT_FALSE(mapping->decorationOutlineLayer());
896
897 // The decoration outline layer is created when composited scrolling
898 // with an outline drawn over the composited scrolling region.
899 scroller->setAttribute(HTMLNames::styleAttr, "outline-offset: -2px;");
900 document().view()->updateAllLifecyclePhases();
901 paintLayer = toLayoutBoxModelObject(scroller->layoutObject())->layer();
902 ASSERT_TRUE(paintLayer);
903
904 mapping = paintLayer->compositedLayerMapping();
905 EXPECT_TRUE(paintLayer->needsCompositedScrolling());
906 EXPECT_TRUE(mapping->decorationOutlineLayer());
907
908 // The decoration outline layer is destroyed when the scrolling region
909 // will not be covered up by the outline.
910 scroller->removeAttribute(HTMLNames::styleAttr);
911 document().view()->updateAllLifecyclePhases();
912 paintLayer = toLayoutBoxModelObject(scroller->layoutObject())->layer();
913 ASSERT_TRUE(paintLayer);
914
915 mapping = paintLayer->compositedLayerMapping();
916 EXPECT_FALSE(mapping->decorationOutlineLayer());
917 }
918
919 TEST_P(CompositedLayerMappingTest,
840 BackgroundPaintedIntoGraphicsLayerIfNotCompositedScrolling) { 920 BackgroundPaintedIntoGraphicsLayerIfNotCompositedScrolling) {
841 document().frame()->settings()->setPreferCompositingToLCDTextEnabled(true); 921 document().frame()->settings()->setPreferCompositingToLCDTextEnabled(true);
842 setBodyInnerHTML( 922 setBodyInnerHTML(
843 "<div id='container' style='overflow: scroll; width: 300px; height: " 923 "<div id='container' style='overflow: scroll; width: 300px; height: "
844 "300px; border-radius: 5px; background: white; will-change: transform;'>" 924 "300px; border-radius: 5px; background: white; will-change: transform;'>"
845 " <div style='background-color: blue; width: 2000px; height: " 925 " <div style='background-color: blue; width: 2000px; height: "
846 "2000px;'></div>" 926 "2000px;'></div>"
847 "</div>"); 927 "</div>");
848 928
849 PaintLayer* layer = 929 PaintLayer* layer =
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
1001 document().view()->updateAllLifecyclePhases(); 1081 document().view()->updateAllLifecyclePhases();
1002 ASSERT_EQ(document().documentElement(), 1082 ASSERT_EQ(document().documentElement(),
1003 rootScrollerController.globalRootScroller()); 1083 rootScrollerController.globalRootScroller());
1004 1084
1005 EXPECT_TRUE(mapping3->clippingLayer()); 1085 EXPECT_TRUE(mapping3->clippingLayer());
1006 EXPECT_TRUE(mapping3->clippingLayer()->platformLayer()->masksToBounds()); 1086 EXPECT_TRUE(mapping3->clippingLayer()->platformLayer()->masksToBounds());
1007 } 1087 }
1008 } 1088 }
1009 1089
1010 } // namespace blink 1090 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698