Commit 5e98777e authored by Tom Sepez's avatar Tom Sepez Committed by Commit Bot

Conditionalize PDFiumEngines enable_javascript on PDF_ENABLE_V8.

No functional change to shipping chrome, but avoid linking in
some dead code should some third-party build chromium with the
GN arg
  pdf_enable_v8 = false.

Change-Id: Ib96547b7632bafc3aca992d903b24d4d1a348608
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2416850
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: default avatarDaniel Hosseinian <dhoss@chromium.org>
Reviewed-by: default avatarLei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/master@{#808415}
parent deb8bb4e
......@@ -53,24 +53,6 @@ PDFiumFormFiller::PDFiumFormFiller(PDFiumEngine* engine, bool enable_javascript)
FPDF_FORMFILLINFO::FFI_OnFocusChange = Form_OnFocusChange;
FPDF_FORMFILLINFO::FFI_DoURIActionWithKeyboardModifier =
Form_DoURIActionWithKeyboardModifier;
#if defined(PDF_ENABLE_XFA)
FPDF_FORMFILLINFO::xfa_disabled = false;
FPDF_FORMFILLINFO::FFI_EmailTo = Form_EmailTo;
FPDF_FORMFILLINFO::FFI_DisplayCaret = Form_DisplayCaret;
FPDF_FORMFILLINFO::FFI_SetCurrentPage = Form_SetCurrentPage;
FPDF_FORMFILLINFO::FFI_GetCurrentPageIndex = Form_GetCurrentPageIndex;
FPDF_FORMFILLINFO::FFI_GetPageViewRect = Form_GetPageViewRect;
FPDF_FORMFILLINFO::FFI_GetPlatform = Form_GetPlatform;
FPDF_FORMFILLINFO::FFI_PageEvent = Form_PageEvent;
FPDF_FORMFILLINFO::FFI_PopupMenu = Form_PopupMenu;
FPDF_FORMFILLINFO::FFI_PostRequestURL = Form_PostRequestURL;
FPDF_FORMFILLINFO::FFI_PutRequestURL = Form_PutRequestURL;
FPDF_FORMFILLINFO::FFI_UploadTo = Form_UploadTo;
FPDF_FORMFILLINFO::FFI_DownloadFromURL = Form_DownloadFromURL;
FPDF_FORMFILLINFO::FFI_OpenFile = Form_OpenFile;
FPDF_FORMFILLINFO::FFI_GotoURL = Form_GotoURL;
FPDF_FORMFILLINFO::FFI_GetLanguage = Form_GetLanguage;
#else
FPDF_FORMFILLINFO::xfa_disabled = true;
FPDF_FORMFILLINFO::FFI_EmailTo = nullptr;
FPDF_FORMFILLINFO::FFI_DisplayCaret = nullptr;
......@@ -87,8 +69,9 @@ PDFiumFormFiller::PDFiumFormFiller(PDFiumEngine* engine, bool enable_javascript)
FPDF_FORMFILLINFO::FFI_OpenFile = nullptr;
FPDF_FORMFILLINFO::FFI_GotoURL = nullptr;
FPDF_FORMFILLINFO::FFI_GetLanguage = nullptr;
#endif // defined(PDF_ENABLE_XFA)
FPDF_FORMFILLINFO::m_pJsPlatform = nullptr;
#if defined(PDF_ENABLE_V8)
if (enable_javascript) {
FPDF_FORMFILLINFO::m_pJsPlatform = this;
IPDF_JSPLATFORM::version = 3;
......@@ -101,9 +84,26 @@ PDFiumFormFiller::PDFiumFormFiller(PDFiumEngine* engine, bool enable_javascript)
IPDF_JSPLATFORM::Doc_submitForm = Form_SubmitForm;
IPDF_JSPLATFORM::Doc_gotoPage = Form_GotoPage;
IPDF_JSPLATFORM::Field_browse = nullptr;
} else {
FPDF_FORMFILLINFO::m_pJsPlatform = nullptr;
}
#if defined(PDF_ENABLE_XFA)
FPDF_FORMFILLINFO::xfa_disabled = false;
FPDF_FORMFILLINFO::FFI_EmailTo = Form_EmailTo;
FPDF_FORMFILLINFO::FFI_DisplayCaret = Form_DisplayCaret;
FPDF_FORMFILLINFO::FFI_SetCurrentPage = Form_SetCurrentPage;
FPDF_FORMFILLINFO::FFI_GetCurrentPageIndex = Form_GetCurrentPageIndex;
FPDF_FORMFILLINFO::FFI_GetPageViewRect = Form_GetPageViewRect;
FPDF_FORMFILLINFO::FFI_GetPlatform = Form_GetPlatform;
FPDF_FORMFILLINFO::FFI_PageEvent = Form_PageEvent;
FPDF_FORMFILLINFO::FFI_PopupMenu = Form_PopupMenu;
FPDF_FORMFILLINFO::FFI_PostRequestURL = Form_PostRequestURL;
FPDF_FORMFILLINFO::FFI_PutRequestURL = Form_PutRequestURL;
FPDF_FORMFILLINFO::FFI_UploadTo = Form_UploadTo;
FPDF_FORMFILLINFO::FFI_DownloadFromURL = Form_DownloadFromURL;
FPDF_FORMFILLINFO::FFI_OpenFile = Form_OpenFile;
FPDF_FORMFILLINFO::FFI_GotoURL = Form_GotoURL;
FPDF_FORMFILLINFO::FFI_GetLanguage = Form_GetLanguage;
#endif // defined(PDF_ENABLE_XFA)
#endif // defined(PDF_ENABLE_V8)
}
PDFiumFormFiller::~PDFiumFormFiller() = default;
......@@ -327,6 +327,7 @@ void PDFiumFormFiller::Form_DoURIActionWithKeyboardModifier(
engine->client_->NavigateTo(std::string(uri), disposition);
}
#if defined(PDF_ENABLE_V8)
#if defined(PDF_ENABLE_XFA)
// static
......@@ -673,6 +674,8 @@ void PDFiumFormFiller::Form_GotoPage(IPDF_JSPLATFORM* param, int page_number) {
engine->ScrollToPage(page_number);
}
#endif // defined(PDF_ENABLE_V8)
// static
PDFiumEngine* PDFiumFormFiller::GetEngine(FPDF_FORMFILLINFO* info) {
auto* form_filler = static_cast<PDFiumFormFiller*>(info);
......
......@@ -73,6 +73,7 @@ class PDFiumFormFiller : public FPDF_FORMFILLINFO, public IPDF_JSPLATFORM {
FPDF_BYTESTRING uri,
int modifiers);
#if defined(PDF_ENABLE_V8)
#if defined(PDF_ENABLE_XFA)
static void Form_EmailTo(FPDF_FORMFILLINFO* param,
FPDF_FILEHANDLER* file_handler,
......@@ -181,6 +182,7 @@ class PDFiumFormFiller : public FPDF_FORMFILLINFO, public IPDF_JSPLATFORM {
int length,
FPDF_WIDESTRING url);
static void Form_GotoPage(IPDF_JSPLATFORM* param, int page_number);
#endif // defined(PDF_ENABLE_V8)
static PDFiumEngine* GetEngine(FPDF_FORMFILLINFO* info);
static PDFiumEngine* GetEngine(IPDF_JSPLATFORM* platform);
......
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