Remove backpointer to CJS_Runtime from CJS_Value
Review-Url: https://codereview.chromium.org/2227673005
diff --git a/fpdfsdk/javascript/global.cpp b/fpdfsdk/javascript/global.cpp
index b305c41..10bab26 100644
--- a/fpdfsdk/javascript/global.cpp
+++ b/fpdfsdk/javascript/global.cpp
@@ -81,9 +81,10 @@
const FX_WCHAR* propname,
CJS_PropValue& vp,
CFX_WideString& sError) {
+ CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
if (vp.IsSetting()) {
CFX_ByteString sPropName = CFX_ByteString::FromUnicode(propname);
- switch (vp.GetType()) {
+ switch (vp.GetJSValue()->GetType()) {
case CJS_Value::VT_number: {
double dData;
vp >> dData;
@@ -122,12 +123,12 @@
} else {
auto it = m_mapGlobal.find(CFX_ByteString::FromUnicode(propname));
if (it == m_mapGlobal.end()) {
- vp.SetNull();
+ vp.GetJSValue()->SetNull(pRuntime);
return TRUE;
}
JSGlobalData* pData = it->second;
if (pData->bDeleted) {
- vp.SetNull();
+ vp.GetJSValue()->SetNull(pRuntime);
return TRUE;
}
switch (pData->nType) {
@@ -147,7 +148,7 @@
return TRUE;
}
case JS_GlobalDataType::NULLOBJ:
- vp.SetNull();
+ vp.GetJSValue()->SetNull(pRuntime);
return TRUE;
default:
break;
@@ -161,16 +162,17 @@
CJS_Value& vRet,
CFX_WideString& sError) {
CJS_Context* pContext = static_cast<CJS_Context*>(cc);
+ CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
if (params.size() != 2) {
sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
return FALSE;
}
- auto it = m_mapGlobal.find(params[0].ToCFXByteString());
+ auto it = m_mapGlobal.find(params[0].ToCFXByteString(pRuntime->GetIsolate()));
if (it != m_mapGlobal.end()) {
JSGlobalData* pData = it->second;
if (!pData->bDeleted) {
- pData->bPersistent = params[1].ToBool();
+ pData->bPersistent = params[1].ToBool(pRuntime->GetIsolate());
return TRUE;
}
}
@@ -271,7 +273,6 @@
CJS_GlobalVariableArray& array) {
v8::Isolate* isolate = pObj->GetIsolate();
CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
-
v8::Local<v8::Array> pKeyList = FXJS_GetObjectElementNames(isolate, pObj);
int nObjElements = pKeyList->Length();
for (int i = 0; i < nObjElements; i++) {
@@ -295,7 +296,8 @@
array.Add(pObjElement);
} break;
case CJS_Value::VT_string: {
- CFX_ByteString sValue = CJS_Value(pRuntime, v).ToCFXByteString();
+ CFX_ByteString sValue =
+ CJS_Value(pRuntime, v).ToCFXByteString(pRuntime->GetIsolate());
CJS_KeyValue* pObjElement = new CJS_KeyValue;
pObjElement->nType = JS_GlobalDataType::STRING;
pObjElement->sKey = sKey;