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

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

Issue 2000053002: WIP: Reset paint invalidation at transform boundaries. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
« no previous file with comments | « third_party/WebKit/Source/core/layout/PaintInvalidationState.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
11 namespace blink { 11 namespace blink {
12 12
13 class VisualRectMappingTest : public RenderingTest { 13 class VisualRectMappingTest : public RenderingTest {
14 public: 14 public:
15 VisualRectMappingTest() 15 VisualRectMappingTest()
16 : RenderingTest(SingleChildFrameLoaderClient::create()) {} 16 : RenderingTest(SingleChildFrameLoaderClient::create()) {}
17 protected: 17 protected:
18 LayoutView& layoutView() const { return *document().layoutView(); } 18 LayoutView& layoutView() const { return *document().layoutView(); }
19 19
20 void checkPaintInvalidationStateRectMapping(const LayoutRect& expectedRect, const LayoutRect& rect, const LayoutObject& object, const LayoutView& layoutView , const LayoutObject& paintInvalidationContainer) 20 void checkPaintInvalidationStateRectMapping(const LayoutRect& expectedRect, const LayoutRect& rect, const LayoutObject& object, const LayoutView& layoutView , const LayoutObject& paintInvalidationContainer)
21 { 21 {
22 Vector<const LayoutObject*> ancestors; 22 Vector<const LayoutObject*> ancestors;
23 for (const LayoutObject* ancestor = &object; ancestor != layoutView; anc estor = ancestor->parentCrossingFrameBoundaries()) 23 LOG(ERROR) << "checkPaintInvalidationStateRectMapping";
24 for (const LayoutObject* ancestor = &object; ancestor != layoutView; anc estor = ancestor->parentCrossingFrameBoundaries()) {
24 ancestors.append(ancestor); 25 ancestors.append(ancestor);
26 // ancestor->showLayoutObject();
27 }
25 28
26 Vector<Optional<PaintInvalidationState>> paintInvalidationStates(ancesto rs.size() + 1); 29 Vector<Optional<PaintInvalidationState>> paintInvalidationStates(ancesto rs.size() + 1);
27 Vector<LayoutObject*> pendingDelayedPaintInvalidations; 30 Vector<LayoutObject*> pendingDelayedPaintInvalidations;
28 paintInvalidationStates[0].emplace(layoutView, pendingDelayedPaintInvali dations); 31 paintInvalidationStates[0].emplace(layoutView, pendingDelayedPaintInvali dations);
29 if (layoutView != object) 32 if (layoutView != object)
30 paintInvalidationStates[0]->updateForChildren(PaintInvalidationFull) ; 33 paintInvalidationStates[0]->updateForChildren(PaintInvalidationFull) ;
31 for (size_t i = 1; i < paintInvalidationStates.size(); ++i) { 34 for (size_t i = 1; i < paintInvalidationStates.size(); ++i) {
32 paintInvalidationStates[i].emplace(*paintInvalidationStates[i - 1], *ancestors[ancestors.size() - i]); 35 paintInvalidationStates[i].emplace(*paintInvalidationStates[i - 1], *ancestors[ancestors.size() - i]);
33 if (paintInvalidationStates[i]->m_currentObject != object) 36 if (paintInvalidationStates[i]->m_currentObject != object)
34 paintInvalidationStates[i]->updateForChildren(PaintInvalidationF ull); 37 paintInvalidationStates[i]->updateForChildren(PaintInvalidationF ull);
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 EXPECT_EQ(LayoutRect(0, 0, 140, 110), rect); 443 EXPECT_EQ(LayoutRect(0, 0, 140, 110), rect);
441 444
442 rect = targetOverflowRect; 445 rect = targetOverflowRect;
443 EXPECT_TRUE(target->mapToVisualRectInAncestorSpace(container, rect)); 446 EXPECT_TRUE(target->mapToVisualRectInAncestorSpace(container, rect));
444 // -2 = target_physical_x(100) + container_border_left(40) - scroll_left(142 ) 447 // -2 = target_physical_x(100) + container_border_left(40) - scroll_left(142 )
445 // 3 = target_y(0) + container_border_top(10) - scroll_top(7) 448 // 3 = target_y(0) + container_border_top(10) - scroll_top(7)
446 // Rect is not clipped by container's overflow clip. 449 // Rect is not clipped by container's overflow clip.
447 EXPECT_EQ(LayoutRect(-2, 3, 140, 110), rect); 450 EXPECT_EQ(LayoutRect(-2, 3, 140, 110), rect);
448 } 451 }
449 452
450 TEST_F(VisualRectMappingTest, DifferentPaintInvalidaitionContainerForAbsolutePos ition) 453 TEST_F(VisualRectMappingTest, DifferentPaintInvalidationContainerForAbsolutePosi tion)
451 { 454 {
452 enableCompositing(); 455 enableCompositing();
453 document().frame()->settings()->setPreferCompositingToLCDTextEnabled(true); 456 document().frame()->settings()->setPreferCompositingToLCDTextEnabled(true);
454 457
455 setBodyInnerHTML( 458 setBodyInnerHTML(
456 "<div id='stacking-context' style='opacity: 0.9; background: blue; will- change: transform'>" 459 "<div id='stacking-context' style='opacity: 0.9; background: blue; will- change: transform'>"
457 " <div id='scroller' style='overflow: scroll; width: 80px; height: 80 px'>" 460 " <div id='scroller' style='overflow: scroll; width: 80px; height: 80 px'>"
458 " <div id='absolute' style='position: absolute; top: 111px; left: 222px; width: 50px; height: 50px; background: green'></div>" 461 " <div id='absolute' style='position: absolute; top: 111px; left: 222px; width: 50px; height: 50px; background: green'></div>"
459 " <div id='normal-flow' style='width: 2000px; height: 2000px; bac kground: yellow'></div>" 462 " <div id='normal-flow' style='width: 2000px; height: 2000px; bac kground: yellow'></div>"
460 " </div>" 463 " </div>"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 515
513 LayoutRect absoluteOverflowRect = absolute->localOverflowRectForPaintInvalid ation(); 516 LayoutRect absoluteOverflowRect = absolute->localOverflowRectForPaintInvalid ation();
514 EXPECT_EQ(LayoutRect(0, 0, 50, 50), absoluteOverflowRect); 517 EXPECT_EQ(LayoutRect(0, 0, 50, 50), absoluteOverflowRect);
515 LayoutRect rect = absoluteOverflowRect; 518 LayoutRect rect = absoluteOverflowRect;
516 EXPECT_TRUE(absolute->mapToVisualRectInAncestorSpace(stackingContext, rect)) ; 519 EXPECT_TRUE(absolute->mapToVisualRectInAncestorSpace(stackingContext, rect)) ;
517 // -172 = top(50) - y_offset_of_stacking_context(222) 520 // -172 = top(50) - y_offset_of_stacking_context(222)
518 EXPECT_EQ(LayoutRect(50, -172, 50, 50), rect); 521 EXPECT_EQ(LayoutRect(50, -172, 50, 50), rect);
519 checkPaintInvalidationStateRectMapping(rect, absoluteOverflowRect, *absolute , layoutView(), *stackingContext); 522 checkPaintInvalidationStateRectMapping(rect, absoluteOverflowRect, *absolute , layoutView(), *stackingContext);
520 } 523 }
521 524
525 TEST_F(VisualRectMappingTest, Transform2D)
526 {
527 enableCompositing();
528 document().frame()->settings()->setPreferCompositingToLCDTextEnabled(true);
529 setBodyInnerHTML(
530 "<div id='target' style='transform: translate(200px, 200px) rotatez(45de g); width: 200px; height: 200px; background: lightgray'>"
531 "</div>");
532
533 LayoutBlock* target = toLayoutBlock(getLayoutObjectByElementId("target"));
534 LayoutRect rect(target->frameRect());
535 EXPECT_TRUE(target->mapToVisualRectInAncestorSpace(&layoutView(), rect));
536 checkPaintInvalidationStateRectMapping(rect, target->frameRect(), *target, l ayoutView(), layoutView());
537 }
538
539 TEST_F(VisualRectMappingTest, Transform2DChild)
540 {
541 enableCompositing();
542 document().frame()->settings()->setPreferCompositingToLCDTextEnabled(true);
543 setBodyInnerHTML(
544 "<div style='transform: translate(200px, 200px) rotatez(45deg); width: 2 00px; height: 200px; background: lightgray'>"
545 " <div id='target' style='width: 50px; height: 50px; position: relative ; top: 25px; left: 25px'></div>"
546 "</div>");
547
548 LayoutBlock* target = toLayoutBlock(getLayoutObjectByElementId("target"));
549 LayoutRect rect(target->frameRect());
550 EXPECT_TRUE(target->mapToVisualRectInAncestorSpace(&layoutView(), rect));
551
552 checkPaintInvalidationStateRectMapping(rect, target->frameRect(), *target, l ayoutView(), layoutView());
553 }
522 } // namespace blink 554 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/PaintInvalidationState.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698