From 3dedace9623fef6161a8666e53a4ab2b9be61e4c Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Fri, 2 Oct 2015 16:43:15 -0700 Subject: Pass v8::Isolate to PDFium at init time. Move the external isolate and embedder slot from the IPDF_JSPlatforms struct supplied at the FPDFDOC_InitFormFillEnvironment() call time to arguments to the FPDF_InitLibraryWithConfig() call. This has several benefits: -- Avoids the crash that could happen if multiple FPDFDOC_InitFormFillEnvironmen() calls should happen to be made by an embedder with different slot values. -- Down the road, for XFA, there may be XFA but no FormFill environment. We support both forms for the time being, until the chrome side catches up, at which point we will deprecate the old way. R=thestig@chromium.org Review URL: https://codereview.chromium.org/1367033002 . --- samples/pdfium_test.cc | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'samples/pdfium_test.cc') diff --git a/samples/pdfium_test.cc b/samples/pdfium_test.cc index 1d8a77a3ad..74e797b944 100644 --- a/samples/pdfium_test.cc +++ b/samples/pdfium_test.cc @@ -437,7 +437,7 @@ void RenderPdf(const std::string& name, const char* pBuf, size_t len, IPDF_JSPLATFORM platform_callbacks; memset(&platform_callbacks, '\0', sizeof(platform_callbacks)); - platform_callbacks.version = 2; + platform_callbacks.version = 3; platform_callbacks.app_alert = ExampleAppAlert; platform_callbacks.Doc_gotoPage = ExampleDocGotoPage; @@ -616,17 +616,19 @@ int main(int argc, const char* argv[]) { v8::V8::SetSnapshotDataBlob(&snapshot); #endif // V8_USE_EXTERNAL_STARTUP_DATA - if (options.font_directory.empty()) { - FPDF_InitLibrary(); - } else { - const char* path_array[2]; + FPDF_LIBRARY_CONFIG config; + config.version = 2; + config.m_pUserFontPaths = nullptr; + config.m_pIsolate = nullptr; + config.m_v8EmbedderSlot = 0; + + const char* path_array[2]; + if (!options.font_directory.empty()) { path_array[0] = options.font_directory.c_str(); path_array[1] = nullptr; - FPDF_LIBRARY_CONFIG config; - config.version = 1; config.m_pUserFontPaths = path_array; - FPDF_InitLibraryWithConfig(&config); } + FPDF_InitLibraryWithConfig(&config); UNSUPPORT_INFO unsuppored_info; memset(&unsuppored_info, '\0', sizeof(unsuppored_info)); -- cgit v1.2.3