| 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 1660 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1671 | 1671 |
| 1672 // Ensure there is no PaintOffset transform between the rect and the svg's | 1672 // Ensure there is no PaintOffset transform between the rect and the svg's |
| 1673 // transform. | 1673 // transform. |
| 1674 EXPECT_EQ(svgWithTransformProperties->transform(), | 1674 EXPECT_EQ(svgWithTransformProperties->transform(), |
| 1675 rectWithTransformProperties->transform()->parent()); | 1675 rectWithTransformProperties->transform()->parent()); |
| 1676 } | 1676 } |
| 1677 | 1677 |
| 1678 TEST_P(PaintPropertyTreeBuilderTest, SvgRootAndForeignObjectPixelSnapping) { | 1678 TEST_P(PaintPropertyTreeBuilderTest, SvgRootAndForeignObjectPixelSnapping) { |
| 1679 setBodyInnerHTML( | 1679 setBodyInnerHTML( |
| 1680 "<svg id=svg style='position: relative; left: 0.6px; top: 0.3px'>" | 1680 "<svg id=svg style='position: relative; left: 0.6px; top: 0.3px'>" |
| 1681 " <foreignObject id=foreign x='3.6' y='5.2'" | 1681 " <foreignObject id=foreign x='3.5' y='5.4' transform='translate(1,1)'>" |
| 1682 " transform='translate(1.5, 1.5) scale(2)'>" | |
| 1683 " <div id=div style='position: absolute; left: 5.6px; top: 7.3px'>" | 1682 " <div id=div style='position: absolute; left: 5.6px; top: 7.3px'>" |
| 1684 " </div>" | 1683 " </div>" |
| 1685 " </foreignObject>" | 1684 " </foreignObject>" |
| 1686 "</svg>"); | 1685 "</svg>"); |
| 1687 | 1686 |
| 1688 const auto* svgProperties = | 1687 const auto* svgProperties = |
| 1689 getLayoutObjectByElementId("svg")->paintProperties(); | 1688 getLayoutObjectByElementId("svg")->paintProperties(); |
| 1690 EXPECT_EQ(nullptr, svgProperties->paintOffsetTranslation()); | 1689 EXPECT_EQ(nullptr, svgProperties->paintOffsetTranslation()); |
| 1691 EXPECT_EQ(LayoutPoint(LayoutUnit(8.6), LayoutUnit(8.3)), | 1690 EXPECT_EQ(LayoutPoint(LayoutUnit(8.6), LayoutUnit(8.3)), |
| 1692 svgProperties->localBorderBoxProperties()->paintOffset); | 1691 svgProperties->localBorderBoxProperties()->paintOffset); |
| 1693 // Paint offset of SVGRoot is baked into svgLocalToBorderBoxTransform after | 1692 // Paint offset of SVGRoot is baked into svgLocalToBorderBoxTransform after |
| 1694 // snapped to pixels. | 1693 // snapped to pixels. |
| 1695 EXPECT_EQ(TransformationMatrix().translate(9, 8), | 1694 EXPECT_EQ(TransformationMatrix().translate(9, 8), |
| 1696 svgProperties->svgLocalToBorderBoxTransform()->matrix()); | 1695 svgProperties->svgLocalToBorderBoxTransform()->matrix()); |
| 1697 | 1696 |
| 1698 const auto* foreignObject = | 1697 const auto* foreignObjectProperties = |
| 1699 toLayoutBox(getLayoutObjectByElementId("foreign")); | 1698 getLayoutObjectByElementId("foreign")->paintProperties(); |
| 1700 const auto* foreignObjectProperties = foreignObject->paintProperties(); | |
| 1701 // The offset of foreign object should be snapped to pixels before applying | |
| 1702 // the local transforms. | |
| 1703 EXPECT_EQ(TransformationMatrix().translate(1.5, 1.5).scale(2).translate(4, 5), | |
| 1704 foreignObjectProperties->transform()->matrix()); | |
| 1705 EXPECT_EQ(LayoutPoint(4, 5), foreignObject->location()); | |
| 1706 EXPECT_EQ(nullptr, foreignObjectProperties->paintOffsetTranslation()); | 1699 EXPECT_EQ(nullptr, foreignObjectProperties->paintOffsetTranslation()); |
| 1707 EXPECT_EQ(LayoutPoint(), | 1700 // Paint offset of foreignObject should be originated from SVG root and |
| 1701 // snapped to pixels. |
| 1702 EXPECT_EQ(LayoutPoint(4, 5), |
| 1708 foreignObjectProperties->localBorderBoxProperties()->paintOffset); | 1703 foreignObjectProperties->localBorderBoxProperties()->paintOffset); |
| 1709 | 1704 |
| 1710 const auto* divProperties = | 1705 const auto* divProperties = |
| 1711 getLayoutObjectByElementId("div")->paintProperties(); | 1706 getLayoutObjectByElementId("div")->paintProperties(); |
| 1712 // Paint offsets of contents of the foreign object originate from (0, 0). | 1707 // Paint offset of descendant of foreignObject accumulates on paint offset of |
| 1713 EXPECT_EQ(LayoutPoint(LayoutUnit(5.6), LayoutUnit(7.3)), | 1708 // foreignObject. |
| 1709 EXPECT_EQ(LayoutPoint(LayoutUnit(4 + 5.6), LayoutUnit(5 + 7.3)), |
| 1714 divProperties->localBorderBoxProperties()->paintOffset); | 1710 divProperties->localBorderBoxProperties()->paintOffset); |
| 1715 } | 1711 } |
| 1716 | 1712 |
| 1717 TEST_P(PaintPropertyTreeBuilderTest, NoRenderingContextByDefault) { | 1713 TEST_P(PaintPropertyTreeBuilderTest, NoRenderingContextByDefault) { |
| 1718 setBodyInnerHTML("<div style='transform: translateZ(0)'></div>"); | 1714 setBodyInnerHTML("<div style='transform: translateZ(0)'></div>"); |
| 1719 | 1715 |
| 1720 const ObjectPaintProperties* properties = | 1716 const ObjectPaintProperties* properties = |
| 1721 document().body()->firstChild()->layoutObject()->paintProperties(); | 1717 document().body()->firstChild()->layoutObject()->paintProperties(); |
| 1722 ASSERT_TRUE(properties->transform()); | 1718 ASSERT_TRUE(properties->transform()); |
| 1723 EXPECT_FALSE(properties->transform()->hasRenderingContext()); | 1719 EXPECT_FALSE(properties->transform()->hasRenderingContext()); |
| (...skipping 1163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2887 EXPECT_EQ(framePreTranslation(), | 2883 EXPECT_EQ(framePreTranslation(), |
| 2888 childProperties->paintOffsetTranslation()->parent()); | 2884 childProperties->paintOffsetTranslation()->parent()); |
| 2889 EXPECT_EQ(childProperties->paintOffsetTranslation(), | 2885 EXPECT_EQ(childProperties->paintOffsetTranslation(), |
| 2890 childPaintState.transform()); | 2886 childPaintState.transform()); |
| 2891 // This will change once we added clip expansion node. | 2887 // This will change once we added clip expansion node. |
| 2892 EXPECT_EQ(filterProperties->effect()->outputClip(), childPaintState.clip()); | 2888 EXPECT_EQ(filterProperties->effect()->outputClip(), childPaintState.clip()); |
| 2893 EXPECT_EQ(filterProperties->effect(), childPaintState.effect()); | 2889 EXPECT_EQ(filterProperties->effect(), childPaintState.effect()); |
| 2894 } | 2890 } |
| 2895 | 2891 |
| 2896 } // namespace blink | 2892 } // namespace blink |
| OLD | NEW |