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 557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
568 LayoutBox* target = toLayoutBox(getLayoutObjectByElementId("target")); | 568 LayoutBox* target = toLayoutBox(getLayoutObjectByElementId("target")); |
569 LayoutBox* outerMulticol = toLayoutBox(getLayoutObjectByElementId("outerMult
icol")); | 569 LayoutBox* outerMulticol = toLayoutBox(getLayoutObjectByElementId("outerMult
icol")); |
570 LayoutBox* innerMulticol = toLayoutBox(getLayoutObjectByElementId("innerMult
icol")); | 570 LayoutBox* innerMulticol = toLayoutBox(getLayoutObjectByElementId("innerMult
icol")); |
571 LayoutBox* innerFlowThread = target->parentBox(); | 571 LayoutBox* innerFlowThread = target->parentBox(); |
572 ASSERT_TRUE(innerFlowThread->isLayoutFlowThread()); | 572 ASSERT_TRUE(innerFlowThread->isLayoutFlowThread()); |
573 LayoutBox* outerFlowThread = innerMulticol->parentBox(); | 573 LayoutBox* outerFlowThread = innerMulticol->parentBox(); |
574 ASSERT_TRUE(outerFlowThread->isLayoutFlowThread()); | 574 ASSERT_TRUE(outerFlowThread->isLayoutFlowThread()); |
575 | 575 |
576 FloatPoint mappedPoint = mapLocalToAncestor(target, outerMulticol, FloatPoin
t()); | 576 FloatPoint mappedPoint = mapLocalToAncestor(target, outerMulticol, FloatPoin
t()); |
577 EXPECT_EQ(FloatPoint(435, 115), mappedPoint); | 577 EXPECT_EQ(FloatPoint(435, 115), mappedPoint); |
578 | 578 mappedPoint = mapAncestorToLocal(target, outerMulticol, mappedPoint); |
579 // TODO(mstensho): Add mapAncestorToLocal() tests when it starts working in
nested multicol. | 579 EXPECT_EQ(FloatPoint(), mappedPoint); |
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 mappedPoint = mapLocalToAncestor(target, innerFlowThread, FloatPoint()); | 582 mappedPoint = mapLocalToAncestor(target, innerFlowThread, FloatPoint()); |
583 EXPECT_EQ(FloatPoint(0, 630), mappedPoint); | 583 EXPECT_EQ(FloatPoint(0, 630), mappedPoint); |
| 584 mappedPoint = mapAncestorToLocal(target, innerFlowThread, mappedPoint); |
| 585 EXPECT_EQ(FloatPoint(), mappedPoint); |
584 | 586 |
585 mappedPoint = mapLocalToAncestor(innerFlowThread, innerMulticol, mappedPoint
); | 587 mappedPoint = mapLocalToAncestor(innerFlowThread, innerMulticol, FloatPoint(
0, 630)); |
| 588 EXPECT_EQ(FloatPoint(140, 305), mappedPoint); |
| 589 mappedPoint = mapAncestorToLocal(innerFlowThread, innerMulticol, mappedPoint
); |
| 590 EXPECT_EQ(FloatPoint(0, 630), mappedPoint); |
| 591 |
| 592 mappedPoint = mapLocalToAncestor(innerMulticol, outerFlowThread, FloatPoint(
140, 305)); |
| 593 EXPECT_EQ(FloatPoint(140, 315), mappedPoint); |
| 594 mappedPoint = mapAncestorToLocal(innerMulticol, outerFlowThread, mappedPoint
); |
586 EXPECT_EQ(FloatPoint(140, 305), mappedPoint); | 595 EXPECT_EQ(FloatPoint(140, 305), mappedPoint); |
587 | 596 |
588 mappedPoint = mapLocalToAncestor(innerMulticol, outerFlowThread, mappedPoint
); | 597 mappedPoint = mapLocalToAncestor(outerFlowThread, outerMulticol, FloatPoint(
140, 315)); |
| 598 EXPECT_EQ(FloatPoint(435, 115), mappedPoint); |
| 599 mappedPoint = mapAncestorToLocal(outerFlowThread, outerMulticol, mappedPoint
); |
589 EXPECT_EQ(FloatPoint(140, 315), mappedPoint); | 600 EXPECT_EQ(FloatPoint(140, 315), mappedPoint); |
590 | |
591 mappedPoint = mapLocalToAncestor(outerFlowThread, outerMulticol, mappedPoint
); | |
592 EXPECT_EQ(FloatPoint(435, 115), mappedPoint); | |
593 } | 601 } |
594 | 602 |
595 TEST_F(MapCoordinatesTest, MulticolWithAbsPosInRelPos) | 603 TEST_F(MapCoordinatesTest, MulticolWithAbsPosInRelPos) |
596 { | 604 { |
597 setBodyInnerHTML( | 605 setBodyInnerHTML( |
598 "<div id='multicol' style='-webkit-columns:3; -webkit-column-gap:0; colu
mn-fill:auto; width:300px; height:100px; border:8px solid; padding:7px;'>" | 606 "<div id='multicol' style='-webkit-columns:3; -webkit-column-gap:0; colu
mn-fill:auto; width:300px; height:100px; border:8px solid; padding:7px;'>" |
599 " <div style='height:110px;'></div>" | 607 " <div style='height:110px;'></div>" |
600 " <div id='relpos' style='position:relative; left:4px; top:4px;'>" | 608 " <div id='relpos' style='position:relative; left:4px; top:4px;'>" |
601 " <div id='target' style='position:absolute; left:15px; top:15px;
margin:10px; border:13px; padding:13px;'></div>" | 609 " <div id='target' style='position:absolute; left:15px; top:15px;
margin:10px; border:13px; padding:13px;'></div>" |
602 " </div>" | 610 " </div>" |
(...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1160 | 1168 |
1161 // With child2, each rotation gets flattened and the end result is approxima
tely a 90-degree rotation. | 1169 // With child2, each rotation gets flattened and the end result is approxima
tely a 90-degree rotation. |
1162 matrix = child2->localToAbsoluteTransform(); | 1170 matrix = child2->localToAbsoluteTransform(); |
1163 EXPECT_NEAR(50.0, matrix.projectPoint(FloatPoint(100.0, 50.0)).x(), LayoutUn
it::epsilon()); | 1171 EXPECT_NEAR(50.0, matrix.projectPoint(FloatPoint(100.0, 50.0)).x(), LayoutUn
it::epsilon()); |
1164 EXPECT_NEAR(50.0, matrix.projectPoint(FloatPoint(100.0, 50.0)).y(), LayoutUn
it::epsilon()); | 1172 EXPECT_NEAR(50.0, matrix.projectPoint(FloatPoint(100.0, 50.0)).y(), LayoutUn
it::epsilon()); |
1165 EXPECT_NEAR(25.0, matrix.projectPoint(FloatPoint(50.0, 100.0)).x(), LayoutUn
it::epsilon()); | 1173 EXPECT_NEAR(25.0, matrix.projectPoint(FloatPoint(50.0, 100.0)).x(), LayoutUn
it::epsilon()); |
1166 EXPECT_NEAR(100.0, matrix.projectPoint(FloatPoint(50.0, 100.0)).y(), LayoutU
nit::epsilon()); | 1174 EXPECT_NEAR(100.0, matrix.projectPoint(FloatPoint(50.0, 100.0)).y(), LayoutU
nit::epsilon()); |
1167 } | 1175 } |
1168 | 1176 |
1169 } // namespace blink | 1177 } // namespace blink |
OLD | NEW |