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_INCLUDE_JAVASCRIPT_JS_RUNTIME_H_ | 7 #ifndef FPDFSDK_INCLUDE_JAVASCRIPT_JS_RUNTIME_H_ |
8 #define FPDFSDK_INCLUDE_JAVASCRIPT_JS_RUNTIME_H_ | 8 #define FPDFSDK_INCLUDE_JAVASCRIPT_JS_RUNTIME_H_ |
9 | 9 |
10 #include <set> | |
11 #include <utility> | |
12 | |
10 #include "../../../third_party/base/nonstd_unique_ptr.h" | 13 #include "../../../third_party/base/nonstd_unique_ptr.h" |
11 #include "../../../core/include/fxcrt/fx_basic.h" | 14 #include "../../../core/include/fxcrt/fx_basic.h" |
12 #include "../jsapi/fxjs_v8.h" | 15 #include "../jsapi/fxjs_v8.h" |
13 #include "IJavaScript.h" | 16 #include "IJavaScript.h" |
14 #include "JS_EventHandler.h" | 17 #include "JS_EventHandler.h" |
15 | 18 |
16 class CJS_Context; | 19 class CJS_Context; |
17 | 20 |
18 class CJS_FieldEvent { | |
19 public: | |
20 CFX_WideString sTargetName; | |
21 JS_EVENT_T eEventType; | |
22 CJS_FieldEvent* pNext; | |
23 }; | |
24 | |
25 class CJS_Runtime : public IFXJS_Runtime { | 21 class CJS_Runtime : public IFXJS_Runtime { |
26 public: | 22 public: |
23 using FieldEvent = std::pair<CFX_WideString, JS_EVENT_T>; | |
24 | |
27 explicit CJS_Runtime(CPDFDoc_Environment* pApp); | 25 explicit CJS_Runtime(CPDFDoc_Environment* pApp); |
28 ~CJS_Runtime() override; | 26 ~CJS_Runtime() override; |
29 | 27 |
30 // IFXJS_Runtime | 28 // IFXJS_Runtime |
31 IFXJS_Context* NewContext() override; | 29 IFXJS_Context* NewContext() override; |
32 void ReleaseContext(IFXJS_Context* pContext) override; | 30 void ReleaseContext(IFXJS_Context* pContext) override; |
33 IFXJS_Context* GetCurrentContext() override; | 31 IFXJS_Context* GetCurrentContext() override; |
34 void SetReaderDocument(CPDFSDK_Document* pReaderDoc) override; | 32 void SetReaderDocument(CPDFSDK_Document* pReaderDoc) override; |
35 CPDFSDK_Document* GetReaderDocument() override { return m_pDocument; } | 33 CPDFSDK_Document* GetReaderDocument() override { return m_pDocument; } |
36 | 34 |
37 CPDFDoc_Environment* GetReaderApp() const { return m_pApp; } | 35 CPDFDoc_Environment* GetReaderApp() const { return m_pApp; } |
38 | 36 |
39 FX_BOOL AddEventToLoop(const CFX_WideString& sTargetName, | 37 FX_BOOL AddEventToSet(const FieldEvent& event); |
Lei Zhang
2015/09/22 22:20:50
Can we use bool in new code?
Tom Sepez
2015/09/22 22:32:46
Done.
| |
40 JS_EVENT_T eEventType); | 38 void RemoveEventFromSet(const FieldEvent& event); |
41 void RemoveEventInLoop(const CFX_WideString& sTargetName, | |
42 JS_EVENT_T eEventType); | |
43 void RemoveEventsInLoop(CJS_FieldEvent* pStart); | |
44 | 39 |
45 void BeginBlock() { m_bBlocking = TRUE; } | 40 void BeginBlock() { m_bBlocking = TRUE; } |
46 void EndBlock() { m_bBlocking = FALSE; } | 41 void EndBlock() { m_bBlocking = FALSE; } |
47 FX_BOOL IsBlocking() const { return m_bBlocking; } | 42 FX_BOOL IsBlocking() const { return m_bBlocking; } |
48 | 43 |
49 v8::Isolate* GetIsolate() const { return m_isolate; } | 44 v8::Isolate* GetIsolate() const { return m_isolate; } |
50 v8::Local<v8::Context> NewJSContext(); | 45 v8::Local<v8::Context> NewJSContext(); |
51 | 46 |
52 private: | 47 private: |
53 void DefineJSObjects(); | 48 void DefineJSObjects(); |
54 | 49 |
55 CFX_ArrayTemplate<CJS_Context*> m_ContextArray; | 50 CFX_ArrayTemplate<CJS_Context*> m_ContextArray; |
56 CPDFDoc_Environment* m_pApp; | 51 CPDFDoc_Environment* m_pApp; |
57 CPDFSDK_Document* m_pDocument; | 52 CPDFSDK_Document* m_pDocument; |
58 FX_BOOL m_bBlocking; | 53 FX_BOOL m_bBlocking; |
59 CJS_FieldEvent* m_pFieldEventPath; | 54 std::set<FieldEvent> m_FieldEventSet; |
60 v8::Isolate* m_isolate; | 55 v8::Isolate* m_isolate; |
61 bool m_isolateManaged; | 56 bool m_isolateManaged; |
62 nonstd::unique_ptr<FXJS_ArrayBufferAllocator> m_pArrayBufferAllocator; | 57 nonstd::unique_ptr<FXJS_ArrayBufferAllocator> m_pArrayBufferAllocator; |
63 v8::Global<v8::Context> m_context; | 58 v8::Global<v8::Context> m_context; |
64 }; | 59 }; |
65 | 60 |
66 #endif // FPDFSDK_INCLUDE_JAVASCRIPT_JS_RUNTIME_H_ | 61 #endif // FPDFSDK_INCLUDE_JAVASCRIPT_JS_RUNTIME_H_ |
OLD | NEW |