OLD | NEW |
1 // Copyright 2015 PDFium Authors. All rights reserved. | 1 // Copyright 2015 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "fpdfsdk/javascript/ijs_context.h" | 9 #include "fpdfsdk/javascript/ijs_context.h" |
10 #include "fpdfsdk/javascript/ijs_runtime.h" | 10 #include "fpdfsdk/javascript/ijs_runtime.h" |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 void OnLink_MouseUp(CPDFSDK_FormFillEnvironment* pFormFillEnv) override {} | 114 void OnLink_MouseUp(CPDFSDK_FormFillEnvironment* pFormFillEnv) override {} |
115 void OnMenu_Exec(CPDFSDK_FormFillEnvironment* pFormFillEnv, | 115 void OnMenu_Exec(CPDFSDK_FormFillEnvironment* pFormFillEnv, |
116 const CFX_WideString&) override {} | 116 const CFX_WideString&) override {} |
117 void OnBatchExec(CPDFSDK_FormFillEnvironment* pFormFillEnv) override {} | 117 void OnBatchExec(CPDFSDK_FormFillEnvironment* pFormFillEnv) override {} |
118 void OnConsole_Exec() override {} | 118 void OnConsole_Exec() override {} |
119 void OnExternal_Exec() override {} | 119 void OnExternal_Exec() override {} |
120 }; | 120 }; |
121 | 121 |
122 class CJS_RuntimeStub final : public IJS_Runtime { | 122 class CJS_RuntimeStub final : public IJS_Runtime { |
123 public: | 123 public: |
124 CJS_RuntimeStub() : m_pDoc(nullptr) {} | 124 CJS_RuntimeStub(CPDFSDK_FormFillEnvironment* pFormFillEnv) |
| 125 : m_pFormFillEnv(pFormFillEnv) {} |
125 ~CJS_RuntimeStub() override {} | 126 ~CJS_RuntimeStub() override {} |
126 | 127 |
127 IJS_Context* NewContext() override { | 128 IJS_Context* NewContext() override { |
128 if (!m_pContext) | 129 if (!m_pContext) |
129 m_pContext = pdfium::MakeUnique<CJS_ContextStub>(); | 130 m_pContext = pdfium::MakeUnique<CJS_ContextStub>(); |
130 return GetCurrentContext(); | 131 return GetCurrentContext(); |
131 } | 132 } |
132 | 133 |
133 IJS_Context* GetCurrentContext() override { return m_pContext.get(); } | 134 IJS_Context* GetCurrentContext() override { return m_pContext.get(); } |
134 void ReleaseContext(IJS_Context* pContext) override {} | 135 void ReleaseContext(IJS_Context* pContext) override {} |
135 | 136 |
136 void SetReaderDocument(CPDFSDK_Document* pReaderDoc) override { | 137 CPDFSDK_FormFillEnvironment* GetFormFillEnv() const override { |
137 m_pDoc = pReaderDoc; | 138 return m_pFormFillEnv; |
138 } | 139 } |
139 CPDFSDK_Document* GetReaderDocument() override { return m_pDoc; } | |
140 | 140 |
141 #ifdef PDF_ENABLE_XFA | 141 #ifdef PDF_ENABLE_XFA |
142 FX_BOOL GetValueByName(const CFX_ByteStringC&, CFXJSE_Value*) override { | 142 FX_BOOL GetValueByName(const CFX_ByteStringC&, CFXJSE_Value*) override { |
143 return FALSE; | 143 return FALSE; |
144 } | 144 } |
145 | 145 |
146 FX_BOOL SetValueByName(const CFX_ByteStringC&, CFXJSE_Value*) override { | 146 FX_BOOL SetValueByName(const CFX_ByteStringC&, CFXJSE_Value*) override { |
147 return FALSE; | 147 return FALSE; |
148 } | 148 } |
149 #endif // PDF_ENABLE_XFA | 149 #endif // PDF_ENABLE_XFA |
150 | 150 |
151 int ExecuteScript(const CFX_WideString& script, | 151 int ExecuteScript(const CFX_WideString& script, |
152 CFX_WideString* info) override { | 152 CFX_WideString* info) override { |
153 return 0; | 153 return 0; |
154 } | 154 } |
155 | 155 |
156 protected: | 156 protected: |
157 CPDFSDK_Document* m_pDoc; | 157 CPDFSDK_FormFillEnvironment* m_pFormFillEnv; |
158 std::unique_ptr<CJS_ContextStub> m_pContext; | 158 std::unique_ptr<CJS_ContextStub> m_pContext; |
159 }; | 159 }; |
160 | 160 |
161 // static | 161 // static |
162 void IJS_Runtime::Initialize(unsigned int slot, void* isolate) {} | 162 void IJS_Runtime::Initialize(unsigned int slot, void* isolate) {} |
163 | 163 |
164 // static | 164 // static |
165 void IJS_Runtime::Destroy() {} | 165 void IJS_Runtime::Destroy() {} |
166 | 166 |
167 // static | 167 // static |
168 IJS_Runtime* IJS_Runtime::Create(CPDFSDK_FormFillEnvironment* pEnv) { | 168 IJS_Runtime* IJS_Runtime::Create(CPDFSDK_FormFillEnvironment* pFormFillEnv) { |
169 return new CJS_RuntimeStub; | 169 return new CJS_RuntimeStub(pFormFillEnv); |
170 } | 170 } |
OLD | NEW |