From 68bc6ad5a70fdb35ae5c088bd3ca977e15ea9573 Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Wed, 1 Nov 2017 21:08:08 +0000 Subject: Remove default value from CJX_Node::HasAttribute The attribute is always false, removed and simplified the code. Change-Id: Ic20ffe8d91fc3fcd66835e1bc2b1bce3da69be16 Reviewed-on: https://pdfium-review.googlesource.com/17316 Reviewed-by: Tom Sepez Commit-Queue: dsinclair --- fxjs/cjx_node.cpp | 25 ++++++------------------- fxjs/cjx_node.h | 4 ++-- xfa/fxfa/parser/cxfa_dataexporter.cpp | 5 ++--- 3 files changed, 10 insertions(+), 24 deletions(-) diff --git a/fxjs/cjx_node.cpp b/fxjs/cjx_node.cpp index 1f39245c73..929a946c09 100644 --- a/fxjs/cjx_node.cpp +++ b/fxjs/cjx_node.cpp @@ -191,9 +191,9 @@ const CXFA_Node* CJX_Node::GetXFANode() const { return static_cast(GetXFAObject()); } -bool CJX_Node::HasAttribute(XFA_ATTRIBUTE eAttr, bool bCanInherit) { +bool CJX_Node::HasAttribute(XFA_ATTRIBUTE eAttr) { void* pKey = GetMapKey_Element(GetXFANode()->GetElementType(), eAttr); - return HasMapModuleKey(pKey, bCanInherit); + return HasMapModuleKey(pKey); } bool CJX_Node::SetAttribute(XFA_ATTRIBUTE eAttr, @@ -3709,23 +3709,10 @@ bool CJX_Node::GetMapModuleBuffer(void* pKey, return true; } -bool CJX_Node::HasMapModuleKey(void* pKey, bool bProtoAlso) { - for (CXFA_Node* pNode = GetXFANode(); pNode; - pNode = pNode->GetTemplateNode()) { - XFA_MAPMODULEDATA* pModule = pNode->JSNode()->GetMapModuleData(); - if (pModule) { - auto it1 = pModule->m_ValueMap.find(pKey); - if (it1 != pModule->m_ValueMap.end()) - return true; - - auto it2 = pModule->m_BufferMap.find(pKey); - if (it2 != pModule->m_BufferMap.end()) - return true; - } - if (!bProtoAlso || pNode->GetPacketID() == XFA_XDPPACKET_Datasets) - break; - } - return false; +bool CJX_Node::HasMapModuleKey(void* pKey) { + XFA_MAPMODULEDATA* pModule = GetXFANode()->JSNode()->GetMapModuleData(); + return pModule && (pdfium::ContainsKey(pModule->m_ValueMap, pKey) || + pdfium::ContainsKey(pModule->m_BufferMap, pKey)); } void CJX_Node::RemoveMapModuleKey(void* pKey) { diff --git a/fxjs/cjx_node.h b/fxjs/cjx_node.h index a70cec3ce7..abac5405a5 100644 --- a/fxjs/cjx_node.h +++ b/fxjs/cjx_node.h @@ -52,7 +52,7 @@ class CJX_Node : public CJX_Object { CXFA_Node* GetXFANode(); const CXFA_Node* GetXFANode() const; - bool HasAttribute(XFA_ATTRIBUTE eAttr, bool bCanInherit = false); + bool HasAttribute(XFA_ATTRIBUTE eAttr); bool SetAttribute(XFA_ATTRIBUTE eAttr, const WideStringView& wsValue, bool bNotify = false); @@ -490,7 +490,7 @@ class CJX_Node : public CJX_Object { void*& pValue, int32_t& iBytes, bool bProtoAlso = true) const; - bool HasMapModuleKey(void* pKey, bool bProtoAlso = false); + bool HasMapModuleKey(void* pKey); void RemoveMapModuleKey(void* pKey = nullptr); void MoveBufferMapData(CXFA_Node* pDstModule, void* pKey); void MoveBufferMapData(CXFA_Node* pSrcModule, diff --git a/xfa/fxfa/parser/cxfa_dataexporter.cpp b/xfa/fxfa/parser/cxfa_dataexporter.cpp index aeee2c196a..70f9513e37 100644 --- a/xfa/fxfa/parser/cxfa_dataexporter.cpp +++ b/xfa/fxfa/parser/cxfa_dataexporter.cpp @@ -91,9 +91,8 @@ void SaveAttribute(CXFA_Node* pNode, bool bProto, WideString& wsOutput) { WideString wsValue; - if ((!bProto && - !pNode->JSNode()->HasAttribute((XFA_ATTRIBUTE)eName, bProto)) || - !pNode->JSNode()->GetAttribute((XFA_ATTRIBUTE)eName, wsValue, false)) { + if ((!bProto && !pNode->JSNode()->HasAttribute(eName)) || + !pNode->JSNode()->GetAttribute(eName, wsValue, false)) { return; } wsValue = ExportEncodeAttribute(wsValue); -- cgit v1.2.3