Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilderTest.cpp

Issue 2512493003: Avoid special handling of LayoutSVGForeignObject about its paint offset (Closed)
Patch Set: - Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 1661 matching lines...) Expand 10 before | Expand all | Expand 10 after
1672 1672
1673 // Ensure there is no PaintOffset transform between the rect and the svg's 1673 // Ensure there is no PaintOffset transform between the rect and the svg's
1674 // transform. 1674 // transform.
1675 EXPECT_EQ(svgWithTransformProperties->transform(), 1675 EXPECT_EQ(svgWithTransformProperties->transform(),
1676 rectWithTransformProperties->transform()->parent()); 1676 rectWithTransformProperties->transform()->parent());
1677 } 1677 }
1678 1678
1679 TEST_P(PaintPropertyTreeBuilderTest, SvgRootAndForeignObjectPixelSnapping) { 1679 TEST_P(PaintPropertyTreeBuilderTest, SvgRootAndForeignObjectPixelSnapping) {
1680 setBodyInnerHTML( 1680 setBodyInnerHTML(
1681 "<svg id=svg style='position: relative; left: 0.6px; top: 0.3px'>" 1681 "<svg id=svg style='position: relative; left: 0.6px; top: 0.3px'>"
1682 " <foreignObject id=foreign x='3.5' y='5.4' transform='translate(1,1)'>" 1682 " <foreignObject id=foreign x='3.6' y='5.2'"
1683 " transform='translate(1.5, 1.5) scale(2)'>"
1683 " <div id=div style='position: absolute; left: 5.6px; top: 7.3px'>" 1684 " <div id=div style='position: absolute; left: 5.6px; top: 7.3px'>"
1684 " </div>" 1685 " </div>"
1685 " </foreignObject>" 1686 " </foreignObject>"
1686 "</svg>"); 1687 "</svg>");
1687 1688
1688 const auto* svgProperties = 1689 const auto* svgProperties =
1689 getLayoutObjectByElementId("svg")->paintProperties(); 1690 getLayoutObjectByElementId("svg")->paintProperties();
1690 EXPECT_EQ(nullptr, svgProperties->paintOffsetTranslation()); 1691 EXPECT_EQ(nullptr, svgProperties->paintOffsetTranslation());
1691 EXPECT_EQ(LayoutPoint(LayoutUnit(8.6), LayoutUnit(8.3)), 1692 EXPECT_EQ(LayoutPoint(LayoutUnit(8.6), LayoutUnit(8.3)),
1692 svgProperties->localBorderBoxProperties()->paintOffset); 1693 svgProperties->localBorderBoxProperties()->paintOffset);
1693 // Paint offset of SVGRoot be baked into svgLocalToBorderBoxTransform after 1694 // Paint offset of SVGRoot be baked into svgLocalToBorderBoxTransform after
1694 // snapped to pixels. 1695 // snapped to pixels.
1695 EXPECT_EQ(TransformationMatrix().translate(9, 8), 1696 EXPECT_EQ(TransformationMatrix().translate(9, 8),
1696 svgProperties->svgLocalToBorderBoxTransform()->matrix()); 1697 svgProperties->svgLocalToBorderBoxTransform()->matrix());
1697 1698
1698 const auto* foreignObjectProperties = 1699 const auto* foreignObject =
1699 getLayoutObjectByElementId("foreign")->paintProperties(); 1700 toLayoutBox(getLayoutObjectByElementId("foreign"));
1701 const auto* foreignObjectProperties = foreignObject->paintProperties();
1702 // The offset of foreign object should be snapped to pixels before applying
1703 // the local transforms.
1704 EXPECT_EQ(TransformationMatrix().translate(1.5, 1.5).scale(2).translate(4, 5),
1705 foreignObjectProperties->transform()->matrix());
1706 EXPECT_EQ(LayoutPoint(4, 5), foreignObject->location());
1700 EXPECT_EQ(nullptr, foreignObjectProperties->paintOffsetTranslation()); 1707 EXPECT_EQ(nullptr, foreignObjectProperties->paintOffsetTranslation());
1701 // Paint offset of foreignObject should be originated from SVG root and 1708 EXPECT_EQ(LayoutPoint(),
1702 // snapped to pixels.
1703 EXPECT_EQ(LayoutPoint(4, 5),
1704 foreignObjectProperties->localBorderBoxProperties()->paintOffset); 1709 foreignObjectProperties->localBorderBoxProperties()->paintOffset);
1705 1710
1706 const auto* divProperties = 1711 const auto* divProperties =
1707 getLayoutObjectByElementId("div")->paintProperties(); 1712 getLayoutObjectByElementId("div")->paintProperties();
1708 // Paint offset of descendant of foreignObject accumulates on paint offset of 1713 // Paint offsets of contents of the foreign object originate from (0, 0).
1709 // foreignObject. 1714 EXPECT_EQ(LayoutPoint(LayoutUnit(5.6), LayoutUnit(7.3)),
1710 EXPECT_EQ(LayoutPoint(LayoutUnit(4 + 5.6), LayoutUnit(5 + 7.3)),
1711 divProperties->localBorderBoxProperties()->paintOffset); 1715 divProperties->localBorderBoxProperties()->paintOffset);
1712 } 1716 }
1713 1717
1714 TEST_P(PaintPropertyTreeBuilderTest, NoRenderingContextByDefault) { 1718 TEST_P(PaintPropertyTreeBuilderTest, NoRenderingContextByDefault) {
1715 setBodyInnerHTML("<div style='transform: translateZ(0)'></div>"); 1719 setBodyInnerHTML("<div style='transform: translateZ(0)'></div>");
1716 1720
1717 const ObjectPaintProperties* properties = 1721 const ObjectPaintProperties* properties =
1718 document().body()->firstChild()->layoutObject()->paintProperties(); 1722 document().body()->firstChild()->layoutObject()->paintProperties();
1719 ASSERT_TRUE(properties->transform()); 1723 ASSERT_TRUE(properties->transform());
1720 EXPECT_FALSE(properties->transform()->hasRenderingContext()); 1724 EXPECT_FALSE(properties->transform()->hasRenderingContext());
(...skipping 1195 matching lines...) Expand 10 before | Expand all | Expand 10 after
2916 EXPECT_EQ(framePreTranslation(), 2920 EXPECT_EQ(framePreTranslation(),
2917 childProperties->paintOffsetTranslation()->parent()); 2921 childProperties->paintOffsetTranslation()->parent());
2918 EXPECT_EQ(childProperties->paintOffsetTranslation(), 2922 EXPECT_EQ(childProperties->paintOffsetTranslation(),
2919 childPaintState.transform()); 2923 childPaintState.transform());
2920 // This will change once we added clip expansion node. 2924 // This will change once we added clip expansion node.
2921 EXPECT_EQ(filterProperties->effect()->outputClip(), childPaintState.clip()); 2925 EXPECT_EQ(filterProperties->effect()->outputClip(), childPaintState.clip());
2922 EXPECT_EQ(filterProperties->effect(), childPaintState.effect()); 2926 EXPECT_EQ(filterProperties->effect(), childPaintState.effect());
2923 } 2927 }
2924 2928
2925 } // namespace blink 2929 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698