From 9d608ff14177cd665f6b2ead639415bda935fbe2 Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Thu, 16 Nov 2017 14:17:17 +0000 Subject: Cleanup CJX_Node::GetAttribute This CL renames GetAttribute to TryAttribute and changes to return a pdfium::Optional instead of a boolean with an out parameter. GetAttribute is then added to call TryAttribute to mirror the other methods in the file. Change-Id: I875dac120776af7c53fe069e4dd36e5486838447 Reviewed-on: https://pdfium-review.googlesource.com/18514 Commit-Queue: dsinclair Reviewed-by: Tom Sepez --- xfa/fxfa/parser/cxfa_node.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'xfa/fxfa/parser/cxfa_node.cpp') diff --git a/xfa/fxfa/parser/cxfa_node.cpp b/xfa/fxfa/parser/cxfa_node.cpp index 90579ff5e2..465529e777 100644 --- a/xfa/fxfa/parser/cxfa_node.cpp +++ b/xfa/fxfa/parser/cxfa_node.cpp @@ -198,8 +198,9 @@ CXFA_Node* CXFA_Node::Clone(bool bRecursive) { if (IsNeedSavingXMLNode()) { std::unique_ptr pCloneXML; if (IsAttributeInXML()) { - WideString wsName; - JSNode()->GetAttribute(XFA_Attribute::Name, wsName, false); + WideString wsName = JSNode() + ->TryAttribute(XFA_Attribute::Name, false) + .value_or(WideString()); auto pCloneXMLElement = pdfium::MakeUnique(wsName); WideString wsValue = JSNode()->GetCData(XFA_Attribute::Value); if (!wsValue.IsEmpty()) @@ -867,8 +868,10 @@ bool CXFA_Node::RemoveChild(CXFA_Node* pNode, bool bNotify) { pNode->JSNode()->GetCData(XFA_Attribute::QualifiedName); pXMLElement->RemoveAttribute(wsAttributeName.c_str()); } - WideString wsName; - pNode->JSNode()->GetAttribute(XFA_Attribute::Name, wsName, false); + + WideString wsName = pNode->JSNode() + ->TryAttribute(XFA_Attribute::Name, false) + .value_or(WideString()); CFX_XMLElement* pNewXMLElement = new CFX_XMLElement(wsName); WideString wsValue = JSNode()->GetCData(XFA_Attribute::Value); if (!wsValue.IsEmpty()) -- cgit v1.2.3