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

Side by Side Diff: third_party/WebKit/Source/core/paint/PaintLayerTest.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
« no previous file with comments | « third_party/WebKit/Source/core/paint/PaintLayer.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/paint/PaintLayer.h" 5 #include "core/paint/PaintLayer.h"
6 6
7 #include "core/html/HTMLIFrameElement.h" 7 #include "core/html/HTMLIFrameElement.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/LayoutView.h" 10 #include "core/layout/LayoutView.h"
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 PaintLayer* layer = getPaintLayerByElementId("target"); 120 PaintLayer* layer = getPaintLayerByElementId("target");
121 EXPECT_EQ( 121 EXPECT_EQ(
122 LayoutRect(90, 40, 110, 243), 122 LayoutRect(90, 40, 110, 243),
123 layer->paintingExtent(document().layoutView()->layer(), LayoutSize(), 0)); 123 layer->paintingExtent(document().layoutView()->layer(), LayoutSize(), 0));
124 } 124 }
125 125
126 TEST_P(PaintLayerTest, ScrollsWithViewportRelativePosition) { 126 TEST_P(PaintLayerTest, ScrollsWithViewportRelativePosition) {
127 setBodyInnerHTML("<div id='target' style='position: relative'></div>"); 127 setBodyInnerHTML("<div id='target' style='position: relative'></div>");
128 128
129 PaintLayer* layer = getPaintLayerByElementId("target"); 129 PaintLayer* layer = getPaintLayerByElementId("target");
130 EXPECT_FALSE(layer->sticksToViewport()); 130 EXPECT_FALSE(layer->fixedToViewport());
131 } 131 }
132 132
133 TEST_P(PaintLayerTest, ScrollsWithViewportFixedPosition) { 133 TEST_P(PaintLayerTest, ScrollsWithViewportFixedPosition) {
134 setBodyInnerHTML("<div id='target' style='position: fixed'></div>"); 134 setBodyInnerHTML("<div id='target' style='position: fixed'></div>");
135 135
136 PaintLayer* layer = getPaintLayerByElementId("target"); 136 PaintLayer* layer = getPaintLayerByElementId("target");
137 EXPECT_TRUE(layer->sticksToViewport()); 137 EXPECT_TRUE(layer->fixedToViewport());
138 } 138 }
139 139
140 TEST_P(PaintLayerTest, ScrollsWithViewportFixedPositionInsideTransform) { 140 TEST_P(PaintLayerTest, ScrollsWithViewportFixedPositionInsideTransform) {
141 // We don't intend to launch SPv2 without root layer scrolling, so skip this 141 // We don't intend to launch SPv2 without root layer scrolling, so skip this
142 // test in that configuration because it's broken. 142 // test in that configuration because it's broken.
143 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled() && 143 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled() &&
144 !RuntimeEnabledFeatures::rootLayerScrollingEnabled()) 144 !RuntimeEnabledFeatures::rootLayerScrollingEnabled())
145 return; 145 return;
146 setBodyInnerHTML( 146 setBodyInnerHTML(
147 "<div style='transform: translateZ(0)'>" 147 "<div style='transform: translateZ(0)'>"
148 " <div id='target' style='position: fixed'></div>" 148 " <div id='target' style='position: fixed'></div>"
149 "</div>" 149 "</div>"
150 "<div style='width: 10px; height: 1000px'></div>"); 150 "<div style='width: 10px; height: 1000px'></div>");
151 PaintLayer* layer = getPaintLayerByElementId("target"); 151 PaintLayer* layer = getPaintLayerByElementId("target");
152 EXPECT_FALSE(layer->sticksToViewport()); 152 EXPECT_FALSE(layer->fixedToViewport());
153 } 153 }
154 154
155 TEST_P(PaintLayerTest, 155 TEST_P(PaintLayerTest,
156 ScrollsWithViewportFixedPositionInsideTransformNoScroll) { 156 ScrollsWithViewportFixedPositionInsideTransformNoScroll) {
157 setBodyInnerHTML( 157 setBodyInnerHTML(
158 "<div style='transform: translateZ(0)'>" 158 "<div style='transform: translateZ(0)'>"
159 " <div id='target' style='position: fixed'></div>" 159 " <div id='target' style='position: fixed'></div>"
160 "</div>"); 160 "</div>");
161 PaintLayer* layer = getPaintLayerByElementId("target"); 161 PaintLayer* layer = getPaintLayerByElementId("target");
162 162
163 // In SPv2 mode, we correctly determine that the frame doesn't scroll at all, 163 // In SPv2 mode, we correctly determine that the frame doesn't scroll at all,
164 // and so return true. 164 // and so return true.
165 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) 165 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled())
166 EXPECT_TRUE(layer->sticksToViewport()); 166 EXPECT_TRUE(layer->fixedToViewport());
167 else 167 else
168 EXPECT_FALSE(layer->sticksToViewport()); 168 EXPECT_FALSE(layer->fixedToViewport());
169 } 169 }
170 170
171 TEST_P(PaintLayerTest, ScrollsWithViewportStickyPosition) { 171 TEST_P(PaintLayerTest, SticksToScrollerStickyPosition) {
172 setBodyInnerHTML(
173 "<div style='transform: translateZ(0)'>"
174 " <div id='target' style='position: sticky; top: 0;'></div>"
175 "</div>"
176 "<div style='width: 10px; height: 1000px'></div>");
177
178 PaintLayer* layer = getPaintLayerByElementId("target");
179 EXPECT_TRUE(layer->sticksToScroller());
180 }
181
182 TEST_P(PaintLayerTest, SticksToScrollerNoAnchor) {
172 setBodyInnerHTML( 183 setBodyInnerHTML(
173 "<div style='transform: translateZ(0)'>" 184 "<div style='transform: translateZ(0)'>"
174 " <div id='target' style='position: sticky'></div>" 185 " <div id='target' style='position: sticky'></div>"
175 "</div>" 186 "</div>"
176 "<div style='width: 10px; height: 1000px'></div>"); 187 "<div style='width: 10px; height: 1000px'></div>");
177 188
178 PaintLayer* layer = getPaintLayerByElementId("target"); 189 PaintLayer* layer =
179 EXPECT_TRUE(layer->sticksToViewport()); 190 toLayoutBoxModelObject(getLayoutObjectByElementId("target"))->layer();
191 EXPECT_FALSE(layer->sticksToScroller());
180 } 192 }
181 193
182 TEST_P(PaintLayerTest, ScrollsWithViewportStickyPositionNoScroll) { 194 TEST_P(PaintLayerTest, SticksToScrollerStickyPositionNoScroll) {
183 setBodyInnerHTML( 195 setBodyInnerHTML(
184 "<div style='transform: translateZ(0)'>" 196 "<div style='transform: translateZ(0)'>"
185 " <div id='target' style='position: sticky'></div>" 197 " <div id='target' style='position: sticky; top: 0;'></div>"
186 "</div>"); 198 "</div>");
187 199
188 PaintLayer* layer = getPaintLayerByElementId("target"); 200 PaintLayer* layer = getPaintLayerByElementId("target");
189 EXPECT_TRUE(layer->sticksToViewport()); 201 EXPECT_TRUE(layer->sticksToScroller());
190 } 202 }
191 203
192 TEST_P(PaintLayerTest, ScrollsWithViewportStickyPositionInsideScroller) { 204 TEST_P(PaintLayerTest, SticksToScrollerStickyPositionInsideScroller) {
193 setBodyInnerHTML( 205 setBodyInnerHTML(
194 "<div style='overflow:scroll; width: 100px; height: 100px;'>" 206 "<div style='overflow:scroll; width: 100px; height: 100px;'>"
195 " <div id='target' style='position: sticky'></div>" 207 " <div id='target' style='position: sticky; top: 0;'></div>"
196 " <div style='width: 50px; height: 1000px;'></div>" 208 " <div style='width: 50px; height: 1000px;'></div>"
197 "</div>"); 209 "</div>");
198 210
199 PaintLayer* layer = getPaintLayerByElementId("target"); 211 PaintLayer* layer = getPaintLayerByElementId("target");
200 EXPECT_FALSE(layer->sticksToViewport()); 212 EXPECT_TRUE(layer->sticksToScroller());
201 } 213 }
202 214
203 TEST_P(PaintLayerTest, CompositedScrollingNoNeedsRepaint) { 215 TEST_P(PaintLayerTest, CompositedScrollingNoNeedsRepaint) {
204 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) 216 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled())
205 return; 217 return;
206 218
207 enableCompositing(); 219 enableCompositing();
208 setBodyInnerHTML( 220 setBodyInnerHTML(
209 "<div id='scroll' style='width: 100px; height: 100px; overflow: scroll;" 221 "<div id='scroll' style='width: 100px; height: 100px; overflow: scroll;"
210 " will-change: transform'>" 222 " will-change: transform'>"
(...skipping 747 matching lines...) Expand 10 before | Expand all | Expand 10 after
958 RefPtr<ComputedStyle> oldStyle = 970 RefPtr<ComputedStyle> oldStyle =
959 ComputedStyle::clone(targetObject->styleRef()); 971 ComputedStyle::clone(targetObject->styleRef());
960 ComputedStyle* newStyle = targetObject->mutableStyle(); 972 ComputedStyle* newStyle = targetObject->mutableStyle();
961 newStyle->setHasCurrentTransformAnimation(); 973 newStyle->setHasCurrentTransformAnimation();
962 targetPaintLayer->updateTransform(oldStyle.get(), *newStyle); 974 targetPaintLayer->updateTransform(oldStyle.get(), *newStyle);
963 975
964 EXPECT_NE(nullptr, targetPaintLayer->transform()); 976 EXPECT_NE(nullptr, targetPaintLayer->transform());
965 } 977 }
966 978
967 } // namespace blink 979 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/paint/PaintLayer.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698