Commit 1fcd3374 authored by Lei Zhang's avatar Lei Zhang Committed by Commit Bot

PDF: Loading the print preview should ignore the first destination page.

When loading the print preview PDF for non-PDF content, the initial
request loads a single page of the print preview source as the first
page in the PDF. Subsequent pages are appended at page index 1 and
onwards. Before r487767, ProcessPreviewPageInfo(), which loads the
subsequent pages, checked the source page index and did not load if the
source page index is less than 1. In r487767, the check changes to make
sure the source page index is never negative, and to ignore loads when
the source page index is 0. But it turns out that was not 100% correct.
What it should have ignored is when the destination page index is 0.

e.g. Print preview a 2 page document, and only select page 2. Here, the
initial load loads source page index 1 as destination page index 0.
ProcessPreviewPageInfo() then gets a request to load source page index 1
as destination page index 0. This is redundant and should be ignored.

Though oftentimes, source page index 0 maps to destination page index 0,
so it just works out by luck.

Fixing this does not change the user observable behavior, but it does
make page load counting easier.

Change-Id: If6ad8f32f95e04fce86268c6015271978b201fc5
Reviewed-on: https://chromium-review.googlesource.com/580634Reviewed-by: default avatarRebekah Potter <rbpotter@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/master@{#488526}
parent 518e065e
......@@ -1416,7 +1416,7 @@ void OutOfProcessInstance::PreviewDocumentLoadComplete() {
preview_document_load_state_ = LOAD_STATE_COMPLETE;
int dest_page_index = preview_pages_info_.front().second;
DCHECK_GE(dest_page_index, 0);
DCHECK_GT(dest_page_index, 0);
DCHECK(preview_engine_);
engine_->AppendPage(preview_engine_.get(), dest_page_index);
......@@ -1624,17 +1624,18 @@ void OutOfProcessInstance::ProcessPreviewPageInfo(const std::string& url,
return;
}
// Print Preview JS will send the loadPreviewPage message for every page,
// including the first page in the print preview, which has already been
// loaded when handing the resetPrintPreviewMode message. Just ignore it.
if (dest_page_index == 0)
return;
int src_page_index = ExtractPrintPreviewPageIndex(url);
if (src_page_index < 0) {
NOTREACHED();
return;
}
// Print Preview JS will call loadPreviewPage() for every page, including
// page 0. Just ignore it.
if (src_page_index == 0)
return;
preview_pages_info_.push(std::make_pair(url, dest_page_index));
LoadAvailablePreviewPage();
}
......
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