summaryrefslogtreecommitdiff
path: root/fpdfsdk/javascript/global.cpp
diff options
context:
space:
mode:
authordan sinclair <dsinclair@chromium.org>2017-10-24 21:40:24 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-10-25 18:14:09 +0000
commit80435cb746fa7bd22cf062ab39829ec86000fd21 (patch)
tree9085fa57d5f49eac4b56b065ca572f424c9f744b /fpdfsdk/javascript/global.cpp
parente85107bc8ab5bbd5b2d3f97fd6071d7ce4a78bcc (diff)
downloadpdfium-80435cb746fa7bd22cf062ab39829ec86000fd21.tar.xz
Convert JS input params to v8::Local<v8::Value>>s
This CL converts the JS set_* methods and the JSMethod methods to accept v8::Local<v8::Value> objects instead of CJS_Value objects. Change-Id: I6de41305deff458eba515bdc3462522b502f74ad Reviewed-on: https://pdfium-review.googlesource.com/16670 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'fpdfsdk/javascript/global.cpp')
-rw-r--r--fpdfsdk/javascript/global.cpp43
1 files changed, 21 insertions, 22 deletions
diff --git a/fpdfsdk/javascript/global.cpp b/fpdfsdk/javascript/global.cpp
index aae7c93160..040c6e6067 100644
--- a/fpdfsdk/javascript/global.cpp
+++ b/fpdfsdk/javascript/global.cpp
@@ -131,10 +131,8 @@ void JSSpecialPropPut(const char* class_name,
v8::String::Utf8Value utf8_value(property);
WideString propname =
WideString::FromUTF8(ByteStringView(*utf8_value, utf8_value.length()));
- CJS_Value prop_value(value);
- if (!pObj->SetProperty(pRuntime, propname.c_str(), prop_value)) {
+ if (!pObj->SetProperty(pRuntime, propname.c_str(), value))
pRuntime->Error(JSFormatErrorString(class_name, "PutProperty", L""));
- }
}
template <class Alt>
@@ -181,7 +179,7 @@ class JSGlobalAlternate : public CJS_EmbedObj {
~JSGlobalAlternate() override;
bool setPersistent(CJS_Runtime* pRuntime,
- const std::vector<CJS_Value>& params,
+ const std::vector<v8::Local<v8::Value>>& params,
CJS_Value& vRet,
WideString& sError);
bool QueryProperty(const wchar_t* propname);
@@ -190,7 +188,7 @@ class JSGlobalAlternate : public CJS_EmbedObj {
CJS_Value* vp);
bool SetProperty(CJS_Runtime* pRuntime,
const wchar_t* propname,
- const CJS_Value& vp);
+ v8::Local<v8::Value> vp);
bool DelProperty(CJS_Runtime* pRuntime, const wchar_t* propname);
void Initial(CPDFSDK_FormFillEnvironment* pFormFillEnv);
@@ -323,54 +321,55 @@ bool JSGlobalAlternate::GetProperty(CJS_Runtime* pRuntime,
bool JSGlobalAlternate::SetProperty(CJS_Runtime* pRuntime,
const wchar_t* propname,
- const CJS_Value& vp) {
+ v8::Local<v8::Value> vp) {
ByteString sPropName = ByteString::FromUnicode(propname);
- if (vp.ToV8Value()->IsNumber()) {
+ if (vp->IsNumber()) {
return SetGlobalVariables(sPropName, JS_GlobalDataType::NUMBER,
- pRuntime->ToDouble(vp.ToV8Value()), false, "",
+ pRuntime->ToDouble(vp), false, "",
v8::Local<v8::Object>(), false);
}
- if (vp.ToV8Value()->IsBoolean()) {
+ if (vp->IsBoolean()) {
return SetGlobalVariables(sPropName, JS_GlobalDataType::BOOLEAN, 0,
- pRuntime->ToBoolean(vp.ToV8Value()), "",
+ pRuntime->ToBoolean(vp), "",
v8::Local<v8::Object>(), false);
}
- if (vp.ToV8Value()->IsString()) {
+ if (vp->IsString()) {
return SetGlobalVariables(
sPropName, JS_GlobalDataType::STRING, 0, false,
- ByteString::FromUnicode(pRuntime->ToWideString(vp.ToV8Value())),
+ ByteString::FromUnicode(pRuntime->ToWideString(vp)),
v8::Local<v8::Object>(), false);
}
- if (vp.ToV8Value()->IsObject()) {
+ if (vp->IsObject()) {
return SetGlobalVariables(sPropName, JS_GlobalDataType::OBJECT, 0, false,
- "", pRuntime->ToObject(vp.ToV8Value()), false);
+ "", pRuntime->ToObject(vp), false);
}
- if (vp.ToV8Value()->IsNull()) {
+ if (vp->IsNull()) {
return SetGlobalVariables(sPropName, JS_GlobalDataType::NULLOBJ, 0, false,
"", v8::Local<v8::Object>(), false);
}
- if (vp.ToV8Value()->IsUndefined()) {
+ if (vp->IsUndefined()) {
DelProperty(pRuntime, propname);
return true;
}
return false;
}
-bool JSGlobalAlternate::setPersistent(CJS_Runtime* pRuntime,
- const std::vector<CJS_Value>& params,
- CJS_Value& vRet,
- WideString& sError) {
+bool JSGlobalAlternate::setPersistent(
+ CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params,
+ CJS_Value& vRet,
+ WideString& sError) {
if (params.size() != 2) {
sError = JSGetStringFromID(IDS_STRING_JSPARAMERROR);
return false;
}
auto it = m_MapGlobal.find(
- ByteString::FromUnicode(pRuntime->ToWideString(params[0].ToV8Value())));
+ ByteString::FromUnicode(pRuntime->ToWideString(params[0])));
if (it == m_MapGlobal.end() || it->second->bDeleted) {
sError = JSGetStringFromID(IDS_STRING_JSNOGLOBAL);
return false;
}
- it->second->bPersistent = pRuntime->ToBoolean(params[1].ToV8Value());
+ it->second->bPersistent = pRuntime->ToBoolean(params[1]);
return true;
}