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

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

Issue 2639283003: Fix traverseNonCompositingDescendantsInPaintOrder for float-under-inline cases (Closed)
Patch Set: Fix 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; z-index: 0'>"
77 " <div style='backface-visibility: hidden'></div>"
78 " <span id='span'"
79 " style='clip-path: polygon(0px 15px, 0px 54px, 100px 0px)'>"
80 " <div id='target' style='float: right'></div>"
81 " </span>"
82 " </div>"
83 "</div>");
84
85 auto* target = getLayoutObjectByElementId("target");
86 auto* containingBlock = getLayoutObjectByElementId("containingBlock");
87 auto* containingBlockLayer = toLayoutBoxModelObject(containingBlock)->layer();
88 auto* compositedContainer = getLayoutObjectByElementId("compositedContainer");
89 auto* compositedContainerLayer =
90 toLayoutBoxModelObject(compositedContainer)->layer();
91 auto* span = getLayoutObjectByElementId("span");
92
93 // Thought |target| is under |span| which is a composited stacking context,
94 // |span| is not the paint invalidation container of |target|.
95 EXPECT_TRUE(span->isPaintInvalidationContainer());
96 EXPECT_TRUE(span->styleRef().isStackingContext());
97 EXPECT_EQ(compositedContainer, &target->containerForPaintInvalidation());
98 EXPECT_EQ(containingBlockLayer, target->paintingLayer());
99
100 // Traversing from target should mark needsRepaint on correct layers.
101 EXPECT_FALSE(containingBlockLayer->needsRepaint());
102 EXPECT_FALSE(compositedContainerLayer->needsRepaint());
103 ObjectPaintInvalidator(*target)
104 .invalidateDisplayItemClientsIncludingNonCompositingDescendants(
105 PaintInvalidationSubtree);
106 EXPECT_TRUE(containingBlockLayer->needsRepaint());
107 EXPECT_TRUE(compositedContainerLayer->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
120 document().view()->updateAllLifecyclePhases();
121
122 // Traversing from compositedContainer should reach target.
123 document().view()->setTracksPaintInvalidations(true);
124 EXPECT_FALSE(containingBlockLayer->needsRepaint());
125 EXPECT_FALSE(compositedContainerLayer->needsRepaint());
126 ObjectPaintInvalidator(*compositedContainer)
127 .invalidateDisplayItemClientsIncludingNonCompositingDescendants(
128 PaintInvalidationSubtree);
129 EXPECT_TRUE(containingBlockLayer->needsRepaint());
130 EXPECT_TRUE(compositedContainerLayer->needsRepaint());
131
132 std::unique_ptr<JSONArray> invalidations =
133 document().view()->trackedObjectPaintInvalidationsAsJSON();
134 document().view()->setTracksPaintInvalidations(false);
135
136 ASSERT_EQ(5u, invalidations->size());
137 String s;
138 JSONObject::cast(invalidations->at(0))->get("object")->asString(&s);
139 EXPECT_EQ(compositedContainer->debugName(), s);
140 JSONObject::cast(invalidations->at(1))->get("object")->asString(&s);
141 EXPECT_EQ(containingBlock->debugName(), s);
142 // This is the anonymous block enclosing the span.
143 JSONObject::cast(invalidations->at(2))->get("object")->asString(&s);
144 EXPECT_EQ("LayoutBlockFlow (anonymous)", s);
145 JSONObject::cast(invalidations->at(3))->get("object")->asString(&s);
146 EXPECT_EQ(target->debugName(), s);
147 // This is the text node after the span.
148 JSONObject::cast(invalidations->at(4))->get("object")->asString(&s);
149 EXPECT_EQ("LayoutText #text", s);
150 }
151
152 TEST_F(ObjectPaintInvalidatorTest,
153 TraverseFloatUnderMultiLevelCompositedInlines) {
154 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled())
155 return;
156
157 enableCompositing();
158 setBodyInnerHTML(
159 "<div id='compositedContainer' style='position: relative;"
160 " will-change: transform'>"
161 " <div id='containingBlock' style='position: relative; z-index: 0'>"
162 " <div style='backface-visibility: hidden'></div>"
163 " <span id='span'"
164 " style='clip-path: polygon(0px 15px, 0px 54px, 100px 0px)'>"
165 " <div style='display: inline-block'>"
166 " <div style='backface-visibility: hidden'></div>"
167 " <span id='innerSpan'"
168 " style='clip-path: polygon(0px 15px, 0px 54px, 100px 0px)'>"
169 " <div id='target' style='float: right'></div>"
170 " </span>"
171 " </div>"
172 " </span>"
173 " </div>"
174 "</div>");
175
176 auto* target = getLayoutObjectByElementId("target");
177 auto* containingBlock = getLayoutObjectByElementId("containingBlock");
178 auto* containingBlockLayer = toLayoutBoxModelObject(containingBlock)->layer();
179 auto* compositedContainer = getLayoutObjectByElementId("compositedContainer");
180 auto* compositedContainerLayer =
181 toLayoutBoxModelObject(compositedContainer)->layer();
182 auto* span = getLayoutObjectByElementId("span");
183 auto* innerSpan = getLayoutObjectByElementId("innerSpan");
184
185 EXPECT_TRUE(span->isPaintInvalidationContainer());
186 EXPECT_TRUE(span->styleRef().isStackingContext());
187 EXPECT_TRUE(innerSpan->isPaintInvalidationContainer());
188 EXPECT_TRUE(innerSpan->styleRef().isStackingContext());
189
190 // Traversing from compositedContainer should reach target.
191 document().view()->setTracksPaintInvalidations(true);
192 EXPECT_FALSE(containingBlockLayer->needsRepaint());
193 EXPECT_FALSE(compositedContainerLayer->needsRepaint());
194 ObjectPaintInvalidator(*compositedContainer)
195 .invalidateDisplayItemClientsIncludingNonCompositingDescendants(
196 PaintInvalidationSubtree);
197 EXPECT_TRUE(containingBlockLayer->needsRepaint());
198 EXPECT_TRUE(compositedContainerLayer->needsRepaint());
199
200 std::unique_ptr<JSONArray> invalidations =
201 document().view()->trackedObjectPaintInvalidationsAsJSON();
202 document().view()->setTracksPaintInvalidations(false);
203
204 ASSERT_EQ(6u, 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 // This is the anonymous block enclosing the span.
211 JSONObject::cast(invalidations->at(2))->get("object")->asString(&s);
212 EXPECT_EQ("LayoutBlockFlow (anonymous)", s);
213 JSONObject::cast(invalidations->at(3))->get("object")->asString(&s);
214 EXPECT_EQ("RootInlineBox", s);
215 JSONObject::cast(invalidations->at(4))->get("object")->asString(&s);
216 EXPECT_EQ(target->debugName(), s);
217 // This is the text node after the span.
218 JSONObject::cast(invalidations->at(5))->get("object")->asString(&s);
219 EXPECT_EQ("LayoutText #text", s);
220 }
221
67 } // namespace blink 222 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698