Fix (nearly all) IWYU in fpdfskd/include/javascript/ headers.
[pdfium.git] / fpdfsdk / include / javascript / JS_Runtime.h
1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4  
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
7 #ifndef _JS_RUNTIME_H_
8 #define _JS_RUNTIME_H_
9
10 #include "../../../core/include/fxcrt/fx_basic.h"
11 #include "../jsapi/fxjs_v8.h"
12 #include "IJavaScript.h"
13 #include "JS_EventHandler.h"
14
15 class CJS_Context;
16
17 class CJS_FieldEvent
18 {
19 public:
20         CFX_WideString          sTargetName;
21         JS_EVENT_T                      eEventType;
22         CJS_FieldEvent*         pNext;
23 };
24
25 class CJS_Runtime : public IFXJS_Runtime
26 {
27 public:
28         CJS_Runtime(CPDFDoc_Environment * pApp);
29         virtual ~CJS_Runtime();
30
31         virtual IFXJS_Context *                                 NewContext();
32         virtual void                                                    ReleaseContext(IFXJS_Context * pContext);
33         virtual IFXJS_Context*                                  GetCurrentContext();
34
35         virtual void                                                    SetReaderDocument(CPDFSDK_Document *pReaderDoc);
36         virtual CPDFSDK_Document *                              GetReaderDocument(){return m_pDocument;}
37
38         CPDFDoc_Environment *                                                   GetReaderApp(){return m_pApp;}
39
40         FX_BOOL                                                                 InitJSObjects();
41
42         FX_BOOL                                                                 AddEventToLoop(const CFX_WideString& sTargetName, JS_EVENT_T eEventType);
43         void                                                                    RemoveEventInLoop(const CFX_WideString& sTargetName, JS_EVENT_T eEventType);
44         void                                                                    RemoveEventsInLoop(CJS_FieldEvent* pStart);
45
46         void                                                                    BeginBlock(){m_bBlocking = TRUE;}
47         void                                                                    EndBlock(){m_bBlocking = FALSE;}
48         FX_BOOL                                                                 IsBlocking(){return m_bBlocking;}
49
50         operator                                                                IJS_Runtime*() {return (IJS_Runtime*)m_isolate;}
51         v8::Isolate*                                                            GetIsolate(){return m_isolate;};
52         void                                                                    SetIsolate(v8::Isolate* isolate){m_isolate = isolate;}
53
54         v8::Handle<v8::Context>                                                 NewJSContext();
55 protected:
56         CFX_ArrayTemplate<CJS_Context *>                m_ContextArray;
57         CPDFDoc_Environment *                                                   m_pApp;
58         CPDFSDK_Document *                                              m_pDocument;
59         FX_BOOL                                                                 m_bBlocking;
60         CJS_FieldEvent*                                                 m_pFieldEventPath;
61
62         v8::Isolate*                                                            m_isolate;
63         v8::Persistent<v8::Context>                                             m_context;
64         FX_BOOL                                                                 m_bRegistered;
65 };
66
67 #endif //_JS_RUNTIME_H_
68