summaryrefslogtreecommitdiff
path: root/fpdfsdk/src/javascript/global.cpp
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2015-10-08 12:04:40 -0700
committerTom Sepez <tsepez@chromium.org>2015-10-08 12:04:40 -0700
commit287b63d9ab410783d71cf37291f09fd57d3059b4 (patch)
treef7694e057d86f98833830ea1a34c2a2bbdca8399 /fpdfsdk/src/javascript/global.cpp
parent4fa0e27ba39f49ba92fb4c160ab836a6f1dd2893 (diff)
downloadpdfium-287b63d9ab410783d71cf37291f09fd57d3059b4.tar.xz
Wean CJS_Value off of v8::Isolate.
CJS_Values should belong to CJS_Runtimes so that we may eventually cram much of the v8 dependencies down into fxjs. This is a first step; the remaining split in this code between isolate and CJS_Runtime goes away when fxjs provides a CFXJS_Runtime object, and the CJS_Runtime is-a/has-a CFXJS_Runtime. But that can't happen until this is resolved. R=thestig@chromium.org Review URL: https://codereview.chromium.org/1394103002 .
Diffstat (limited to 'fpdfsdk/src/javascript/global.cpp')
-rw-r--r--fpdfsdk/src/javascript/global.cpp20
1 files changed, 10 insertions, 10 deletions
diff --git a/fpdfsdk/src/javascript/global.cpp b/fpdfsdk/src/javascript/global.cpp
index 69e983f139..c8510d27dc 100644
--- a/fpdfsdk/src/javascript/global.cpp
+++ b/fpdfsdk/src/javascript/global.cpp
@@ -193,8 +193,8 @@ FX_BOOL JSGlobalAlternate::DoProperty(IJS_Context* cc,
vp << pData->sData;
return TRUE;
case JS_GLOBALDATA_TYPE_OBJECT: {
- v8::Local<v8::Object> obj =
- v8::Local<v8::Object>::New(vp.GetIsolate(), pData->pData);
+ v8::Local<v8::Object> obj = v8::Local<v8::Object>::New(
+ vp.GetJSRuntime()->GetIsolate(), pData->pData);
vp << obj;
return TRUE;
}
@@ -286,8 +286,7 @@ void JSGlobalAlternate::UpdateGlobalPersistentVariables() {
}
}
-void JSGlobalAlternate::CommitGlobalPersisitentVariables() {
- ASSERT(m_pGlobalData);
+void JSGlobalAlternate::CommitGlobalPersisitentVariables(IJS_Context* cc) {
for (auto it = m_mapGlobal.begin(); it != m_mapGlobal.end(); ++it) {
CFX_ByteString name = it->first;
JSGlobalData* pData = it->second;
@@ -308,12 +307,11 @@ void JSGlobalAlternate::CommitGlobalPersisitentVariables() {
m_pGlobalData->SetGlobalVariablePersistent(name, pData->bPersistent);
break;
case JS_GLOBALDATA_TYPE_OBJECT:
- // if (pData->pData)
{
CJS_GlobalVariableArray array;
v8::Local<v8::Object> obj = v8::Local<v8::Object>::New(
GetJSObject()->GetIsolate(), pData->pData);
- ObjectToArray(obj, array);
+ ObjectToArray(cc, obj, array);
m_pGlobalData->SetGlobalVariableObject(name, array);
m_pGlobalData->SetGlobalVariablePersistent(name,
pData->bPersistent);
@@ -328,13 +326,15 @@ void JSGlobalAlternate::CommitGlobalPersisitentVariables() {
}
}
-void JSGlobalAlternate::ObjectToArray(v8::Local<v8::Object> pObj,
+void JSGlobalAlternate::ObjectToArray(IJS_Context* cc,
+ v8::Local<v8::Object> pObj,
CJS_GlobalVariableArray& array) {
v8::Local<v8::Context> context = pObj->CreationContext();
v8::Isolate* isolate = context->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++) {
CFX_WideString ws =
FXJS_ToString(isolate, FXJS_GetArrayElement(isolate, pKeyList, i));
@@ -358,7 +358,7 @@ void JSGlobalAlternate::ObjectToArray(v8::Local<v8::Object> pObj,
} break;
case CJS_Value::VT_string: {
CFX_ByteString sValue =
- CJS_Value(isolate, v, CJS_Value::VT_string).ToCFXByteString();
+ CJS_Value(pRuntime, v, CJS_Value::VT_string).ToCFXByteString();
CJS_KeyValue* pObjElement = new CJS_KeyValue;
pObjElement->nType = JS_GLOBALDATA_TYPE_STRING;
pObjElement->sKey = sKey;
@@ -369,7 +369,7 @@ void JSGlobalAlternate::ObjectToArray(v8::Local<v8::Object> pObj,
CJS_KeyValue* pObjElement = new CJS_KeyValue;
pObjElement->nType = JS_GLOBALDATA_TYPE_OBJECT;
pObjElement->sKey = sKey;
- ObjectToArray(FXJS_ToObject(isolate, v), pObjElement->objData);
+ ObjectToArray(cc, FXJS_ToObject(isolate, v), pObjElement->objData);
array.Add(pObjElement);
} break;
case CJS_Value::VT_null: {