From c9171e16d9d4477501d326d8d456fdc03e0f832e Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Thu, 26 Jul 2018 19:34:26 +0000 Subject: Use moar ToXMLElement() in place of static_cast<>. Introduces checks in a few new places, but mainly just consolidates checking/casting logic. Change-Id: I634a03060d254db099972c6978249992367e146c Reviewed-on: https://pdfium-review.googlesource.com/38900 Commit-Queue: Tom Sepez Reviewed-by: Lei Zhang --- xfa/fxfa/parser/cxfa_node.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 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 363af54028..9fdea14cae 100644 --- a/xfa/fxfa/parser/cxfa_node.cpp +++ b/xfa/fxfa/parser/cxfa_node.cpp @@ -1259,11 +1259,9 @@ void CXFA_Node::RemoveChild(CXFA_Node* pNode, bool bNotify) { return; } - ASSERT(pNode->xml_node_.Get() == xml_node_.Get() && - xml_node_->GetType() == FX_XMLNODE_Element); - if (pNode->xml_node_->GetType() == FX_XMLNODE_Element) { - CFX_XMLElement* pXMLElement = - static_cast(pNode->xml_node_.Get()); + ASSERT(pNode->xml_node_.Get() == xml_node_.Get()); + CFX_XMLElement* pXMLElement = ToXMLElement(pNode->xml_node_.Get()); + if (pXMLElement) { WideString wsAttributeName = pNode->JSObject()->GetCData(XFA_Attribute::QualifiedName); pXMLElement->RemoveAttribute(wsAttributeName); @@ -4700,10 +4698,10 @@ bool CXFA_Node::PresenceRequiresSpace() const { } void CXFA_Node::SetToXML(const WideString& value) { - auto* elem = static_cast(GetXMLMappingNode()); - FX_XMLNODETYPE eXMLType = elem->GetType(); - switch (eXMLType) { + auto* pNode = GetXMLMappingNode(); + switch (pNode->GetType()) { case FX_XMLNODE_Element: { + auto* elem = static_cast(pNode); if (IsAttributeInXML()) { elem->SetAttribute(JSObject()->GetCData(XFA_Attribute::QualifiedName), value); -- cgit v1.2.3