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 "fxjse/runtime.h" | 7 #include "fxjse/runtime.h" |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 | 10 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 CFXJSE_RuntimeData::CFXJSE_RuntimeData(v8::Isolate* pIsolate) | 72 CFXJSE_RuntimeData::CFXJSE_RuntimeData(v8::Isolate* pIsolate) |
73 : m_pIsolate(pIsolate) {} | 73 : m_pIsolate(pIsolate) {} |
74 | 74 |
75 CFXJSE_RuntimeData::~CFXJSE_RuntimeData() {} | 75 CFXJSE_RuntimeData::~CFXJSE_RuntimeData() {} |
76 | 76 |
77 CFXJSE_RuntimeData* CFXJSE_RuntimeData::Create(v8::Isolate* pIsolate) { | 77 CFXJSE_RuntimeData* CFXJSE_RuntimeData::Create(v8::Isolate* pIsolate) { |
78 CFXJSE_RuntimeData* pRuntimeData = new CFXJSE_RuntimeData(pIsolate); | 78 CFXJSE_RuntimeData* pRuntimeData = new CFXJSE_RuntimeData(pIsolate); |
79 CFXJSE_ScopeUtil_IsolateHandle scope(pIsolate); | 79 CFXJSE_ScopeUtil_IsolateHandle scope(pIsolate); |
80 v8::Local<v8::FunctionTemplate> hFuncTemplate = | 80 v8::Local<v8::FunctionTemplate> hFuncTemplate = |
81 v8::FunctionTemplate::New(pIsolate); | 81 v8::FunctionTemplate::New(pIsolate); |
| 82 v8::Local<v8::ObjectTemplate> hGlobalTemplate = |
| 83 hFuncTemplate->InstanceTemplate(); |
| 84 hGlobalTemplate->Set( |
| 85 v8::Symbol::GetToStringTag(pIsolate), |
| 86 v8::String::NewFromUtf8(pIsolate, "global", v8::NewStringType::kNormal) |
| 87 .ToLocalChecked()); |
82 v8::Local<v8::Context> hContext = | 88 v8::Local<v8::Context> hContext = |
83 v8::Context::New(pIsolate, 0, hFuncTemplate->InstanceTemplate()); | 89 v8::Context::New(pIsolate, 0, hGlobalTemplate); |
84 hContext->SetSecurityToken(v8::External::New(pIsolate, pIsolate)); | 90 hContext->SetSecurityToken(v8::External::New(pIsolate, pIsolate)); |
85 pRuntimeData->m_hRootContextGlobalTemplate.Reset(pIsolate, hFuncTemplate); | 91 pRuntimeData->m_hRootContextGlobalTemplate.Reset(pIsolate, hFuncTemplate); |
86 pRuntimeData->m_hRootContext.Reset(pIsolate, hContext); | 92 pRuntimeData->m_hRootContext.Reset(pIsolate, hContext); |
87 return pRuntimeData; | 93 return pRuntimeData; |
88 } | 94 } |
89 | 95 |
90 CFXJSE_RuntimeData* CFXJSE_RuntimeData::Get(v8::Isolate* pIsolate) { | 96 CFXJSE_RuntimeData* CFXJSE_RuntimeData::Get(v8::Isolate* pIsolate) { |
91 FXJS_PerIsolateData::SetUp(pIsolate); | 97 FXJS_PerIsolateData::SetUp(pIsolate); |
92 FXJS_PerIsolateData* pData = FXJS_PerIsolateData::Get(pIsolate); | 98 FXJS_PerIsolateData* pData = FXJS_PerIsolateData::Get(pIsolate); |
93 if (!pData->m_pFXJSERuntimeData) | 99 if (!pData->m_pFXJSERuntimeData) |
(...skipping 21 matching lines...) Expand all Loading... |
115 lpfnDisposeCallback(pIsolate, bFound); | 121 lpfnDisposeCallback(pIsolate, bFound); |
116 } | 122 } |
117 | 123 |
118 void CFXJSE_IsolateTracker::RemoveAll( | 124 void CFXJSE_IsolateTracker::RemoveAll( |
119 CFXJSE_IsolateTracker::DisposeCallback lpfnDisposeCallback) { | 125 CFXJSE_IsolateTracker::DisposeCallback lpfnDisposeCallback) { |
120 for (v8::Isolate* pIsolate : m_OwnedIsolates) | 126 for (v8::Isolate* pIsolate : m_OwnedIsolates) |
121 lpfnDisposeCallback(pIsolate, true); | 127 lpfnDisposeCallback(pIsolate, true); |
122 | 128 |
123 m_OwnedIsolates.clear(); | 129 m_OwnedIsolates.clear(); |
124 } | 130 } |
OLD | NEW |