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

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

Issue 2776563003: Only automatically promote sticky position elements which move with scroll. (Closed)
Patch Set: Merge with master Created 3 years, 8 months 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/CompositingReasonFinder.h" 5 #include "core/layout/compositing/CompositingReasonFinder.h"
6 6
7 #include "core/frame/FrameView.h" 7 #include "core/frame/FrameView.h"
8 #include "core/layout/LayoutBlock.h" 8 #include "core/layout/LayoutBlock.h"
9 #include "core/layout/LayoutTestHelper.h" 9 #include "core/layout/LayoutTestHelper.h"
10 #include "core/paint/PaintLayer.h" 10 #include "core/paint/PaintLayer.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 EXPECT_EQ(PaintsIntoOwnBacking, paintLayer->compositingState()); 54 EXPECT_EQ(PaintsIntoOwnBacking, paintLayer->compositingState());
55 EXPECT_TRUE(paintLayer->graphicsLayerBacking()->contentsOpaque()); 55 EXPECT_TRUE(paintLayer->graphicsLayerBacking()->contentsOpaque());
56 56
57 // The opaque fixed box with shadow should not be promoted because the layer 57 // The opaque fixed box with shadow should not be promoted because the layer
58 // will include the shadow which is not opaque. 58 // will include the shadow which is not opaque.
59 element = document().getElementById("opaque-with-shadow"); 59 element = document().getElementById("opaque-with-shadow");
60 paintLayer = toLayoutBoxModelObject(element->layoutObject())->layer(); 60 paintLayer = toLayoutBoxModelObject(element->layoutObject())->layer();
61 EXPECT_EQ(NotComposited, paintLayer->compositingState()); 61 EXPECT_EQ(NotComposited, paintLayer->compositingState());
62 } 62 }
63 63
64 TEST_F(CompositingReasonFinderTest, OnlyAnchoredStickyPositionPromoted) {
65 setBodyInnerHTML(
66 "<style>"
67 ".scroller {contain: paint; width: 400px; height: 400px; overflow: auto; "
68 "will-change: transform;}"
69 ".sticky { position: sticky; width: 10px; height: 10px;}</style>"
70 "<div class='scroller'>"
71 " <div id='sticky-top' class='sticky' style='top: 0px;'></div>"
72 " <div id='sticky-no-anchor' class='sticky'></div>"
73 " <div style='height: 2000px;'></div>"
74 "</div>");
75 document().view()->updateAllLifecyclePhases();
76
77 EXPECT_EQ(PaintsIntoOwnBacking,
78 toLayoutBoxModelObject(getLayoutObjectByElementId("sticky-top"))
79 ->layer()
80 ->compositingState());
81 EXPECT_EQ(NotComposited, toLayoutBoxModelObject(
82 getLayoutObjectByElementId("sticky-no-anchor"))
83 ->layer()
84 ->compositingState());
85 }
86
87 TEST_F(CompositingReasonFinderTest, OnlyScrollingStickyPositionPromoted) {
88 setBodyInnerHTML(
89 "<style>.scroller {width: 400px; height: 400px; overflow: auto; "
90 "will-change: transform;}"
91 ".sticky { position: sticky; top: 0; width: 10px; height: 10px;}"
92 "</style>"
93 "<div class='scroller'>"
94 " <div id='sticky-scrolling' class='sticky'></div>"
95 " <div style='height: 2000px;'></div>"
96 "</div>"
97 "<div class='scroller'>"
98 " <div id='sticky-no-scrolling' class='sticky'></div>"
99 "</div>");
100 document().view()->updateAllLifecyclePhases();
101
102 EXPECT_EQ(
103 PaintsIntoOwnBacking,
104 toLayoutBoxModelObject(getLayoutObjectByElementId("sticky-scrolling"))
105 ->layer()
106 ->compositingState());
107 EXPECT_EQ(
108 NotComposited,
109 toLayoutBoxModelObject(getLayoutObjectByElementId("sticky-no-scrolling"))
110 ->layer()
111 ->compositingState());
112 }
113
64 // Tests that a transform on the fixed or an ancestor will prevent promotion 114 // Tests that a transform on the fixed or an ancestor will prevent promotion
65 // TODO(flackr): Allow integer transforms as long as all of the ancestor 115 // TODO(flackr): Allow integer transforms as long as all of the ancestor
66 // transforms are also integer. 116 // transforms are also integer.
67 TEST_F(CompositingReasonFinderTest, OnlyNonTransformedFixedLayersPromoted) { 117 TEST_F(CompositingReasonFinderTest, OnlyNonTransformedFixedLayersPromoted) {
68 ScopedCompositeFixedPositionForTest compositeFixedPosition(true); 118 ScopedCompositeFixedPositionForTest compositeFixedPosition(true);
69 119
70 setBodyInnerHTML( 120 setBodyInnerHTML(
71 "<style>" 121 "<style>"
72 "#fixed { position: fixed; height: 200px; width: 200px; background: " 122 "#fixed { position: fixed; height: 200px; width: 200px; background: "
73 "white; top: 0; }" 123 "white; top: 0; }"
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 Element* innerSticky = document().getElementById("innerSticky"); 347 Element* innerSticky = document().getElementById("innerSticky");
298 PaintLayer* innerStickyLayer = 348 PaintLayer* innerStickyLayer =
299 toLayoutBoxModelObject(innerSticky->layoutObject())->layer(); 349 toLayoutBoxModelObject(innerSticky->layoutObject())->layer();
300 ASSERT_TRUE(innerStickyLayer); 350 ASSERT_TRUE(innerStickyLayer);
301 351
302 EXPECT_EQ(PaintsIntoOwnBacking, outerStickyLayer->compositingState()); 352 EXPECT_EQ(PaintsIntoOwnBacking, outerStickyLayer->compositingState());
303 EXPECT_EQ(PaintsIntoOwnBacking, innerStickyLayer->compositingState()); 353 EXPECT_EQ(PaintsIntoOwnBacking, innerStickyLayer->compositingState());
304 } 354 }
305 355
306 } // namespace blink 356 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698