Make IJS_Runtime::AsCJSRuntime be XFA-only
Since it is only called from the XFA side.
Change-Id: I6e34b39bb0c28db9b367215fae0285acafa22c14
Reviewed-on: https://pdfium-review.googlesource.com/c/44810
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/fxjs/cjs_runtime.cpp b/fxjs/cjs_runtime.cpp
index 5364571..5034915 100644
--- a/fxjs/cjs_runtime.cpp
+++ b/fxjs/cjs_runtime.cpp
@@ -127,10 +127,6 @@
CJS_Annot::DefineJSObjects(this);
}
-CJS_Runtime* CJS_Runtime::AsCJSRuntime() {
- return this;
-}
-
IJS_EventContext* CJS_Runtime::NewEventContext() {
m_EventContextArray.push_back(pdfium::MakeUnique<CJS_EventContext>(this));
return m_EventContextArray.back().get();
@@ -187,6 +183,10 @@
return sRet;
}
+CJS_Runtime* CJS_Runtime::AsCJSRuntime() {
+ return this;
+}
+
bool CJS_Runtime::GetValueByNameFromGlobalObject(const ByteStringView& utf8Name,
CFXJSE_Value* pValue) {
v8::Isolate::Scope isolate_scope(GetIsolate());
diff --git a/fxjs/cjs_runtime.h b/fxjs/cjs_runtime.h
index 99dbd0d..687fdee 100644
--- a/fxjs/cjs_runtime.h
+++ b/fxjs/cjs_runtime.h
@@ -30,7 +30,6 @@
~CJS_Runtime() override;
// IJS_Runtime
- CJS_Runtime* AsCJSRuntime() override;
IJS_EventContext* NewEventContext() override;
void ReleaseEventContext(IJS_EventContext* pContext) override;
CPDFSDK_FormFillEnvironment* GetFormFillEnv() const override;
@@ -52,6 +51,7 @@
v8::Local<v8::Value> MaybeCoerceToNumber(v8::Local<v8::Value> value);
#ifdef PDF_ENABLE_XFA
+ CJS_Runtime* AsCJSRuntime() override;
bool GetValueByNameFromGlobalObject(const ByteStringView& utf8Name,
CFXJSE_Value* pValue) override;
bool SetValueByNameInGlobalObject(const ByteStringView& utf8Name,
diff --git a/fxjs/cjs_runtimestub.cpp b/fxjs/cjs_runtimestub.cpp
index 44bdbca..53ca17c 100644
--- a/fxjs/cjs_runtimestub.cpp
+++ b/fxjs/cjs_runtimestub.cpp
@@ -14,10 +14,6 @@
CJS_RuntimeStub::~CJS_RuntimeStub() = default;
-CJS_Runtime* CJS_RuntimeStub::AsCJSRuntime() {
- return nullptr;
-}
-
IJS_EventContext* CJS_RuntimeStub::NewEventContext() {
if (!m_pContext)
m_pContext = pdfium::MakeUnique<CJS_EventContextStub>();
@@ -31,6 +27,10 @@
}
#ifdef PDF_ENABLE_XFA
+CJS_Runtime* CJS_RuntimeStub::AsCJSRuntime() {
+ return nullptr;
+}
+
bool CJS_RuntimeStub::GetValueByNameFromGlobalObject(const ByteStringView&,
CFXJSE_Value*) {
return false;
diff --git a/fxjs/cjs_runtimestub.h b/fxjs/cjs_runtimestub.h
index 779a675..b4bb2dd 100644
--- a/fxjs/cjs_runtimestub.h
+++ b/fxjs/cjs_runtimestub.h
@@ -21,12 +21,13 @@
explicit CJS_RuntimeStub(CPDFSDK_FormFillEnvironment* pFormFillEnv);
~CJS_RuntimeStub() override;
- CJS_Runtime* AsCJSRuntime() override;
+ // IJS_Runtime:
IJS_EventContext* NewEventContext() override;
void ReleaseEventContext(IJS_EventContext* pContext) override;
CPDFSDK_FormFillEnvironment* GetFormFillEnv() const override;
#ifdef PDF_ENABLE_XFA
+ CJS_Runtime* AsCJSRuntime() override;
bool GetValueByNameFromGlobalObject(const ByteStringView&,
CFXJSE_Value*) override;
bool SetValueByNameInGlobalObject(const ByteStringView&,
diff --git a/fxjs/ijs_runtime.h b/fxjs/ijs_runtime.h
index 781e86c..19f3c63 100644
--- a/fxjs/ijs_runtime.h
+++ b/fxjs/ijs_runtime.h
@@ -52,13 +52,13 @@
virtual ~IJS_Runtime();
- virtual CJS_Runtime* AsCJSRuntime() = 0;
virtual IJS_EventContext* NewEventContext() = 0;
virtual void ReleaseEventContext(IJS_EventContext* pContext) = 0;
virtual CPDFSDK_FormFillEnvironment* GetFormFillEnv() const = 0;
virtual Optional<JS_Error> ExecuteScript(const WideString& script) = 0;
#ifdef PDF_ENABLE_XFA
+ virtual CJS_Runtime* AsCJSRuntime() = 0;
virtual bool GetValueByNameFromGlobalObject(const ByteStringView& utf8Name,
CFXJSE_Value* pValue) = 0;
virtual bool SetValueByNameInGlobalObject(const ByteStringView& utf8Name,