Make CXFA_NodeHelper method names match style guide.
Drop some superfluous words and remove underscores in names.
Re-order NodeIsProperty() to avoid needless call.
Change-Id: I6b1edbdbc96fe710ebbdcfc2b209a05c3157132d
Reviewed-on: https://pdfium-review.googlesource.com/c/47232
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
diff --git a/fxjs/xfa/cfxjse_engine.cpp b/fxjs/xfa/cfxjse_engine.cpp
index 43a6ea3..5b50bf8 100644
--- a/fxjs/xfa/cfxjse_engine.cpp
+++ b/fxjs/xfa/cfxjse_engine.cpp
@@ -625,17 +625,14 @@
break;
}
if (bNextCreate) {
- bool bCreate = pNodeHelper->ResolveNodes_CreateNode(
- rndFind.m_wsName, rndFind.m_wsCondition,
- nStart ==
- pdfium::base::checked_cast<int32_t>(wsExpression.GetLength()),
- this);
- if (bCreate)
+ int32_t checked_length =
+ pdfium::base::checked_cast<int32_t>(wsExpression.GetLength());
+ if (pNodeHelper->CreateNode(rndFind.m_wsName, rndFind.m_wsCondition,
+ nStart == checked_length, this)) {
continue;
-
+ }
break;
}
-
std::vector<CXFA_Object*> retObjects;
while (i < nNodes) {
bool bDataBind = false;
@@ -681,7 +678,7 @@
pNodeHelper->m_pCreateParent = ToNode(rndFind.m_CurObject);
pNodeHelper->m_iCreateCount = 1;
}
- bool bCreate = pNodeHelper->ResolveNodes_CreateNode(
+ bool bCreate = pNodeHelper->CreateNode(
rndFind.m_wsName, rndFind.m_wsCondition,
nStart ==
pdfium::base::checked_cast<int32_t>(wsExpression.GetLength()),
@@ -717,7 +714,7 @@
if (pNodeHelper->m_pCreateParent)
resolveNodeRS->objects.emplace_back(pNodeHelper->m_pCreateParent.Get());
else
- pNodeHelper->CreateNode_ForCondition(rndFind.m_wsCondition);
+ pNodeHelper->CreateNodeForCondition(rndFind.m_wsCondition);
resolveNodeRS->dwFlags = pNodeHelper->m_iCreateFlag;
if (resolveNodeRS->dwFlags == XFA_ResolveNode_RSType_CreateNodeOne) {
diff --git a/fxjs/xfa/cfxjse_resolveprocessor.cpp b/fxjs/xfa/cfxjse_resolveprocessor.cpp
index e6fa74b..1a89c5b 100644
--- a/fxjs/xfa/cfxjse_resolveprocessor.cpp
+++ b/fxjs/xfa/cfxjse_resolveprocessor.cpp
@@ -98,8 +98,8 @@
bClassName = true;
wsName = wsName.Right(wsName.GetLength() - 1);
}
- findNode = m_pNodeHelper->ResolveNodes_GetOneChild(
- ToNode(rnd.m_CurObject), wsName.c_str(), bClassName);
+ findNode = m_pNodeHelper->GetOneChild(ToNode(rnd.m_CurObject), wsName.c_str(),
+ bClassName);
if (!findNode)
return false;
@@ -363,8 +363,8 @@
}
}
- CXFA_Node* parentNode = m_pNodeHelper->ResolveNodes_GetParent(
- curNode->AsNode(), XFA_LOGIC_NoTransparent);
+ CXFA_Node* parentNode =
+ m_pNodeHelper->GetParent(curNode->AsNode(), XFA_LOGIC_NoTransparent);
uint32_t uCurClassHash = curNode->GetClassHashCode();
if (!parentNode) {
if (uCurClassHash == uNameHash) {
@@ -718,7 +718,7 @@
void CFXJSE_ResolveProcessor::SetIndexDataBind(WideString& wsNextCondition,
int32_t& iIndex,
int32_t iCount) {
- if (m_pNodeHelper->CreateNode_ForCondition(wsNextCondition)) {
+ if (m_pNodeHelper->CreateNodeForCondition(wsNextCondition)) {
if (m_pNodeHelper->m_eLastCreateType == XFA_Element::DataGroup) {
iIndex = 0;
} else {
diff --git a/xfa/fxfa/parser/cxfa_nodehelper.cpp b/xfa/fxfa/parser/cxfa_nodehelper.cpp
index caf3bdb..14bc1b1 100644
--- a/xfa/fxfa/parser/cxfa_nodehelper.cpp
+++ b/xfa/fxfa/parser/cxfa_nodehelper.cpp
@@ -22,15 +22,15 @@
CXFA_NodeHelper::~CXFA_NodeHelper() = default;
-CXFA_Node* CXFA_NodeHelper::ResolveNodes_GetOneChild(CXFA_Node* parent,
- const wchar_t* pwsName,
- bool bIsClassName) {
+CXFA_Node* CXFA_NodeHelper::GetOneChild(CXFA_Node* parent,
+ const wchar_t* pwsName,
+ bool bIsClassName) {
if (!parent)
return nullptr;
std::vector<CXFA_Node*> siblings;
uint32_t uNameHash = FX_HashCode_GetW(WideStringView(pwsName), false);
- NodeAcc_TraverseAnySiblings(parent, uNameHash, &siblings, bIsClassName);
+ TraverseAnySiblings(parent, uNameHash, &siblings, bIsClassName);
return !siblings.empty() ? siblings[0] : nullptr;
}
@@ -40,28 +40,27 @@
bool bIsClassName) {
if (!pNode)
return 0;
- CXFA_Node* parent = ResolveNodes_GetParent(pNode, XFA_LOGIC_NoTransparent);
+ CXFA_Node* parent = GetParent(pNode, XFA_LOGIC_NoTransparent);
if (!parent)
return 0;
if (!parent->HasProperty(pNode->GetElementType()) &&
eLogicType == XFA_LOGIC_Transparent) {
- parent = ResolveNodes_GetParent(pNode, XFA_LOGIC_Transparent);
+ parent = GetParent(pNode, XFA_LOGIC_Transparent);
if (!parent)
return 0;
}
if (bIsClassName) {
- return NodeAcc_TraverseSiblings(parent, pNode->GetClassHashCode(),
- pSiblings, eLogicType, bIsClassName, true);
+ return TraverseSiblings(parent, pNode->GetClassHashCode(), pSiblings,
+ eLogicType, bIsClassName, true);
}
- return NodeAcc_TraverseSiblings(parent, pNode->GetNameHash(), pSiblings,
- eLogicType, bIsClassName, true);
+ return TraverseSiblings(parent, pNode->GetNameHash(), pSiblings, eLogicType,
+ bIsClassName, true);
}
-int32_t CXFA_NodeHelper::NodeAcc_TraverseAnySiblings(
- CXFA_Node* parent,
- uint32_t dNameHash,
- std::vector<CXFA_Node*>* pSiblings,
- bool bIsClassName) {
+int32_t CXFA_NodeHelper::TraverseAnySiblings(CXFA_Node* parent,
+ uint32_t dNameHash,
+ std::vector<CXFA_Node*>* pSiblings,
+ bool bIsClassName) {
if (!parent || !pSiblings)
return 0;
@@ -82,8 +81,7 @@
if (nCount > 0)
return nCount;
- nCount +=
- NodeAcc_TraverseAnySiblings(child, dNameHash, pSiblings, bIsClassName);
+ nCount += TraverseAnySiblings(child, dNameHash, pSiblings, bIsClassName);
}
for (CXFA_Node* child :
parent->GetNodeList(XFA_NODEFILTER_Children, XFA_Element::Unknown)) {
@@ -101,19 +99,17 @@
if (nCount > 0)
return nCount;
- nCount +=
- NodeAcc_TraverseAnySiblings(child, dNameHash, pSiblings, bIsClassName);
+ nCount += TraverseAnySiblings(child, dNameHash, pSiblings, bIsClassName);
}
return nCount;
}
-int32_t CXFA_NodeHelper::NodeAcc_TraverseSiblings(
- CXFA_Node* parent,
- uint32_t dNameHash,
- std::vector<CXFA_Node*>* pSiblings,
- XFA_LOGIC_TYPE eLogicType,
- bool bIsClassName,
- bool bIsFindProperty) {
+int32_t CXFA_NodeHelper::TraverseSiblings(CXFA_Node* parent,
+ uint32_t dNameHash,
+ std::vector<CXFA_Node*>* pSiblings,
+ XFA_LOGIC_TYPE eLogicType,
+ bool bIsClassName,
+ bool bIsFindProperty) {
if (!parent || !pSiblings)
return 0;
@@ -138,8 +134,8 @@
}
if (child->IsUnnamed() &&
child->GetElementType() == XFA_Element::PageSet) {
- nCount += NodeAcc_TraverseSiblings(child, dNameHash, pSiblings,
- eLogicType, bIsClassName, false);
+ nCount += TraverseSiblings(child, dNameHash, pSiblings, eLogicType,
+ bIsClassName, false);
}
}
if (nCount > 0)
@@ -166,15 +162,15 @@
if (NodeIsTransparent(child) &&
child->GetElementType() != XFA_Element::PageSet) {
- nCount += NodeAcc_TraverseSiblings(child, dNameHash, pSiblings,
- eLogicType, bIsClassName, false);
+ nCount += TraverseSiblings(child, dNameHash, pSiblings, eLogicType,
+ bIsClassName, false);
}
}
return nCount;
}
-CXFA_Node* CXFA_NodeHelper::ResolveNodes_GetParent(CXFA_Node* pNode,
- XFA_LOGIC_TYPE eLogicType) {
+CXFA_Node* CXFA_NodeHelper::GetParent(CXFA_Node* pNode,
+ XFA_LOGIC_TYPE eLogicType) {
if (!pNode) {
return nullptr;
}
@@ -184,7 +180,7 @@
CXFA_Node* parent;
CXFA_Node* node = pNode;
while (true) {
- parent = ResolveNodes_GetParent(node, XFA_LOGIC_NoTransparent);
+ parent = GetParent(node, XFA_LOGIC_NoTransparent);
if (!parent) {
break;
}
@@ -202,23 +198,22 @@
XFA_LOGIC_TYPE eLogicType,
bool bIsProperty,
bool bIsClassIndex) {
- CXFA_Node* parent = ResolveNodes_GetParent(pNode, XFA_LOGIC_NoTransparent);
- if (!parent) {
+ CXFA_Node* parent = GetParent(pNode, XFA_LOGIC_NoTransparent);
+ if (!parent)
return 0;
- }
+
if (!bIsProperty && eLogicType == XFA_LOGIC_Transparent) {
- parent = ResolveNodes_GetParent(pNode, XFA_LOGIC_Transparent);
- if (!parent) {
+ parent = GetParent(pNode, XFA_LOGIC_Transparent);
+ if (!parent)
return 0;
- }
}
uint32_t dwHashName = pNode->GetNameHash();
if (bIsClassIndex) {
dwHashName = pNode->GetClassHashCode();
}
std::vector<CXFA_Node*> siblings;
- int32_t iSize = NodeAcc_TraverseSiblings(parent, dwHashName, &siblings,
- eLogicType, bIsClassIndex, true);
+ int32_t iSize = TraverseSiblings(parent, dwHashName, &siblings, eLogicType,
+ bIsClassIndex, true);
for (int32_t i = 0; i < iSize; ++i) {
CXFA_Node* child = siblings[i];
if (child == pNode) {
@@ -233,14 +228,13 @@
WideString wsName;
if (bIsAllPath) {
wsName = GetNameExpression(refNode, false);
- CXFA_Node* parent =
- ResolveNodes_GetParent(refNode, XFA_LOGIC_NoTransparent);
+ CXFA_Node* parent = GetParent(refNode, XFA_LOGIC_NoTransparent);
while (parent) {
WideString wsParent = GetNameExpression(parent, false);
wsParent += L".";
wsParent += wsName;
wsName = std::move(wsParent);
- parent = ResolveNodes_GetParent(parent, XFA_LOGIC_NoTransparent);
+ parent = GetParent(parent, XFA_LOGIC_NoTransparent);
}
return wsName;
}
@@ -271,7 +265,7 @@
refNodeType == XFA_Element::Area || refNodeType == XFA_Element::Proto;
}
-bool CXFA_NodeHelper::CreateNode_ForCondition(WideString& wsCondition) {
+bool CXFA_NodeHelper::CreateNodeForCondition(const WideString& wsCondition) {
int32_t iLen = wsCondition.GetLength();
WideString wsIndex(L"0");
bool bAll = false;
@@ -304,10 +298,10 @@
return true;
}
-bool CXFA_NodeHelper::ResolveNodes_CreateNode(WideString wsName,
- WideString wsCondition,
- bool bLastNode,
- CFXJSE_Engine* pScriptContext) {
+bool CXFA_NodeHelper::CreateNode(WideString wsName,
+ WideString wsCondition,
+ bool bLastNode,
+ CFXJSE_Engine* pScriptContext) {
if (!m_pCreateParent) {
return false;
}
@@ -323,7 +317,7 @@
wsName = wsName.Right(wsName.GetLength() - 1);
}
if (m_iCreateCount == 0) {
- CreateNode_ForCondition(wsCondition);
+ CreateNodeForCondition(wsCondition);
}
if (bIsClassName) {
XFA_Element eType = XFA_GetElementByName(wsName);
@@ -381,6 +375,9 @@
}
bool CXFA_NodeHelper::NodeIsProperty(CXFA_Node* refNode) {
- CXFA_Node* parent = ResolveNodes_GetParent(refNode, XFA_LOGIC_NoTransparent);
- return parent && refNode && parent->HasProperty(refNode->GetElementType());
+ if (!refNode)
+ return false;
+
+ CXFA_Node* parent = GetParent(refNode, XFA_LOGIC_NoTransparent);
+ return parent && parent->HasProperty(refNode->GetElementType());
}
diff --git a/xfa/fxfa/parser/cxfa_nodehelper.h b/xfa/fxfa/parser/cxfa_nodehelper.h
index 3dcbe4c..5142e95 100644
--- a/xfa/fxfa/parser/cxfa_nodehelper.h
+++ b/xfa/fxfa/parser/cxfa_nodehelper.h
@@ -26,22 +26,20 @@
CXFA_NodeHelper();
~CXFA_NodeHelper();
- CXFA_Node* ResolveNodes_GetOneChild(CXFA_Node* parent,
- const wchar_t* pwsName,
- bool bIsClassName);
- CXFA_Node* ResolveNodes_GetParent(CXFA_Node* pNode,
- XFA_LOGIC_TYPE eLogicType);
-
- int32_t NodeAcc_TraverseSiblings(CXFA_Node* parent,
- uint32_t dNameHash,
- std::vector<CXFA_Node*>* pSiblings,
- XFA_LOGIC_TYPE eLogicType,
- bool bIsClassName,
- bool bIsFindProperty);
- int32_t NodeAcc_TraverseAnySiblings(CXFA_Node* parent,
- uint32_t dNameHash,
- std::vector<CXFA_Node*>* pSiblings,
- bool bIsClassName);
+ CXFA_Node* GetOneChild(CXFA_Node* parent,
+ const wchar_t* pwsName,
+ bool bIsClassName);
+ CXFA_Node* GetParent(CXFA_Node* pNode, XFA_LOGIC_TYPE eLogicType);
+ int32_t TraverseSiblings(CXFA_Node* parent,
+ uint32_t dNameHash,
+ std::vector<CXFA_Node*>* pSiblings,
+ XFA_LOGIC_TYPE eLogicType,
+ bool bIsClassName,
+ bool bIsFindProperty);
+ int32_t TraverseAnySiblings(CXFA_Node* parent,
+ uint32_t dNameHash,
+ std::vector<CXFA_Node*>* pSiblings,
+ bool bIsClassName);
int32_t CountSiblings(CXFA_Node* pNode,
XFA_LOGIC_TYPE eLogicType,
std::vector<CXFA_Node*>* pSiblings,
@@ -52,11 +50,11 @@
bool bIsClassIndex);
WideString GetNameExpression(CXFA_Node* refNode, bool bIsAllPath);
bool NodeIsTransparent(CXFA_Node* refNode);
- bool ResolveNodes_CreateNode(WideString wsName,
- WideString wsCondition,
- bool bLastNode,
- CFXJSE_Engine* pScriptContext);
- bool CreateNode_ForCondition(WideString& wsCondition);
+ bool CreateNode(WideString wsName,
+ WideString wsCondition,
+ bool bLastNode,
+ CFXJSE_Engine* pScriptContext);
+ bool CreateNodeForCondition(const WideString& wsCondition);
void SetCreateNodeType(CXFA_Node* refNode);
bool NodeIsProperty(CXFA_Node* refNode);