diff options
author | Tom Sepez <tsepez@chromium.org> | 2018-02-09 19:08:59 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-02-09 19:08:59 +0000 |
commit | b7c7df6a979d16d926814f601246234bf65adbc2 (patch) | |
tree | c25ce661a438bb14ff7bca5e288a0fe6bdab28b9 | |
parent | 3f8ee5e6b4e42fc77b4716b23ccd00840e24e250 (diff) | |
download | pdfium-b7c7df6a979d16d926814f601246234bf65adbc2.tar.xz |
Rename fxjs_v8.{h,cpp} to cfxjs_engine.{h,cpp}
Place the template map definitions entirely in .cpp file.
Change-Id: I2643f1b99f5582b69aa985857c4aa6f9b5ab57c8
Reviewed-on: https://pdfium-review.googlesource.com/26150
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: dsinclair <dsinclair@chromium.org>
-rw-r--r-- | BUILD.gn | 6 | ||||
-rw-r--r-- | fxjs/JS_Define.h | 2 | ||||
-rw-r--r-- | fxjs/cfxjs_engine.cpp (renamed from fxjs/fxjs_v8.cpp) | 46 | ||||
-rw-r--r-- | fxjs/cfxjs_engine.h (renamed from fxjs/fxjs_v8.h) | 61 | ||||
-rw-r--r-- | fxjs/cfxjs_engine_embeddertest.cpp (renamed from fxjs/fxjs_v8_embeddertest.cpp) | 8 | ||||
-rw-r--r-- | fxjs/cfxjse_context.cpp | 2 | ||||
-rw-r--r-- | fxjs/cfxjse_engine.cpp | 2 | ||||
-rw-r--r-- | fxjs/cfxjse_runtimedata.cpp | 2 | ||||
-rw-r--r-- | fxjs/cjs_object.h | 2 | ||||
-rw-r--r-- | fxjs/cjs_return.h | 2 | ||||
-rw-r--r-- | fxjs/cjs_runtime.h | 2 | ||||
-rw-r--r-- | testing/js_embedder_test.h | 2 | ||||
-rw-r--r-- | testing/xfa_js_embedder_test.h | 2 |
13 files changed, 71 insertions, 68 deletions
@@ -1203,6 +1203,8 @@ jumbo_static_library("fxjs") { "fxjs/JS_Define.h", "fxjs/cfx_v8.cpp", "fxjs/cfx_v8.h", + "fxjs/cfxjs_engine.cpp", + "fxjs/cfxjs_engine.h", "fxjs/cjs_annot.cpp", "fxjs/cjs_annot.h", "fxjs/cjs_app.cpp", @@ -1271,8 +1273,6 @@ jumbo_static_library("fxjs") { "fxjs/cjs_util.h", "fxjs/cjs_zoomtype.cpp", "fxjs/cjs_zoomtype.h", - "fxjs/fxjs_v8.cpp", - "fxjs/fxjs_v8.h", "fxjs/global_timer.cpp", "fxjs/global_timer.h", "fxjs/js_resources.cpp", @@ -3028,8 +3028,8 @@ test("pdfium_embeddertests") { if (pdf_enable_v8) { sources += [ + "fxjs/cfxjs_engine_embeddertest.cpp", "fxjs/cjs_publicmethods_embeddertest.cpp", - "fxjs/fxjs_v8_embeddertest.cpp", "testing/js_embedder_test.cpp", "testing/js_embedder_test.h", ] diff --git a/fxjs/JS_Define.h b/fxjs/JS_Define.h index 58c094fe37..d9ab139374 100644 --- a/fxjs/JS_Define.h +++ b/fxjs/JS_Define.h @@ -10,9 +10,9 @@ #include <utility> #include <vector> +#include "fxjs/cfxjs_engine.h" #include "fxjs/cjs_object.h" #include "fxjs/cjs_return.h" -#include "fxjs/fxjs_v8.h" #include "fxjs/js_resources.h" #include "third_party/base/ptr_util.h" diff --git a/fxjs/fxjs_v8.cpp b/fxjs/cfxjs_engine.cpp index f29dca6807..c773a16324 100644 --- a/fxjs/fxjs_v8.cpp +++ b/fxjs/cfxjs_engine.cpp @@ -4,7 +4,7 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#include "fxjs/fxjs_v8.h" +#include "fxjs/cfxjs_engine.h" #include <memory> #include <utility> @@ -25,6 +25,50 @@ static CFX_V8ArrayBufferAllocator* g_arrayBufferAllocator = nullptr; static v8::Global<v8::ObjectTemplate>* g_DefaultGlobalObjectTemplate = nullptr; static wchar_t kPerObjectDataTag[] = L"CFXJS_PerObjectData"; +// Global weak map to save dynamic objects. +class V8TemplateMapTraits : public v8::StdMapTraits<void*, v8::Object> { + public: + typedef v8::GlobalValueMap<void*, v8::Object, V8TemplateMapTraits> MapType; + typedef void WeakCallbackDataType; + + static WeakCallbackDataType* + WeakCallbackParameter(MapType* map, void* key, v8::Local<v8::Object> value) { + return key; + } + static MapType* MapFromWeakCallbackInfo( + const v8::WeakCallbackInfo<WeakCallbackDataType>&); + + static void* KeyFromWeakCallbackInfo( + const v8::WeakCallbackInfo<WeakCallbackDataType>& data) { + return data.GetParameter(); + } + static const v8::PersistentContainerCallbackType kCallbackType = + v8::kWeakWithInternalFields; + static void DisposeWeak( + const v8::WeakCallbackInfo<WeakCallbackDataType>& data) {} + static void OnWeakCallback( + const v8::WeakCallbackInfo<WeakCallbackDataType>& data) {} + static void Dispose(v8::Isolate* isolate, + v8::Global<v8::Object> value, + void* key); + static void DisposeCallbackData(WeakCallbackDataType* callbackData) {} +}; + +class V8TemplateMap { + public: + typedef v8::GlobalValueMap<void*, v8::Object, V8TemplateMapTraits> MapType; + + explicit V8TemplateMap(v8::Isolate* isolate); + ~V8TemplateMap(); + + void set(void* key, v8::Local<v8::Object> handle); + + friend class V8TemplateMapTraits; + + private: + MapType m_map; +}; + class CFXJS_PerObjectData { public: explicit CFXJS_PerObjectData(int nObjDefID) : m_ObjDefID(nObjDefID) {} diff --git a/fxjs/fxjs_v8.h b/fxjs/cfxjs_engine.h index 9ef746018c..5f883f7e4a 100644 --- a/fxjs/fxjs_v8.h +++ b/fxjs/cfxjs_engine.h @@ -4,15 +4,15 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -// FXJS_V8 is a layer that makes it easier to define native objects in V8, but -// has no knowledge of PDF-specific native objects. It could in theory be used -// to implement other sets of native objects. +// CFXJS_ENGINE is a layer that makes it easier to define native objects in V8, +// but has no knowledge of PDF-specific native objects. It could in theory be +// used to implement other sets of native objects. // PDFium code should include this file rather than including V8 headers // directly. -#ifndef FXJS_FXJS_V8_H_ -#define FXJS_FXJS_V8_H_ +#ifndef FXJS_CFXJS_ENGINE_H_ +#define FXJS_CFXJS_ENGINE_H_ #include <functional> #include <map> @@ -25,14 +25,15 @@ #include "v8/include/v8.h" #ifdef PDF_ENABLE_XFA -// FXJS_V8 doesn't interpret this class, it is just passed along to XFA. +// CFXJS_ENGINE doesn't interpret this class, it is just passed along to XFA. class CFXJSE_RuntimeData; #endif // PDF_ENABLE_XFA class CFXJS_ObjDefinition; class CJS_Object; +class V8TemplateMap; -// FXJS_V8 places no restrictions on this class; it merely passes it +// CFXJS_ENGINE places no restrictions on this class; it merely passes it // on to caller-provided methods. class IJS_EventContext; // A description of the event that caused JS execution. @@ -48,50 +49,6 @@ struct FXJSErr { unsigned linnum; }; -// Global weak map to save dynamic objects. -class V8TemplateMapTraits : public v8::StdMapTraits<void*, v8::Object> { - public: - typedef v8::GlobalValueMap<void*, v8::Object, V8TemplateMapTraits> MapType; - typedef void WeakCallbackDataType; - - static WeakCallbackDataType* - WeakCallbackParameter(MapType* map, void* key, v8::Local<v8::Object> value) { - return key; - } - static MapType* MapFromWeakCallbackInfo( - const v8::WeakCallbackInfo<WeakCallbackDataType>&); - - static void* KeyFromWeakCallbackInfo( - const v8::WeakCallbackInfo<WeakCallbackDataType>& data) { - return data.GetParameter(); - } - static const v8::PersistentContainerCallbackType kCallbackType = - v8::kWeakWithInternalFields; - static void DisposeWeak( - const v8::WeakCallbackInfo<WeakCallbackDataType>& data) {} - static void OnWeakCallback( - const v8::WeakCallbackInfo<WeakCallbackDataType>& data) {} - static void Dispose(v8::Isolate* isolate, - v8::Global<v8::Object> value, - void* key); - static void DisposeCallbackData(WeakCallbackDataType* callbackData) {} -}; - -class V8TemplateMap { - public: - typedef v8::GlobalValueMap<void*, v8::Object, V8TemplateMapTraits> MapType; - - explicit V8TemplateMap(v8::Isolate* isolate); - ~V8TemplateMap(); - - void set(void* key, v8::Local<v8::Object> handle); - - friend class V8TemplateMapTraits; - - private: - MapType m_map; -}; - class FXJS_PerIsolateData { public: ~FXJS_PerIsolateData(); @@ -197,4 +154,4 @@ class CFXJS_Engine : public CFX_V8 { std::map<WideString, v8::Global<v8::Array>> m_ConstArrays; }; -#endif // FXJS_FXJS_V8_H_ +#endif // FXJS_CFXJS_ENGINE_H_ diff --git a/fxjs/fxjs_v8_embeddertest.cpp b/fxjs/cfxjs_engine_embeddertest.cpp index 77bea86fe1..f25bfbe060 100644 --- a/fxjs/fxjs_v8_embeddertest.cpp +++ b/fxjs/cfxjs_engine_embeddertest.cpp @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "fxjs/cfxjs_engine.h" + #include "testing/gtest/include/gtest/gtest.h" #include "testing/js_embedder_test.h" @@ -17,7 +19,7 @@ const wchar_t kScript2[] = L"fred = 8"; } // namespace -class FXJSV8EmbedderTest : public JSEmbedderTest { +class CFXJSEngineEmbedderTest : public JSEmbedderTest { public: void ExecuteInCurrentContext(const WideString& script) { FXJSErr error; @@ -32,7 +34,7 @@ class FXJSV8EmbedderTest : public JSEmbedderTest { } }; -TEST_F(FXJSV8EmbedderTest, Getters) { +TEST_F(CFXJSEngineEmbedderTest, Getters) { v8::Isolate::Scope isolate_scope(isolate()); v8::HandleScope handle_scope(isolate()); v8::Context::Scope context_scope(GetV8Context()); @@ -41,7 +43,7 @@ TEST_F(FXJSV8EmbedderTest, Getters) { CheckAssignmentInCurrentContext(kExpected1); } -TEST_F(FXJSV8EmbedderTest, MultipleEngines) { +TEST_F(CFXJSEngineEmbedderTest, MultipleEngines) { v8::Isolate::Scope isolate_scope(isolate()); v8::HandleScope handle_scope(isolate()); diff --git a/fxjs/cfxjse_context.cpp b/fxjs/cfxjse_context.cpp index 61c330d687..d12758de2a 100644 --- a/fxjs/cfxjse_context.cpp +++ b/fxjs/cfxjse_context.cpp @@ -8,9 +8,9 @@ #include <utility> +#include "fxjs/cfxjs_engine.h" #include "fxjs/cfxjse_class.h" #include "fxjs/cfxjse_value.h" -#include "fxjs/fxjs_v8.h" #include "third_party/base/ptr_util.h" namespace { diff --git a/fxjs/cfxjse_engine.cpp b/fxjs/cfxjse_engine.cpp index d5a1511a54..47911f8a2d 100644 --- a/fxjs/cfxjse_engine.cpp +++ b/fxjs/cfxjse_engine.cpp @@ -11,10 +11,10 @@ #include "core/fxcrt/autorestorer.h" #include "core/fxcrt/cfx_widetextbuf.h" #include "core/fxcrt/fx_extension.h" +#include "fxjs/cfxjs_engine.h" #include "fxjs/cfxjse_class.h" #include "fxjs/cfxjse_resolveprocessor.h" #include "fxjs/cfxjse_value.h" -#include "fxjs/fxjs_v8.h" #include "third_party/base/ptr_util.h" #include "third_party/base/stl_util.h" #include "xfa/fxfa/cxfa_eventparam.h" diff --git a/fxjs/cfxjse_runtimedata.cpp b/fxjs/cfxjse_runtimedata.cpp index b5c2de9297..0153e81a6c 100644 --- a/fxjs/cfxjse_runtimedata.cpp +++ b/fxjs/cfxjse_runtimedata.cpp @@ -8,8 +8,8 @@ #include <utility> +#include "fxjs/cfxjs_engine.h" #include "fxjs/cfxjse_isolatetracker.h" -#include "fxjs/fxjs_v8.h" CFXJSE_RuntimeData::CFXJSE_RuntimeData(v8::Isolate* pIsolate) : m_pIsolate(pIsolate) {} diff --git a/fxjs/cjs_object.h b/fxjs/cjs_object.h index 22a5e1625a..7b26fba527 100644 --- a/fxjs/cjs_object.h +++ b/fxjs/cjs_object.h @@ -11,8 +11,8 @@ #include <utility> #include "fpdfsdk/fsdk_define.h" +#include "fxjs/cfxjs_engine.h" #include "fxjs/cjs_runtime.h" -#include "fxjs/fxjs_v8.h" struct JSConstSpec { enum Type { Number = 0, String = 1 }; diff --git a/fxjs/cjs_return.h b/fxjs/cjs_return.h index 61c5778cda..37c91caafe 100644 --- a/fxjs/cjs_return.h +++ b/fxjs/cjs_return.h @@ -7,7 +7,7 @@ #ifndef FXJS_CJS_RETURN_H_ #define FXJS_CJS_RETURN_H_ -#include "fxjs/fxjs_v8.h" +#include "fxjs/cfxjs_engine.h" class CJS_Return { public: diff --git a/fxjs/cjs_runtime.h b/fxjs/cjs_runtime.h index 9d0d47fa81..0aab84828f 100644 --- a/fxjs/cjs_runtime.h +++ b/fxjs/cjs_runtime.h @@ -15,8 +15,8 @@ #include "core/fxcrt/observable.h" #include "fpdfsdk/cpdfsdk_formfillenvironment.h" +#include "fxjs/cfxjs_engine.h" #include "fxjs/cjs_eventhandler.h" -#include "fxjs/fxjs_v8.h" #include "fxjs/ijs_runtime.h" class CJS_EventContext; diff --git a/testing/js_embedder_test.h b/testing/js_embedder_test.h index 4bd5433b19..44245e3024 100644 --- a/testing/js_embedder_test.h +++ b/testing/js_embedder_test.h @@ -7,7 +7,7 @@ #include <memory> -#include "fxjs/fxjs_v8.h" +#include "fxjs/cfxjs_engine.h" #include "testing/embedder_test.h" class JSEmbedderTest : public EmbedderTest { diff --git a/testing/xfa_js_embedder_test.h b/testing/xfa_js_embedder_test.h index 44840b31eb..0ddb02ce70 100644 --- a/testing/xfa_js_embedder_test.h +++ b/testing/xfa_js_embedder_test.h @@ -8,8 +8,8 @@ #include <memory> #include <string> +#include "fxjs/cfxjs_engine.h" #include "fxjs/cfxjse_value.h" -#include "fxjs/fxjs_v8.h" #include "testing/embedder_test.h" #include "xfa/fxfa/parser/cxfa_document.h" #include "xfa/fxfa/parser/cxfa_node.h" |