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

Side by Side Diff: third_party/WebKit/Source/core/frame/FrameViewTest.cpp

Issue 2811803003: Revert of Only create sticky position constraints for constrained sticky position. (Closed)
Patch Set: 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/frame/FrameView.h" 5 #include "core/frame/FrameView.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "bindings/core/v8/ExceptionState.h" 9 #include "bindings/core/v8/ExceptionState.h"
10 #include "core/frame/Settings.h" 10 #include "core/frame/Settings.h"
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 } 171 }
172 172
173 TEST_P(FrameViewTest, StyleChangeUpdatesViewportConstrainedObjects) { 173 TEST_P(FrameViewTest, StyleChangeUpdatesViewportConstrainedObjects) {
174 // When using root layer scrolling there is no concept of viewport constrained 174 // When using root layer scrolling there is no concept of viewport constrained
175 // objects, so skip this test. 175 // objects, so skip this test.
176 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) 176 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled())
177 return; 177 return;
178 178
179 GetDocument().body()->setInnerHTML( 179 GetDocument().body()->setInnerHTML(
180 "<style>.container { height: 200%; }" 180 "<style>.container { height: 200%; }"
181 "#sticky1 { position: sticky; top: 0; height: 50px; }" 181 "#sticky { position: sticky; top: 0; height: 50px; }</style>"
182 "#sticky2 { position: sticky; height: 50px; }</style>" 182 "<div class='container'><div id='sticky'></div></div>");
183 "<div class='container'>"
184 " <div id='sticky1'></div>"
185 " <div id='sticky2'></div>"
186 "</div>");
187 GetDocument().View()->UpdateAllLifecyclePhases(); 183 GetDocument().View()->UpdateAllLifecyclePhases();
188 184
189 LayoutBoxModelObject* sticky1 = ToLayoutBoxModelObject( 185 LayoutBoxModelObject* sticky = ToLayoutBoxModelObject(
190 GetDocument().GetElementById("sticky1")->GetLayoutObject()); 186 GetDocument().GetElementById("sticky")->GetLayoutObject());
191 LayoutBoxModelObject* sticky2 = ToLayoutBoxModelObject(
192 GetDocument().GetElementById("sticky2")->GetLayoutObject());
193 187
194 EXPECT_TRUE( 188 EXPECT_TRUE(
195 GetDocument().View()->ViewportConstrainedObjects()->Contains(sticky1)); 189 GetDocument().View()->ViewportConstrainedObjects()->Contains(sticky));
196 // #sticky2 is not viewport constrained because it has no anchor edges.
197 EXPECT_FALSE(
198 GetDocument().View()->ViewportConstrainedObjects()->Contains(sticky2));
199 190
200 // Making the element non-sticky should remove it from the set of 191 // Making the element non-sticky should remove it from the set of
201 // viewport-constrained objects. 192 // viewport-constrained objects.
202 GetDocument().GetElementById("sticky1")->setAttribute(HTMLNames::styleAttr, 193 GetDocument().GetElementById("sticky")->setAttribute(HTMLNames::styleAttr,
203 "position: relative"); 194 "position: relative");
204 GetDocument().View()->UpdateAllLifecyclePhases(); 195 GetDocument().View()->UpdateAllLifecyclePhases();
205 196
206 EXPECT_FALSE( 197 EXPECT_FALSE(
207 GetDocument().View()->ViewportConstrainedObjects()->Contains(sticky1)); 198 GetDocument().View()->ViewportConstrainedObjects()->Contains(sticky));
208 199
209 // And making it sticky again should put it back in that list. 200 // And making it sticky again should put it back in that list.
210 GetDocument().GetElementById("sticky1")->setAttribute(HTMLNames::styleAttr, 201 GetDocument().GetElementById("sticky")->setAttribute(HTMLNames::styleAttr,
211 ""); 202 "");
212 GetDocument().View()->UpdateAllLifecyclePhases(); 203 GetDocument().View()->UpdateAllLifecyclePhases();
213 204
214 EXPECT_TRUE( 205 EXPECT_TRUE(
215 GetDocument().View()->ViewportConstrainedObjects()->Contains(sticky1)); 206 GetDocument().View()->ViewportConstrainedObjects()->Contains(sticky));
216
217 // Adding an anchor edge on the non-anchored sticky should add it to the
218 // viewport-constrained objects.
219 GetDocument().GetElementById("sticky2")->setAttribute(HTMLNames::styleAttr,
220 "top: 0");
221 GetDocument().View()->UpdateAllLifecyclePhases();
222
223 EXPECT_TRUE(
224 GetDocument().View()->ViewportConstrainedObjects()->Contains(sticky2));
225
226 // Removing the anchor edge on a sticky position element should remove it from
227 // the viewport-constrained objects.
228 GetDocument().GetElementById("sticky2")->setAttribute(HTMLNames::styleAttr,
229 "");
230 GetDocument().View()->UpdateAllLifecyclePhases();
231
232 EXPECT_FALSE(
233 GetDocument().View()->ViewportConstrainedObjects()->Contains(sticky2));
234 } 207 }
235 208
236 } // namespace 209 } // namespace
237 } // namespace blink 210 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/frame/FrameView.cpp ('k') | third_party/WebKit/Source/core/layout/LayoutBoxModelObject.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698