From 1a3e186e975aa8eb6a6e42f2626b6f8ca980db19 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Tue, 21 Aug 2018 22:56:37 +0000 Subject: Use UnownedPtr<> in xfa_resolvenode_rs.h Change-Id: I4420fbf7402a8b08e33ca525e98690643d59efdf Reviewed-on: https://pdfium-review.googlesource.com/40930 Reviewed-by: Lei Zhang Commit-Queue: Tom Sepez --- xfa/fxfa/cxfa_ffdocview.cpp | 2 +- xfa/fxfa/parser/cxfa_document.cpp | 9 +++++---- xfa/fxfa/parser/cxfa_document.h | 4 +++- xfa/fxfa/parser/xfa_resolvenode_rs.h | 18 +++++++----------- 4 files changed, 16 insertions(+), 17 deletions(-) (limited to 'xfa/fxfa') diff --git a/xfa/fxfa/cxfa_ffdocview.cpp b/xfa/fxfa/cxfa_ffdocview.cpp index 46b5710242..affdca2b6e 100644 --- a/xfa/fxfa/cxfa_ffdocview.cpp +++ b/xfa/fxfa/cxfa_ffdocview.cpp @@ -622,7 +622,7 @@ void CXFA_FFDocView::RunBindItems() { WideString wsValue; WideString wsLabel; uint32_t uValueHash = FX_HashCode_GetW(wsValueRef.AsStringView(), false); - for (CXFA_Object* refObject : rs.objects) { + for (auto& refObject : rs.objects) { CXFA_Node* refNode = refObject->AsNode(); if (!refNode) continue; diff --git a/xfa/fxfa/parser/cxfa_document.cpp b/xfa/fxfa/parser/cxfa_document.cpp index d42bfb5601..72bba2aeb0 100644 --- a/xfa/fxfa/parser/cxfa_document.cpp +++ b/xfa/fxfa/parser/cxfa_document.cpp @@ -360,7 +360,8 @@ CXFA_Node* FindDataRefDataNode(CXFA_Document* pDocument, } if (rs.dwFlags == XFA_ResolveNode_RSType_CreateNodeOne) { - CXFA_Object* pObject = !rs.objects.empty() ? rs.objects.front() : nullptr; + CXFA_Object* pObject = + !rs.objects.empty() ? rs.objects.front().Get() : nullptr; CXFA_Node* pNode = ToNode(pObject); return (bForceBind || !pNode || !pNode->HasBindItem()) ? pNode : nullptr; } @@ -1200,7 +1201,7 @@ void UpdateBindingRelations(CXFA_Document* pDocument, pDocument->GetScriptContext()->ResolveObjects( pDataScope, wsRef.AsStringView(), &rs, dFlags, pTemplateNode); CXFA_Object* pObject = - !rs.objects.empty() ? rs.objects.front() : nullptr; + !rs.objects.empty() ? rs.objects.front().Get() : nullptr; pDataNode = ToNode(pObject); if (pDataNode) { CreateDataBinding(pFormNode, pDataNode, @@ -1618,8 +1619,8 @@ void CXFA_Document::DataMerge_UpdateBindingRelations( } CXFA_Node* CXFA_Document::GetNotBindNode( - const std::vector& arrayObjects) const { - for (CXFA_Object* pObject : arrayObjects) { + const std::vector>& arrayObjects) const { + for (auto& pObject : arrayObjects) { CXFA_Node* pNode = pObject->AsNode(); if (pNode && !pNode->HasBindItem()) return pNode; diff --git a/xfa/fxfa/parser/cxfa_document.h b/xfa/fxfa/parser/cxfa_document.h index 5260b1873f..590a4cf12a 100644 --- a/xfa/fxfa/parser/cxfa_document.h +++ b/xfa/fxfa/parser/cxfa_document.h @@ -11,6 +11,7 @@ #include #include +#include "core/fxcrt/unowned_ptr.h" #include "xfa/fxfa/fxfa.h" #include "xfa/fxfa/parser/cxfa_localemgr.h" #include "xfa/fxfa/parser/cxfa_nodeowner.h" @@ -65,7 +66,8 @@ class CXFA_Document : public CXFA_NodeOwner { CXFA_LocaleMgr* GetLocaleMgr(); CXFA_Object* GetXFAObject(XFA_HashCode wsNodeNameHash); CXFA_Node* GetNodeByID(CXFA_Node* pRoot, const WideStringView& wsID) const; - CXFA_Node* GetNotBindNode(const std::vector& arrayNodes) const; + CXFA_Node* GetNotBindNode( + const std::vector>& arrayNodes) const; CXFA_LayoutProcessor* GetLayoutProcessor(); CFXJSE_Engine* GetScriptContext() const; diff --git a/xfa/fxfa/parser/xfa_resolvenode_rs.h b/xfa/fxfa/parser/xfa_resolvenode_rs.h index 86960abecc..7039c61ee9 100644 --- a/xfa/fxfa/parser/xfa_resolvenode_rs.h +++ b/xfa/fxfa/parser/xfa_resolvenode_rs.h @@ -7,13 +7,10 @@ #ifndef XFA_FXFA_PARSER_XFA_RESOLVENODE_RS_H_ #define XFA_FXFA_PARSER_XFA_RESOLVENODE_RS_H_ -#include -#include #include -#include "fxjs/cfxjse_value.h" -#include "third_party/base/ptr_util.h" -#include "xfa/fxfa/fxfa.h" +#include "core/fxcrt/unowned_ptr.h" +#include "fxjs/xfa/cjx_object.h" #include "xfa/fxfa/parser/cxfa_object.h" #define XFA_RESOLVENODE_Children 0x0001 @@ -40,14 +37,13 @@ struct XFA_RESOLVENODE_RS { XFA_RESOLVENODE_RS(); ~XFA_RESOLVENODE_RS(); - std::vector objects; // Not owned. - XFA_ResolveNode_RSType dwFlags; - const XFA_SCRIPTATTRIBUTEINFO* pScriptAttribute; + XFA_ResolveNode_RSType dwFlags = XFA_ResolveNode_RSType_Nodes; + std::vector> objects; + UnownedPtr pScriptAttribute; }; -inline XFA_RESOLVENODE_RS::XFA_RESOLVENODE_RS() - : dwFlags(XFA_ResolveNode_RSType_Nodes), pScriptAttribute(nullptr) {} +inline XFA_RESOLVENODE_RS::XFA_RESOLVENODE_RS() = default; -inline XFA_RESOLVENODE_RS::~XFA_RESOLVENODE_RS() {} +inline XFA_RESOLVENODE_RS::~XFA_RESOLVENODE_RS() = default; #endif // XFA_FXFA_PARSER_XFA_RESOLVENODE_RS_H_ -- cgit v1.2.3