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

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: Add unit tests and nit 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 DecorationLayerOnlyCreatedInCompositedScrolling) {
841 setBodyInnerHTML(
842 "<div id='target' style='height: 200px; "
843 "will-change: transform;'></div>");
flackr 2016/11/17 16:10:45 This element should have a negative offset outline
yigu 2016/11/18 04:14:07 Done.
844 document().view()->updateAllLifecyclePhases();
845
846 Element* element = document().getElementById("target");
847 PaintLayer* paintLayer =
848 toLayoutBoxModelObject(element->layoutObject())->layer();
849 ASSERT_TRUE(paintLayer);
850
851 // No decoration layer is created when not composited scrolling.
852 EXPECT_TRUE(paintLayer->hasCompositedLayerMapping());
853 EXPECT_FALSE(paintLayer->needsCompositedScrolling());
854
855 CompositedLayerMapping* mapping = paintLayer->compositedLayerMapping();
856 EXPECT_FALSE(mapping->decorationLayer());
857 }
858
859 TEST_P(CompositedLayerMappingTest,
860 DecorationLayerCreatedAndDestroyedInCompositedScrolling) {
861 setBodyInnerHTML(
862 "<style>"
863 "#scroller { overflow: scroll; height: 200px; width: 200px; background: "
864 "white local content-box; outline: 1px solid blue;}"
865 "#scrolled { height: 300px; }"
866 "</style>"
867 "<div id=\"parent\">"
868 " <div id=\"scroller\"><div id=\"scrolled\"></div></div>"
869 "</div>");
870 document().view()->updateAllLifecyclePhases();
871
872 Element* scroller = document().getElementById("scroller");
873 PaintLayer* paintLayer =
874 toLayoutBoxModelObject(scroller->layoutObject())->layer();
875 ASSERT_TRUE(paintLayer);
876
877 CompositedLayerMapping* mapping = paintLayer->compositedLayerMapping();
878 EXPECT_FALSE(mapping->decorationLayer());
879
880 // The decoration layer is created when composited scrolling
881 // with an outline drawn over the composited scrolling region.
882 scroller->setAttribute(HTMLNames::styleAttr, "outline-offset: -2px;");
883 document().view()->updateAllLifecyclePhases();
884 paintLayer = toLayoutBoxModelObject(scroller->layoutObject())->layer();
885 ASSERT_TRUE(paintLayer);
886
887 mapping = paintLayer->compositedLayerMapping();
888 EXPECT_TRUE(paintLayer->needsCompositedScrolling());
889 EXPECT_TRUE(mapping->decorationLayer());
890
891 // The decoration layer is destroyed when the scrolling region
892 // will not be covered up by the outline.
893 scroller->removeAttribute(HTMLNames::styleAttr);
894 document().view()->updateAllLifecyclePhases();
895 paintLayer = toLayoutBoxModelObject(scroller->layoutObject())->layer();
896 ASSERT_TRUE(paintLayer);
897
898 mapping = paintLayer->compositedLayerMapping();
899 EXPECT_FALSE(mapping->decorationLayer());
900 }
901
902 TEST_P(CompositedLayerMappingTest,
840 BackgroundPaintedIntoGraphicsLayerIfNotCompositedScrolling) { 903 BackgroundPaintedIntoGraphicsLayerIfNotCompositedScrolling) {
841 document().frame()->settings()->setPreferCompositingToLCDTextEnabled(true); 904 document().frame()->settings()->setPreferCompositingToLCDTextEnabled(true);
842 setBodyInnerHTML( 905 setBodyInnerHTML(
843 "<div id='container' style='overflow: scroll; width: 300px; height: " 906 "<div id='container' style='overflow: scroll; width: 300px; height: "
844 "300px; border-radius: 5px; background: white; will-change: transform;'>" 907 "300px; border-radius: 5px; background: white; will-change: transform;'>"
845 " <div style='background-color: blue; width: 2000px; height: " 908 " <div style='background-color: blue; width: 2000px; height: "
846 "2000px;'></div>" 909 "2000px;'></div>"
847 "</div>"); 910 "</div>");
848 911
849 PaintLayer* layer = 912 PaintLayer* layer =
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
1001 document().view()->updateAllLifecyclePhases(); 1064 document().view()->updateAllLifecyclePhases();
1002 ASSERT_EQ(document().documentElement(), 1065 ASSERT_EQ(document().documentElement(),
1003 rootScrollerController.globalRootScroller()); 1066 rootScrollerController.globalRootScroller());
1004 1067
1005 EXPECT_TRUE(mapping3->clippingLayer()); 1068 EXPECT_TRUE(mapping3->clippingLayer());
1006 EXPECT_TRUE(mapping3->clippingLayer()->platformLayer()->masksToBounds()); 1069 EXPECT_TRUE(mapping3->clippingLayer()->platformLayer()->masksToBounds());
1007 } 1070 }
1008 } 1071 }
1009 1072
1010 } // namespace blink 1073 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698