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

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

Issue 2847873002: Don't pass subpixel offsets through non-translation transforms (Closed)
Patch Set: - Created 3 years, 7 months 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/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
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.7px;"
1779 " top: 0.7px;"
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.7px;"
1791 " top: 0.7px;"
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 LayoutObject* b = GetDocument().getElementById("b")->GetLayoutObject();
1802 const ObjectPaintProperties* b_properties = b->PaintProperties();
1803 EXPECT_EQ(TransformationMatrix().Scale(10),
1804 b_properties->Transform()->Matrix());
1805 // The paint offset transform should not be snapped.
1806 EXPECT_EQ(TransformationMatrix().Translate(LayoutUnit(0.7).ToDouble(),
1807 LayoutUnit(0.7).ToDouble()),
1808 b_properties->Transform()->Parent()->Matrix());
1809 EXPECT_EQ(LayoutPoint(), b->PaintOffset());
1810 CHECK_EXACT_VISUAL_RECT(LayoutRect(LayoutUnit(0.7), LayoutUnit(0.7),
1811 LayoutUnit(400), LayoutUnit(400)),
1812 b, frame_view->GetLayoutView());
1813
1814 // c's painting should start at (0.7,0.7).
1815 LayoutObject* c = GetDocument().getElementById("c")->GetLayoutObject();
1816 EXPECT_EQ(LayoutPoint(LayoutUnit(0.7), LayoutUnit(0.7)), c->PaintOffset());
1817 // Visual rects via the non-paint properties system use enclosingIntRect
1818 // before applying transforms, because they are computed bottom-up and
1819 // therefore can't apply pixel snapping. Therefore apply a slop of 1px.
1820 CHECK_VISUAL_RECT(LayoutRect(LayoutUnit(0.7) * 10 + LayoutUnit(0.7),
1821 LayoutUnit(0.7) * 10 + LayoutUnit(0.7),
1822 LayoutUnit(400), LayoutUnit(400)),
1823 c, frame_view->GetLayoutView(), 1);
1824 }
1825
1826 TEST_P(PaintPropertyTreeBuilderTest,
1770 PaintOffsetWithPixelSnappingThroughMultipleTransforms) { 1827 PaintOffsetWithPixelSnappingThroughMultipleTransforms) {
1771 SetBodyInnerHTML( 1828 SetBodyInnerHTML(
1772 "<style>" 1829 "<style>"
1773 " * { margin: 0; }" 1830 " * { margin: 0; }"
1774 " div { position: relative; }" 1831 " div { position: relative; }"
1775 " #a {" 1832 " #a {"
1776 " width: 70px;" 1833 " width: 70px;"
1777 " height: 70px;" 1834 " height: 70px;"
1778 " left: 0.7px;" 1835 " left: 0.7px;"
1779 " top: 0.7px;" 1836 " top: 0.7px;"
(...skipping 1690 matching lines...) Expand 10 before | Expand all | Expand 10 after
3470 3527
3471 LayoutObject& svg_root = 3528 LayoutObject& svg_root =
3472 *GetDocument().getElementById("svgroot")->GetLayoutObject(); 3529 *GetDocument().getElementById("svgroot")->GetLayoutObject();
3473 const ObjectPaintProperties* svg_root_properties = svg_root.PaintProperties(); 3530 const ObjectPaintProperties* svg_root_properties = svg_root.PaintProperties();
3474 EXPECT_TRUE(svg_root_properties->Effect()); 3531 EXPECT_TRUE(svg_root_properties->Effect());
3475 EXPECT_EQ(EffectPaintPropertyNode::Root(), 3532 EXPECT_EQ(EffectPaintPropertyNode::Root(),
3476 svg_root_properties->Effect()->Parent()); 3533 svg_root_properties->Effect()->Parent());
3477 } 3534 }
3478 3535
3479 } // namespace blink 3536 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698