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

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

Issue 2015523004: Don't explicitly initialize LayoutUnit to 0. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Go through the subdirs of core/layout/ too. Created 4 years, 6 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/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 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 224
225 TEST_F(VisualRectMappingTest, ContainerOverflowScroll) 225 TEST_F(VisualRectMappingTest, ContainerOverflowScroll)
226 { 226 {
227 setBodyInnerHTML( 227 setBodyInnerHTML(
228 "<div id='container' style='position: absolute; top: 111px; left: 222px; " 228 "<div id='container' style='position: absolute; top: 111px; left: 222px; "
229 " border: 10px solid red; overflow: scroll; width: 50px; height: 80px ;'>" 229 " border: 10px solid red; overflow: scroll; width: 50px; height: 80px ;'>"
230 " <div id='target' style='box-shadow: 40px 20px black; width: 100px; height: 90px'></div>" 230 " <div id='target' style='box-shadow: 40px 20px black; width: 100px; height: 90px'></div>"
231 "</div>"); 231 "</div>");
232 232
233 LayoutBlock* container = toLayoutBlock(getLayoutObjectByElementId("container ")); 233 LayoutBlock* container = toLayoutBlock(getLayoutObjectByElementId("container "));
234 EXPECT_EQ(LayoutUnit(0), container->scrollTop()); 234 EXPECT_EQ(LayoutUnit(), container->scrollTop());
235 EXPECT_EQ(LayoutUnit(0), container->scrollLeft()); 235 EXPECT_EQ(LayoutUnit(), container->scrollLeft());
236 container->setScrollTop(LayoutUnit(7)); 236 container->setScrollTop(LayoutUnit(7));
237 container->setScrollLeft(LayoutUnit(8)); 237 container->setScrollLeft(LayoutUnit(8));
238 document().view()->updateAllLifecyclePhases(); 238 document().view()->updateAllLifecyclePhases();
239 239
240 LayoutBlock* target = toLayoutBlock(getLayoutObjectByElementId("target")); 240 LayoutBlock* target = toLayoutBlock(getLayoutObjectByElementId("target"));
241 LayoutRect targetOverflowRect = target->localOverflowRectForPaintInvalidatio n(); 241 LayoutRect targetOverflowRect = target->localOverflowRectForPaintInvalidatio n();
242 // 140 = width(100) + box_shadow_offset_x(40) 242 // 140 = width(100) + box_shadow_offset_x(40)
243 // 110 = height(90) + box_shadow_offset_y(20) 243 // 110 = height(90) + box_shadow_offset_y(20)
244 EXPECT_EQ(LayoutRect(0, 0, 140, 110), targetOverflowRect); 244 EXPECT_EQ(LayoutRect(0, 0, 140, 110), targetOverflowRect);
245 LayoutRect rect = targetOverflowRect; 245 LayoutRect rect = targetOverflowRect;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 { 280 {
281 setBodyInnerHTML( 281 setBodyInnerHTML(
282 "<div id='container' style='writing-mode: vertical-rl; position: absolut e; top: 111px; left: 222px;" 282 "<div id='container' style='writing-mode: vertical-rl; position: absolut e; top: 111px; left: 222px;"
283 " border: solid red; border-width: 10px 20px 30px 40px;" 283 " border: solid red; border-width: 10px 20px 30px 40px;"
284 " overflow: scroll; width: 50px; height: 80px'>" 284 " overflow: scroll; width: 50px; height: 80px'>"
285 " <div id='target' style='box-shadow: 40px 20px black; width: 100px; height: 90px'></div>" 285 " <div id='target' style='box-shadow: 40px 20px black; width: 100px; height: 90px'></div>"
286 " <div style='width: 100px; height: 100px'></div>" 286 " <div style='width: 100px; height: 100px'></div>"
287 "</div>"); 287 "</div>");
288 288
289 LayoutBlock* container = toLayoutBlock(getLayoutObjectByElementId("container ")); 289 LayoutBlock* container = toLayoutBlock(getLayoutObjectByElementId("container "));
290 EXPECT_EQ(LayoutUnit(0), container->scrollTop()); 290 EXPECT_EQ(LayoutUnit(), container->scrollTop());
291 // The initial scroll offset is to the left-most because of flipped blocks w riting mode. 291 // The initial scroll offset is to the left-most because of flipped blocks w riting mode.
292 // 150 = total_layout_overflow(100 + 100) - width(50) 292 // 150 = total_layout_overflow(100 + 100) - width(50)
293 EXPECT_EQ(LayoutUnit(150), container->scrollLeft()); 293 EXPECT_EQ(LayoutUnit(150), container->scrollLeft());
294 container->setScrollTop(LayoutUnit(7)); 294 container->setScrollTop(LayoutUnit(7));
295 container->setScrollLeft(LayoutUnit(142)); // Scroll to the right by 8 pixel s. 295 container->setScrollLeft(LayoutUnit(142)); // Scroll to the right by 8 pixel s.
296 document().view()->updateAllLifecyclePhases(); 296 document().view()->updateAllLifecyclePhases();
297 297
298 LayoutBlock* target = toLayoutBlock(getLayoutObjectByElementId("target")); 298 LayoutBlock* target = toLayoutBlock(getLayoutObjectByElementId("target"));
299 LayoutRect targetOverflowRect = target->localOverflowRectForPaintInvalidatio n(); 299 LayoutRect targetOverflowRect = target->localOverflowRectForPaintInvalidatio n();
300 // -40 = -box_shadow_offset_x(40) (with target's top-right corner as the ori gin) 300 // -40 = -box_shadow_offset_x(40) (with target's top-right corner as the ori gin)
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 343
344 TEST_F(VisualRectMappingTest, ContainerOverflowHidden) 344 TEST_F(VisualRectMappingTest, ContainerOverflowHidden)
345 { 345 {
346 setBodyInnerHTML( 346 setBodyInnerHTML(
347 "<div id='container' style='position: absolute; top: 111px; left: 222px; " 347 "<div id='container' style='position: absolute; top: 111px; left: 222px; "
348 " border: 10px solid red; overflow: hidden; width: 50px; height: 80px ;'>" 348 " border: 10px solid red; overflow: hidden; width: 50px; height: 80px ;'>"
349 " <div id='target' style='box-shadow: 40px 20px black; width: 100px; height: 90px'></div>" 349 " <div id='target' style='box-shadow: 40px 20px black; width: 100px; height: 90px'></div>"
350 "</div>"); 350 "</div>");
351 351
352 LayoutBlock* container = toLayoutBlock(getLayoutObjectByElementId("container ")); 352 LayoutBlock* container = toLayoutBlock(getLayoutObjectByElementId("container "));
353 EXPECT_EQ(LayoutUnit(0), container->scrollTop()); 353 EXPECT_EQ(LayoutUnit(), container->scrollTop());
354 EXPECT_EQ(LayoutUnit(0), container->scrollLeft()); 354 EXPECT_EQ(LayoutUnit(), container->scrollLeft());
355 container->setScrollTop(LayoutUnit(27)); 355 container->setScrollTop(LayoutUnit(27));
356 container->setScrollLeft(LayoutUnit(28)); 356 container->setScrollLeft(LayoutUnit(28));
357 document().view()->updateAllLifecyclePhases(); 357 document().view()->updateAllLifecyclePhases();
358 358
359 LayoutBlock* target = toLayoutBlock(getLayoutObjectByElementId("target")); 359 LayoutBlock* target = toLayoutBlock(getLayoutObjectByElementId("target"));
360 LayoutRect targetOverflowRect = target->localOverflowRectForPaintInvalidatio n(); 360 LayoutRect targetOverflowRect = target->localOverflowRectForPaintInvalidatio n();
361 // 140 = width(100) + box_shadow_offset_x(40) 361 // 140 = width(100) + box_shadow_offset_x(40)
362 // 110 = height(90) + box_shadow_offset_y(20) 362 // 110 = height(90) + box_shadow_offset_y(20)
363 EXPECT_EQ(LayoutRect(0, 0, 140, 110), targetOverflowRect); 363 EXPECT_EQ(LayoutRect(0, 0, 140, 110), targetOverflowRect);
364 LayoutRect rect = targetOverflowRect; 364 LayoutRect rect = targetOverflowRect;
(...skipping 10 matching lines...) Expand all
375 { 375 {
376 setBodyInnerHTML( 376 setBodyInnerHTML(
377 "<div id='container' style='writing-mode: vertical-rl; position: absolut e; top: 111px; left: 222px;" 377 "<div id='container' style='writing-mode: vertical-rl; position: absolut e; top: 111px; left: 222px;"
378 " border: solid red; border-width: 10px 20px 30px 40px;" 378 " border: solid red; border-width: 10px 20px 30px 40px;"
379 " overflow: hidden; width: 50px; height: 80px'>" 379 " overflow: hidden; width: 50px; height: 80px'>"
380 " <div id='target' style='box-shadow: 40px 20px black; width: 100px; height: 90px'></div>" 380 " <div id='target' style='box-shadow: 40px 20px black; width: 100px; height: 90px'></div>"
381 " <div style='width: 100px; height: 100px'></div>" 381 " <div style='width: 100px; height: 100px'></div>"
382 "</div>"); 382 "</div>");
383 383
384 LayoutBlock* container = toLayoutBlock(getLayoutObjectByElementId("container ")); 384 LayoutBlock* container = toLayoutBlock(getLayoutObjectByElementId("container "));
385 EXPECT_EQ(LayoutUnit(0), container->scrollTop()); 385 EXPECT_EQ(LayoutUnit(), container->scrollTop());
386 // The initial scroll offset is to the left-most because of flipped blocks w riting mode. 386 // The initial scroll offset is to the left-most because of flipped blocks w riting mode.
387 // 150 = total_layout_overflow(100 + 100) - width(50) 387 // 150 = total_layout_overflow(100 + 100) - width(50)
388 EXPECT_EQ(LayoutUnit(150), container->scrollLeft()); 388 EXPECT_EQ(LayoutUnit(150), container->scrollLeft());
389 container->setScrollTop(LayoutUnit(7)); 389 container->setScrollTop(LayoutUnit(7));
390 container->setScrollLeft(LayoutUnit(82)); // Scroll to the right by 8 pixels . 390 container->setScrollLeft(LayoutUnit(82)); // Scroll to the right by 8 pixels .
391 document().view()->updateAllLifecyclePhases(); 391 document().view()->updateAllLifecyclePhases();
392 392
393 LayoutBlock* target = toLayoutBlock(getLayoutObjectByElementId("target")); 393 LayoutBlock* target = toLayoutBlock(getLayoutObjectByElementId("target"));
394 LayoutRect targetOverflowRect = target->localOverflowRectForPaintInvalidatio n(); 394 LayoutRect targetOverflowRect = target->localOverflowRectForPaintInvalidatio n();
395 // -40 = -box_shadow_offset_x(40) (with target's top-right corner as the ori gin) 395 // -40 = -box_shadow_offset_x(40) (with target's top-right corner as the ori gin)
(...skipping 17 matching lines...) Expand all
413 { 413 {
414 setBodyInnerHTML( 414 setBodyInnerHTML(
415 "<div id='container' style='writing-mode: vertical-rl; position: absolut e; top: 111px; left: 222px;" 415 "<div id='container' style='writing-mode: vertical-rl; position: absolut e; top: 111px; left: 222px;"
416 " border: solid red; border-width: 10px 20px 30px 40px;" 416 " border: solid red; border-width: 10px 20px 30px 40px;"
417 " overflow: scroll; width: 50px; height: 80px'>" 417 " overflow: scroll; width: 50px; height: 80px'>"
418 " <div id='target' style='writing-mode: vertical-lr; box-shadow: 40px 20px black; width: 100px; height: 90px'></div>" 418 " <div id='target' style='writing-mode: vertical-lr; box-shadow: 40px 20px black; width: 100px; height: 90px'></div>"
419 " <div style='width: 100px; height: 100px'></div>" 419 " <div style='width: 100px; height: 100px'></div>"
420 "</div>"); 420 "</div>");
421 421
422 LayoutBlock* container = toLayoutBlock(getLayoutObjectByElementId("container ")); 422 LayoutBlock* container = toLayoutBlock(getLayoutObjectByElementId("container "));
423 EXPECT_EQ(LayoutUnit(0), container->scrollTop()); 423 EXPECT_EQ(LayoutUnit(), container->scrollTop());
424 // The initial scroll offset is to the left-most because of flipped blocks w riting mode. 424 // The initial scroll offset is to the left-most because of flipped blocks w riting mode.
425 // 150 = total_layout_overflow(100 + 100) - width(50) 425 // 150 = total_layout_overflow(100 + 100) - width(50)
426 EXPECT_EQ(LayoutUnit(150), container->scrollLeft()); 426 EXPECT_EQ(LayoutUnit(150), container->scrollLeft());
427 container->setScrollTop(LayoutUnit(7)); 427 container->setScrollTop(LayoutUnit(7));
428 container->setScrollLeft(LayoutUnit(142)); // Scroll to the right by 8 pixel s. 428 container->setScrollLeft(LayoutUnit(142)); // Scroll to the right by 8 pixel s.
429 document().view()->updateAllLifecyclePhases(); 429 document().view()->updateAllLifecyclePhases();
430 430
431 LayoutBlock* target = toLayoutBlock(getLayoutObjectByElementId("target")); 431 LayoutBlock* target = toLayoutBlock(getLayoutObjectByElementId("target"));
432 LayoutRect targetOverflowRect = target->localOverflowRectForPaintInvalidatio n(); 432 LayoutRect targetOverflowRect = target->localOverflowRectForPaintInvalidatio n();
433 // 140 = width(100) + box_shadow_offset_x(40) 433 // 140 = width(100) + box_shadow_offset_x(40)
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 LayoutRect absoluteOverflowRect = absolute->localOverflowRectForPaintInvalid ation(); 513 LayoutRect absoluteOverflowRect = absolute->localOverflowRectForPaintInvalid ation();
514 EXPECT_EQ(LayoutRect(0, 0, 50, 50), absoluteOverflowRect); 514 EXPECT_EQ(LayoutRect(0, 0, 50, 50), absoluteOverflowRect);
515 LayoutRect rect = absoluteOverflowRect; 515 LayoutRect rect = absoluteOverflowRect;
516 EXPECT_TRUE(absolute->mapToVisualRectInAncestorSpace(stackingContext, rect)) ; 516 EXPECT_TRUE(absolute->mapToVisualRectInAncestorSpace(stackingContext, rect)) ;
517 // -172 = top(50) - y_offset_of_stacking_context(222) 517 // -172 = top(50) - y_offset_of_stacking_context(222)
518 EXPECT_EQ(LayoutRect(50, -172, 50, 50), rect); 518 EXPECT_EQ(LayoutRect(50, -172, 50, 50), rect);
519 checkPaintInvalidationStateRectMapping(rect, absoluteOverflowRect, *absolute , layoutView(), *stackingContext); 519 checkPaintInvalidationStateRectMapping(rect, absoluteOverflowRect, *absolute , layoutView(), *stackingContext);
520 } 520 }
521 521
522 } // namespace blink 522 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698