| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/LayoutTestHelper.h" | 5 #include "core/layout/LayoutTestHelper.h" |
| 6 #include "core/layout/LayoutTreeAsText.h" | 6 #include "core/layout/LayoutTreeAsText.h" |
| 7 #include "core/layout/api/LayoutViewItem.h" | 7 #include "core/layout/api/LayoutViewItem.h" |
| 8 #include "core/paint/ObjectPaintProperties.h" | 8 #include "core/paint/ObjectPaintProperties.h" |
| 9 #include "core/paint/PaintPropertyTreePrinter.h" | 9 #include "core/paint/PaintPropertyTreePrinter.h" |
| 10 #include "platform/graphics/paint/GeometryMapper.h" | 10 #include "platform/graphics/paint/GeometryMapper.h" |
| (...skipping 1680 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1691 rectWithTransform.paintProperties(); | 1691 rectWithTransform.paintProperties(); |
| 1692 EXPECT_EQ(TransformationMatrix().translate(1, 1), | 1692 EXPECT_EQ(TransformationMatrix().translate(1, 1), |
| 1693 rectWithTransformProperties->transform()->matrix()); | 1693 rectWithTransformProperties->transform()->matrix()); |
| 1694 | 1694 |
| 1695 // Ensure there is no PaintOffset transform between the rect and the svg's | 1695 // Ensure there is no PaintOffset transform between the rect and the svg's |
| 1696 // transform. | 1696 // transform. |
| 1697 EXPECT_EQ(svgWithTransformProperties->transform(), | 1697 EXPECT_EQ(svgWithTransformProperties->transform(), |
| 1698 rectWithTransformProperties->transform()->parent()); | 1698 rectWithTransformProperties->transform()->parent()); |
| 1699 } | 1699 } |
| 1700 | 1700 |
| 1701 TEST_P(PaintPropertyTreeBuilderTest, SvgRootAndForeignObjectPixelSnapping) { |
| 1702 setBodyInnerHTML( |
| 1703 "<svg id=svg style='position: relative; left: 0.6px; top: 0.3px'>" |
| 1704 " <foreignObject id=foreign x='3.5' y='5.4' transform='translate(1,1)'>" |
| 1705 " <div id=div style='position: absolute; left: 5.6px; top: 7.3px'>" |
| 1706 " </div>" |
| 1707 " </foreignObject>" |
| 1708 "</svg>"); |
| 1709 |
| 1710 const auto* svgProperties = |
| 1711 getLayoutObjectByElementId("svg")->paintProperties(); |
| 1712 EXPECT_EQ(nullptr, svgProperties->paintOffsetTranslation()); |
| 1713 EXPECT_EQ(LayoutPoint(LayoutUnit(8.6), LayoutUnit(8.3)), |
| 1714 svgProperties->localBorderBoxProperties()->paintOffset); |
| 1715 // Paint offset of SVGRoot be baked into svgLocalToBorderBoxTransform after |
| 1716 // snapped to pixels. |
| 1717 EXPECT_EQ(TransformationMatrix().translate(9, 8), |
| 1718 svgProperties->svgLocalToBorderBoxTransform()->matrix()); |
| 1719 |
| 1720 const auto* foreignObjectProperties = |
| 1721 getLayoutObjectByElementId("foreign")->paintProperties(); |
| 1722 EXPECT_EQ(nullptr, foreignObjectProperties->paintOffsetTranslation()); |
| 1723 // Paint offset of foreignObject should be originated from SVG root and |
| 1724 // snapped to pixels. |
| 1725 EXPECT_EQ(LayoutPoint(4, 5), |
| 1726 foreignObjectProperties->localBorderBoxProperties()->paintOffset); |
| 1727 |
| 1728 const auto* divProperties = |
| 1729 getLayoutObjectByElementId("div")->paintProperties(); |
| 1730 // Paint offset of descendant of foreignObject accumulates on paint offset of |
| 1731 // foreignObject. |
| 1732 EXPECT_EQ(LayoutPoint(LayoutUnit(4 + 5.6), LayoutUnit(5 + 7.3)), |
| 1733 divProperties->localBorderBoxProperties()->paintOffset); |
| 1734 } |
| 1735 |
| 1701 TEST_P(PaintPropertyTreeBuilderTest, NoRenderingContextByDefault) { | 1736 TEST_P(PaintPropertyTreeBuilderTest, NoRenderingContextByDefault) { |
| 1702 setBodyInnerHTML("<div style='transform: translateZ(0)'></div>"); | 1737 setBodyInnerHTML("<div style='transform: translateZ(0)'></div>"); |
| 1703 | 1738 |
| 1704 const ObjectPaintProperties* properties = | 1739 const ObjectPaintProperties* properties = |
| 1705 document().body()->firstChild()->layoutObject()->paintProperties(); | 1740 document().body()->firstChild()->layoutObject()->paintProperties(); |
| 1706 ASSERT_TRUE(properties->transform()); | 1741 ASSERT_TRUE(properties->transform()); |
| 1707 EXPECT_FALSE(properties->transform()->hasRenderingContext()); | 1742 EXPECT_FALSE(properties->transform()->hasRenderingContext()); |
| 1708 } | 1743 } |
| 1709 | 1744 |
| 1710 TEST_P(PaintPropertyTreeBuilderTest, Preserve3DCreatesSharedRenderingContext) { | 1745 TEST_P(PaintPropertyTreeBuilderTest, Preserve3DCreatesSharedRenderingContext) { |
| (...skipping 1143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2854 " <div id=absolute style='position: absolute'>absolute</div>" | 2889 " <div id=absolute style='position: absolute'>absolute</div>" |
| 2855 " </div>" | 2890 " </div>" |
| 2856 " </span>" | 2891 " </span>" |
| 2857 "</div>"); | 2892 "</div>"); |
| 2858 // There should be anonymous block created containing the inline "relative", | 2893 // There should be anonymous block created containing the inline "relative", |
| 2859 // serving as the container of "absolute". | 2894 // serving as the container of "absolute". |
| 2860 EXPECT_TRUE( | 2895 EXPECT_TRUE( |
| 2861 getLayoutObjectByElementId("absolute")->container()->isLayoutBlock()); | 2896 getLayoutObjectByElementId("absolute")->container()->isLayoutBlock()); |
| 2862 } | 2897 } |
| 2863 } // namespace blink | 2898 } // namespace blink |
| OLD | NEW |