| OLD | NEW |
| 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 Loading... |
| 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 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 513 LayoutRect absoluteOverflowRect = absolute->localOverflowRectForPaintInvalid
ation(); | 546 LayoutRect absoluteOverflowRect = absolute->localOverflowRectForPaintInvalid
ation(); |
| 514 EXPECT_EQ(LayoutRect(0, 0, 50, 50), absoluteOverflowRect); | 547 EXPECT_EQ(LayoutRect(0, 0, 50, 50), absoluteOverflowRect); |
| 515 LayoutRect rect = absoluteOverflowRect; | 548 LayoutRect rect = absoluteOverflowRect; |
| 516 EXPECT_TRUE(absolute->mapToVisualRectInAncestorSpace(stackingContext, rect))
; | 549 EXPECT_TRUE(absolute->mapToVisualRectInAncestorSpace(stackingContext, rect))
; |
| 517 // -172 = top(50) - y_offset_of_stacking_context(222) | 550 // -172 = top(50) - y_offset_of_stacking_context(222) |
| 518 EXPECT_EQ(LayoutRect(50, -172, 50, 50), rect); | 551 EXPECT_EQ(LayoutRect(50, -172, 50, 50), rect); |
| 519 checkPaintInvalidationStateRectMapping(rect, absoluteOverflowRect, *absolute
, layoutView(), *stackingContext); | 552 checkPaintInvalidationStateRectMapping(rect, absoluteOverflowRect, *absolute
, layoutView(), *stackingContext); |
| 520 } | 553 } |
| 521 | 554 |
| 522 } // namespace blink | 555 } // namespace blink |
| OLD | NEW |