Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(33)

Side by Side Diff: fpdfsdk/include/javascript/JS_Runtime.h

Issue 1365503003: Merge to XFA: Use std::set<> to track active event handlers. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Blown merge. Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | fpdfsdk/src/javascript/JS_Context.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 // Returns true if the event isn't already found in the set.
40 JS_EVENT_T eEventType); 38 bool AddEventToSet(const FieldEvent& event);
41 void RemoveEventInLoop(const CFX_WideString& sTargetName, 39 void RemoveEventFromSet(const FieldEvent& event);
42 JS_EVENT_T eEventType);
43 void RemoveEventsInLoop(CJS_FieldEvent* pStart);
44 40
45 void BeginBlock() { m_bBlocking = TRUE; } 41 void BeginBlock() { m_bBlocking = TRUE; }
46 void EndBlock() { m_bBlocking = FALSE; } 42 void EndBlock() { m_bBlocking = FALSE; }
47 FX_BOOL IsBlocking() const { return m_bBlocking; } 43 FX_BOOL IsBlocking() const { return m_bBlocking; }
48 44
49 v8::Isolate* GetIsolate() const { return m_isolate; } 45 v8::Isolate* GetIsolate() const { return m_isolate; }
50 v8::Local<v8::Context> NewJSContext(); 46 v8::Local<v8::Context> NewJSContext();
51 47
52 virtual FX_BOOL GetHValueByName(const CFX_ByteStringC& utf8Name, 48 virtual FX_BOOL GetHValueByName(const CFX_ByteStringC& utf8Name,
53 FXJSE_HVALUE hValue); 49 FXJSE_HVALUE hValue);
54 virtual FX_BOOL SetHValueByName(const CFX_ByteStringC& utf8Name, 50 virtual FX_BOOL SetHValueByName(const CFX_ByteStringC& utf8Name,
55 FXJSE_HVALUE hValue); 51 FXJSE_HVALUE hValue);
56 52
57 private: 53 private:
58 void DefineJSObjects(); 54 void DefineJSObjects();
59 55
60 CFX_ArrayTemplate<CJS_Context*> m_ContextArray; 56 CFX_ArrayTemplate<CJS_Context*> m_ContextArray;
61 CPDFDoc_Environment* m_pApp; 57 CPDFDoc_Environment* m_pApp;
62 CPDFSDK_Document* m_pDocument; 58 CPDFSDK_Document* m_pDocument;
63 FX_BOOL m_bBlocking; 59 FX_BOOL m_bBlocking;
64 CJS_FieldEvent* m_pFieldEventPath; 60 std::set<FieldEvent> m_FieldEventSet;
65 v8::Isolate* m_isolate; 61 v8::Isolate* m_isolate;
66 bool m_isolateManaged; 62 bool m_isolateManaged;
67 nonstd::unique_ptr<FXJS_ArrayBufferAllocator> m_pArrayBufferAllocator; 63 nonstd::unique_ptr<FXJS_ArrayBufferAllocator> m_pArrayBufferAllocator;
68 v8::Global<v8::Context> m_context; 64 v8::Global<v8::Context> m_context;
69 }; 65 };
70 66
71 #endif // FPDFSDK_INCLUDE_JAVASCRIPT_JS_RUNTIME_H_ 67 #endif // FPDFSDK_INCLUDE_JAVASCRIPT_JS_RUNTIME_H_
OLDNEW
« no previous file with comments | « no previous file | fpdfsdk/src/javascript/JS_Context.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698