summaryrefslogtreecommitdiff
path: root/xfa
diff options
context:
space:
mode:
authordsinclair <dsinclair@chromium.org>2016-06-23 12:14:55 -0700
committerCommit bot <commit-bot@chromium.org>2016-06-23 12:14:55 -0700
commit6e12478cb298c3a8277493ee79ae0b73d6df8554 (patch)
tree46e28dbab97bbe41cca67ace9a3a05429c9cd519 /xfa
parentf7f659c2c98a4d02e3695266d33f449b7be01af9 (diff)
downloadpdfium-6e12478cb298c3a8277493ee79ae0b73d6df8554.tar.xz
Change XFA_GetElementByName to XFA_GetElementTypeForName
This method was only ever used to get the XFA_Element type for the given element name. Changed to make the signature match the usage. Review-Url: https://codereview.chromium.org/2095733002
Diffstat (limited to 'xfa')
-rw-r--r--xfa/fxfa/include/fxfa_basic.h2
-rw-r--r--xfa/fxfa/parser/xfa_basic_imp.cpp15
-rw-r--r--xfa/fxfa/parser/xfa_object_imp.cpp19
-rw-r--r--xfa/fxfa/parser/xfa_parser_imp.cpp15
-rw-r--r--xfa/fxfa/parser/xfa_script_imp.cpp11
-rw-r--r--xfa/fxfa/parser/xfa_script_nodehelper.cpp9
-rw-r--r--xfa/fxfa/parser/xfa_script_resolveprocessor.cpp9
7 files changed, 35 insertions, 45 deletions
diff --git a/xfa/fxfa/include/fxfa_basic.h b/xfa/fxfa/include/fxfa_basic.h
index 51d81cd157..9fe2650ffc 100644
--- a/xfa/fxfa/include/fxfa_basic.h
+++ b/xfa/fxfa/include/fxfa_basic.h
@@ -938,7 +938,7 @@ struct XFA_ELEMENTINFO {
XFA_ObjectType eObjectType;
};
-const XFA_ELEMENTINFO* XFA_GetElementByName(const CFX_WideStringC& wsName);
+XFA_Element XFA_GetElementTypeForName(const CFX_WideStringC& wsName);
const XFA_ELEMENTINFO* XFA_GetElementByID(XFA_Element eName);
enum XFA_ATTRIBUTETYPE {
diff --git a/xfa/fxfa/parser/xfa_basic_imp.cpp b/xfa/fxfa/parser/xfa_basic_imp.cpp
index 6896299a0e..67a110b4e5 100644
--- a/xfa/fxfa/parser/xfa_basic_imp.cpp
+++ b/xfa/fxfa/parser/xfa_basic_imp.cpp
@@ -174,9 +174,9 @@ CXFA_Measurement XFA_GetAttributeDefaultValue_Measure(XFA_Element eElement,
return CXFA_Measurement();
}
-const XFA_ELEMENTINFO* XFA_GetElementByName(const CFX_WideStringC& wsName) {
+XFA_Element XFA_GetElementTypeForName(const CFX_WideStringC& wsName) {
if (wsName.IsEmpty())
- return nullptr;
+ return XFA_Element::Unknown;
uint32_t uHash = FX_HashCode_GetW(wsName, false);
int32_t iStart = 0;
@@ -184,15 +184,14 @@ const XFA_ELEMENTINFO* XFA_GetElementByName(const CFX_WideStringC& wsName) {
do {
int32_t iMid = (iStart + iEnd) / 2;
const XFA_ELEMENTINFO* pInfo = g_XFAElementData + iMid;
- if (uHash == pInfo->uHash) {
- return pInfo;
- } else if (uHash < pInfo->uHash) {
+ if (uHash == pInfo->uHash)
+ return pInfo->eName;
+ if (uHash < pInfo->uHash)
iEnd = iMid - 1;
- } else {
+ else
iStart = iMid + 1;
- }
} while (iStart <= iEnd);
- return nullptr;
+ return XFA_Element::Unknown;
}
const XFA_ELEMENTINFO* XFA_GetElementByID(XFA_Element eName) {
return eName == XFA_Element::Unknown
diff --git a/xfa/fxfa/parser/xfa_object_imp.cpp b/xfa/fxfa/parser/xfa_object_imp.cpp
index 06ffb10a18..47b244fce5 100644
--- a/xfa/fxfa/parser/xfa_object_imp.cpp
+++ b/xfa/fxfa/parser/xfa_object_imp.cpp
@@ -881,9 +881,8 @@ void CXFA_Node::Script_NodeClass_GetElement(CFXJSE_Arguments* pArguments) {
CFX_WideString::FromUTF8(pArguments->GetUTF8String(0).AsStringC());
if (iLength >= 2)
iValue = pArguments->GetInt32(1);
- const XFA_ELEMENTINFO* pElementInfo =
- XFA_GetElementByName(wsExpression.AsStringC());
- CXFA_Node* pNode = GetProperty(iValue, pElementInfo->eName);
+ CXFA_Node* pNode =
+ GetProperty(iValue, XFA_GetElementTypeForName(wsExpression.AsStringC()));
pArguments->GetReturnValue()->Assign(
m_pDocument->GetScriptContext()->GetJSValueFromMap(pNode));
}
@@ -911,14 +910,13 @@ void CXFA_Node::Script_NodeClass_IsPropertySpecified(
if (pAttributeInfo)
bHas = HasAttribute(pAttributeInfo->eName);
if (!bHas) {
- const XFA_ELEMENTINFO* pElementInfo =
- XFA_GetElementByName(wsExpression.AsStringC());
- bHas = !!GetProperty(iIndex, pElementInfo->eName);
+ XFA_Element eType = XFA_GetElementTypeForName(wsExpression.AsStringC());
+ bHas = !!GetProperty(iIndex, eType);
if (!bHas && bParent && m_pParent) {
// Also check on the parent.
bHas = m_pParent->HasAttribute(pAttributeInfo->eName);
if (!bHas)
- bHas = !!m_pParent->GetProperty(iIndex, pElementInfo->eName);
+ bHas = !!m_pParent->GetProperty(iIndex, eType);
}
}
CFXJSE_Value* pValue = pArguments->GetReturnValue();
@@ -2628,14 +2626,13 @@ void CXFA_Node::Script_Template_CreateNode(CFXJSE_Arguments* pArguments) {
strNameSpace = CFX_WideString::FromUTF8(bsNameSpace.AsStringC());
}
}
- const XFA_ELEMENTINFO* pElement =
- XFA_GetElementByName(strTagName.AsStringC());
- CXFA_Node* pNewNode = CreateSamePacketNode(pElement->eName);
+ XFA_Element eType = XFA_GetElementTypeForName(strTagName.AsStringC());
+ CXFA_Node* pNewNode = CreateSamePacketNode(eType);
if (!pNewNode) {
pArguments->GetReturnValue()->SetNull();
} else {
if (!strName.IsEmpty()) {
- if (XFA_GetAttributeOfElement(pElement->eName, XFA_ATTRIBUTE_Name,
+ if (XFA_GetAttributeOfElement(eType, XFA_ATTRIBUTE_Name,
XFA_XDPPACKET_UNKNOWN)) {
pNewNode->SetAttribute(XFA_ATTRIBUTE_Name, strName.AsStringC(), true);
if (pNewNode->GetPacketID() == XFA_XDPPACKET_Datasets) {
diff --git a/xfa/fxfa/parser/xfa_parser_imp.cpp b/xfa/fxfa/parser/xfa_parser_imp.cpp
index 38fdbbb662..20964053f5 100644
--- a/xfa/fxfa/parser/xfa_parser_imp.cpp
+++ b/xfa/fxfa/parser/xfa_parser_imp.cpp
@@ -833,13 +833,12 @@ CXFA_Node* CXFA_SimpleParser::NormalLoader(CXFA_Node* pXFANode,
CFDE_XMLElement* pXMLElement = static_cast<CFDE_XMLElement*>(pXMLChild);
CFX_WideString wsTagName;
pXMLElement->GetLocalTagName(wsTagName);
- const XFA_ELEMENTINFO* pElemInfo =
- XFA_GetElementByName(wsTagName.AsStringC());
- if (!pElemInfo) {
+ XFA_Element eType = XFA_GetElementTypeForName(wsTagName.AsStringC());
+ if (eType == XFA_Element::Unknown)
continue;
- }
+
const XFA_PROPERTY* pPropertyInfo = XFA_GetPropertyOfElement(
- pXFANode->GetElementType(), pElemInfo->eName, ePacketID);
+ pXFANode->GetElementType(), eType, ePacketID);
if (pPropertyInfo &&
((pPropertyInfo->uFlags &
(XFA_PROPERTYFLAG_OneOf | XFA_PROPERTYFLAG_DefaultOneOf)) != 0)) {
@@ -848,8 +847,7 @@ CXFA_Node* CXFA_SimpleParser::NormalLoader(CXFA_Node* pXFANode,
}
bOneOfPropertyFound = TRUE;
}
- CXFA_Node* pXFAChild =
- m_pFactory->CreateNode(ePacketID, pElemInfo->eName);
+ CXFA_Node* pXFAChild = m_pFactory->CreateNode(ePacketID, eType);
if (pXFAChild == NULL) {
return NULL;
}
@@ -881,8 +879,7 @@ CXFA_Node* CXFA_SimpleParser::NormalLoader(CXFA_Node* pXFANode,
pXFAChild->SetAttribute(lpAttrInfo->eName, wsAttrValue.AsStringC());
}
pXFANode->InsertChild(pXFAChild);
- if (pElemInfo->eName == XFA_Element::Validate ||
- pElemInfo->eName == XFA_Element::Locale) {
+ if (eType == XFA_Element::Validate || eType == XFA_Element::Locale) {
if (ePacketID == XFA_XDPPACKET_Config) {
ParseContentNode(pXFAChild, pXMLElement, ePacketID);
} else {
diff --git a/xfa/fxfa/parser/xfa_script_imp.cpp b/xfa/fxfa/parser/xfa_script_imp.cpp
index ee7576ebf1..2afa5fcdec 100644
--- a/xfa/fxfa/parser/xfa_script_imp.cpp
+++ b/xfa/fxfa/parser/xfa_script_imp.cpp
@@ -319,13 +319,12 @@ void CXFA_ScriptContext::NormalPropertySetter(CFXJSE_Value* pOriginalValue,
}
CXFA_Node* pNode = ToNode(pObject);
CXFA_Node* pPropOrChild = nullptr;
- const XFA_ELEMENTINFO* lpElementInfo =
- XFA_GetElementByName(wsPropName.AsStringC());
- if (lpElementInfo) {
- pPropOrChild = pNode->GetProperty(0, lpElementInfo->eName);
- } else {
+ XFA_Element eType = XFA_GetElementTypeForName(wsPropName.AsStringC());
+ if (eType != XFA_Element::Unknown)
+ pPropOrChild = pNode->GetProperty(0, eType);
+ else
pPropOrChild = pNode->GetFirstChildByName(wsPropName.AsStringC());
- }
+
if (pPropOrChild) {
CFX_WideString wsDefaultName(L"{default}");
const XFA_SCRIPTATTRIBUTEINFO* lpAttrInfo =
diff --git a/xfa/fxfa/parser/xfa_script_nodehelper.cpp b/xfa/fxfa/parser/xfa_script_nodehelper.cpp
index 0fd5ff21d5..42f406e48a 100644
--- a/xfa/fxfa/parser/xfa_script_nodehelper.cpp
+++ b/xfa/fxfa/parser/xfa_script_nodehelper.cpp
@@ -376,13 +376,12 @@ FX_BOOL CXFA_NodeHelper::XFA_ResolveNodes_CreateNode(
XFA_CreateNode_ForCondition(wsCondition);
}
if (bIsClassName) {
- const XFA_ELEMENTINFO* lpElement = XFA_GetElementByName(wsName.AsStringC());
- if (lpElement == NULL) {
+ XFA_Element eType = XFA_GetElementTypeForName(wsName.AsStringC());
+ if (eType == XFA_Element::Unknown)
return FALSE;
- }
+
for (int32_t iIndex = 0; iIndex < m_iCreateCount; iIndex++) {
- CXFA_Node* pNewNode =
- m_pCreateParent->CreateSamePacketNode(lpElement->eName);
+ CXFA_Node* pNewNode = m_pCreateParent->CreateSamePacketNode(eType);
if (pNewNode) {
m_pCreateParent->InsertChild(pNewNode);
if (iIndex == m_iCreateCount - 1) {
diff --git a/xfa/fxfa/parser/xfa_script_resolveprocessor.cpp b/xfa/fxfa/parser/xfa_script_resolveprocessor.cpp
index a78ad7bb6b..bcfaa113d4 100644
--- a/xfa/fxfa/parser/xfa_script_resolveprocessor.cpp
+++ b/xfa/fxfa/parser/xfa_script_resolveprocessor.cpp
@@ -362,11 +362,10 @@ int32_t CXFA_ResolveProcessor::XFA_ResolveNodes_Normal(
pProp = pInstanceManager->GetProperty(0, XFA_Element::Occur, TRUE);
}
} else {
- const XFA_ELEMENTINFO* pElement =
- XFA_GetElementByName(wsName.AsStringC());
- if (pElement) {
- pProp = curNode->AsNode()->GetProperty(
- 0, pElement->eName, pElement->eName != XFA_Element::PageSet);
+ XFA_Element eType = XFA_GetElementTypeForName(wsName.AsStringC());
+ if (eType != XFA_Element::Unknown) {
+ pProp = curNode->AsNode()->GetProperty(0, eType,
+ eType != XFA_Element::PageSet);
}
}
if (pProp) {