summaryrefslogtreecommitdiff
path: root/fpdfsdk/src
diff options
context:
space:
mode:
Diffstat (limited to 'fpdfsdk/src')
-rw-r--r--fpdfsdk/src/javascript/Document.cpp4
-rw-r--r--fpdfsdk/src/javascript/Field.cpp18
-rw-r--r--fpdfsdk/src/javascript/JS_EventHandler.cpp44
-rw-r--r--fpdfsdk/src/javascript/JS_Runtime.cpp2
-rw-r--r--fpdfsdk/src/jsapi/fxjs_v8.cpp22
5 files changed, 26 insertions, 64 deletions
diff --git a/fpdfsdk/src/javascript/Document.cpp b/fpdfsdk/src/javascript/Document.cpp
index 27a3971e15..796fddb5ed 100644
--- a/fpdfsdk/src/javascript/Document.cpp
+++ b/fpdfsdk/src/javascript/Document.cpp
@@ -1428,7 +1428,7 @@ FX_BOOL Document::icons(IFXJS_Context* cc,
if (pObj.IsEmpty())
return FALSE;
- CJS_Icon* pJS_Icon = (CJS_Icon*)FXJS_GetPrivate(pObj);
+ CJS_Icon* pJS_Icon = (CJS_Icon*)FXJS_GetPrivate(m_isolate, pObj);
if (!pJS_Icon)
return FALSE;
@@ -1472,7 +1472,7 @@ FX_BOOL Document::getIcon(IFXJS_Context* cc,
if (pObj.IsEmpty())
return FALSE;
- CJS_Icon* pJS_Icon = (CJS_Icon*)FXJS_GetPrivate(pObj);
+ CJS_Icon* pJS_Icon = (CJS_Icon*)FXJS_GetPrivate(m_isolate, pObj);
if (!pJS_Icon)
return FALSE;
diff --git a/fpdfsdk/src/javascript/Field.cpp b/fpdfsdk/src/javascript/Field.cpp
index 66a9601cbf..140bb422fe 100644
--- a/fpdfsdk/src/javascript/Field.cpp
+++ b/fpdfsdk/src/javascript/Field.cpp
@@ -3300,8 +3300,6 @@ FX_BOOL Field::buttonGetIcon(IFXJS_Context* cc,
return FALSE;
CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
- ASSERT(pFormField != NULL);
-
if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON)
return FALSE;
@@ -3310,17 +3308,13 @@ FX_BOOL Field::buttonGetIcon(IFXJS_Context* cc,
return FALSE;
CJS_Context* pContext = (CJS_Context*)cc;
- ASSERT(pContext != NULL);
-
CJS_Runtime* pRuntime = pContext->GetJSRuntime();
- ASSERT(pRuntime != NULL);
-
v8::Local<v8::Object> pObj =
FXJS_NewFxDynamicObj(pRuntime->GetIsolate(), pContext,
FXJS_GetObjDefnID(pRuntime->GetIsolate(), L"Icon"));
ASSERT(pObj.IsEmpty() == FALSE);
- CJS_Icon* pJS_Icon = (CJS_Icon*)FXJS_GetPrivate(pObj);
+ CJS_Icon* pJS_Icon = (CJS_Icon*)FXJS_GetPrivate(pRuntime->GetIsolate(), pObj);
Icon* pIcon = (Icon*)pJS_Icon->GetEmbedObject();
CPDF_Stream* pIconStream = NULL;
@@ -3339,8 +3333,6 @@ FX_BOOL Field::buttonGetIcon(IFXJS_Context* cc,
return TRUE;
}
-//#pragma warning(default: 4800)
-
FX_BOOL Field::buttonImportIcon(IFXJS_Context* cc,
const CJS_Parameters& params,
CJS_Value& vRet,
@@ -3526,22 +3518,20 @@ FX_BOOL Field::getArray(IFXJS_Context* cc,
CJS_Array FormFieldArray(m_isolate);
for (int j = 0, jsz = swSort.GetSize(); j < jsz; j++) {
- CFX_WideString* pStr = swSort.GetAt(j);
-
+ nonstd::unique_ptr<CFX_WideString> pStr(swSort.GetAt(j));
v8::Local<v8::Object> pObj = FXJS_NewFxDynamicObj(
pRuntime->GetIsolate(), pContext,
FXJS_GetObjDefnID(pRuntime->GetIsolate(), L"Field"));
ASSERT(pObj.IsEmpty() == FALSE);
- CJS_Field* pJSField = (CJS_Field*)FXJS_GetPrivate(pObj);
+ CJS_Field* pJSField =
+ (CJS_Field*)FXJS_GetPrivate(pRuntime->GetIsolate(), pObj);
Field* pField = (Field*)pJSField->GetEmbedObject();
pField->AttachField(m_pJSDoc, *pStr);
CJS_Value FormFieldValue(m_isolate);
FormFieldValue = pJSField;
FormFieldArray.SetElement(j, FormFieldValue);
-
- delete pStr;
}
vRet = FormFieldArray;
diff --git a/fpdfsdk/src/javascript/JS_EventHandler.cpp b/fpdfsdk/src/javascript/JS_EventHandler.cpp
index bd762b4946..553fc95631 100644
--- a/fpdfsdk/src/javascript/JS_EventHandler.cpp
+++ b/fpdfsdk/src/javascript/JS_EventHandler.cpp
@@ -611,10 +611,7 @@ FX_BOOL CJS_EventHandler::Shift() {
}
Field* CJS_EventHandler::Source() {
- ASSERT(m_pJSContext != NULL);
-
CJS_Runtime* pRuntime = m_pJSContext->GetJSRuntime();
-
v8::Local<v8::Object> pDocObj = FXJS_NewFxDynamicObj(
pRuntime->GetIsolate(), m_pJSContext,
FXJS_GetObjDefnID(pRuntime->GetIsolate(), L"Document"));
@@ -624,32 +621,21 @@ Field* CJS_EventHandler::Source() {
FXJS_GetObjDefnID(pRuntime->GetIsolate(), L"Field"));
ASSERT(pFieldObj.IsEmpty() == FALSE);
- CJS_Document* pJSDocument = (CJS_Document*)FXJS_GetPrivate(pDocObj);
+ CJS_Document* pJSDocument =
+ (CJS_Document*)FXJS_GetPrivate(pRuntime->GetIsolate(), pDocObj);
Document* pDocument = (Document*)pJSDocument->GetEmbedObject();
- if (m_pTargetDoc != NULL)
- pDocument->AttachDoc(m_pTargetDoc);
- else
- pDocument->AttachDoc(m_pJSContext->GetReaderDocument());
-
- // if (m_pSourceField == NULL)
- // return NULL;
- // CRAO_Widget *pWidget = IBCL_Widget::GetWidget(m_pSourceField);
- // CPDF_FormField* pFormField = pWidget->GetFormField();
- // ASSERT(pFormField);
- // CFX_WideString csFieldName = pFormField->GetFullName();
- CJS_Field* pJSField = (CJS_Field*)FXJS_GetPrivate(pFieldObj);
- ASSERT(pJSField != NULL);
+ pDocument->AttachDoc(m_pTargetDoc ? m_pTargetDoc
+ : m_pJSContext->GetReaderDocument());
+
+ CJS_Field* pJSField =
+ (CJS_Field*)FXJS_GetPrivate(pRuntime->GetIsolate(), pFieldObj);
Field* pField = (Field*)pJSField->GetEmbedObject();
- ASSERT(pField != NULL);
pField->AttachField(pDocument, m_strSourceName);
return pField;
}
Field* CJS_EventHandler::Target_Field() {
- ASSERT(m_pJSContext != NULL);
-
CJS_Runtime* pRuntime = m_pJSContext->GetJSRuntime();
-
v8::Local<v8::Object> pDocObj = FXJS_NewFxDynamicObj(
pRuntime->GetIsolate(), m_pJSContext,
FXJS_GetObjDefnID(pRuntime->GetIsolate(), L"Document"));
@@ -659,19 +645,15 @@ Field* CJS_EventHandler::Target_Field() {
FXJS_GetObjDefnID(pRuntime->GetIsolate(), L"Field"));
ASSERT(pFieldObj.IsEmpty() == FALSE);
- CJS_Document* pJSDocument = (CJS_Document*)FXJS_GetPrivate(pDocObj);
+ CJS_Document* pJSDocument =
+ (CJS_Document*)FXJS_GetPrivate(pRuntime->GetIsolate(), pDocObj);
Document* pDocument = (Document*)pJSDocument->GetEmbedObject();
- if (m_pTargetDoc != NULL)
- pDocument->AttachDoc(m_pTargetDoc);
- else
- pDocument->AttachDoc(m_pJSContext->GetReaderDocument());
-
- CJS_Field* pJSField = (CJS_Field*)FXJS_GetPrivate(pFieldObj);
- ASSERT(pJSField != NULL);
+ pDocument->AttachDoc(m_pTargetDoc ? m_pTargetDoc
+ : m_pJSContext->GetReaderDocument());
+ CJS_Field* pJSField =
+ (CJS_Field*)FXJS_GetPrivate(pRuntime->GetIsolate(), pFieldObj);
Field* pField = (Field*)pJSField->GetEmbedObject();
- ASSERT(pField != NULL);
-
pField->AttachField(pDocument, m_strTargetName);
return pField;
}
diff --git a/fpdfsdk/src/javascript/JS_Runtime.cpp b/fpdfsdk/src/javascript/JS_Runtime.cpp
index 81f9462674..edc8c253d9 100644
--- a/fpdfsdk/src/javascript/JS_Runtime.cpp
+++ b/fpdfsdk/src/javascript/JS_Runtime.cpp
@@ -184,7 +184,7 @@ void CJS_Runtime::SetReaderDocument(CPDFSDK_Document* pReaderDoc) {
if (FXJS_GetObjDefnID(pThis) ==
FXJS_GetObjDefnID(GetIsolate(), L"Document")) {
if (CJS_Document* pJSDocument =
- (CJS_Document*)FXJS_GetPrivate(pThis)) {
+ (CJS_Document*)FXJS_GetPrivate(GetIsolate(), pThis)) {
if (Document* pDocument = (Document*)pJSDocument->GetEmbedObject())
pDocument->AttachDoc(pReaderDoc);
}
diff --git a/fpdfsdk/src/jsapi/fxjs_v8.cpp b/fpdfsdk/src/jsapi/fxjs_v8.cpp
index 381bfbad7f..69ea2cb48b 100644
--- a/fpdfsdk/src/jsapi/fxjs_v8.cpp
+++ b/fpdfsdk/src/jsapi/fxjs_v8.cpp
@@ -489,13 +489,6 @@ const wchar_t* FXJS_GetTypeof(v8::Local<v8::Value> pObj) {
return kFXJSValueNameUndefined;
return NULL;
}
-void FXJS_SetPrivate(v8::Local<v8::Object> pObj, void* p) {
- FXJS_SetPrivate(NULL, pObj, p);
-}
-
-void* FXJS_GetPrivate(v8::Local<v8::Object> pObj) {
- return FXJS_GetPrivate(NULL, pObj);
-}
void FXJS_SetPrivate(v8::Isolate* pIsolate,
v8::Local<v8::Object> pObj,
@@ -511,24 +504,21 @@ void FXJS_SetPrivate(v8::Isolate* pIsolate,
void* FXJS_GetPrivate(v8::Isolate* pIsolate, v8::Local<v8::Object> pObj) {
if (pObj.IsEmpty())
- return NULL;
- CFXJS_PrivateData* pPrivateData = NULL;
- if (pObj->InternalFieldCount())
+ return nullptr;
+ CFXJS_PrivateData* pPrivateData = nullptr;
+ if (pObj->InternalFieldCount()) {
pPrivateData =
(CFXJS_PrivateData*)pObj->GetAlignedPointerFromInternalField(0);
- else {
+ } else {
// It could be a global proxy object.
v8::Local<v8::Value> v = pObj->GetPrototype();
- v8::Isolate* isolate = (v8::Isolate*)pIsolate;
- v8::Local<v8::Context> context = isolate->GetCurrentContext();
+ v8::Local<v8::Context> context = pIsolate->GetCurrentContext();
if (v->IsObject())
pPrivateData = (CFXJS_PrivateData*)v->ToObject(context)
.ToLocalChecked()
->GetAlignedPointerFromInternalField(0);
}
- if (!pPrivateData)
- return NULL;
- return pPrivateData->pPrivate;
+ return pPrivateData ? pPrivateData->pPrivate : nullptr;
}
void FXJS_FreePrivate(void* pPrivateData) {