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 #include "../../include/javascript/JavaScript.h" | 7 #include "../../include/javascript/JavaScript.h" |
8 #include "../../include/javascript/IJavaScript.h" | 8 #include "../../include/javascript/IJavaScript.h" |
9 #include "../../include/javascript/JS_EventHandler.h" | 9 #include "../../include/javascript/JS_EventHandler.h" |
10 #include "../../include/javascript/JS_Runtime.h" | 10 #include "../../include/javascript/JS_Runtime.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 #include "../../include/javascript/Icon.h" | 22 #include "../../include/javascript/Icon.h" |
23 #include "../../include/javascript/PublicMethods.h" | 23 #include "../../include/javascript/PublicMethods.h" |
24 #include "../../include/javascript/report.h" | 24 #include "../../include/javascript/report.h" |
25 #include "../../include/javascript/util.h" | 25 #include "../../include/javascript/util.h" |
26 #include "../../include/javascript/JS_GlobalData.h" | 26 #include "../../include/javascript/JS_GlobalData.h" |
27 #include "../../include/javascript/global.h" | 27 #include "../../include/javascript/global.h" |
28 #include "../../include/javascript/console.h" | 28 #include "../../include/javascript/console.h" |
29 #include "../../include/fpdfxfa/fpdfxfa_app.h" | 29 #include "../../include/fpdfxfa/fpdfxfa_app.h" |
30 #include "../../../xfa/src/fxjse/src/value.h" | 30 #include "../../../xfa/src/fxjse/src/value.h" |
31 | 31 |
32 #include <libplatform/libplatform.h> | |
33 | |
34 CJS_RuntimeFactory::~CJS_RuntimeFactory() | 32 CJS_RuntimeFactory::~CJS_RuntimeFactory() |
35 { | 33 { |
36 } | 34 } |
37 | 35 |
38 IFXJS_Runtime* CJS_RuntimeFactory::NewJSRuntime
(CPDFDoc_Environment* pApp) | 36 IFXJS_Runtime* CJS_RuntimeFactory::NewJSRuntime
(CPDFDoc_Environment* pApp) |
39 { | 37 { |
40 if (!m_bInit) | 38 if (!m_bInit) |
41 { | 39 { |
42 JS_Initial(); | 40 JS_Initial(); |
43 /* | |
44 m_platform = v8::platform::CreateDefaultPlatform(); | |
45 v8::V8::InitializePlatform(m_platform); | |
46 v8::V8::Initialize(); | |
47 */ | |
48 m_bInit = TRUE; | 41 m_bInit = TRUE; |
49 } | 42 } |
50 return new CJS_Runtime(pApp); | 43 return new CJS_Runtime(pApp); |
51 } | 44 } |
52 void CJS_RuntimeFactory::AddR
ef() | 45 void CJS_RuntimeFactory::AddR
ef() |
53 { | 46 { |
54 //to do.Should be implemented as atom manipulation. | 47 //to do.Should be implemented as atom manipulation. |
55 m_nRef++; | 48 m_nRef++; |
56 } | 49 } |
57 void CJS_RuntimeFactory::Rele
ase() | 50 void CJS_RuntimeFactory::Rele
ase() |
58 { | 51 { |
59 if(m_bInit) | 52 if(m_bInit) |
60 { | 53 { |
61 //to do.Should be implemented as atom manipulation. | 54 //to do.Should be implemented as atom manipulation. |
62 if (--m_nRef == 0) | 55 if (--m_nRef == 0) |
63 { | 56 { |
64 JS_Release(); | 57 JS_Release(); |
65 ReleaseGlobalData(); | 58 ReleaseGlobalData(); |
66 v8::V8::ShutdownPlatform(); | |
67 delete m_platform; | |
68 m_platform = NULL; | |
69 m_bInit = FALSE; | 59 m_bInit = FALSE; |
70 } | 60 } |
71 } | 61 } |
72 } | 62 } |
73 | 63 |
74 void CJS_RuntimeFactory::Dele
teJSRuntime(IFXJS_Runtime* pRuntime) | 64 void CJS_RuntimeFactory::Dele
teJSRuntime(IFXJS_Runtime* pRuntime) |
75 { | 65 { |
76 if(pRuntime) | 66 if(pRuntime) |
77 delete (CJS_Runtime*)pRuntime; | 67 delete (CJS_Runtime*)pRuntime; |
78 } | 68 } |
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
528 v8::Local<v8::Context> context = | 518 v8::Local<v8::Context> context = |
529 v8::Local<v8::Context>::New(pIsolate, m_context); | 519 v8::Local<v8::Context>::New(pIsolate, m_context); |
530 v8::Context::Scope context_scope(context); | 520 v8::Context::Scope context_scope(context); |
531 | 521 |
532 //v8::Local<v8::Context> tmpCotext = v8::Local<v8::Context>::New(GetIsol
ate(), m_context); | 522 //v8::Local<v8::Context> tmpCotext = v8::Local<v8::Context>::New(GetIsol
ate(), m_context); |
533 v8::Local<v8::Value> propvalue = v8::Local<v8::Value>::New(GetIsolate(),
((CFXJSE_Value*)hValue)->DirectGetValue()); | 523 v8::Local<v8::Value> propvalue = v8::Local<v8::Value>::New(GetIsolate(),
((CFXJSE_Value*)hValue)->DirectGetValue()); |
534 context->Global()->Set(v8::String::NewFromUtf8(pIsolate, name, v8::Strin
g::kNormalString, utf8Name.GetLength()), propvalue); | 524 context->Global()->Set(v8::String::NewFromUtf8(pIsolate, name, v8::Strin
g::kNormalString, utf8Name.GetLength()), propvalue); |
535 | 525 |
536 return TRUE; | 526 return TRUE; |
537 } | 527 } |
OLD | NEW |