Use fine-grained v8 headers in pdfium
Now that v8.h has been split into many parts, include only the parts
that are needed.
Also update .gn to more accurately reflect the parts of v8 that are now
gn-check-clean.
Bug: v8:11965
Change-Id: Ia38f131b599274ca0deb393e5887e66a2eea164c
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/84950
Auto-Submit: Dan Elphick <delphick@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/fxjs/cfx_v8.cpp b/fxjs/cfx_v8.cpp
index 1acb7de..e1b7a3e 100644
--- a/fxjs/cfx_v8.cpp
+++ b/fxjs/cfx_v8.cpp
@@ -9,6 +9,7 @@
#include "core/fxcrt/fx_memory.h"
#include "fxjs/fxv8.h"
#include "third_party/base/allocator/partition_allocator/partition_alloc.h"
+#include "v8/include/v8-isolate.h"
CFX_V8::CFX_V8(v8::Isolate* isolate) : m_pIsolate(isolate) {}
@@ -146,3 +147,7 @@
void CFX_V8ArrayBufferAllocator::Free(void* data, size_t length) {
GetArrayBufferPartitionAllocator().root()->Free(data);
}
+
+void CFX_V8IsolateDeleter::operator()(v8::Isolate* ptr) {
+ ptr->Dispose();
+}
diff --git a/fxjs/cfx_v8.h b/fxjs/cfx_v8.h
index 8cc49e6..1a164e3 100644
--- a/fxjs/cfx_v8.h
+++ b/fxjs/cfx_v8.h
@@ -11,7 +11,8 @@
#include "core/fxcrt/fx_string.h"
#include "core/fxcrt/unowned_ptr.h"
-#include "v8/include/v8.h"
+#include "v8/include/v8-array-buffer.h"
+#include "v8/include/v8-forward.h"
class CFX_V8 {
public:
@@ -73,7 +74,7 @@
// Use with std::unique_ptr<v8::Isolate> to dispose of isolates correctly.
struct CFX_V8IsolateDeleter {
- inline void operator()(v8::Isolate* ptr) { ptr->Dispose(); }
+ void operator()(v8::Isolate* ptr);
};
#endif // FXJS_CFX_V8_H_
diff --git a/fxjs/cfx_v8_unittest.cpp b/fxjs/cfx_v8_unittest.cpp
index bd6ce0a..d49deca 100644
--- a/fxjs/cfx_v8_unittest.cpp
+++ b/fxjs/cfx_v8_unittest.cpp
@@ -10,6 +10,10 @@
#include "testing/fxv8_unittest.h"
#include "testing/gtest/include/gtest/gtest.h"
+#include "v8/include/v8-container.h"
+#include "v8/include/v8-context.h"
+#include "v8/include/v8-date.h"
+#include "v8/include/v8-isolate.h"
namespace {
bool getter_sentinel = false;
diff --git a/fxjs/cfxjs_engine.cpp b/fxjs/cfxjs_engine.cpp
index 50e67ef..e57e7f2 100644
--- a/fxjs/cfxjs_engine.cpp
+++ b/fxjs/cfxjs_engine.cpp
@@ -16,6 +16,12 @@
#include "fxjs/xfa/cfxjse_runtimedata.h"
#include "third_party/base/check.h"
#include "third_party/base/check_op.h"
+#include "v8/include/v8-context.h"
+#include "v8/include/v8-exception.h"
+#include "v8/include/v8-isolate.h"
+#include "v8/include/v8-message.h"
+#include "v8/include/v8-primitive.h"
+#include "v8/include/v8-script.h"
#include "v8/include/v8-util.h"
class CFXJS_PerObjectData;
diff --git a/fxjs/cfxjs_engine.h b/fxjs/cfxjs_engine.h
index 03cde02..4f1c08e 100644
--- a/fxjs/cfxjs_engine.h
+++ b/fxjs/cfxjs_engine.h
@@ -22,7 +22,10 @@
#include "core/fxcrt/fx_string.h"
#include "fxjs/cfx_v8.h"
#include "fxjs/ijs_runtime.h"
-#include "v8/include/v8.h"
+#include "v8/include/v8-forward.h"
+#include "v8/include/v8-function-callback.h"
+#include "v8/include/v8-persistent-handle.h"
+#include "v8/include/v8-template.h"
class CFXJS_ObjDefinition;
class CJS_Object;
diff --git a/fxjs/cfxjs_engine_unittest.cpp b/fxjs/cfxjs_engine_unittest.cpp
index d62e69c..0470a78 100644
--- a/fxjs/cfxjs_engine_unittest.cpp
+++ b/fxjs/cfxjs_engine_unittest.cpp
@@ -9,6 +9,8 @@
#include "fxjs/cjs_object.h"
#include "testing/fxv8_unittest.h"
#include "testing/gtest/include/gtest/gtest.h"
+#include "v8/include/v8-context.h"
+#include "v8/include/v8-isolate.h"
class FXJSEngineUnitTest : public FXV8UnitTest {
public:
diff --git a/fxjs/cjs_app.cpp b/fxjs/cjs_app.cpp
index bacd8d2..c9f1ca6 100644
--- a/fxjs/cjs_app.cpp
+++ b/fxjs/cjs_app.cpp
@@ -16,6 +16,7 @@
#include "fxjs/global_timer.h"
#include "fxjs/ijs_event_context.h"
#include "fxjs/js_resources.h"
+#include "v8/include/v8-container.h"
namespace {
diff --git a/fxjs/cjs_color.cpp b/fxjs/cjs_color.cpp
index d28bf3f..4b35e78 100644
--- a/fxjs/cjs_color.cpp
+++ b/fxjs/cjs_color.cpp
@@ -15,6 +15,7 @@
#include "fxjs/cjs_runtime.h"
#include "fxjs/fxv8.h"
#include "fxjs/js_define.h"
+#include "v8/include/v8-container.h"
const JSPropertySpec CJS_Color::PropertySpecs[] = {
{"black", get_black_static, set_black_static},
diff --git a/fxjs/cjs_document.cpp b/fxjs/cjs_document.cpp
index cd8b16c..7520da2 100644
--- a/fxjs/cjs_document.cpp
+++ b/fxjs/cjs_document.cpp
@@ -31,6 +31,7 @@
#include "fxjs/cjs_icon.h"
#include "fxjs/js_resources.h"
#include "third_party/base/check.h"
+#include "v8/include/v8-container.h"
const JSPropertySpec CJS_Document::PropertySpecs[] = {
{"ADBE", get_ADBE_static, set_ADBE_static},
diff --git a/fxjs/cjs_event_context.cpp b/fxjs/cjs_event_context.cpp
index 87361a1..da8b8ee 100644
--- a/fxjs/cjs_event_context.cpp
+++ b/fxjs/cjs_event_context.cpp
@@ -14,6 +14,8 @@
#include "fxjs/js_define.h"
#include "fxjs/js_resources.h"
#include "third_party/base/check.h"
+#include "v8/include/v8-context.h"
+#include "v8/include/v8-isolate.h"
CJS_EventContext::CJS_EventContext(CJS_Runtime* pRuntime)
: m_pRuntime(pRuntime), m_pFormFillEnv(pRuntime->GetFormFillEnv()) {}
diff --git a/fxjs/cjs_field.cpp b/fxjs/cjs_field.cpp
index 70a8483..6469d69 100644
--- a/fxjs/cjs_field.cpp
+++ b/fxjs/cjs_field.cpp
@@ -30,6 +30,7 @@
#include "third_party/base/check.h"
#include "third_party/base/notreached.h"
#include "third_party/base/optional.h"
+#include "v8/include/v8-container.h"
namespace {
diff --git a/fxjs/cjs_global.cpp b/fxjs/cjs_global.cpp
index 3aeb94f..5d10ae7 100644
--- a/fxjs/cjs_global.cpp
+++ b/fxjs/cjs_global.cpp
@@ -19,6 +19,7 @@
#include "fxjs/js_define.h"
#include "fxjs/js_resources.h"
#include "third_party/base/check.h"
+#include "v8/include/v8-isolate.h"
namespace {
diff --git a/fxjs/cjs_globalarrays.cpp b/fxjs/cjs_globalarrays.cpp
index 0ec2671..407b620 100644
--- a/fxjs/cjs_globalarrays.cpp
+++ b/fxjs/cjs_globalarrays.cpp
@@ -7,6 +7,8 @@
#include "fxjs/cjs_globalarrays.h"
#include "third_party/base/cxx17_backports.h"
+#include "v8/include/v8-container.h"
+#include "v8/include/v8-isolate.h"
#define GLOBAL_ARRAY(rt, name, ...) \
{ \
diff --git a/fxjs/cjs_publicmethods.cpp b/fxjs/cjs_publicmethods.cpp
index 12e5427..7a63656 100644
--- a/fxjs/cjs_publicmethods.cpp
+++ b/fxjs/cjs_publicmethods.cpp
@@ -36,6 +36,7 @@
#include "third_party/base/check.h"
#include "third_party/base/cxx17_backports.h"
#include "third_party/base/optional.h"
+#include "v8/include/v8-container.h"
// static
const JSMethodSpec CJS_PublicMethods::GlobalFunctionSpecs[] = {
diff --git a/fxjs/cjs_result.h b/fxjs/cjs_result.h
index 5e1ed7c..f639842 100644
--- a/fxjs/cjs_result.h
+++ b/fxjs/cjs_result.h
@@ -9,7 +9,7 @@
#include "fxjs/js_resources.h"
#include "third_party/base/optional.h"
-#include "v8/include/v8.h"
+#include "v8/include/v8-forward.h"
class CJS_Result {
public:
diff --git a/fxjs/cjs_runtime.cpp b/fxjs/cjs_runtime.cpp
index a263280..d73744c 100644
--- a/fxjs/cjs_runtime.cpp
+++ b/fxjs/cjs_runtime.cpp
@@ -40,6 +40,9 @@
#include "fxjs/fxv8.h"
#include "fxjs/js_define.h"
#include "third_party/base/check_op.h"
+#include "v8/include/v8-context.h"
+#include "v8/include/v8-exception.h"
+#include "v8/include/v8-isolate.h"
CJS_Runtime::CJS_Runtime(CPDFSDK_FormFillEnvironment* pFormFillEnv)
: m_pFormFillEnv(pFormFillEnv) {
diff --git a/fxjs/cjs_util.cpp b/fxjs/cjs_util.cpp
index c316e00..8a346d1 100644
--- a/fxjs/cjs_util.cpp
+++ b/fxjs/cjs_util.cpp
@@ -25,6 +25,7 @@
#include "fxjs/js_resources.h"
#include "third_party/base/check_op.h"
#include "third_party/base/cxx17_backports.h"
+#include "v8/include/v8-date.h"
#if defined(OS_ANDROID)
#include <ctype.h>
diff --git a/fxjs/cjs_util.h b/fxjs/cjs_util.h
index 2ad4d27..ff96d83 100644
--- a/fxjs/cjs_util.h
+++ b/fxjs/cjs_util.h
@@ -12,6 +12,7 @@
#include "core/fxcrt/widestring.h"
#include "fxjs/cjs_object.h"
#include "fxjs/js_define.h"
+#include "v8/include/v8-forward.h"
class CJS_Util final : public CJS_Object {
public:
diff --git a/fxjs/fxv8.cpp b/fxjs/fxv8.cpp
index e139e26..00caf27 100644
--- a/fxjs/fxv8.cpp
+++ b/fxjs/fxv8.cpp
@@ -6,6 +6,13 @@
#include "fxjs/fxv8.h"
+#include "v8/include/v8-container.h"
+#include "v8/include/v8-date.h"
+#include "v8/include/v8-exception.h"
+#include "v8/include/v8-isolate.h"
+#include "v8/include/v8-primitive.h"
+#include "v8/include/v8-value.h"
+
namespace fxv8 {
bool IsUndefined(v8::Local<v8::Value> value) {
diff --git a/fxjs/fxv8.h b/fxjs/fxv8.h
index 75655c7..a370047 100644
--- a/fxjs/fxv8.h
+++ b/fxjs/fxv8.h
@@ -11,7 +11,7 @@
#include "core/fxcrt/fx_string.h"
#include "third_party/base/span.h"
-#include "v8/include/v8.h"
+#include "v8/include/v8-forward.h"
// The fxv8 functions soften up the interface to the V8 API.
diff --git a/fxjs/js_define.cpp b/fxjs/js_define.cpp
index e86330c..c994b1d 100644
--- a/fxjs/js_define.cpp
+++ b/fxjs/js_define.cpp
@@ -19,6 +19,9 @@
#include "fxjs/fx_date_helpers.h"
#include "fxjs/fxv8.h"
#include "third_party/base/check.h"
+#include "v8/include/v8-context.h"
+#include "v8/include/v8-function.h"
+#include "v8/include/v8-isolate.h"
void JSDestructor(v8::Local<v8::Object> obj) {
CFXJS_Engine::SetObjectPrivate(obj, nullptr);
diff --git a/fxjs/xfa/cfxjse_class.cpp b/fxjs/xfa/cfxjse_class.cpp
index 6f2c80f..f4af90a 100644
--- a/fxjs/xfa/cfxjse_class.cpp
+++ b/fxjs/xfa/cfxjse_class.cpp
@@ -18,6 +18,14 @@
#include "fxjs/xfa/cfxjse_value.h"
#include "third_party/base/check.h"
#include "third_party/base/check_op.h"
+#include "v8/include/v8-container.h"
+#include "v8/include/v8-external.h"
+#include "v8/include/v8-function-callback.h"
+#include "v8/include/v8-function.h"
+#include "v8/include/v8-isolate.h"
+#include "v8/include/v8-object.h"
+#include "v8/include/v8-primitive.h"
+#include "v8/include/v8-template.h"
using pdfium::fxjse::kClassTag;
using pdfium::fxjse::kFuncTag;
diff --git a/fxjs/xfa/cfxjse_class.h b/fxjs/xfa/cfxjse_class.h
index c5491b6..e63be73 100644
--- a/fxjs/xfa/cfxjse_class.h
+++ b/fxjs/xfa/cfxjse_class.h
@@ -9,7 +9,8 @@
#include "core/fxcrt/unowned_ptr.h"
#include "fxjs/xfa/fxjse.h"
-#include "v8/include/v8.h"
+#include "v8/include/v8-forward.h"
+#include "v8/include/v8-persistent-handle.h"
class CFXJSE_Context;
struct FXJSE_CLASS_DESCRIPTOR;
diff --git a/fxjs/xfa/cfxjse_context.cpp b/fxjs/xfa/cfxjse_context.cpp
index b5eb033..563bfe7 100644
--- a/fxjs/xfa/cfxjse_context.cpp
+++ b/fxjs/xfa/cfxjse_context.cpp
@@ -18,6 +18,10 @@
#include "third_party/base/check.h"
#include "third_party/base/check_op.h"
#include "third_party/base/ptr_util.h"
+#include "v8/include/v8-exception.h"
+#include "v8/include/v8-function.h"
+#include "v8/include/v8-message.h"
+#include "v8/include/v8-script.h"
#include "xfa/fxfa/parser/cxfa_thisproxy.h"
namespace {
diff --git a/fxjs/xfa/cfxjse_context.h b/fxjs/xfa/cfxjse_context.h
index a423ac8..381f8b0 100644
--- a/fxjs/xfa/cfxjse_context.h
+++ b/fxjs/xfa/cfxjse_context.h
@@ -13,7 +13,8 @@
#include "core/fxcrt/fx_string.h"
#include "core/fxcrt/unowned_ptr.h"
#include "v8/include/cppgc/persistent.h"
-#include "v8/include/v8.h"
+#include "v8/include/v8-forward.h"
+#include "v8/include/v8-persistent-handle.h"
class CFXJSE_Class;
class CFXJSE_HostObject;
diff --git a/fxjs/xfa/cfxjse_engine.cpp b/fxjs/xfa/cfxjse_engine.cpp
index 117cd7a..17ff87a 100644
--- a/fxjs/xfa/cfxjse_engine.cpp
+++ b/fxjs/xfa/cfxjse_engine.cpp
@@ -23,6 +23,9 @@
#include "fxjs/xfa/cfxjse_value.h"
#include "fxjs/xfa/cjx_object.h"
#include "third_party/base/containers/contains.h"
+#include "v8/include/v8-function-callback.h"
+#include "v8/include/v8-function.h"
+#include "v8/include/v8-object.h"
#include "xfa/fxfa/cxfa_eventparam.h"
#include "xfa/fxfa/cxfa_ffdoc.h"
#include "xfa/fxfa/cxfa_ffnotify.h"
diff --git a/fxjs/xfa/cfxjse_engine.h b/fxjs/xfa/cfxjse_engine.h
index 15de599..cd82540 100644
--- a/fxjs/xfa/cfxjse_engine.h
+++ b/fxjs/xfa/cfxjse_engine.h
@@ -16,7 +16,7 @@
#include "core/fxcrt/unowned_ptr.h"
#include "fxjs/cfx_v8.h"
#include "v8/include/cppgc/persistent.h"
-#include "v8/include/v8.h"
+#include "v8/include/v8-forward.h"
#include "xfa/fxfa/cxfa_eventparam.h"
#include "xfa/fxfa/parser/cxfa_document.h"
#include "xfa/fxfa/parser/cxfa_script.h"
diff --git a/fxjs/xfa/cfxjse_formcalc_context.cpp b/fxjs/xfa/cfxjse_formcalc_context.cpp
index bd8e1a0..d54fec2 100644
--- a/fxjs/xfa/cfxjse_formcalc_context.cpp
+++ b/fxjs/xfa/cfxjse_formcalc_context.cpp
@@ -27,6 +27,9 @@
#include "third_party/base/check.h"
#include "third_party/base/cxx17_backports.h"
#include "third_party/base/optional.h"
+#include "v8/include/v8-container.h"
+#include "v8/include/v8-function-callback.h"
+#include "v8/include/v8-object.h"
#include "xfa/fgas/crt/cfgas_decimal.h"
#include "xfa/fxfa/cxfa_ffnotify.h"
#include "xfa/fxfa/fm2js/cxfa_fmparser.h"
diff --git a/fxjs/xfa/cfxjse_formcalc_context.h b/fxjs/xfa/cfxjse_formcalc_context.h
index e220428..33c5ad1 100644
--- a/fxjs/xfa/cfxjse_formcalc_context.h
+++ b/fxjs/xfa/cfxjse_formcalc_context.h
@@ -16,6 +16,8 @@
#include "core/fxcrt/unowned_ptr.h"
#include "fxjs/xfa/fxjse.h"
#include "third_party/base/optional.h"
+#include "v8/include/v8-forward.h"
+#include "v8/include/v8-persistent-handle.h"
class CFXJSE_Context;
class CFX_WideTextBuf;
diff --git a/fxjs/xfa/cfxjse_isolatetracker.h b/fxjs/xfa/cfxjse_isolatetracker.h
index 3b0b058..86b1f24 100644
--- a/fxjs/xfa/cfxjse_isolatetracker.h
+++ b/fxjs/xfa/cfxjse_isolatetracker.h
@@ -8,7 +8,8 @@
#define FXJS_XFA_CFXJSE_ISOLATETRACKER_H_
#include "core/fxcrt/fx_memory.h"
-#include "v8/include/v8.h"
+#include "v8/include/v8-context.h"
+#include "v8/include/v8-isolate.h"
class CFXJSE_Context;
diff --git a/fxjs/xfa/cfxjse_runtimedata.cpp b/fxjs/xfa/cfxjse_runtimedata.cpp
index 18b883c..fbf6c5d 100644
--- a/fxjs/xfa/cfxjse_runtimedata.cpp
+++ b/fxjs/xfa/cfxjse_runtimedata.cpp
@@ -12,6 +12,12 @@
#include "fxjs/fxv8.h"
#include "fxjs/xfa/cfxjse_isolatetracker.h"
#include "third_party/base/check_op.h"
+#include "v8/include/v8-context.h"
+#include "v8/include/v8-external.h"
+#include "v8/include/v8-isolate.h"
+#include "v8/include/v8-object.h"
+#include "v8/include/v8-primitive.h"
+#include "v8/include/v8-template.h"
CFXJSE_RuntimeData::CFXJSE_RuntimeData() = default;
diff --git a/fxjs/xfa/cfxjse_runtimedata.h b/fxjs/xfa/cfxjse_runtimedata.h
index 148b01e..030cc9a 100644
--- a/fxjs/xfa/cfxjse_runtimedata.h
+++ b/fxjs/xfa/cfxjse_runtimedata.h
@@ -10,7 +10,8 @@
#include <memory>
#include "fxjs/cfxjs_engine.h"
-#include "v8/include/v8.h"
+#include "v8/include/v8-forward.h"
+#include "v8/include/v8-persistent-handle.h"
class CFXJSE_RuntimeData : public FXJS_PerIsolateData::ExtensionIface {
public:
diff --git a/fxjs/xfa/cfxjse_value.cpp b/fxjs/xfa/cfxjse_value.cpp
index 9a5ed51..d77a28d 100644
--- a/fxjs/xfa/cfxjse_value.cpp
+++ b/fxjs/xfa/cfxjse_value.cpp
@@ -14,6 +14,10 @@
#include "fxjs/xfa/cfxjse_context.h"
#include "fxjs/xfa/cfxjse_isolatetracker.h"
#include "third_party/base/check.h"
+#include "v8/include/v8-container.h"
+#include "v8/include/v8-exception.h"
+#include "v8/include/v8-function.h"
+#include "v8/include/v8-script.h"
namespace {
diff --git a/fxjs/xfa/cfxjse_value.h b/fxjs/xfa/cfxjse_value.h
index 0f2c36a..cebeb50 100644
--- a/fxjs/xfa/cfxjse_value.h
+++ b/fxjs/xfa/cfxjse_value.h
@@ -15,7 +15,8 @@
#include "core/fxcrt/fx_string.h"
#include "core/fxcrt/unowned_ptr.h"
#include "third_party/base/check.h"
-#include "v8/include/v8.h"
+#include "v8/include/v8-forward.h"
+#include "v8/include/v8-persistent-handle.h"
class CFXJSE_Class;
class CFXJSE_HostObject;
diff --git a/fxjs/xfa/cjx_boolean.cpp b/fxjs/xfa/cjx_boolean.cpp
index 7e77d25..75424ad 100644
--- a/fxjs/xfa/cjx_boolean.cpp
+++ b/fxjs/xfa/cjx_boolean.cpp
@@ -8,6 +8,7 @@
#include "fxjs/fxv8.h"
#include "fxjs/xfa/cfxjse_value.h"
+#include "v8/include/v8-primitive.h"
#include "xfa/fxfa/parser/cxfa_boolean.h"
CJX_Boolean::CJX_Boolean(CXFA_Boolean* node) : CJX_Object(node) {}
diff --git a/fxjs/xfa/fxjse.cpp b/fxjs/xfa/fxjse.cpp
index b4f8d61..7b6d7fd 100644
--- a/fxjs/xfa/fxjse.cpp
+++ b/fxjs/xfa/fxjse.cpp
@@ -8,6 +8,9 @@
#include "fxjs/fxv8.h"
#include "fxjs/xfa/cfxjse_context.h"
+#include "v8/include/v8-isolate.h"
+#include "v8/include/v8-object.h"
+#include "v8/include/v8-template.h"
namespace pdfium {
namespace fxjse {
diff --git a/fxjs/xfa/fxjse.h b/fxjs/xfa/fxjse.h
index 44b9c14..9007d63 100644
--- a/fxjs/xfa/fxjse.h
+++ b/fxjs/xfa/fxjse.h
@@ -10,7 +10,7 @@
#include <stdint.h>
#include "core/fxcrt/fx_string.h"
-#include "v8/include/v8.h"
+#include "v8/include/v8-forward.h"
namespace pdfium {
namespace fxjse {