summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--fpdfsdk/javascript/JS_Runtime_Stub.cpp4
-rw-r--r--fpdfsdk/javascript/cjs_context.cpp2
-rw-r--r--fpdfsdk/javascript/cjs_runtime.cpp6
-rw-r--r--fpdfsdk/javascript/cjs_runtime.h4
-rw-r--r--fpdfsdk/javascript/ijs_runtime.h4
-rw-r--r--fpdfsdk/jsapi/fxjs_v8.cpp5
-rw-r--r--fpdfsdk/jsapi/fxjs_v8_embeddertest.cpp12
-rw-r--r--fpdfsdk/jsapi/include/fxjs_v8.h3
8 files changed, 15 insertions, 25 deletions
diff --git a/fpdfsdk/javascript/JS_Runtime_Stub.cpp b/fpdfsdk/javascript/JS_Runtime_Stub.cpp
index e94f8c7780..4930900337 100644
--- a/fpdfsdk/javascript/JS_Runtime_Stub.cpp
+++ b/fpdfsdk/javascript/JS_Runtime_Stub.cpp
@@ -148,9 +148,7 @@ class CJS_RuntimeStub final : public IJS_Runtime {
}
#endif // PDF_ENABLE_XFA
- int Execute(IJS_Context* cc,
- const wchar_t* script,
- CFX_WideString* info) override {
+ int Execute(const CFX_WideString& script, CFX_WideString* info) override {
return 0;
}
diff --git a/fpdfsdk/javascript/cjs_context.cpp b/fpdfsdk/javascript/cjs_context.cpp
index c8630ab32d..b844dc6e5c 100644
--- a/fpdfsdk/javascript/cjs_context.cpp
+++ b/fpdfsdk/javascript/cjs_context.cpp
@@ -51,7 +51,7 @@ FX_BOOL CJS_Context::RunScript(const CFX_WideString& script,
CFX_WideString sErrorMessage;
int nRet = 0;
if (script.GetLength() > 0) {
- nRet = m_pRuntime->Execute(this, script.c_str(), &sErrorMessage);
+ nRet = m_pRuntime->Execute(script.c_str(), &sErrorMessage);
}
if (nRet < 0) {
diff --git a/fpdfsdk/javascript/cjs_runtime.cpp b/fpdfsdk/javascript/cjs_runtime.cpp
index 9cbf1b003a..2c0ed32bd6 100644
--- a/fpdfsdk/javascript/cjs_runtime.cpp
+++ b/fpdfsdk/javascript/cjs_runtime.cpp
@@ -214,11 +214,9 @@ void CJS_Runtime::SetReaderDocument(CPDFSDK_Document* pReaderDoc) {
}
}
-int CJS_Runtime::Execute(IJS_Context* cc,
- const wchar_t* script,
- CFX_WideString* info) {
+int CJS_Runtime::Execute(const CFX_WideString& script, CFX_WideString* info) {
FXJSErr error = {};
- int nRet = FXJS_Execute(m_isolate, cc, script, &error);
+ int nRet = FXJS_Execute(m_isolate, script, &error);
if (nRet < 0) {
info->Format(L"[ Line: %05d { %s } ] : %s", error.linnum - 1, error.srcline,
error.message);
diff --git a/fpdfsdk/javascript/cjs_runtime.h b/fpdfsdk/javascript/cjs_runtime.h
index cc0f6545ac..4181bd21c9 100644
--- a/fpdfsdk/javascript/cjs_runtime.h
+++ b/fpdfsdk/javascript/cjs_runtime.h
@@ -43,9 +43,7 @@ class CJS_Runtime : public IJS_Runtime {
IJS_Context* GetCurrentContext() override;
void SetReaderDocument(CPDFSDK_Document* pReaderDoc) override;
CPDFSDK_Document* GetReaderDocument() override { return m_pDocument; }
- int Execute(IJS_Context* cc,
- const wchar_t* script,
- CFX_WideString* info) override;
+ int Execute(const CFX_WideString& script, CFX_WideString* info) override;
CPDFDoc_Environment* GetReaderApp() const { return m_pApp; }
diff --git a/fpdfsdk/javascript/ijs_runtime.h b/fpdfsdk/javascript/ijs_runtime.h
index ef80feb820..19a440e6ed 100644
--- a/fpdfsdk/javascript/ijs_runtime.h
+++ b/fpdfsdk/javascript/ijs_runtime.h
@@ -30,9 +30,7 @@ class IJS_Runtime {
virtual IJS_Context* GetCurrentContext() = 0;
virtual void SetReaderDocument(CPDFSDK_Document* pReaderDoc) = 0;
virtual CPDFSDK_Document* GetReaderDocument() = 0;
- virtual int Execute(IJS_Context* cc,
- const wchar_t* script,
- CFX_WideString* info) = 0;
+ virtual int Execute(const CFX_WideString& script, CFX_WideString* info) = 0;
#ifdef PDF_ENABLE_XFA
virtual FX_BOOL GetValueByName(const CFX_ByteStringC& utf8Name,
diff --git a/fpdfsdk/jsapi/fxjs_v8.cpp b/fpdfsdk/jsapi/fxjs_v8.cpp
index f8c2a3dd6d..73f6bbf4fb 100644
--- a/fpdfsdk/jsapi/fxjs_v8.cpp
+++ b/fpdfsdk/jsapi/fxjs_v8.cpp
@@ -414,12 +414,11 @@ void FXJS_SetRuntimeForV8Context(v8::Local<v8::Context> v8Context,
#endif // PDF_ENABLE_XFA
int FXJS_Execute(v8::Isolate* pIsolate,
- IJS_Context* pJSContext,
- const wchar_t* script,
+ const CFX_WideString& script,
FXJSErr* pError) {
v8::Isolate::Scope isolate_scope(pIsolate);
v8::TryCatch try_catch(pIsolate);
- CFX_ByteString bsScript = CFX_WideString(script).UTF8Encode();
+ CFX_ByteString bsScript = script.UTF8Encode();
v8::Local<v8::Context> context = pIsolate->GetCurrentContext();
v8::Local<v8::Script> compiled_script;
if (!v8::Script::Compile(context,
diff --git a/fpdfsdk/jsapi/fxjs_v8_embeddertest.cpp b/fpdfsdk/jsapi/fxjs_v8_embeddertest.cpp
index a8358c4ee9..b33ddca32d 100644
--- a/fpdfsdk/jsapi/fxjs_v8_embeddertest.cpp
+++ b/fpdfsdk/jsapi/fxjs_v8_embeddertest.cpp
@@ -19,9 +19,9 @@ const wchar_t kScript2[] = L"fred = 8";
class FXJSV8EmbedderTest : public JSEmbedderTest {
public:
- void ExecuteInCurrentContext(const wchar_t* script) {
+ void ExecuteInCurrentContext(const CFX_WideString& script) {
FXJSErr error;
- int sts = FXJS_Execute(isolate(), nullptr, script, &error);
+ int sts = FXJS_Execute(isolate(), script, &error);
EXPECT_EQ(0, sts);
}
void CheckAssignmentInCurrentContext(double expected) {
@@ -39,7 +39,7 @@ TEST_F(FXJSV8EmbedderTest, Getters) {
v8::HandleScope handle_scope(isolate());
v8::Context::Scope context_scope(GetV8Context());
- ExecuteInCurrentContext(kScript1);
+ ExecuteInCurrentContext(CFX_WideString(kScript1));
CheckAssignmentInCurrentContext(kExpected1);
}
@@ -58,14 +58,14 @@ TEST_F(FXJSV8EmbedderTest, MultipleRutimes) {
&static_objects2);
v8::Context::Scope context_scope(GetV8Context());
- ExecuteInCurrentContext(kScript0);
+ ExecuteInCurrentContext(CFX_WideString(kScript0));
CheckAssignmentInCurrentContext(kExpected0);
{
v8::Local<v8::Context> context1 =
v8::Local<v8::Context>::New(isolate(), global_context1);
v8::Context::Scope context_scope1(context1);
- ExecuteInCurrentContext(kScript1);
+ ExecuteInCurrentContext(CFX_WideString(kScript1));
CheckAssignmentInCurrentContext(kExpected1);
}
FXJS_ReleaseRuntime(isolate(), &global_context1, &static_objects1);
@@ -74,7 +74,7 @@ TEST_F(FXJSV8EmbedderTest, MultipleRutimes) {
v8::Local<v8::Context> context2 =
v8::Local<v8::Context>::New(isolate(), global_context2);
v8::Context::Scope context_scope2(context2);
- ExecuteInCurrentContext(kScript2);
+ ExecuteInCurrentContext(CFX_WideString(kScript2));
CheckAssignmentInCurrentContext(kExpected2);
}
FXJS_ReleaseRuntime(isolate(), &global_context2, &static_objects2);
diff --git a/fpdfsdk/jsapi/include/fxjs_v8.h b/fpdfsdk/jsapi/include/fxjs_v8.h
index 235f3bc902..6606df4d26 100644
--- a/fpdfsdk/jsapi/include/fxjs_v8.h
+++ b/fpdfsdk/jsapi/include/fxjs_v8.h
@@ -211,8 +211,7 @@ void FXJS_SetRuntimeForV8Context(v8::Local<v8::Context> v8Context,
// Called after FXJS_InitializeRuntime call made.
int FXJS_Execute(v8::Isolate* pIsolate,
- IJS_Context* pJSContext,
- const wchar_t* script,
+ const CFX_WideString& script,
FXJSErr* perror);
v8::Local<v8::Object> FXJS_NewFxDynamicObj(v8::Isolate* pIsolate,