From 67687896d2959494d2e689ffbbc9c86098e54280 Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Mon, 6 Nov 2017 21:35:11 +0000 Subject: 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 Reviewed-by: Tom Sepez --- xfa/fxfa/parser/cxfa_document.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'xfa/fxfa/parser/cxfa_document.cpp') 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(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(this); + ASSERT(m_pScriptContext); return m_pScriptContext.get(); } -- cgit v1.2.3