Chromium Code Reviews| Index: pdf/pdfium/pdfium_engine.cc |
| diff --git a/pdf/pdfium/pdfium_engine.cc b/pdf/pdfium/pdfium_engine.cc |
| index 6859b01a6a3d36b1cc89848d53c87b6a62df9700..75f512a06d84254d0877c3d511280f030d1c856a 100644 |
| --- a/pdf/pdfium/pdfium_engine.cc |
| +++ b/pdf/pdfium/pdfium_engine.cc |
| @@ -2284,6 +2284,9 @@ int PDFiumEngine::GetNamedDestinationPage(const std::string& destination) { |
| } |
| int PDFiumEngine::GetMostVisiblePage() { |
| + if (in_flight_visible_page_) |
| + return *in_flight_visible_page_; |
| + |
| CalculateVisiblePages(); |
| return most_visible_page_; |
| } |
| @@ -2674,6 +2677,11 @@ bool PDFiumEngine::IsPageVisible(int index) const { |
| return base::ContainsValue(visible_pages_, index); |
| } |
| +void PDFiumEngine::ScrollToPage(int page) { |
| + in_flight_visible_page_ = page; |
| + client_->ScrollToPage(page); |
| +} |
| + |
| bool PDFiumEngine::CheckPageAvailable(int index, std::vector<int>* pending) { |
| if (!doc_ || !form_) |
| return false; |
| @@ -3180,6 +3188,11 @@ int PDFiumEngine::GetVisiblePageIndex(FPDF_PAGE page) { |
| } |
| void PDFiumEngine::SetCurrentPage(int index) { |
| + if (in_flight_visible_page_) { |
| + DCHECK(*in_flight_visible_page_ == index); |
|
Tom Sepez
2016/08/25 19:19:22
This dcheck may be too strong -- what if we get a
tonikitoo
2016/08/25 20:17:51
Done.
|
| + in_flight_visible_page_.reset(); |
| + } |
| + |
| if (index == most_visible_page_ || !form_) |
| return; |
| if (most_visible_page_ != -1 && called_do_document_action_) { |
| @@ -3513,13 +3526,13 @@ void PDFiumEngine::Form_ExecuteNamedAction(FPDF_FORMFILLINFO* param, |
| // Reader supports more, like FitWidth, but since they're not part of the spec |
| // and we haven't got bugs about them, no need to now. |
| if (action == "NextPage") { |
| - engine->client_->ScrollToPage(index + 1); |
| + engine->ScrollToPage(index + 1); |
| } else if (action == "PrevPage") { |
| - engine->client_->ScrollToPage(index - 1); |
| + engine->ScrollToPage(index - 1); |
| } else if (action == "FirstPage") { |
| - engine->client_->ScrollToPage(0); |
| + engine->ScrollToPage(0); |
| } else if (action == "LastPage") { |
| - engine->client_->ScrollToPage(engine->pages_.size() - 1); |
| + engine->ScrollToPage(engine->pages_.size() - 1); |
| } |
| } |
| @@ -3543,7 +3556,7 @@ void PDFiumEngine::Form_DoGoToAction(FPDF_FORMFILLINFO* param, |
| float* position_array, |
| int size_of_array) { |
| PDFiumEngine* engine = static_cast<PDFiumEngine*>(param); |
| - engine->client_->ScrollToPage(page_index); |
| + engine->ScrollToPage(page_index); |
| } |
| int PDFiumEngine::Form_Alert(IPDF_JSPLATFORM* param, |
| @@ -3672,7 +3685,7 @@ void PDFiumEngine::Form_SubmitForm(IPDF_JSPLATFORM* param, |
| void PDFiumEngine::Form_GotoPage(IPDF_JSPLATFORM* param, |
| int page_number) { |
| PDFiumEngine* engine = static_cast<PDFiumEngine*>(param); |
| - engine->client_->ScrollToPage(page_number); |
| + engine->ScrollToPage(page_number); |
| } |
| int PDFiumEngine::Form_Browse(IPDF_JSPLATFORM* param, |