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

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

Issue 2575663002: RootLayerScrolling: Fix PaintControllerPaintTestForSlimmingPaintV2 (Closed)
Patch Set: rebase Created 4 years 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/paint/PaintControllerPaintTest.h ('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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/PaintControllerPaintTest.h" 5 #include "core/paint/PaintControllerPaintTest.h"
6 6
7 #include "core/editing/FrameCaret.h" 7 #include "core/editing/FrameCaret.h"
8 #include "core/editing/FrameSelection.h" 8 #include "core/editing/FrameSelection.h"
9 #include "core/layout/LayoutText.h" 9 #include "core/layout/LayoutText.h"
10 #include "core/layout/line/InlineTextBox.h" 10 #include "core/layout/line/InlineTextBox.h"
11 #include "core/page/FocusController.h" 11 #include "core/page/FocusController.h"
12 #include "core/paint/LayoutObjectDrawingRecorder.h" 12 #include "core/paint/LayoutObjectDrawingRecorder.h"
13 #include "core/paint/ObjectPaintProperties.h" 13 #include "core/paint/ObjectPaintProperties.h"
14 #include "core/paint/PaintLayerPainter.h" 14 #include "core/paint/PaintLayerPainter.h"
15 #include "platform/graphics/GraphicsContext.h" 15 #include "platform/graphics/GraphicsContext.h"
16 #include "platform/graphics/paint/DrawingDisplayItem.h" 16 #include "platform/graphics/paint/DrawingDisplayItem.h"
17 17
18 namespace blink { 18 namespace blink {
19 19
20 INSTANTIATE_TEST_CASE_P(All, 20 INSTANTIATE_TEST_CASE_P(All,
21 PaintControllerPaintTestForSlimmingPaintV1AndV2, 21 PaintControllerPaintTestForSlimmingPaintV1AndV2,
22 ::testing::Bool()); 22 ::testing::Bool());
23 23
24 INSTANTIATE_TEST_CASE_P(All,
25 PaintControllerPaintTestForSlimmingPaintV2,
26 ::testing::Bool());
27
24 TEST_P(PaintControllerPaintTestForSlimmingPaintV1AndV2, 28 TEST_P(PaintControllerPaintTestForSlimmingPaintV1AndV2,
25 FullDocumentPaintingWithCaret) { 29 FullDocumentPaintingWithCaret) {
26 setBodyInnerHTML( 30 setBodyInnerHTML(
27 "<div id='div' contentEditable='true' style='outline:none'>XYZ</div>"); 31 "<div id='div' contentEditable='true' style='outline:none'>XYZ</div>");
28 document().page()->focusController().setActive(true); 32 document().page()->focusController().setActive(true);
29 document().page()->focusController().setFocused(true); 33 document().page()->focusController().setFocused(true);
30 Element& div = *toElement(document().body()->firstChild()); 34 Element& div = *toElement(document().body()->firstChild());
31 InlineTextBox& textInlineBox = 35 InlineTextBox& textInlineBox =
32 *toLayoutText(div.firstChild()->layoutObject())->firstTextBox(); 36 *toLayoutText(div.firstChild()->layoutObject())->firstTextBox();
33 37
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 DisplayItem::kClipFrameToVisibleContentRect))); 168 DisplayItem::kClipFrameToVisibleContentRect)));
165 } 169 }
166 } else { 170 } else {
167 EXPECT_DISPLAY_LIST(rootPaintController().getDisplayItemList(), 3, 171 EXPECT_DISPLAY_LIST(rootPaintController().getDisplayItemList(), 3,
168 TestDisplayItem(layoutView(), documentBackgroundType), 172 TestDisplayItem(layoutView(), documentBackgroundType),
169 TestDisplayItem(newFirstTextBox, foregroundType), 173 TestDisplayItem(newFirstTextBox, foregroundType),
170 TestDisplayItem(secondTextBox, foregroundType)); 174 TestDisplayItem(secondTextBox, foregroundType));
171 } 175 }
172 } 176 }
173 177
174 TEST_F(PaintControllerPaintTestForSlimmingPaintV2, ChunkIdClientCacheFlag) { 178 TEST_P(PaintControllerPaintTestForSlimmingPaintV2, ChunkIdClientCacheFlag) {
175 setBodyInnerHTML( 179 setBodyInnerHTML(
176 "<div id='div' style='width: 200px; height: 200px; opacity: 0.5'>" 180 "<div id='div' style='width: 200px; height: 200px; opacity: 0.5'>"
177 " <div style='width: 100px; height: 100px; background-color: " 181 " <div style='width: 100px; height: 100px; background-color: "
178 "blue'></div>" 182 "blue'></div>"
179 " <div style='width: 100px; height: 100px; background-color: " 183 " <div style='width: 100px; height: 100px; background-color: "
180 "blue'></div>" 184 "blue'></div>"
181 "</div>"); 185 "</div>");
182 PaintLayer& htmlLayer = 186 PaintLayer& htmlLayer =
183 *toLayoutBoxModelObject(document().documentElement()->layoutObject()) 187 *toLayoutBoxModelObject(document().documentElement()->layoutObject())
184 ->layer(); 188 ->layer();
185 LayoutBlock& div = *toLayoutBlock(getLayoutObjectByElementId("div")); 189 LayoutBlock& div = *toLayoutBlock(getLayoutObjectByElementId("div"));
186 LayoutObject& subDiv = *div.firstChild(); 190 LayoutObject& subDiv = *div.firstChild();
187 LayoutObject& subDiv2 = *subDiv.nextSibling(); 191 LayoutObject& subDiv2 = *subDiv.nextSibling();
188 EXPECT_DISPLAY_LIST( 192 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) {
189 rootPaintController().getDisplayItemList(), 11, 193 EXPECT_DISPLAY_LIST(
190 TestDisplayItem(layoutView(), 194 rootPaintController().getDisplayItemList(), 9,
191 DisplayItem::kClipFrameToVisibleContentRect), 195 TestDisplayItem(*layoutView().layer(), DisplayItem::kSubsequence),
192 TestDisplayItem(*layoutView().layer(), DisplayItem::kSubsequence), 196 TestDisplayItem(layoutView(), documentBackgroundType),
193 TestDisplayItem(layoutView(), documentBackgroundType), 197 TestDisplayItem(htmlLayer, DisplayItem::kSubsequence),
194 TestDisplayItem(htmlLayer, DisplayItem::kSubsequence), 198 TestDisplayItem(div, DisplayItem::kBeginCompositing),
195 TestDisplayItem(div, DisplayItem::kBeginCompositing), 199 TestDisplayItem(subDiv, backgroundType),
196 TestDisplayItem(subDiv, backgroundType), 200 TestDisplayItem(subDiv2, backgroundType),
197 TestDisplayItem(subDiv2, backgroundType), 201 TestDisplayItem(div, DisplayItem::kEndCompositing),
198 TestDisplayItem(div, DisplayItem::kEndCompositing), 202 TestDisplayItem(htmlLayer, DisplayItem::kEndSubsequence),
199 TestDisplayItem(htmlLayer, DisplayItem::kEndSubsequence), 203 TestDisplayItem(*layoutView().layer(), DisplayItem::kEndSubsequence));
200 TestDisplayItem(*layoutView().layer(), DisplayItem::kEndSubsequence), 204 } else {
201 TestDisplayItem(layoutView(), 205 EXPECT_DISPLAY_LIST(
202 DisplayItem::clipTypeToEndClipType( 206 rootPaintController().getDisplayItemList(), 11,
203 DisplayItem::kClipFrameToVisibleContentRect))); 207 TestDisplayItem(layoutView(),
208 DisplayItem::kClipFrameToVisibleContentRect),
209 TestDisplayItem(*layoutView().layer(), DisplayItem::kSubsequence),
210 TestDisplayItem(layoutView(), documentBackgroundType),
211 TestDisplayItem(htmlLayer, DisplayItem::kSubsequence),
212 TestDisplayItem(div, DisplayItem::kBeginCompositing),
213 TestDisplayItem(subDiv, backgroundType),
214 TestDisplayItem(subDiv2, backgroundType),
215 TestDisplayItem(div, DisplayItem::kEndCompositing),
216 TestDisplayItem(htmlLayer, DisplayItem::kEndSubsequence),
217 TestDisplayItem(*layoutView().layer(), DisplayItem::kEndSubsequence),
218 TestDisplayItem(layoutView(),
219 DisplayItem::clipTypeToEndClipType(
220 DisplayItem::kClipFrameToVisibleContentRect)));
221 }
204 222
205 const PaintChunk& backgroundChunk = rootPaintController().paintChunks()[0]; 223 const PaintChunk& backgroundChunk = rootPaintController().paintChunks()[0];
206 EXPECT_TRUE(backgroundChunk.properties.propertyTreeState.scroll()->isRoot()); 224 EXPECT_TRUE(backgroundChunk.properties.propertyTreeState.scroll()->isRoot());
207 225
208 const EffectPaintPropertyNode* effectNode = div.paintProperties()->effect(); 226 const EffectPaintPropertyNode* effectNode = div.paintProperties()->effect();
209 EXPECT_EQ(0.5f, effectNode->opacity()); 227 EXPECT_EQ(0.5f, effectNode->opacity());
210 const PaintChunk& chunk = rootPaintController().paintChunks()[1]; 228
229 // When RLS is enabled, an additional paint chunk will be created for the
230 // LayoutView's layer.
231 unsigned divChunkIndex =
232 RuntimeEnabledFeatures::rootLayerScrollingEnabled() ? 2 : 1;
233 const PaintChunk& chunk = rootPaintController().paintChunks()[divChunkIndex];
211 EXPECT_EQ(*div.layer(), chunk.id->client); 234 EXPECT_EQ(*div.layer(), chunk.id->client);
212 EXPECT_EQ(effectNode, chunk.properties.propertyTreeState.effect()); 235 EXPECT_EQ(effectNode, chunk.properties.propertyTreeState.effect());
213 236
214 EXPECT_FALSE(div.layer()->isJustCreated()); 237 EXPECT_FALSE(div.layer()->isJustCreated());
215 // Client used by only paint chunks and non-cachaeable display items but not 238 // Client used by only paint chunks and non-cachaeable display items but not
216 // by any cacheable display items won't be marked as validly cached. 239 // by any cacheable display items won't be marked as validly cached.
217 EXPECT_FALSE(rootPaintController().clientCacheIsValid(*div.layer())); 240 EXPECT_FALSE(rootPaintController().clientCacheIsValid(*div.layer()));
218 EXPECT_FALSE(rootPaintController().clientCacheIsValid(div)); 241 EXPECT_FALSE(rootPaintController().clientCacheIsValid(div));
219 EXPECT_TRUE(rootPaintController().clientCacheIsValid(subDiv)); 242 EXPECT_TRUE(rootPaintController().clientCacheIsValid(subDiv));
220 } 243 }
221 244
222 TEST_F(PaintControllerPaintTestForSlimmingPaintV2, CompositingFold) { 245 TEST_P(PaintControllerPaintTestForSlimmingPaintV2, CompositingFold) {
223 setBodyInnerHTML( 246 setBodyInnerHTML(
224 "<div id='div' style='width: 200px; height: 200px; opacity: 0.5'>" 247 "<div id='div' style='width: 200px; height: 200px; opacity: 0.5'>"
225 " <div style='width: 100px; height: 100px; background-color: " 248 " <div style='width: 100px; height: 100px; background-color: "
226 "blue'></div>" 249 "blue'></div>"
227 "</div>"); 250 "</div>");
228 PaintLayer& htmlLayer = 251 PaintLayer& htmlLayer =
229 *toLayoutBoxModelObject(document().documentElement()->layoutObject()) 252 *toLayoutBoxModelObject(document().documentElement()->layoutObject())
230 ->layer(); 253 ->layer();
231 LayoutBlock& div = *toLayoutBlock(getLayoutObjectByElementId("div")); 254 LayoutBlock& div = *toLayoutBlock(getLayoutObjectByElementId("div"));
232 LayoutObject& subDiv = *div.firstChild(); 255 LayoutObject& subDiv = *div.firstChild();
233 256
234 EXPECT_DISPLAY_LIST( 257 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) {
235 rootPaintController().getDisplayItemList(), 8, 258 EXPECT_DISPLAY_LIST(
236 TestDisplayItem(layoutView(), 259 rootPaintController().getDisplayItemList(), 6,
237 DisplayItem::kClipFrameToVisibleContentRect), 260 TestDisplayItem(*layoutView().layer(), DisplayItem::kSubsequence),
238 TestDisplayItem(*layoutView().layer(), DisplayItem::kSubsequence), 261 TestDisplayItem(layoutView(), documentBackgroundType),
239 TestDisplayItem(layoutView(), documentBackgroundType), 262 TestDisplayItem(htmlLayer, DisplayItem::kSubsequence),
240 TestDisplayItem(htmlLayer, DisplayItem::kSubsequence), 263 // The begin and end compositing display items have been folded into
241 // The begin and end compositing display items have been folded into this 264 // this
242 // one. 265 // one.
243 TestDisplayItem(subDiv, backgroundType), 266 TestDisplayItem(subDiv, backgroundType),
244 TestDisplayItem(htmlLayer, DisplayItem::kEndSubsequence), 267 TestDisplayItem(htmlLayer, DisplayItem::kEndSubsequence),
245 TestDisplayItem(*layoutView().layer(), DisplayItem::kEndSubsequence), 268 TestDisplayItem(*layoutView().layer(), DisplayItem::kEndSubsequence));
246 TestDisplayItem(layoutView(), 269 } else {
247 DisplayItem::clipTypeToEndClipType( 270 EXPECT_DISPLAY_LIST(
248 DisplayItem::kClipFrameToVisibleContentRect))); 271 rootPaintController().getDisplayItemList(), 8,
272 TestDisplayItem(layoutView(),
273 DisplayItem::kClipFrameToVisibleContentRect),
274 TestDisplayItem(*layoutView().layer(), DisplayItem::kSubsequence),
275 TestDisplayItem(layoutView(), documentBackgroundType),
276 TestDisplayItem(htmlLayer, DisplayItem::kSubsequence),
277 // The begin and end compositing display items have been folded into
278 // this
279 // one.
280 TestDisplayItem(subDiv, backgroundType),
281 TestDisplayItem(htmlLayer, DisplayItem::kEndSubsequence),
282 TestDisplayItem(*layoutView().layer(), DisplayItem::kEndSubsequence),
283 TestDisplayItem(layoutView(),
284 DisplayItem::clipTypeToEndClipType(
285 DisplayItem::kClipFrameToVisibleContentRect)));
286 }
249 } 287 }
250 288
251 } // namespace blink 289 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/paint/PaintControllerPaintTest.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698