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

Side by Side Diff: pdf/pdfium/pdfium_engine.cc

Issue 2030953003: Fixup FPDFAvail_IsPageAvail checks in PDFiumEngine. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "pdf/pdfium/pdfium_engine.h" 5 #include "pdf/pdfium/pdfium_engine.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 1081 matching lines...) Expand 10 before | Expand all | Expand 10 after
1092 DCHECK(doc_loader_.IsDocumentComplete() && doc_); 1092 DCHECK(doc_loader_.IsDocumentComplete() && doc_);
1093 1093
1094 bool need_update = false; 1094 bool need_update = false;
1095 for (size_t i = 0; i < pages_.size(); ++i) { 1095 for (size_t i = 0; i < pages_.size(); ++i) {
1096 if (pages_[i]->available()) 1096 if (pages_[i]->available())
1097 continue; 1097 continue;
1098 1098
1099 pages_[i]->set_available(true); 1099 pages_[i]->set_available(true);
1100 // We still need to call IsPageAvail() even if the whole document is 1100 // We still need to call IsPageAvail() even if the whole document is
1101 // already downloaded. 1101 // already downloaded.
1102 FPDFAvail_IsPageAvail(fpdf_availability_, i, &download_hints_); 1102 while (true) {
dsinclair 2016/06/02 18:03:25 This is probably bad, and I feel bad, but I wasn't
1103 int val = FPDFAvail_IsPageAvail(fpdf_availability_, i, &download_hints_);
1104 if (val == PDF_DATA_ERROR)
1105 return;
1106 if (val == PDF_DATA_AVAIL)
1107 break;
1108 }
1103 need_update = true; 1109 need_update = true;
1104 if (IsPageVisible(i)) 1110 if (IsPageVisible(i))
1105 client_->Invalidate(GetPageScreenRect(i)); 1111 client_->Invalidate(GetPageScreenRect(i));
1106 } 1112 }
1107 if (need_update) 1113 if (need_update)
1108 LoadPageInfo(true); 1114 LoadPageInfo(true);
1109 1115
1110 if (called_do_document_action_) 1116 if (called_do_document_action_)
1111 return; 1117 return;
1112 called_do_document_action_ = true; 1118 called_do_document_action_ = true;
(...skipping 1514 matching lines...) Expand 10 before | Expand all | Expand 10 after
2627 } 2633 }
2628 2634
2629 bool PDFiumEngine::CheckPageAvailable(int index, std::vector<int>* pending) { 2635 bool PDFiumEngine::CheckPageAvailable(int index, std::vector<int>* pending) {
2630 if (!doc_ || !form_) 2636 if (!doc_ || !form_)
2631 return false; 2637 return false;
2632 2638
2633 const int num_pages = static_cast<int>(pages_.size()); 2639 const int num_pages = static_cast<int>(pages_.size());
2634 if (index < num_pages && pages_[index]->available()) 2640 if (index < num_pages && pages_[index]->available())
2635 return true; 2641 return true;
2636 2642
2637 if (!FPDFAvail_IsPageAvail(fpdf_availability_, index, &download_hints_)) { 2643 if (FPDFAvail_IsPageAvail(fpdf_availability_, index, &download_hints_) !=
2644 PDF_DATA_AVAIL) {
2638 if (!ContainsValue(*pending, index)) 2645 if (!ContainsValue(*pending, index))
2639 pending->push_back(index); 2646 pending->push_back(index);
2640 return false; 2647 return false;
2641 } 2648 }
2642 2649
2643 if (index < num_pages) 2650 if (index < num_pages)
2644 pages_[index]->set_available(true); 2651 pages_[index]->set_available(true);
2645 if (!default_page_size_.GetArea()) 2652 if (!default_page_size_.GetArea())
2646 default_page_size_ = GetPageSize(index); 2653 default_page_size_ = GetPageSize(index);
2647 return true; 2654 return true;
(...skipping 1222 matching lines...) Expand 10 before | Expand all | Expand 10 after
3870 FPDF_DOCUMENT doc = 3877 FPDF_DOCUMENT doc =
3871 FPDF_LoadMemDocument(pdf_buffer, pdf_buffer_size, nullptr); 3878 FPDF_LoadMemDocument(pdf_buffer, pdf_buffer_size, nullptr);
3872 if (!doc) 3879 if (!doc)
3873 return false; 3880 return false;
3874 bool success = FPDF_GetPageSizeByIndex(doc, page_number, width, height) != 0; 3881 bool success = FPDF_GetPageSizeByIndex(doc, page_number, width, height) != 0;
3875 FPDF_CloseDocument(doc); 3882 FPDF_CloseDocument(doc);
3876 return success; 3883 return success;
3877 } 3884 }
3878 3885
3879 } // namespace chrome_pdf 3886 } // namespace chrome_pdf
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698