| OLD | NEW |
| 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 "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 | 10 |
| (...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 484 "</div>"); | 484 "</div>"); |
| 485 | 485 |
| 486 LayoutObject* target = getLayoutObjectByElementId("sibling")->nextSibling(); | 486 LayoutObject* target = getLayoutObjectByElementId("sibling")->nextSibling(); |
| 487 ASSERT_TRUE(target->isText()); | 487 ASSERT_TRUE(target->isText()); |
| 488 LayoutBox* flowThread = toLayoutBox(target->parent()); | 488 LayoutBox* flowThread = toLayoutBox(target->parent()); |
| 489 ASSERT_TRUE(flowThread->isLayoutFlowThread()); | 489 ASSERT_TRUE(flowThread->isLayoutFlowThread()); |
| 490 LayoutBox* multicol = toLayoutBox(getLayoutObjectByElementId("multicol")); | 490 LayoutBox* multicol = toLayoutBox(getLayoutObjectByElementId("multicol")); |
| 491 | 491 |
| 492 FloatPoint mappedPoint = mapLocalToAncestor(target, flowThread, FloatPoint(1
0, 70)); | 492 FloatPoint mappedPoint = mapLocalToAncestor(target, flowThread, FloatPoint(1
0, 70)); |
| 493 EXPECT_EQ(FloatPoint(10, 70), mappedPoint); | 493 EXPECT_EQ(FloatPoint(10, 70), mappedPoint); |
| 494 mappedPoint = mapAncestorToLocal(target, flowThread, mappedPoint); |
| 495 EXPECT_EQ(FloatPoint(10, 70), mappedPoint); |
| 494 | 496 |
| 495 mappedPoint = mapLocalToAncestor(flowThread, multicol, mappedPoint); | 497 mappedPoint = mapLocalToAncestor(flowThread, multicol, FloatPoint(10, 70)); |
| 496 EXPECT_EQ(FloatPoint(225, 25), mappedPoint); | 498 EXPECT_EQ(FloatPoint(225, 25), mappedPoint); |
| 497 | |
| 498 mappedPoint = mapAncestorToLocal(flowThread, multicol, mappedPoint); | 499 mappedPoint = mapAncestorToLocal(flowThread, multicol, mappedPoint); |
| 499 EXPECT_EQ(FloatPoint(220, 20), mappedPoint); | |
| 500 | |
| 501 mappedPoint = mapAncestorToLocal(target, flowThread, mappedPoint); | |
| 502 EXPECT_EQ(FloatPoint(10, 70), mappedPoint); | 500 EXPECT_EQ(FloatPoint(10, 70), mappedPoint); |
| 503 } | 501 } |
| 504 | 502 |
| 505 TEST_F(MapCoordinatesTest, MulticolWithInline) | 503 TEST_F(MapCoordinatesTest, MulticolWithInline) |
| 506 { | 504 { |
| 507 setBodyInnerHTML( | 505 setBodyInnerHTML( |
| 508 "<div id='multicol' style='columns:2; column-gap:20px; width:400px; line
-height:50px; padding:5px; orphans:1; widows:1;'>" | 506 "<div id='multicol' style='columns:2; column-gap:20px; width:400px; line
-height:50px; padding:5px; orphans:1; widows:1;'>" |
| 509 " <span id='target'><br>text</span>" | 507 " <span id='target'><br>text</span>" |
| 510 "</div>"); | 508 "</div>"); |
| 511 | 509 |
| 512 LayoutObject* target = getLayoutObjectByElementId("target"); | 510 LayoutObject* target = getLayoutObjectByElementId("target"); |
| 513 LayoutBox* flowThread = toLayoutBox(target->parent()); | 511 LayoutBox* flowThread = toLayoutBox(target->parent()); |
| 514 ASSERT_TRUE(flowThread->isLayoutFlowThread()); | 512 ASSERT_TRUE(flowThread->isLayoutFlowThread()); |
| 515 LayoutBox* multicol = toLayoutBox(getLayoutObjectByElementId("multicol")); | 513 LayoutBox* multicol = toLayoutBox(getLayoutObjectByElementId("multicol")); |
| 516 | 514 |
| 517 FloatPoint mappedPoint = mapLocalToAncestor(target, flowThread, FloatPoint(1
0, 70)); | 515 FloatPoint mappedPoint = mapLocalToAncestor(target, flowThread, FloatPoint(1
0, 70)); |
| 518 EXPECT_EQ(FloatPoint(10, 70), mappedPoint); | 516 EXPECT_EQ(FloatPoint(10, 70), mappedPoint); |
| 517 mappedPoint = mapAncestorToLocal(target, flowThread, mappedPoint); |
| 518 EXPECT_EQ(FloatPoint(10, 70), mappedPoint); |
| 519 | 519 |
| 520 mappedPoint = mapLocalToAncestor(flowThread, multicol, mappedPoint); | 520 mappedPoint = mapLocalToAncestor(flowThread, multicol, FloatPoint(10, 70)); |
| 521 EXPECT_EQ(FloatPoint(225, 25), mappedPoint); | 521 EXPECT_EQ(FloatPoint(225, 25), mappedPoint); |
| 522 | |
| 523 mappedPoint = mapAncestorToLocal(flowThread, multicol, mappedPoint); | 522 mappedPoint = mapAncestorToLocal(flowThread, multicol, mappedPoint); |
| 524 EXPECT_EQ(FloatPoint(220, 20), mappedPoint); | |
| 525 | |
| 526 mappedPoint = mapAncestorToLocal(target, flowThread, mappedPoint); | |
| 527 EXPECT_EQ(FloatPoint(10, 70), mappedPoint); | 523 EXPECT_EQ(FloatPoint(10, 70), mappedPoint); |
| 528 } | 524 } |
| 529 | 525 |
| 530 TEST_F(MapCoordinatesTest, MulticolWithBlock) | 526 TEST_F(MapCoordinatesTest, MulticolWithBlock) |
| 531 { | 527 { |
| 532 setBodyInnerHTML( | 528 setBodyInnerHTML( |
| 533 "<div id='container' style='-webkit-columns:3; -webkit-column-gap:0; col
umn-fill:auto; width:300px; height:100px; border:8px solid; padding:7px;'>" | 529 "<div id='container' style='-webkit-columns:3; -webkit-column-gap:0; col
umn-fill:auto; width:300px; height:100px; border:8px solid; padding:7px;'>" |
| 534 " <div style='height:110px;'></div>" | 530 " <div style='height:110px;'></div>" |
| 535 " <div id='target' style='margin:10px; border:13px; padding:13px;'></
div>" | 531 " <div id='target' style='margin:10px; border:13px; padding:13px;'></
div>" |
| 536 "</div>"); | 532 "</div>"); |
| 537 | 533 |
| 538 LayoutBox* target = toLayoutBox(getLayoutObjectByElementId("target")); | 534 LayoutBox* target = toLayoutBox(getLayoutObjectByElementId("target")); |
| 539 LayoutBox* container = toLayoutBox(getLayoutObjectByElementId("container")); | 535 LayoutBox* container = toLayoutBox(getLayoutObjectByElementId("container")); |
| 540 | 536 |
| 541 FloatPoint mappedPoint = mapLocalToAncestor(target, container, FloatPoint())
; | 537 FloatPoint mappedPoint = mapLocalToAncestor(target, container, FloatPoint())
; |
| 542 EXPECT_EQ(FloatPoint(125, 35), mappedPoint); | 538 EXPECT_EQ(FloatPoint(125, 35), mappedPoint); |
| 543 mappedPoint = mapAncestorToLocal(target, container, mappedPoint); | 539 mappedPoint = mapAncestorToLocal(target, container, mappedPoint); |
| 544 EXPECT_EQ(FloatPoint(), mappedPoint); | 540 EXPECT_EQ(FloatPoint(), mappedPoint); |
| 545 | 541 |
| 546 // Walk each ancestor in the chain separately, to verify each step on the wa
y. | 542 // Walk each ancestor in the chain separately, to verify each step on the wa
y. |
| 547 LayoutBox* flowThread = target->parentBox(); | 543 LayoutBox* flowThread = target->parentBox(); |
| 548 ASSERT_TRUE(flowThread->isLayoutFlowThread()); | 544 ASSERT_TRUE(flowThread->isLayoutFlowThread()); |
| 549 | 545 |
| 550 mappedPoint = mapLocalToAncestor(target, flowThread, FloatPoint()); | 546 mappedPoint = mapLocalToAncestor(target, flowThread, FloatPoint()); |
| 551 EXPECT_EQ(FloatPoint(10, 120), mappedPoint); | 547 EXPECT_EQ(FloatPoint(10, 120), mappedPoint); |
| 552 | |
| 553 mappedPoint = mapLocalToAncestor(flowThread, container, mappedPoint); | |
| 554 EXPECT_EQ(FloatPoint(125, 35), mappedPoint); | |
| 555 | |
| 556 mappedPoint = mapAncestorToLocal(flowThread, container, mappedPoint); | |
| 557 EXPECT_EQ(FloatPoint(110, 20), mappedPoint); | |
| 558 | |
| 559 mappedPoint = mapAncestorToLocal(target, flowThread, mappedPoint); | 548 mappedPoint = mapAncestorToLocal(target, flowThread, mappedPoint); |
| 560 EXPECT_EQ(FloatPoint(), mappedPoint); | 549 EXPECT_EQ(FloatPoint(), mappedPoint); |
| 550 |
| 551 mappedPoint = mapLocalToAncestor(flowThread, container, FloatPoint(10, 120))
; |
| 552 EXPECT_EQ(FloatPoint(125, 35), mappedPoint); |
| 553 mappedPoint = mapAncestorToLocal(flowThread, container, mappedPoint); |
| 554 EXPECT_EQ(FloatPoint(10, 120), mappedPoint); |
| 561 } | 555 } |
| 562 | 556 |
| 563 TEST_F(MapCoordinatesTest, NestedMulticolWithBlock) | 557 TEST_F(MapCoordinatesTest, NestedMulticolWithBlock) |
| 564 { | 558 { |
| 565 setBodyInnerHTML( | 559 setBodyInnerHTML( |
| 566 "<div id='outerMulticol' style='columns:2; column-gap:0; column-fill:aut
o; width:560px; height:215px; border:8px solid; padding:7px;'>" | 560 "<div id='outerMulticol' style='columns:2; column-gap:0; column-fill:aut
o; width:560px; height:215px; border:8px solid; padding:7px;'>" |
| 567 " <div style='height:10px;'></div>" | 561 " <div style='height:10px;'></div>" |
| 568 " <div id='innerMulticol' style='columns:2; column-gap:0; border:8px
solid; padding:7px;'>" | 562 " <div id='innerMulticol' style='columns:2; column-gap:0; border:8px
solid; padding:7px;'>" |
| 569 " <div style='height:630px;'></div>" | 563 " <div style='height:630px;'></div>" |
| 570 " <div id='target' style='width:50px; height:50px;'></div>" | 564 " <div id='target' style='width:50px; height:50px;'></div>" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 616 mappedPoint = mapAncestorToLocal(target, multicol, mappedPoint); | 610 mappedPoint = mapAncestorToLocal(target, multicol, mappedPoint); |
| 617 EXPECT_EQ(FloatPoint(), mappedPoint); | 611 EXPECT_EQ(FloatPoint(), mappedPoint); |
| 618 | 612 |
| 619 // Walk each ancestor in the chain separately, to verify each step on the wa
y. | 613 // Walk each ancestor in the chain separately, to verify each step on the wa
y. |
| 620 LayoutBox* relpos = toLayoutBox(getLayoutObjectByElementId("relpos")); | 614 LayoutBox* relpos = toLayoutBox(getLayoutObjectByElementId("relpos")); |
| 621 LayoutBox* flowThread = relpos->parentBox(); | 615 LayoutBox* flowThread = relpos->parentBox(); |
| 622 ASSERT_TRUE(flowThread->isLayoutFlowThread()); | 616 ASSERT_TRUE(flowThread->isLayoutFlowThread()); |
| 623 | 617 |
| 624 mappedPoint = mapLocalToAncestor(target, relpos, FloatPoint()); | 618 mappedPoint = mapLocalToAncestor(target, relpos, FloatPoint()); |
| 625 EXPECT_EQ(FloatPoint(25, 25), mappedPoint); | 619 EXPECT_EQ(FloatPoint(25, 25), mappedPoint); |
| 620 mappedPoint = mapAncestorToLocal(target, relpos, mappedPoint); |
| 621 EXPECT_EQ(FloatPoint(), mappedPoint); |
| 626 | 622 |
| 627 mappedPoint = mapLocalToAncestor(relpos, flowThread, mappedPoint); | 623 mappedPoint = mapLocalToAncestor(relpos, flowThread, FloatPoint(25, 25)); |
| 628 EXPECT_EQ(FloatPoint(29, 139), mappedPoint); | 624 EXPECT_EQ(FloatPoint(29, 139), mappedPoint); |
| 629 | |
| 630 mappedPoint = mapLocalToAncestor(flowThread, multicol, mappedPoint); | |
| 631 EXPECT_EQ(FloatPoint(144, 54), mappedPoint); | |
| 632 | |
| 633 mappedPoint = mapAncestorToLocal(flowThread, multicol, mappedPoint); | |
| 634 EXPECT_EQ(FloatPoint(129, 39), mappedPoint); | |
| 635 | |
| 636 mappedPoint = mapAncestorToLocal(relpos, flowThread, mappedPoint); | 625 mappedPoint = mapAncestorToLocal(relpos, flowThread, mappedPoint); |
| 637 EXPECT_EQ(FloatPoint(25, 25), mappedPoint); | 626 EXPECT_EQ(FloatPoint(25, 25), mappedPoint); |
| 638 | 627 |
| 639 mappedPoint = mapAncestorToLocal(target, relpos, mappedPoint); | 628 mappedPoint = mapLocalToAncestor(flowThread, multicol, FloatPoint(29, 139)); |
| 640 EXPECT_EQ(FloatPoint(), mappedPoint); | 629 EXPECT_EQ(FloatPoint(144, 54), mappedPoint); |
| 630 mappedPoint = mapAncestorToLocal(flowThread, multicol, mappedPoint); |
| 631 EXPECT_EQ(FloatPoint(29, 139), mappedPoint); |
| 641 } | 632 } |
| 642 | 633 |
| 643 TEST_F(MapCoordinatesTest, MulticolWithAbsPosNotContained) | 634 TEST_F(MapCoordinatesTest, MulticolWithAbsPosNotContained) |
| 644 { | 635 { |
| 645 setBodyInnerHTML( | 636 setBodyInnerHTML( |
| 646 "<div id='container' style='position:relative; margin:666px; border:7px
solid; padding:3px;'>" | 637 "<div id='container' style='position:relative; margin:666px; border:7px
solid; padding:3px;'>" |
| 647 " <div id='multicol' style='-webkit-columns:3; -webkit-column-gap:0;
column-fill:auto; width:300px; height:100px; border:8px solid; padding:7px;'>" | 638 " <div id='multicol' style='-webkit-columns:3; -webkit-column-gap:0;
column-fill:auto; width:300px; height:100px; border:8px solid; padding:7px;'>" |
| 648 " <div style='height:110px;'></div>" | 639 " <div style='height:110px;'></div>" |
| 649 " <div id='target' style='position:absolute; left:-1px; top:-1px;
margin:10px; border:13px; padding:13px;'></div>" | 640 " <div id='target' style='position:absolute; left:-1px; top:-1px;
margin:10px; border:13px; padding:13px;'></div>" |
| 650 " </div>" | 641 " </div>" |
| (...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1169 | 1160 |
| 1170 // With child2, each rotation gets flattened and the end result is approxima
tely a 90-degree rotation. | 1161 // With child2, each rotation gets flattened and the end result is approxima
tely a 90-degree rotation. |
| 1171 matrix = child2->localToAbsoluteTransform(); | 1162 matrix = child2->localToAbsoluteTransform(); |
| 1172 EXPECT_NEAR(50.0, matrix.projectPoint(FloatPoint(100.0, 50.0)).x(), LayoutUn
it::epsilon()); | 1163 EXPECT_NEAR(50.0, matrix.projectPoint(FloatPoint(100.0, 50.0)).x(), LayoutUn
it::epsilon()); |
| 1173 EXPECT_NEAR(50.0, matrix.projectPoint(FloatPoint(100.0, 50.0)).y(), LayoutUn
it::epsilon()); | 1164 EXPECT_NEAR(50.0, matrix.projectPoint(FloatPoint(100.0, 50.0)).y(), LayoutUn
it::epsilon()); |
| 1174 EXPECT_NEAR(25.0, matrix.projectPoint(FloatPoint(50.0, 100.0)).x(), LayoutUn
it::epsilon()); | 1165 EXPECT_NEAR(25.0, matrix.projectPoint(FloatPoint(50.0, 100.0)).x(), LayoutUn
it::epsilon()); |
| 1175 EXPECT_NEAR(100.0, matrix.projectPoint(FloatPoint(50.0, 100.0)).y(), LayoutU
nit::epsilon()); | 1166 EXPECT_NEAR(100.0, matrix.projectPoint(FloatPoint(50.0, 100.0)).y(), LayoutU
nit::epsilon()); |
| 1176 } | 1167 } |
| 1177 | 1168 |
| 1178 } // namespace blink | 1169 } // namespace blink |
| OLD | NEW |