diff options
author | Tom Sepez <tsepez@chromium.org> | 2015-09-17 15:40:06 -0700 |
---|---|---|
committer | Tom Sepez <tsepez@chromium.org> | 2015-09-17 15:40:06 -0700 |
commit | d5a0e95db021e50064cc2e761f023b75c24b72a2 (patch) | |
tree | b355b190bdec2a9e8cc56d8f4b2be888a891fc6f /fpdfsdk/src/javascript | |
parent | 39bfe122b4867601051c56562a5ab9cf6be644ad (diff) | |
download | pdfium-d5a0e95db021e50064cc2e761f023b75c24b72a2.tar.xz |
Merge to XFA: Don't pass null isolates to FXJS_ when we have a real isolate.
(cherry picked from commit 34b39e1d4fa0b16d47770b823230344356cc451a)
Original Review URL: https://codereview.chromium.org/1350703003 .
TBR=thestig@chromium.org
Review URL: https://codereview.chromium.org/1342403005 .
Diffstat (limited to 'fpdfsdk/src/javascript')
-rw-r--r-- | fpdfsdk/src/javascript/Document.cpp | 4 | ||||
-rw-r--r-- | fpdfsdk/src/javascript/Field.cpp | 18 | ||||
-rw-r--r-- | fpdfsdk/src/javascript/JS_EventHandler.cpp | 44 | ||||
-rw-r--r-- | fpdfsdk/src/javascript/JS_Runtime.cpp | 2 |
4 files changed, 20 insertions, 48 deletions
diff --git a/fpdfsdk/src/javascript/Document.cpp b/fpdfsdk/src/javascript/Document.cpp index bccf08b271..105e487e1c 100644 --- a/fpdfsdk/src/javascript/Document.cpp +++ b/fpdfsdk/src/javascript/Document.cpp @@ -1467,7 +1467,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; @@ -1511,7 +1511,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 52f6321f4a..266f29592a 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 bbe9f6e8c8..643cefb92f 100644 --- a/fpdfsdk/src/javascript/JS_Runtime.cpp +++ b/fpdfsdk/src/javascript/JS_Runtime.cpp @@ -205,7 +205,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); } |