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 960 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
971 | 971 |
972 LayoutObject* target = getLayoutObjectByElementId("target"); | 972 LayoutObject* target = getLayoutObjectByElementId("target"); |
973 LayoutBox* container = toLayoutBox(getLayoutObjectByElementId("container")); | 973 LayoutBox* container = toLayoutBox(getLayoutObjectByElementId("container")); |
974 | 974 |
975 FloatPoint mappedPoint = mapLocalToAncestor(target, container, FloatPoint())
; | 975 FloatPoint mappedPoint = mapLocalToAncestor(target, container, FloatPoint())
; |
976 EXPECT_EQ(FloatPoint(200, 100), mappedPoint); | 976 EXPECT_EQ(FloatPoint(200, 100), mappedPoint); |
977 mappedPoint = mapAncestorToLocal(target, container, mappedPoint); | 977 mappedPoint = mapAncestorToLocal(target, container, mappedPoint); |
978 EXPECT_EQ(FloatPoint(), mappedPoint); | 978 EXPECT_EQ(FloatPoint(), mappedPoint); |
979 } | 979 } |
980 | 980 |
| 981 TEST_F(MapCoordinatesTest, SVGShapeWithViewBoxWithNonZeroOffset) |
| 982 { |
| 983 setBodyInnerHTML( |
| 984 "<svg id='container' viewBox='100 100 200 200' width='400' height='200'>
" |
| 985 " <g transform='translate(100 50)'>" |
| 986 " <rect id='target' transform='translate(100 100)' width='100' he
ight='100'/>" |
| 987 " </g>" |
| 988 "</svg>"); |
| 989 |
| 990 LayoutObject* target = getLayoutObjectByElementId("target"); |
| 991 LayoutBox* container = toLayoutBox(getLayoutObjectByElementId("container")); |
| 992 |
| 993 FloatPoint mappedPoint = mapLocalToAncestor(target, container, FloatPoint())
; |
| 994 EXPECT_EQ(FloatPoint(200, 50), mappedPoint); |
| 995 mappedPoint = mapAncestorToLocal(target, container, mappedPoint); |
| 996 EXPECT_EQ(FloatPoint(), mappedPoint); |
| 997 } |
| 998 |
| 999 TEST_F(MapCoordinatesTest, SVGShapeWithViewBoxWithNonZeroOffsetAndScale) |
| 1000 { |
| 1001 setBodyInnerHTML( |
| 1002 "<svg id='container' viewBox='100 100 100 100' width='400' height='200'>
" |
| 1003 " <g transform='translate(50 50)'>" |
| 1004 " <rect id='target' transform='translate(100 100)' width='100' he
ight='100'/>" |
| 1005 " </g>" |
| 1006 "</svg>"); |
| 1007 |
| 1008 LayoutObject* target = getLayoutObjectByElementId("target"); |
| 1009 LayoutBox* container = toLayoutBox(getLayoutObjectByElementId("container")); |
| 1010 |
| 1011 FloatPoint mappedPoint = mapLocalToAncestor(target, container, FloatPoint())
; |
| 1012 EXPECT_EQ(FloatPoint(200, 100), mappedPoint); |
| 1013 mappedPoint = mapAncestorToLocal(target, container, mappedPoint); |
| 1014 EXPECT_EQ(FloatPoint(), mappedPoint); |
| 1015 } |
| 1016 |
981 TEST_F(MapCoordinatesTest, SVGForeignObject) | 1017 TEST_F(MapCoordinatesTest, SVGForeignObject) |
982 { | 1018 { |
983 setBodyInnerHTML( | 1019 setBodyInnerHTML( |
984 "<svg id='container' viewBox='0 0 100 100' width='400' height='200'>" | 1020 "<svg id='container' viewBox='0 0 100 100' width='400' height='200'>" |
985 " <g transform='translate(50 50)'>" | 1021 " <g transform='translate(50 50)'>" |
986 " <foreignObject transform='translate(-25 -25)'>" | 1022 " <foreignObject transform='translate(-25 -25)'>" |
987 " <div xmlns='http://www.w3.org/1999/xhtml' id='target' style
='margin-left: 50px; border: 42px; padding: 84px; width: 50px; height: 50px'>" | 1023 " <div xmlns='http://www.w3.org/1999/xhtml' id='target' style
='margin-left: 50px; border: 42px; padding: 84px; width: 50px; height: 50px'>" |
988 " </div>" | 1024 " </div>" |
989 " </foreignObject>" | 1025 " </foreignObject>" |
990 " </g>" | 1026 " </g>" |
(...skipping 12 matching lines...) Expand all Loading... |
1003 EXPECT_EQ(FloatPoint(25, -25), mappedPoint); | 1039 EXPECT_EQ(FloatPoint(25, -25), mappedPoint); |
1004 // <foreignObject> | 1040 // <foreignObject> |
1005 mappedPoint = mapAncestorToLocal(target->parent(), container, FloatPoint(250
, 50)); | 1041 mappedPoint = mapAncestorToLocal(target->parent(), container, FloatPoint(250
, 50)); |
1006 EXPECT_EQ(FloatPoint(50, 0), mappedPoint); | 1042 EXPECT_EQ(FloatPoint(50, 0), mappedPoint); |
1007 // <div> | 1043 // <div> |
1008 mappedPoint = mapAncestorToLocal(target, container, FloatPoint(250, 50)); | 1044 mappedPoint = mapAncestorToLocal(target, container, FloatPoint(250, 50)); |
1009 EXPECT_EQ(FloatPoint(), mappedPoint); | 1045 EXPECT_EQ(FloatPoint(), mappedPoint); |
1010 } | 1046 } |
1011 | 1047 |
1012 } // namespace blink | 1048 } // namespace blink |
OLD | NEW |