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

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

Issue 1767573002: In mapAncestorToLocal, account for frame documents always being fixed-position containers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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/MapCoordinatesTest.cpp
diff --git a/third_party/WebKit/Source/core/layout/MapCoordinatesTest.cpp b/third_party/WebKit/Source/core/layout/MapCoordinatesTest.cpp
index f34a9daa88955f5bcd37d51d2b277b46698b28b7..c4cf7c774f2e2aba8d6b153f3b646923b232497e 100644
--- a/third_party/WebKit/Source/core/layout/MapCoordinatesTest.cpp
+++ b/third_party/WebKit/Source/core/layout/MapCoordinatesTest.cpp
@@ -12,6 +12,8 @@ namespace blink {
class MapCoordinatesTest : public RenderingTest {
public:
+ MapCoordinatesTest()
+ : RenderingTest(SingleChildFrameLoaderClient::create()) {}
FloatPoint mapLocalToAncestor(const LayoutObject*, const LayoutBoxModelObject* ancestor, FloatPoint, MapCoordinatesFlags = 0) const;
FloatQuad mapLocalToAncestor(const LayoutObject*, const LayoutBoxModelObject* ancestor, FloatQuad, MapCoordinatesFlags = 0) const;
FloatPoint mapAncestorToLocal(const LayoutObject*, const LayoutBoxModelObject* ancestor, FloatPoint, MapCoordinatesFlags = 0) const;
@@ -448,6 +450,31 @@ TEST_F(MapCoordinatesTest, FixedPosInFixedPos)
EXPECT_EQ(FloatPoint(), mappedPoint);
}
+// TODO(chrishtr): add more multi-frame tests.
+TEST_F(MapCoordinatesTest, FixedPosInScrolledIFrame)
+{
+ document().setBaseURLOverride(KURL(ParsedURLString, "http://test.com"));
+ setBodyInnerHTML(
+ "<style>body { margin: 0; }</style>"
+ "<div style='width: 200; height: 8000px'></div>"
+ "<iframe 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: 200px; position:fixed}</style><div id=target></div>");
+
+ document().view()->setScrollPosition(DoublePoint(0.0, 1000), ProgrammaticScroll);
+ document().view()->updateAllLifecyclePhases();
+
+ Element* target = frameDocument.getElementById("target");
+ ASSERT_TRUE(target);
+ FloatPoint mappedPoint = mapAncestorToLocal(target->layoutObject(), nullptr, FloatPoint(10, 70), TraverseDocumentBoundaries);
+
+ // y = 70 - 8000, since the iframe is offset by 8000px from the main frame.
+ // The scroll is not taken into account because the element is not fixed to the root LayoutView,
+ // and the space of the root LayoutView does not include scroll.
+ EXPECT_EQ(FloatPoint(10, -7930), mappedPoint);
+}
+
TEST_F(MapCoordinatesTest, MulticolWithText)
{
setBodyInnerHTML(

Powered by Google App Engine
This is Rietveld 408576698