OLD | NEW |
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 "config.h" | 5 #include "config.h" |
6 | 6 |
7 #include "core/layout/LayoutTestHelper.h" | 7 #include "core/layout/LayoutTestHelper.h" |
8 #include "core/layout/LayoutView.h" | 8 #include "core/layout/LayoutView.h" |
9 #include "core/layout/compositing/LayerCompositor.h" | 9 #include "core/layout/compositing/LayerCompositor.h" |
10 #include "core/layout/line/InlineTextBox.h" | 10 #include "core/layout/line/InlineTextBox.h" |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 { | 89 { |
90 RenderDrawingRecorder drawingRecorder(context, *renderer, phase, bound); | 90 RenderDrawingRecorder drawingRecorder(context, *renderer, phase, bound); |
91 if (drawingRecorder.canUseCachedDrawing()) | 91 if (drawingRecorder.canUseCachedDrawing()) |
92 return; | 92 return; |
93 IntRect rect(0, 0, 10, 10); | 93 IntRect rect(0, 0, 10, 10); |
94 context->drawRect(rect); | 94 context->drawRect(rect); |
95 } | 95 } |
96 | 96 |
97 void drawClippedRect(GraphicsContext* context, LayoutBoxModelObject* renderer, P
aintPhase phase, const FloatRect& bound) | 97 void drawClippedRect(GraphicsContext* context, LayoutBoxModelObject* renderer, P
aintPhase phase, const FloatRect& bound) |
98 { | 98 { |
99 IntRect rect(1, 1, 9, 9); | 99 LayoutRect rect(1, 1, 9, 9); |
100 ClipRect clipRect(rect); | 100 ClipRect clipRect(rect); |
101 LayerClipRecorder layerClipRecorder(renderer, context, DisplayItem::ClipLaye
rForeground, clipRect, 0, LayoutPoint(), PaintLayerFlags()); | 101 LayerClipRecorder layerClipRecorder(renderer, context, DisplayItem::ClipLaye
rForeground, clipRect, 0, LayoutPoint(), PaintLayerFlags()); |
102 drawRect(context, renderer, phase, bound); | 102 drawRect(context, renderer, phase, bound); |
103 } | 103 } |
104 | 104 |
105 TEST_F(ViewDisplayListTest, NestedRecorders) | 105 TEST_F(ViewDisplayListTest, NestedRecorders) |
106 { | 106 { |
107 GraphicsContext context(nullptr, &rootDisplayItemList()); | 107 GraphicsContext context(nullptr, &rootDisplayItemList()); |
108 FloatRect bound = layoutView()->viewRect(); | 108 FloatRect bound = layoutView()->viewRect(); |
109 | 109 |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseOu
tline))); | 334 TestDisplayItem(first, DisplayItem::paintPhaseToDrawingType(PaintPhaseOu
tline))); |
335 } | 335 } |
336 | 336 |
337 TEST_F(ViewDisplayListTest, UpdateClip) | 337 TEST_F(ViewDisplayListTest, UpdateClip) |
338 { | 338 { |
339 setBodyInnerHTML("<div id='first'><div id='second'></div></div>"); | 339 setBodyInnerHTML("<div id='first'><div id='second'></div></div>"); |
340 LayoutBoxModelObject* firstRenderer = toLayoutBoxModelObject(document().body
()->firstChild()->renderer()); | 340 LayoutBoxModelObject* firstRenderer = toLayoutBoxModelObject(document().body
()->firstChild()->renderer()); |
341 LayoutBoxModelObject* secondRenderer = toLayoutBoxModelObject(document().bod
y()->firstChild()->firstChild()->renderer()); | 341 LayoutBoxModelObject* secondRenderer = toLayoutBoxModelObject(document().bod
y()->firstChild()->firstChild()->renderer()); |
342 GraphicsContext context(nullptr, &rootDisplayItemList()); | 342 GraphicsContext context(nullptr, &rootDisplayItemList()); |
343 | 343 |
344 ClipRect firstClipRect(IntRect(1, 1, 2, 2)); | 344 ClipRect firstClipRect(LayoutRect(1, 1, 2, 2)); |
345 { | 345 { |
346 LayerClipRecorder layerClipRecorder(firstRenderer, &context, DisplayItem
::ClipLayerForeground, firstClipRect, 0, LayoutPoint(), PaintLayerFlags()); | 346 LayerClipRecorder layerClipRecorder(firstRenderer, &context, DisplayItem
::ClipLayerForeground, firstClipRect, 0, LayoutPoint(), PaintLayerFlags()); |
347 drawRect(&context, firstRenderer, PaintPhaseBlockBackground, FloatRect(1
00, 100, 150, 150)); | 347 drawRect(&context, firstRenderer, PaintPhaseBlockBackground, FloatRect(1
00, 100, 150, 150)); |
348 drawRect(&context, secondRenderer, PaintPhaseBlockBackground, FloatRect(
100, 100, 150, 150)); | 348 drawRect(&context, secondRenderer, PaintPhaseBlockBackground, FloatRect(
100, 100, 150, 150)); |
349 } | 349 } |
350 rootDisplayItemList().endNewPaints(); | 350 rootDisplayItemList().endNewPaints(); |
351 | 351 |
352 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 4, | 352 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 4, |
353 TestDisplayItem(firstRenderer, DisplayItem::ClipLayerForeground), | 353 TestDisplayItem(firstRenderer, DisplayItem::ClipLayerForeground), |
354 TestDisplayItem(firstRenderer, DisplayItem::paintPhaseToDrawingType(Pain
tPhaseBlockBackground)), | 354 TestDisplayItem(firstRenderer, DisplayItem::paintPhaseToDrawingType(Pain
tPhaseBlockBackground)), |
355 TestDisplayItem(secondRenderer, DisplayItem::paintPhaseToDrawingType(Pai
ntPhaseBlockBackground)), | 355 TestDisplayItem(secondRenderer, DisplayItem::paintPhaseToDrawingType(Pai
ntPhaseBlockBackground)), |
356 TestDisplayItem(firstRenderer, DisplayItem::clipTypeToEndClipType(Displa
yItem::ClipLayerForeground))); | 356 TestDisplayItem(firstRenderer, DisplayItem::clipTypeToEndClipType(Displa
yItem::ClipLayerForeground))); |
357 | 357 |
358 rootDisplayItemList().invalidate(firstRenderer->displayItemClient()); | 358 rootDisplayItemList().invalidate(firstRenderer->displayItemClient()); |
359 drawRect(&context, firstRenderer, PaintPhaseBlockBackground, FloatRect(100,
100, 150, 150)); | 359 drawRect(&context, firstRenderer, PaintPhaseBlockBackground, FloatRect(100,
100, 150, 150)); |
360 drawRect(&context, secondRenderer, PaintPhaseBlockBackground, FloatRect(100,
100, 150, 150)); | 360 drawRect(&context, secondRenderer, PaintPhaseBlockBackground, FloatRect(100,
100, 150, 150)); |
361 rootDisplayItemList().endNewPaints(); | 361 rootDisplayItemList().endNewPaints(); |
362 | 362 |
363 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2, | 363 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2, |
364 TestDisplayItem(firstRenderer, DisplayItem::paintPhaseToDrawingType(Pain
tPhaseBlockBackground)), | 364 TestDisplayItem(firstRenderer, DisplayItem::paintPhaseToDrawingType(Pain
tPhaseBlockBackground)), |
365 TestDisplayItem(secondRenderer, DisplayItem::paintPhaseToDrawingType(Pai
ntPhaseBlockBackground))); | 365 TestDisplayItem(secondRenderer, DisplayItem::paintPhaseToDrawingType(Pai
ntPhaseBlockBackground))); |
366 | 366 |
367 rootDisplayItemList().invalidate(secondRenderer->displayItemClient()); | 367 rootDisplayItemList().invalidate(secondRenderer->displayItemClient()); |
368 drawRect(&context, firstRenderer, PaintPhaseBlockBackground, FloatRect(100,
100, 150, 150)); | 368 drawRect(&context, firstRenderer, PaintPhaseBlockBackground, FloatRect(100,
100, 150, 150)); |
369 ClipRect secondClipRect(IntRect(1, 1, 2, 2)); | 369 ClipRect secondClipRect(LayoutRect(1, 1, 2, 2)); |
370 { | 370 { |
371 LayerClipRecorder layerClipRecorder(secondRenderer, &context, DisplayIte
m::ClipLayerForeground, secondClipRect, 0, LayoutPoint(), PaintLayerFlags()); | 371 LayerClipRecorder layerClipRecorder(secondRenderer, &context, DisplayIte
m::ClipLayerForeground, secondClipRect, 0, LayoutPoint(), PaintLayerFlags()); |
372 drawRect(&context, secondRenderer, PaintPhaseBlockBackground, FloatRect(
100, 100, 150, 150)); | 372 drawRect(&context, secondRenderer, PaintPhaseBlockBackground, FloatRect(
100, 100, 150, 150)); |
373 } | 373 } |
374 rootDisplayItemList().endNewPaints(); | 374 rootDisplayItemList().endNewPaints(); |
375 | 375 |
376 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 4, | 376 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 4, |
377 TestDisplayItem(firstRenderer, DisplayItem::paintPhaseToDrawingType(Pain
tPhaseBlockBackground)), | 377 TestDisplayItem(firstRenderer, DisplayItem::paintPhaseToDrawingType(Pain
tPhaseBlockBackground)), |
378 TestDisplayItem(secondRenderer, DisplayItem::ClipLayerForeground), | 378 TestDisplayItem(secondRenderer, DisplayItem::ClipLayerForeground), |
379 TestDisplayItem(secondRenderer, DisplayItem::paintPhaseToDrawingType(Pai
ntPhaseBlockBackground)), | 379 TestDisplayItem(secondRenderer, DisplayItem::paintPhaseToDrawingType(Pai
ntPhaseBlockBackground)), |
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
751 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 4, | 751 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 4, |
752 TestDisplayItem(multicol, DisplayItem::paintPhaseToDrawingType(PaintPhas
eBlockBackground)), | 752 TestDisplayItem(multicol, DisplayItem::paintPhaseToDrawingType(PaintPhas
eBlockBackground)), |
753 TestDisplayItem(content, DisplayItem::paintPhaseToDrawingType(PaintPhase
Foreground)), | 753 TestDisplayItem(content, DisplayItem::paintPhaseToDrawingType(PaintPhase
Foreground)), |
754 TestDisplayItem(content, DisplayItem::paintPhaseToDrawingType(PaintPhase
Foreground)), | 754 TestDisplayItem(content, DisplayItem::paintPhaseToDrawingType(PaintPhase
Foreground)), |
755 TestDisplayItem(content, DisplayItem::paintPhaseToDrawingType(PaintPhase
Foreground))); | 755 TestDisplayItem(content, DisplayItem::paintPhaseToDrawingType(PaintPhase
Foreground))); |
756 EXPECT_NE(picture1, static_cast<DrawingDisplayItem*>(rootDisplayItemList().p
aintList()[1].get())->picture()); | 756 EXPECT_NE(picture1, static_cast<DrawingDisplayItem*>(rootDisplayItemList().p
aintList()[1].get())->picture()); |
757 EXPECT_NE(picture2, static_cast<DrawingDisplayItem*>(rootDisplayItemList().p
aintList()[2].get())->picture()); | 757 EXPECT_NE(picture2, static_cast<DrawingDisplayItem*>(rootDisplayItemList().p
aintList()[2].get())->picture()); |
758 } | 758 } |
759 | 759 |
760 } // namespace blink | 760 } // namespace blink |
OLD | NEW |