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 1186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2897 EXPECT_EQ(framePreTranslation(), | 2932 EXPECT_EQ(framePreTranslation(), |
2898 childProperties->paintOffsetTranslation()->parent()); | 2933 childProperties->paintOffsetTranslation()->parent()); |
2899 EXPECT_EQ(childProperties->paintOffsetTranslation(), | 2934 EXPECT_EQ(childProperties->paintOffsetTranslation(), |
2900 childPaintState.transform()); | 2935 childPaintState.transform()); |
2901 // This will change once we added clip expansion node. | 2936 // This will change once we added clip expansion node. |
2902 EXPECT_EQ(filterProperties->effect()->outputClip(), childPaintState.clip()); | 2937 EXPECT_EQ(filterProperties->effect()->outputClip(), childPaintState.clip()); |
2903 EXPECT_EQ(filterProperties->effect(), childPaintState.effect()); | 2938 EXPECT_EQ(filterProperties->effect(), childPaintState.effect()); |
2904 } | 2939 } |
2905 | 2940 |
2906 } // namespace blink | 2941 } // namespace blink |
OLD | NEW |