Move const arrays to CFXJS_Engine from CJS_V8
CJS_V8 is shared by both the non-xfa and xfa-side JS engines,
but the const arrays are only used by the non-xfa side.
Change-Id: Ic5ed8238df1a14dde8a4463b2388b4a7a923e392
Reviewed-on: https://pdfium-review.googlesource.com/25250
Commit-Queue: dsinclair <dsinclair@chromium.org>
Reviewed-by: dsinclair <dsinclair@chromium.org>
diff --git a/fxjs/cjs_v8.cpp b/fxjs/cjs_v8.cpp
index b4f7fb1..7855813 100644
--- a/fxjs/cjs_v8.cpp
+++ b/fxjs/cjs_v8.cpp
@@ -196,14 +196,6 @@
return v8::Local<v8::Array>::Cast(pValue->ToObject(context).ToLocalChecked());
}
-void CJS_V8::SetConstArray(const WideString& name, v8::Local<v8::Array> array) {
- m_ConstArrays[name] = v8::Global<v8::Array>(GetIsolate(), array);
-}
-
-v8::Local<v8::Array> CJS_V8::GetConstArray(const WideString& name) {
- return v8::Local<v8::Array>::New(GetIsolate(), m_ConstArrays[name]);
-}
-
#ifdef PDF_ENABLE_XFA
CXFA_Object* CJS_V8::ToXFAObject(v8::Local<v8::Value> obj) {
ASSERT(!obj.IsEmpty());
diff --git a/fxjs/cjs_v8.h b/fxjs/cjs_v8.h
index 1a8d15b..1359309 100644
--- a/fxjs/cjs_v8.h
+++ b/fxjs/cjs_v8.h
@@ -60,9 +60,6 @@
unsigned index,
v8::Local<v8::Value> pValue);
- void SetConstArray(const WideString& name, v8::Local<v8::Array> array);
- v8::Local<v8::Array> GetConstArray(const WideString& name);
-
// Objects.
std::vector<WideString> GetObjectPropertyNames(v8::Local<v8::Object> pObj);
v8::Local<v8::Value> GetObjectProperty(v8::Local<v8::Object> pObj,
@@ -73,11 +70,9 @@
protected:
void SetIsolate(v8::Isolate* pIsolate) { m_isolate = pIsolate; }
- void ClearConstArray() { m_ConstArrays.clear(); }
private:
v8::Isolate* m_isolate;
- std::map<WideString, v8::Global<v8::Array>> m_ConstArrays;
};
#endif // FXJS_CJS_V8_H_
diff --git a/fxjs/fxjs_v8.cpp b/fxjs/fxjs_v8.cpp
index c9d227c..f1555b2 100644
--- a/fxjs/fxjs_v8.cpp
+++ b/fxjs/fxjs_v8.cpp
@@ -436,7 +436,7 @@
if (!pData)
return;
- ClearConstArray();
+ m_ConstArrays.clear();
int maxID = CFXJS_ObjDefinition::MaxID(GetIsolate());
for (int i = 0; i < maxID; ++i) {
@@ -561,3 +561,12 @@
}
return pData ? pData->m_pPrivate : nullptr;
}
+
+v8::Local<v8::Array> CFXJS_Engine::GetConstArray(const WideString& name) {
+ return v8::Local<v8::Array>::New(GetIsolate(), m_ConstArrays[name]);
+}
+
+void CFXJS_Engine::SetConstArray(const WideString& name,
+ v8::Local<v8::Array> array) {
+ m_ConstArrays[name] = v8::Global<v8::Array>(GetIsolate(), array);
+}
diff --git a/fxjs/fxjs_v8.h b/fxjs/fxjs_v8.h
index 6878bcd..4e6b248 100644
--- a/fxjs/fxjs_v8.h
+++ b/fxjs/fxjs_v8.h
@@ -189,12 +189,16 @@
return v8::Local<v8::Context>::New(GetIsolate(), m_V8Context);
}
+ v8::Local<v8::Array> GetConstArray(const WideString& name);
+ void SetConstArray(const WideString& name, v8::Local<v8::Array> array);
+
protected:
CFXJS_Engine();
private:
v8::Global<v8::Context> m_V8Context;
std::vector<v8::Global<v8::Object>*> m_StaticObjects;
+ std::map<WideString, v8::Global<v8::Array>> m_ConstArrays;
};
#endif // FXJS_FXJS_V8_H_