Chromium Code Reviews| Index: third_party/WebKit/Source/core/layout/VisualRectMappingTest.cpp |
| diff --git a/third_party/WebKit/Source/core/layout/VisualRectMappingTest.cpp b/third_party/WebKit/Source/core/layout/VisualRectMappingTest.cpp |
| index 4c462ef0c94bf3803f68f627fcd5c390c50c3c07..bfaed40dcb391a16e2bbe077c2d9788c95dc6ccc 100644 |
| --- a/third_party/WebKit/Source/core/layout/VisualRectMappingTest.cpp |
| +++ b/third_party/WebKit/Source/core/layout/VisualRectMappingTest.cpp |
| @@ -2,6 +2,7 @@ |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| +#include "core/html/HTMLFrameOwnerElement.h" |
|
dcheng
2016/11/17 08:49:58
So that line 223 can convert from HTMLFrameOwnerEl
|
| #include "core/layout/LayoutTestHelper.h" |
| #include "core/layout/LayoutView.h" |
| #include "core/layout/PaintInvalidationState.h" |
| @@ -120,29 +121,30 @@ TEST_F(VisualRectMappingTest, LayoutInline) { |
| } |
| TEST_F(VisualRectMappingTest, LayoutView) { |
| + setChildFrameHTML( |
| + "<style>body { margin: 0; }</style><span><img style='width: 20px; " |
| + "height: 100px'></span>text text text"); |
| + |
| document().setBaseURLOverride(KURL(ParsedURLString, "http://test.com")); |
| setBodyInnerHTML( |
| "<style>body { margin: 0; }</style>" |
| "<div id=frameContainer>" |
| - " <iframe id=frame src='http://test.com' width='50' height='50' " |
| + " <iframe 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"); |
| document().view()->updateAllLifecyclePhases(); |
| LayoutBlock* frameContainer = |
| toLayoutBlock(getLayoutObjectByElementId("frameContainer")); |
| - LayoutBlock* frameBody = toLayoutBlock(frameDocument.body()->layoutObject()); |
| + LayoutBlock* frameBody = |
| + toLayoutBlock(childDocument().body()->layoutObject()); |
| LayoutText* frameText = toLayoutText(frameBody->lastChild()); |
| // 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()->setScrollOffset(ScrollOffset(0, 47), |
| - ProgrammaticScroll); |
| + childDocument().view()->setScrollOffset(ScrollOffset(0, 47), |
| + ProgrammaticScroll); |
| LayoutRect originalRect(4, 60, 20, 80); |
| LayoutRect rect = originalRect; |
| EXPECT_TRUE(frameText->mapToVisualRectInAncestorSpace(frameContainer, rect)); |
| @@ -161,23 +163,24 @@ TEST_F(VisualRectMappingTest, LayoutView) { |
| } |
| TEST_F(VisualRectMappingTest, LayoutViewSubpixelRounding) { |
| + setChildFrameHTML( |
| + "<style>body { margin: 0; }</style><div id='target' style='position: " |
| + "relative; width: 100px; height: 100px; left: 0.5px'>"); |
| + |
| 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' " |
| + " <iframe 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'>"); |
| document().view()->updateAllLifecyclePhases(); |
| LayoutBlock* frameContainer = |
| toLayoutBlock(getLayoutObjectByElementId("frameContainer")); |
| - LayoutObject* target = frameDocument.getElementById("target")->layoutObject(); |
| + LayoutObject* target = |
| + childDocument().getElementById("target")->layoutObject(); |
| LayoutRect rect(0, 0, 100, 100); |
| EXPECT_TRUE(target->mapToVisualRectInAncestorSpace(frameContainer, rect)); |
| // When passing from the iframe to the parent frame, the rect of (0.5, 0, 100, |
| @@ -188,35 +191,36 @@ TEST_F(VisualRectMappingTest, LayoutViewSubpixelRounding) { |
| } |
| TEST_F(VisualRectMappingTest, LayoutViewDisplayNone) { |
| + setChildFrameHTML( |
| + "<style>body { margin: 0; }</style><div " |
| + "style='width:100px;height:100px;'></div>"); |
| + |
| document().setBaseURLOverride(KURL(ParsedURLString, "http://test.com")); |
| setBodyInnerHTML( |
| "<style>body { margin: 0; }</style>" |
| "<div id=frameContainer>" |
| - " <iframe id=frame src='http://test.com' width='50' height='50' " |
| + " <iframe src='http://test.com' width='50' height='50' " |
| "frameBorder='0'></iframe>" |
| "</div>"); |
| - Document& frameDocument = |
| - setupChildIframe("frame", |
| - "<style>body { margin: 0; }</style><div " |
| - "style='width:100px;height:100px;'></div>"); |
| document().view()->updateAllLifecyclePhases(); |
| LayoutBlock* frameContainer = |
| toLayoutBlock(getLayoutObjectByElementId("frameContainer")); |
| - LayoutBlock* frameBody = toLayoutBlock(frameDocument.body()->layoutObject()); |
| + LayoutBlock* frameBody = |
| + toLayoutBlock(childDocument().body()->layoutObject()); |
| LayoutBlock* frameDiv = toLayoutBlock(frameBody->lastChild()); |
| // This part is copied from the LayoutView test, just to ensure that the |
| // mapped rect is valid before display:none is set on the iframe. |
| - frameDocument.view()->setScrollOffset(ScrollOffset(0, 47), |
| - ProgrammaticScroll); |
| + childDocument().view()->setScrollOffset(ScrollOffset(0, 47), |
| + ProgrammaticScroll); |
| LayoutRect originalRect(4, 60, 20, 80); |
| LayoutRect rect = originalRect; |
| EXPECT_TRUE(frameDiv->mapToVisualRectInAncestorSpace(frameContainer, rect)); |
| EXPECT_EQ(rect, LayoutRect(4, 13, 20, 37)); |
| - Element* frameElement = document().getElementById("frame"); |
| + Element* frameElement = childDocument().localOwner(); |
| frameElement->setInlineStyleProperty(CSSPropertyDisplay, "none"); |
| document().view()->updateAllLifecyclePhases(); |