summaryrefslogtreecommitdiff
path: root/xfa
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-11-06 21:35:11 +0000
committerChromium commit bot <commit-bot@chromium.org>2017-11-06 21:35:11 +0000
commit67687896d2959494d2e689ffbbc9c86098e54280 (patch)
treedf8e1d598a973ad7f3ccbf3e7bec0e4ca68085b2 /xfa
parent98c6b5e57932cc212fcd08056e43e1c11c18d926 (diff)
downloadpdfium-67687896d2959494d2e689ffbbc9c86098e54280.tar.xz
Consolidate CFXJSE_Engine construction
This CL removes the Initialize method from CFXJSE_Engine and moves the code to the constuctor. The DefineJsContext and DefineJSClass methods are also removed and done directly in the constructor. Change-Id: I3f849509a17a6bda22b520c640f23ee110e939af Reviewed-on: https://pdfium-review.googlesource.com/17857 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'xfa')
-rw-r--r--xfa/fxfa/parser/cxfa_document.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/xfa/fxfa/parser/cxfa_document.cpp b/xfa/fxfa/parser/cxfa_document.cpp
index fc5373a18a..66778cdcfc 100644
--- a/xfa/fxfa/parser/cxfa_document.cpp
+++ b/xfa/fxfa/parser/cxfa_document.cpp
@@ -286,14 +286,15 @@ CXFA_LocaleMgr* CXFA_Document::GetLocalMgr() {
}
CFXJSE_Engine* CXFA_Document::InitScriptContext(v8::Isolate* pIsolate) {
- CFXJSE_Engine* result = GetScriptContext();
- result->Initialize(pIsolate);
- return result;
+ ASSERT(!m_pScriptContext);
+ m_pScriptContext = pdfium::MakeUnique<CFXJSE_Engine>(this, pIsolate);
+ return m_pScriptContext.get();
}
+// We have to call |InitScriptContext| before any calls to |GetScriptContext|
+// or the context won't have an isolate set into it.
CFXJSE_Engine* CXFA_Document::GetScriptContext() {
- if (!m_pScriptContext)
- m_pScriptContext = pdfium::MakeUnique<CFXJSE_Engine>(this);
+ ASSERT(m_pScriptContext);
return m_pScriptContext.get();
}