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

Side by Side Diff: Source/core/paint/ViewDisplayListTest.cpp

Issue 834173003: Change about caret painting in slimming paint mode (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Add tests Created 5 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/paint/BlockPainter.cpp ('k') | Source/core/rendering/PaintInfo.cpp » ('j') | 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 "config.h" 5 #include "config.h"
6 6
7 #include "core/paint/LayerClipRecorder.h" 7 #include "core/paint/LayerClipRecorder.h"
8 #include "core/paint/LayerPainter.h"
8 #include "core/paint/RenderDrawingRecorder.h" 9 #include "core/paint/RenderDrawingRecorder.h"
9 #include "core/rendering/RenderView.h" 10 #include "core/rendering/RenderView.h"
10 #include "core/rendering/RenderingTestHelper.h" 11 #include "core/rendering/RenderingTestHelper.h"
11 #include "core/rendering/compositing/RenderLayerCompositor.h" 12 #include "core/rendering/compositing/RenderLayerCompositor.h"
12 #include "platform/graphics/GraphicsContext.h" 13 #include "platform/graphics/GraphicsContext.h"
13 #include "platform/graphics/GraphicsLayer.h" 14 #include "platform/graphics/GraphicsLayer.h"
14 #include "platform/graphics/paint/DisplayItemList.h" 15 #include "platform/graphics/paint/DisplayItemList.h"
15 #include <gtest/gtest.h> 16 #include <gtest/gtest.h>
16 17
17 namespace blink { 18 namespace blink {
(...skipping 26 matching lines...) Expand all
44 public: 45 public:
45 TestDisplayItem(const RenderObject* renderer, Type type) : DisplayItem(rende rer->displayItemClient(), type) { } 46 TestDisplayItem(const RenderObject* renderer, Type type) : DisplayItem(rende rer->displayItemClient(), type) { }
46 47
47 virtual void replay(GraphicsContext*) override final { ASSERT_NOT_REACHED(); } 48 virtual void replay(GraphicsContext*) override final { ASSERT_NOT_REACHED(); }
48 virtual void appendToWebDisplayItemList(WebDisplayItemList*) const override final { ASSERT_NOT_REACHED(); } 49 virtual void appendToWebDisplayItemList(WebDisplayItemList*) const override final { ASSERT_NOT_REACHED(); }
49 #ifndef NDEBUG 50 #ifndef NDEBUG
50 virtual const char* name() const override final { return "Test"; } 51 virtual const char* name() const override final { return "Test"; }
51 #endif 52 #endif
52 }; 53 };
53 54
55 #ifndef NDEBUG
56 #define TRACE_DISPLAY_ITEMS(expected, actual) \
57 String trace = "Expected: " + (expected).asDebugString() + " Actual: " + (ac tual).asDebugString(); \
58 SCOPED_TRACE(trace.utf8().data());
59 #else
60 #define TRACE_DISPLAY_ITEMS(expected, actual)
61 #endif
62
54 #define EXPECT_DISPLAY_LIST(actual, expectedSize, ...) { \ 63 #define EXPECT_DISPLAY_LIST(actual, expectedSize, ...) { \
55 EXPECT_EQ((size_t)expectedSize, actual.size()); \ 64 EXPECT_EQ((size_t)expectedSize, actual.size()); \
56 const TestDisplayItem expected[] = { __VA_ARGS__ }; \ 65 const TestDisplayItem expected[] = { __VA_ARGS__ }; \
57 for (size_t index = 0; index < expectedSize; index++) { \ 66 for (size_t index = 0; index < expectedSize; index++) { \
67 TRACE_DISPLAY_ITEMS(expected[index], *actual[index]); \
58 EXPECT_EQ(expected[index].client(), actual[index]->client()); \ 68 EXPECT_EQ(expected[index].client(), actual[index]->client()); \
59 EXPECT_EQ(expected[index].type(), actual[index]->type()); \ 69 EXPECT_EQ(expected[index].type(), actual[index]->type()); \
60 } \ 70 } \
61 } 71 }
62 72
63 void drawRect(GraphicsContext* context, RenderObject* renderer, PaintPhase phase , const FloatRect& bound) 73 void drawRect(GraphicsContext* context, RenderObject* renderer, PaintPhase phase , const FloatRect& bound)
64 { 74 {
65 RenderDrawingRecorder drawingRecorder(context, *renderer, phase, bound); 75 RenderDrawingRecorder drawingRecorder(context, *renderer, phase, bound);
66 if (drawingRecorder.canUseCachedDrawing()) 76 if (drawingRecorder.canUseCachedDrawing())
67 return; 77 return;
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 // The second display item should be cached. 448 // The second display item should be cached.
439 EXPECT_EQ(secondDisplayItem, rootDisplayItemList().paintList()[1].get()); 449 EXPECT_EQ(secondDisplayItem, rootDisplayItemList().paintList()[1].get());
440 EXPECT_TRUE(rootDisplayItemList().clientCacheIsValid(firstRenderer->displayI temClient())); 450 EXPECT_TRUE(rootDisplayItemList().clientCacheIsValid(firstRenderer->displayI temClient()));
441 EXPECT_TRUE(rootDisplayItemList().clientCacheIsValid(secondRenderer->display ItemClient())); 451 EXPECT_TRUE(rootDisplayItemList().clientCacheIsValid(secondRenderer->display ItemClient()));
442 452
443 rootDisplayItemList().invalidateAll(); 453 rootDisplayItemList().invalidateAll();
444 EXPECT_FALSE(rootDisplayItemList().clientCacheIsValid(firstRenderer->display ItemClient())); 454 EXPECT_FALSE(rootDisplayItemList().clientCacheIsValid(firstRenderer->display ItemClient()));
445 EXPECT_FALSE(rootDisplayItemList().clientCacheIsValid(secondRenderer->displa yItemClient())); 455 EXPECT_FALSE(rootDisplayItemList().clientCacheIsValid(secondRenderer->displa yItemClient()));
446 } 456 }
447 457
458 TEST_F(ViewDisplayListTest, FullDocumentPaintingWithCaret)
459 {
460 setBodyInnerHTML("<div id='div' contentEditable='true'>XYZ</div>");
461 RenderView* renderView = document().renderView();
462 RenderLayer* rootLayer = renderView->layer();
463 RenderObject* htmlRenderer = document().documentElement()->renderer();
464 Element* div = toElement(document().body()->firstChild());
465 RenderObject* divRenderer = document().body()->firstChild()->renderer();
466 RenderObject* textRenderer = div->firstChild()->renderer();
467
468 SkCanvas canvas(800, 600);
469 GraphicsContext context(&canvas, &rootDisplayItemList());
470 LayerPaintingInfo paintingInfo(rootLayer, LayoutRect(0, 0, 800, 600), PaintB ehaviorNormal, LayoutSize());
471 LayerPainter(*rootLayer).paintLayerContents(&context, paintingInfo, PaintLay erPaintingCompositingAllPhases);
472
473 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 2,
474 TestDisplayItem(htmlRenderer, DisplayItem::DrawingPaintPhaseBlockBackgro und),
475 TestDisplayItem(textRenderer, DisplayItem::DrawingPaintPhaseForeground)) ;
476
477 div->focus();
478 document().view()->updateLayoutAndStyleForPainting();
479 LayerPainter(*rootLayer).paintLayerContents(&context, paintingInfo, PaintLay erPaintingCompositingAllPhases);
480
481 EXPECT_DISPLAY_LIST(rootDisplayItemList().paintList(), 3,
482 TestDisplayItem(htmlRenderer, DisplayItem::DrawingPaintPhaseBlockBackgro und),
483 TestDisplayItem(textRenderer, DisplayItem::DrawingPaintPhaseForeground),
484 TestDisplayItem(divRenderer, DisplayItem::DrawingPaintPhaseCaret));
485 }
486
448 } // anonymous namespace 487 } // anonymous namespace
449 } // namespace blink 488 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/paint/BlockPainter.cpp ('k') | Source/core/rendering/PaintInfo.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698