0

Speculative fix for RefreshCurrentDocumentLayout() crash

Attempts to fix RefreshCurrentDocumentLayout() crash by handling "no
pages" identically to other cases. Without this change, the number of
pages in the layout may differ from the number of pages in the engine.

This fix is speculative because we currently don't understand how the
page count is dropping to 0, although we have some theories about Print
Preview that we're investigating.

Bug: 1264542
Change-Id: I7192589d8f2f3c8855275809ec35689217766201
Cq-Do-Not-Cancel-Tryjobs: true
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3255868
Commit-Queue: K. Moon <kmoon@chromium.org>
Auto-Submit: K. Moon <kmoon@chromium.org>
Reviewed-by: Hui Yingst <nigi@chromium.org>
Cr-Commit-Position: refs/heads/main@{#937112}
This commit is contained in:
K. Moon
2021-11-01 23:34:55 +00:00
committed by Chromium LUCI CQ
parent 28edddf1b2
commit c582560c3f
2 changed files with 15 additions and 5 deletions

@ -282,6 +282,13 @@ TEST_F(DocumentLayoutTest, ComputeLayoutOneUp) {
EXPECT_EQ(gfx::Size(320, 2231), layout_.size());
}
TEST_F(DocumentLayoutTest, ComputeLayoutOneUpWithNoPages) {
SetPageSpread(DocumentLayout::PageSpread::kOneUp);
layout_.ComputeLayout({});
ASSERT_EQ(0u, layout_.page_count());
}
TEST_F(DocumentLayoutTest, DirtySetOnLayoutInputChangeOneUp) {
SetPageSpread(DocumentLayout::PageSpread::kOneUp);
@ -354,6 +361,13 @@ TEST_F(DocumentLayoutTest, ComputeLayoutTwoUpOdd) {
EXPECT_EQ(gfx::Size(800, 1300), layout_.size());
}
TEST_F(DocumentLayoutTest, ComputeLayoutTwoUpOddWithNoPages) {
SetPageSpread(DocumentLayout::PageSpread::kTwoUpOdd);
layout_.ComputeLayout({});
ASSERT_EQ(0u, layout_.page_count());
}
TEST_F(DocumentLayoutTest, DirtySetOnLayoutInputChangeTwoUpOdd) {
SetPageSpread(DocumentLayout::PageSpread::kTwoUpOdd);

@ -2832,11 +2832,7 @@ void PDFiumEngine::ProposeNextDocumentLayout() {
}
void PDFiumEngine::UpdateDocumentLayout(DocumentLayout* layout) {
std::vector<gfx::Size> page_sizes = LoadPageSizes(layout->options());
if (page_sizes.empty())
return;
layout->ComputeLayout(page_sizes);
layout->ComputeLayout(LoadPageSizes(layout->options()));
}
std::vector<gfx::Size> PDFiumEngine::LoadPageSizes(