summaryrefslogtreecommitdiff
path: root/xfa/fxfa/parser/cxfa_node.cpp
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2018-01-10 16:40:56 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-01-10 16:40:56 +0000
commit93cfa060aa6324b2a79f25782e3c986750479ac5 (patch)
treeca2ef7a14861235877b084f9433502b5507b36bb /xfa/fxfa/parser/cxfa_node.cpp
parent18a6069f5ce332b2bab97bf3a6d8ea9528d69791 (diff)
downloadpdfium-93cfa060aa6324b2a79f25782e3c986750479ac5.tar.xz
Remove 2 param CXFA_Node::GetNodeItem
This CL removes the CXFA_Node::GetNodeItem(kind, object_type) method in favour of explicit methods. All of the callers passed in a XFA_ObjectType::ContainerNode. Change-Id: I713184d3fa188a122284f50ac2a6b0fd3d7aed26 Reviewed-on: https://pdfium-review.googlesource.com/22651 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'xfa/fxfa/parser/cxfa_node.cpp')
-rw-r--r--xfa/fxfa/parser/cxfa_node.cpp70
1 files changed, 33 insertions, 37 deletions
diff --git a/xfa/fxfa/parser/cxfa_node.cpp b/xfa/fxfa/parser/cxfa_node.cpp
index ad70e94256..6d77f74c4e 100644
--- a/xfa/fxfa/parser/cxfa_node.cpp
+++ b/xfa/fxfa/parser/cxfa_node.cpp
@@ -277,39 +277,38 @@ CXFA_Node* CXFA_Node::GetPrevSibling() const {
return nullptr;
}
-CXFA_Node* CXFA_Node::GetNodeItem(XFA_NODEITEM eItem,
- XFA_ObjectType eType) const {
- CXFA_Node* pNode = nullptr;
- switch (eItem) {
- case XFA_NODEITEM_NextSibling:
- pNode = m_pNext;
- while (pNode && pNode->GetObjectType() != eType)
- pNode = pNode->m_pNext;
- break;
- case XFA_NODEITEM_FirstChild:
- pNode = m_pChild;
- while (pNode && pNode->GetObjectType() != eType)
- pNode = pNode->m_pNext;
- break;
- case XFA_NODEITEM_Parent:
- pNode = m_pParent;
- while (pNode && pNode->GetObjectType() != eType)
- pNode = pNode->m_pParent;
- break;
- case XFA_NODEITEM_PrevSibling:
- if (m_pParent) {
- CXFA_Node* pSibling = m_pParent->m_pChild;
- while (pSibling && pSibling != this) {
- if (eType == pSibling->GetObjectType())
- pNode = pSibling;
-
- pSibling = pSibling->m_pNext;
- }
- }
- break;
- default:
- break;
+CXFA_Node* CXFA_Node::GetNextContainerSibling() const {
+ CXFA_Node* pNode = m_pNext;
+ while (pNode && pNode->GetObjectType() != XFA_ObjectType::ContainerNode)
+ pNode = pNode->m_pNext;
+ return pNode;
+}
+
+CXFA_Node* CXFA_Node::GetPrevContainerSibling() const {
+ if (!m_pParent || m_pParent->m_pChild == this)
+ return nullptr;
+
+ CXFA_Node* container = nullptr;
+ for (CXFA_Node* pNode = m_pParent->m_pChild; pNode; pNode = pNode->m_pNext) {
+ if (pNode->GetObjectType() == XFA_ObjectType::ContainerNode)
+ container = pNode;
+ if (pNode->m_pNext == this)
+ return container;
}
+ return nullptr;
+}
+
+CXFA_Node* CXFA_Node::GetFirstContainerChild() const {
+ CXFA_Node* pNode = m_pChild;
+ while (pNode && pNode->GetObjectType() != XFA_ObjectType::ContainerNode)
+ pNode = pNode->m_pNext;
+ return pNode;
+}
+
+CXFA_Node* CXFA_Node::GetContainerParent() const {
+ CXFA_Node* pNode = m_pParent;
+ while (pNode && pNode->GetObjectType() != XFA_ObjectType::ContainerNode)
+ pNode = pNode->m_pParent;
return pNode;
}
@@ -672,8 +671,7 @@ XFA_AttributeEnum CXFA_Node::GetIntact() {
if (*intact == XFA_AttributeEnum::None &&
eLayoutType == XFA_AttributeEnum::Row &&
m_pDocument->GetCurVersionMode() < XFA_VERSION_208) {
- CXFA_Node* pPreviewRow = GetNodeItem(XFA_NODEITEM_PrevSibling,
- XFA_ObjectType::ContainerNode);
+ CXFA_Node* pPreviewRow = GetPrevContainerSibling();
if (pPreviewRow &&
pPreviewRow->JSObject()->GetEnum(XFA_Attribute::Layout) ==
XFA_AttributeEnum::Row) {
@@ -1583,9 +1581,7 @@ CXFA_Para* CXFA_Node::GetPara() const {
}
bool CXFA_Node::IsOpenAccess() {
- for (auto* pNode = this; pNode;
- pNode = pNode->GetNodeItem(XFA_NODEITEM_Parent,
- XFA_ObjectType::ContainerNode)) {
+ for (auto* pNode = this; pNode; pNode = pNode->GetContainerParent()) {
XFA_AttributeEnum iAcc = pNode->JSObject()->GetEnum(XFA_Attribute::Access);
if (iAcc != XFA_AttributeEnum::Open)
return false;