summaryrefslogtreecommitdiff
path: root/fpdfsdk/javascript/util.cpp
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2017-02-16 17:01:00 -0800
committerChromium commit bot <commit-bot@chromium.org>2017-02-21 15:18:27 +0000
commitb1670b5cca9a59dfb612ef9eb891a70dd716bf9c (patch)
treee624b1ca93721894ff29a14bb52443bf4f952cf6 /fpdfsdk/javascript/util.cpp
parent026f3d306d339585612d63a9f6ac5ed8839a3179 (diff)
downloadpdfium-b1670b5cca9a59dfb612ef9eb891a70dd716bf9c.tar.xz
Pass CJS_Runtime to JS callbacks.
This is much more convenient, since only a fraction of them need an IJS_EventContext, which can be obtained from the CJS_Runtime. Make GetCurrentEventContext() specific to CJS_Runtime, and return the concrete type. This saves a lot of casting. Change-Id: If79a3bcbf44de513f3caace153099234cc313d47 Reviewed-on: https://pdfium-review.googlesource.com/2793 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'fpdfsdk/javascript/util.cpp')
-rw-r--r--fpdfsdk/javascript/util.cpp15
1 files changed, 5 insertions, 10 deletions
diff --git a/fpdfsdk/javascript/util.cpp b/fpdfsdk/javascript/util.cpp
index 0baca534b4..8ae1773c49 100644
--- a/fpdfsdk/javascript/util.cpp
+++ b/fpdfsdk/javascript/util.cpp
@@ -114,11 +114,10 @@ util::util(CJS_Object* pJSObject) : CJS_EmbedObj(pJSObject) {}
util::~util() {}
-bool util::printf(IJS_EventContext* cc,
+bool util::printf(CJS_Runtime* pRuntime,
const std::vector<CJS_Value>& params,
CJS_Value& vRet,
CFX_WideString& sError) {
- CJS_Runtime* pRuntime = CJS_Runtime::FromEventContext(cc);
int iSize = params.size();
if (iSize < 1)
return false;
@@ -177,7 +176,7 @@ bool util::printf(IJS_EventContext* cc,
return true;
}
-bool util::printd(IJS_EventContext* cc,
+bool util::printd(CJS_Runtime* pRuntime,
const std::vector<CJS_Value>& params,
CJS_Value& vRet,
CFX_WideString& sError) {
@@ -185,7 +184,6 @@ bool util::printd(IJS_EventContext* cc,
if (iSize < 2)
return false;
- CJS_Runtime* pRuntime = CJS_Runtime::FromEventContext(cc);
CJS_Value p1 = params[0];
CJS_Value p2 = params[1];
CJS_Date jsDate;
@@ -307,7 +305,7 @@ bool util::printd(IJS_EventContext* cc,
return false;
}
-bool util::printx(IJS_EventContext* cc,
+bool util::printx(CJS_Runtime* pRuntime,
const std::vector<CJS_Value>& params,
CJS_Value& vRet,
CFX_WideString& sError) {
@@ -316,7 +314,6 @@ bool util::printx(IJS_EventContext* cc,
return false;
}
- CJS_Runtime* pRuntime = CJS_Runtime::FromEventContext(cc);
vRet = CJS_Value(pRuntime, printx(params[0].ToCFXWideString(pRuntime),
params[1].ToCFXWideString(pRuntime))
.c_str());
@@ -425,11 +422,10 @@ CFX_WideString util::printx(const CFX_WideString& wsFormat,
return wsResult;
}
-bool util::scand(IJS_EventContext* cc,
+bool util::scand(CJS_Runtime* pRuntime,
const std::vector<CJS_Value>& params,
CJS_Value& vRet,
CFX_WideString& sError) {
- CJS_Runtime* pRuntime = CJS_Runtime::FromEventContext(cc);
int iSize = params.size();
if (iSize < 2)
return false;
@@ -450,7 +446,7 @@ bool util::scand(IJS_EventContext* cc,
return true;
}
-bool util::byteToChar(IJS_EventContext* cc,
+bool util::byteToChar(CJS_Runtime* pRuntime,
const std::vector<CJS_Value>& params,
CJS_Value& vRet,
CFX_WideString& sError) {
@@ -459,7 +455,6 @@ bool util::byteToChar(IJS_EventContext* cc,
return false;
}
- CJS_Runtime* pRuntime = CJS_Runtime::FromEventContext(cc);
int arg = params[0].ToInt(pRuntime);
if (arg < 0 || arg > 255) {
sError = JSGetStringFromID(IDS_STRING_JSVALUEERROR);