From 53701cd5a8e71137a00e4a1d7803761317b7574b Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Fri, 31 Aug 2018 17:44:51 +0000 Subject: Use more UnownedPtrs in CFXJSE_Engine. Change-Id: If577500905f5bc5bb631718e9c87aa03ee6bee5a Reviewed-on: https://pdfium-review.googlesource.com/41571 Reviewed-by: Tom Sepez Commit-Queue: Lei Zhang --- fxjs/cfxjse_engine.cpp | 10 +++------- fxjs/cfxjse_engine.h | 10 +++++----- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/fxjs/cfxjse_engine.cpp b/fxjs/cfxjse_engine.cpp index 305e29a9cd..eb19573411 100644 --- a/fxjs/cfxjse_engine.cpp +++ b/fxjs/cfxjse_engine.cpp @@ -138,7 +138,7 @@ bool CFXJSE_Engine::RunScript(CXFA_Script::Type eScriptType, } else { btScript = FX_UTF8Encode(wsScript); } - AutoRestorer nodeRestorer(&m_pThisObject); + AutoRestorer> nodeRestorer(&m_pThisObject); m_pThisObject = pThisObject; CFXJSE_Value* pValue = pThisObject ? GetJSValueFromMap(pThisObject) : nullptr; @@ -510,7 +510,7 @@ bool CFXJSE_Engine::RunVariablesScript(CXFA_Node* pScriptNode) { CXFA_Node* pThisObject = pParent->GetParent(); CFXJSE_Context* pVariablesContext = CreateVariablesContext(pScriptNode, pThisObject); - AutoRestorer nodeRestorer(&m_pThisObject); + AutoRestorer> nodeRestorer(&m_pThisObject); m_pThisObject = pThisObject; return pVariablesContext->ExecuteScript(btScript.c_str(), hRetValue.get(), nullptr); @@ -563,10 +563,6 @@ void CFXJSE_Engine::RemoveBuiltInObjs(CFXJSE_Context* pContext) const { } } -CFXJSE_Class* CFXJSE_Engine::GetJseNormalClass() { - return m_pJsClass; -} - bool CFXJSE_Engine::ResolveObjects(CXFA_Object* refObject, const WideStringView& wsExpression, XFA_RESOLVENODE_RS* resolveNodeRS, @@ -753,7 +749,7 @@ CFXJSE_Value* CFXJSE_Engine::GetJSValueFromMap(CXFA_Object* pObject) { return iter->second.get(); auto jsValue = pdfium::MakeUnique(GetIsolate()); - jsValue->SetObject(pObject, m_pJsClass); + jsValue->SetObject(pObject, m_pJsClass.Get()); CFXJSE_Value* pValue = jsValue.get(); m_mapObjectToValue.insert(std::make_pair(pObject, std::move(jsValue))); diff --git a/fxjs/cfxjse_engine.h b/fxjs/cfxjse_engine.h index 2279eea8e4..a766e268a4 100644 --- a/fxjs/cfxjse_engine.h +++ b/fxjs/cfxjse_engine.h @@ -67,7 +67,7 @@ class CFXJSE_Engine final : public CFX_V8 { CXFA_Node* bindNode); CFXJSE_Value* GetJSValueFromMap(CXFA_Object* pObject); void AddToCacheList(std::unique_ptr pList); - CXFA_Object* GetThisObject() const { return m_pThisObject; } + CXFA_Object* GetThisObject() const { return m_pThisObject.Get(); } int32_t GetIndexByName(CXFA_Node* refNode); int32_t GetIndexByClassName(CXFA_Node* refNode); @@ -75,7 +75,7 @@ class CFXJSE_Engine final : public CFX_V8 { void SetNodesOfRunScript(std::vector* pArray); void AddNodesOfRunScript(CXFA_Node* pNode); - CFXJSE_Class* GetJseNormalClass(); + CFXJSE_Class* GetJseNormalClass() const { return m_pJsClass.Get(); } void SetRunAtType(XFA_AttributeEnum eRunAt) { m_eRunAtType = eRunAt; } bool IsRunAtClient() { return m_eRunAtType != XFA_AttributeEnum::Server; } @@ -108,7 +108,7 @@ class CFXJSE_Engine final : public CFX_V8 { UnownedPtr const m_pSubordinateRuntime; UnownedPtr const m_pDocument; std::unique_ptr m_JsContext; - CFXJSE_Class* m_pJsClass = nullptr; + UnownedPtr m_pJsClass; CXFA_Script::Type m_eScriptType = CXFA_Script::Type::Unknown; std::map> m_mapObjectToValue; std::map> @@ -117,10 +117,10 @@ class CFXJSE_Engine final : public CFX_V8 { std::vector m_upObjectArray; // CacheList holds the List items so we can clean them up when we're done. std::vector> m_CacheList; - std::vector* m_pScriptNodeArray = nullptr; + UnownedPtr> m_pScriptNodeArray; const std::unique_ptr m_ResolveProcessor; std::unique_ptr m_FM2JSContext; - CXFA_Object* m_pThisObject = nullptr; + UnownedPtr m_pThisObject; XFA_AttributeEnum m_eRunAtType = XFA_AttributeEnum::Client; }; -- cgit v1.2.3