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

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

Issue 2141693002: Fix order of operations in LayoutView::mapAncestorToLocal (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: none Created 4 years, 5 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
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutView.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/layout/MapCoordinatesTest.cpp
diff --git a/third_party/WebKit/Source/core/layout/MapCoordinatesTest.cpp b/third_party/WebKit/Source/core/layout/MapCoordinatesTest.cpp
index ee06f78ae4a5b5859d0bee3a063d0764b0e2fc7f..9da280540f53b3f7e6dfa317023c818d87f4b7c7 100644
--- a/third_party/WebKit/Source/core/layout/MapCoordinatesTest.cpp
+++ b/third_party/WebKit/Source/core/layout/MapCoordinatesTest.cpp
@@ -475,6 +475,33 @@ TEST_F(MapCoordinatesTest, FixedPosInIFrameWhenMainFrameScrolled)
EXPECT_EQ(FloatPoint(10, -7930), mappedPoint);
}
+TEST_F(MapCoordinatesTest, IFrameTransformed)
+{
+ document().setBaseURLOverride(KURL(ParsedURLString, "http://test.com"));
+ setBodyInnerHTML(
+ "<style>body { margin: 0; }</style>"
+ "<iframe style='transform: scale(2)' id=frame src='http://test.com' width='500' height='500' frameBorder='0'>"
+ "</iframe>");
+
+ Document& frameDocument = setupChildIframe("frame", "<style>body { margin: 0; } #target { width: 200px; height: 8000px}</style><div id=target></div>");
+
+ document().view()->updateAllLifecyclePhases();
+
+ frameDocument.view()->setScrollPosition(DoublePoint(0.0, 1000), ProgrammaticScroll);
+ frameDocument.view()->updateAllLifecyclePhases();
+
+ Element* target = frameDocument.getElementById("target");
+ ASSERT_TRUE(target);
+ FloatPoint mappedPoint = mapAncestorToLocal(target->layoutObject(), nullptr, FloatPoint(200, 200), TraverseDocumentBoundaries | UseTransforms);
+
+ // Derivation:
+ // (200, 200) -> (-50, -50) (Adjust for transform origin of scale, which is at the center of the 500x500 iframe)
+ // (-50, -50) -> (-25, -25) (Divide by 2 to invert the scale)
+ // (-25, -25) -> (225, 225) (Add the origin back in)
+ // (225, 225) -> (225, 1225) (Adjust by scroll offset of y=1000)
+ EXPECT_EQ(FloatPoint(225, 1225), mappedPoint);
+}
+
TEST_F(MapCoordinatesTest, FixedPosInScrolledIFrameWithTransform)
{
document().setBaseURLOverride(KURL(ParsedURLString, "http://test.com"));
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutView.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698