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

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

Issue 2706673002: Mark elements as viewport constrained when they become sticky positioned (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/LayoutBoxModelObject.h" 5 #include "core/layout/LayoutBoxModelObject.h"
6 6
7 #include "core/dom/DOMTokenList.h" 7 #include "core/dom/DOMTokenList.h"
8 #include "core/dom/DocumentLifecycle.h" 8 #include "core/dom/DocumentLifecycle.h"
9 #include "core/html/HTMLElement.h" 9 #include "core/html/HTMLElement.h"
10 #include "core/layout/ImageQualityController.h" 10 #include "core/layout/ImageQualityController.h"
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 321
322 // After updating compositing inputs we should have the updated position. 322 // After updating compositing inputs we should have the updated position.
323 document().view()->updateAllLifecyclePhases(); 323 document().view()->updateAllLifecyclePhases();
324 EXPECT_EQ(50.f, 324 EXPECT_EQ(50.f,
325 getScrollContainerRelativeStickyBoxRect( 325 getScrollContainerRelativeStickyBoxRect(
326 scrollableArea->stickyConstraintsMap().get(sticky->layer())) 326 scrollableArea->stickyConstraintsMap().get(sticky->layer()))
327 .location() 327 .location()
328 .x()); 328 .x());
329 } 329 }
330 330
331 TEST_F(LayoutBoxModelObjectTest, StyleChangesUpdateViewportConstrainedObjects) {
332 setBodyInnerHTML(
333 "<style>"
334 ".container { height: 200%; }"
335 "#sticky { position: sticky; top: 0; height: 50px; }</style>"
336 "<div class='container'><div id='sticky'></div></div>");
337
338 LayoutBoxModelObject* sticky =
339 toLayoutBoxModelObject(getLayoutObjectByElementId("sticky"));
340
341 EXPECT_TRUE(
342 document().view()->viewportConstrainedObjects()->contains(sticky));
343
344 RefPtr<ComputedStyle> relativeStyle = ComputedStyle::clone(*sticky->style());
345 relativeStyle->setPosition(EPosition::kRelative);
346 sticky->setStyle(relativeStyle.get());
347
348 EXPECT_FALSE(
349 document().view()->viewportConstrainedObjects()->contains(sticky));
350
351 RefPtr<ComputedStyle> stickyStyle = ComputedStyle::clone(*sticky->style());
352 stickyStyle->setPosition(EPosition::kSticky);
353 sticky->setStyle(stickyStyle.get());
354
355 EXPECT_TRUE(
356 document().view()->viewportConstrainedObjects()->contains(sticky));
357 }
358
331 } // namespace blink 359 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698