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

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

Issue 2701993002: DO NOT COMMIT: Results of running new (proposed) clang-format on Blink (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/LayoutInline.h" 5 #include "core/layout/LayoutInline.h"
6 #include "core/layout/LayoutTestHelper.h" 6 #include "core/layout/LayoutTestHelper.h"
7 #include "core/layout/LayoutView.h" 7 #include "core/layout/LayoutView.h"
8 #include "platform/geometry/TransformState.h" 8 #include "platform/geometry/TransformState.h"
9 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h" 9 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 LayoutBox* target = toLayoutBox(getLayoutObjectByElementId("target")); 541 LayoutBox* target = toLayoutBox(getLayoutObjectByElementId("target"));
542 LayoutBox* container = toLayoutBox(getLayoutObjectByElementId("container")); 542 LayoutBox* container = toLayoutBox(getLayoutObjectByElementId("container"));
543 LayoutBox* body = container->parentBox(); 543 LayoutBox* body = container->parentBox();
544 LayoutBox* html = body->parentBox(); 544 LayoutBox* html = body->parentBox();
545 LayoutBox* view = html->parentBox(); 545 LayoutBox* view = html->parentBox();
546 ASSERT_TRUE(view->isLayoutView()); 546 ASSERT_TRUE(view->isLayoutView());
547 547
548 document().view()->layoutViewportScrollableArea()->setScrollOffset( 548 document().view()->layoutViewportScrollableArea()->setScrollOffset(
549 ScrollOffset(0.0, 50), ProgrammaticScroll); 549 ScrollOffset(0.0, 50), ProgrammaticScroll);
550 document().view()->updateAllLifecyclePhases(); 550 document().view()->updateAllLifecyclePhases();
551 EXPECT_EQ(50, document() 551 EXPECT_EQ(50,
552 .view() 552 document()
553 ->layoutViewportScrollableArea() 553 .view()
554 ->scrollOffsetInt() 554 ->layoutViewportScrollableArea()
555 .height()); 555 ->scrollOffsetInt()
556 .height());
556 557
557 FloatPoint mappedPoint = mapLocalToAncestor(target, view, FloatPoint()); 558 FloatPoint mappedPoint = mapLocalToAncestor(target, view, FloatPoint());
558 EXPECT_EQ(adjustForFrameScroll(FloatPoint(200, 250)), mappedPoint); 559 EXPECT_EQ(adjustForFrameScroll(FloatPoint(200, 250)), mappedPoint);
559 mappedPoint = mapAncestorToLocal(target, view, mappedPoint); 560 mappedPoint = mapAncestorToLocal(target, view, mappedPoint);
560 EXPECT_EQ(FloatPoint(), mappedPoint); 561 EXPECT_EQ(FloatPoint(), mappedPoint);
561 562
562 mappedPoint = mapLocalToAncestor(target, container, FloatPoint()); 563 mappedPoint = mapLocalToAncestor(target, container, FloatPoint());
563 EXPECT_EQ(FloatPoint(100, 100), mappedPoint); 564 EXPECT_EQ(FloatPoint(100, 100), mappedPoint);
564 mappedPoint = mapAncestorToLocal(target, container, FloatPoint(100, 100)); 565 mappedPoint = mapAncestorToLocal(target, container, FloatPoint(100, 100));
565 EXPECT_EQ(FloatPoint(), mappedPoint); 566 EXPECT_EQ(FloatPoint(), mappedPoint);
(...skipping 10 matching lines...) Expand all
576 LayoutBox* target = toLayoutBox(getLayoutObjectByElementId("target")); 577 LayoutBox* target = toLayoutBox(getLayoutObjectByElementId("target"));
577 LayoutBox* container = toLayoutBox(getLayoutObjectByElementId("container")); 578 LayoutBox* container = toLayoutBox(getLayoutObjectByElementId("container"));
578 LayoutBox* body = container->parentBox(); 579 LayoutBox* body = container->parentBox();
579 LayoutBox* html = body->parentBox(); 580 LayoutBox* html = body->parentBox();
580 LayoutBox* view = html->parentBox(); 581 LayoutBox* view = html->parentBox();
581 ASSERT_TRUE(view->isLayoutView()); 582 ASSERT_TRUE(view->isLayoutView());
582 583
583 document().view()->layoutViewportScrollableArea()->setScrollOffset( 584 document().view()->layoutViewportScrollableArea()->setScrollOffset(
584 ScrollOffset(0.0, 50), ProgrammaticScroll); 585 ScrollOffset(0.0, 50), ProgrammaticScroll);
585 document().view()->updateAllLifecyclePhases(); 586 document().view()->updateAllLifecyclePhases();
586 EXPECT_EQ(50, document() 587 EXPECT_EQ(50,
587 .view() 588 document()
588 ->layoutViewportScrollableArea() 589 .view()
589 ->scrollOffsetInt() 590 ->layoutViewportScrollableArea()
590 .height()); 591 ->scrollOffsetInt()
592 .height());
591 593
592 FloatPoint mappedPoint = mapLocalToAncestor(target, view, FloatPoint()); 594 FloatPoint mappedPoint = mapLocalToAncestor(target, view, FloatPoint());
593 EXPECT_EQ(adjustForFrameScroll(FloatPoint(200, 250)), mappedPoint); 595 EXPECT_EQ(adjustForFrameScroll(FloatPoint(200, 250)), mappedPoint);
594 mappedPoint = mapAncestorToLocal(target, view, mappedPoint); 596 mappedPoint = mapAncestorToLocal(target, view, mappedPoint);
595 EXPECT_EQ(FloatPoint(), mappedPoint); 597 EXPECT_EQ(FloatPoint(), mappedPoint);
596 598
597 mappedPoint = mapLocalToAncestor(target, container, FloatPoint()); 599 mappedPoint = mapLocalToAncestor(target, container, FloatPoint());
598 EXPECT_EQ(FloatPoint(100, 150), mappedPoint); 600 EXPECT_EQ(FloatPoint(100, 150), mappedPoint);
599 mappedPoint = mapAncestorToLocal(target, container, FloatPoint(100, 150)); 601 mappedPoint = mapAncestorToLocal(target, container, FloatPoint(100, 150));
600 EXPECT_EQ(FloatPoint(), mappedPoint); 602 EXPECT_EQ(FloatPoint(), mappedPoint);
601 } 603 }
602 604
603 TEST_P(MapCoordinatesTest, FixedPosInTransform) { 605 TEST_P(MapCoordinatesTest, FixedPosInTransform) {
604 setBodyInnerHTML( 606 setBodyInnerHTML(
605 "<style>#container { transform: translateY(100px); position: absolute; " 607 "<style>#container { transform: translateY(100px); position: absolute; "
606 "left: 0; top: 100px; }" 608 "left: 0; top: 100px; }"
607 ".fixed { position: fixed; top: 0; }" 609 ".fixed { position: fixed; top: 0; }"
608 ".spacer { height: 2000px; } </style>" 610 ".spacer { height: 2000px; } </style>"
609 "<div id='container'><div class='fixed' id='target'></div></div>" 611 "<div id='container'><div class='fixed' id='target'></div></div>"
610 "<div class='spacer'></div>"); 612 "<div class='spacer'></div>");
611 613
612 document().view()->layoutViewportScrollableArea()->setScrollOffset( 614 document().view()->layoutViewportScrollableArea()->setScrollOffset(
613 ScrollOffset(0.0, 50), ProgrammaticScroll); 615 ScrollOffset(0.0, 50), ProgrammaticScroll);
614 document().view()->updateAllLifecyclePhases(); 616 document().view()->updateAllLifecyclePhases();
615 EXPECT_EQ(50, document() 617 EXPECT_EQ(50,
616 .view() 618 document()
617 ->layoutViewportScrollableArea() 619 .view()
618 ->scrollOffsetInt() 620 ->layoutViewportScrollableArea()
619 .height()); 621 ->scrollOffsetInt()
622 .height());
620 623
621 LayoutBox* target = toLayoutBox(getLayoutObjectByElementId("target")); 624 LayoutBox* target = toLayoutBox(getLayoutObjectByElementId("target"));
622 LayoutBox* container = toLayoutBox(getLayoutObjectByElementId("container")); 625 LayoutBox* container = toLayoutBox(getLayoutObjectByElementId("container"));
623 LayoutBox* body = container->parentBox(); 626 LayoutBox* body = container->parentBox();
624 LayoutBox* html = body->parentBox(); 627 LayoutBox* html = body->parentBox();
625 LayoutBox* view = html->parentBox(); 628 LayoutBox* view = html->parentBox();
626 ASSERT_TRUE(view->isLayoutView()); 629 ASSERT_TRUE(view->isLayoutView());
627 630
628 FloatPoint mappedPoint = mapLocalToAncestor(target, view, FloatPoint()); 631 FloatPoint mappedPoint = mapLocalToAncestor(target, view, FloatPoint());
629 EXPECT_EQ(adjustForFrameScroll(FloatPoint(0, 100)), mappedPoint); 632 EXPECT_EQ(adjustForFrameScroll(FloatPoint(0, 100)), mappedPoint);
(...skipping 16 matching lines...) Expand all
646 "<style>#container { contain: paint; position: absolute; left: 0; top: " 649 "<style>#container { contain: paint; position: absolute; left: 0; top: "
647 "100px; }" 650 "100px; }"
648 ".fixed { position: fixed; top: 0; }" 651 ".fixed { position: fixed; top: 0; }"
649 ".spacer { height: 2000px; } </style>" 652 ".spacer { height: 2000px; } </style>"
650 "<div id='container'><div class='fixed' id='target'></div></div>" 653 "<div id='container'><div class='fixed' id='target'></div></div>"
651 "<div class='spacer'></div>"); 654 "<div class='spacer'></div>");
652 655
653 document().view()->layoutViewportScrollableArea()->setScrollOffset( 656 document().view()->layoutViewportScrollableArea()->setScrollOffset(
654 ScrollOffset(0.0, 50), ProgrammaticScroll); 657 ScrollOffset(0.0, 50), ProgrammaticScroll);
655 document().view()->updateAllLifecyclePhases(); 658 document().view()->updateAllLifecyclePhases();
656 EXPECT_EQ(50, document() 659 EXPECT_EQ(50,
657 .view() 660 document()
658 ->layoutViewportScrollableArea() 661 .view()
659 ->scrollOffsetInt() 662 ->layoutViewportScrollableArea()
660 .height()); 663 ->scrollOffsetInt()
664 .height());
661 665
662 LayoutBox* target = toLayoutBox(getLayoutObjectByElementId("target")); 666 LayoutBox* target = toLayoutBox(getLayoutObjectByElementId("target"));
663 LayoutBox* container = toLayoutBox(getLayoutObjectByElementId("container")); 667 LayoutBox* container = toLayoutBox(getLayoutObjectByElementId("container"));
664 LayoutBox* body = container->parentBox(); 668 LayoutBox* body = container->parentBox();
665 LayoutBox* html = body->parentBox(); 669 LayoutBox* html = body->parentBox();
666 LayoutBox* view = html->parentBox(); 670 LayoutBox* view = html->parentBox();
667 ASSERT_TRUE(view->isLayoutView()); 671 ASSERT_TRUE(view->isLayoutView());
668 672
669 FloatPoint mappedPoint = mapLocalToAncestor(target, view, FloatPoint()); 673 FloatPoint mappedPoint = mapLocalToAncestor(target, view, FloatPoint());
670 EXPECT_EQ(adjustForFrameScroll(FloatPoint(0, 100)), mappedPoint); 674 EXPECT_EQ(adjustForFrameScroll(FloatPoint(0, 100)), mappedPoint);
(...skipping 974 matching lines...) Expand 10 before | Expand all | Expand 10 after
1645 LayoutUnit::epsilon()); 1649 LayoutUnit::epsilon());
1646 EXPECT_NEAR(50.0, matrix.projectPoint(FloatPoint(100.0, 50.0)).y(), 1650 EXPECT_NEAR(50.0, matrix.projectPoint(FloatPoint(100.0, 50.0)).y(),
1647 LayoutUnit::epsilon()); 1651 LayoutUnit::epsilon());
1648 EXPECT_NEAR(25.0, matrix.projectPoint(FloatPoint(50.0, 100.0)).x(), 1652 EXPECT_NEAR(25.0, matrix.projectPoint(FloatPoint(50.0, 100.0)).x(),
1649 LayoutUnit::epsilon()); 1653 LayoutUnit::epsilon());
1650 EXPECT_NEAR(100.0, matrix.projectPoint(FloatPoint(50.0, 100.0)).y(), 1654 EXPECT_NEAR(100.0, matrix.projectPoint(FloatPoint(50.0, 100.0)).y(),
1651 LayoutUnit::epsilon()); 1655 LayoutUnit::epsilon());
1652 } 1656 }
1653 1657
1654 } // namespace blink 1658 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698