| 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 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 483 " text" | 483 " text" |
| 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(220, 20), mappedPoint); | 493 EXPECT_EQ(FloatPoint(10, 70), mappedPoint); |
| 494 | 494 |
| 495 mappedPoint = mapLocalToAncestor(flowThread, multicol, mappedPoint); | 495 mappedPoint = mapLocalToAncestor(flowThread, multicol, mappedPoint); |
| 496 EXPECT_EQ(FloatPoint(225, 25), mappedPoint); | 496 EXPECT_EQ(FloatPoint(225, 25), mappedPoint); |
| 497 | 497 |
| 498 mappedPoint = mapAncestorToLocal(flowThread, multicol, mappedPoint); | 498 mappedPoint = mapAncestorToLocal(flowThread, multicol, mappedPoint); |
| 499 EXPECT_EQ(FloatPoint(220, 20), mappedPoint); | 499 EXPECT_EQ(FloatPoint(220, 20), mappedPoint); |
| 500 | 500 |
| 501 mappedPoint = mapAncestorToLocal(target, flowThread, mappedPoint); | 501 mappedPoint = mapAncestorToLocal(target, flowThread, mappedPoint); |
| 502 EXPECT_EQ(FloatPoint(10, 70), mappedPoint); | 502 EXPECT_EQ(FloatPoint(10, 70), mappedPoint); |
| 503 } | 503 } |
| 504 | 504 |
| 505 TEST_F(MapCoordinatesTest, MulticolWithInline) | 505 TEST_F(MapCoordinatesTest, MulticolWithInline) |
| 506 { | 506 { |
| 507 setBodyInnerHTML( | 507 setBodyInnerHTML( |
| 508 "<div id='multicol' style='-webkit-columns:2; -webkit-column-gap:20px; w
idth:400px; line-height:50px; padding:5px;'>" | 508 "<div id='multicol' style='-webkit-columns:2; -webkit-column-gap:20px; w
idth:400px; line-height:50px; padding:5px;'>" |
| 509 " <span id='target'><br>text</span>" | 509 " <span id='target'><br>text</span>" |
| 510 "</div>"); | 510 "</div>"); |
| 511 | 511 |
| 512 LayoutObject* target = getLayoutObjectByElementId("target"); | 512 LayoutObject* target = getLayoutObjectByElementId("target"); |
| 513 LayoutBox* flowThread = toLayoutBox(target->parent()); | 513 LayoutBox* flowThread = toLayoutBox(target->parent()); |
| 514 ASSERT_TRUE(flowThread->isLayoutFlowThread()); | 514 ASSERT_TRUE(flowThread->isLayoutFlowThread()); |
| 515 LayoutBox* multicol = toLayoutBox(getLayoutObjectByElementId("multicol")); | 515 LayoutBox* multicol = toLayoutBox(getLayoutObjectByElementId("multicol")); |
| 516 | 516 |
| 517 FloatPoint mappedPoint = mapLocalToAncestor(target, flowThread, FloatPoint(1
0, 70)); | 517 FloatPoint mappedPoint = mapLocalToAncestor(target, flowThread, FloatPoint(1
0, 70)); |
| 518 EXPECT_EQ(FloatPoint(220, 20), mappedPoint); | 518 EXPECT_EQ(FloatPoint(10, 70), mappedPoint); |
| 519 | 519 |
| 520 mappedPoint = mapLocalToAncestor(flowThread, multicol, mappedPoint); | 520 mappedPoint = mapLocalToAncestor(flowThread, multicol, mappedPoint); |
| 521 EXPECT_EQ(FloatPoint(225, 25), mappedPoint); | 521 EXPECT_EQ(FloatPoint(225, 25), mappedPoint); |
| 522 | 522 |
| 523 mappedPoint = mapAncestorToLocal(flowThread, multicol, mappedPoint); | 523 mappedPoint = mapAncestorToLocal(flowThread, multicol, mappedPoint); |
| 524 EXPECT_EQ(FloatPoint(220, 20), mappedPoint); | 524 EXPECT_EQ(FloatPoint(220, 20), mappedPoint); |
| 525 | 525 |
| 526 mappedPoint = mapAncestorToLocal(target, flowThread, mappedPoint); | 526 mappedPoint = mapAncestorToLocal(target, flowThread, mappedPoint); |
| 527 EXPECT_EQ(FloatPoint(10, 70), mappedPoint); | 527 EXPECT_EQ(FloatPoint(10, 70), mappedPoint); |
| 528 } | 528 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 541 FloatPoint mappedPoint = mapLocalToAncestor(target, container, FloatPoint())
; | 541 FloatPoint mappedPoint = mapLocalToAncestor(target, container, FloatPoint())
; |
| 542 EXPECT_EQ(FloatPoint(125, 35), mappedPoint); | 542 EXPECT_EQ(FloatPoint(125, 35), mappedPoint); |
| 543 mappedPoint = mapAncestorToLocal(target, container, mappedPoint); | 543 mappedPoint = mapAncestorToLocal(target, container, mappedPoint); |
| 544 EXPECT_EQ(FloatPoint(), mappedPoint); | 544 EXPECT_EQ(FloatPoint(), mappedPoint); |
| 545 | 545 |
| 546 // Walk each ancestor in the chain separately, to verify each step on the wa
y. | 546 // Walk each ancestor in the chain separately, to verify each step on the wa
y. |
| 547 LayoutBox* flowThread = target->parentBox(); | 547 LayoutBox* flowThread = target->parentBox(); |
| 548 ASSERT_TRUE(flowThread->isLayoutFlowThread()); | 548 ASSERT_TRUE(flowThread->isLayoutFlowThread()); |
| 549 | 549 |
| 550 mappedPoint = mapLocalToAncestor(target, flowThread, FloatPoint()); | 550 mappedPoint = mapLocalToAncestor(target, flowThread, FloatPoint()); |
| 551 EXPECT_EQ(FloatPoint(110, 20), mappedPoint); | 551 EXPECT_EQ(FloatPoint(10, 120), mappedPoint); |
| 552 | 552 |
| 553 mappedPoint = mapLocalToAncestor(flowThread, container, mappedPoint); | 553 mappedPoint = mapLocalToAncestor(flowThread, container, mappedPoint); |
| 554 EXPECT_EQ(FloatPoint(125, 35), mappedPoint); | 554 EXPECT_EQ(FloatPoint(125, 35), mappedPoint); |
| 555 | 555 |
| 556 mappedPoint = mapAncestorToLocal(flowThread, container, mappedPoint); | 556 mappedPoint = mapAncestorToLocal(flowThread, container, mappedPoint); |
| 557 EXPECT_EQ(FloatPoint(110, 20), mappedPoint); | 557 EXPECT_EQ(FloatPoint(110, 20), mappedPoint); |
| 558 | 558 |
| 559 mappedPoint = mapAncestorToLocal(target, flowThread, mappedPoint); | 559 mappedPoint = mapAncestorToLocal(target, flowThread, mappedPoint); |
| 560 EXPECT_EQ(FloatPoint(), mappedPoint); | 560 EXPECT_EQ(FloatPoint(), mappedPoint); |
| 561 } | 561 } |
| (...skipping 18 matching lines...) Expand all Loading... |
| 580 | 580 |
| 581 // Walk each ancestor in the chain separately, to verify each step on the wa
y. | 581 // Walk each ancestor in the chain separately, to verify each step on the wa
y. |
| 582 LayoutBox* relpos = toLayoutBox(getLayoutObjectByElementId("relpos")); | 582 LayoutBox* relpos = toLayoutBox(getLayoutObjectByElementId("relpos")); |
| 583 LayoutBox* flowThread = relpos->parentBox(); | 583 LayoutBox* flowThread = relpos->parentBox(); |
| 584 ASSERT_TRUE(flowThread->isLayoutFlowThread()); | 584 ASSERT_TRUE(flowThread->isLayoutFlowThread()); |
| 585 | 585 |
| 586 mappedPoint = mapLocalToAncestor(target, relpos, FloatPoint()); | 586 mappedPoint = mapLocalToAncestor(target, relpos, FloatPoint()); |
| 587 EXPECT_EQ(FloatPoint(25, 25), mappedPoint); | 587 EXPECT_EQ(FloatPoint(25, 25), mappedPoint); |
| 588 | 588 |
| 589 mappedPoint = mapLocalToAncestor(relpos, flowThread, mappedPoint); | 589 mappedPoint = mapLocalToAncestor(relpos, flowThread, mappedPoint); |
| 590 EXPECT_EQ(FloatPoint(129, 39), mappedPoint); | 590 EXPECT_EQ(FloatPoint(29, 139), mappedPoint); |
| 591 | 591 |
| 592 mappedPoint = mapLocalToAncestor(flowThread, multicol, mappedPoint); | 592 mappedPoint = mapLocalToAncestor(flowThread, multicol, mappedPoint); |
| 593 EXPECT_EQ(FloatPoint(144, 54), mappedPoint); | 593 EXPECT_EQ(FloatPoint(144, 54), mappedPoint); |
| 594 | 594 |
| 595 mappedPoint = mapAncestorToLocal(flowThread, multicol, mappedPoint); | 595 mappedPoint = mapAncestorToLocal(flowThread, multicol, mappedPoint); |
| 596 EXPECT_EQ(FloatPoint(129, 39), mappedPoint); | 596 EXPECT_EQ(FloatPoint(129, 39), mappedPoint); |
| 597 | 597 |
| 598 mappedPoint = mapAncestorToLocal(relpos, flowThread, mappedPoint); | 598 mappedPoint = mapAncestorToLocal(relpos, flowThread, mappedPoint); |
| 599 EXPECT_EQ(FloatPoint(25, 25), mappedPoint); | 599 EXPECT_EQ(FloatPoint(25, 25), mappedPoint); |
| 600 | 600 |
| (...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1131 | 1131 |
| 1132 // With child2, each rotation gets flattened and the end result is approxima
tely a 90-degree rotation. | 1132 // With child2, each rotation gets flattened and the end result is approxima
tely a 90-degree rotation. |
| 1133 matrix = child2->localToAbsoluteTransform(); | 1133 matrix = child2->localToAbsoluteTransform(); |
| 1134 EXPECT_NEAR(50.0, matrix.projectPoint(FloatPoint(100.0, 50.0)).x(), LayoutUn
it::epsilon()); | 1134 EXPECT_NEAR(50.0, matrix.projectPoint(FloatPoint(100.0, 50.0)).x(), LayoutUn
it::epsilon()); |
| 1135 EXPECT_NEAR(50.0, matrix.projectPoint(FloatPoint(100.0, 50.0)).y(), LayoutUn
it::epsilon()); | 1135 EXPECT_NEAR(50.0, matrix.projectPoint(FloatPoint(100.0, 50.0)).y(), LayoutUn
it::epsilon()); |
| 1136 EXPECT_NEAR(25.0, matrix.projectPoint(FloatPoint(50.0, 100.0)).x(), LayoutUn
it::epsilon()); | 1136 EXPECT_NEAR(25.0, matrix.projectPoint(FloatPoint(50.0, 100.0)).x(), LayoutUn
it::epsilon()); |
| 1137 EXPECT_NEAR(100.0, matrix.projectPoint(FloatPoint(50.0, 100.0)).y(), LayoutU
nit::epsilon()); | 1137 EXPECT_NEAR(100.0, matrix.projectPoint(FloatPoint(50.0, 100.0)).y(), LayoutU
nit::epsilon()); |
| 1138 } | 1138 } |
| 1139 | 1139 |
| 1140 } // namespace blink | 1140 } // namespace blink |
| OLD | NEW |