Make members private in CXFA_LayoutItem, adding accessors.
Change-Id: I154e6fd543b6eabc8314430e93064bd60bfd8643
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/51530
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/fxjs/xfa/cjx_layoutpseudomodel.cpp b/fxjs/xfa/cjx_layoutpseudomodel.cpp
index f7a07e7..1bf9e6a 100644
--- a/fxjs/xfa/cjx_layoutpseudomodel.cpp
+++ b/fxjs/xfa/cjx_layoutpseudomodel.cpp
@@ -232,8 +232,8 @@
return retArray;
}
if (wsType.EqualsASCII("contentArea")) {
- for (CXFA_LayoutItem* pItem = pLayoutPage->m_pFirstChild; pItem;
- pItem = pItem->m_pNextSibling) {
+ for (CXFA_LayoutItem* pItem = pLayoutPage->GetFirstChild(); pItem;
+ pItem = pItem->GetNextSibling()) {
if (pItem->GetFormNode()->GetElementType() == XFA_Element::ContentArea)
retArray.push_back(pItem->GetFormNode());
}
@@ -244,12 +244,12 @@
if (pLayoutPage->GetFormNode())
retArray.push_back(pLayoutPage->GetFormNode());
- for (CXFA_LayoutItem* pItem = pLayoutPage->m_pFirstChild; pItem;
- pItem = pItem->m_pNextSibling) {
+ for (CXFA_LayoutItem* pItem = pLayoutPage->GetFirstChild(); pItem;
+ pItem = pItem->GetNextSibling()) {
if (pItem->GetFormNode()->GetElementType() == XFA_Element::ContentArea) {
retArray.push_back(pItem->GetFormNode());
if (!bOnPageArea) {
- CXFA_LayoutItemIterator iterator(pItem->m_pFirstChild);
+ CXFA_LayoutItemIterator iterator(pItem->GetFirstChild());
for (CXFA_LayoutItem* pChild = iterator.GetCurrent(); pChild;
pChild = iterator.MoveToNext()) {
CXFA_ContentLayoutItem* pItemChild = pChild->AsContentLayoutItem();
@@ -305,11 +305,11 @@
eType = XFA_Element::Area;
if (eType != XFA_Element::Unknown) {
- for (CXFA_LayoutItem* pItem = pLayoutPage->m_pFirstChild; pItem;
- pItem = pItem->m_pNextSibling) {
+ for (CXFA_LayoutItem* pItem = pLayoutPage->GetFirstChild(); pItem;
+ pItem = pItem->GetNextSibling()) {
if (pItem->GetFormNode()->GetElementType() == XFA_Element::ContentArea) {
if (!bOnPageArea) {
- CXFA_LayoutItemIterator iterator(pItem->m_pFirstChild);
+ CXFA_LayoutItemIterator iterator(pItem->GetFirstChild());
for (CXFA_LayoutItem* pChild = iterator.GetCurrent(); pChild;
pChild = iterator.MoveToNext()) {
CXFA_ContentLayoutItem* pItemChild = pChild->AsContentLayoutItem();
diff --git a/xfa/fxfa/layout/cxfa_containerlayoutitem.cpp b/xfa/fxfa/layout/cxfa_containerlayoutitem.cpp
index 6d5e313..8617dd0 100644
--- a/xfa/fxfa/layout/cxfa_containerlayoutitem.cpp
+++ b/xfa/fxfa/layout/cxfa_containerlayoutitem.cpp
@@ -19,11 +19,12 @@
CXFA_ContainerLayoutItem::~CXFA_ContainerLayoutItem() = default;
CXFA_LayoutProcessor* CXFA_ContainerLayoutItem::GetLayout() const {
- return m_pFormNode->GetDocument()->GetLayoutProcessor();
+ return GetFormNode()->GetDocument()->GetLayoutProcessor();
}
int32_t CXFA_ContainerLayoutItem::GetPageIndex() const {
- return m_pFormNode->GetDocument()
+ return GetFormNode()
+ ->GetDocument()
->GetLayoutProcessor()
->GetLayoutPageMgr()
->GetPageIndex(this);
@@ -32,7 +33,7 @@
CFX_SizeF CXFA_ContainerLayoutItem::GetPageSize() const {
CFX_SizeF size;
CXFA_Medium* pMedium =
- m_pFormNode->GetFirstChildByClass<CXFA_Medium>(XFA_Element::Medium);
+ GetFormNode()->GetFirstChildByClass<CXFA_Medium>(XFA_Element::Medium);
if (!pMedium)
return size;
@@ -47,5 +48,5 @@
}
CXFA_Node* CXFA_ContainerLayoutItem::GetMasterPage() const {
- return m_pFormNode.Get();
+ return GetFormNode();
}
diff --git a/xfa/fxfa/layout/cxfa_contentlayoutitem.cpp b/xfa/fxfa/layout/cxfa_contentlayoutitem.cpp
index bc97674..b88e1ae 100644
--- a/xfa/fxfa/layout/cxfa_contentlayoutitem.cpp
+++ b/xfa/fxfa/layout/cxfa_contentlayoutitem.cpp
@@ -15,8 +15,9 @@
CXFA_ContentLayoutItem::~CXFA_ContentLayoutItem() {
RemoveSelf();
- if (m_pFormNode->JSObject()->GetLayoutItem() == this)
- m_pFormNode->JSObject()->SetLayoutItem(nullptr);
+ CJX_Object* pJsObject = GetFormNode()->JSObject();
+ if (pJsObject->GetLayoutItem() == this)
+ pJsObject->SetLayoutItem(nullptr);
}
CXFA_FFWidget* CXFA_ContentLayoutItem::AsFFWidget() {
@@ -61,12 +62,12 @@
if (bRelative)
return CFX_RectF(sPos, sSize);
- for (CXFA_LayoutItem* pLayoutItem = m_pParent; pLayoutItem;
- pLayoutItem = pLayoutItem->m_pParent) {
+ for (CXFA_LayoutItem* pLayoutItem = GetParent(); pLayoutItem;
+ pLayoutItem = pLayoutItem->GetParent()) {
if (CXFA_ContentLayoutItem* pContent = pLayoutItem->AsContentLayoutItem()) {
sPos += pContent->m_sPos;
CXFA_Margin* pMarginNode =
- pContent->m_pFormNode->GetFirstChildByClass<CXFA_Margin>(
+ pContent->GetFormNode()->GetFirstChildByClass<CXFA_Margin>(
XFA_Element::Margin);
if (pMarginNode) {
sPos += CFX_PointF(pMarginNode->JSObject()->GetMeasureInUnit(
diff --git a/xfa/fxfa/layout/cxfa_itemlayoutprocessor.cpp b/xfa/fxfa/layout/cxfa_itemlayoutprocessor.cpp
index 12941c4..5a8c3af 100644
--- a/xfa/fxfa/layout/cxfa_itemlayoutprocessor.cpp
+++ b/xfa/fxfa/layout/cxfa_itemlayoutprocessor.cpp
@@ -208,8 +208,8 @@
int32_t nCurrentColIdx = 0;
bool bMetWholeRowCell = false;
- for (CXFA_LayoutItem* pIter = pLayoutRow->m_pFirstChild; pIter;
- pIter = pIter->m_pNextSibling) {
+ for (CXFA_LayoutItem* pIter = pLayoutRow->GetFirstChild(); pIter;
+ pIter = pIter->GetNextSibling()) {
CXFA_ContentLayoutItem* pLayoutChild = pIter->AsContentLayoutItem();
if (!pLayoutChild)
continue;
@@ -256,8 +256,8 @@
}
if (bContainerHeightAutoSize) {
- for (CXFA_LayoutItem* pIter = pLayoutRow->m_pFirstChild; pIter;
- pIter = pIter->m_pNextSibling) {
+ for (CXFA_LayoutItem* pIter = pLayoutRow->GetFirstChild(); pIter;
+ pIter = pIter->GetNextSibling()) {
CXFA_ContentLayoutItem* pLayoutChild = pIter->AsContentLayoutItem();
if (!pLayoutChild)
continue;
@@ -269,7 +269,7 @@
CXFA_Para* pParaNode =
pLayoutChild->GetFormNode()->GetFirstChildByClass<CXFA_Para>(
XFA_Element::Para);
- if (pParaNode && pLayoutChild->m_pFirstChild) {
+ if (pParaNode && pLayoutChild->GetFirstChild()) {
float fOffHeight = fContentCalculatedHeight - fOldChildHeight;
XFA_AttributeValue eVType =
pParaNode->JSObject()->GetEnum(XFA_Attribute::VAlign);
@@ -285,8 +285,8 @@
break;
}
if (fOffHeight > 0) {
- for (CXFA_LayoutItem* pInnerIter = pLayoutChild->m_pFirstChild;
- pInnerIter; pInnerIter = pInnerIter->m_pNextSibling) {
+ for (CXFA_LayoutItem* pInnerIter = pLayoutChild->GetFirstChild();
+ pInnerIter; pInnerIter = pInnerIter->GetNextSibling()) {
CXFA_ContentLayoutItem* pInnerChild =
pInnerIter->AsContentLayoutItem();
if (!pInnerChild)
@@ -313,8 +313,8 @@
if (pLayoutRow->GetFormNode()->JSObject()->GetEnum(XFA_Attribute::Layout) ==
XFA_AttributeValue::Rl_row) {
- for (CXFA_LayoutItem* pIter = pLayoutRow->m_pFirstChild; pIter;
- pIter = pIter->m_pNextSibling) {
+ for (CXFA_LayoutItem* pIter = pLayoutRow->GetFirstChild(); pIter;
+ pIter = pIter->GetNextSibling()) {
CXFA_ContentLayoutItem* pLayoutChild = pIter->AsContentLayoutItem();
if (!pLayoutChild)
continue;
@@ -505,8 +505,8 @@
}
}
float fRelSplitPos = *fProposedSplitPos - fCurBottomMargin;
- for (CXFA_LayoutItem* pIter = pLayoutItem->m_pFirstChild; pIter;
- pIter = pIter->m_pNextSibling) {
+ for (CXFA_LayoutItem* pIter = pLayoutItem->GetFirstChild(); pIter;
+ pIter = pIter->GetNextSibling()) {
CXFA_ContentLayoutItem* pChildItem = pIter->AsContentLayoutItem();
if (!pChildItem)
continue;
@@ -704,15 +704,15 @@
pSecondLayoutItem->m_sPos.y = 0;
pSecondLayoutItem->m_sSize.height = pLayoutItem->m_sSize.height - fSplitPos;
pLayoutItem->m_sSize.height -= pSecondLayoutItem->m_sSize.height;
- if (pLayoutItem->m_pFirstChild)
+ if (pLayoutItem->GetFirstChild())
pSecondLayoutItem->m_sSize.height += fCurTopMargin;
if (pSecondParent) {
pSecondParent->AddChild(pSecondLayoutItem);
- if (fCurTopMargin > 0 && pLayoutItem->m_pFirstChild) {
+ if (fCurTopMargin > 0 && pLayoutItem->GetFirstChild()) {
pSecondParent->m_sSize.height += fCurTopMargin;
- for (CXFA_LayoutItem* pParentIter = pSecondParent->m_pParent; pParentIter;
- pParentIter = pParentIter->m_pParent) {
+ for (CXFA_LayoutItem* pParentIter = pSecondParent->GetParent();
+ pParentIter; pParentIter = pParentIter->GetParent()) {
CXFA_ContentLayoutItem* pContentItem =
pParentIter->AsContentLayoutItem();
if (!pContentItem)
@@ -722,22 +722,22 @@
}
}
} else {
- pSecondLayoutItem->m_pParent = pLayoutItem->m_pParent;
- pSecondLayoutItem->m_pNextSibling = pLayoutItem->m_pNextSibling;
- pLayoutItem->m_pNextSibling = pSecondLayoutItem;
+ pSecondLayoutItem->SetParent(pLayoutItem->GetParent());
+ pSecondLayoutItem->SetNextSibling(pLayoutItem->GetNextSibling());
+ pLayoutItem->SetNextSibling(pSecondLayoutItem);
}
CXFA_ContentLayoutItem* pChildren =
- ToContentLayoutItem(pLayoutItem->m_pFirstChild);
- pLayoutItem->m_pFirstChild = nullptr;
+ ToContentLayoutItem(pLayoutItem->GetFirstChild());
+ pLayoutItem->SetFirstChild(nullptr);
float lHeightForKeep = 0;
float fAddMarginHeight = 0;
std::vector<CXFA_ContentLayoutItem*> keepLayoutItems;
for (CXFA_ContentLayoutItem *pChildItem = pChildren, *pChildNext = nullptr;
pChildItem; pChildItem = pChildNext) {
- pChildNext = ToContentLayoutItem(pChildItem->m_pNextSibling);
- pChildItem->m_pNextSibling = nullptr;
+ pChildNext = ToContentLayoutItem(pChildItem->GetNextSibling());
+ pChildItem->SetNextSibling(nullptr);
if (fSplitPos <= fCurTopMargin + pChildItem->m_sPos.y + fCurBottomMargin +
kXFALayoutPrecision) {
if (!ExistContainerKeep(pChildItem->GetFormNode(), true)) {
@@ -797,8 +797,8 @@
CXFA_ContentLayoutItem* CXFA_ItemLayoutProcessor::ExtractLayoutItem() {
CXFA_ContentLayoutItem* pLayoutItem = m_pLayoutItem;
if (pLayoutItem) {
- m_pLayoutItem = ToContentLayoutItem(pLayoutItem->m_pNextSibling);
- pLayoutItem->m_pNextSibling = nullptr;
+ m_pLayoutItem = ToContentLayoutItem(pLayoutItem->GetNextSibling());
+ pLayoutItem->SetNextSibling(nullptr);
}
if (m_nCurChildNodeStage != Stage::kDone || !m_pOldLayoutItem)
@@ -815,8 +815,8 @@
if (pToDeleteItem == pLayoutItem)
break;
pNotify->OnLayoutItemRemoving(pDocLayout, pToDeleteItem);
- if (pToDeleteItem->m_pParent)
- pToDeleteItem->m_pParent->RemoveChild(pToDeleteItem);
+ if (pToDeleteItem->GetParent())
+ pToDeleteItem->GetParent()->RemoveChild(pToDeleteItem);
delete pToDeleteItem;
}
return pLayoutItem;
@@ -998,17 +998,17 @@
}
pBeforeItem = nullptr;
- CXFA_LayoutItem* pLayoutItem = pPageAreaLayoutItem->m_pFirstChild;
+ CXFA_LayoutItem* pLayoutItem = pPageAreaLayoutItem->GetFirstChild();
while (pLayoutItem) {
if (!pLayoutItem->IsContentLayoutItem() ||
pLayoutItem->GetFormNode()->GetElementType() != XFA_Element::Draw) {
- pLayoutItem = pLayoutItem->m_pNextSibling;
+ pLayoutItem = pLayoutItem->GetNextSibling();
continue;
}
if (pLayoutItem->GetFormNode()->GetElementType() != XFA_Element::Draw)
continue;
- CXFA_LayoutItem* pNextLayoutItem = pLayoutItem->m_pNextSibling;
+ CXFA_LayoutItem* pNextLayoutItem = pLayoutItem->GetNextSibling();
pPageAreaLayoutItem->RemoveChild(pLayoutItem);
if (!pBeforeItem)
pPageAreaLayoutItem->AddHeadChild(pLayoutItem);
@@ -1199,8 +1199,8 @@
std::vector<CXFA_ContentLayoutItem*> rgRowItems;
std::vector<int32_t> rgRowItemsSpan;
std::vector<float> rgRowItemsWidth;
- for (CXFA_LayoutItem* pIter = m_pLayoutItem->m_pFirstChild; pIter;
- pIter = pIter->m_pNextSibling) {
+ for (CXFA_LayoutItem* pIter = m_pLayoutItem->GetFirstChild(); pIter;
+ pIter = pIter->GetNextSibling()) {
CXFA_ContentLayoutItem* pLayoutChild = pIter->AsContentLayoutItem();
if (!pLayoutChild)
continue;
@@ -1217,7 +1217,7 @@
continue;
}
CXFA_ContentLayoutItem* pRowLayoutCell =
- ToContentLayoutItem(pLayoutChild->m_pFirstChild);
+ ToContentLayoutItem(pLayoutChild->GetFirstChild());
if (pRowLayoutCell) {
rgRowItems.push_back(pRowLayoutCell);
int32_t iColSpan =
@@ -1239,7 +1239,7 @@
(rgRowItemsSpan[i] <= 0 ||
!rgRowItems[i]->GetFormNode()->PresenceRequiresSpace())) {
CXFA_ContentLayoutItem* pNewCell =
- ToContentLayoutItem(rgRowItems[i]->m_pNextSibling);
+ ToContentLayoutItem(rgRowItems[i]->GetNextSibling());
if (rgRowItemsSpan[i] < 0 &&
rgRowItems[i]->GetFormNode()->PresenceRequiresSpace()) {
pNewCell = nullptr;
@@ -1292,8 +1292,8 @@
}
float fCurrentRowY = 0;
- for (CXFA_LayoutItem* pIter = m_pLayoutItem->m_pFirstChild; pIter;
- pIter = pIter->m_pNextSibling) {
+ for (CXFA_LayoutItem* pIter = m_pLayoutItem->GetFirstChild(); pIter;
+ pIter = pIter->GetNextSibling()) {
CXFA_ContentLayoutItem* pLayoutChild = pIter->AsContentLayoutItem();
if (!pLayoutChild)
continue;
@@ -1437,8 +1437,8 @@
return false;
float fItemsHeight = 0;
- for (CXFA_LayoutItem* pIter = pParentLayoutItem->m_pFirstChild; pIter;
- pIter = pIter->m_pNextSibling) {
+ for (CXFA_LayoutItem* pIter = pParentLayoutItem->GetFirstChild(); pIter;
+ pIter = pIter->GetNextSibling()) {
CXFA_ContentLayoutItem* pChildLayoutItem = pIter->AsContentLayoutItem();
if (!pChildLayoutItem)
continue;
@@ -1565,9 +1565,9 @@
if (m_pLayoutItem) {
if (m_nCurChildNodeStage != Stage::kDone &&
eFlowStrategy != XFA_AttributeValue::Tb) {
- pLayoutChild = ToContentLayoutItem(m_pLayoutItem->m_pFirstChild);
+ pLayoutChild = ToContentLayoutItem(m_pLayoutItem->GetFirstChild());
for (CXFA_LayoutItem* pLayoutNext = pLayoutChild; pLayoutNext;
- pLayoutNext = pLayoutNext->m_pNextSibling) {
+ pLayoutNext = pLayoutNext->GetNextSibling()) {
CXFA_ContentLayoutItem* pContentNext =
pLayoutNext->AsContentLayoutItem();
if (!pContentNext)
@@ -1578,8 +1578,9 @@
}
}
- for (CXFA_LayoutItem* pTempChild = m_pLayoutItem->m_pFirstChild;
- pTempChild != pLayoutChild; pTempChild = pTempChild->m_pNextSibling) {
+ for (CXFA_LayoutItem* pTempChild = m_pLayoutItem->GetFirstChild();
+ pTempChild != pLayoutChild;
+ pTempChild = pTempChild->GetNextSibling()) {
CXFA_ContentLayoutItem* pLayoutTempChild =
pTempChild->AsContentLayoutItem();
if (!pLayoutTempChild)
@@ -1623,11 +1624,11 @@
(eFlowStrategy != XFA_AttributeValue::Rl_tb ? 0 : 2);
if (pLayoutChild) {
for (CXFA_LayoutItem* pNext = pLayoutChild; pNext;
- pNext = pNext->m_pNextSibling) {
+ pNext = pNext->GetNextSibling()) {
CXFA_ContentLayoutItem* pLayoutNext = pNext->AsContentLayoutItem();
if (!pLayoutNext)
continue;
- if (!pLayoutNext->m_pNextSibling && m_pCurChildPreprocessor &&
+ if (!pLayoutNext->GetNextSibling() && m_pCurChildPreprocessor &&
m_pCurChildPreprocessor->GetFormNode() ==
pLayoutNext->GetFormNode()) {
if (m_pCurChildPreprocessor->m_pLayoutItem)
@@ -1652,14 +1653,14 @@
}
}
- if (ToContentLayoutItem(m_pLayoutItem->m_pFirstChild) == pLayoutChild) {
- m_pLayoutItem->m_pFirstChild = nullptr;
+ if (ToContentLayoutItem(m_pLayoutItem->GetFirstChild()) == pLayoutChild) {
+ m_pLayoutItem->SetFirstChild(nullptr);
} else {
- for (CXFA_LayoutItem* pLayoutNext = m_pLayoutItem->m_pFirstChild;
- pLayoutNext; pLayoutNext = pLayoutNext->m_pNextSibling) {
- if (ToContentLayoutItem(pLayoutNext->m_pNextSibling) ==
+ for (CXFA_LayoutItem* pLayoutNext = m_pLayoutItem->GetFirstChild();
+ pLayoutNext; pLayoutNext = pLayoutNext->GetNextSibling()) {
+ if (ToContentLayoutItem(pLayoutNext->GetNextSibling()) ==
pLayoutChild) {
- pLayoutNext->m_pNextSibling = nullptr;
+ pLayoutNext->SetNextSibling(nullptr);
break;
}
}
@@ -1668,10 +1669,10 @@
CXFA_ContentLayoutItem* pLayoutNextTemp =
ToContentLayoutItem(pLayoutChild);
while (pLayoutNextTemp) {
- pLayoutNextTemp->m_pParent = nullptr;
+ pLayoutNextTemp->SetParent(nullptr);
CXFA_ContentLayoutItem* pSaveLayoutNext =
- ToContentLayoutItem(pLayoutNextTemp->m_pNextSibling);
- pLayoutNextTemp->m_pNextSibling = nullptr;
+ ToContentLayoutItem(pLayoutNextTemp->GetNextSibling());
+ pLayoutNextTemp->SetNextSibling(nullptr);
pLayoutNextTemp = pSaveLayoutNext;
}
pLayoutChild = nullptr;
@@ -2293,8 +2294,8 @@
}
float fHeight = pLeaderLayoutItem->m_sSize.height;
- for (CXFA_LayoutItem* pIter = m_pLayoutItem->m_pFirstChild; pIter;
- pIter = pIter->m_pNextSibling) {
+ for (CXFA_LayoutItem* pIter = m_pLayoutItem->GetFirstChild(); pIter;
+ pIter = pIter->GetNextSibling()) {
CXFA_ContentLayoutItem* pContentItem = pIter->AsContentLayoutItem();
if (!pContentItem)
continue;
@@ -2596,8 +2597,8 @@
pFormNode);
m_bUseInheriated = true;
} else {
- CXFA_LayoutItem* firstChild = pProcessor->m_pLayoutItem->m_pFirstChild;
- if (firstChild && !firstChild->m_pNextSibling &&
+ CXFA_LayoutItem* firstChild = pProcessor->m_pLayoutItem->GetFirstChild();
+ if (firstChild && !firstChild->GetNextSibling() &&
firstChild->GetFormNode()->IsLayoutGeneratedNode()) {
pProcessor->ProcessUnUseOverFlow(pOverflowLeaderNode,
pOverflowTrailerNode,
@@ -2608,7 +2609,7 @@
}
}
- if (pProcessor->m_pLayoutItem->m_pNextSibling) {
+ if (pProcessor->m_pLayoutItem->GetNextSibling()) {
childSize = pProcessor->GetCurrentComponentSize();
rgCurLineLayoutItems[uHAlign].push_back(pProcessor->ExtractLayoutItem());
*bAddedItemInRow = true;
diff --git a/xfa/fxfa/layout/cxfa_layoutitem.cpp b/xfa/fxfa/layout/cxfa_layoutitem.cpp
index 484655a..927d83b 100644
--- a/xfa/fxfa/layout/cxfa_layoutitem.cpp
+++ b/xfa/fxfa/layout/cxfa_layoutitem.cpp
@@ -15,13 +15,13 @@
#include "xfa/fxfa/parser/cxfa_node.h"
void XFA_ReleaseLayoutItem(CXFA_LayoutItem* pLayoutItem) {
- CXFA_LayoutItem* pNode = pLayoutItem->m_pFirstChild;
+ CXFA_LayoutItem* pNode = pLayoutItem->GetFirstChild();
CXFA_Document* pDocument = pLayoutItem->GetFormNode()->GetDocument();
CXFA_FFNotify* pNotify = pDocument->GetNotify();
CXFA_LayoutProcessor* pDocLayout = pDocument->GetLayoutProcessor();
while (pNode) {
- CXFA_LayoutItem* pNext = pNode->m_pNextSibling;
- pNode->m_pParent = nullptr;
+ CXFA_LayoutItem* pNext = pNode->GetNextSibling();
+ pNode->SetParent(nullptr);
pNotify->OnLayoutItemRemoving(pDocLayout, pNode);
XFA_ReleaseLayoutItem(pNode);
pNode = pNext;
diff --git a/xfa/fxfa/layout/cxfa_layoutitem.h b/xfa/fxfa/layout/cxfa_layoutitem.h
index 840859b..9d00526 100644
--- a/xfa/fxfa/layout/cxfa_layoutitem.h
+++ b/xfa/fxfa/layout/cxfa_layoutitem.h
@@ -25,23 +25,30 @@
CXFA_ContainerLayoutItem* GetPage() const;
CXFA_LayoutItem* GetParent() const { return m_pParent; }
+ CXFA_LayoutItem* GetFirstChild() const { return m_pFirstChild; }
+ CXFA_LayoutItem* GetNextSibling() const { return m_pNextSibling; }
CXFA_Node* GetFormNode() const { return m_pFormNode.Get(); }
void SetFormNode(CXFA_Node* pNode) { m_pFormNode = pNode; }
+ // TODO(tsepez) replace these calls with AddChild() etc.
+ void SetParent(CXFA_LayoutItem* pParent) { m_pParent = pParent; }
+ void SetFirstChild(CXFA_LayoutItem* pChild) { m_pFirstChild = pChild; }
+ void SetNextSibling(CXFA_LayoutItem* pSibling) { m_pNextSibling = pSibling; }
+
void AddChild(CXFA_LayoutItem* pChildItem);
void AddHeadChild(CXFA_LayoutItem* pChildItem);
void RemoveChild(CXFA_LayoutItem* pChildItem);
void InsertChild(CXFA_LayoutItem* pBeforeItem, CXFA_LayoutItem* pChildItem);
- CXFA_LayoutItem* m_pParent = nullptr; // Raw, intra-tree pointer.
- CXFA_LayoutItem* m_pNextSibling = nullptr; // Raw, intra-tree pointer.
- CXFA_LayoutItem* m_pFirstChild = nullptr; // Raw, intra-tree pointer.
-
protected:
enum ItemType { kContainerItem, kContentItem };
CXFA_LayoutItem(CXFA_Node* pNode, ItemType type);
+ private:
const ItemType m_ItemType;
+ CXFA_LayoutItem* m_pParent = nullptr; // Raw, intra-tree pointer.
+ CXFA_LayoutItem* m_pFirstChild = nullptr; // Raw, intra-tree pointer.
+ CXFA_LayoutItem* m_pNextSibling = nullptr; // Raw, intra-tree pointer.
UnownedPtr<CXFA_Node> m_pFormNode;
};
diff --git a/xfa/fxfa/layout/cxfa_layoutpagemgr.cpp b/xfa/fxfa/layout/cxfa_layoutpagemgr.cpp
index 616e319..7f8138c 100644
--- a/xfa/fxfa/layout/cxfa_layoutpagemgr.cpp
+++ b/xfa/fxfa/layout/cxfa_layoutpagemgr.cpp
@@ -41,8 +41,8 @@
if (pLayoutItem->GetFormNode()->GetElementType() != XFA_Element::PageSet)
return nullptr;
- for (CXFA_LayoutItem* pChildItem = pLayoutItem->m_pFirstChild; pChildItem;
- pChildItem = pChildItem->m_pNextSibling) {
+ for (CXFA_LayoutItem* pChildItem = pLayoutItem->GetFirstChild(); pChildItem;
+ pChildItem = pChildItem->GetNextSibling()) {
CXFA_ContainerLayoutItem* pContainer =
pChildItem->AsContainerLayoutItem();
if (pContainer &&
@@ -55,8 +55,8 @@
static CXFA_ContainerLayoutItem* GetNextSibling(
CXFA_ContainerLayoutItem* pLayoutItem) {
- for (CXFA_LayoutItem* pChildItem = pLayoutItem->m_pNextSibling; pChildItem;
- pChildItem = pChildItem->m_pNextSibling) {
+ for (CXFA_LayoutItem* pChildItem = pLayoutItem->GetNextSibling();
+ pChildItem; pChildItem = pChildItem->GetNextSibling()) {
CXFA_ContainerLayoutItem* pContainer =
pChildItem->AsContainerLayoutItem();
if (pContainer &&
@@ -69,7 +69,7 @@
static CXFA_ContainerLayoutItem* GetParent(
CXFA_ContainerLayoutItem* pLayoutItem) {
- return ToContainerLayoutItem(pLayoutItem->m_pParent);
+ return ToContainerLayoutItem(pLayoutItem->GetParent());
}
};
@@ -121,8 +121,8 @@
(bVisibleItem ? XFA_WidgetStatus_Visible : 0) | dwRelevantContainer;
}
pNotify->OnLayoutItemAdded(pDocLayout, pContainerItem, nPageIndex, dwStatus);
- for (CXFA_LayoutItem* pChild = pContainerItem->m_pFirstChild; pChild;
- pChild = pChild->m_pNextSibling) {
+ for (CXFA_LayoutItem* pChild = pContainerItem->GetFirstChild(); pChild;
+ pChild = pChild->GetNextSibling()) {
if (pChild->IsContentLayoutItem()) {
SyncContainer(pNotify, pDocLayout, pChild, dwRelevantContainer,
bVisibleItem, nPageIndex);
@@ -132,7 +132,7 @@
void ReorderLayoutItemToTail(CXFA_ContainerLayoutItem* pLayoutItem) {
CXFA_ContainerLayoutItem* pParentLayoutItem =
- ToContainerLayoutItem(pLayoutItem->m_pParent);
+ ToContainerLayoutItem(pLayoutItem->GetParent());
if (!pParentLayoutItem)
return;
@@ -142,7 +142,7 @@
void RemoveLayoutItem(CXFA_ContainerLayoutItem* pLayoutItem) {
CXFA_ContainerLayoutItem* pParentLayoutItem =
- ToContainerLayoutItem(pLayoutItem->m_pParent);
+ ToContainerLayoutItem(pLayoutItem->GetParent());
if (!pParentLayoutItem)
return;
@@ -213,11 +213,11 @@
CXFA_ContainerLayoutItem* pPageAreaLayoutItem,
CXFA_Node* pContentArea,
CXFA_ContainerLayoutItem*& pContentAreaLayoutItem) {
- for (CXFA_LayoutItem* pChild = pPageAreaLayoutItem->m_pFirstChild; pChild;
- pChild = pChild->m_pNextSibling) {
+ for (CXFA_LayoutItem* pChild = pPageAreaLayoutItem->GetFirstChild(); pChild;
+ pChild = pChild->GetNextSibling()) {
CXFA_ContainerLayoutItem* pLayoutItem = pChild->AsContainerLayoutItem();
if (pLayoutItem && pLayoutItem->GetFormNode() == pContentArea) {
- if (!pLayoutItem->m_pFirstChild) {
+ if (!pLayoutItem->GetFirstChild()) {
pContentAreaLayoutItem = pLayoutItem;
return true;
}
@@ -231,10 +231,10 @@
CXFA_FFNotify* pNotify,
CXFA_LayoutProcessor* pDocLayout) {
CXFA_LayoutItem* pNextLayoutItem;
- CXFA_LayoutItem* pCurLayoutItem = pParentLayoutItem->m_pFirstChild;
+ CXFA_LayoutItem* pCurLayoutItem = pParentLayoutItem->GetFirstChild();
while (pCurLayoutItem) {
- pNextLayoutItem = pCurLayoutItem->m_pNextSibling;
- if (pCurLayoutItem->m_pFirstChild)
+ pNextLayoutItem = pCurLayoutItem->GetNextSibling();
+ if (pCurLayoutItem->GetFirstChild())
SyncRemoveLayoutItem(pCurLayoutItem, pNotify, pDocLayout);
pNotify->OnLayoutItemRemoving(pDocLayout, pCurLayoutItem);
@@ -284,7 +284,7 @@
CXFA_LayoutItem* pLayoutItem = GetRootLayoutItem();
CXFA_LayoutItem* pNextLayout = nullptr;
for (; pLayoutItem; pLayoutItem = pNextLayout) {
- pNextLayout = pLayoutItem->m_pNextSibling;
+ pNextLayout = pLayoutItem->GetNextSibling();
XFA_ReleaseLayoutItem(pLayoutItem);
}
}
@@ -301,9 +301,9 @@
ASSERT(m_pTemplatePageSetRoot);
if (m_pPageSetLayoutItemRoot) {
- m_pPageSetLayoutItemRoot->m_pParent = nullptr;
- m_pPageSetLayoutItemRoot->m_pFirstChild = nullptr;
- m_pPageSetLayoutItemRoot->m_pNextSibling = nullptr;
+ m_pPageSetLayoutItemRoot->SetParent(nullptr);
+ m_pPageSetLayoutItemRoot->SetFirstChild(nullptr);
+ m_pPageSetLayoutItemRoot->SetNextSibling(nullptr);
m_pPageSetLayoutItemRoot->SetFormNode(m_pTemplatePageSetRoot);
} else {
m_pPageSetLayoutItemRoot =
@@ -530,7 +530,7 @@
CXFA_ContainerLayoutItem* pParentPageSetLayout = nullptr;
if (pPageSet == GetCurrentContainerRecord()->pCurPageSet->GetFormNode()) {
pParentPageSetLayout = ToContainerLayoutItem(
- GetCurrentContainerRecord()->pCurPageSet->m_pParent);
+ GetCurrentContainerRecord()->pCurPageSet->GetParent());
} else {
pParentPageSetLayout = ToContainerLayoutItem(
pPageSet->GetParent()->JSObject()->GetLayoutItem());
@@ -539,10 +539,10 @@
pPageSet->JSObject()->SetLayoutItem(pPageSetLayoutItem);
if (!pParentPageSetLayout) {
CXFA_ContainerLayoutItem* pPrePageSet = m_pPageSetLayoutItemRoot;
- while (pPrePageSet->m_pNextSibling) {
- pPrePageSet = pPrePageSet->m_pNextSibling->AsContainerLayoutItem();
+ while (pPrePageSet->GetNextSibling()) {
+ pPrePageSet = pPrePageSet->GetNextSibling()->AsContainerLayoutItem();
}
- pPrePageSet->m_pNextSibling = pPageSetLayoutItem;
+ pPrePageSet->SetNextSibling(pPageSetLayoutItem);
m_pPageSetCurRoot = pPageSetLayoutItem;
} else {
pParentPageSetLayout->AddChild(pPageSetLayoutItem);
@@ -609,7 +609,7 @@
for (CXFA_ContainerLayoutItem* pRootPageSetLayoutItem =
m_pPageSetLayoutItemRoot;
pRootPageSetLayoutItem; pRootPageSetLayoutItem = ToContainerLayoutItem(
- pRootPageSetLayoutItem->m_pNextSibling)) {
+ pRootPageSetLayoutItem->GetNextSibling())) {
PageSetIterator sIterator(pRootPageSetLayoutItem);
for (CXFA_ContainerLayoutItem* pPageSetLayoutItem = sIterator.GetCurrent();
pPageSetLayoutItem; pPageSetLayoutItem = sIterator.MoveToNext()) {
@@ -626,9 +626,9 @@
CXFA_LayoutItem* pLastPageAreaLayoutItem = nullptr;
int32_t nPageAreaCount = 0;
for (CXFA_LayoutItem* pPageAreaLayoutItem =
- pPageSetLayoutItem->m_pFirstChild;
+ pPageSetLayoutItem->GetFirstChild();
pPageAreaLayoutItem;
- pPageAreaLayoutItem = pPageAreaLayoutItem->m_pNextSibling) {
+ pPageAreaLayoutItem = pPageAreaLayoutItem->GetNextSibling()) {
if (pPageAreaLayoutItem->GetFormNode()->GetElementType() !=
XFA_Element::PageArea) {
continue;
@@ -671,19 +671,19 @@
bool bUsable = true;
std::vector<float> rgUsedHeights;
for (CXFA_LayoutItem* pChildLayoutItem =
- pLastPageAreaLayoutItem->m_pFirstChild;
+ pLastPageAreaLayoutItem->GetFirstChild();
pChildLayoutItem;
- pChildLayoutItem = pChildLayoutItem->m_pNextSibling) {
+ pChildLayoutItem = pChildLayoutItem->GetNextSibling()) {
if (pChildLayoutItem->GetFormNode()->GetElementType() !=
XFA_Element::ContentArea) {
continue;
}
float fUsedHeight = 0;
for (CXFA_LayoutItem* pContentChildLayoutItem =
- pChildLayoutItem->m_pFirstChild;
+ pChildLayoutItem->GetFirstChild();
pContentChildLayoutItem;
pContentChildLayoutItem =
- pContentChildLayoutItem->m_pNextSibling) {
+ pContentChildLayoutItem->GetNextSibling()) {
if (CXFA_ContentLayoutItem* pContent =
pContentChildLayoutItem->AsContentLayoutItem()) {
fUsedHeight += pContent->m_sSize.height;
@@ -711,13 +711,13 @@
}
if (bUsable) {
CXFA_LayoutItem* pChildLayoutItem =
- pLastPageAreaLayoutItem->m_pFirstChild;
+ pLastPageAreaLayoutItem->GetFirstChild();
CXFA_Node* pContentAreaNode = pNode->GetFirstChild();
pLastPageAreaLayoutItem->SetFormNode(pNode);
while (pChildLayoutItem && pContentAreaNode) {
if (pChildLayoutItem->GetFormNode()->GetElementType() !=
XFA_Element::ContentArea) {
- pChildLayoutItem = pChildLayoutItem->m_pNextSibling;
+ pChildLayoutItem = pChildLayoutItem->GetNextSibling();
continue;
}
if (pContentAreaNode->GetElementType() !=
@@ -726,7 +726,7 @@
continue;
}
pChildLayoutItem->SetFormNode(pContentAreaNode);
- pChildLayoutItem = pChildLayoutItem->m_pNextSibling;
+ pChildLayoutItem = pChildLayoutItem->GetNextSibling();
pContentAreaNode = pContentAreaNode->GetNextSibling();
}
} else if (pNode->JSObject()->GetEnum(XFA_Attribute::PagePosition) ==
@@ -1633,16 +1633,16 @@
void CXFA_LayoutPageMgr::SaveLayoutItem(CXFA_LayoutItem* pParentLayoutItem) {
CXFA_LayoutItem* pNextLayoutItem;
- CXFA_LayoutItem* pCurLayoutItem = pParentLayoutItem->m_pFirstChild;
+ CXFA_LayoutItem* pCurLayoutItem = pParentLayoutItem->GetFirstChild();
while (pCurLayoutItem) {
- pNextLayoutItem = pCurLayoutItem->m_pNextSibling;
+ pNextLayoutItem = pCurLayoutItem->GetNextSibling();
if (pCurLayoutItem->IsContentLayoutItem()) {
if (pCurLayoutItem->GetFormNode()->HasRemovedChildren()) {
CXFA_FFNotify* pNotify =
m_pTemplatePageSetRoot->GetDocument()->GetNotify();
CXFA_LayoutProcessor* pDocLayout =
m_pTemplatePageSetRoot->GetDocument()->GetLayoutProcessor();
- if (pCurLayoutItem->m_pFirstChild)
+ if (pCurLayoutItem->GetFirstChild())
SyncRemoveLayoutItem(pCurLayoutItem, pNotify, pDocLayout);
pNotify->OnLayoutItemRemoving(pDocLayout, pCurLayoutItem);
@@ -1661,12 +1661,12 @@
}
}
- if (pCurLayoutItem->m_pFirstChild)
+ if (pCurLayoutItem->GetFirstChild())
SaveLayoutItem(pCurLayoutItem);
- pCurLayoutItem->m_pParent = nullptr;
- pCurLayoutItem->m_pNextSibling = nullptr;
- pCurLayoutItem->m_pFirstChild = nullptr;
+ pCurLayoutItem->SetParent(nullptr);
+ pCurLayoutItem->SetNextSibling(nullptr);
+ pCurLayoutItem->SetFirstChild(nullptr);
if (!pCurLayoutItem->IsContentLayoutItem() &&
pCurLayoutItem->GetFormNode()->GetElementType() !=
XFA_Element::PageArea) {
@@ -1722,7 +1722,7 @@
int32_t iIndex = 0;
for (; pRootLayout;
- pRootLayout = ToContainerLayoutItem(pRootLayout->m_pNextSibling)) {
+ pRootLayout = ToContainerLayoutItem(pRootLayout->GetNextSibling())) {
CXFA_Node* pPendingPageSet = nullptr;
CXFA_NodeIteratorTemplate<
CXFA_ContainerLayoutItem,
@@ -1761,7 +1761,7 @@
switch (pNode->GetElementType()) {
case XFA_Element::PageSet: {
- CXFA_Node* pParentNode = pContainerItem->m_pParent->GetFormNode();
+ CXFA_Node* pParentNode = pContainerItem->GetParent()->GetFormNode();
pContainerItem->SetFormNode(XFA_NodeMerge_CloneOrMergeContainer(
pDocument, pParentNode, pContainerItem->GetFormNode(), true,
nullptr));
@@ -1769,14 +1769,14 @@
}
case XFA_Element::PageArea: {
CXFA_LayoutItem* pFormLayout = pContainerItem;
- CXFA_Node* pParentNode = pContainerItem->m_pParent->GetFormNode();
+ CXFA_Node* pParentNode = pContainerItem->GetParent()->GetFormNode();
bool bIsExistForm = true;
for (int32_t iLevel = 0; iLevel < 3; iLevel++) {
- pFormLayout = pFormLayout->m_pFirstChild;
+ pFormLayout = pFormLayout->GetFirstChild();
if (iLevel == 2) {
while (pFormLayout &&
!pFormLayout->GetFormNode()->PresenceRequiresSpace()) {
- pFormLayout = pFormLayout->m_pNextSibling;
+ pFormLayout = pFormLayout->GetNextSibling();
}
}
if (!pFormLayout) {
@@ -1816,7 +1816,7 @@
break;
}
case XFA_Element::ContentArea: {
- CXFA_Node* pParentNode = pContainerItem->m_pParent->GetFormNode();
+ CXFA_Node* pParentNode = pContainerItem->GetParent()->GetFormNode();
for (CXFA_Node* pChildNode = pParentNode->GetFirstChild(); pChildNode;
pChildNode = pChildNode->GetNextSibling()) {
if (pChildNode->GetTemplateNodeIfExists() !=
@@ -1894,7 +1894,7 @@
void CXFA_LayoutPageMgr::LayoutPageSetContents() {
for (CXFA_ContainerLayoutItem* pRootLayoutItem = GetRootLayoutItem();
pRootLayoutItem; pRootLayoutItem = ToContainerLayoutItem(
- pRootLayoutItem->m_pNextSibling)) {
+ pRootLayoutItem->GetNextSibling())) {
CXFA_NodeIteratorTemplate<
CXFA_ContainerLayoutItem,
CXFA_TraverseStrategy_ContentAreaContainerLayoutItem>
@@ -1921,7 +1921,7 @@
int32_t nPageIdx = -1;
for (CXFA_ContainerLayoutItem* pRootLayoutItem = GetRootLayoutItem();
pRootLayoutItem; pRootLayoutItem = ToContainerLayoutItem(
- pRootLayoutItem->m_pNextSibling)) {
+ pRootLayoutItem->GetNextSibling())) {
CXFA_NodeIteratorTemplate<
CXFA_ContainerLayoutItem,
CXFA_TraverseStrategy_ContentAreaContainerLayoutItem>
@@ -1976,10 +1976,10 @@
}
void XFA_ReleaseLayoutItem_NoPageArea(CXFA_LayoutItem* pLayoutItem) {
- CXFA_LayoutItem* pNode = pLayoutItem->m_pFirstChild;
+ CXFA_LayoutItem* pNode = pLayoutItem->GetFirstChild();
while (pNode) {
- CXFA_LayoutItem* pNext = pNode->m_pNextSibling;
- pNode->m_pParent = nullptr;
+ CXFA_LayoutItem* pNext = pNode->GetNextSibling();
+ pNode->SetParent(nullptr);
XFA_ReleaseLayoutItem_NoPageArea(pNode);
pNode = pNext;
}
@@ -2021,7 +2021,7 @@
pRootLayoutItem = m_pPageSetLayoutItemRoot;
CXFA_ContainerLayoutItem* pNextLayout = nullptr;
for (; pRootLayoutItem; pRootLayoutItem = pNextLayout) {
- pNextLayout = ToContainerLayoutItem(pRootLayoutItem->m_pNextSibling);
+ pNextLayout = ToContainerLayoutItem(pRootLayoutItem->GetNextSibling());
SaveLayoutItem(pRootLayoutItem);
delete pRootLayoutItem;
}
diff --git a/xfa/fxfa/layout/cxfa_traversestrategy_contentareacontainerlayoutitem.h b/xfa/fxfa/layout/cxfa_traversestrategy_contentareacontainerlayoutitem.h
index 5f89538..f1296cf 100644
--- a/xfa/fxfa/layout/cxfa_traversestrategy_contentareacontainerlayoutitem.h
+++ b/xfa/fxfa/layout/cxfa_traversestrategy_contentareacontainerlayoutitem.h
@@ -13,8 +13,8 @@
public:
static CXFA_ContainerLayoutItem* GetFirstChild(
CXFA_ContainerLayoutItem* pLayoutItem) {
- for (CXFA_LayoutItem* pChildItem = pLayoutItem->m_pFirstChild; pChildItem;
- pChildItem = pChildItem->m_pNextSibling) {
+ for (CXFA_LayoutItem* pChildItem = pLayoutItem->GetFirstChild(); pChildItem;
+ pChildItem = pChildItem->GetNextSibling()) {
if (CXFA_ContainerLayoutItem* pContainer =
pChildItem->AsContainerLayoutItem()) {
return pContainer;
@@ -25,8 +25,8 @@
static CXFA_ContainerLayoutItem* GetNextSibling(
CXFA_ContainerLayoutItem* pLayoutItem) {
- for (CXFA_LayoutItem* pChildItem = pLayoutItem->m_pNextSibling; pChildItem;
- pChildItem = pChildItem->m_pNextSibling) {
+ for (CXFA_LayoutItem* pChildItem = pLayoutItem->GetNextSibling();
+ pChildItem; pChildItem = pChildItem->GetNextSibling()) {
if (CXFA_ContainerLayoutItem* pContainer =
pChildItem->AsContainerLayoutItem()) {
return pContainer;
@@ -37,7 +37,7 @@
static CXFA_ContainerLayoutItem* GetParent(
CXFA_ContainerLayoutItem* pLayoutItem) {
- return ToContainerLayoutItem(pLayoutItem->m_pParent);
+ return ToContainerLayoutItem(pLayoutItem->GetParent());
}
};
diff --git a/xfa/fxfa/layout/cxfa_traversestrategy_layoutitem.h b/xfa/fxfa/layout/cxfa_traversestrategy_layoutitem.h
index 357b440..d35ce11 100644
--- a/xfa/fxfa/layout/cxfa_traversestrategy_layoutitem.h
+++ b/xfa/fxfa/layout/cxfa_traversestrategy_layoutitem.h
@@ -13,13 +13,13 @@
class CXFA_TraverseStrategy_LayoutItem {
public:
static CXFA_LayoutItem* GetFirstChild(CXFA_LayoutItem* pLayoutItem) {
- return pLayoutItem->m_pFirstChild;
+ return pLayoutItem->GetFirstChild();
}
static CXFA_LayoutItem* GetNextSibling(CXFA_LayoutItem* pLayoutItem) {
- return pLayoutItem->m_pNextSibling;
+ return pLayoutItem->GetNextSibling();
}
static CXFA_LayoutItem* GetParent(CXFA_LayoutItem* pLayoutItem) {
- return pLayoutItem->m_pParent;
+ return pLayoutItem->GetParent();
}
};