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

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

Issue 1556603002: Call FPDFAvail_IsFormAvail() before creating form. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Don't call FPDF_IsFormAvail() if |fpdf_availability_| is not set Created 4 years, 11 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 2579 matching lines...) Expand 10 before | Expand all | Expand 10 after
2590 return; 2590 return;
2591 } 2591 }
2592 2592
2593 if (FPDFDoc_GetPageMode(doc_) == PAGEMODE_USEOUTLINES) 2593 if (FPDFDoc_GetPageMode(doc_) == PAGEMODE_USEOUTLINES)
2594 client_->DocumentHasUnsupportedFeature("Bookmarks"); 2594 client_->DocumentHasUnsupportedFeature("Bookmarks");
2595 2595
2596 permissions_ = FPDF_GetDocPermissions(doc_); 2596 permissions_ = FPDF_GetDocPermissions(doc_);
2597 permissions_handler_revision_ = FPDF_GetSecurityHandlerRevision(doc_); 2597 permissions_handler_revision_ = FPDF_GetSecurityHandlerRevision(doc_);
2598 2598
2599 if (!form_) { 2599 if (!form_) {
2600 // Only returns 0 when data isn't available. If form data is downloaded, or 2600 if (fpdf_availability_) {
spelchat 2015/12/30 19:01:08 This check and DCHECK_NE could be removed instead.
Lei Zhang 2015/12/30 19:58:19 I think for this to happen, the error from FPDFAva
spelchat 2015/12/30 20:14:00 Yes all the FPDFAvail_* functions get called but r
2601 // if this isn't a form, returns positive values. 2601 int form_status =
2602 if (!doc_loader_.IsDocumentComplete() && 2602 FPDFAvail_IsFormAvail(fpdf_availability_, &download_hints_);
2603 !FPDFAvail_IsFormAvail(fpdf_availability_, &download_hints_)) { 2603 DCHECK_NE(form_status, PDF_FORM_ERROR);
2604 return; 2604 bool doc_complete = doc_loader_.IsDocumentComplete();
2605 // Try again if the data is not available and the document hasn't finished
2606 // downloading.
2607 if (form_status == PDF_FORM_NOTAVAIL && !doc_complete)
2608 return;
2605 } 2609 }
2606 2610
2607 form_ = FPDFDOC_InitFormFillEnvironment( 2611 form_ = FPDFDOC_InitFormFillEnvironment(
2608 doc_, static_cast<FPDF_FORMFILLINFO*>(this)); 2612 doc_, static_cast<FPDF_FORMFILLINFO*>(this));
2609 #ifdef PDF_USE_XFA 2613 #ifdef PDF_USE_XFA
2610 FPDF_LoadXFA(doc_); 2614 FPDF_LoadXFA(doc_);
2611 #endif 2615 #endif
2612 2616
2613 FPDF_SetFormFieldHighlightColor(form_, 0, kFormHighlightColor); 2617 FPDF_SetFormFieldHighlightColor(form_, 0, kFormHighlightColor);
2614 FPDF_SetFormFieldHighlightAlpha(form_, kFormHighlightAlpha); 2618 FPDF_SetFormFieldHighlightAlpha(form_, kFormHighlightAlpha);
(...skipping 1384 matching lines...) Expand 10 before | Expand all | Expand 10 after
3999 double* height) { 4003 double* height) {
4000 FPDF_DOCUMENT doc = FPDF_LoadMemDocument(pdf_buffer, pdf_buffer_size, NULL); 4004 FPDF_DOCUMENT doc = FPDF_LoadMemDocument(pdf_buffer, pdf_buffer_size, NULL);
4001 if (!doc) 4005 if (!doc)
4002 return false; 4006 return false;
4003 bool success = FPDF_GetPageSizeByIndex(doc, page_number, width, height) != 0; 4007 bool success = FPDF_GetPageSizeByIndex(doc, page_number, width, height) != 0;
4004 FPDF_CloseDocument(doc); 4008 FPDF_CloseDocument(doc);
4005 return success; 4009 return success;
4006 } 4010 }
4007 4011
4008 } // namespace chrome_pdf 4012 } // 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