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

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

Issue 2639283003: Fix traverseNonCompositingDescendantsInPaintOrder for float-under-inline cases (Closed)
Patch Set: - Created 3 years, 11 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/paint/ObjectPaintInvalidator.h" 5 #include "core/paint/ObjectPaintInvalidator.h"
6 6
7 #include "core/layout/LayoutObject.h" 7 #include "core/layout/LayoutObject.h"
8 #include "core/layout/LayoutTestHelper.h" 8 #include "core/layout/LayoutTestHelper.h"
9 #include "core/paint/PaintLayer.h"
9 #include "platform/json/JSONValues.h" 10 #include "platform/json/JSONValues.h"
10 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
11 12
12 namespace blink { 13 namespace blink {
13 14
14 using ObjectPaintInvalidatorTest = RenderingTest; 15 using ObjectPaintInvalidatorTest = RenderingTest;
15 16
16 TEST_F(ObjectPaintInvalidatorTest, 17 TEST_F(ObjectPaintInvalidatorTest,
17 TraverseNonCompositingDescendantsInPaintOrder) { 18 TraverseNonCompositingDescendantsInPaintOrder) {
18 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) 19 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled())
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 EXPECT_EQ(getLayoutObjectByElementId("normal-child")->debugName(), s); 58 EXPECT_EQ(getLayoutObjectByElementId("normal-child")->debugName(), s);
58 JSONObject::cast(invalidations->at(2))->get("object")->asString(&s); 59 JSONObject::cast(invalidations->at(2))->get("object")->asString(&s);
59 EXPECT_EQ(getLayoutObjectByElementId("stacked-child")->debugName(), s); 60 EXPECT_EQ(getLayoutObjectByElementId("stacked-child")->debugName(), s);
60 JSONObject::cast(invalidations->at(3))->get("object")->asString(&s); 61 JSONObject::cast(invalidations->at(3))->get("object")->asString(&s);
61 EXPECT_EQ(getLayoutObjectByElementId( 62 EXPECT_EQ(getLayoutObjectByElementId(
62 "stacked-child-of-composited-non-stacking-context") 63 "stacked-child-of-composited-non-stacking-context")
63 ->debugName(), 64 ->debugName(),
64 s); 65 s);
65 } 66 }
66 67
68 TEST_F(ObjectPaintInvalidatorTest, TraverseFloatUnderCompositedInline) {
69 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled())
70 return;
71
72 enableCompositing();
73 setBodyInnerHTML(
74 "<div id='compositedContainer' style='position: relative;"
75 " will-change: transform'>"
76 " <div id='containingBlock' style='position: relative'>"
77 " <span id='span' style='position: relative; will-change: transform'>"
78 " <div id='target' style='float: right'></div>"
79 " </span>"
80 " </div>"
81 "</div>");
82
83 auto* target = getLayoutObjectByElementId("target");
84 auto* containingBlock = getLayoutObjectByElementId("containingBlock");
85 auto* containingBlockLayer = toLayoutBoxModelObject(containingBlock)->layer();
86 auto* compositedContainer = getLayoutObjectByElementId("compositedContainer");
87 auto* compositedContainerLayer =
88 toLayoutBoxModelObject(compositedContainer)->layer();
89 auto* span = getLayoutObjectByElementId("span");
90 auto* spanLayer = toLayoutBoxModelObject(span)->layer();
91
92 // Thought |target| is under |span| which is a composited stacking context,
93 // |span| is not the paint invalidation container of |target|.
94 EXPECT_TRUE(span->isPaintInvalidationContainer());
95 EXPECT_TRUE(span->styleRef().isStackingContext());
96 EXPECT_EQ(compositedContainer, &target->containerForPaintInvalidation());
97 EXPECT_EQ(containingBlockLayer, target->paintingLayer());
98
99 // Traversing from target should mark needsRepaint on correct layers.
100 EXPECT_FALSE(containingBlockLayer->needsRepaint());
101 EXPECT_FALSE(compositedContainerLayer->needsRepaint());
102 ObjectPaintInvalidator(*target)
103 .invalidateDisplayItemClientsIncludingNonCompositingDescendants(
104 PaintInvalidationSubtree);
105 EXPECT_TRUE(containingBlockLayer->needsRepaint());
106 EXPECT_TRUE(compositedContainerLayer->needsRepaint());
107 EXPECT_FALSE(spanLayer->needsRepaint());
108
109 document().view()->updateAllLifecyclePhases();
110
111 // Traversing from span should mark needsRepaint on correct layers for target.
112 EXPECT_FALSE(containingBlockLayer->needsRepaint());
113 EXPECT_FALSE(compositedContainerLayer->needsRepaint());
114 ObjectPaintInvalidator(*span)
115 .invalidateDisplayItemClientsIncludingNonCompositingDescendants(
116 PaintInvalidationSubtree);
117 EXPECT_TRUE(containingBlockLayer->needsRepaint());
118 EXPECT_TRUE(compositedContainerLayer->needsRepaint());
119 EXPECT_TRUE(spanLayer->needsRepaint());
120
121 document().view()->updateAllLifecyclePhases();
122
123 // Traversing from compositedContainer should reach target.
124 document().view()->setTracksPaintInvalidations(true);
125 EXPECT_FALSE(containingBlockLayer->needsRepaint());
126 EXPECT_FALSE(compositedContainerLayer->needsRepaint());
127 ObjectPaintInvalidator(*compositedContainer)
128 .invalidateDisplayItemClientsIncludingNonCompositingDescendants(
129 PaintInvalidationSubtree);
130 EXPECT_TRUE(containingBlockLayer->needsRepaint());
131 EXPECT_TRUE(compositedContainerLayer->needsRepaint());
132 EXPECT_FALSE(spanLayer->needsRepaint());
133
134 std::unique_ptr<JSONArray> invalidations =
135 document().view()->trackedObjectPaintInvalidationsAsJSON();
136 document().view()->setTracksPaintInvalidations(false);
137
138 ASSERT_EQ(4u, invalidations->size());
139 String s;
140 JSONObject::cast(invalidations->at(0))->get("object")->asString(&s);
141 EXPECT_EQ(compositedContainer->debugName(), s);
142 JSONObject::cast(invalidations->at(1))->get("object")->asString(&s);
143 EXPECT_EQ(containingBlock->debugName(), s);
144 JSONObject::cast(invalidations->at(2))->get("object")->asString(&s);
145 EXPECT_EQ(target->debugName(), s);
146 // This is the text node after the span.
147 JSONObject::cast(invalidations->at(3))->get("object")->asString(&s);
148 EXPECT_EQ("LayoutText #text", s);
149 }
150
151 TEST_F(ObjectPaintInvalidatorTest,
152 TraverseFloatUnderMultiLevelCompositedInlines) {
153 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled())
154 return;
155
156 enableCompositing();
157 setBodyInnerHTML(
158 "<div id='compositedContainer' style='position: relative;"
159 " will-change: transform'>"
160 " <div id='containingBlock' style='position: relative; z-index: 0'>"
161 " <span id='span' style='position: relative; will-change: transform'>"
162 " <span id='innerSpan'"
163 " style='position: relative; will-change: transform'>"
164 " <div id='target' style='float: right'></div>"
165 " </span>"
166 " </span>"
167 " </div>"
168 "</div>");
169
170 auto* target = getLayoutObjectByElementId("target");
171 auto* containingBlock = getLayoutObjectByElementId("containingBlock");
172 auto* containingBlockLayer = toLayoutBoxModelObject(containingBlock)->layer();
173 auto* compositedContainer = getLayoutObjectByElementId("compositedContainer");
174 auto* compositedContainerLayer =
175 toLayoutBoxModelObject(compositedContainer)->layer();
176 auto* span = getLayoutObjectByElementId("span");
177 auto* spanLayer = toLayoutBoxModelObject(span)->layer();
178 auto* innerSpan = getLayoutObjectByElementId("innerSpan");
179 auto* innerSpanLayer = toLayoutBoxModelObject(innerSpan)->layer();
180
181 EXPECT_TRUE(span->isPaintInvalidationContainer());
182 EXPECT_TRUE(span->styleRef().isStackingContext());
183 EXPECT_TRUE(innerSpan->isPaintInvalidationContainer());
184 EXPECT_TRUE(innerSpan->styleRef().isStackingContext());
185 EXPECT_EQ(compositedContainer, &target->containerForPaintInvalidation());
186 EXPECT_EQ(containingBlockLayer, target->paintingLayer());
187
188 // Traversing from compositedContainer should reach target.
189 document().view()->setTracksPaintInvalidations(true);
190 EXPECT_FALSE(containingBlockLayer->needsRepaint());
191 EXPECT_FALSE(compositedContainerLayer->needsRepaint());
192 ObjectPaintInvalidator(*compositedContainer)
193 .invalidateDisplayItemClientsIncludingNonCompositingDescendants(
194 PaintInvalidationSubtree);
195 EXPECT_TRUE(containingBlockLayer->needsRepaint());
196 EXPECT_TRUE(compositedContainerLayer->needsRepaint());
197 EXPECT_FALSE(spanLayer->needsRepaint());
198 EXPECT_FALSE(innerSpanLayer->needsRepaint());
199
200 std::unique_ptr<JSONArray> invalidations =
201 document().view()->trackedObjectPaintInvalidationsAsJSON();
202 document().view()->setTracksPaintInvalidations(false);
203
204 ASSERT_EQ(4u, invalidations->size());
205 String s;
206 JSONObject::cast(invalidations->at(0))->get("object")->asString(&s);
207 EXPECT_EQ(compositedContainer->debugName(), s);
208 JSONObject::cast(invalidations->at(1))->get("object")->asString(&s);
209 EXPECT_EQ(containingBlock->debugName(), s);
210 JSONObject::cast(invalidations->at(2))->get("object")->asString(&s);
211 EXPECT_EQ(target->debugName(), s);
212 // This is the text node after the span.
213 JSONObject::cast(invalidations->at(3))->get("object")->asString(&s);
214 EXPECT_EQ("LayoutText #text", s);
215 }
216
217 TEST_F(ObjectPaintInvalidatorTest, TraverseStackedFloatUnderCompositedInline) {
218 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled())
219 return;
220
221 enableCompositing();
222 setBodyInnerHTML(
223 "<span id='span' style='position: relative; will-change: transform'>"
224 " <div id='target' style='position: relative; float: right'></div>"
225 "</span>");
226
227 auto* target = getLayoutObjectByElementId("target");
228 auto* targetLayer = toLayoutBoxModelObject(target)->layer();
229 auto* span = getLayoutObjectByElementId("span");
230 auto* spanLayer = toLayoutBoxModelObject(span)->layer();
231
232 EXPECT_TRUE(span->isPaintInvalidationContainer());
233 EXPECT_TRUE(span->styleRef().isStackingContext());
234 EXPECT_EQ(span, &target->containerForPaintInvalidation());
235 EXPECT_EQ(targetLayer, target->paintingLayer());
236
237 // Traversing from span should reach target.
238 document().view()->setTracksPaintInvalidations(true);
239 EXPECT_FALSE(spanLayer->needsRepaint());
240 ObjectPaintInvalidator(*span)
241 .invalidateDisplayItemClientsIncludingNonCompositingDescendants(
242 PaintInvalidationSubtree);
243 EXPECT_TRUE(spanLayer->needsRepaint());
244
245 std::unique_ptr<JSONArray> invalidations =
246 document().view()->trackedObjectPaintInvalidationsAsJSON();
247 document().view()->setTracksPaintInvalidations(false);
248
249 ASSERT_EQ(3u, invalidations->size());
250 String s;
251 JSONObject::cast(invalidations->at(0))->get("object")->asString(&s);
252 EXPECT_EQ(span->debugName(), s);
253 JSONObject::cast(invalidations->at(1))->get("object")->asString(&s);
254 EXPECT_EQ("LayoutText #text", s);
255 JSONObject::cast(invalidations->at(2))->get("object")->asString(&s);
256 EXPECT_EQ(target->debugName(), s);
257 }
258
67 } // namespace blink 259 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698