diff options
author | Tom Sepez <tsepez@chromium.org> | 2015-08-17 12:15:26 -0700 |
---|---|---|
committer | Tom Sepez <tsepez@chromium.org> | 2015-08-17 12:15:26 -0700 |
commit | 7dc5cc1c18e04375c19b9793c9da5864660a22f9 (patch) | |
tree | 2c49a5b2b6888ed15a3c93568e5ee906d7853583 | |
parent | 0998538c4a5ad116caf020aa2bd82bd32a6f7772 (diff) | |
download | pdfium-7dc5cc1c18e04375c19b9793c9da5864660a22f9.tar.xz |
Merge to XFA: js_global_data and global_alternate violate naming rules.
(cherry picked from commit ed7599b9042169f11b00f1126bfd3aff0f56b35f)
Original Review URL: https://codereview.chromium.org/1289903004 .
R=thestig@chromium.org
TBR=thestig@chromium.org
Review URL: https://codereview.chromium.org/1286083005 .
-rw-r--r-- | fpdfsdk/include/javascript/global.h | 18 | ||||
-rw-r--r-- | fpdfsdk/src/javascript/JS_GlobalData.cpp | 17 | ||||
-rw-r--r-- | fpdfsdk/src/javascript/global.cpp | 89 |
3 files changed, 52 insertions, 72 deletions
diff --git a/fpdfsdk/include/javascript/global.h b/fpdfsdk/include/javascript/global.h index 369956749b..e881625f56 100644 --- a/fpdfsdk/include/javascript/global.h +++ b/fpdfsdk/include/javascript/global.h @@ -13,8 +13,8 @@ class CJS_GlobalData; class CJS_GlobalVariableArray; class CJS_KeyValue; -struct js_global_data { - js_global_data() { +struct JSGlobalData { + JSGlobalData() { nType = 0; dData = 0; bData = FALSE; @@ -23,7 +23,7 @@ struct js_global_data { bDeleted = FALSE; } - ~js_global_data() { pData.Reset(); } + ~JSGlobalData() { pData.Reset(); } int nType; // 0:int 1:bool 2:string 3:obj double dData; bool bData; @@ -33,18 +33,15 @@ struct js_global_data { bool bDeleted; }; -class global_alternate : public CJS_EmbedObj { +class JSGlobalAlternate : public CJS_EmbedObj { public: - global_alternate(CJS_Object* pJSObject); - ~global_alternate() override; + JSGlobalAlternate(CJS_Object* pJSObject); + ~JSGlobalAlternate() override; - public: FX_BOOL setPersistent(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError); - - public: FX_BOOL QueryProperty(const FX_WCHAR* propname); FX_BOOL DoProperty(IFXJS_Context* cc, const FX_WCHAR* propname, @@ -53,7 +50,6 @@ class global_alternate : public CJS_EmbedObj { FX_BOOL DelProperty(IFXJS_Context* cc, const FX_WCHAR* propname, CFX_WideString& sError); - void Initial(CPDFDoc_Environment* pApp); private: @@ -89,7 +85,7 @@ class CJS_Global : public CJS_Object { DECLARE_SPECIAL_JS_CLASS(CJS_Global); - JS_SPECIAL_STATIC_METHOD(setPersistent, global_alternate, global); + JS_SPECIAL_STATIC_METHOD(setPersistent, JSGlobalAlternate, global); }; #endif // FPDFSDK_INCLUDE_JAVASCRIPT_GLOBAL_H_ diff --git a/fpdfsdk/src/javascript/JS_GlobalData.cpp b/fpdfsdk/src/javascript/JS_GlobalData.cpp index 715374d96f..567e4f2c0a 100644 --- a/fpdfsdk/src/javascript/JS_GlobalData.cpp +++ b/fpdfsdk/src/javascript/JS_GlobalData.cpp @@ -398,23 +398,6 @@ void CJS_GlobalData::LoadGlobalPersistentVariables() { } } -/* -struct js_global_datafile_header -{ - FX_WORD type; //FX ('X' << 8) | 'F' - FX_WORD version; //1.0 - FX_DWORD datacount; -}; -struct js_global_datafile_data -{ - FX_WORD type; - FX_DWORD nData; - FX_WORD bData; - FX_DWORD nStrLen; - char* pStr; -}; -*/ - void CJS_GlobalData::SaveGlobalPersisitentVariables() { FX_DWORD nCount = 0; CFX_BinaryBuf sData; diff --git a/fpdfsdk/src/javascript/global.cpp b/fpdfsdk/src/javascript/global.cpp index ff915a8b38..f03c4d1f41 100644 --- a/fpdfsdk/src/javascript/global.cpp +++ b/fpdfsdk/src/javascript/global.cpp @@ -90,13 +90,13 @@ BEGIN_JS_STATIC_METHOD(CJS_Global) JS_STATIC_METHOD_ENTRY(setPersistent) END_JS_STATIC_METHOD() -IMPLEMENT_SPECIAL_JS_CLASS(CJS_Global, global_alternate, global); +IMPLEMENT_SPECIAL_JS_CLASS(CJS_Global, JSGlobalAlternate, global); FX_BOOL CJS_Global::InitInstance(IFXJS_Context* cc) { CJS_Context* pContext = (CJS_Context*)cc; ASSERT(pContext != NULL); - global_alternate* pGlobal = (global_alternate*)GetEmbedObject(); + JSGlobalAlternate* pGlobal = (JSGlobalAlternate*)GetEmbedObject(); ASSERT(pGlobal != NULL); pGlobal->Initial(pContext->GetReaderApp()); @@ -104,29 +104,30 @@ FX_BOOL CJS_Global::InitInstance(IFXJS_Context* cc) { return TRUE; }; -global_alternate::global_alternate(CJS_Object* pJSObject) - : CJS_EmbedObj(pJSObject), m_pApp(NULL) {} +JSGlobalAlternate::JSGlobalAlternate(CJS_Object* pJSObject) + : CJS_EmbedObj(pJSObject), m_pApp(NULL) { +} -global_alternate::~global_alternate() { +JSGlobalAlternate::~JSGlobalAlternate() { DestroyGlobalPersisitentVariables(); CPDFXFA_App::GetInstance()->GetRuntimeFactory()->ReleaseGlobalData(); } -void global_alternate::Initial(CPDFDoc_Environment* pApp) { +void JSGlobalAlternate::Initial(CPDFDoc_Environment* pApp) { m_pApp = pApp; m_pGlobalData = CPDFXFA_App::GetInstance()->GetRuntimeFactory()->NewGlobalData(pApp); UpdateGlobalPersistentVariables(); } -FX_BOOL global_alternate::QueryProperty(const FX_WCHAR* propname) { +FX_BOOL JSGlobalAlternate::QueryProperty(const FX_WCHAR* propname) { return CFX_WideString(propname) != L"setPersistent"; } -FX_BOOL global_alternate::DelProperty(IFXJS_Context* cc, - const FX_WCHAR* propname, - CFX_WideString& sError) { - js_global_data* pData = NULL; +FX_BOOL JSGlobalAlternate::DelProperty(IFXJS_Context* cc, + const FX_WCHAR* propname, + CFX_WideString& sError) { + JSGlobalData* pData = NULL; CFX_ByteString sPropName = CFX_ByteString::FromUnicode(propname); if (m_mapGlobal.Lookup(sPropName, (void*&)pData)) { @@ -137,10 +138,10 @@ FX_BOOL global_alternate::DelProperty(IFXJS_Context* cc, return FALSE; } -FX_BOOL global_alternate::DoProperty(IFXJS_Context* cc, - const FX_WCHAR* propname, - CJS_PropValue& vp, - CFX_WideString& sError) { +FX_BOOL JSGlobalAlternate::DoProperty(IFXJS_Context* cc, + const FX_WCHAR* propname, + CJS_PropValue& vp, + CFX_WideString& sError) { if (vp.IsSetting()) { CFX_ByteString sPropName = CFX_ByteString::FromUnicode(propname); switch (vp.GetType()) { @@ -189,7 +190,7 @@ FX_BOOL global_alternate::DoProperty(IFXJS_Context* cc, vp.SetNull(); return TRUE; } - js_global_data* pData = (js_global_data*)pVoid; + JSGlobalData* pData = (JSGlobalData*)pVoid; if (pData->bDeleted) return TRUE; @@ -219,10 +220,10 @@ FX_BOOL global_alternate::DoProperty(IFXJS_Context* cc, return FALSE; } -FX_BOOL global_alternate::setPersistent(IFXJS_Context* cc, - const CJS_Parameters& params, - CJS_Value& vRet, - CFX_WideString& sError) { +FX_BOOL JSGlobalAlternate::setPersistent(IFXJS_Context* cc, + const CJS_Parameters& params, + CJS_Value& vRet, + CFX_WideString& sError) { CJS_Context* pContext = static_cast<CJS_Context*>(cc); if (params.size() != 2) { sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); @@ -231,7 +232,7 @@ FX_BOOL global_alternate::setPersistent(IFXJS_Context* cc, CFX_ByteString sName = params[0].ToCFXByteString(); - js_global_data* pData = NULL; + JSGlobalData* pData = NULL; if (m_mapGlobal.Lookup(sName, (void*&)pData)) { if (pData && !pData->bDeleted) { pData->bPersistent = params[1].ToBool(); @@ -243,7 +244,7 @@ FX_BOOL global_alternate::setPersistent(IFXJS_Context* cc, return FALSE; } -void global_alternate::UpdateGlobalPersistentVariables() { +void JSGlobalAlternate::UpdateGlobalPersistentVariables() { ASSERT(m_pGlobalData != NULL); for (int i = 0, sz = m_pGlobalData->GetSize(); i < sz; i++) { @@ -298,13 +299,13 @@ void global_alternate::UpdateGlobalPersistentVariables() { } } -void global_alternate::CommitGlobalPersisitentVariables() { +void JSGlobalAlternate::CommitGlobalPersisitentVariables() { ASSERT(m_pGlobalData != NULL); FX_POSITION pos = m_mapGlobal.GetStartPosition(); while (pos) { CFX_ByteString name; - js_global_data* pData = NULL; + JSGlobalData* pData = NULL; m_mapGlobal.GetNextAssoc(pos, name, (void*&)pData); if (pData) { @@ -350,8 +351,8 @@ void global_alternate::CommitGlobalPersisitentVariables() { } } -void global_alternate::ObjectToArray(v8::Local<v8::Object> pObj, - CJS_GlobalVariableArray& array) { +void JSGlobalAlternate::ObjectToArray(v8::Local<v8::Object> pObj, + CJS_GlobalVariableArray& array) { v8::Local<v8::Context> context = pObj->CreationContext(); v8::Isolate* isolate = context->GetIsolate(); v8::Local<v8::Array> pKeyList = JS_GetObjectElementNames(isolate, pObj); @@ -407,8 +408,8 @@ void global_alternate::ObjectToArray(v8::Local<v8::Object> pObj, } } -void global_alternate::PutObjectProperty(v8::Local<v8::Object> pObj, - CJS_KeyValue* pData) { +void JSGlobalAlternate::PutObjectProperty(v8::Local<v8::Object> pObj, + CJS_KeyValue* pData) { ASSERT(pData != NULL); for (int i = 0, sz = pData->objData.Count(); i < sz; i++) { @@ -447,11 +448,11 @@ void global_alternate::PutObjectProperty(v8::Local<v8::Object> pObj, } } -void global_alternate::DestroyGlobalPersisitentVariables() { +void JSGlobalAlternate::DestroyGlobalPersisitentVariables() { FX_POSITION pos = m_mapGlobal.GetStartPosition(); while (pos) { CFX_ByteString name; - js_global_data* pData = NULL; + JSGlobalData* pData = NULL; m_mapGlobal.GetNextAssoc(pos, name, (void*&)pData); delete pData; } @@ -459,17 +460,17 @@ void global_alternate::DestroyGlobalPersisitentVariables() { m_mapGlobal.RemoveAll(); } -FX_BOOL global_alternate::SetGlobalVariables(const FX_CHAR* propname, - int nType, - double dData, - bool bData, - const CFX_ByteString& sData, - JSObject pData, - bool bDefaultPersistent) { +FX_BOOL JSGlobalAlternate::SetGlobalVariables(const FX_CHAR* propname, + int nType, + double dData, + bool bData, + const CFX_ByteString& sData, + JSObject pData, + bool bDefaultPersistent) { if (propname == NULL) return FALSE; - js_global_data* pTemp = NULL; + JSGlobalData* pTemp = NULL; m_mapGlobal.Lookup(propname, (void*&)pTemp); if (pTemp) { @@ -504,35 +505,35 @@ FX_BOOL global_alternate::SetGlobalVariables(const FX_CHAR* propname, return TRUE; } - js_global_data* pNewData = NULL; + JSGlobalData* pNewData = NULL; switch (nType) { case JS_GLOBALDATA_TYPE_NUMBER: { - pNewData = new js_global_data; + pNewData = new JSGlobalData; pNewData->nType = JS_GLOBALDATA_TYPE_NUMBER; pNewData->dData = dData; pNewData->bPersistent = bDefaultPersistent; } break; case JS_GLOBALDATA_TYPE_BOOLEAN: { - pNewData = new js_global_data; + pNewData = new JSGlobalData; pNewData->nType = JS_GLOBALDATA_TYPE_BOOLEAN; pNewData->bData = bData; pNewData->bPersistent = bDefaultPersistent; } break; case JS_GLOBALDATA_TYPE_STRING: { - pNewData = new js_global_data; + pNewData = new JSGlobalData; pNewData->nType = JS_GLOBALDATA_TYPE_STRING; pNewData->sData = sData; pNewData->bPersistent = bDefaultPersistent; } break; case JS_GLOBALDATA_TYPE_OBJECT: { - pNewData = new js_global_data; + pNewData = new JSGlobalData; pNewData->nType = JS_GLOBALDATA_TYPE_OBJECT; pNewData->pData.Reset(JS_GetRuntime(pData), pData); pNewData->bPersistent = bDefaultPersistent; } break; case JS_GLOBALDATA_TYPE_NULL: { - pNewData = new js_global_data; + pNewData = new JSGlobalData; pNewData->nType = JS_GLOBALDATA_TYPE_NULL; pNewData->bPersistent = bDefaultPersistent; } break; |