Commit 31f1804d authored by Xianzhu Wang's avatar Xianzhu Wang Committed by Commit Bot

[PE] Allow transient PaintController to abort without commit

This disables DCHECK(new_display_item_list_.IsEmpty()) for transient
paint controllers in the destructor. We could require the client of
a transient controller to always commit and finish cycle, but allowing
to abort seems simpler and harmless.

Bug: 904971
Change-Id: If1bd15b55cbad0e1871eaed4a8d30b78e8a54d86
Reviewed-on: https://chromium-review.googlesource.com/c/1336953Reviewed-by: default avatarChris Harrelson <chrishtr@chromium.org>
Commit-Queue: Xianzhu Wang <wangxianzhu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#608615}
parent 38d5b1de
......@@ -25,8 +25,9 @@ PaintController::PaintController(Usage usage)
}
PaintController::~PaintController() {
// New display items should be committed before PaintController is destroyed.
DCHECK(new_display_item_list_.IsEmpty());
// New display items should be committed before PaintController is destroyed,
// except for transient paint controllers.
DCHECK(usage_ == kTransient || new_display_item_list_.IsEmpty());
}
bool PaintController::UseCachedItemIfPossible(const DisplayItemClient& client,
......
......@@ -1556,6 +1556,17 @@ TEST_P(PaintControllerTest, InsertValidItemInFront) {
EXPECT_TRUE(fourth.IsValid());
}
TEST_P(PaintControllerTest, TransientPaintControllerIncompleteCycle) {
auto paint_controller = PaintController::Create(PaintController::kTransient);
GraphicsContext context(*paint_controller);
FakeDisplayItemClient client("client", LayoutRect(100, 100, 50, 50));
InitRootChunk(*paint_controller);
DrawRect(context, client, kBackgroundType, FloatRect(100, 100, 50, 50));
// The client of a transient paint controller can abort without
// CommintNewDisplayItems() and FinishCycle(). This should not crash.
paint_controller = nullptr;
}
// Death tests don't work properly on Android.
#if defined(GTEST_HAS_DEATH_TEST) && !defined(OS_ANDROID)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment