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

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

Issue 1950573003: Improve handling of PaintInvalidationLayer (renamed to PaintInvalidationSubtree) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@LocationChange
Patch Set: Created 4 years, 7 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
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 for (const LayoutObject* ancestor = &object; ancestor != layoutView; anc estor = ancestor->parentCrossingFrameBoundaries())
24 ancestors.append(ancestor); 24 ancestors.append(ancestor);
25 25
26 Vector<Optional<PaintInvalidationState>> paintInvalidationStates(ancesto rs.size() + 1); 26 Vector<Optional<PaintInvalidationState>> paintInvalidationStates(ancesto rs.size() + 1);
27 Vector<LayoutObject*> pendingDelayedPaintInvalidations; 27 Vector<LayoutObject*> pendingDelayedPaintInvalidations;
28 paintInvalidationStates[0].emplace(layoutView, pendingDelayedPaintInvali dations); 28 paintInvalidationStates[0].emplace(layoutView, pendingDelayedPaintInvali dations);
29 if (layoutView != object) 29 if (layoutView != object)
30 paintInvalidationStates[0]->updateForChildren(); 30 paintInvalidationStates[0]->updateForChildren(PaintInvalidationFull) ;
31 for (size_t i = 1; i < paintInvalidationStates.size(); ++i) { 31 for (size_t i = 1; i < paintInvalidationStates.size(); ++i) {
32 paintInvalidationStates[i].emplace(*paintInvalidationStates[i - 1], *ancestors[ancestors.size() - i]); 32 paintInvalidationStates[i].emplace(*paintInvalidationStates[i - 1], *ancestors[ancestors.size() - i]);
33 if (paintInvalidationStates[i]->m_currentObject != object) 33 if (paintInvalidationStates[i]->m_currentObject != object)
34 paintInvalidationStates[i]->updateForChildren(); 34 paintInvalidationStates[i]->updateForChildren(PaintInvalidationF ull);
35 } 35 }
36 36
37 const PaintInvalidationState& paintInvalidationState = *paintInvalidatio nStates.last(); 37 const PaintInvalidationState& paintInvalidationState = *paintInvalidatio nStates.last();
38 ASSERT_EQ(paintInvalidationState.m_currentObject, object); 38 ASSERT_EQ(paintInvalidationState.m_currentObject, object);
39 ASSERT_EQ(&paintInvalidationState.paintInvalidationContainer(), &paintIn validationContainer); 39 ASSERT_EQ(&paintInvalidationState.paintInvalidationContainer(), &paintIn validationContainer);
40 40
41 LayoutRect r = rect; 41 LayoutRect r = rect;
42 paintInvalidationState.mapLocalRectToPaintInvalidationContainer(r); 42 paintInvalidationState.mapLocalRectToPaintInvalidationContainer(r);
43 EXPECT_EQ(expectedRect, r); 43 EXPECT_EQ(expectedRect, r);
44 } 44 }
(...skipping 468 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