diff options
Diffstat (limited to 'fxjs')
-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 |
10 files changed, 66 insertions, 63 deletions
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; |