From 506df426d5d64d68e9dc27ffebcf56f6c6a1bccf Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Wed, 16 Sep 2015 10:42:08 -0700 Subject: Ensure functions in FXJS_V8 are prefixed by FXJS_. Currently, its hard to tell which functions come from the JS_ layer at fpdfsdk/include/javascript vs. which functions come from the FXJS_V8 layer at fpdfsdk/include/jsapi. Until we take up the task of using namespaces, at least make the prefix consistent. Move objects out of FXJS_V8 that are really part of JS_. R=thestig@chromium.org Review URL: https://codereview.chromium.org/1347833002 . --- fpdfsdk/src/javascript/Document.cpp | 101 ++++++++++++++++++------------------ 1 file changed, 51 insertions(+), 50 deletions(-) (limited to 'fpdfsdk/src/javascript/Document.cpp') diff --git a/fpdfsdk/src/javascript/Document.cpp b/fpdfsdk/src/javascript/Document.cpp index a8a4ebc491..27a3971e15 100644 --- a/fpdfsdk/src/javascript/Document.cpp +++ b/fpdfsdk/src/javascript/Document.cpp @@ -326,11 +326,11 @@ FX_BOOL Document::getField(IFXJS_Context* cc, CJS_Runtime* pRuntime = pContext->GetJSRuntime(); v8::Local pFieldObj = - JS_NewFxDynamicObj(pRuntime->GetIsolate(), pContext, - JS_GetObjDefnID(pRuntime->GetIsolate(), L"Field")); + FXJS_NewFxDynamicObj(pRuntime->GetIsolate(), pContext, + FXJS_GetObjDefnID(pRuntime->GetIsolate(), L"Field")); v8::Isolate* isolate = GetIsolate(cc); - CJS_Field* pJSField = (CJS_Field*)JS_GetPrivate(isolate, pFieldObj); + CJS_Field* pJSField = (CJS_Field*)FXJS_GetPrivate(isolate, pFieldObj); Field* pField = (Field*)pJSField->GetEmbedObject(); pField->AttachField(this, wideName); @@ -457,11 +457,11 @@ FX_BOOL Document::print(IFXJS_Context* cc, int nlength = params.size(); if (nlength == 9) { - if (params[8].GetType() == VT_fxobject) { + if (params[8].GetType() == CJS_Value::VT_fxobject) { v8::Local pObj = params[8].ToV8Object(); { - if (JS_GetObjDefnID(pObj) == - JS_GetObjDefnID(pRuntime->GetIsolate(), L"PrintParamsObj")) { + if (FXJS_GetObjDefnID(pObj) == + FXJS_GetObjDefnID(pRuntime->GetIsolate(), L"PrintParamsObj")) { if (CJS_Object* pJSObj = params[8].ToCJSObject()) { if (PrintParamsObj* pprintparamsObj = (PrintParamsObj*)pJSObj->GetEmbedObject()) { @@ -595,7 +595,7 @@ FX_BOOL Document::resetForm(IFXJS_Context* cc, default: aName.Attach(params[0].ToV8Array()); break; - case VT_string: + case CJS_Value::VT_string: aName.SetElement(0, params[0]); break; } @@ -651,7 +651,7 @@ FX_BOOL Document::submitForm(IFXJS_Context* cc, CJS_Array aFields(isolate); CJS_Value v = params[0]; - if (v.GetType() == VT_string) { + if (v.GetType() == CJS_Value::VT_string) { strURL = params[0].ToCFXWideString(); if (nSize > 1) bFDF = params[1].ToBool(); @@ -659,17 +659,17 @@ FX_BOOL Document::submitForm(IFXJS_Context* cc, bEmpty = params[2].ToBool(); if (nSize > 3) aFields.Attach(params[3].ToV8Array()); - } else if (v.GetType() == VT_object) { + } else if (v.GetType() == CJS_Value::VT_object) { v8::Local pObj = params[0].ToV8Object(); - v8::Local pValue = JS_GetObjectElement(isolate, pObj, L"cURL"); + v8::Local pValue = FXJS_GetObjectElement(isolate, pObj, L"cURL"); if (!pValue.IsEmpty()) strURL = CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToCFXWideString(); - pValue = JS_GetObjectElement(isolate, pObj, L"bFDF"); + pValue = FXJS_GetObjectElement(isolate, pObj, L"bFDF"); bFDF = CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToBool(); - pValue = JS_GetObjectElement(isolate, pObj, L"bEmpty"); + pValue = FXJS_GetObjectElement(isolate, pObj, L"bEmpty"); bEmpty = CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToBool(); - pValue = JS_GetObjectElement(isolate, pObj, L"aFields"); + pValue = FXJS_GetObjectElement(isolate, pObj, L"aFields"); aFields.Attach( CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToV8Array()); } @@ -766,26 +766,26 @@ FX_BOOL Document::mailDoc(IFXJS_Context* cc, v8::Isolate* isolate = GetIsolate(cc); - if (params.size() >= 1 && params[0].GetType() == VT_object) { + if (params.size() >= 1 && params[0].GetType() == CJS_Value::VT_object) { v8::Local pObj = params[0].ToV8Object(); - v8::Local pValue = JS_GetObjectElement(isolate, pObj, L"bUI"); + v8::Local pValue = FXJS_GetObjectElement(isolate, pObj, L"bUI"); bUI = CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToInt(); - pValue = JS_GetObjectElement(isolate, pObj, L"cTo"); + pValue = FXJS_GetObjectElement(isolate, pObj, L"cTo"); cTo = CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToCFXWideString(); - pValue = JS_GetObjectElement(isolate, pObj, L"cCc"); + pValue = FXJS_GetObjectElement(isolate, pObj, L"cCc"); cCc = CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToCFXWideString(); - pValue = JS_GetObjectElement(isolate, pObj, L"cBcc"); + pValue = FXJS_GetObjectElement(isolate, pObj, L"cBcc"); cBcc = CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToCFXWideString(); - pValue = JS_GetObjectElement(isolate, pObj, L"cSubject"); + pValue = FXJS_GetObjectElement(isolate, pObj, L"cSubject"); cSubject = CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToCFXWideString(); - pValue = JS_GetObjectElement(isolate, pObj, L"cMsg"); + pValue = FXJS_GetObjectElement(isolate, pObj, L"cMsg"); cMsg = CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToCFXWideString(); } @@ -851,16 +851,17 @@ FX_BOOL Document::info(IFXJS_Context* cc, CJS_Context* pContext = (CJS_Context*)cc; CJS_Runtime* pRuntime = pContext->GetJSRuntime(); v8::Local pObj = - JS_NewFxDynamicObj(pRuntime->GetIsolate(), pContext, -1); - JS_PutObjectString(isolate, pObj, L"Author", cwAuthor.c_str()); - JS_PutObjectString(isolate, pObj, L"Title", cwTitle.c_str()); - JS_PutObjectString(isolate, pObj, L"Subject", cwSubject.c_str()); - JS_PutObjectString(isolate, pObj, L"Keywords", cwKeywords.c_str()); - JS_PutObjectString(isolate, pObj, L"Creator", cwCreator.c_str()); - JS_PutObjectString(isolate, pObj, L"Producer", cwProducer.c_str()); - JS_PutObjectString(isolate, pObj, L"CreationDate", cwCreationDate.c_str()); - JS_PutObjectString(isolate, pObj, L"ModDate", cwModDate.c_str()); - JS_PutObjectString(isolate, pObj, L"Trapped", cwTrapped.c_str()); + FXJS_NewFxDynamicObj(pRuntime->GetIsolate(), pContext, -1); + FXJS_PutObjectString(isolate, pObj, L"Author", cwAuthor.c_str()); + FXJS_PutObjectString(isolate, pObj, L"Title", cwTitle.c_str()); + FXJS_PutObjectString(isolate, pObj, L"Subject", cwSubject.c_str()); + FXJS_PutObjectString(isolate, pObj, L"Keywords", cwKeywords.c_str()); + FXJS_PutObjectString(isolate, pObj, L"Creator", cwCreator.c_str()); + FXJS_PutObjectString(isolate, pObj, L"Producer", cwProducer.c_str()); + FXJS_PutObjectString(isolate, pObj, L"CreationDate", + cwCreationDate.c_str()); + FXJS_PutObjectString(isolate, pObj, L"ModDate", cwModDate.c_str()); + FXJS_PutObjectString(isolate, pObj, L"Trapped", cwTrapped.c_str()); // It's to be compatible to non-standard info dictionary. FX_POSITION pos = pDictionary->GetStartPos(); @@ -870,14 +871,14 @@ FX_BOOL Document::info(IFXJS_Context* cc, CFX_WideString wsKey = CFX_WideString::FromUTF8(bsKey, bsKey.GetLength()); if ((pValueObj->GetType() == PDFOBJ_STRING) || (pValueObj->GetType() == PDFOBJ_NAME)) - JS_PutObjectString(isolate, pObj, wsKey.c_str(), - pValueObj->GetUnicodeText().c_str()); + FXJS_PutObjectString(isolate, pObj, wsKey.c_str(), + pValueObj->GetUnicodeText().c_str()); if (pValueObj->GetType() == PDFOBJ_NUMBER) - JS_PutObjectNumber(isolate, pObj, wsKey.c_str(), - (float)pValueObj->GetNumber()); + FXJS_PutObjectNumber(isolate, pObj, wsKey.c_str(), + (float)pValueObj->GetNumber()); if (pValueObj->GetType() == PDFOBJ_BOOLEAN) - JS_PutObjectBoolean(isolate, pObj, wsKey.c_str(), - (bool)pValueObj->GetInteger()); + FXJS_PutObjectBoolean(isolate, pObj, wsKey.c_str(), + (bool)pValueObj->GetInteger()); } vp << pObj; } @@ -1287,7 +1288,7 @@ FX_BOOL Document::getAnnots3D(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, CFX_WideString& sError) { - vRet = VT_undefined; + vRet = CJS_Value::VT_undefined; return TRUE; } @@ -1366,15 +1367,15 @@ FX_BOOL Document::addIcon(IFXJS_Context* cc, } CFX_WideString swIconName = params[0].ToCFXWideString(); - if (params[1].GetType() != VT_object) { + if (params[1].GetType() != CJS_Value::VT_object) { sError = JSGetStringFromID(pContext, IDS_STRING_JSTYPEERROR); return FALSE; } v8::Local pJSIcon = params[1].ToV8Object(); CJS_Runtime* pRuntime = pContext->GetJSRuntime(); - if (JS_GetObjDefnID(pJSIcon) != - JS_GetObjDefnID(pRuntime->GetIsolate(), L"Icon")) { + if (FXJS_GetObjDefnID(pJSIcon) != + FXJS_GetObjDefnID(pRuntime->GetIsolate(), L"Icon")) { sError = JSGetStringFromID(pContext, IDS_STRING_JSTYPEERROR); return FALSE; } @@ -1421,13 +1422,13 @@ FX_BOOL Document::icons(IFXJS_Context* cc, for (int i = 0; i < iIconTreeLength; i++) { pIconElement = (*m_pIconTree)[i]; - v8::Local pObj = - JS_NewFxDynamicObj(pRuntime->GetIsolate(), pContext, - JS_GetObjDefnID(pRuntime->GetIsolate(), L"Icon")); + v8::Local pObj = FXJS_NewFxDynamicObj( + pRuntime->GetIsolate(), pContext, + FXJS_GetObjDefnID(pRuntime->GetIsolate(), L"Icon")); if (pObj.IsEmpty()) return FALSE; - CJS_Icon* pJS_Icon = (CJS_Icon*)JS_GetPrivate(pObj); + CJS_Icon* pJS_Icon = (CJS_Icon*)FXJS_GetPrivate(pObj); if (!pJS_Icon) return FALSE; @@ -1465,13 +1466,13 @@ FX_BOOL Document::getIcon(IFXJS_Context* cc, if ((*m_pIconTree)[i]->IconName == swIconName) { Icon* pRetIcon = (*m_pIconTree)[i]->IconStream; - v8::Local pObj = - JS_NewFxDynamicObj(pRuntime->GetIsolate(), pContext, - JS_GetObjDefnID(pRuntime->GetIsolate(), L"Icon")); + v8::Local pObj = FXJS_NewFxDynamicObj( + pRuntime->GetIsolate(), pContext, + FXJS_GetObjDefnID(pRuntime->GetIsolate(), L"Icon")); if (pObj.IsEmpty()) return FALSE; - CJS_Icon* pJS_Icon = (CJS_Icon*)JS_GetPrivate(pObj); + CJS_Icon* pJS_Icon = (CJS_Icon*)FXJS_GetPrivate(pObj); if (!pJS_Icon) return FALSE; @@ -1662,9 +1663,9 @@ FX_BOOL Document::getPrintParams(IFXJS_Context* cc, CFX_WideString& sError) { CJS_Context* pContext = (CJS_Context*)cc; CJS_Runtime* pRuntime = pContext->GetJSRuntime(); - v8::Local pRetObj = JS_NewFxDynamicObj( + v8::Local pRetObj = FXJS_NewFxDynamicObj( pRuntime->GetIsolate(), pContext, - JS_GetObjDefnID(pRuntime->GetIsolate(), L"PrintParamsObj")); + FXJS_GetObjDefnID(pRuntime->GetIsolate(), L"PrintParamsObj")); // Not implemented yet. -- cgit v1.2.3