diff options
Diffstat (limited to 'fpdfsdk/include/javascript')
-rw-r--r-- | fpdfsdk/include/javascript/IJavaScript.h | 2 | ||||
-rw-r--r-- | fpdfsdk/include/javascript/JS_Context.h | 2 | ||||
-rw-r--r-- | fpdfsdk/include/javascript/JS_Define.h | 56 | ||||
-rw-r--r-- | fpdfsdk/include/javascript/JS_GlobalData.h | 1 | ||||
-rw-r--r-- | fpdfsdk/include/javascript/JS_Object.h | 15 | ||||
-rw-r--r-- | fpdfsdk/include/javascript/JS_Runtime.h | 16 | ||||
-rw-r--r-- | fpdfsdk/include/javascript/JavaScript.h | 1 |
7 files changed, 41 insertions, 52 deletions
diff --git a/fpdfsdk/include/javascript/IJavaScript.h b/fpdfsdk/include/javascript/IJavaScript.h index 7633bbb486..7754537af2 100644 --- a/fpdfsdk/include/javascript/IJavaScript.h +++ b/fpdfsdk/include/javascript/IJavaScript.h @@ -88,6 +88,8 @@ public: virtual void Exit() = 0; virtual void Enter() = 0; virtual FX_BOOL IsEntered() = 0; + virtual FX_BOOL GetHValueByName(FX_BSTR utf8Name, FXJSE_HVALUE hValue) = 0; + virtual FX_BOOL SetHValueByName(FX_BSTR utf8Name, FXJSE_HVALUE hValue) = 0; }; class CPDFDoc_Environment; diff --git a/fpdfsdk/include/javascript/JS_Context.h b/fpdfsdk/include/javascript/JS_Context.h index 806808651d..adb28cdaed 100644 --- a/fpdfsdk/include/javascript/JS_Context.h +++ b/fpdfsdk/include/javascript/JS_Context.h @@ -74,7 +74,7 @@ public: FX_BOOL IsMsgBoxEnabled() const {return m_bMsgBoxEnable;} public: - CPDFDoc_Environment* GetReaderApp(); + CPDFDoc_Environment* GetReaderApp(); CJS_Runtime* GetJSRuntime(){return m_pRuntime;} FX_BOOL DoJob(int nMode, const CFX_WideString& script, CFX_WideString& info); diff --git a/fpdfsdk/include/javascript/JS_Define.h b/fpdfsdk/include/javascript/JS_Define.h index 108c1e23ee..1798e01591 100644 --- a/fpdfsdk/include/javascript/JS_Define.h +++ b/fpdfsdk/include/javascript/JS_Define.h @@ -93,11 +93,8 @@ typedef CFX_WideString JS_ErrorString; {\ v8::Isolate* isolate = info.GetIsolate();\ v8::Local<v8::Context> context = isolate->GetCurrentContext();\ - v8::Local<v8::Value> v = context->GetEmbedderData(1);\ - ASSERT(!v.IsEmpty());\ - if(v.IsEmpty()) return;\ - v8::Handle<v8::External> field = v8::Handle<v8::External>::Cast(v);\ - IFXJS_Runtime* pRuntime = (IFXJS_Runtime*)field->Value();\ + IFXJS_Runtime* pRuntime = (IFXJS_Runtime*)isolate->GetData(2);\ + if (pRuntime == NULL) return;\ IFXJS_Context* cc = pRuntime->GetCurrentContext();\ CJS_PropValue value(isolate);\ value.StartGetting();\ @@ -129,11 +126,8 @@ typedef CFX_WideString JS_ErrorString; {\ v8::Isolate* isolate = info.GetIsolate();\ v8::Local<v8::Context> context = isolate->GetCurrentContext();\ - v8::Local<v8::Value> v = context->GetEmbedderData(1);\ - ASSERT(!v.IsEmpty());\ - if(v.IsEmpty()) return;\ - v8::Handle<v8::External> field = v8::Handle<v8::External>::Cast(v);\ - IFXJS_Runtime* pRuntime = (IFXJS_Runtime*)field->Value();\ + IFXJS_Runtime* pRuntime = (IFXJS_Runtime*)isolate->GetData(2);\ + if (pRuntime == NULL) return;\ IFXJS_Context* cc = pRuntime->GetCurrentContext();\ CJS_PropValue propValue(CJS_Value(isolate,value,VT_unknown));\ propValue.StartSetting();\ @@ -170,11 +164,8 @@ JS_STATIC_PROP_SET(prop_name, class_name) {\ v8::Isolate* isolate = info.GetIsolate();\ v8::Local<v8::Context> context = isolate->GetCurrentContext();\ - v8::Local<v8::Value> v = context->GetEmbedderData(1);\ - ASSERT(!v.IsEmpty());\ - if(v.IsEmpty()) return;\ - v8::Handle<v8::External> field = v8::Handle<v8::External>::Cast(v);\ - IFXJS_Runtime* pRuntime = (IFXJS_Runtime*)field->Value();\ + IFXJS_Runtime* pRuntime = (IFXJS_Runtime*)isolate->GetData(2);\ + if (pRuntime == NULL) return;\ IFXJS_Context* cc = pRuntime->GetCurrentContext();\ CJS_Parameters parameters;\ for (unsigned int i = 0; i<(unsigned int)info.Length(); i++)\ @@ -359,11 +350,8 @@ const wchar_t * js_class_name::m_pClassName = JS_WIDESTRING(class_name);\ {\ v8::Isolate* isolate = info.GetIsolate();\ v8::Local<v8::Context> context = isolate->GetCurrentContext();\ - v8::Local<v8::Value> v = context->GetEmbedderData(1);\ - ASSERT(!v.IsEmpty());\ - if(v.IsEmpty()) return;\ - v8::Handle<v8::External> field = v8::Handle<v8::External>::Cast(v);\ - IFXJS_Runtime* pRuntime = (IFXJS_Runtime*)field->Value();\ + IFXJS_Runtime* pRuntime = (IFXJS_Runtime*)isolate->GetData(2);\ + if (pRuntime == NULL) return;\ IFXJS_Context* cc = pRuntime->GetCurrentContext();\ v8::String::Utf8Value utf8_value(property);\ CFX_WideString propname = CFX_WideString::FromUTF8(*utf8_value, utf8_value.length());\ @@ -397,11 +385,8 @@ const wchar_t * js_class_name::m_pClassName = JS_WIDESTRING(class_name);\ {\ v8::Isolate* isolate = info.GetIsolate();\ v8::Local<v8::Context> context = isolate->GetCurrentContext();\ - v8::Local<v8::Value> v = context->GetEmbedderData(1);\ - ASSERT(!v.IsEmpty());\ - if(v.IsEmpty()) return;\ - v8::Handle<v8::External> field = v8::Handle<v8::External>::Cast(v);\ - IFXJS_Runtime* pRuntime = (IFXJS_Runtime*)field->Value();\ + IFXJS_Runtime* pRuntime = (IFXJS_Runtime*)isolate->GetData(2);\ + if (pRuntime == NULL) return;\ IFXJS_Context* cc = pRuntime->GetCurrentContext();\ v8::String::Utf8Value utf8_value(property);\ CFX_WideString propname = CFX_WideString::FromUTF8(*utf8_value, utf8_value.length());\ @@ -434,11 +419,8 @@ const wchar_t * js_class_name::m_pClassName = JS_WIDESTRING(class_name);\ {\ v8::Isolate* isolate = info.GetIsolate();\ v8::Local<v8::Context> context = isolate->GetCurrentContext();\ - v8::Local<v8::Value> v = context->GetEmbedderData(1);\ - ASSERT(!v.IsEmpty());\ - if(v.IsEmpty()) return;\ - v8::Handle<v8::External> field = v8::Handle<v8::External>::Cast(v);\ - IFXJS_Runtime* pRuntime = (IFXJS_Runtime*)field->Value();\ + IFXJS_Runtime* pRuntime = (IFXJS_Runtime*)isolate->GetData(2);\ + if (pRuntime == NULL) return;\ IFXJS_Context* cc = pRuntime->GetCurrentContext();\ v8::String::Utf8Value utf8_value(property);\ CFX_WideString propname = CFX_WideString::FromUTF8(*utf8_value, utf8_value.length());\ @@ -525,11 +507,8 @@ void js_class_name::GetMethods(JSMethodSpec*& pMethods, int& nSize)\ {\ v8::Isolate* isolate = info.GetIsolate();\ v8::Local<v8::Context> context = isolate->GetCurrentContext();\ - v8::Local<v8::Value> v = context->GetEmbedderData(1);\ - ASSERT(!v.IsEmpty());\ - if(v.IsEmpty()) return;\ - v8::Handle<v8::External> field = v8::Handle<v8::External>::Cast(v);\ - IFXJS_Runtime* pRuntime = (IFXJS_Runtime*)field->Value();\ + IFXJS_Runtime* pRuntime = (IFXJS_Runtime*)isolate->GetData(2);\ + if (pRuntime == NULL) return;\ IFXJS_Context* cc = pRuntime->GetCurrentContext();\ CJS_Parameters parameters;\ for (unsigned int i = 0; i<(unsigned int)info.Length(); i++)\ @@ -568,11 +547,8 @@ static void fun_name##_static(JS_METHOD_ARGS)\ {\ v8::Isolate* isolate = info.GetIsolate();\ v8::Local<v8::Context> context = isolate->GetCurrentContext();\ - v8::Local<v8::Value> v = context->GetEmbedderData(1);\ - ASSERT(!v.IsEmpty());\ - if(v.IsEmpty()) return;\ - v8::Handle<v8::External> field = v8::Handle<v8::External>::Cast(v);\ - IFXJS_Runtime* pRuntime = (IFXJS_Runtime*)field->Value();\ + IFXJS_Runtime* pRuntime = (IFXJS_Runtime*)isolate->GetData(2);\ + if (pRuntime == NULL) return;\ IFXJS_Context* cc = pRuntime->GetCurrentContext();\ CJS_Parameters parameters;\ for (unsigned int i = 0; i<(unsigned int)info.Length(); i++)\ diff --git a/fpdfsdk/include/javascript/JS_GlobalData.h b/fpdfsdk/include/javascript/JS_GlobalData.h index 8eee158a00..c54d7b550d 100644 --- a/fpdfsdk/include/javascript/JS_GlobalData.h +++ b/fpdfsdk/include/javascript/JS_GlobalData.h @@ -91,6 +91,7 @@ private: private: CFX_ArrayTemplate<CJS_GlobalData_Element*> m_arrayGlobalData; CFX_WideString m_sFilePath; + CPDFDoc_Environment* m_pApp; }; #endif //_JS_GLOBALDATA_H_ diff --git a/fpdfsdk/include/javascript/JS_Object.h b/fpdfsdk/include/javascript/JS_Object.h index a6dac5d2a3..ca6f4a1d11 100644 --- a/fpdfsdk/include/javascript/JS_Object.h +++ b/fpdfsdk/include/javascript/JS_Object.h @@ -26,7 +26,7 @@ public: operator CJS_Object* (){return m_pJSObject;}; CPDFSDK_PageView * JSGetPageView(IFXJS_Context* cc); - int MsgBox(CPDFDoc_Environment* pApp, CPDFSDK_PageView* pPageView, FX_LPCWSTR swMsg, FX_LPCWSTR swTitle = NULL, FX_UINT nType = 0, FX_UINT nIcon = 0); + int MsgBox(CPDFDoc_Environment * pApp, CPDFSDK_PageView* pPageView, FX_LPCWSTR swMsg, FX_LPCWSTR swTitle = NULL, FX_UINT nType = 0, FX_UINT nIcon = 0); void Alert(CJS_Context* pContext, FX_LPCWSTR swMsg); FX_BOOL IsSafeMode(IFXJS_Context* cc); @@ -56,7 +56,7 @@ public: CJS_EmbedObj * GetEmbedObject(){return m_pEmbedObj;}; static CPDFSDK_PageView * JSGetPageView(IFXJS_Context* cc); - static int MsgBox(CPDFDoc_Environment* pApp, CPDFSDK_PageView* pPageView, FX_LPCWSTR swMsg, FX_LPCWSTR swTitle = NULL, FX_UINT nType = 0,FX_UINT nIcon = 0); + static int MsgBox(CPDFDoc_Environment * pApp, CPDFSDK_PageView* pPageView, FX_LPCWSTR swMsg, FX_LPCWSTR swTitle = NULL, FX_UINT nType = 0,FX_UINT nIcon = 0); static void Alert(CJS_Context* pContext, FX_LPCWSTR swMsg); v8::Isolate* GetIsolate() {return m_pIsolate;} @@ -164,7 +164,7 @@ class CJS_Runtime; class CJS_Timer { public: - CJS_Timer(CJS_EmbedObj * pObj,CPDFDoc_Environment* pApp): + CJS_Timer(CJS_EmbedObj * pObj, CPDFDoc_Environment* pApp): m_nTimerID(0), m_pEmbedObj(pObj), m_bProcessing(FALSE), @@ -197,6 +197,11 @@ public: { if (m_nTimerID) { + if (m_pApp == NULL) { + m_sTimeMap.RemoveAt(m_nTimerID); + m_nTimerID = 0; + return; + } IFX_SystemHandler* pHandler = m_pApp->GetSysHandler(); pHandler->KillTimer(m_nTimerID); m_sTimeMap.RemoveAt(m_nTimerID); @@ -277,8 +282,8 @@ private: FX_BOOL m_bProcessing; //data - FX_DWORD m_dwStartTime; - FX_DWORD m_dwTimeOut; + FX_DWORD m_dwStartTime; + FX_DWORD m_dwTimeOut; FX_DWORD m_dwElapse; CJS_Runtime* m_pRuntime; CFX_WideString m_swJScript; diff --git a/fpdfsdk/include/javascript/JS_Runtime.h b/fpdfsdk/include/javascript/JS_Runtime.h index 0a195f132c..217a985869 100644 --- a/fpdfsdk/include/javascript/JS_Runtime.h +++ b/fpdfsdk/include/javascript/JS_Runtime.h @@ -37,7 +37,7 @@ public: virtual void Enter(); virtual FX_BOOL IsEntered(); - CPDFDoc_Environment * GetReaderApp(){return m_pApp;} + CPDFDoc_Environment * GetReaderApp(){return m_pApp;} FX_BOOL InitJSObjects(); @@ -50,19 +50,23 @@ public: FX_BOOL IsBlocking(){return m_bBlocking;} operator IJS_Runtime*() {return (IJS_Runtime*)m_isolate;} - v8::Isolate* GetIsolate(){return m_isolate;}; + v8::Isolate* GetIsolate(){return m_isolate;}; void SetIsolate(v8::Isolate* isolate){m_isolate = isolate;} - v8::Handle<v8::Context> NewJSContext(); + v8::Handle<v8::Context> NewJSContext(); + + + virtual FX_BOOL GetHValueByName(FX_BSTR utf8Name, FXJSE_HVALUE hValue); + virtual FX_BOOL SetHValueByName(FX_BSTR utf8Name, FXJSE_HVALUE hValue); protected: CFX_ArrayTemplate<CJS_Context *> m_ContextArray; - CPDFDoc_Environment * m_pApp; + CPDFDoc_Environment * m_pApp; CPDFSDK_Document * m_pDocument; FX_BOOL m_bBlocking; CJS_FieldEvent* m_pFieldEventPath; - v8::Isolate* m_isolate; - v8::Persistent<v8::Context> m_context; + v8::Isolate* m_isolate; + v8::Persistent<v8::Context> m_context; FX_BOOL m_bRegistered; }; diff --git a/fpdfsdk/include/javascript/JavaScript.h b/fpdfsdk/include/javascript/JavaScript.h index 166472b61e..ca5922e074 100644 --- a/fpdfsdk/include/javascript/JavaScript.h +++ b/fpdfsdk/include/javascript/JavaScript.h @@ -28,6 +28,7 @@ #include "../fxedit/fx_edit.h" #include "../pdfwindow/IPDFWindow.h" #include "../fsdk_mgr.h" +#include "../fpdfxfa/fpdfxfa_app.h" #include <string> |