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 ca38e7dbde378cc0ca7de8fdf33e9bedec7527f2..05d3640e331de25a1e9678207a1cde2266ebc0c9 100644 |
--- a/third_party/WebKit/Source/core/layout/LayoutObjectTest.cpp |
+++ b/third_party/WebKit/Source/core/layout/LayoutObjectTest.cpp |
@@ -11,6 +11,9 @@ |
namespace blink { |
class LayoutObjectTest : public RenderingTest { |
+public: |
+ LayoutObjectTest() |
+ : RenderingTest(SingleChildFrameLoaderClient::create()) {} |
protected: |
LayoutView& layoutView() const { return *document().layoutView(); } |
}; |
@@ -108,18 +111,45 @@ TEST_F(LayoutObjectTest, ContainingBlockAbsoluteLayoutObjectShouldNotBeNonStatic |
TEST_F(LayoutObjectTest, MapToVisibleRectInAncestorSpace) |
{ |
+ document().setBaseURLOverride(KURL(ParsedURLString, "http://test.com")); |
setBodyInnerHTML( |
+ "<style>body { margin: 0; }</style>" |
"<div id='container' style='overflow: scroll; will-change: transform; width: 50px; height: 50px'>" |
chrishtr
2016/03/24 21:18:43
will-change: transform; seems irrelevant
szager1
2016/03/24 21:52:28
Done.
|
" <span><img style='width: 20px; height: 100px'></span>" |
" text text text text text text text" |
+ "</div>" |
+ "<div id=frameContainer>" |
+ " <iframe id=frame src='http://test.com' width='50' height='50' frameBorder='0'></iframe>" |
"</div>"); |
+ |
+ Document& frameDocument = setupChildIframe("frame", "<style>body { margin: 0; }</style><span><img style='width: 20px; height: 100px'></span>text text text"); |
+ frameDocument.updateLayout(); |
+ |
LayoutBlock* container = toLayoutBlock(getLayoutObjectByElementId("container")); |
LayoutText* text = toLayoutText(container->lastChild()); |
+ LayoutBlock* frameContainer = toLayoutBlock(getLayoutObjectByElementId("frameContainer")); |
+ LayoutBlock* frameBody = toLayoutBlock(frameDocument.body()->layoutObject()); |
+ LayoutText* frameText = toLayoutText(frameBody->lastChild()); |
chrishtr
2016/03/24 21:18:43
Separate these two test types into two unittests (
szager1
2016/03/24 21:52:28
Done.
|
container->setScrollTop(LayoutUnit(50)); |
- LayoutRect rect(0, 60, 20, 20); |
- text->mapToVisibleRectInAncestorSpace(container, rect, nullptr); |
- EXPECT_TRUE(rect == LayoutRect(0, 10, 20, 20)); |
+ LayoutRect rect(0, 60, 20, 80); |
+ EXPECT_TRUE(text->mapToVisibleRectInAncestorSpace(container, rect, nullptr)); |
+ EXPECT_EQ(rect, LayoutRect(0, 10, 20, 80)); |
+ |
+ rect = LayoutRect(0, 60, 80, 0); |
+ EXPECT_TRUE(text->mapToVisibleRectInAncestorSpace(container, rect, nullptr, EdgeInclusive)); |
+ EXPECT_EQ(rect, LayoutRect(0, 10, 80, 0)); |
+ |
+ // This case involves clipping: frame height is 50, y-coordinate of result rect is 13, |
+ // so height should be clipped to (50 - 13) == 37. |
+ frameDocument.view()->setScrollPosition(DoublePoint(0, 47), ProgrammaticScroll); |
chrishtr
2016/03/24 21:18:43
Make one test for LayoutInline, one for LayoutText
szager1
2016/03/24 21:52:28
Done.
|
+ rect = LayoutRect(4, 60, 20, 80); |
+ EXPECT_TRUE(frameText->mapToVisibleRectInAncestorSpace(frameContainer, rect, nullptr)); |
+ EXPECT_EQ(rect, LayoutRect(4, 13, 20, 37)); |
+ |
+ rect = LayoutRect(4, 60, 0, 80); |
+ EXPECT_TRUE(frameText->mapToVisibleRectInAncestorSpace(frameContainer, rect, nullptr, EdgeInclusive)); |
+ EXPECT_EQ(rect, LayoutRect(4, 13, 0, 37)); |
} |
} // namespace blink |