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/paint/PaintPropertyTreeBuilderTest.h" | 5 #include "core/paint/PaintPropertyTreeBuilderTest.h" |
6 | 6 |
7 #include "core/html/HTMLIFrameElement.h" | 7 #include "core/html/HTMLIFrameElement.h" |
8 #include "core/layout/LayoutTreeAsText.h" | 8 #include "core/layout/LayoutTreeAsText.h" |
9 #include "core/paint/ObjectPaintProperties.h" | 9 #include "core/paint/ObjectPaintProperties.h" |
10 #include "core/paint/PaintPropertyTreePrinter.h" | 10 #include "core/paint/PaintPropertyTreePrinter.h" |
(...skipping 1749 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1760 // Visual rects via the non-paint properties system use enclosingIntRect | 1760 // Visual rects via the non-paint properties system use enclosingIntRect |
1761 // before applying transforms, because they are computed bottom-up and | 1761 // before applying transforms, because they are computed bottom-up and |
1762 // therefore can't apply pixel snapping. Therefore apply a slop of 1px. | 1762 // therefore can't apply pixel snapping. Therefore apply a slop of 1px. |
1763 CHECK_VISUAL_RECT(LayoutRect(LayoutUnit(0.7) + LayoutUnit(0.7), | 1763 CHECK_VISUAL_RECT(LayoutRect(LayoutUnit(0.7) + LayoutUnit(0.7), |
1764 LayoutUnit(0.7) + LayoutUnit(0.7), | 1764 LayoutUnit(0.7) + LayoutUnit(0.7), |
1765 LayoutUnit(40), LayoutUnit(40)), | 1765 LayoutUnit(40), LayoutUnit(40)), |
1766 c, frame_view->GetLayoutView(), 1); | 1766 c, frame_view->GetLayoutView(), 1); |
1767 } | 1767 } |
1768 | 1768 |
1769 TEST_P(PaintPropertyTreeBuilderTest, | 1769 TEST_P(PaintPropertyTreeBuilderTest, |
| 1770 NonTranslationTransformShouldResetSubpixelPaintOffset) { |
| 1771 SetBodyInnerHTML( |
| 1772 "<style>" |
| 1773 " * { margin: 0; }" |
| 1774 " div { position: relative; }" |
| 1775 " #a {" |
| 1776 " width: 70px;" |
| 1777 " height: 70px;" |
| 1778 " left: 0.8px;" |
| 1779 " top: 0.8px;" |
| 1780 " }" |
| 1781 " #b {" |
| 1782 " width: 40px;" |
| 1783 " height: 40px;" |
| 1784 " transform: scale(10);" |
| 1785 " transform-origin: 0 0;" |
| 1786 " }" |
| 1787 " #c {" |
| 1788 " width: 40px;" |
| 1789 " height: 40px;" |
| 1790 " left: 0.6px;" |
| 1791 " top: 0.6px;" |
| 1792 " }" |
| 1793 "</style>" |
| 1794 "<div id='a'>" |
| 1795 " <div id='b'>" |
| 1796 " <div id='c'></div>" |
| 1797 " </div>" |
| 1798 "</div>"); |
| 1799 FrameView* frame_view = GetDocument().View(); |
| 1800 |
| 1801 LayoutUnit a_offset = LayoutUnit(0.8); |
| 1802 LayoutUnit c_offset = LayoutUnit(0.6); |
| 1803 |
| 1804 LayoutObject* b = GetDocument().getElementById("b")->GetLayoutObject(); |
| 1805 const ObjectPaintProperties* b_properties = b->PaintProperties(); |
| 1806 EXPECT_EQ(TransformationMatrix().Scale(10), |
| 1807 b_properties->Transform()->Matrix()); |
| 1808 // The paint offset transform should not be snapped. |
| 1809 EXPECT_EQ(TransformationMatrix().Translate(a_offset.ToDouble(), |
| 1810 a_offset.ToDouble()), |
| 1811 b_properties->Transform()->Parent()->Matrix()); |
| 1812 EXPECT_EQ(LayoutPoint(), b->PaintOffset()); |
| 1813 CHECK_EXACT_VISUAL_RECT( |
| 1814 LayoutRect(a_offset, a_offset, LayoutUnit(400), LayoutUnit(400)), b, |
| 1815 frame_view->GetLayoutView()); |
| 1816 |
| 1817 // c's painting should start at c_offset. |
| 1818 LayoutObject* c = GetDocument().getElementById("c")->GetLayoutObject(); |
| 1819 EXPECT_EQ(LayoutPoint(c_offset, c_offset), c->PaintOffset()); |
| 1820 // Visual rects via the non-paint properties system use enclosingIntRect |
| 1821 // before applying transforms, because they are computed bottom-up and |
| 1822 // therefore can't apply pixel snapping. Therefore apply a slop of |
| 1823 // c_offset * 10 + 1px. |
| 1824 CHECK_VISUAL_RECT( |
| 1825 LayoutRect(c_offset * 10 + a_offset, c_offset * 10 + a_offset, |
| 1826 LayoutUnit(400), LayoutUnit(400)), |
| 1827 c, frame_view->GetLayoutView(), c_offset * 10 + 1); |
| 1828 } |
| 1829 |
| 1830 TEST_P(PaintPropertyTreeBuilderTest, |
1770 PaintOffsetWithPixelSnappingThroughMultipleTransforms) { | 1831 PaintOffsetWithPixelSnappingThroughMultipleTransforms) { |
1771 SetBodyInnerHTML( | 1832 SetBodyInnerHTML( |
1772 "<style>" | 1833 "<style>" |
1773 " * { margin: 0; }" | 1834 " * { margin: 0; }" |
1774 " div { position: relative; }" | 1835 " div { position: relative; }" |
1775 " #a {" | 1836 " #a {" |
1776 " width: 70px;" | 1837 " width: 70px;" |
1777 " height: 70px;" | 1838 " height: 70px;" |
1778 " left: 0.7px;" | 1839 " left: 0.7px;" |
1779 " top: 0.7px;" | 1840 " top: 0.7px;" |
(...skipping 1690 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3470 | 3531 |
3471 LayoutObject& svg_root = | 3532 LayoutObject& svg_root = |
3472 *GetDocument().getElementById("svgroot")->GetLayoutObject(); | 3533 *GetDocument().getElementById("svgroot")->GetLayoutObject(); |
3473 const ObjectPaintProperties* svg_root_properties = svg_root.PaintProperties(); | 3534 const ObjectPaintProperties* svg_root_properties = svg_root.PaintProperties(); |
3474 EXPECT_TRUE(svg_root_properties->Effect()); | 3535 EXPECT_TRUE(svg_root_properties->Effect()); |
3475 EXPECT_EQ(EffectPaintPropertyNode::Root(), | 3536 EXPECT_EQ(EffectPaintPropertyNode::Root(), |
3476 svg_root_properties->Effect()->Parent()); | 3537 svg_root_properties->Effect()->Parent()); |
3477 } | 3538 } |
3478 | 3539 |
3479 } // namespace blink | 3540 } // namespace blink |
OLD | NEW |