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

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

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

Powered by Google App Engine
This is Rietveld 408576698