summaryrefslogtreecommitdiff
path: root/xfa/fxfa
diff options
context:
space:
mode:
Diffstat (limited to 'xfa/fxfa')
-rw-r--r--xfa/fxfa/cxfa_ffdocview.cpp6
-rw-r--r--xfa/fxfa/cxfa_widgetacc.cpp6
-rw-r--r--xfa/fxfa/parser/cxfa_itemlayoutprocessor.cpp24
-rw-r--r--xfa/fxfa/parser/cxfa_layoutpagemgr.cpp31
-rw-r--r--xfa/fxfa/parser/cxfa_layoutprocessor.cpp3
-rw-r--r--xfa/fxfa/parser/cxfa_node.cpp70
-rw-r--r--xfa/fxfa/parser/cxfa_node.h12
-rw-r--r--xfa/fxfa/parser/cxfa_traversestrategy_xfacontainernode.h9
8 files changed, 61 insertions, 100 deletions
diff --git a/xfa/fxfa/cxfa_ffdocview.cpp b/xfa/fxfa/cxfa_ffdocview.cpp
index 681d4cd8f8..52b7f64cf7 100644
--- a/xfa/fxfa/cxfa_ffdocview.cpp
+++ b/xfa/fxfa/cxfa_ffdocview.cpp
@@ -467,10 +467,8 @@ int32_t CXFA_FFDocView::ExecEventActivityByDeepFirst(CXFA_Node* pFormNode,
int32_t iRet = XFA_EVENTERROR_NotExist;
if (bRecursive) {
- for (CXFA_Node* pNode = pFormNode->GetNodeItem(
- XFA_NODEITEM_FirstChild, XFA_ObjectType::ContainerNode);
- pNode; pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling,
- XFA_ObjectType::ContainerNode)) {
+ for (CXFA_Node* pNode = pFormNode->GetFirstContainerChild(); pNode;
+ pNode = pNode->GetNextContainerSibling()) {
elementType = pNode->GetElementType();
if (elementType != XFA_Element::Variables &&
elementType != XFA_Element::Draw) {
diff --git a/xfa/fxfa/cxfa_widgetacc.cpp b/xfa/fxfa/cxfa_widgetacc.cpp
index 2889707280..f1067249f7 100644
--- a/xfa/fxfa/cxfa_widgetacc.cpp
+++ b/xfa/fxfa/cxfa_widgetacc.cpp
@@ -383,8 +383,7 @@ void CXFA_WidgetAcc::ResetData() {
break;
}
case XFA_Element::ExclGroup: {
- CXFA_Node* pNextChild = m_pNode->GetNodeItem(
- XFA_NODEITEM_FirstChild, XFA_ObjectType::ContainerNode);
+ CXFA_Node* pNextChild = m_pNode->GetFirstContainerChild();
while (pNextChild) {
CXFA_Node* pChild = pNextChild;
CXFA_WidgetAcc* pAcc = pChild->GetWidgetAcc();
@@ -416,8 +415,7 @@ void CXFA_WidgetAcc::ResetData() {
}
pAcc->SetValue(XFA_VALUEPICTURE_Raw, itemText);
}
- pNextChild = pChild->GetNodeItem(XFA_NODEITEM_NextSibling,
- XFA_ObjectType::ContainerNode);
+ pNextChild = pChild->GetNextContainerSibling();
}
break;
}
diff --git a/xfa/fxfa/parser/cxfa_itemlayoutprocessor.cpp b/xfa/fxfa/parser/cxfa_itemlayoutprocessor.cpp
index 0b8daa8970..6275650370 100644
--- a/xfa/fxfa/parser/cxfa_itemlayoutprocessor.cpp
+++ b/xfa/fxfa/parser/cxfa_itemlayoutprocessor.cpp
@@ -521,12 +521,8 @@ bool ExistContainerKeep(CXFA_Node* pCurNode, bool bPreFind) {
if (!pCurNode || !XFA_ItemLayoutProcessor_IsTakingSpace(pCurNode))
return false;
- XFA_NODEITEM eItemType = XFA_NODEITEM_PrevSibling;
- if (!bPreFind)
- eItemType = XFA_NODEITEM_NextSibling;
-
- CXFA_Node* pPreContainer =
- pCurNode->GetNodeItem(eItemType, XFA_ObjectType::ContainerNode);
+ CXFA_Node* pPreContainer = bPreFind ? pCurNode->GetPrevContainerSibling()
+ : pCurNode->GetNextContainerSibling();
if (!pPreContainer)
return false;
@@ -1470,15 +1466,12 @@ void CXFA_ItemLayoutProcessor::GotoNextContainerNode(
CheckNextChildContainer : {
CXFA_Node* pNextChildContainer =
pChildContainer == XFA_LAYOUT_INVALIDNODE
- ? pEntireContainer->GetNodeItem(XFA_NODEITEM_FirstChild,
- XFA_ObjectType::ContainerNode)
- : pChildContainer->GetNodeItem(XFA_NODEITEM_NextSibling,
- XFA_ObjectType::ContainerNode);
+ ? pEntireContainer->GetFirstContainerChild()
+ : pChildContainer->GetNextContainerSibling();
while (pNextChildContainer &&
pNextChildContainer->IsLayoutGeneratedNode()) {
CXFA_Node* pSaveNode = pNextChildContainer;
- pNextChildContainer = pNextChildContainer->GetNodeItem(
- XFA_NODEITEM_NextSibling, XFA_ObjectType::ContainerNode);
+ pNextChildContainer = pNextChildContainer->GetNextContainerSibling();
if (pSaveNode->IsUnusedNode())
DeleteLayoutGeneratedNode(pSaveNode);
}
@@ -2171,11 +2164,8 @@ XFA_ItemLayoutProcessorResult CXFA_ItemLayoutProcessor::DoLayoutFlowedContainer(
bool bFocrTb = false;
if (pParentNode &&
GetLayout(pParentNode, &bFocrTb) == XFA_AttributeEnum::Row) {
- CXFA_Node* pChildContainer = m_pFormNode->GetNodeItem(
- XFA_NODEITEM_FirstChild, XFA_ObjectType::ContainerNode);
- if (pChildContainer &&
- pChildContainer->GetNodeItem(XFA_NODEITEM_NextSibling,
- XFA_ObjectType::ContainerNode)) {
+ CXFA_Node* pChildContainer = m_pFormNode->GetFirstContainerChild();
+ if (pChildContainer && pChildContainer->GetNextContainerSibling()) {
containerSize.height = 0;
bContainerHeightAutoSize = true;
}
diff --git a/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp b/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp
index c1947cf9cc..35a1bc8283 100644
--- a/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp
+++ b/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp
@@ -239,8 +239,7 @@ bool RunBreakTestScript(CXFA_Script* pTestScript) {
if (wsExpression.IsEmpty())
return true;
return pTestScript->GetDocument()->GetNotify()->RunScript(
- pTestScript, pTestScript->GetNodeItem(XFA_NODEITEM_Parent,
- XFA_ObjectType::ContainerNode));
+ pTestScript, pTestScript->GetContainerParent());
}
} // namespace
@@ -810,8 +809,7 @@ bool CXFA_LayoutPageMgr::ExecuteBreakBeforeOrAfter(
case XFA_Element::BreakAfter: {
WideString wsBreakLeader;
WideString wsBreakTrailer;
- CXFA_Node* pFormNode = pCurNode->GetNodeItem(
- XFA_NODEITEM_Parent, XFA_ObjectType::ContainerNode);
+ CXFA_Node* pFormNode = pCurNode->GetContainerParent();
CXFA_Node* pContainer = pFormNode->GetTemplateNode();
bool bStartNew =
pCurNode->JSObject()->GetInteger(XFA_Attribute::StartNew) != 0;
@@ -838,12 +836,9 @@ bool CXFA_LayoutPageMgr::ExecuteBreakBeforeOrAfter(
if (!m_ProposedContainerRecords.empty() &&
m_CurrentContainerRecordIter == m_ProposedContainerRecords.begin() &&
eType == XFA_Element::BreakBefore) {
- CXFA_Node* pParentNode = pFormNode->GetNodeItem(
- XFA_NODEITEM_Parent, XFA_ObjectType::ContainerNode);
+ CXFA_Node* pParentNode = pFormNode->GetContainerParent();
if (!pParentNode ||
- pFormNode !=
- pParentNode->GetNodeItem(XFA_NODEITEM_FirstChild,
- XFA_ObjectType::ContainerNode)) {
+ pFormNode != pParentNode->GetFirstContainerChild()) {
break;
}
pParentNode = pParentNode->GetParent();
@@ -884,15 +879,13 @@ bool CXFA_LayoutPageMgr::ProcessBreakBeforeOrAfter(
bool& bCreatePage) {
CXFA_Node* pLeaderTemplate = nullptr;
CXFA_Node* pTrailerTemplate = nullptr;
- CXFA_Node* pFormNode = pBreakNode->GetNodeItem(XFA_NODEITEM_Parent,
- XFA_ObjectType::ContainerNode);
+ CXFA_Node* pFormNode = pBreakNode->GetContainerParent();
if (XFA_ItemLayoutProcessor_IsTakingSpace(pFormNode)) {
bCreatePage = ExecuteBreakBeforeOrAfter(pBreakNode, bBefore,
pLeaderTemplate, pTrailerTemplate);
CXFA_Document* pDocument = pBreakNode->GetDocument();
CXFA_Node* pDataScope = nullptr;
- pFormNode = pFormNode->GetNodeItem(XFA_NODEITEM_Parent,
- XFA_ObjectType::ContainerNode);
+ pFormNode = pFormNode->GetContainerParent();
if (pLeaderTemplate) {
if (!pDataScope)
pDataScope = XFA_DataMerge_FindDataScope(pFormNode);
@@ -921,8 +914,7 @@ bool CXFA_LayoutPageMgr::ProcessBookendLeaderOrTrailer(
bool bLeader,
CXFA_Node*& pBookendAppendNode) {
CXFA_Node* pLeaderTemplate = nullptr;
- CXFA_Node* pFormNode = pBookendNode->GetNodeItem(
- XFA_NODEITEM_Parent, XFA_ObjectType::ContainerNode);
+ CXFA_Node* pFormNode = pBookendNode->GetContainerParent();
if (ResolveBookendLeaderOrTrailer(pBookendNode, bLeader, pLeaderTemplate)) {
CXFA_Document* pDocument = pBookendNode->GetDocument();
CXFA_Node* pDataScope = nullptr;
@@ -945,9 +937,7 @@ CXFA_Node* CXFA_LayoutPageMgr::BreakOverflow(CXFA_Node* pOverflowNode,
CXFA_Node*& pTrailerTemplate,
bool bCreatePage) {
CXFA_Node* pContainer =
- pOverflowNode
- ->GetNodeItem(XFA_NODEITEM_Parent, XFA_ObjectType::ContainerNode)
- ->GetTemplateNode();
+ pOverflowNode->GetContainerParent()->GetTemplateNode();
if (pOverflowNode->GetElementType() == XFA_Element::Break) {
WideString wsOverflowLeader =
pOverflowNode->JSObject()->GetCData(XFA_Attribute::OverflowLeader);
@@ -1078,10 +1068,7 @@ bool CXFA_LayoutPageMgr::ResolveBookendLeaderOrTrailer(
CXFA_Node* pBookendNode,
bool bLeader,
CXFA_Node*& pBookendAppendTemplate) {
- CXFA_Node* pContainer =
- pBookendNode
- ->GetNodeItem(XFA_NODEITEM_Parent, XFA_ObjectType::ContainerNode)
- ->GetTemplateNode();
+ CXFA_Node* pContainer = pBookendNode->GetContainerParent()->GetTemplateNode();
if (pBookendNode->GetElementType() == XFA_Element::Break) {
WideString leader = pBookendNode->JSObject()->GetCData(
bLeader ? XFA_Attribute::BookendLeader : XFA_Attribute::BookendTrailer);
diff --git a/xfa/fxfa/parser/cxfa_layoutprocessor.cpp b/xfa/fxfa/parser/cxfa_layoutprocessor.cpp
index 36caa0c0a6..b074de13eb 100644
--- a/xfa/fxfa/parser/cxfa_layoutprocessor.cpp
+++ b/xfa/fxfa/parser/cxfa_layoutprocessor.cpp
@@ -101,8 +101,7 @@ bool CXFA_LayoutProcessor::IncrementLayout() {
return DoLayout() == 100;
}
for (CXFA_Node* pNode : m_rgChangedContainers) {
- CXFA_Node* pParentNode =
- pNode->GetNodeItem(XFA_NODEITEM_Parent, XFA_ObjectType::ContainerNode);
+ CXFA_Node* pParentNode = pNode->GetContainerParent();
if (!pParentNode)
return false;
if (!CXFA_ItemLayoutProcessor::IncrementRelayoutNode(this, pNode,
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;
diff --git a/xfa/fxfa/parser/cxfa_node.h b/xfa/fxfa/parser/cxfa_node.h
index fe1c3e007f..c1074ffaad 100644
--- a/xfa/fxfa/parser/cxfa_node.h
+++ b/xfa/fxfa/parser/cxfa_node.h
@@ -55,13 +55,6 @@ enum XFA_NodeFlag {
XFA_NodeFlag_LayoutGeneratedNode = 1 << 8
};
-enum XFA_NODEITEM {
- XFA_NODEITEM_Parent,
- XFA_NODEITEM_FirstChild,
- XFA_NODEITEM_NextSibling,
- XFA_NODEITEM_PrevSibling,
-};
-
class CXFA_Node : public CXFA_Object {
public:
struct PropertyData {
@@ -188,7 +181,10 @@ class CXFA_Node : public CXFA_Object {
CXFA_Node* GetFirstChild() const { return m_pChild; }
CXFA_Node* GetParent() const { return m_pParent; }
- CXFA_Node* GetNodeItem(XFA_NODEITEM eItem, XFA_ObjectType eType) const;
+ CXFA_Node* GetNextContainerSibling() const;
+ CXFA_Node* GetPrevContainerSibling() const;
+ CXFA_Node* GetFirstContainerChild() const;
+ CXFA_Node* GetContainerParent() const;
std::vector<CXFA_Node*> GetNodeList(uint32_t dwTypeFilter,
XFA_Element eTypeFilter);
diff --git a/xfa/fxfa/parser/cxfa_traversestrategy_xfacontainernode.h b/xfa/fxfa/parser/cxfa_traversestrategy_xfacontainernode.h
index ce6463c700..3ca632a1d1 100644
--- a/xfa/fxfa/parser/cxfa_traversestrategy_xfacontainernode.h
+++ b/xfa/fxfa/parser/cxfa_traversestrategy_xfacontainernode.h
@@ -13,16 +13,13 @@
class CXFA_TraverseStrategy_XFAContainerNode {
public:
static CXFA_Node* GetFirstChild(CXFA_Node* pTemplateNode) {
- return pTemplateNode->GetNodeItem(XFA_NODEITEM_FirstChild,
- XFA_ObjectType::ContainerNode);
+ return pTemplateNode->GetFirstContainerChild();
}
static CXFA_Node* GetNextSibling(CXFA_Node* pTemplateNode) {
- return pTemplateNode->GetNodeItem(XFA_NODEITEM_NextSibling,
- XFA_ObjectType::ContainerNode);
+ return pTemplateNode->GetNextContainerSibling();
}
static CXFA_Node* GetParent(CXFA_Node* pTemplateNode) {
- return pTemplateNode->GetNodeItem(XFA_NODEITEM_Parent,
- XFA_ObjectType::ContainerNode);
+ return pTemplateNode->GetContainerParent();
}
};