summaryrefslogtreecommitdiff
path: root/fxjs
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2018-07-25 17:04:49 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-07-25 17:04:49 +0000
commit96b0d1332430e34219334373aeb0f6a85eb8ad68 (patch)
treee50f75e447d6c1dff6e50b4b089af5b1a21b475e /fxjs
parent1f7db295b1deeecb562d6213b3ea17b9168405eb (diff)
downloadpdfium-96b0d1332430e34219334373aeb0f6a85eb8ad68.tar.xz
Introduce ToXMLElement() checked downcast helper function
And use it in place of ASSERT() that the type was correct. Since we can check it, doing so at runtime may help avoid type confusion, and we'll get a nice safe SEGV if the asserted condition ever fails. Change-Id: I46b65a4b70e819a670d7cad7966e0d100f0d9a63 Reviewed-on: https://pdfium-review.googlesource.com/38810 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'fxjs')
-rw-r--r--fxjs/xfa/cjx_object.cpp14
1 files changed, 4 insertions, 10 deletions
diff --git a/fxjs/xfa/cjx_object.cpp b/fxjs/xfa/cjx_object.cpp
index 2cf6f6755d..1c0454d425 100644
--- a/fxjs/xfa/cjx_object.cpp
+++ b/fxjs/xfa/cjx_object.cpp
@@ -480,13 +480,11 @@ void CJX_Object::SetCData(XFA_Attribute eAttr,
return;
}
- auto* elem = static_cast<CFX_XMLElement*>(xfaObj->GetXMLMappingNode());
- ASSERT(elem->GetType() == FX_XMLNODE_Element);
-
WideString wsAttrName = CXFA_Node::AttributeToName(eAttr);
if (eAttr == XFA_Attribute::ContentType)
wsAttrName = L"xfa:" + wsAttrName;
+ CFX_XMLElement* elem = ToXMLElement(xfaObj->GetXMLMappingNode());
elem->SetAttribute(wsAttrName, wsValue);
return;
}
@@ -544,14 +542,10 @@ CFX_XMLElement* CJX_Object::SetValue(XFA_Attribute eAttr,
OnChanging(eAttr, bNotify);
SetMapModuleValue(pKey, pValue);
OnChanged(eAttr, bNotify, false);
- if (!ToNode(GetXFAObject())->IsNeedSavingXMLNode())
- return nullptr;
-
- auto* elem =
- static_cast<CFX_XMLElement*>(ToNode(GetXFAObject())->GetXMLMappingNode());
- ASSERT(elem->GetType() == FX_XMLNODE_Element);
- return elem;
+ CXFA_Node* pNode = ToNode(GetXFAObject());
+ return pNode->IsNeedSavingXMLNode() ? ToXMLElement(pNode->GetXMLMappingNode())
+ : nullptr;
}
void CJX_Object::SetContent(const WideString& wsContent,