blob: 34a846e9e3ae9336e99d4bcd3c722edc5e50a948 (
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
51
|
// Copyright 2018 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.
#include "fxjs/ijs_runtime.h"
#include "fxjs/cjs_runtimestub.h"
#include "third_party/base/ptr_util.h"
#ifdef PDF_ENABLE_V8
#include "fxjs/cfxjs_engine.h"
#include "fxjs/cjs_runtime.h"
#endif
IJS_Runtime::ScopedEventContext::ScopedEventContext(IJS_Runtime* pRuntime)
: m_pRuntime(pRuntime), m_pContext(pRuntime->NewEventContext()) {}
IJS_Runtime::ScopedEventContext::~ScopedEventContext() {
m_pRuntime->ReleaseEventContext(m_pContext.Release());
}
// static
void IJS_Runtime::Initialize(unsigned int slot, void* isolate) {
#ifdef PDF_ENABLE_V8
FXJS_Initialize(slot, static_cast<v8::Isolate*>(isolate));
#endif
}
// static
void IJS_Runtime::Destroy() {
#ifdef PDF_ENABLE_V8
FXJS_Release();
#endif
}
// static
std::unique_ptr<IJS_Runtime> IJS_Runtime::Create(
CPDFSDK_FormFillEnvironment* pFormFillEnv) {
#ifdef PDF_ENABLE_V8
if (pFormFillEnv->IsJSPlatformPresent())
return pdfium::MakeUnique<CJS_Runtime>(pFormFillEnv);
#endif
return pdfium::MakeUnique<CJS_RuntimeStub>(pFormFillEnv);
}
IJS_Runtime::~IJS_Runtime() = default;
IJS_Runtime::JS_Error::JS_Error(int line,
int column,
const WideString& exception)
: line(line), column(column), exception(exception) {}
|