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

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

Issue 1846753004: Fix wrong box-shadow visual overflow with flipped blocks writing mode (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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
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/LayoutObject.h" 5 #include "core/layout/LayoutObject.h"
6 6
7 #include "core/layout/LayoutTestHelper.h" 7 #include "core/layout/LayoutTestHelper.h"
8 #include "core/layout/LayoutView.h" 8 #include "core/layout/LayoutView.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 196
197 LayoutBlock* frameContainer = toLayoutBlock(getLayoutObjectByElementId("fram eContainer")); 197 LayoutBlock* frameContainer = toLayoutBlock(getLayoutObjectByElementId("fram eContainer"));
198 LayoutObject* target = frameDocument.getElementById("target")->layoutObject( ); 198 LayoutObject* target = frameDocument.getElementById("target")->layoutObject( );
199 LayoutRect rect(0, 0, 100, 100); 199 LayoutRect rect(0, 0, 100, 100);
200 EXPECT_TRUE(target->mapToVisualRectInAncestorSpace(frameContainer, rect)); 200 EXPECT_TRUE(target->mapToVisualRectInAncestorSpace(frameContainer, rect));
201 // 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 201 // 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
202 // the 0.5 offset of frameContainer. 202 // the 0.5 offset of frameContainer.
203 EXPECT_EQ(LayoutRect(LayoutPoint(DoublePoint(0.5, 0)), LayoutSize(101, 100)) , rect); 203 EXPECT_EQ(LayoutRect(LayoutPoint(DoublePoint(0.5, 0)), LayoutSize(101, 100)) , rect);
204 } 204 }
205 205
206 TEST_F(LayoutObjectTest, OverflowRectMappingWithSelfFlippedWritingMode)
207 {
208 setBodyInnerHTML(
209 "<div id='target' style='writing-mode: vertical-rl; box-shadow: 40px 20p x black;"
210 " width: 100px; height: 50px; position: absolute; top: 111px; left: 2 22px'>"
211 "</div>");
212
213 LayoutBlock* target = toLayoutBlock(getLayoutObjectByElementId("target"));
214 LayoutRect overflowRect = target->localOverflowRectForPaintInvalidation();
215 EXPECT_EQ(LayoutRect(-40, 0, 140, 70), overflowRect);
216 LayoutRect rect = overflowRect;
217 EXPECT_TRUE(target->mapToVisualRectInAncestorSpace(target, rect));
218 EXPECT_EQ(LayoutRect(0, 0, 140, 70), rect);
219 rect = overflowRect;
220 EXPECT_TRUE(target->mapToVisualRectInAncestorSpace(&layoutView(), rect));
221 EXPECT_EQ(LayoutRect(222, 111, 140, 70), rect);
chrishtr 2016/04/01 00:42:09 Why is it offset by 222, 111? Isn't that the size
Xianzhu 2016/04/01 01:17:22 They are absolute position of 'target' ("position
chrishtr 2016/04/01 16:50:58 Oh right sorry.
222 }
223
224 TEST_F(LayoutObjectTest, OverflowRectMappingWithContainerFlippedWritingMode)
225 {
226 setBodyInnerHTML(
227 "<div id='container' style='writing-mode: vertical-rl; position: absolut e; top: 111px; left: 222px'>"
228 " <div id='target' style='box-shadow: 40px 20px black; width: 100px; height: 90px'></div>"
229 " <div style='width: 100px; height: 100px'></div>"
230 "</div>");
231
232 LayoutBlock* target = toLayoutBlock(getLayoutObjectByElementId("target"));
233 LayoutRect targetOverflowRect = target->localOverflowRectForPaintInvalidatio n();
234 EXPECT_EQ(LayoutRect(-40, 0, 140, 110), targetOverflowRect);
235 LayoutRect rect = targetOverflowRect;
236 EXPECT_TRUE(target->mapToVisualRectInAncestorSpace(target, rect));
237 EXPECT_EQ(LayoutRect(0, 0, 140, 110), rect);
238
239 LayoutBlock* container = toLayoutBlock(getLayoutObjectByElementId("container "));
240 rect = targetOverflowRect;
241 EXPECT_TRUE(target->mapToVisualRectInAncestorSpace(container, rect));
242 EXPECT_EQ(LayoutRect(100, 0, 140, 110), rect);
243 rect = targetOverflowRect;
244 EXPECT_TRUE(target->mapToVisualRectInAncestorSpace(&layoutView(), rect));
245 EXPECT_EQ(LayoutRect(322, 111, 140, 110), rect);
246
247 LayoutRect containerOverflowRect = container->localOverflowRectForPaintInval idation();
248 EXPECT_EQ(LayoutRect(-40, 0, 240, 110), containerOverflowRect);
249 rect = containerOverflowRect;
250 EXPECT_TRUE(target->mapToVisualRectInAncestorSpace(container, rect));
251 EXPECT_EQ(LayoutRect(0, 0, 240, 110), rect);
252 rect = containerOverflowRect;
253 EXPECT_TRUE(target->mapToVisualRectInAncestorSpace(&layoutView(), rect));
254 EXPECT_EQ(LayoutRect(222, 111, 240, 110), rect);
255 }
256
206 } // namespace blink 257 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutBox.cpp ('k') | third_party/WebKit/Source/core/layout/PaintInvalidationState.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698