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

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

Issue 2769353002: Only create sticky position constraints for constrained sticky position. (Closed)
Patch Set: Set dependent patch. Created 3 years, 9 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 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 } 165 }
166 166
167 TEST_P(FrameViewTest, StyleChangeUpdatesViewportConstrainedObjects) { 167 TEST_P(FrameViewTest, StyleChangeUpdatesViewportConstrainedObjects) {
168 // When using root layer scrolling there is no concept of viewport constrained 168 // When using root layer scrolling there is no concept of viewport constrained
169 // objects, so skip this test. 169 // objects, so skip this test.
170 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) 170 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled())
171 return; 171 return;
172 172
173 document().body()->setInnerHTML( 173 document().body()->setInnerHTML(
174 "<style>.container { height: 200%; }" 174 "<style>.container { height: 200%; }"
175 "#sticky { position: sticky; top: 0; height: 50px; }</style>" 175 "#sticky1 { position: sticky; top: 0; height: 50px; }"
176 "<div class='container'><div id='sticky'></div></div>"); 176 "#sticky2 { position: sticky; height: 50px; }</style>"
177 "<div class='container'>"
178 " <div id='sticky1'></div>"
179 " <div id='sticky2'></div>"
180 "</div>");
177 document().view()->updateAllLifecyclePhases(); 181 document().view()->updateAllLifecyclePhases();
178 182
179 LayoutBoxModelObject* sticky = toLayoutBoxModelObject( 183 LayoutBoxModelObject* sticky1 = toLayoutBoxModelObject(
180 document().getElementById("sticky")->layoutObject()); 184 document().getElementById("sticky1")->layoutObject());
185 LayoutBoxModelObject* sticky2 = toLayoutBoxModelObject(
186 document().getElementById("sticky2")->layoutObject());
181 187
182 EXPECT_TRUE( 188 EXPECT_TRUE(
183 document().view()->viewportConstrainedObjects()->contains(sticky)); 189 document().view()->viewportConstrainedObjects()->contains(sticky1));
190 // #sticky2 is not viewport constrained because it has no anchor edges.
191 EXPECT_FALSE(
192 document().view()->viewportConstrainedObjects()->contains(sticky2));
184 193
185 // Making the element non-sticky should remove it from the set of 194 // Making the element non-sticky should remove it from the set of
186 // viewport-constrained objects. 195 // viewport-constrained objects.
187 document().getElementById("sticky")->setAttribute(HTMLNames::styleAttr, 196 document().getElementById("sticky1")->setAttribute(HTMLNames::styleAttr,
188 "position: relative"); 197 "position: relative");
189 document().view()->updateAllLifecyclePhases(); 198 document().view()->updateAllLifecyclePhases();
190 199
191 EXPECT_FALSE( 200 EXPECT_FALSE(
192 document().view()->viewportConstrainedObjects()->contains(sticky)); 201 document().view()->viewportConstrainedObjects()->contains(sticky1));
193 202
194 // And making it sticky again should put it back in that list. 203 // And making it sticky again should put it back in that list.
195 document().getElementById("sticky")->setAttribute(HTMLNames::styleAttr, ""); 204 document().getElementById("sticky1")->setAttribute(HTMLNames::styleAttr, "");
196 document().view()->updateAllLifecyclePhases(); 205 document().view()->updateAllLifecyclePhases();
197 206
198 EXPECT_TRUE( 207 EXPECT_TRUE(
199 document().view()->viewportConstrainedObjects()->contains(sticky)); 208 document().view()->viewportConstrainedObjects()->contains(sticky1));
209
210 // Adding an anchor edge on the non-anchored sticky should add it to the
211 // viewport-constrained objects.
212 document().getElementById("sticky2")->setAttribute(HTMLNames::styleAttr,
213 "top: 0");
214 document().view()->updateAllLifecyclePhases();
215
216 EXPECT_TRUE(
217 document().view()->viewportConstrainedObjects()->contains(sticky2));
218
219 // Removing the anchor edge on a sticky position element should remove it from
220 // the viewport-constrained objects.
221 document().getElementById("sticky2")->setAttribute(HTMLNames::styleAttr, "");
222 document().view()->updateAllLifecyclePhases();
223
224 EXPECT_FALSE(
225 document().view()->viewportConstrainedObjects()->contains(sticky2));
200 } 226 }
201 227
202 } // namespace 228 } // namespace
203 } // namespace blink 229 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698