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

Unified 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, 8 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilderTest.cpp
diff --git a/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilderTest.cpp b/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilderTest.cpp
index da5a8c47ffa8dc4f27487621b1742226ad7ae949..64c2c4f355256ad1af9591d6ad1a152f760dfba4 100644
--- a/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilderTest.cpp
+++ b/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilderTest.cpp
@@ -1767,6 +1767,63 @@ TEST_P(PaintPropertyTreeBuilderTest,
}
TEST_P(PaintPropertyTreeBuilderTest,
+ NonTranslationTransformShouldResetSubpixelPaintOffset) {
+ SetBodyInnerHTML(
+ "<style>"
+ " * { margin: 0; }"
+ " div { position: relative; }"
+ " #a {"
+ " width: 70px;"
+ " height: 70px;"
+ " left: 0.7px;"
+ " top: 0.7px;"
+ " }"
+ " #b {"
+ " width: 40px;"
+ " height: 40px;"
+ " transform: scale(10);"
+ " transform-origin: 0 0;"
+ " }"
+ " #c {"
+ " width: 40px;"
+ " height: 40px;"
+ " left: 0.7px;"
+ " top: 0.7px;"
+ " }"
+ "</style>"
+ "<div id='a'>"
+ " <div id='b'>"
+ " <div id='c'></div>"
+ " </div>"
+ "</div>");
+ FrameView* frame_view = GetDocument().View();
+
+ LayoutObject* b = GetDocument().getElementById("b")->GetLayoutObject();
+ const ObjectPaintProperties* b_properties = b->PaintProperties();
+ EXPECT_EQ(TransformationMatrix().Scale(10),
+ b_properties->Transform()->Matrix());
+ // The paint offset transform should not be snapped.
+ EXPECT_EQ(TransformationMatrix().Translate(LayoutUnit(0.7).ToDouble(),
+ LayoutUnit(0.7).ToDouble()),
+ b_properties->Transform()->Parent()->Matrix());
+ EXPECT_EQ(LayoutPoint(), b->PaintOffset());
+ CHECK_EXACT_VISUAL_RECT(LayoutRect(LayoutUnit(0.7), LayoutUnit(0.7),
+ LayoutUnit(400), LayoutUnit(400)),
+ b, frame_view->GetLayoutView());
+
+ // c's painting should start at (0.7,0.7).
+ LayoutObject* c = GetDocument().getElementById("c")->GetLayoutObject();
+ EXPECT_EQ(LayoutPoint(LayoutUnit(0.7), LayoutUnit(0.7)), c->PaintOffset());
+ // Visual rects via the non-paint properties system use enclosingIntRect
+ // before applying transforms, because they are computed bottom-up and
+ // therefore can't apply pixel snapping. Therefore apply a slop of 1px.
+ CHECK_VISUAL_RECT(LayoutRect(LayoutUnit(0.7) * 10 + LayoutUnit(0.7),
+ LayoutUnit(0.7) * 10 + LayoutUnit(0.7),
+ LayoutUnit(400), LayoutUnit(400)),
+ c, frame_view->GetLayoutView(), 1);
+}
+
+TEST_P(PaintPropertyTreeBuilderTest,
PaintOffsetWithPixelSnappingThroughMultipleTransforms) {
SetBodyInnerHTML(
"<style>"

Powered by Google App Engine
This is Rietveld 408576698