From 2dd06eb37dd9cb31746b1ab7e9ed306b2a12a3b7 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Mon, 29 Oct 2018 21:16:42 +0000 Subject: 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 Commit-Queue: Tom Sepez --- fxjs/cjs_runtime.cpp | 8 ++++---- fxjs/cjs_runtime.h | 2 +- fxjs/cjs_runtimestub.cpp | 8 ++++---- fxjs/cjs_runtimestub.h | 3 ++- fxjs/ijs_runtime.h | 2 +- 5 files changed, 12 insertions(+), 11 deletions(-) (limited to 'fxjs') diff --git a/fxjs/cjs_runtime.cpp b/fxjs/cjs_runtime.cpp index 5364571919..50349158cb 100644 --- a/fxjs/cjs_runtime.cpp +++ b/fxjs/cjs_runtime.cpp @@ -127,10 +127,6 @@ void CJS_Runtime::DefineJSObjects() { CJS_Annot::DefineJSObjects(this); } -CJS_Runtime* CJS_Runtime::AsCJSRuntime() { - return this; -} - IJS_EventContext* CJS_Runtime::NewEventContext() { m_EventContextArray.push_back(pdfium::MakeUnique(this)); return m_EventContextArray.back().get(); @@ -187,6 +183,10 @@ WideString ChangeObjName(const WideString& str) { 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 99dbd0d443..687fdee454 100644 --- a/fxjs/cjs_runtime.h +++ b/fxjs/cjs_runtime.h @@ -30,7 +30,6 @@ class CJS_Runtime final : public IJS_Runtime, ~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 @@ class CJS_Runtime final : public IJS_Runtime, v8::Local MaybeCoerceToNumber(v8::Local 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 44bdbca884..53ca17c2cb 100644 --- a/fxjs/cjs_runtimestub.cpp +++ b/fxjs/cjs_runtimestub.cpp @@ -14,10 +14,6 @@ CJS_RuntimeStub::CJS_RuntimeStub(CPDFSDK_FormFillEnvironment* pFormFillEnv) CJS_RuntimeStub::~CJS_RuntimeStub() = default; -CJS_Runtime* CJS_RuntimeStub::AsCJSRuntime() { - return nullptr; -} - IJS_EventContext* CJS_RuntimeStub::NewEventContext() { if (!m_pContext) m_pContext = pdfium::MakeUnique(); @@ -31,6 +27,10 @@ CPDFSDK_FormFillEnvironment* CJS_RuntimeStub::GetFormFillEnv() const { } #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 779a67579e..b4bb2dd8f0 100644 --- a/fxjs/cjs_runtimestub.h +++ b/fxjs/cjs_runtimestub.h @@ -21,12 +21,13 @@ class CJS_RuntimeStub final : public IJS_Runtime { 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 781e86c576..19f3c63e44 100644 --- a/fxjs/ijs_runtime.h +++ b/fxjs/ijs_runtime.h @@ -52,13 +52,13 @@ class IJS_Runtime { 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 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, -- cgit v1.2.3