summaryrefslogtreecommitdiff
path: root/xfa/fxfa
diff options
context:
space:
mode:
Diffstat (limited to 'xfa/fxfa')
-rw-r--r--xfa/fxfa/fm2js/xfa_fm2jscontext.cpp5
-rw-r--r--xfa/fxfa/parser/cxfa_scriptcontext.cpp41
-rw-r--r--xfa/fxfa/parser/cxfa_scriptcontext.h5
3 files changed, 26 insertions, 25 deletions
diff --git a/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp b/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp
index 5c67418218..172c234aca 100644
--- a/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp
+++ b/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp
@@ -6133,8 +6133,9 @@ CXFA_FM2JSContext::CXFA_FM2JSContext(v8::Isolate* pScriptIsolate,
CFXJSE_Context* pScriptContext,
CXFA_Document* pDoc)
: m_pIsolate(pScriptIsolate),
- m_pFMClass(
- CFXJSE_Class::Create(pScriptContext, &formcalc_fm2js_descriptor)),
+ m_pFMClass(CFXJSE_Class::Create(pScriptContext,
+ &formcalc_fm2js_descriptor,
+ false)),
m_pValue(pdfium::MakeUnique<CFXJSE_Value>(pScriptIsolate)),
m_pDocument(pDoc) {
m_pValue.get()->SetNull();
diff --git a/xfa/fxfa/parser/cxfa_scriptcontext.cpp b/xfa/fxfa/parser/cxfa_scriptcontext.cpp
index b0b52299e7..e7697f5fab 100644
--- a/xfa/fxfa/parser/cxfa_scriptcontext.cpp
+++ b/xfa/fxfa/parser/cxfa_scriptcontext.cpp
@@ -129,12 +129,8 @@ CXFA_ScriptContext::CXFA_ScriptContext(CXFA_Document* pDocument)
m_eRunAtType(XFA_ATTRIBUTEENUM_Client) {}
CXFA_ScriptContext::~CXFA_ScriptContext() {
- for (const auto& pair : m_mapVariableToContext) {
- CFXJSE_Context* pVariableContext = pair.second;
- delete ToThisProxy(pVariableContext->GetGlobalObject().get(), nullptr);
- delete pVariableContext;
- }
- m_mapVariableToContext.clear();
+ for (const auto& pair : m_mapVariableToContext)
+ delete ToThisProxy(pair.second->GetGlobalObject().get(), nullptr);
}
void CXFA_ScriptContext::Initialize(v8::Isolate* pIsolate) {
@@ -440,25 +436,28 @@ XFA_SCRIPTLANGTYPE CXFA_ScriptContext::GetType() {
return m_eScriptType;
}
void CXFA_ScriptContext::DefineJsContext() {
- m_JsContext.reset(CFXJSE_Context::Create(m_pIsolate, &GlobalClassDescriptor,
- m_pDocument->GetRoot()));
+ m_JsContext = CFXJSE_Context::Create(m_pIsolate, &GlobalClassDescriptor,
+ m_pDocument->GetRoot());
RemoveBuiltInObjs(m_JsContext.get());
m_JsContext->EnableCompatibleMode();
}
+
CFXJSE_Context* CXFA_ScriptContext::CreateVariablesContext(
CXFA_Node* pScriptNode,
CXFA_Node* pSubform) {
if (!pScriptNode || !pSubform)
return nullptr;
- CFXJSE_Context* pVariablesContext =
+ auto pNewContext =
CFXJSE_Context::Create(m_pIsolate, &VariablesClassDescriptor,
new CXFA_ThisProxy(pSubform, pScriptNode));
- RemoveBuiltInObjs(pVariablesContext);
- pVariablesContext->EnableCompatibleMode();
- m_mapVariableToContext[pScriptNode] = pVariablesContext;
- return pVariablesContext;
+ RemoveBuiltInObjs(pNewContext.get());
+ pNewContext->EnableCompatibleMode();
+ CFXJSE_Context* pResult = pNewContext.get();
+ m_mapVariableToContext[pScriptNode] = std::move(pNewContext);
+ return pResult;
}
+
CXFA_Object* CXFA_ScriptContext::GetVariablesThis(CXFA_Object* pObject,
bool bScriptNode) {
if (!pObject->IsVariablesThis())
@@ -517,15 +516,14 @@ bool CXFA_ScriptContext::QueryVariableValue(CXFA_Node* pScriptNode,
if (it == m_mapVariableToContext.end() || !it->second)
return false;
- void* lpVariables = it->second;
- bool bRes = false;
- CFXJSE_Context* pVariableContext = static_cast<CFXJSE_Context*>(lpVariables);
+ CFXJSE_Context* pVariableContext = it->second.get();
std::unique_ptr<CFXJSE_Value> pObject = pVariableContext->GetGlobalObject();
auto hVariableValue = pdfium::MakeUnique<CFXJSE_Value>(m_pIsolate);
if (!bGetter) {
pObject->SetObjectOwnProperty(szPropName, pValue);
- bRes = true;
- } else if (pObject->HasObjectOwnProperty(szPropName, false)) {
+ return true;
+ }
+ if (pObject->HasObjectOwnProperty(szPropName, false)) {
pObject->GetObjectProperty(szPropName, hVariableValue.get());
if (hVariableValue->IsFunction())
pValue->SetFunctionBind(hVariableValue.get(), pObject.get());
@@ -533,13 +531,14 @@ bool CXFA_ScriptContext::QueryVariableValue(CXFA_Node* pScriptNode,
pValue->Assign(hVariableValue.get());
else
hVariableValue.get()->Assign(pValue);
- bRes = true;
+ return true;
}
- return bRes;
+ return false;
}
void CXFA_ScriptContext::DefineJsClass() {
- m_pJsClass = CFXJSE_Class::Create(m_JsContext.get(), &NormalClassDescriptor);
+ m_pJsClass =
+ CFXJSE_Class::Create(m_JsContext.get(), &NormalClassDescriptor, false);
}
void CXFA_ScriptContext::RemoveBuiltInObjs(CFXJSE_Context* pContext) const {
diff --git a/xfa/fxfa/parser/cxfa_scriptcontext.h b/xfa/fxfa/parser/cxfa_scriptcontext.h
index 3f81bb8ebe..4a497ca22a 100644
--- a/xfa/fxfa/parser/cxfa_scriptcontext.h
+++ b/xfa/fxfa/parser/cxfa_scriptcontext.h
@@ -103,13 +103,14 @@ class CXFA_ScriptContext {
void DefineJsClass();
void RemoveBuiltInObjs(CFXJSE_Context* pContext) const;
- CXFA_Document* m_pDocument;
+ CXFA_Document* const m_pDocument;
std::unique_ptr<CFXJSE_Context> m_JsContext;
v8::Isolate* m_pIsolate;
CFXJSE_Class* m_pJsClass;
XFA_SCRIPTLANGTYPE m_eScriptType;
std::map<CXFA_Object*, std::unique_ptr<CFXJSE_Value>> m_mapObjectToValue;
- std::map<CXFA_Object*, CFXJSE_Context*> m_mapVariableToContext;
+ std::map<CXFA_Object*, std::unique_ptr<CFXJSE_Context>>
+ m_mapVariableToContext;
CXFA_EventParam m_eventParam;
std::vector<CXFA_Node*> m_upObjectArray;
// CacheList holds the NodeList items so we can clean them up when we're done.