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

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

Issue 2961613002: Slightly refactor StickyPositionScrollingConstraints API and add documentation (Closed)
Patch Set: More documentation, split out ancestor offset calculation Created 3 years, 5 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"
11 #include "core/layout/LayoutTestHelper.h" 11 #include "core/layout/LayoutTestHelper.h"
12 #include "core/page/scrolling/StickyPositionScrollingConstraints.h" 12 #include "core/page/scrolling/StickyPositionScrollingConstraints.h"
13 #include "core/paint/PaintLayer.h" 13 #include "core/paint/PaintLayer.h"
14 #include "core/paint/PaintLayerScrollableArea.h" 14 #include "core/paint/PaintLayerScrollableArea.h"
15 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
16 16
17 namespace blink { 17 namespace blink {
18 18
19 class LayoutBoxModelObjectTest : public RenderingTest { 19 class LayoutBoxModelObjectTest : public RenderingTest {
20 protected: 20 protected:
21 PaintLayer* GetPaintLayerByElementId(const char* id) {
22 return ToLayoutBoxModelObject(GetLayoutObjectByElementId(id))->Layer();
23 }
24
21 const FloatRect& GetScrollContainerRelativeContainingBlockRect( 25 const FloatRect& GetScrollContainerRelativeContainingBlockRect(
22 const StickyPositionScrollingConstraints& constraints) const { 26 const StickyPositionScrollingConstraints& constraints) const {
23 return constraints.ScrollContainerRelativeContainingBlockRect(); 27 return constraints.ScrollContainerRelativeContainingBlockRect();
24 } 28 }
25 29
26 const FloatRect& GetScrollContainerRelativeStickyBoxRect( 30 const FloatRect& GetScrollContainerRelativeStickyBoxRect(
27 const StickyPositionScrollingConstraints& constraints) const { 31 const StickyPositionScrollingConstraints& constraints) const {
28 return constraints.ScrollContainerRelativeStickyBoxRect(); 32 return constraints.ScrollContainerRelativeStickyBoxRect();
29 } 33 }
30 }; 34 };
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 "<div id='stickyOuterDiv'>" 353 "<div id='stickyOuterDiv'>"
350 " <div id='stickyOuterInline'>" 354 " <div id='stickyOuterInline'>"
351 " <div id='unanchoredSticky'>" 355 " <div id='unanchoredSticky'>"
352 " <div class='inline'>" 356 " <div class='inline'>"
353 " <div id='stickyInnerInline'></div>" 357 " <div id='stickyInnerInline'></div>"
354 " </div>" 358 " </div>"
355 " </div>" 359 " </div>"
356 " </div>" 360 " </div>"
357 "</div>"); 361 "</div>");
358 362
359 LayoutBoxModelObject* sticky_outer_div = 363 PaintLayer* sticky_outer_div = GetPaintLayerByElementId("stickyOuterDiv");
360 ToLayoutBoxModelObject(GetLayoutObjectByElementId("stickyOuterDiv")); 364 PaintLayer* sticky_outer_inline =
361 LayoutBoxModelObject* sticky_outer_inline = 365 GetPaintLayerByElementId("stickyOuterInline");
362 ToLayoutBoxModelObject(GetLayoutObjectByElementId("stickyOuterInline")); 366 PaintLayer* unanchored_sticky = GetPaintLayerByElementId("unanchoredSticky");
363 LayoutBoxModelObject* unanchored_sticky = 367 PaintLayer* sticky_inner_inline =
364 ToLayoutBoxModelObject(GetLayoutObjectByElementId("unanchoredSticky")); 368 GetPaintLayerByElementId("stickyInnerInline");
365 LayoutBoxModelObject* sticky_inner_inline =
366 ToLayoutBoxModelObject(GetLayoutObjectByElementId("stickyInnerInline"));
367 369
368 PaintLayerScrollableArea* scrollable_area = 370 PaintLayerScrollableArea* scrollable_area =
369 sticky_outer_div->Layer()->AncestorOverflowLayer()->GetScrollableArea(); 371 sticky_outer_div->AncestorOverflowLayer()->GetScrollableArea();
370 ASSERT_TRUE(scrollable_area); 372 ASSERT_TRUE(scrollable_area);
371 StickyConstraintsMap constraints_map = 373 StickyConstraintsMap constraints_map =
372 scrollable_area->GetStickyConstraintsMap(); 374 scrollable_area->GetStickyConstraintsMap();
373 375
374 ASSERT_TRUE(constraints_map.Contains(sticky_outer_div->Layer())); 376 ASSERT_TRUE(constraints_map.Contains(sticky_outer_div));
375 ASSERT_TRUE(constraints_map.Contains(sticky_outer_inline->Layer())); 377 ASSERT_TRUE(constraints_map.Contains(sticky_outer_inline));
376 ASSERT_FALSE(constraints_map.Contains(unanchored_sticky->Layer())); 378 ASSERT_FALSE(constraints_map.Contains(unanchored_sticky));
377 ASSERT_TRUE(constraints_map.Contains(sticky_inner_inline->Layer())); 379 ASSERT_TRUE(constraints_map.Contains(sticky_inner_inline));
378 380
379 // The outer block element trivially has no sticky-box shifting ancestor. 381 // The outer block element trivially has no sticky-box shifting ancestor.
380 EXPECT_FALSE(constraints_map.at(sticky_outer_div->Layer()) 382 EXPECT_FALSE(constraints_map.at(sticky_outer_div)
381 .NearestStickyBoxShiftingStickyBox()); 383 .NearestStickyLayerShiftingStickyBox());
382 384
383 // Neither does the outer inline element, as its parent element is also its 385 // Neither does the outer inline element, as its parent element is also its
384 // containing block. 386 // containing block.
385 EXPECT_FALSE(constraints_map.at(sticky_outer_inline->Layer()) 387 EXPECT_FALSE(constraints_map.at(sticky_outer_inline)
386 .NearestStickyBoxShiftingStickyBox()); 388 .NearestStickyLayerShiftingStickyBox());
387 389
388 // However the inner inline element does have a sticky-box shifting ancestor, 390 // However the inner inline element does have a sticky-box shifting ancestor,
389 // as its containing block is the ancestor block element, above its ancestor 391 // as its containing block is the ancestor block element, above its ancestor
390 // sticky element. 392 // sticky element.
391 EXPECT_EQ(sticky_outer_inline, 393 EXPECT_EQ(sticky_outer_inline, constraints_map.at(sticky_inner_inline)
392 constraints_map.at(sticky_inner_inline->Layer()) 394 .NearestStickyLayerShiftingStickyBox());
393 .NearestStickyBoxShiftingStickyBox());
394 } 395 }
395 396
396 // Verifies that the correct containing-block shifting ancestor is found when 397 // Verifies that the correct containing-block shifting ancestor is found when
397 // computing the sticky constraints. Any such ancestor is the first sticky 398 // computing the sticky constraints. Any such ancestor is the first sticky
398 // element between your containing block (inclusive) and your ancestor overflow 399 // element between your containing block (inclusive) and your ancestor overflow
399 // layer (exclusive). 400 // layer (exclusive).
400 TEST_F(LayoutBoxModelObjectTest, 401 TEST_F(LayoutBoxModelObjectTest,
401 StickyPositionFindsCorrectContainingBlockShiftingAncestor) { 402 StickyPositionFindsCorrectContainingBlockShiftingAncestor) {
402 // We make the scroller itself sticky in order to check that elements do not 403 // We make the scroller itself sticky in order to check that elements do not
403 // detect it as their containing-block shifting ancestor. 404 // detect it as their containing-block shifting ancestor.
404 SetBodyInnerHTML( 405 SetBodyInnerHTML(
405 "<style>#scroller { overflow-y: scroll; position: sticky; top: 0;}" 406 "<style>#scroller { overflow-y: scroll; position: sticky; top: 0;}"
406 "#stickyParent { position: sticky; top: 0;}" 407 "#stickyParent { position: sticky; top: 0;}"
407 "#stickyChild { position: sticky; top: 0;}" 408 "#stickyChild { position: sticky; top: 0;}"
408 "#unanchoredSticky { position: sticky; }" 409 "#unanchoredSticky { position: sticky; }"
409 "#stickyNestedChild { position: sticky; top: 0;}</style>" 410 "#stickyNestedChild { position: sticky; top: 0;}</style>"
410 "<div id='scroller'>" 411 "<div id='scroller'>"
411 " <div id='stickyParent'>" 412 " <div id='stickyParent'>"
412 " <div id='unanchoredSticky'>" 413 " <div id='unanchoredSticky'>"
413 " <div id='stickyChild'></div>" 414 " <div id='stickyChild'></div>"
414 " <div><div id='stickyNestedChild'></div></div>" 415 " <div><div id='stickyNestedChild'></div></div>"
415 " </div>" 416 " </div>"
416 " </div>" 417 " </div>"
417 "</div>"); 418 "</div>");
418 419
419 LayoutBoxModelObject* scroller = 420 PaintLayer* scroller = GetPaintLayerByElementId("scroller");
420 ToLayoutBoxModelObject(GetLayoutObjectByElementId("scroller")); 421 PaintLayer* sticky_parent = GetPaintLayerByElementId("stickyParent");
421 LayoutBoxModelObject* sticky_parent = 422 PaintLayer* sticky_child = GetPaintLayerByElementId("stickyChild");
422 ToLayoutBoxModelObject(GetLayoutObjectByElementId("stickyParent")); 423 PaintLayer* sticky_nested_child =
423 LayoutBoxModelObject* sticky_child = 424 GetPaintLayerByElementId("stickyNestedChild");
424 ToLayoutBoxModelObject(GetLayoutObjectByElementId("stickyChild"));
425 LayoutBoxModelObject* sticky_nested_child =
426 ToLayoutBoxModelObject(GetLayoutObjectByElementId("stickyNestedChild"));
427 425
428 PaintLayerScrollableArea* scrollable_area = 426 PaintLayerScrollableArea* scrollable_area = scroller->GetScrollableArea();
429 scroller->Layer()->GetScrollableArea();
430 ASSERT_TRUE(scrollable_area); 427 ASSERT_TRUE(scrollable_area);
431 StickyConstraintsMap constraints_map = 428 StickyConstraintsMap constraints_map =
432 scrollable_area->GetStickyConstraintsMap(); 429 scrollable_area->GetStickyConstraintsMap();
433 430
434 ASSERT_FALSE(constraints_map.Contains(scroller->Layer())); 431 ASSERT_FALSE(constraints_map.Contains(scroller));
435 ASSERT_TRUE(constraints_map.Contains(sticky_parent->Layer())); 432 ASSERT_TRUE(constraints_map.Contains(sticky_parent));
436 ASSERT_TRUE(constraints_map.Contains(sticky_child->Layer())); 433 ASSERT_TRUE(constraints_map.Contains(sticky_child));
437 ASSERT_TRUE(constraints_map.Contains(sticky_nested_child->Layer())); 434 ASSERT_TRUE(constraints_map.Contains(sticky_nested_child));
438 435
439 // The outer <div> should not detect the scroller as its containing-block 436 // The outer <div> should not detect the scroller as its containing-block
440 // shifting ancestor. 437 // shifting ancestor.
441 EXPECT_FALSE(constraints_map.at(sticky_parent->Layer()) 438 EXPECT_FALSE(constraints_map.at(sticky_parent)
442 .NearestStickyBoxShiftingContainingBlock()); 439 .NearestStickyLayerShiftingContainingBlock());
443 440
444 // Both inner children should detect the parent <div> as their 441 // Both inner children should detect the parent <div> as their
445 // containing-block shifting ancestor. They skip past unanchored sticky 442 // containing-block shifting ancestor. They skip past unanchored sticky
446 // because it will never have a non-zero offset. 443 // because it will never have a non-zero offset.
447 EXPECT_EQ(sticky_parent, constraints_map.at(sticky_child->Layer()) 444 EXPECT_EQ(sticky_parent, constraints_map.at(sticky_child)
448 .NearestStickyBoxShiftingContainingBlock()); 445 .NearestStickyLayerShiftingContainingBlock());
449 EXPECT_EQ(sticky_parent, constraints_map.at(sticky_nested_child->Layer()) 446 EXPECT_EQ(sticky_parent, constraints_map.at(sticky_nested_child)
450 .NearestStickyBoxShiftingContainingBlock()); 447 .NearestStickyLayerShiftingContainingBlock());
451 } 448 }
452 449
453 // Verifies that the correct containing-block shifting ancestor is found when 450 // Verifies that the correct containing-block shifting ancestor is found when
454 // computing the sticky constraints, in the case where the overflow ancestor is 451 // computing the sticky constraints, in the case where the overflow ancestor is
455 // the page itself. This is a special-case version of the test above, as we 452 // the page itself. This is a special-case version of the test above, as we
456 // often treat the root page as special when it comes to scroll logic. It should 453 // often treat the root page as special when it comes to scroll logic. It should
457 // not make a difference for containing-block shifting ancestor calculations. 454 // not make a difference for containing-block shifting ancestor calculations.
458 TEST_F(LayoutBoxModelObjectTest, 455 TEST_F(LayoutBoxModelObjectTest,
459 StickyPositionFindsCorrectContainingBlockShiftingAncestorRoot) { 456 StickyPositionFindsCorrectContainingBlockShiftingAncestorRoot) {
460 SetBodyInnerHTML( 457 SetBodyInnerHTML(
461 "<style>#stickyParent { position: sticky; top: 0;}" 458 "<style>#stickyParent { position: sticky; top: 0;}"
462 "#stickyGrandchild { position: sticky; top: 0;}</style>" 459 "#stickyGrandchild { position: sticky; top: 0;}</style>"
463 "<div id='stickyParent'><div><div id='stickyGrandchild'></div></div>" 460 "<div id='stickyParent'><div><div id='stickyGrandchild'></div></div>"
464 "</div>"); 461 "</div>");
465 462
466 LayoutBoxModelObject* sticky_parent = 463 PaintLayer* sticky_parent = GetPaintLayerByElementId("stickyParent");
467 ToLayoutBoxModelObject(GetLayoutObjectByElementId("stickyParent")); 464 PaintLayer* sticky_grandchild = GetPaintLayerByElementId("stickyGrandchild");
468 LayoutBoxModelObject* sticky_grandchild =
469 ToLayoutBoxModelObject(GetLayoutObjectByElementId("stickyGrandchild"));
470 465
471 PaintLayerScrollableArea* scrollable_area = 466 PaintLayerScrollableArea* scrollable_area =
472 sticky_parent->Layer()->AncestorOverflowLayer()->GetScrollableArea(); 467 sticky_parent->AncestorOverflowLayer()->GetScrollableArea();
473 ASSERT_TRUE(scrollable_area); 468 ASSERT_TRUE(scrollable_area);
474 StickyConstraintsMap constraints_map = 469 StickyConstraintsMap constraints_map =
475 scrollable_area->GetStickyConstraintsMap(); 470 scrollable_area->GetStickyConstraintsMap();
476 471
477 ASSERT_TRUE(constraints_map.Contains(sticky_parent->Layer())); 472 ASSERT_TRUE(constraints_map.Contains(sticky_parent));
478 ASSERT_TRUE(constraints_map.Contains(sticky_grandchild->Layer())); 473 ASSERT_TRUE(constraints_map.Contains(sticky_grandchild));
479 474
480 // The grandchild sticky should detect the parent as its containing-block 475 // The grandchild sticky should detect the parent as its containing-block
481 // shifting ancestor. 476 // shifting ancestor.
482 EXPECT_EQ(sticky_parent, constraints_map.at(sticky_grandchild->Layer()) 477 EXPECT_EQ(sticky_parent, constraints_map.at(sticky_grandchild)
483 .NearestStickyBoxShiftingContainingBlock()); 478 .NearestStickyLayerShiftingContainingBlock());
484 } 479 }
485 480
486 // Verifies that the correct containing-block shifting ancestor is found when 481 // Verifies that the correct containing-block shifting ancestor is found when
487 // computing the sticky constraints, in the case of tables. Tables are unusual 482 // computing the sticky constraints, in the case of tables. Tables are unusual
488 // because the containing block for all table elements is the <table> itself, so 483 // because the containing block for all table elements is the <table> itself, so
489 // we have to skip over elements to find the correct ancestor. 484 // we have to skip over elements to find the correct ancestor.
490 TEST_F(LayoutBoxModelObjectTest, 485 TEST_F(LayoutBoxModelObjectTest,
491 StickyPositionFindsCorrectContainingBlockShiftingAncestorTable) { 486 StickyPositionFindsCorrectContainingBlockShiftingAncestorTable) {
492 SetBodyInnerHTML( 487 SetBodyInnerHTML(
493 "<style>#scroller { overflow-y: scroll; }" 488 "<style>#scroller { overflow-y: scroll; }"
494 "#stickyOuter { position: sticky; top: 0;}" 489 "#stickyOuter { position: sticky; top: 0;}"
495 "#stickyTh { position: sticky; top: 0;}</style>" 490 "#stickyTh { position: sticky; top: 0;}</style>"
496 "<div id='scroller'><div id='stickyOuter'><table><thead><tr>" 491 "<div id='scroller'><div id='stickyOuter'><table><thead><tr>"
497 "<th id='stickyTh'></th></tr></thead></table></div></div>"); 492 "<th id='stickyTh'></th></tr></thead></table></div></div>");
498 493
499 LayoutBoxModelObject* scroller = 494 PaintLayer* scroller = GetPaintLayerByElementId("scroller");
500 ToLayoutBoxModelObject(GetLayoutObjectByElementId("scroller")); 495 PaintLayer* sticky_outer = GetPaintLayerByElementId("stickyOuter");
501 LayoutBoxModelObject* sticky_outer = 496 PaintLayer* sticky_th = GetPaintLayerByElementId("stickyTh");
502 ToLayoutBoxModelObject(GetLayoutObjectByElementId("stickyOuter"));
503 LayoutBoxModelObject* sticky_th =
504 ToLayoutBoxModelObject(GetLayoutObjectByElementId("stickyTh"));
505 497
506 PaintLayerScrollableArea* scrollable_area = 498 PaintLayerScrollableArea* scrollable_area = scroller->GetScrollableArea();
507 scroller->Layer()->GetScrollableArea();
508 ASSERT_TRUE(scrollable_area); 499 ASSERT_TRUE(scrollable_area);
509 StickyConstraintsMap constraints_map = 500 StickyConstraintsMap constraints_map =
510 scrollable_area->GetStickyConstraintsMap(); 501 scrollable_area->GetStickyConstraintsMap();
511 502
512 ASSERT_FALSE(constraints_map.Contains(scroller->Layer())); 503 ASSERT_FALSE(constraints_map.Contains(scroller));
513 ASSERT_TRUE(constraints_map.Contains(sticky_outer->Layer())); 504 ASSERT_TRUE(constraints_map.Contains(sticky_outer));
514 ASSERT_TRUE(constraints_map.Contains(sticky_th->Layer())); 505 ASSERT_TRUE(constraints_map.Contains(sticky_th));
515 506
516 // The table cell should detect the outer <div> as its containing-block 507 // The table cell should detect the outer <div> as its containing-block
517 // shifting ancestor. 508 // shifting ancestor.
518 EXPECT_EQ(sticky_outer, constraints_map.at(sticky_th->Layer()) 509 EXPECT_EQ(sticky_outer, constraints_map.at(sticky_th)
519 .NearestStickyBoxShiftingContainingBlock()); 510 .NearestStickyLayerShiftingContainingBlock());
520 } 511 }
521 512
522 // Verifies that the calculated position:sticky offsets are correct when we have 513 // Verifies that the calculated position:sticky offsets are correct when we have
523 // a simple case of nested sticky elements. 514 // a simple case of nested sticky elements.
524 TEST_F(LayoutBoxModelObjectTest, StickyPositionNested) { 515 TEST_F(LayoutBoxModelObjectTest, StickyPositionNested) {
525 SetBodyInnerHTML( 516 SetBodyInnerHTML(
526 "<style>#scroller { height: 100px; width: 100px; overflow-y: auto; }" 517 "<style>#scroller { height: 100px; width: 100px; overflow-y: auto; }"
527 "#prePadding { height: 50px }" 518 "#prePadding { height: 50px }"
528 "#stickyParent { position: sticky; top: 0; height: 50px; }" 519 "#stickyParent { position: sticky; top: 0; height: 50px; }"
529 "#stickyChild { position: sticky; top: 0; height: 25px; }" 520 "#stickyChild { position: sticky; top: 0; height: 25px; }"
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
922 ToLayoutBoxModelObject(GetLayoutObjectByElementId("scroller")); 913 ToLayoutBoxModelObject(GetLayoutObjectByElementId("scroller"));
923 PaintLayerScrollableArea* scrollable_area = scroller->GetScrollableArea(); 914 PaintLayerScrollableArea* scrollable_area = scroller->GetScrollableArea();
924 915
925 StickyConstraintsMap constraints_map = 916 StickyConstraintsMap constraints_map =
926 scrollable_area->GetStickyConstraintsMap(); 917 scrollable_area->GetStickyConstraintsMap();
927 ASSERT_TRUE(constraints_map.Contains(outer_sticky->Layer())); 918 ASSERT_TRUE(constraints_map.Contains(outer_sticky->Layer()));
928 ASSERT_TRUE(constraints_map.Contains(inner_sticky->Layer())); 919 ASSERT_TRUE(constraints_map.Contains(inner_sticky->Layer()));
929 920
930 // The inner sticky should not detect the outer one as any sort of ancestor. 921 // The inner sticky should not detect the outer one as any sort of ancestor.
931 EXPECT_FALSE(constraints_map.at(inner_sticky->Layer()) 922 EXPECT_FALSE(constraints_map.at(inner_sticky->Layer())
932 .NearestStickyBoxShiftingStickyBox()); 923 .NearestStickyLayerShiftingStickyBox());
933 EXPECT_FALSE(constraints_map.at(inner_sticky->Layer()) 924 EXPECT_FALSE(constraints_map.at(inner_sticky->Layer())
934 .NearestStickyBoxShiftingContainingBlock()); 925 .NearestStickyLayerShiftingContainingBlock());
935 926
936 // Scroll the page down. 927 // Scroll the page down.
937 scrollable_area->ScrollToAbsolutePosition( 928 scrollable_area->ScrollToAbsolutePosition(
938 FloatPoint(scrollable_area->ScrollPosition().X(), 100)); 929 FloatPoint(scrollable_area->ScrollPosition().X(), 100));
939 ASSERT_EQ(100.0, scrollable_area->ScrollPosition().Y()); 930 ASSERT_EQ(100.0, scrollable_area->ScrollPosition().Y());
940 931
941 // TODO(smcgruer): Until http://crbug.com/686164 is fixed, we need to update 932 // TODO(smcgruer): Until http://crbug.com/686164 is fixed, we need to update
942 // the constraints here before calculations will be correct. 933 // the constraints here before calculations will be correct.
943 inner_sticky->UpdateStickyPositionConstraints(); 934 inner_sticky->UpdateStickyPositionConstraints();
944 935
945 EXPECT_EQ(LayoutSize(0, 100), outer_sticky->StickyPositionOffset()); 936 EXPECT_EQ(LayoutSize(0, 100), outer_sticky->StickyPositionOffset());
946 EXPECT_EQ(LayoutSize(0, 25), inner_sticky->StickyPositionOffset()); 937 EXPECT_EQ(LayoutSize(0, 25), inner_sticky->StickyPositionOffset());
947 } 938 }
948 939
949 TEST_F(LayoutBoxModelObjectTest, NoCrashStackingContextChangeNonRooted) { 940 TEST_F(LayoutBoxModelObjectTest, NoCrashStackingContextChangeNonRooted) {
950 SetBodyInnerHTML("<div id='target'></div>"); 941 SetBodyInnerHTML("<div id='target'></div>");
951 auto& object = *GetLayoutObjectByElementId("target"); 942 auto& object = *GetLayoutObjectByElementId("target");
952 auto* parent = object.Parent(); 943 auto* parent = object.Parent();
953 object.SetDangerousOneWayParent(nullptr); 944 object.SetDangerousOneWayParent(nullptr);
954 EXPECT_FALSE(object.IsRooted()); 945 EXPECT_FALSE(object.IsRooted());
955 946
956 auto style = ComputedStyle::Create(); 947 auto style = ComputedStyle::Create();
957 style->SetIsStackingContext(true); 948 style->SetIsStackingContext(true);
958 object.SetStyle(style); // This should not crash. 949 object.SetStyle(style); // This should not crash.
959 object.SetDangerousOneWayParent(parent); 950 object.SetDangerousOneWayParent(parent);
960 } 951 }
961 952
962 } // namespace blink 953 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698