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

Unified Diff: third_party/WebKit/Source/core/layout/LayoutObjectTest.cpp

Issue 1834263002: Round visual rects when crossing frame boundaries. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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/layout/LayoutObjectTest.cpp
diff --git a/third_party/WebKit/Source/core/layout/LayoutObjectTest.cpp b/third_party/WebKit/Source/core/layout/LayoutObjectTest.cpp
index 8a8ff1947d269a6290abedb8603d716de51fb17c..274ea86c5fd4c92f736ed487ddb929da28ab9330 100644
--- a/third_party/WebKit/Source/core/layout/LayoutObjectTest.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutObjectTest.cpp
@@ -181,4 +181,26 @@ TEST_F(LayoutObjectTest, LayoutViewMapToVisibleRectInAncestorSpace)
EXPECT_EQ(rect, LayoutRect(4, 13, 0, 37));
}
+TEST_F(LayoutObjectTest, LayoutViewMapToVisibleRectInAncestorSpaceSubpixelRounding)
+{
+ document().setBaseURLOverride(KURL(ParsedURLString, "http://test.com"));
+ setBodyInnerHTML(
+ "<style>body { margin: 0; }</style>"
+ "<div id=frameContainer style='position: relative; left: 0.5px'>"
+ " <iframe id=frame style='position: relative; left: 0.5px' src='http://test.com' width='200' height='200' frameBorder='0'></iframe>"
+ "</div>");
+
+ Document& frameDocument = setupChildIframe(
+ "frame", "<style>body { margin: 0; }</style><div id='target' style='position: relative; width: 100px; height: 100px; left: 0.5px'>");
+ frameDocument.updateLayout();
+
+ LayoutBlock* frameContainer = toLayoutBlock(getLayoutObjectByElementId("frameContainer"));
+ LayoutObject* target = frameDocument.getElementById("target")->layoutObject();
+ LayoutRect rect(0, 0, 100, 100);
+ EXPECT_TRUE(target->mapToVisibleRectInAncestorSpace(frameContainer, rect));
+ // When passing from the iframe to the parent frame, the rect of (0.5, 0, 100, 100) is expanded to (0, 0, 100, 100), and then offset by
+ // the 0.5 offset of frameContainer.
+ EXPECT_EQ(LayoutRect(LayoutPoint(DoublePoint(0.5, 0)), LayoutSize(101, 100)), rect);
+}
+
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698