OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef FPDFSDK_JAVASCRIPT_CJS_RUNTIME_H_ | 7 #ifndef FPDFSDK_JAVASCRIPT_CJS_RUNTIME_H_ |
8 #define FPDFSDK_JAVASCRIPT_CJS_RUNTIME_H_ | 8 #define FPDFSDK_JAVASCRIPT_CJS_RUNTIME_H_ |
9 | 9 |
10 #include <map> | 10 #include <map> |
(...skipping 12 matching lines...) Expand all Loading... |
23 | 23 |
24 class CJS_Runtime : public IJS_Runtime, | 24 class CJS_Runtime : public IJS_Runtime, |
25 public CFXJS_Engine, | 25 public CFXJS_Engine, |
26 public CFX_Observable<CJS_Runtime> { | 26 public CFX_Observable<CJS_Runtime> { |
27 public: | 27 public: |
28 using FieldEvent = std::pair<CFX_WideString, JS_EVENT_T>; | 28 using FieldEvent = std::pair<CFX_WideString, JS_EVENT_T>; |
29 | 29 |
30 static CJS_Runtime* FromContext(const IJS_Context* cc); | 30 static CJS_Runtime* FromContext(const IJS_Context* cc); |
31 static CJS_Runtime* CurrentRuntimeFromIsolate(v8::Isolate* pIsolate); | 31 static CJS_Runtime* CurrentRuntimeFromIsolate(v8::Isolate* pIsolate); |
32 | 32 |
33 explicit CJS_Runtime(CPDFDoc_Environment* pApp); | 33 explicit CJS_Runtime(CPDFSDK_Environment* pApp); |
34 ~CJS_Runtime() override; | 34 ~CJS_Runtime() override; |
35 | 35 |
36 // IJS_Runtime | 36 // IJS_Runtime |
37 IJS_Context* NewContext() override; | 37 IJS_Context* NewContext() override; |
38 void ReleaseContext(IJS_Context* pContext) override; | 38 void ReleaseContext(IJS_Context* pContext) override; |
39 IJS_Context* GetCurrentContext() override; | 39 IJS_Context* GetCurrentContext() override; |
40 void SetReaderDocument(CPDFSDK_Document* pReaderDoc) override; | 40 void SetReaderDocument(CPDFSDK_Document* pReaderDoc) override; |
41 CPDFSDK_Document* GetReaderDocument() override; | 41 CPDFSDK_Document* GetReaderDocument() override; |
42 int ExecuteScript(const CFX_WideString& script, | 42 int ExecuteScript(const CFX_WideString& script, |
43 CFX_WideString* info) override; | 43 CFX_WideString* info) override; |
44 | 44 |
45 CPDFDoc_Environment* GetReaderApp() const { return m_pApp; } | 45 CPDFSDK_Environment* GetReaderApp() const { return m_pApp; } |
46 | 46 |
47 // Returns true if the event isn't already found in the set. | 47 // Returns true if the event isn't already found in the set. |
48 bool AddEventToSet(const FieldEvent& event); | 48 bool AddEventToSet(const FieldEvent& event); |
49 void RemoveEventFromSet(const FieldEvent& event); | 49 void RemoveEventFromSet(const FieldEvent& event); |
50 | 50 |
51 void BeginBlock() { m_bBlocking = TRUE; } | 51 void BeginBlock() { m_bBlocking = TRUE; } |
52 void EndBlock() { m_bBlocking = FALSE; } | 52 void EndBlock() { m_bBlocking = FALSE; } |
53 FX_BOOL IsBlocking() const { return m_bBlocking; } | 53 FX_BOOL IsBlocking() const { return m_bBlocking; } |
54 | 54 |
55 #ifdef PDF_ENABLE_XFA | 55 #ifdef PDF_ENABLE_XFA |
56 FX_BOOL GetValueByName(const CFX_ByteStringC& utf8Name, | 56 FX_BOOL GetValueByName(const CFX_ByteStringC& utf8Name, |
57 CFXJSE_Value* pValue) override; | 57 CFXJSE_Value* pValue) override; |
58 FX_BOOL SetValueByName(const CFX_ByteStringC& utf8Name, | 58 FX_BOOL SetValueByName(const CFX_ByteStringC& utf8Name, |
59 CFXJSE_Value* pValue) override; | 59 CFXJSE_Value* pValue) override; |
60 #endif // PDF_ENABLE_XFA | 60 #endif // PDF_ENABLE_XFA |
61 | 61 |
62 private: | 62 private: |
63 void DefineJSObjects(); | 63 void DefineJSObjects(); |
64 | 64 |
65 std::vector<std::unique_ptr<CJS_Context>> m_ContextArray; | 65 std::vector<std::unique_ptr<CJS_Context>> m_ContextArray; |
66 CPDFDoc_Environment* const m_pApp; | 66 CPDFSDK_Environment* const m_pApp; |
67 CPDFSDK_Document* m_pDocument; | 67 CPDFSDK_Document* m_pDocument; |
68 bool m_bBlocking; | 68 bool m_bBlocking; |
69 bool m_isolateManaged; | 69 bool m_isolateManaged; |
70 std::set<FieldEvent> m_FieldEventSet; | 70 std::set<FieldEvent> m_FieldEventSet; |
71 }; | 71 }; |
72 | 72 |
73 #endif // FPDFSDK_JAVASCRIPT_CJS_RUNTIME_H_ | 73 #endif // FPDFSDK_JAVASCRIPT_CJS_RUNTIME_H_ |
OLD | NEW |