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

Side by Side Diff: third_party/WebKit/Source/core/layout/VisualRectMappingTest.cpp

Issue 2218703002: [mapToVisualRectInAncestorSpace] Check for detached iframes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Simplify test Created 4 years, 4 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 unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutView.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/layout/LayoutTestHelper.h" 5 #include "core/layout/LayoutTestHelper.h"
6 #include "core/layout/LayoutView.h" 6 #include "core/layout/LayoutView.h"
7 #include "core/layout/PaintInvalidationState.h" 7 #include "core/layout/PaintInvalidationState.h"
8 #include "core/paint/PaintLayer.h" 8 #include "core/paint/PaintLayer.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 149
150 LayoutBlock* frameContainer = toLayoutBlock(getLayoutObjectByElementId("fram eContainer")); 150 LayoutBlock* frameContainer = toLayoutBlock(getLayoutObjectByElementId("fram eContainer"));
151 LayoutObject* target = frameDocument.getElementById("target")->layoutObject( ); 151 LayoutObject* target = frameDocument.getElementById("target")->layoutObject( );
152 LayoutRect rect(0, 0, 100, 100); 152 LayoutRect rect(0, 0, 100, 100);
153 EXPECT_TRUE(target->mapToVisualRectInAncestorSpace(frameContainer, rect)); 153 EXPECT_TRUE(target->mapToVisualRectInAncestorSpace(frameContainer, rect));
154 // When passing from the iframe to the parent frame, the rect of (0.5, 0, 10 0, 100) is expanded to (0, 0, 100, 100), and then offset by 154 // When passing from the iframe to the parent frame, the rect of (0.5, 0, 10 0, 100) is expanded to (0, 0, 100, 100), and then offset by
155 // the 0.5 offset of frameContainer. 155 // the 0.5 offset of frameContainer.
156 EXPECT_EQ(LayoutRect(LayoutPoint(DoublePoint(0.5, 0)), LayoutSize(101, 100)) , rect); 156 EXPECT_EQ(LayoutRect(LayoutPoint(DoublePoint(0.5, 0)), LayoutSize(101, 100)) , rect);
157 } 157 }
158 158
159 TEST_F(VisualRectMappingTest, LayoutViewDisplayNone)
160 {
161 document().setBaseURLOverride(KURL(ParsedURLString, "http://test.com"));
162 setBodyInnerHTML(
163 "<style>body { margin: 0; }</style>"
164 "<div id=frameContainer>"
165 " <iframe id=frame src='http://test.com' width='50' height='50' frameBo rder='0'></iframe>"
166 "</div>");
167
168 Document& frameDocument = setupChildIframe("frame", "<style>body { margin: 0 ; }</style><div style='width:100px;height:100px;'></div>");
169 document().view()->updateAllLifecyclePhases();
170
171 LayoutBlock* frameContainer = toLayoutBlock(getLayoutObjectByElementId("fram eContainer"));
172 LayoutBlock* frameBody = toLayoutBlock(frameDocument.body()->layoutObject()) ;
173 LayoutBlock* frameDiv = toLayoutBlock(frameBody->lastChild());
174
175 // This part is copied from the LayoutView test, just to ensure that the map ped
176 // rect is valid before display:none is set on the iframe.
177 frameDocument.view()->setScrollPosition(DoublePoint(0, 47), ProgrammaticScro ll);
178 LayoutRect originalRect(4, 60, 20, 80);
179 LayoutRect rect = originalRect;
180 EXPECT_TRUE(frameDiv->mapToVisualRectInAncestorSpace(frameContainer, rect));
181 EXPECT_EQ(rect, LayoutRect(4, 13, 20, 37));
182
183 Element* frameElement = document().getElementById("frame");
184 frameElement->setInlineStyleProperty(CSSPropertyDisplay, "none");
185 document().view()->updateAllLifecyclePhases();
186
187 rect = originalRect;
188 EXPECT_FALSE(frameDiv->mapToVisualRectInAncestorSpace(&layoutView(), rect));
189 EXPECT_EQ(rect, LayoutRect());
190 }
191
159 TEST_F(VisualRectMappingTest, SelfFlippedWritingMode) 192 TEST_F(VisualRectMappingTest, SelfFlippedWritingMode)
160 { 193 {
161 setBodyInnerHTML( 194 setBodyInnerHTML(
162 "<div id='target' style='writing-mode: vertical-rl; box-shadow: 40px 20p x black;" 195 "<div id='target' style='writing-mode: vertical-rl; box-shadow: 40px 20p x black;"
163 " width: 100px; height: 50px; position: absolute; top: 111px; left: 2 22px'>" 196 " width: 100px; height: 50px; position: absolute; top: 111px; left: 2 22px'>"
164 "</div>"); 197 "</div>");
165 198
166 LayoutBlock* target = toLayoutBlock(getLayoutObjectByElementId("target")); 199 LayoutBlock* target = toLayoutBlock(getLayoutObjectByElementId("target"));
167 LayoutRect overflowRect = target->localOverflowRectForPaintInvalidation(); 200 LayoutRect overflowRect = target->localOverflowRectForPaintInvalidation();
168 // -40 = -box_shadow_offset_x(40) (with target's top-right corner as the ori gin) 201 // -40 = -box_shadow_offset_x(40) (with target's top-right corner as the ori gin)
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
532 LayoutRect absoluteOverflowRect = absolute->localOverflowRectForPaintInvalid ation(); 565 LayoutRect absoluteOverflowRect = absolute->localOverflowRectForPaintInvalid ation();
533 EXPECT_EQ(LayoutRect(0, 0, 50, 50), absoluteOverflowRect); 566 EXPECT_EQ(LayoutRect(0, 0, 50, 50), absoluteOverflowRect);
534 LayoutRect rect = absoluteOverflowRect; 567 LayoutRect rect = absoluteOverflowRect;
535 EXPECT_TRUE(absolute->mapToVisualRectInAncestorSpace(stackingContext, rect)) ; 568 EXPECT_TRUE(absolute->mapToVisualRectInAncestorSpace(stackingContext, rect)) ;
536 // -172 = top(50) - y_offset_of_stacking_context(222) 569 // -172 = top(50) - y_offset_of_stacking_context(222)
537 EXPECT_EQ(LayoutRect(50, -172, 50, 50), rect); 570 EXPECT_EQ(LayoutRect(50, -172, 50, 50), rect);
538 checkPaintInvalidationStateRectMapping(rect, absoluteOverflowRect, *absolute , layoutView(), *stackingContext); 571 checkPaintInvalidationStateRectMapping(rect, absoluteOverflowRect, *absolute , layoutView(), *stackingContext);
539 } 572 }
540 573
541 } // namespace blink 574 } // namespace blink
OLDNEW
« 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