Use fine-grained v8 headers.
Include specific v8-foo.h files instead of v8.h. Resolve IWYU issues to
fix the build.
Bug: v8:11965
Change-Id: I19bc2393383d0d867d87ed1b96ecb8de92b76078
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/94991
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Nigi <nigi@chromium.org>
diff --git a/fxjs/cfxjs_engine_embeddertest.cpp b/fxjs/cfxjs_engine_embeddertest.cpp
index 5763f4d..3538175 100644
--- a/fxjs/cfxjs_engine_embeddertest.cpp
+++ b/fxjs/cfxjs_engine_embeddertest.cpp
@@ -6,6 +6,11 @@
#include "testing/external_engine_embedder_test.h"
#include "testing/gtest/include/gtest/gtest.h"
+#include "v8/include/v8-context.h"
+#include "v8/include/v8-isolate.h"
+#include "v8/include/v8-local-handle.h"
+#include "v8/include/v8-object.h"
+#include "v8/include/v8-value.h"
namespace {
diff --git a/fxjs/cjs_publicmethods_embeddertest.cpp b/fxjs/cjs_publicmethods_embeddertest.cpp
index c595eb4..1854f75 100644
--- a/fxjs/cjs_publicmethods_embeddertest.cpp
+++ b/fxjs/cjs_publicmethods_embeddertest.cpp
@@ -12,6 +12,11 @@
#include "fxjs/cjs_publicmethods.h"
#include "testing/external_engine_embedder_test.h"
#include "testing/gtest/include/gtest/gtest.h"
+#include "v8/include/v8-container.h"
+#include "v8/include/v8-context.h"
+#include "v8/include/v8-isolate.h"
+#include "v8/include/v8-local-handle.h"
+#include "v8/include/v8-value.h"
namespace {
diff --git a/samples/pdfium_test.cc b/samples/pdfium_test.cc
index f6e35fe..b69eedb 100644
--- a/samples/pdfium_test.cc
+++ b/samples/pdfium_test.cc
@@ -58,7 +58,10 @@
#ifdef PDF_ENABLE_V8
#include "testing/v8_initializer.h"
#include "v8/include/libplatform/libplatform.h"
-#include "v8/include/v8.h"
+#include "v8/include/v8-array-buffer.h"
+#include "v8/include/v8-isolate.h"
+#include "v8/include/v8-platform.h"
+#include "v8/include/v8-snapshot.h"
#endif // PDF_ENABLE_V8
#ifdef _WIN32
diff --git a/samples/simple_with_v8.cc b/samples/simple_with_v8.cc
index 0bb377a..48c7608 100644
--- a/samples/simple_with_v8.cc
+++ b/samples/simple_with_v8.cc
@@ -12,7 +12,9 @@
#include "public/fpdf_formfill.h"
#include "public/fpdfview.h"
#include "v8/include/libplatform/libplatform.h"
-#include "v8/include/v8.h"
+#include "v8/include/v8-array-buffer.h"
+#include "v8/include/v8-initialization.h"
+#include "v8/include/v8-isolate.h"
int main(int argc, const char* argv[]) {
// V8 must be initialized before the PDFium library if using V8.
diff --git a/testing/embedder_test.cpp b/testing/embedder_test.cpp
index e398ab6..f8265a4 100644
--- a/testing/embedder_test.cpp
+++ b/testing/embedder_test.cpp
@@ -28,12 +28,6 @@
#include "third_party/base/notreached.h"
#include "third_party/base/numerics/safe_conversions.h"
-#ifdef PDF_ENABLE_V8
-#include "testing/v8_test_environment.h"
-#include "v8/include/v8-platform.h"
-#include "v8/include/v8.h"
-#endif // PDF_ENABLE_V8
-
namespace {
int GetBitmapBytesPerPixel(FPDF_BITMAP bitmap) {
diff --git a/testing/external_engine_embedder_test.cpp b/testing/external_engine_embedder_test.cpp
index 7f70a90..8fc11d6 100644
--- a/testing/external_engine_embedder_test.cpp
+++ b/testing/external_engine_embedder_test.cpp
@@ -8,6 +8,9 @@
#include "fxjs/cfxjs_engine.h"
#include "testing/v8_test_environment.h"
+#include "v8/include/v8-context.h"
+#include "v8/include/v8-isolate.h"
+#include "v8/include/v8-local-handle.h"
ExternalEngineEmbedderTest::ExternalEngineEmbedderTest() = default;
diff --git a/testing/external_engine_embedder_test.h b/testing/external_engine_embedder_test.h
index fa352ee..4b8ee25 100644
--- a/testing/external_engine_embedder_test.h
+++ b/testing/external_engine_embedder_test.h
@@ -8,7 +8,8 @@
#include <memory>
#include "testing/js_embedder_test.h"
-#include "v8/include/v8.h"
+#include "v8/include/v8-context.h"
+#include "v8/include/v8-local-handle.h"
class CFXJS_Engine;
diff --git a/testing/fuzzers/pdf_formcalc_context_fuzzer.cc b/testing/fuzzers/pdf_formcalc_context_fuzzer.cc
index edcc75d..993492e 100644
--- a/testing/fuzzers/pdf_formcalc_context_fuzzer.cc
+++ b/testing/fuzzers/pdf_formcalc_context_fuzzer.cc
@@ -13,7 +13,6 @@
#include "fxjs/xfa/cfxjse_value.h"
#include "public/fpdf_formfill.h"
#include "testing/fuzzers/pdfium_fuzzer_helper.h"
-#include "v8/include/v8.h"
#include "xfa/fxfa/cxfa_eventparam.h"
namespace {
diff --git a/testing/fuzzers/pdf_fuzzer_init_public.cc b/testing/fuzzers/pdf_fuzzer_init_public.cc
index e9ebe69..a809d35 100644
--- a/testing/fuzzers/pdf_fuzzer_init_public.cc
+++ b/testing/fuzzers/pdf_fuzzer_init_public.cc
@@ -13,8 +13,11 @@
#ifdef PDF_ENABLE_V8
#include "testing/free_deleter.h"
#include "testing/v8_initializer.h"
+#include "v8/include/v8-platform.h"
#ifdef PDF_ENABLE_XFA
#include "testing/fuzzers/xfa_process_state.h"
+#include "v8/include/v8-array-buffer.h"
+#include "v8/include/v8-isolate.h"
#endif // PDF_ENABLE_XFA
#endif // PDF_ENABLE_V8
diff --git a/testing/fuzzers/pdf_fuzzer_init_public.h b/testing/fuzzers/pdf_fuzzer_init_public.h
index be7348d..f4d1c4e 100644
--- a/testing/fuzzers/pdf_fuzzer_init_public.h
+++ b/testing/fuzzers/pdf_fuzzer_init_public.h
@@ -12,12 +12,19 @@
#ifdef PDF_ENABLE_V8
#include "fxjs/cfx_v8.h"
-#include "v8/include/v8-platform.h"
-#include "v8/include/v8.h"
+#include "v8/include/v8-array-buffer.h"
+#include "v8/include/v8-snapshot.h"
#endif // PDF_ENABLE_V8
class XFAProcessState;
+#ifdef PDF_ENABLE_V8
+namespace v8 {
+class Isolate;
+class Platform;
+} // namespace v8
+#endif // PDF_ENABLE_V8
+
// Initializes the library once for all runs of the fuzzer.
class PDFFuzzerInitPublic {
public:
diff --git a/testing/fxv8_unittest.cpp b/testing/fxv8_unittest.cpp
index 4be2139..9a825f1 100644
--- a/testing/fxv8_unittest.cpp
+++ b/testing/fxv8_unittest.cpp
@@ -7,7 +7,7 @@
#include <memory>
#include "fxjs/cfx_v8_array_buffer_allocator.h"
-#include "v8/include/v8.h"
+#include "v8/include/v8-isolate.h"
void FXV8UnitTest::V8IsolateDeleter::operator()(v8::Isolate* ptr) const {
ptr->Dispose();
diff --git a/testing/unit_test_main.cpp b/testing/unit_test_main.cpp
index 5c42b39..fd2ea9b 100644
--- a/testing/unit_test_main.cpp
+++ b/testing/unit_test_main.cpp
@@ -9,8 +9,6 @@
#ifdef PDF_ENABLE_V8
#include "testing/v8_test_environment.h"
-#include "v8/include/v8-platform.h"
-#include "v8/include/v8.h"
#ifdef PDF_ENABLE_XFA
#include "testing/xfa_test_environment.h"
#endif // PDF_ENABLE_XFA
diff --git a/testing/v8_initializer.cpp b/testing/v8_initializer.cpp
index d789278..bf672bf 100644
--- a/testing/v8_initializer.cpp
+++ b/testing/v8_initializer.cpp
@@ -11,7 +11,8 @@
#include "testing/utils/path_service.h"
#include "third_party/base/numerics/safe_conversions.h"
#include "v8/include/libplatform/libplatform.h"
-#include "v8/include/v8.h"
+#include "v8/include/v8-initialization.h"
+#include "v8/include/v8-snapshot.h"
#ifdef PDF_ENABLE_XFA
#include "v8/include/cppgc/platform.h"
diff --git a/testing/v8_test_environment.cpp b/testing/v8_test_environment.cpp
index da8c7a8..ad91d3d 100644
--- a/testing/v8_test_environment.cpp
+++ b/testing/v8_test_environment.cpp
@@ -11,8 +11,9 @@
#include "testing/v8_initializer.h"
#include "third_party/base/check.h"
#include "v8/include/libplatform/libplatform.h"
+#include "v8/include/v8-isolate.h"
#include "v8/include/v8-platform.h"
-#include "v8/include/v8.h"
+#include "v8/include/v8-snapshot.h"
namespace {
diff --git a/testing/xfa_js_embedder_test.cpp b/testing/xfa_js_embedder_test.cpp
index b15f8f4..475e984 100644
--- a/testing/xfa_js_embedder_test.cpp
+++ b/testing/xfa_js_embedder_test.cpp
@@ -15,6 +15,9 @@
#include "fxjs/xfa/cfxjse_value.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/base/check_op.h"
+#include "v8/include/v8-container.h"
+#include "v8/include/v8-local-handle.h"
+#include "v8/include/v8-value.h"
XFAJSEmbedderTest::XFAJSEmbedderTest() = default;
diff --git a/testing/xfa_js_embedder_test.h b/testing/xfa_js_embedder_test.h
index 58a8fcf..96e292f 100644
--- a/testing/xfa_js_embedder_test.h
+++ b/testing/xfa_js_embedder_test.h
@@ -9,7 +9,9 @@
#include "core/fxcrt/string_view_template.h"
#include "testing/js_embedder_test.h"
-#include "v8/include/v8.h"
+#include "v8/include/v8-local-handle.h"
+#include "v8/include/v8-persistent-handle.h"
+#include "v8/include/v8-value.h"
class CFXJSE_Engine;
class CXFA_Document;