summaryrefslogtreecommitdiff
path: root/xfa
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2017-09-15 00:01:01 -0700
committerChromium commit bot <commit-bot@chromium.org>2017-09-15 18:56:26 +0000
commitbb2f7e73bef47b4e865118cb52170563d849b4de (patch)
treee2899e50de583ce96ec585459b1da6690e34e005 /xfa
parent022d13b85408beb400ce703bb5c59736adea208f (diff)
downloadpdfium-bb2f7e73bef47b4e865118cb52170563d849b4de.tar.xz
Simplify a couple of CXFA_Node methods.
Change-Id: I89c81e18273e929910f083399ed169017a6171f5 Reviewed-on: https://pdfium-review.googlesource.com/14091 Reviewed-by: Ryan Harrison <rharrison@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'xfa')
-rw-r--r--xfa/fxfa/parser/cxfa_node.cpp64
1 files changed, 29 insertions, 35 deletions
diff --git a/xfa/fxfa/parser/cxfa_node.cpp b/xfa/fxfa/parser/cxfa_node.cpp
index 9239e222c5..2f741c59e6 100644
--- a/xfa/fxfa/parser/cxfa_node.cpp
+++ b/xfa/fxfa/parser/cxfa_node.cpp
@@ -1237,22 +1237,19 @@ void CXFA_Node::Script_NodeClass_IsPropertySpecified(
ThrowParamCountMismatchException(L"isPropertySpecified");
return;
}
- CFX_WideString wsExpression;
- bool bParent = true;
- int32_t iIndex = 0;
- wsExpression =
+
+ CFXJSE_Value* pValue = pArguments->GetReturnValue();
+ if (!pValue)
+ return;
+
+ CFX_WideString wsExpression =
CFX_WideString::FromUTF8(pArguments->GetUTF8String(0).AsStringC());
- if (iLength >= 2)
- bParent = !!pArguments->GetInt32(1);
- if (iLength >= 3)
- iIndex = pArguments->GetInt32(2);
- bool bHas = false;
const XFA_ATTRIBUTEINFO* pAttributeInfo =
XFA_GetAttributeByName(wsExpression.AsStringC());
- CFX_WideString wsValue;
- if (pAttributeInfo)
- bHas = HasAttribute(pAttributeInfo->eName);
+ bool bHas = pAttributeInfo ? HasAttribute(pAttributeInfo->eName) : false;
if (!bHas) {
+ bool bParent = iLength < 2 || pArguments->GetInt32(1);
+ int32_t iIndex = iLength == 3 ? pArguments->GetInt32(2) : 0;
XFA_Element eType = XFA_GetElementTypeForName(wsExpression.AsStringC());
bHas = !!GetProperty(iIndex, eType);
if (!bHas && bParent && m_pParent) {
@@ -1262,9 +1259,7 @@ void CXFA_Node::Script_NodeClass_IsPropertySpecified(
bHas = !!m_pParent->GetProperty(iIndex, eType);
}
}
- CFXJSE_Value* pValue = pArguments->GetReturnValue();
- if (pValue)
- pValue->SetBoolean(bHas);
+ pValue->SetBoolean(bHas);
}
void CXFA_Node::Script_NodeClass_LoadXML(CFXJSE_Arguments* pArguments) {
@@ -4307,31 +4302,30 @@ bool CXFA_Node::TryNamespace(CFX_WideString& wsNamespace) {
wsNamespace.clear();
if (IsModelNode() || GetElementType() == XFA_Element::Packet) {
CFX_XMLNode* pXMLNode = GetXMLMappingNode();
- if (!pXMLNode || pXMLNode->GetType() != FX_XMLNODE_Element) {
+ if (!pXMLNode || pXMLNode->GetType() != FX_XMLNODE_Element)
return false;
- }
+
wsNamespace = static_cast<CFX_XMLElement*>(pXMLNode)->GetNamespaceURI();
return true;
- } else if (GetPacketID() == XFA_XDPPACKET_Datasets) {
- CFX_XMLNode* pXMLNode = GetXMLMappingNode();
- if (!pXMLNode) {
- return false;
- }
- if (pXMLNode->GetType() != FX_XMLNODE_Element) {
- return true;
- }
- if (GetElementType() == XFA_Element::DataValue &&
- GetEnum(XFA_ATTRIBUTE_Contains) == XFA_ATTRIBUTEENUM_MetaData) {
- return XFA_FDEExtension_ResolveNamespaceQualifier(
- static_cast<CFX_XMLElement*>(pXMLNode),
- GetCData(XFA_ATTRIBUTE_QualifiedName), &wsNamespace);
- }
- wsNamespace = static_cast<CFX_XMLElement*>(pXMLNode)->GetNamespaceURI();
+ }
+
+ if (GetPacketID() != XFA_XDPPACKET_Datasets)
+ return GetModelNode()->TryNamespace(wsNamespace);
+
+ CFX_XMLNode* pXMLNode = GetXMLMappingNode();
+ if (!pXMLNode)
+ return false;
+ if (pXMLNode->GetType() != FX_XMLNODE_Element)
return true;
- } else {
- CXFA_Node* pModelNode = GetModelNode();
- return pModelNode->TryNamespace(wsNamespace);
+
+ if (GetElementType() == XFA_Element::DataValue &&
+ GetEnum(XFA_ATTRIBUTE_Contains) == XFA_ATTRIBUTEENUM_MetaData) {
+ return XFA_FDEExtension_ResolveNamespaceQualifier(
+ static_cast<CFX_XMLElement*>(pXMLNode),
+ GetCData(XFA_ATTRIBUTE_QualifiedName), &wsNamespace);
}
+ wsNamespace = static_cast<CFX_XMLElement*>(pXMLNode)->GetNamespaceURI();
+ return true;
}
CXFA_Node* CXFA_Node::GetProperty(int32_t index,