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

Side by Side Diff: third_party/WebKit/Source/core/paint/PaintInvalidationTest.cpp

Issue 2791933003: setMayNeedPaintInvalidation in setNeedsOverflowRecalcAfterStyleChange() (Closed)
Patch Set: - Created 3 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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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/frame/FrameView.h" 5 #include "core/frame/FrameView.h"
6 #include "core/layout/LayoutTestHelper.h" 6 #include "core/layout/LayoutTestHelper.h"
7 #include "core/layout/LayoutView.h" 7 #include "core/layout/LayoutView.h"
8 #include "core/paint/PaintLayer.h"
8 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h" 9 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h"
9 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
10 11
11 namespace blink { 12 namespace blink {
12 13
13 namespace { 14 namespace {
14 15
15 class PaintInvalidationTest : public ::testing::WithParamInterface<bool>, 16 class PaintInvalidationTest : public ::testing::WithParamInterface<bool>,
16 private ScopedRootLayerScrollingForTest, 17 private ScopedRootLayerScrollingForTest,
17 public RenderingTest { 18 public RenderingTest {
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 &childLayoutView->containerForPaintInvalidation()); 77 &childLayoutView->containerForPaintInvalidation());
77 EXPECT_EQ(LayoutRect(10, 10, 100, 100), childLayoutView->visualRect()); 78 EXPECT_EQ(LayoutRect(10, 10, 100, 100), childLayoutView->visualRect());
78 79
79 iframe->setAttribute(HTMLNames::styleAttr, "border: 20px solid blue"); 80 iframe->setAttribute(HTMLNames::styleAttr, "border: 20px solid blue");
80 document().view()->updateAllLifecyclePhases(); 81 document().view()->updateAllLifecyclePhases();
81 EXPECT_EQ(document().layoutView(), 82 EXPECT_EQ(document().layoutView(),
82 &childLayoutView->containerForPaintInvalidation()); 83 &childLayoutView->containerForPaintInvalidation());
83 EXPECT_EQ(LayoutRect(30, 30, 100, 100), childLayoutView->visualRect()); 84 EXPECT_EQ(LayoutRect(30, 30, 100, 100), childLayoutView->visualRect());
84 }; 85 };
85 86
87 // This is a simplified test case for crbug.com/704182. It ensures no repaint
88 // on transform change causing no visual change.
89 TEST_P(PaintInvalidationTest, InvisibleTransformUnderFixedOnScroll) {
90 enableCompositing();
91 setBodyInnerHTML(
92 "<style>"
93 " #fixed {"
94 " position: fixed;"
95 " top: 0;"
96 " left: 0;"
97 " width: 100px;"
98 " height: 100px;"
99 " background-color: blue;"
100 " }"
101 " #transform {"
102 " width: 100px;"
103 " height: 100px;"
104 " background-color: yellow;"
105 " will-change: transform;"
106 " transform: translate(10px, 20px);"
107 " }"
108 "</style>"
109 "<div style='height: 2000px'></div>"
110 "<div id='fixed' style='visibility: hidden'>"
111 " <div id='transform'></div>"
112 "</div>");
113
114 auto& fixed = *document().getElementById("fixed");
115 const auto& fixedObject = toLayoutBox(*fixed.layoutObject());
116 const auto& fixedLayer = *fixedObject.layer();
117 auto& transform = *document().getElementById("transform");
118 EXPECT_TRUE(fixedLayer.subtreeIsInvisible());
119 EXPECT_EQ(LayoutRect(0, 0, 110, 120), fixedObject.layoutOverflowRect());
120
121 document().domWindow()->scrollTo(0, 100);
122 transform.setAttribute(HTMLNames::styleAttr,
123 "transform: translate(20px, 30px)");
124 document().view()->updateLifecycleToCompositingCleanPlusScrolling();
125
126 EXPECT_TRUE(fixedLayer.subtreeIsInvisible());
127 // We skip invisible layers when setting non-composited fixed-position
128 // needing paint invalidation when the frame is scrolled.
129 EXPECT_FALSE(fixedObject.shouldDoFullPaintInvalidation());
130 // This was set when fixedObject is marked needsOverflowRecaldAfterStyleChange
131 // when child changed transform.
132 EXPECT_TRUE(fixedObject.mayNeedPaintInvalidation());
133 EXPECT_EQ(LayoutRect(0, 0, 120, 130), fixedObject.layoutOverflowRect());
134
135 // We should not repaint anything because all contents are invisible.
136 document().view()->updateAllLifecyclePhasesExceptPaint();
137 EXPECT_FALSE(fixedLayer.needsRepaint());
138 document().view()->updateAllLifecyclePhases();
139
140 // The following ensures normal paint invalidation still works.
141 transform.setAttribute(
142 HTMLNames::styleAttr,
143 "visibility: visible; transform: translate(20px, 30px)");
144 document().view()->updateLifecycleToCompositingCleanPlusScrolling();
145 EXPECT_FALSE(fixedLayer.subtreeIsInvisible());
146 document().view()->updateAllLifecyclePhases();
147 fixed.setAttribute(HTMLNames::styleAttr, "top: 50px");
148 document().view()->updateLifecycleToCompositingCleanPlusScrolling();
149 EXPECT_TRUE(fixedObject.mayNeedPaintInvalidation());
150 EXPECT_FALSE(fixedLayer.subtreeIsInvisible());
151 document().view()->updateAllLifecyclePhasesExceptPaint();
152 EXPECT_TRUE(fixedLayer.needsRepaint());
153 document().view()->updateAllLifecyclePhases();
154 }
155
86 } // namespace 156 } // namespace
87 157
88 } // namespace blink 158 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutObject.cpp ('k') | third_party/WebKit/Source/core/paint/PaintInvalidator.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698