summaryrefslogtreecommitdiff
path: root/fxjs/cjs_global.cpp
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2018-06-06 18:30:15 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-06-06 18:30:15 +0000
commitddaa40fe873070d3aae9a21b9a93848fc7e809f1 (patch)
tree222d228484da9e234a647254440e9aff98dca224 /fxjs/cjs_global.cpp
parent5caa34c64382d8587a3ec3de5edbb30976b1390d (diff)
downloadpdfium-ddaa40fe873070d3aae9a21b9a93848fc7e809f1.tar.xz
Stop using some v8::Context slot to find runtime.
Instead, use the object binding's pointer. Puts the cart back behind the horse. Change-Id: I4c06ae991b871c6e90b0e6c70b69886addca2354 Reviewed-on: https://pdfium-review.googlesource.com/33630 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'fxjs/cjs_global.cpp')
-rw-r--r--fxjs/cjs_global.cpp54
1 files changed, 24 insertions, 30 deletions
diff --git a/fxjs/cjs_global.cpp b/fxjs/cjs_global.cpp
index 9a1f541212..5834ab9600 100644
--- a/fxjs/cjs_global.cpp
+++ b/fxjs/cjs_global.cpp
@@ -32,18 +32,17 @@ template <class Alt>
void JSSpecialPropQuery(const char*,
v8::Local<v8::String> property,
const v8::PropertyCallbackInfo<v8::Integer>& info) {
- CJS_Runtime* pRuntime =
- CJS_Runtime::RuntimeFromIsolateCurrentContext(info.GetIsolate());
- if (!pRuntime)
+ CJS_Object* pJSObj = CFXJS_Engine::GetObjectPrivate(info.Holder());
+ if (!pJSObj)
return;
- CJS_Object* pJSObj = pRuntime->GetObjectPrivate(info.Holder());
- if (!pJSObj)
+ CJS_Runtime* pRuntime = pJSObj->GetRuntime();
+ if (!pRuntime)
return;
- Alt* pObj = static_cast<Alt*>(pJSObj);
- CJS_Return result =
- pObj->QueryProperty(PropFromV8Prop(info.GetIsolate(), property).c_str());
+ CJS_Return result = static_cast<Alt*>(pJSObj)->QueryProperty(
+ PropFromV8Prop(info.GetIsolate(), property).c_str());
+
info.GetReturnValue().Set(!result.HasError() ? 4 : 0);
}
@@ -51,24 +50,22 @@ template <class Alt>
void JSSpecialPropGet(const char* class_name,
v8::Local<v8::String> property,
const v8::PropertyCallbackInfo<v8::Value>& info) {
- CJS_Runtime* pRuntime =
- CJS_Runtime::RuntimeFromIsolateCurrentContext(info.GetIsolate());
- if (!pRuntime)
+ CJS_Object* pJSObj = CFXJS_Engine::GetObjectPrivate(info.Holder());
+ if (!pJSObj)
return;
- CJS_Object* pJSObj = pRuntime->GetObjectPrivate(info.Holder());
- if (!pJSObj)
+ CJS_Runtime* pRuntime = pJSObj->GetRuntime();
+ if (!pRuntime)
return;
- Alt* pObj = static_cast<Alt*>(pJSObj);
- CJS_Return result = pObj->GetProperty(
+ CJS_Return result = static_cast<Alt*>(pJSObj)->GetProperty(
pRuntime, PropFromV8Prop(info.GetIsolate(), property).c_str());
+
if (result.HasError()) {
pRuntime->Error(
JSFormatErrorString(class_name, "GetProperty", result.Error()));
return;
}
-
if (result.HasReturn())
info.GetReturnValue().Set(result.Return());
}
@@ -78,18 +75,17 @@ void JSSpecialPropPut(const char* class_name,
v8::Local<v8::String> property,
v8::Local<v8::Value> value,
const v8::PropertyCallbackInfo<v8::Value>& info) {
- CJS_Runtime* pRuntime =
- CJS_Runtime::RuntimeFromIsolateCurrentContext(info.GetIsolate());
- if (!pRuntime)
+ CJS_Object* pJSObj = CFXJS_Engine::GetObjectPrivate(info.Holder());
+ if (!pJSObj)
return;
- CJS_Object* pJSObj = pRuntime->GetObjectPrivate(info.Holder());
- if (!pJSObj)
+ CJS_Runtime* pRuntime = pJSObj->GetRuntime();
+ if (!pRuntime)
return;
- Alt* pObj = static_cast<Alt*>(pJSObj);
- CJS_Return result = pObj->SetProperty(
+ CJS_Return result = static_cast<Alt*>(pJSObj)->SetProperty(
pRuntime, PropFromV8Prop(info.GetIsolate(), property).c_str(), value);
+
if (result.HasError()) {
pRuntime->Error(
JSFormatErrorString(class_name, "PutProperty", result.Error()));
@@ -100,17 +96,15 @@ template <class Alt>
void JSSpecialPropDel(const char* class_name,
v8::Local<v8::String> property,
const v8::PropertyCallbackInfo<v8::Boolean>& info) {
- CJS_Runtime* pRuntime =
- CJS_Runtime::RuntimeFromIsolateCurrentContext(info.GetIsolate());
- if (!pRuntime)
+ CJS_Object* pJSObj = CFXJS_Engine::GetObjectPrivate(info.Holder());
+ if (!pJSObj)
return;
- CJS_Object* pJSObj = pRuntime->GetObjectPrivate(info.Holder());
- if (!pJSObj)
+ CJS_Runtime* pRuntime = pJSObj->GetRuntime();
+ if (!pRuntime)
return;
- Alt* pObj = static_cast<Alt*>(pJSObj);
- CJS_Return result = pObj->DelProperty(
+ CJS_Return result = static_cast<Alt*>(pJSObj)->DelProperty(
pRuntime, PropFromV8Prop(info.GetIsolate(), property).c_str());
if (result.HasError()) {
// TODO(dsinclair): Should this set the pRuntime->Error result?