summaryrefslogtreecommitdiff
path: root/fpdfsdk/javascript/util.cpp
diff options
context:
space:
mode:
authortsepez <tsepez@chromium.org>2016-09-08 11:23:24 -0700
committerCommit bot <commit-bot@chromium.org>2016-09-08 11:23:24 -0700
commitcd5dc855df0ca37b7667b5f3ceb951d2d417d99f (patch)
tree3b7b7a8ab8a1738fd11a94df733ceff0cfae299f /fpdfsdk/javascript/util.cpp
parent8832fbf53cf71d4d4cb53986d9cfc024edd2bf1f (diff)
downloadpdfium-cd5dc855df0ca37b7667b5f3ceb951d2d417d99f.tar.xz
Remove unused context parameter from JSGetStringFromID
Clean up before using IDS_STRING_JSBADOBJECT in nearly all JS callbacks, which will happen in the next CL when we watch C-side object destruction. Add a "no permission" message as well. Review-Url: https://codereview.chromium.org/2319543003
Diffstat (limited to 'fpdfsdk/javascript/util.cpp')
-rw-r--r--fpdfsdk/javascript/util.cpp23
1 files changed, 10 insertions, 13 deletions
diff --git a/fpdfsdk/javascript/util.cpp b/fpdfsdk/javascript/util.cpp
index fa53a9e223..44511f591f 100644
--- a/fpdfsdk/javascript/util.cpp
+++ b/fpdfsdk/javascript/util.cpp
@@ -190,12 +190,12 @@ FX_BOOL util::printd(IJS_Context* cc,
CJS_Value p2 = params[1];
CJS_Date jsDate;
if (!p2.ConvertToDate(pRuntime, jsDate)) {
- sError = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSPRINT1);
+ sError = JSGetStringFromID(IDS_STRING_JSPRINT1);
return FALSE;
}
if (!jsDate.IsValidDate(pRuntime)) {
- sError = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSPRINT2);
+ sError = JSGetStringFromID(IDS_STRING_JSPRINT2);
return FALSE;
}
@@ -223,7 +223,7 @@ FX_BOOL util::printd(IJS_Context* cc,
jsDate.GetSeconds(pRuntime));
break;
default:
- sError = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSVALUEERROR);
+ sError = JSGetStringFromID(IDS_STRING_JSVALUEERROR);
return FALSE;
}
@@ -233,7 +233,7 @@ FX_BOOL util::printd(IJS_Context* cc,
if (p1.GetType() == CJS_Value::VT_string) {
if (iSize > 2 && params[2].ToBool(pRuntime)) {
- sError = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_NOTSUPPORT);
+ sError = JSGetStringFromID(IDS_STRING_JSNOTSUPPORT);
return FALSE; // currently, it doesn't support XFAPicture.
}
@@ -303,7 +303,7 @@ FX_BOOL util::printd(IJS_Context* cc,
return TRUE;
}
- sError = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSTYPEERROR);
+ sError = JSGetStringFromID(IDS_STRING_JSTYPEERROR);
return FALSE;
}
@@ -312,13 +312,12 @@ FX_BOOL util::printx(IJS_Context* cc,
const std::vector<CJS_Value>& params,
CJS_Value& vRet,
CFX_WideString& sError) {
- CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
-
if (params.size() < 2) {
- sError = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSPARAMERROR);
+ sError = JSGetStringFromID(IDS_STRING_JSPARAMERROR);
return FALSE;
}
+ CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
vRet = CJS_Value(pRuntime, printx(params[0].ToCFXWideString(pRuntime),
params[1].ToCFXWideString(pRuntime))
.c_str());
@@ -456,17 +455,15 @@ FX_BOOL util::byteToChar(IJS_Context* cc,
const std::vector<CJS_Value>& params,
CJS_Value& vRet,
CFX_WideString& sError) {
- CJS_Context* pContext = static_cast<CJS_Context*>(cc);
- CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
-
if (params.size() < 1) {
- sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
+ sError = JSGetStringFromID(IDS_STRING_JSPARAMERROR);
return FALSE;
}
+ CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
int arg = params[0].ToInt(pRuntime);
if (arg < 0 || arg > 255) {
- sError = JSGetStringFromID(pContext, IDS_STRING_JSVALUEERROR);
+ sError = JSGetStringFromID(IDS_STRING_JSVALUEERROR);
return FALSE;
}