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

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

Issue 2716583005: Do not promote position sticky or fixed elements unless they move with scroll. (Closed)
Patch Set: Created 3 years, 10 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 document().frame()->settings()->setPreferCompositingToLCDTextEnabled(true);
66 setBodyInnerHTML(
67 "<style>"
68 ".scroller {contain: paint; width: 400px; height: 400px; overflow: auto;}"
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(
82 NotComposited,
83 toLayoutBoxModelObject(getLayoutObjectByElementId("sticky-no-anchor"))
84 ->layer()
85 ->compositingState());
86 }
87
88 TEST_F(CompositingReasonFinderTest, OnlyScrollingStickyPositionPromoted) {
89 document().frame()->settings()->setPreferCompositingToLCDTextEnabled(true);
90 setBodyInnerHTML(
91 "<style>.scroller {width: 400px; height: 400px; overflow: auto;}"
92 ".sticky { position: sticky; top: 0; width: 10px; height: 10px;}"
93 "</style>"
94 "<div class='scroller'>"
95 " <div id='sticky-scrolling' class='sticky'></div>"
96 " <div style='height: 2000px;'></div>"
97 "</div>"
98 "<div class='scroller'>"
99 " <div id='sticky-no-scrolling' class='sticky'></div>"
100 "</div>");
101 document().view()->updateAllLifecyclePhases();
102
103 EXPECT_EQ(
104 PaintsIntoOwnBacking,
105 toLayoutBoxModelObject(getLayoutObjectByElementId("sticky-scrolling"))
106 ->layer()
107 ->compositingState());
108 EXPECT_EQ(
109 NotComposited,
110 toLayoutBoxModelObject(getLayoutObjectByElementId("sticky-no-scrolling"))
111 ->layer()
112 ->compositingState());
113 }
114
64 // Tests that a transform on the fixed or an ancestor will prevent promotion 115 // 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 116 // TODO(flackr): Allow integer transforms as long as all of the ancestor
66 // transforms are also integer. 117 // transforms are also integer.
67 TEST_F(CompositingReasonFinderTest, OnlyNonTransformedFixedLayersPromoted) { 118 TEST_F(CompositingReasonFinderTest, OnlyNonTransformedFixedLayersPromoted) {
68 ScopedCompositeFixedPositionForTest compositeFixedPosition(true); 119 ScopedCompositeFixedPositionForTest compositeFixedPosition(true);
69 120
70 setBodyInnerHTML( 121 setBodyInnerHTML(
71 "<style>" 122 "<style>"
72 "#fixed { position: fixed; height: 200px; width: 200px; background: " 123 "#fixed { position: fixed; height: 200px; width: 200px; background: "
73 "white; top: 0; }" 124 "white; top: 0; }"
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 CompositingReasonFinder::requiresCompositingForEffectAnimation(*style)); 316 CompositingReasonFinder::requiresCompositingForEffectAnimation(*style));
266 317
267 style->setIsRunningOpacityAnimationOnCompositor(false); 318 style->setIsRunningOpacityAnimationOnCompositor(false);
268 style->setIsRunningFilterAnimationOnCompositor(false); 319 style->setIsRunningFilterAnimationOnCompositor(false);
269 style->setIsRunningBackdropFilterAnimationOnCompositor(true); 320 style->setIsRunningBackdropFilterAnimationOnCompositor(true);
270 EXPECT_TRUE( 321 EXPECT_TRUE(
271 CompositingReasonFinder::requiresCompositingForEffectAnimation(*style)); 322 CompositingReasonFinder::requiresCompositingForEffectAnimation(*style));
272 } 323 }
273 324
274 } // namespace blink 325 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698