diff options
39 files changed, 119 insertions, 188 deletions
@@ -774,7 +774,8 @@ static_library("pdfwindow") { static_library("javascript") { sources = [ - "fpdfsdk/include/javascript/IJavaScript.h", + "fpdfsdk/javascript/ijs_context.h", + "fpdfsdk/javascript/ijs_runtime.h", ] if (pdf_enable_v8) { sources += [ @@ -787,8 +788,6 @@ static_library("javascript") { "fpdfsdk/javascript/Field.h", "fpdfsdk/javascript/Icon.cpp", "fpdfsdk/javascript/Icon.h", - "fpdfsdk/javascript/JS_Context.cpp", - "fpdfsdk/javascript/JS_Context.h", "fpdfsdk/javascript/JS_Define.h", "fpdfsdk/javascript/JS_EventHandler.cpp", "fpdfsdk/javascript/JS_EventHandler.h", @@ -796,14 +795,16 @@ static_library("javascript") { "fpdfsdk/javascript/JS_GlobalData.h", "fpdfsdk/javascript/JS_Object.cpp", "fpdfsdk/javascript/JS_Object.h", - "fpdfsdk/javascript/JS_Runtime.cpp", - "fpdfsdk/javascript/JS_Runtime.h", "fpdfsdk/javascript/JS_Value.cpp", "fpdfsdk/javascript/JS_Value.h", "fpdfsdk/javascript/PublicMethods.cpp", "fpdfsdk/javascript/PublicMethods.h", "fpdfsdk/javascript/app.cpp", "fpdfsdk/javascript/app.h", + "fpdfsdk/javascript/cjs_context.cpp", + "fpdfsdk/javascript/cjs_context.h", + "fpdfsdk/javascript/cjs_runtime.cpp", + "fpdfsdk/javascript/cjs_runtime.h", "fpdfsdk/javascript/color.cpp", "fpdfsdk/javascript/color.h", "fpdfsdk/javascript/console.cpp", diff --git a/fpdfsdk/DEPS b/fpdfsdk/DEPS index 1f188771d9..1383f25c35 100644 --- a/fpdfsdk/DEPS +++ b/fpdfsdk/DEPS @@ -7,7 +7,6 @@ include_rules = [ '+core/fpdfapi/fpdf_parser/include', '+core/fpdfapi/fpdf_render/include', '+core/fxcrt/include', - '+javascript/IJavaScript.h', '+public', '+v8', '+xfa/include', diff --git a/fpdfsdk/fpdfview.cpp b/fpdfsdk/fpdfview.cpp index 3a3449745c..e5a53da739 100644 --- a/fpdfsdk/fpdfview.cpp +++ b/fpdfsdk/fpdfview.cpp @@ -18,7 +18,7 @@ #include "fpdfsdk/include/fsdk_define.h" #include "fpdfsdk/include/fsdk_mgr.h" #include "fpdfsdk/include/fsdk_rendercontext.h" -#include "fpdfsdk/include/javascript/IJavaScript.h" +#include "fpdfsdk/javascript/ijs_runtime.h" #include "public/fpdf_ext.h" #include "public/fpdf_progressive.h" #include "third_party/base/numerics/safe_conversions_impl.h" diff --git a/fpdfsdk/fpdfxfa/fpdfxfa_app.cpp b/fpdfsdk/fpdfxfa/fpdfxfa_app.cpp index cdc1949d46..b52879a25a 100644 --- a/fpdfsdk/fpdfxfa/fpdfxfa_app.cpp +++ b/fpdfsdk/fpdfxfa/fpdfxfa_app.cpp @@ -9,7 +9,6 @@ #include "fpdfsdk/include/fpdfxfa/fpdfxfa_util.h" #include "fpdfsdk/include/fsdk_define.h" #include "fpdfsdk/include/fsdk_mgr.h" -#include "fpdfsdk/include/javascript/IJavaScript.h" #include "public/fpdf_formfill.h" #include "xfa/fxbarcode/include/BC_Library.h" diff --git a/fpdfsdk/fpdfxfa/fpdfxfa_doc.cpp b/fpdfsdk/fpdfxfa/fpdfxfa_doc.cpp index e9c9e61ffc..23efc3321a 100644 --- a/fpdfsdk/fpdfxfa/fpdfxfa_doc.cpp +++ b/fpdfsdk/fpdfxfa/fpdfxfa_doc.cpp @@ -14,7 +14,7 @@ #include "fpdfsdk/include/fpdfxfa/fpdfxfa_util.h" #include "fpdfsdk/include/fsdk_define.h" #include "fpdfsdk/include/fsdk_mgr.h" -#include "fpdfsdk/include/javascript/IJavaScript.h" +#include "fpdfsdk/javascript/ijs_runtime.h" #include "public/fpdf_formfill.h" #define IDS_XFA_Validate_Input \ diff --git a/fpdfsdk/fsdk_actionhandler.cpp b/fpdfsdk/fsdk_actionhandler.cpp index 1977ce5cee..ebcaf354ad 100644 --- a/fpdfsdk/fsdk_actionhandler.cpp +++ b/fpdfsdk/fsdk_actionhandler.cpp @@ -11,7 +11,8 @@ #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" #include "fpdfsdk/include/fsdk_define.h" #include "fpdfsdk/include/fsdk_mgr.h" -#include "fpdfsdk/include/javascript/IJavaScript.h" +#include "fpdfsdk/javascript/ijs_context.h" +#include "fpdfsdk/javascript/ijs_runtime.h" #include "third_party/base/stl_util.h" CPDFSDK_ActionHandler::CPDFSDK_ActionHandler() diff --git a/fpdfsdk/fsdk_baseform.cpp b/fpdfsdk/fsdk_baseform.cpp index 6027eec23d..9b21880d05 100644 --- a/fpdfsdk/fsdk_baseform.cpp +++ b/fpdfsdk/fsdk_baseform.cpp @@ -20,7 +20,8 @@ #include "fpdfsdk/include/fsdk_baseannot.h" #include "fpdfsdk/include/fsdk_define.h" #include "fpdfsdk/include/fsdk_mgr.h" -#include "fpdfsdk/include/javascript/IJavaScript.h" +#include "fpdfsdk/javascript/ijs_context.h" +#include "fpdfsdk/javascript/ijs_runtime.h" #include "fpdfsdk/pdfwindow/PWL_Utils.h" #ifdef PDF_ENABLE_XFA diff --git a/fpdfsdk/fsdk_mgr.cpp b/fpdfsdk/fsdk_mgr.cpp index 83de4e84f9..b318b0a9db 100644 --- a/fpdfsdk/fsdk_mgr.cpp +++ b/fpdfsdk/fsdk_mgr.cpp @@ -14,7 +14,7 @@ #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" #include "fpdfsdk/formfiller/cffl_formfiller.h" #include "fpdfsdk/include/fsdk_define.h" -#include "fpdfsdk/include/javascript/IJavaScript.h" +#include "fpdfsdk/javascript/ijs_runtime.h" #include "public/fpdf_ext.h" #include "third_party/base/stl_util.h" diff --git a/fpdfsdk/include/fsdk_mgr.h b/fpdfsdk/include/fsdk_mgr.h index 3b8c951e0e..4bc5a7f916 100644 --- a/fpdfsdk/include/fsdk_mgr.h +++ b/fpdfsdk/include/fsdk_mgr.h @@ -19,7 +19,6 @@ #include "fpdfsdk/include/fsdk_common.h" #include "fpdfsdk/include/fsdk_define.h" #include "fpdfsdk/include/fx_systemhandler.h" -#include "javascript/IJavaScript.h" #include "public/fpdf_formfill.h" #include "public/fpdf_fwlevent.h" @@ -30,6 +29,7 @@ class CPDFSDK_InterForm; class CPDFSDK_PageView; class CPDFSDK_Widget; class IFX_SystemHandler; +class IJS_Runtime; // NOTE: |bsUTF16LE| must outlive the use of the result. Care must be taken // since modifying the result would impact |bsUTF16LE|. diff --git a/fpdfsdk/include/fxedit/fxet_edit.h b/fpdfsdk/include/fxedit/fxet_edit.h index 6f174a81d1..d3383ac2cd 100644 --- a/fpdfsdk/include/fxedit/fxet_edit.h +++ b/fpdfsdk/include/fxedit/fxet_edit.h @@ -21,8 +21,6 @@ class CFX_Edit_Provider; #define FX_EDIT_IsFloatSmaller(fa, fb) \ (fa < fb && !FX_EDIT_IsFloatEqual(fa, fb)) -/* ------------------------- CFX_Edit_Refresh ---------------------------- */ - enum REFRESH_PLAN_E { RP_ANALYSE, RP_NOANALYSE, RP_OPTIONAL }; enum EDIT_PROPS_E { @@ -165,8 +163,6 @@ class CFX_Edit_Refresh { CFX_Edit_RectArray m_RefreshRects; }; -/* ------------------------- CFX_Edit_Select ---------------------------- */ - class CFX_Edit_Select { public: CFX_Edit_Select() {} @@ -206,8 +202,6 @@ class CFX_Edit_Select { CPVT_WordPlace BeginPos, EndPos; }; -/* ------------------------- CFX_Edit_Undo ---------------------------- */ - class CFX_Edit_Undo { public: explicit CFX_Edit_Undo(int32_t nBufsize); @@ -280,9 +274,6 @@ class CFX_Edit_GroupUndoItem : public IFX_Edit_UndoItem { CFX_ArrayTemplate<CFX_Edit_UndoItem*> m_Items; }; -/* ------------------------- CFX_Edit_UndoItem derived classes - * ---------------------------- */ - class CFXEU_InsertWord : public CFX_Edit_UndoItem { public: CFXEU_InsertWord(CFX_Edit* pEdit, @@ -507,8 +498,6 @@ class CFXEU_SetWordProps : public CFX_Edit_UndoItem { CPVT_WordProps m_NewWordProps; }; -/* ------------------------- CFX_Edit ---------------------------- */ - class CFX_Edit : public IFX_Edit { friend class CFX_Edit_Iterator; friend class CFXEU_InsertWord; @@ -764,8 +753,6 @@ class CFX_Edit : public IFX_Edit { CFX_Edit_GroupUndoItem* m_pGroupUndoItem; }; -/* ------------------------- CFX_Edit_Iterator ---------------------------- */ - class CFX_Edit_Iterator : public IFX_Edit_Iterator { public: CFX_Edit_Iterator(CFX_Edit* pEdit, IPDF_VariableText_Iterator* pVTIterator); diff --git a/fpdfsdk/include/javascript/DEPS b/fpdfsdk/include/javascript/DEPS deleted file mode 100644 index 2846bdc69c..0000000000 --- a/fpdfsdk/include/javascript/DEPS +++ /dev/null @@ -1,3 +0,0 @@ -include_rules = [ - '+xfa/fxjse/include' -] diff --git a/fpdfsdk/javascript/Consts.cpp b/fpdfsdk/javascript/Consts.cpp index 3fdbb40ccb..8aeb0b9239 100644 --- a/fpdfsdk/javascript/Consts.cpp +++ b/fpdfsdk/javascript/Consts.cpp @@ -6,7 +6,6 @@ #include "fpdfsdk/javascript/Consts.h" -#include "fpdfsdk/include/javascript/IJavaScript.h" #include "fpdfsdk/javascript/JS_Define.h" #include "fpdfsdk/javascript/JS_Object.h" #include "fpdfsdk/javascript/JS_Value.h" diff --git a/fpdfsdk/javascript/Consts.h b/fpdfsdk/javascript/Consts.h index 165e91ffaa..e358cb9341 100644 --- a/fpdfsdk/javascript/Consts.h +++ b/fpdfsdk/javascript/Consts.h @@ -9,8 +9,6 @@ #include "fpdfsdk/javascript/JS_Define.h" -/* ------------------------------ border ------------------------------ */ - class CJS_Border : public CJS_Object { public: explicit CJS_Border(v8::Local<v8::Object> pObject) : CJS_Object(pObject) {} @@ -19,8 +17,6 @@ class CJS_Border : public CJS_Object { DECLARE_JS_CLASS_CONST(); }; -/* ------------------------------ display ------------------------------ */ - class CJS_Display : public CJS_Object { public: explicit CJS_Display(v8::Local<v8::Object> pObject) : CJS_Object(pObject) {} @@ -29,8 +25,6 @@ class CJS_Display : public CJS_Object { DECLARE_JS_CLASS_CONST(); }; -/* ------------------------------ font ------------------------------ */ - class CJS_Font : public CJS_Object { public: explicit CJS_Font(v8::Local<v8::Object> pObject) : CJS_Object(pObject) {} @@ -39,8 +33,6 @@ class CJS_Font : public CJS_Object { DECLARE_JS_CLASS_CONST(); }; -/* ------------------------------ highlight ------------------------------ */ - class CJS_Highlight : public CJS_Object { public: explicit CJS_Highlight(v8::Local<v8::Object> pObject) : CJS_Object(pObject) {} @@ -49,8 +41,6 @@ class CJS_Highlight : public CJS_Object { DECLARE_JS_CLASS_CONST(); }; -/* ------------------------------ position ------------------------------ */ - class CJS_Position : public CJS_Object { public: explicit CJS_Position(v8::Local<v8::Object> pObject) : CJS_Object(pObject) {} @@ -59,8 +49,6 @@ class CJS_Position : public CJS_Object { DECLARE_JS_CLASS_CONST(); }; -/* ------------------------------ scaleHow ------------------------------ */ - class CJS_ScaleHow : public CJS_Object { public: explicit CJS_ScaleHow(v8::Local<v8::Object> pObject) : CJS_Object(pObject) {} @@ -69,8 +57,6 @@ class CJS_ScaleHow : public CJS_Object { DECLARE_JS_CLASS_CONST(); }; -/* ------------------------------ scaleWhen ------------------------------ */ - class CJS_ScaleWhen : public CJS_Object { public: explicit CJS_ScaleWhen(v8::Local<v8::Object> pObject) : CJS_Object(pObject) {} @@ -79,8 +65,6 @@ class CJS_ScaleWhen : public CJS_Object { DECLARE_JS_CLASS_CONST(); }; -/* ------------------------------ style ------------------------------ */ - class CJS_Style : public CJS_Object { public: explicit CJS_Style(v8::Local<v8::Object> pObject) : CJS_Object(pObject) {} @@ -89,8 +73,6 @@ class CJS_Style : public CJS_Object { DECLARE_JS_CLASS_CONST(); }; -/* ------------------------------ zoomtype ------------------------------ */ - class CJS_Zoomtype : public CJS_Object { public: explicit CJS_Zoomtype(v8::Local<v8::Object> pObject) : CJS_Object(pObject) {} @@ -99,15 +81,11 @@ class CJS_Zoomtype : public CJS_Object { DECLARE_JS_CLASS_CONST(); }; -/* ------------------------------ CJS_GlobalConsts -------------------------- */ - class CJS_GlobalConsts : public CJS_Object { public: static void DefineJSObjects(CJS_Runtime* pRuntime); }; -/* ------------------------------ CJS_GlobalArrays -------------------------- */ - class CJS_GlobalArrays : public CJS_Object { public: static void DefineJSObjects(CJS_Runtime* pRuntmie); diff --git a/fpdfsdk/javascript/Document.cpp b/fpdfsdk/javascript/Document.cpp index 70b4ef7e03..762ba71cf2 100644 --- a/fpdfsdk/javascript/Document.cpp +++ b/fpdfsdk/javascript/Document.cpp @@ -12,16 +12,15 @@ #include "core/fpdfapi/fpdf_page/include/cpdf_page.h" #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" #include "fpdfsdk/include/fsdk_mgr.h" -#include "fpdfsdk/include/javascript/IJavaScript.h" #include "fpdfsdk/javascript/Field.h" #include "fpdfsdk/javascript/Icon.h" -#include "fpdfsdk/javascript/JS_Context.h" #include "fpdfsdk/javascript/JS_Define.h" #include "fpdfsdk/javascript/JS_EventHandler.h" #include "fpdfsdk/javascript/JS_Object.h" -#include "fpdfsdk/javascript/JS_Runtime.h" #include "fpdfsdk/javascript/JS_Value.h" #include "fpdfsdk/javascript/app.h" +#include "fpdfsdk/javascript/cjs_context.h" +#include "fpdfsdk/javascript/cjs_runtime.h" #include "fpdfsdk/javascript/resource.h" #include "third_party/base/numerics/safe_math.h" @@ -54,8 +53,6 @@ PrintParamsObj::PrintParamsObj(CJS_Object* pJSObject) bAnnotations = TRUE; } -/* ---------------------- Document ---------------------- */ - #define MINWIDTH 5.0f #define MINHEIGHT 5.0f @@ -148,9 +145,6 @@ void CJS_Document::InitInstance(IJS_Runtime* pIRuntime) { pDoc->SetIsolate(pRuntime->GetIsolate()); } -/* --------------------------------- Document --------------------------------- - */ - Document::Document(CJS_Object* pJSObject) : CJS_EmbedObj(pJSObject), m_isolate(NULL), diff --git a/fpdfsdk/javascript/Field.cpp b/fpdfsdk/javascript/Field.cpp index 5b8750d88e..158d4d6a7f 100644 --- a/fpdfsdk/javascript/Field.cpp +++ b/fpdfsdk/javascript/Field.cpp @@ -14,16 +14,15 @@ #include "core/fpdfapi/fpdf_font/include/cpdf_font.h" #include "core/fpdfapi/fpdf_page/include/cpdf_page.h" #include "fpdfsdk/include/fsdk_mgr.h" -#include "fpdfsdk/include/javascript/IJavaScript.h" #include "fpdfsdk/javascript/Document.h" #include "fpdfsdk/javascript/Icon.h" -#include "fpdfsdk/javascript/JS_Context.h" #include "fpdfsdk/javascript/JS_Define.h" #include "fpdfsdk/javascript/JS_EventHandler.h" #include "fpdfsdk/javascript/JS_Object.h" -#include "fpdfsdk/javascript/JS_Runtime.h" #include "fpdfsdk/javascript/JS_Value.h" #include "fpdfsdk/javascript/PublicMethods.h" +#include "fpdfsdk/javascript/cjs_context.h" +#include "fpdfsdk/javascript/cjs_runtime.h" #include "fpdfsdk/javascript/color.h" BEGIN_JS_STATIC_CONST(CJS_Field) diff --git a/fpdfsdk/javascript/Icon.cpp b/fpdfsdk/javascript/Icon.cpp index d3c2ba8039..7dde8bf0b5 100644 --- a/fpdfsdk/javascript/Icon.cpp +++ b/fpdfsdk/javascript/Icon.cpp @@ -6,13 +6,10 @@ #include "fpdfsdk/javascript/Icon.h" -#include "fpdfsdk/include/javascript/IJavaScript.h" #include "fpdfsdk/javascript/JS_Define.h" #include "fpdfsdk/javascript/JS_Object.h" #include "fpdfsdk/javascript/JS_Value.h" -/* ---------------------- Icon ---------------------- */ - BEGIN_JS_STATIC_CONST(CJS_Icon) END_JS_STATIC_CONST() diff --git a/fpdfsdk/javascript/JS_EventHandler.cpp b/fpdfsdk/javascript/JS_EventHandler.cpp index 0dffa7de54..5984946f6d 100644 --- a/fpdfsdk/javascript/JS_EventHandler.cpp +++ b/fpdfsdk/javascript/JS_EventHandler.cpp @@ -6,16 +6,13 @@ #include "fpdfsdk/javascript/JS_EventHandler.h" -#include "fpdfsdk/include/javascript/IJavaScript.h" #include "fpdfsdk/javascript/Document.h" #include "fpdfsdk/javascript/Field.h" -#include "fpdfsdk/javascript/JS_Context.h" #include "fpdfsdk/javascript/JS_Define.h" #include "fpdfsdk/javascript/JS_Object.h" -#include "fpdfsdk/javascript/JS_Runtime.h" #include "fpdfsdk/javascript/JS_Value.h" - -/* ---------------------------- CJS_EventHandler ---------------------------- */ +#include "fpdfsdk/javascript/cjs_context.h" +#include "fpdfsdk/javascript/cjs_runtime.h" CJS_EventHandler::CJS_EventHandler(CJS_Context* pContext) : m_pJSContext(pContext), diff --git a/fpdfsdk/javascript/JS_GlobalData.cpp b/fpdfsdk/javascript/JS_GlobalData.cpp index 3a9e52175a..fe3475c2b1 100644 --- a/fpdfsdk/javascript/JS_GlobalData.cpp +++ b/fpdfsdk/javascript/JS_GlobalData.cpp @@ -7,13 +7,10 @@ #include "fpdfsdk/javascript/JS_GlobalData.h" #include "core/fdrm/crypto/include/fx_crypt.h" -#include "fpdfsdk/include/javascript/IJavaScript.h" #include "third_party/base/stl_util.h" #define JS_MAXGLOBALDATA (1024 * 4 - 8) -/* --------------------- CJS_GlobalVariableArray --------------------- */ - CJS_GlobalVariableArray::CJS_GlobalVariableArray() {} CJS_GlobalVariableArray::~CJS_GlobalVariableArray() { @@ -81,8 +78,6 @@ void CJS_GlobalVariableArray::Empty() { array.RemoveAll(); } -/* -------------------------- CJS_GlobalData -------------------------- */ - #define READER_JS_GLOBALDATA_FILENAME L"Reader_JsGlobal.Data" #define PHANTOM_JS_GLOBALDATA_FILENAME L"Phantom_JsGlobal.Data" #define SDK_JS_GLOBALDATA_FILENAME L"SDK_JsGlobal.Data" diff --git a/fpdfsdk/javascript/JS_Object.cpp b/fpdfsdk/javascript/JS_Object.cpp index 9bfa857cb9..d85cc1dbe4 100644 --- a/fpdfsdk/javascript/JS_Object.cpp +++ b/fpdfsdk/javascript/JS_Object.cpp @@ -6,10 +6,9 @@ #include "fpdfsdk/javascript/JS_Object.h" -#include "fpdfsdk/include/fsdk_mgr.h" // For CPDFDoc_Environment. -#include "fpdfsdk/include/javascript/IJavaScript.h" -#include "fpdfsdk/javascript/JS_Context.h" +#include "fpdfsdk/include/fsdk_mgr.h" #include "fpdfsdk/javascript/JS_Define.h" +#include "fpdfsdk/javascript/cjs_context.h" namespace { diff --git a/fpdfsdk/javascript/JS_Object.h b/fpdfsdk/javascript/JS_Object.h index da15199e34..e0ec23e79a 100644 --- a/fpdfsdk/javascript/JS_Object.h +++ b/fpdfsdk/javascript/JS_Object.h @@ -10,9 +10,9 @@ #include <map> #include <memory> -#include "fpdfsdk/include/fsdk_define.h" // For FX_UINT +#include "fpdfsdk/include/fsdk_define.h" #include "fpdfsdk/include/jsapi/fxjs_v8.h" -#include "fpdfsdk/javascript/JS_Runtime.h" +#include "fpdfsdk/javascript/cjs_runtime.h" class CJS_Context; class CJS_Object; diff --git a/fpdfsdk/javascript/JS_Runtime_Stub.cpp b/fpdfsdk/javascript/JS_Runtime_Stub.cpp index d7962807c9..7d201d1b56 100644 --- a/fpdfsdk/javascript/JS_Runtime_Stub.cpp +++ b/fpdfsdk/javascript/JS_Runtime_Stub.cpp @@ -6,8 +6,9 @@ #include <memory> -#include "fpdfsdk/include/fsdk_mgr.h" // For CPDFDoc_Environment. -#include "fpdfsdk/include/javascript/IJavaScript.h" +#include "fpdfsdk/include/fsdk_mgr.h" +#include "fpdfsdk/javascript/ijs_context.h" +#include "fpdfsdk/javascript/ijs_runtime.h" class CJS_ContextStub final : public IJS_Context { public: diff --git a/fpdfsdk/javascript/JS_Value.cpp b/fpdfsdk/javascript/JS_Value.cpp index 4d2a1d44a8..0b31494b75 100644 --- a/fpdfsdk/javascript/JS_Value.cpp +++ b/fpdfsdk/javascript/JS_Value.cpp @@ -282,8 +282,6 @@ FX_BOOL CJS_Value::ConvertToDate(CJS_Date& date) const { return FALSE; } -/* ---------------------------- CJS_PropValue ---------------------------- */ - CJS_PropValue::CJS_PropValue(const CJS_Value& value) : CJS_Value(value), m_bIsSetting(0) {} diff --git a/fpdfsdk/javascript/PublicMethods.cpp b/fpdfsdk/javascript/PublicMethods.cpp index 62659e4163..b928aab31d 100644 --- a/fpdfsdk/javascript/PublicMethods.cpp +++ b/fpdfsdk/javascript/PublicMethods.cpp @@ -11,15 +11,14 @@ #include <vector> #include "core/fxcrt/include/fx_ext.h" -#include "fpdfsdk/include/fsdk_mgr.h" // For CPDFDoc_Environment. -#include "fpdfsdk/include/javascript/IJavaScript.h" +#include "fpdfsdk/include/fsdk_mgr.h" #include "fpdfsdk/javascript/Field.h" -#include "fpdfsdk/javascript/JS_Context.h" #include "fpdfsdk/javascript/JS_Define.h" #include "fpdfsdk/javascript/JS_EventHandler.h" #include "fpdfsdk/javascript/JS_Object.h" -#include "fpdfsdk/javascript/JS_Runtime.h" #include "fpdfsdk/javascript/JS_Value.h" +#include "fpdfsdk/javascript/cjs_context.h" +#include "fpdfsdk/javascript/cjs_runtime.h" #include "fpdfsdk/javascript/color.h" #include "fpdfsdk/javascript/resource.h" #include "fpdfsdk/javascript/util.h" @@ -739,8 +738,6 @@ CFX_WideString CJS_PublicMethods::MakeFormatDate(double dDate, return sRet; } -/* -------------------------------------------------------------------------- */ - // function AFNumber_Format(nDec, sepStyle, negStyle, currStyle, strCurrency, // bCurrencyPrepend) FX_BOOL CJS_PublicMethods::AFNumber_Format(IJS_Context* cc, @@ -780,7 +777,6 @@ FX_BOOL CJS_PublicMethods::AFNumber_Format(IJS_Context* cc, if (iNegStyle < 0 || iNegStyle > 3) iNegStyle = 0; - ////////////////////////////////////////////////////// // for processing decimal places strValue.Replace(",", "."); double dValue = atof(strValue); @@ -813,7 +809,7 @@ FX_BOOL CJS_PublicMethods::AFNumber_Format(IJS_Context* cc, } iMax = iDec2 + 1; } - /////////////////////////////////////////////////////// + // for processing seperator style if (iDec2 < iMax) { if (iSepStyle == 0 || iSepStyle == 1) { @@ -840,9 +836,7 @@ FX_BOOL CJS_PublicMethods::AFNumber_Format(IJS_Context* cc, } } - ////////////////////////////////////////////////////////////////////// // for processing currency string - Value = CFX_WideString::FromLocal(strValue); std::wstring strValue2 = Value.c_str(); @@ -851,7 +845,6 @@ FX_BOOL CJS_PublicMethods::AFNumber_Format(IJS_Context* cc, else strValue2 = strValue2 + wstrCurrency; - ///////////////////////////////////////////////////////////////////////// // for processing negative style if (iNegative) { if (iNegStyle == 0) { @@ -1069,7 +1062,6 @@ FX_BOOL CJS_PublicMethods::AFPercent_Format( if (iSepStyle < 0 || iSepStyle > 3) iSepStyle = 0; - ////////////////////////////////////////////////////// // for processing decimal places double dValue = atof(strValue); dValue *= 100; @@ -1097,7 +1089,7 @@ FX_BOOL CJS_PublicMethods::AFPercent_Format( } iMax = iDec2 + 1; } - /////////////////////////////////////////////////////// + // for processing seperator style if (iDec2 < iMax) { if (iSepStyle == 0 || iSepStyle == 1) { @@ -1123,7 +1115,7 @@ FX_BOOL CJS_PublicMethods::AFPercent_Format( iMax++; } } - //////////////////////////////////////////////////////////////////// + // negative mark if (iNegative) strValue = "-" + strValue; diff --git a/fpdfsdk/javascript/app.cpp b/fpdfsdk/javascript/app.cpp index 83836759d7..dd706ebd8c 100644 --- a/fpdfsdk/javascript/app.cpp +++ b/fpdfsdk/javascript/app.cpp @@ -10,14 +10,13 @@ #include <vector> #include "fpdfsdk/include/fsdk_mgr.h" -#include "fpdfsdk/include/javascript/IJavaScript.h" #include "fpdfsdk/javascript/Document.h" -#include "fpdfsdk/javascript/JS_Context.h" #include "fpdfsdk/javascript/JS_Define.h" #include "fpdfsdk/javascript/JS_EventHandler.h" #include "fpdfsdk/javascript/JS_Object.h" -#include "fpdfsdk/javascript/JS_Runtime.h" #include "fpdfsdk/javascript/JS_Value.h" +#include "fpdfsdk/javascript/cjs_context.h" +#include "fpdfsdk/javascript/cjs_runtime.h" #include "fpdfsdk/javascript/resource.h" BEGIN_JS_STATIC_CONST(CJS_TimerObj) diff --git a/fpdfsdk/javascript/JS_Context.cpp b/fpdfsdk/javascript/cjs_context.cpp index c382b07b8b..66a3e0783d 100644 --- a/fpdfsdk/javascript/JS_Context.cpp +++ b/fpdfsdk/javascript/cjs_context.cpp @@ -4,15 +4,12 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#include "fpdfsdk/javascript/JS_Context.h" +#include "fpdfsdk/javascript/cjs_context.h" -#include "fpdfsdk/include/javascript/IJavaScript.h" #include "fpdfsdk/javascript/JS_EventHandler.h" -#include "fpdfsdk/javascript/JS_Runtime.h" +#include "fpdfsdk/javascript/cjs_runtime.h" #include "fpdfsdk/javascript/resource.h" -/* -------------------------- CJS_Context -------------------------- */ - CJS_Context::CJS_Context(CJS_Runtime* pRuntime) : m_pRuntime(pRuntime), m_bBusy(FALSE), m_bMsgBoxEnable(TRUE) { m_pEventHandler = new CJS_EventHandler(this); diff --git a/fpdfsdk/javascript/JS_Context.h b/fpdfsdk/javascript/cjs_context.h index 5aeba27fca..64b97d616e 100644 --- a/fpdfsdk/javascript/JS_Context.h +++ b/fpdfsdk/javascript/cjs_context.h @@ -4,15 +4,16 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#ifndef FPDFSDK_JAVASCRIPT_JS_CONTEXT_H_ -#define FPDFSDK_JAVASCRIPT_JS_CONTEXT_H_ +#ifndef FPDFSDK_JAVASCRIPT_CJS_CONTEXT_H_ +#define FPDFSDK_JAVASCRIPT_CJS_CONTEXT_H_ #include "core/fxcrt/include/fx_string.h" #include "core/fxcrt/include/fx_system.h" -#include "fpdfsdk/include/javascript/IJavaScript.h" +#include "fpdfsdk/javascript/ijs_context.h" class CJS_EventHandler; class CJS_Runtime; +class CPDFDoc_Environment; class CJS_Context : public IJS_Context { public: @@ -134,4 +135,4 @@ class CJS_Context : public IJS_Context { FX_BOOL m_bMsgBoxEnable; }; -#endif // FPDFSDK_JAVASCRIPT_JS_CONTEXT_H_ +#endif // FPDFSDK_JAVASCRIPT_CJS_CONTEXT_H_ diff --git a/fpdfsdk/javascript/JS_Runtime.cpp b/fpdfsdk/javascript/cjs_runtime.cpp index 44fb340f2d..9c616e6c0e 100644 --- a/fpdfsdk/javascript/JS_Runtime.cpp +++ b/fpdfsdk/javascript/cjs_runtime.cpp @@ -4,17 +4,16 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#include "fpdfsdk/javascript/JS_Runtime.h" +#include "fpdfsdk/javascript/cjs_runtime.h" #include <algorithm> -#include "fpdfsdk/include/fsdk_mgr.h" // For CPDFDoc_Environment. -#include "fpdfsdk/include/javascript/IJavaScript.h" +#include "fpdfsdk/include/fsdk_mgr.h" #include "fpdfsdk/javascript/Consts.h" #include "fpdfsdk/javascript/Document.h" #include "fpdfsdk/javascript/Field.h" #include "fpdfsdk/javascript/Icon.h" -#include "fpdfsdk/javascript/JS_Context.h" +#include "fpdfsdk/javascript/cjs_context.h" #include "fpdfsdk/javascript/JS_Define.h" #include "fpdfsdk/javascript/JS_EventHandler.h" #include "fpdfsdk/javascript/JS_GlobalData.h" diff --git a/fpdfsdk/javascript/JS_Runtime.h b/fpdfsdk/javascript/cjs_runtime.h index 68dfb5b973..97e30e7eee 100644 --- a/fpdfsdk/javascript/JS_Runtime.h +++ b/fpdfsdk/javascript/cjs_runtime.h @@ -4,8 +4,8 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#ifndef FPDFSDK_JAVASCRIPT_JS_RUNTIME_H_ -#define FPDFSDK_JAVASCRIPT_JS_RUNTIME_H_ +#ifndef FPDFSDK_JAVASCRIPT_CJS_RUNTIME_H_ +#define FPDFSDK_JAVASCRIPT_CJS_RUNTIME_H_ #include <map> #include <memory> @@ -14,9 +14,9 @@ #include <vector> #include "core/fxcrt/include/fx_basic.h" -#include "fpdfsdk/include/javascript/IJavaScript.h" #include "fpdfsdk/include/jsapi/fxjs_v8.h" #include "fpdfsdk/javascript/JS_EventHandler.h" +#include "fpdfsdk/javascript/ijs_runtime.h" class CJS_Context; @@ -89,4 +89,4 @@ class CJS_Runtime : public IJS_Runtime { std::set<Observer*> m_observers; }; -#endif // FPDFSDK_JAVASCRIPT_JS_RUNTIME_H_ +#endif // FPDFSDK_JAVASCRIPT_CJS_RUNTIME_H_ diff --git a/fpdfsdk/javascript/color.cpp b/fpdfsdk/javascript/color.cpp index 2681a8693e..74c885b682 100644 --- a/fpdfsdk/javascript/color.cpp +++ b/fpdfsdk/javascript/color.cpp @@ -8,15 +8,12 @@ #include <vector> -#include "fpdfsdk/include/javascript/IJavaScript.h" -#include "fpdfsdk/javascript/JS_Context.h" #include "fpdfsdk/javascript/JS_Define.h" #include "fpdfsdk/javascript/JS_EventHandler.h" #include "fpdfsdk/javascript/JS_Object.h" -#include "fpdfsdk/javascript/JS_Runtime.h" #include "fpdfsdk/javascript/JS_Value.h" - -/* -------------------------- color -------------------------- */ +#include "fpdfsdk/javascript/cjs_context.h" +#include "fpdfsdk/javascript/cjs_runtime.h" BEGIN_JS_STATIC_CONST(CJS_Color) END_JS_STATIC_CONST() diff --git a/fpdfsdk/javascript/console.cpp b/fpdfsdk/javascript/console.cpp index 4cce32d54a..a09fe4db17 100644 --- a/fpdfsdk/javascript/console.cpp +++ b/fpdfsdk/javascript/console.cpp @@ -8,14 +8,11 @@ #include <vector> -#include "fpdfsdk/include/javascript/IJavaScript.h" -#include "fpdfsdk/javascript/JS_Context.h" #include "fpdfsdk/javascript/JS_Define.h" #include "fpdfsdk/javascript/JS_EventHandler.h" #include "fpdfsdk/javascript/JS_Object.h" #include "fpdfsdk/javascript/JS_Value.h" - -/* ------------------------ console ------------------------ */ +#include "fpdfsdk/javascript/cjs_context.h" BEGIN_JS_STATIC_CONST(CJS_Console) END_JS_STATIC_CONST() diff --git a/fpdfsdk/javascript/event.cpp b/fpdfsdk/javascript/event.cpp index 7549451e6c..253a802c8f 100644 --- a/fpdfsdk/javascript/event.cpp +++ b/fpdfsdk/javascript/event.cpp @@ -6,15 +6,12 @@ #include "fpdfsdk/javascript/event.h" -#include "fpdfsdk/include/javascript/IJavaScript.h" #include "fpdfsdk/javascript/Field.h" -#include "fpdfsdk/javascript/JS_Context.h" #include "fpdfsdk/javascript/JS_Define.h" #include "fpdfsdk/javascript/JS_EventHandler.h" #include "fpdfsdk/javascript/JS_Object.h" #include "fpdfsdk/javascript/JS_Value.h" - -/* -------------------------- event -------------------------- */ +#include "fpdfsdk/javascript/cjs_context.h" BEGIN_JS_STATIC_CONST(CJS_Event) END_JS_STATIC_CONST() diff --git a/fpdfsdk/javascript/global.cpp b/fpdfsdk/javascript/global.cpp index 251e95bd48..fe974c7af2 100644 --- a/fpdfsdk/javascript/global.cpp +++ b/fpdfsdk/javascript/global.cpp @@ -9,17 +9,14 @@ #include <vector> #include "core/fxcrt/include/fx_ext.h" -#include "fpdfsdk/include/javascript/IJavaScript.h" -#include "fpdfsdk/javascript/JS_Context.h" #include "fpdfsdk/javascript/JS_Define.h" #include "fpdfsdk/javascript/JS_EventHandler.h" #include "fpdfsdk/javascript/JS_GlobalData.h" #include "fpdfsdk/javascript/JS_Object.h" #include "fpdfsdk/javascript/JS_Value.h" +#include "fpdfsdk/javascript/cjs_context.h" #include "fpdfsdk/javascript/resource.h" -/* ---------------------------- global ---------------------------- */ - // Helper class for compile-time calculation of hash values in order to // avoid having global object initializers. template <unsigned ACC, wchar_t... Ns> diff --git a/fpdfsdk/include/javascript/IJavaScript.h b/fpdfsdk/javascript/ijs_context.h index 8aab367983..365533c091 100644 --- a/fpdfsdk/include/javascript/IJavaScript.h +++ b/fpdfsdk/javascript/ijs_context.h @@ -1,24 +1,19 @@ -// Copyright 2014 PDFium Authors. All rights reserved. +// Copyright 2016 PDFium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#ifndef FPDFSDK_INCLUDE_JAVASCRIPT_IJAVASCRIPT_H_ -#define FPDFSDK_INCLUDE_JAVASCRIPT_IJAVASCRIPT_H_ +#ifndef FPDFSDK_JAVASCRIPT_IJS_CONTEXT_H_ +#define FPDFSDK_JAVASCRIPT_IJS_CONTEXT_H_ #include "core/fxcrt/include/fx_string.h" #include "core/fxcrt/include/fx_system.h" -#ifdef PDF_ENABLE_XFA -#include "xfa/fxjse/include/fxjse.h" -#endif // PDF_ENABLE_XFA - -class CPDFDoc_Environment; -class CPDFSDK_Annot; -class CPDFSDK_Document; class CPDF_Bookmark; class CPDF_FormField; +class CPDFSDK_Annot; +class CPDFSDK_Document; // Records the details of an event and triggers JS execution for it. class IJS_Context { @@ -136,31 +131,4 @@ class IJS_Context { virtual ~IJS_Context() {} }; -// Owns the FJXS objects needed to actually execute JS. -class IJS_Runtime { - public: - static void Initialize(unsigned int slot, void* isolate); - static IJS_Runtime* Create(CPDFDoc_Environment* pEnv); - virtual ~IJS_Runtime() {} - - virtual IJS_Context* NewContext() = 0; - virtual void ReleaseContext(IJS_Context* pContext) = 0; - virtual IJS_Context* GetCurrentContext() = 0; - virtual void SetReaderDocument(CPDFSDK_Document* pReaderDoc) = 0; - virtual CPDFSDK_Document* GetReaderDocument() = 0; - virtual int Execute(IJS_Context* cc, - const wchar_t* script, - CFX_WideString* info) = 0; - -#ifdef PDF_ENABLE_XFA - virtual FX_BOOL GetHValueByName(const CFX_ByteStringC& utf8Name, - FXJSE_HVALUE hValue) = 0; - virtual FX_BOOL SetHValueByName(const CFX_ByteStringC& utf8Name, - FXJSE_HVALUE hValue) = 0; -#endif // PDF_ENABLE_XFA - - protected: - IJS_Runtime() {} -}; - -#endif // FPDFSDK_INCLUDE_JAVASCRIPT_IJAVASCRIPT_H_ +#endif // FPDFSDK_JAVASCRIPT_IJS_CONTEXT_H_ diff --git a/fpdfsdk/javascript/ijs_runtime.h b/fpdfsdk/javascript/ijs_runtime.h new file mode 100644 index 0000000000..d4e9000cfd --- /dev/null +++ b/fpdfsdk/javascript/ijs_runtime.h @@ -0,0 +1,48 @@ +// Copyright 2016 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#ifndef FPDFSDK_JAVASCRIPT_IJS_RUNTIME_H_ +#define FPDFSDK_JAVASCRIPT_IJS_RUNTIME_H_ + +#include "core/fxcrt/include/fx_string.h" +#include "core/fxcrt/include/fx_system.h" + +#ifdef PDF_ENABLE_XFA +#include "xfa/fxjse/include/fxjse.h" +#endif // PDF_ENABLE_XFA + +class CPDFDoc_Environment; +class CPDFSDK_Document; +class IJS_Context; + +// Owns the FJXS objects needed to actually execute JS. +class IJS_Runtime { + public: + static void Initialize(unsigned int slot, void* isolate); + static IJS_Runtime* Create(CPDFDoc_Environment* pEnv); + virtual ~IJS_Runtime() {} + + virtual IJS_Context* NewContext() = 0; + virtual void ReleaseContext(IJS_Context* pContext) = 0; + virtual IJS_Context* GetCurrentContext() = 0; + virtual void SetReaderDocument(CPDFSDK_Document* pReaderDoc) = 0; + virtual CPDFSDK_Document* GetReaderDocument() = 0; + virtual int Execute(IJS_Context* cc, + const wchar_t* script, + CFX_WideString* info) = 0; + +#ifdef PDF_ENABLE_XFA + virtual FX_BOOL GetHValueByName(const CFX_ByteStringC& utf8Name, + FXJSE_HVALUE hValue) = 0; + virtual FX_BOOL SetHValueByName(const CFX_ByteStringC& utf8Name, + FXJSE_HVALUE hValue) = 0; +#endif // PDF_ENABLE_XFA + + protected: + IJS_Runtime() {} +}; + +#endif // FPDFSDK_JAVASCRIPT_IJS_RUNTIME_H_ diff --git a/fpdfsdk/javascript/report.cpp b/fpdfsdk/javascript/report.cpp index ca7e199b0f..69cc336003 100644 --- a/fpdfsdk/javascript/report.cpp +++ b/fpdfsdk/javascript/report.cpp @@ -8,13 +8,10 @@ #include <vector> -#include "fpdfsdk/include/javascript/IJavaScript.h" #include "fpdfsdk/javascript/JS_Define.h" #include "fpdfsdk/javascript/JS_Object.h" #include "fpdfsdk/javascript/JS_Value.h" -/* ---------------------- report ---------------------- */ - BEGIN_JS_STATIC_CONST(CJS_Report) END_JS_STATIC_CONST() diff --git a/fpdfsdk/javascript/util.cpp b/fpdfsdk/javascript/util.cpp index 0f50daf38c..adaa9c794b 100644 --- a/fpdfsdk/javascript/util.cpp +++ b/fpdfsdk/javascript/util.cpp @@ -13,14 +13,13 @@ #include <vector> #include "core/fxcrt/include/fx_ext.h" -#include "fpdfsdk/include/javascript/IJavaScript.h" -#include "fpdfsdk/javascript/JS_Context.h" #include "fpdfsdk/javascript/JS_Define.h" #include "fpdfsdk/javascript/JS_EventHandler.h" #include "fpdfsdk/javascript/JS_Object.h" -#include "fpdfsdk/javascript/JS_Runtime.h" #include "fpdfsdk/javascript/JS_Value.h" #include "fpdfsdk/javascript/PublicMethods.h" +#include "fpdfsdk/javascript/cjs_context.h" +#include "fpdfsdk/javascript/cjs_runtime.h" #include "fpdfsdk/javascript/resource.h" #if _FX_OS_ == _FX_ANDROID_ diff --git a/pdfium.gyp b/pdfium.gyp index 7b53772fd4..c592f0dbfd 100644 --- a/pdfium.gyp +++ b/pdfium.gyp @@ -805,7 +805,8 @@ 'target_name': 'javascript', 'type': 'static_library', 'sources': [ - 'fpdfsdk/include/javascript/IJavaScript.h', + 'fpdfsdk/javascript/ijs_context.h', + 'fpdfsdk/javascript/ijs_runtime.h', 'fpdfsdk/javascript/JS_Runtime_Stub.cpp', ], 'conditions': [ @@ -832,8 +833,6 @@ 'fpdfsdk/javascript/Field.h', 'fpdfsdk/javascript/Icon.cpp', 'fpdfsdk/javascript/Icon.h', - 'fpdfsdk/javascript/JS_Context.cpp', - 'fpdfsdk/javascript/JS_Context.h', 'fpdfsdk/javascript/JS_Define.h', 'fpdfsdk/javascript/JS_EventHandler.cpp', 'fpdfsdk/javascript/JS_EventHandler.h', @@ -841,8 +840,6 @@ 'fpdfsdk/javascript/JS_GlobalData.h', 'fpdfsdk/javascript/JS_Object.cpp', 'fpdfsdk/javascript/JS_Object.h', - 'fpdfsdk/javascript/JS_Runtime.cpp', - 'fpdfsdk/javascript/JS_Runtime.h', 'fpdfsdk/javascript/JS_Value.cpp', 'fpdfsdk/javascript/JS_Value.h', 'fpdfsdk/javascript/PublicMethods.cpp', @@ -856,6 +853,10 @@ 'fpdfsdk/javascript/console.cpp', 'fpdfsdk/javascript/console.cpp', 'fpdfsdk/javascript/console.h', + 'fpdfsdk/javascript/cjs_context.cpp', + 'fpdfsdk/javascript/cjs_context.h', + 'fpdfsdk/javascript/cjs_runtime.cpp', + 'fpdfsdk/javascript/cjs_runtime.h', 'fpdfsdk/javascript/event.cpp', 'fpdfsdk/javascript/event.h', 'fpdfsdk/javascript/global.cpp', diff --git a/samples/image_diff_png.cc b/samples/image_diff_png.cc index 93823aa431..18753e2580 100644 --- a/samples/image_diff_png.cc +++ b/samples/image_diff_png.cc @@ -69,7 +69,7 @@ void ConvertRGBAtoRGB(const unsigned char* rgba, int pixel_width, } // namespace -// Decoder -------------------------------------------------------------------- +// Decoder // // This code is based on WebKit libpng interface (PNGImageDecoder), which is // in turn based on the Mozilla png decoder. @@ -355,7 +355,7 @@ bool Decode(const unsigned char* input, size_t input_size, return true; } -// Encoder -------------------------------------------------------------------- +// Encoder // // This section of the code is based on nsPNGEncoder.cpp in Mozilla // (Copyright 2005 Google Inc.) diff --git a/xfa/fxjse/runtime.cpp b/xfa/fxjse/runtime.cpp index a1472c7d8f..83affe550d 100644 --- a/xfa/fxjse/runtime.cpp +++ b/xfa/fxjse/runtime.cpp @@ -9,7 +9,7 @@ #include "fpdfsdk/include/jsapi/fxjs_v8.h" #include "xfa/fxjse/scope_inline.h" -// Duplicates fpdfsdk's JS_Runtime.h, but keeps XFA from depending on it. +// Duplicates fpdfsdk's cjs_runtime.h, but keeps XFA from depending on it. // TODO(tsepez): make a single version of this. class FXJSE_ArrayBufferAllocator : public v8::ArrayBuffer::Allocator { void* Allocate(size_t length) override { return calloc(1, length); } |