Commit fc77d2c7 authored by Tom Sepez's avatar Tom Sepez Committed by Commit Bot

Fix chromium compilation when GN argument pdf_enable_v8=false

We never build chrome with this configuration, but there's no reason to
prevent some third-party from building chromium in this manner. In the
absence of a few new #ifdefs, we would get errors like:
  error: use of undeclared identifier 'FPDF_GetRecommendedV8Flags'

Change-Id: I1500dd1aa587707ea81e175254b79a21f1bd6010
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2416939
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: default avatarLei Zhang <thestig@chromium.org>
Reviewed-by: default avatarDaniel Hosseinian <dhoss@chromium.org>
Cr-Commit-Position: refs/heads/master@{#808194}
parent 41c6b0f7
...@@ -222,6 +222,7 @@ bool FindMultipleClickBoundary(bool is_double_click, base::char16 cur) { ...@@ -222,6 +222,7 @@ bool FindMultipleClickBoundary(bool is_double_click, base::char16 cur) {
return false; return false;
} }
#if defined(PDF_ENABLE_V8)
gin::IsolateHolder* g_isolate_holder = nullptr; gin::IsolateHolder* g_isolate_holder = nullptr;
bool IsV8Initialized() { bool IsV8Initialized() {
...@@ -247,6 +248,7 @@ void TearDownV8() { ...@@ -247,6 +248,7 @@ void TearDownV8() {
delete g_isolate_holder; delete g_isolate_holder;
g_isolate_holder = nullptr; g_isolate_holder = nullptr;
} }
#endif // defined(PDF_ENABLE_V8)
// Returns true if the given |area| and |form_type| combination from // Returns true if the given |area| and |form_type| combination from
// PDFiumEngine::GetCharIndex() indicates it is a form text area. // PDFiumEngine::GetCharIndex() indicates it is a form text area.
...@@ -396,7 +398,11 @@ void InitializeSDK(bool enable_v8) { ...@@ -396,7 +398,11 @@ void InitializeSDK(bool enable_v8) {
FPDF_LIBRARY_CONFIG config; FPDF_LIBRARY_CONFIG config;
config.version = 3; config.version = 3;
config.m_pUserFontPaths = nullptr; config.m_pUserFontPaths = nullptr;
config.m_pIsolate = nullptr;
config.m_pPlatform = nullptr;
config.m_v8EmbedderSlot = gin::kEmbedderPDFium;
#if defined(PDF_ENABLE_V8)
if (enable_v8) { if (enable_v8) {
SetUpV8(); SetUpV8();
config.m_pIsolate = v8::Isolate::GetCurrent(); config.m_pIsolate = v8::Isolate::GetCurrent();
...@@ -404,11 +410,9 @@ void InitializeSDK(bool enable_v8) { ...@@ -404,11 +410,9 @@ void InitializeSDK(bool enable_v8) {
// will manipulate the pointer value should gin::V8Platform someday have // will manipulate the pointer value should gin::V8Platform someday have
// multiple base classes. // multiple base classes.
config.m_pPlatform = static_cast<v8::Platform*>(gin::V8Platform::Get()); config.m_pPlatform = static_cast<v8::Platform*>(gin::V8Platform::Get());
} else {
config.m_pIsolate = nullptr;
config.m_pPlatform = nullptr;
} }
config.m_v8EmbedderSlot = gin::kEmbedderPDFium; #endif // defined(PDF_ENABLE_V8)
FPDF_InitLibraryWithConfig(&config); FPDF_InitLibraryWithConfig(&config);
#if defined(OS_LINUX) || defined(OS_CHROMEOS) #if defined(OS_LINUX) || defined(OS_CHROMEOS)
...@@ -420,8 +424,10 @@ void InitializeSDK(bool enable_v8) { ...@@ -420,8 +424,10 @@ void InitializeSDK(bool enable_v8) {
void ShutdownSDK() { void ShutdownSDK() {
FPDF_DestroyLibrary(); FPDF_DestroyLibrary();
#if defined(PDF_ENABLE_V8)
if (IsV8Initialized()) if (IsV8Initialized())
TearDownV8(); TearDownV8();
#endif // defined(PDF_ENABLE_V8)
} }
PDFEngine::AccessibilityLinkInfo::AccessibilityLinkInfo() = default; PDFEngine::AccessibilityLinkInfo::AccessibilityLinkInfo() = default;
...@@ -458,8 +464,10 @@ PDFiumEngine::PDFiumEngine(PDFEngine::Client* client, bool enable_javascript) ...@@ -458,8 +464,10 @@ PDFiumEngine::PDFiumEngine(PDFEngine::Client* client, bool enable_javascript)
mouse_down_state_(PDFiumPage::NONSELECTABLE_AREA, mouse_down_state_(PDFiumPage::NONSELECTABLE_AREA,
PDFiumPage::LinkTarget()), PDFiumPage::LinkTarget()),
print_(this) { print_(this) {
#if defined(PDF_ENABLE_V8)
if (enable_javascript) if (enable_javascript)
DCHECK(IsV8Initialized()); DCHECK(IsV8Initialized());
#endif // defined(PDF_ENABLE_V8)
IFSDK_PAUSE::version = 1; IFSDK_PAUSE::version = 1;
IFSDK_PAUSE::user = nullptr; IFSDK_PAUSE::user = nullptr;
......
...@@ -62,6 +62,7 @@ class PDFiumEngine : public PDFEngine, ...@@ -62,6 +62,7 @@ class PDFiumEngine : public PDFEngine,
// Exposed for testing. // Exposed for testing.
enum class FocusElementType { kNone, kDocument, kPage }; enum class FocusElementType { kNone, kDocument, kPage };
// NOTE: |enable_javascript| is ignored when PDF_ENABLE_V8 is not defined.
PDFiumEngine(PDFEngine::Client* client, bool enable_javascript); PDFiumEngine(PDFEngine::Client* client, bool enable_javascript);
PDFiumEngine(const PDFiumEngine&) = delete; PDFiumEngine(const PDFiumEngine&) = delete;
PDFiumEngine& operator=(const PDFiumEngine&) = delete; PDFiumEngine& operator=(const PDFiumEngine&) = delete;
......
...@@ -19,6 +19,7 @@ class PDFiumEngine; ...@@ -19,6 +19,7 @@ class PDFiumEngine;
class PDFiumFormFiller : public FPDF_FORMFILLINFO, public IPDF_JSPLATFORM { class PDFiumFormFiller : public FPDF_FORMFILLINFO, public IPDF_JSPLATFORM {
public: public:
// NOTE: |enable_javascript| is ignored when PDF_ENABLE_V8 is not defined.
PDFiumFormFiller(PDFiumEngine* engine, bool enable_javascript); PDFiumFormFiller(PDFiumEngine* engine, bool enable_javascript);
PDFiumFormFiller(const PDFiumFormFiller&) = delete; PDFiumFormFiller(const PDFiumFormFiller&) = delete;
PDFiumFormFiller& operator=(const PDFiumFormFiller&) = delete; PDFiumFormFiller& operator=(const PDFiumFormFiller&) = delete;
......
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