summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2018-06-06 20:51:04 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-06-06 20:51:04 +0000
commit6ffd840c1f4d7d74a6c4c07c5791c4f3db8d50b9 (patch)
tree1020d5547830ef16b52648818232c69c65850cdf
parent222d3fdf687554b298650080e2e8f47d83411651 (diff)
downloadpdfium-chromium/3452.tar.xz
Remove still more v8::Context slot usage.chromium/3452
Removes CJS_Runtime::RuntimeFromIsolateCurrentContext() Change-Id: I51abcf32aaafac522e1595edf663507c26781357 Reviewed-on: https://pdfium-review.googlesource.com/34230 Commit-Queue: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
-rw-r--r--fxjs/cjs_global.cpp11
-rw-r--r--fxjs/cjs_publicmethods.cpp7
-rw-r--r--fxjs/cjs_runtime.cpp7
-rw-r--r--fxjs/cjs_runtime.h2
-rw-r--r--fxjs/js_define.cpp6
5 files changed, 15 insertions, 18 deletions
diff --git a/fxjs/cjs_global.cpp b/fxjs/cjs_global.cpp
index 5834ab9600..1e01f96aee 100644
--- a/fxjs/cjs_global.cpp
+++ b/fxjs/cjs_global.cpp
@@ -311,9 +311,9 @@ CJS_Return CJS_Global::setPersistent(
}
void CJS_Global::UpdateGlobalPersistentVariables() {
- CJS_Runtime* pRuntime =
- static_cast<CJS_Runtime*>(CFXJS_Engine::EngineFromIsolateCurrentContext(
- ToV8Object()->GetIsolate()));
+ CJS_Runtime* pRuntime = GetRuntime();
+ if (!pRuntime)
+ return;
for (int i = 0, sz = m_pGlobalData->GetSize(); i < sz; i++) {
CJS_GlobalData_Element* pData = m_pGlobalData->GetAt(i);
@@ -450,8 +450,9 @@ void CJS_Global::ObjectToArray(CJS_Runtime* pRuntime,
void CJS_Global::PutObjectProperty(v8::Local<v8::Object> pObj,
CJS_KeyValue* pData) {
- CJS_Runtime* pRuntime =
- CJS_Runtime::RuntimeFromIsolateCurrentContext(ToV8Object()->GetIsolate());
+ CJS_Runtime* pRuntime = GetRuntime();
+ if (pRuntime)
+ return;
for (int i = 0, sz = pData->objData.Count(); i < sz; i++) {
CJS_KeyValue* pObjData = pData->objData.GetAt(i);
diff --git a/fxjs/cjs_publicmethods.cpp b/fxjs/cjs_publicmethods.cpp
index d37706c973..678aca5317 100644
--- a/fxjs/cjs_publicmethods.cpp
+++ b/fxjs/cjs_publicmethods.cpp
@@ -120,8 +120,11 @@ template <CJS_Return (*F)(CJS_Runtime*,
const std::vector<v8::Local<v8::Value>>&)>
void JSGlobalFunc(const char* func_name_string,
const v8::FunctionCallbackInfo<v8::Value>& info) {
- CJS_Runtime* pRuntime =
- CJS_Runtime::RuntimeFromIsolateCurrentContext(info.GetIsolate());
+ CJS_Object* pObj = CFXJS_Engine::GetObjectPrivate(info.Holder());
+ if (!pObj)
+ return;
+
+ CJS_Runtime* pRuntime = pObj->GetRuntime();
if (!pRuntime)
return;
diff --git a/fxjs/cjs_runtime.cpp b/fxjs/cjs_runtime.cpp
index 2896c5f701..d7ee93ff2c 100644
--- a/fxjs/cjs_runtime.cpp
+++ b/fxjs/cjs_runtime.cpp
@@ -46,13 +46,6 @@
#include "fxjs/cfxjse_value.h"
#endif // PDF_ENABLE_XFA
-// static
-CJS_Runtime* CJS_Runtime::RuntimeFromIsolateCurrentContext(
- v8::Isolate* pIsolate) {
- return static_cast<CJS_Runtime*>(
- CFXJS_Engine::EngineFromIsolateCurrentContext(pIsolate));
-}
-
CJS_Runtime::CJS_Runtime(CPDFSDK_FormFillEnvironment* pFormFillEnv)
: m_pFormFillEnv(pFormFillEnv),
m_bBlocking(false),
diff --git a/fxjs/cjs_runtime.h b/fxjs/cjs_runtime.h
index 0c32562304..73b722db43 100644
--- a/fxjs/cjs_runtime.h
+++ b/fxjs/cjs_runtime.h
@@ -27,8 +27,6 @@ class CJS_Runtime : public IJS_Runtime,
public:
using FieldEvent = std::pair<WideString, JS_EVENT_T>;
- static CJS_Runtime* RuntimeFromIsolateCurrentContext(v8::Isolate* pIsolate);
-
explicit CJS_Runtime(CPDFSDK_FormFillEnvironment* pFormFillEnv);
~CJS_Runtime() override;
diff --git a/fxjs/js_define.cpp b/fxjs/js_define.cpp
index 3e14a3dd1d..124fd91651 100644
--- a/fxjs/js_define.cpp
+++ b/fxjs/js_define.cpp
@@ -236,8 +236,10 @@ double JS_DateParse(const WideString& str) {
v8::Local<v8::Function> funC = v8::Local<v8::Function>::Cast(v);
const int argc = 1;
v8::Local<v8::Value> timeStr =
- CJS_Runtime::RuntimeFromIsolateCurrentContext(pIsolate)->NewString(
- str.AsStringView());
+ v8::String::NewFromUtf8(pIsolate,
+ FX_UTF8Encode(str.AsStringView()).c_str(),
+ v8::NewStringType::kNormal)
+ .ToLocalChecked();
v8::Local<v8::Value> argv[argc] = {timeStr};
v = funC->Call(context, context->Global(), argc, argv).ToLocalChecked();
if (v->IsNumber()) {