blob: 0153e81a6c3f9bc8e597f6286ab2d11e82a65e07 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
// Copyright 2016 PDFium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
#include "fxjs/cfxjse_runtimedata.h"
#include <utility>
#include "fxjs/cfxjs_engine.h"
#include "fxjs/cfxjse_isolatetracker.h"
CFXJSE_RuntimeData::CFXJSE_RuntimeData(v8::Isolate* pIsolate)
: m_pIsolate(pIsolate) {}
CFXJSE_RuntimeData::~CFXJSE_RuntimeData() {}
std::unique_ptr<CFXJSE_RuntimeData> CFXJSE_RuntimeData::Create(
v8::Isolate* pIsolate) {
std::unique_ptr<CFXJSE_RuntimeData> pRuntimeData(
new CFXJSE_RuntimeData(pIsolate));
CFXJSE_ScopeUtil_IsolateHandle scope(pIsolate);
v8::Local<v8::FunctionTemplate> hFuncTemplate =
v8::FunctionTemplate::New(pIsolate);
v8::Local<v8::ObjectTemplate> hGlobalTemplate =
hFuncTemplate->InstanceTemplate();
hGlobalTemplate->Set(
v8::Symbol::GetToStringTag(pIsolate),
v8::String::NewFromUtf8(pIsolate, "global", v8::NewStringType::kNormal)
.ToLocalChecked());
v8::Local<v8::Context> hContext =
v8::Context::New(pIsolate, 0, hGlobalTemplate);
hContext->SetSecurityToken(v8::External::New(pIsolate, pIsolate));
pRuntimeData->m_hRootContextGlobalTemplate.Reset(pIsolate, hFuncTemplate);
pRuntimeData->m_hRootContext.Reset(pIsolate, hContext);
return pRuntimeData;
}
CFXJSE_RuntimeData* CFXJSE_RuntimeData::Get(v8::Isolate* pIsolate) {
FXJS_PerIsolateData::SetUp(pIsolate);
FXJS_PerIsolateData* pData = FXJS_PerIsolateData::Get(pIsolate);
if (!pData->m_pFXJSERuntimeData)
pData->m_pFXJSERuntimeData = CFXJSE_RuntimeData::Create(pIsolate);
return pData->m_pFXJSERuntimeData.get();
}
|