0

Pass v8::Platform to PDFium via FPDF_LIBRARY_CONFIG version 3.

Although the v8 platform is not currently used by PDFium, this
adds the "plumbing" to get the platform from above from gin, as
it may be required in the future.

Change-Id: I7d0d962c339f109982342f4831a8c3122f089e7d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2240013
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Cr-Commit-Position: refs/heads/master@{#777192}
This commit is contained in:
Tom Sepez
2020-06-11 00:39:45 +00:00
committed by Commit Bot
parent 1fae077992
commit 4a89e19655
2 changed files with 9 additions and 2 deletions

@ -28,6 +28,7 @@
#include "gin/array_buffer.h"
#include "gin/public/gin_embedders.h"
#include "gin/public/isolate_holder.h"
#include "gin/public/v8_platform.h"
#include "pdf/document_loader_impl.h"
#include "pdf/draw_utils/coordinates.h"
#include "pdf/draw_utils/shadow.h"
@ -370,14 +371,19 @@ base::string16 GetAttachmentName(FPDF_ATTACHMENT attachment) {
void InitializeSDK(bool enable_v8) {
FPDF_LIBRARY_CONFIG config;
config.version = 2;
config.version = 3;
config.m_pUserFontPaths = nullptr;
if (enable_v8) {
SetUpV8();
config.m_pIsolate = v8::Isolate::GetCurrent();
// NOTE: static_cast<> prior to assigning to (void*) is safer since it
// will manipulate the pointer value should gin::V8Platform someday have
// multiple base classes.
config.m_pPlatform = static_cast<v8::Platform*>(gin::V8Platform::Get());
} else {
config.m_pIsolate = nullptr;
config.m_pPlatform = nullptr;
}
config.m_v8EmbedderSlot = gin::kEmbedderPDFium;
FPDF_InitLibraryWithConfig(&config);

@ -103,10 +103,11 @@ PDFiumTestBase::InitializeEngineWithoutLoading(
void PDFiumTestBase::InitializePDFium() {
FPDF_LIBRARY_CONFIG config;
config.version = 2;
config.version = 3;
config.m_pUserFontPaths = nullptr;
config.m_pIsolate = nullptr;
config.m_v8EmbedderSlot = 0;
config.m_pPlatform = nullptr;
FPDF_InitLibraryWithConfig(&config);
}