summaryrefslogtreecommitdiff
path: root/xfa/src
diff options
context:
space:
mode:
Diffstat (limited to 'xfa/src')
-rw-r--r--xfa/src/fxfa/src/app/xfa_ffpageview.cpp4
-rw-r--r--xfa/src/fxfa/src/common/xfa_doclayout.h36
-rw-r--r--xfa/src/fxfa/src/parser/xfa_layout_appadapter.h16
-rw-r--r--xfa/src/fxfa/src/parser/xfa_layout_itemlayout.cpp7
-rw-r--r--xfa/src/fxfa/src/parser/xfa_layout_pagemgr_new.cpp30
5 files changed, 57 insertions, 36 deletions
diff --git a/xfa/src/fxfa/src/app/xfa_ffpageview.cpp b/xfa/src/fxfa/src/app/xfa_ffpageview.cpp
index 32d749bc01..c9b55c889a 100644
--- a/xfa/src/fxfa/src/app/xfa_ffpageview.cpp
+++ b/xfa/src/fxfa/src/app/xfa_ffpageview.cpp
@@ -341,9 +341,7 @@ void CXFA_FFTabOrderPageWidgetIterator::OrderContainer(
CFX_PtrArray tabParams;
CXFA_LayoutItem* pSearchItem = sIterator->MoveToNext();
while (pSearchItem) {
- FX_BOOL bIsContentLayoutItem =
- ((CXFA_LayoutItem*)pSearchItem)->IsContentLayoutItem();
- if (!bIsContentLayoutItem) {
+ if (!pSearchItem->IsContentLayoutItem()) {
bContentArea = TRUE;
pSearchItem = sIterator->MoveToNext();
continue;
diff --git a/xfa/src/fxfa/src/common/xfa_doclayout.h b/xfa/src/fxfa/src/common/xfa_doclayout.h
index fa8ac9bbe9..dbc30d3e12 100644
--- a/xfa/src/fxfa/src/common/xfa_doclayout.h
+++ b/xfa/src/fxfa/src/common/xfa_doclayout.h
@@ -8,13 +8,19 @@
#define _XFA_DOCLAYOUT_H_
#define _XFA_LAYOUTITEM_ProcessCACHE_
+class CXFA_ContainerLayoutItem;
+class CXFA_ContentLayoutItem;
class IXFA_LayoutPage;
class CXFA_LayoutItem {
public:
- CXFA_LayoutItem(CXFA_Node* pNode, FX_BOOL bIsContentLayoutItem);
virtual ~CXFA_LayoutItem();
+ FX_BOOL IsContainerLayoutItem() const { return !m_bIsContentLayoutItem; }
+ FX_BOOL IsContentLayoutItem() const { return m_bIsContentLayoutItem; }
+ inline CXFA_ContainerLayoutItem* AsContainerLayoutItem();
+ inline CXFA_ContentLayoutItem* AsContentLayoutItem();
+
IXFA_LayoutPage* GetPage() const;
CXFA_Node* GetFormNode() const;
void GetRect(CFX_RectF& rtLayout, FX_BOOL bRelative = FALSE) const;
@@ -28,44 +34,63 @@ class CXFA_LayoutItem {
CXFA_LayoutItem* GetPrev() const;
CXFA_LayoutItem* GetNext() const;
- FX_BOOL IsContentLayoutItem() { return m_bIsContentLayoutItem; }
void AddChild(CXFA_LayoutItem* pChildItem);
void AddHeadChild(CXFA_LayoutItem* pChildItem);
void RemoveChild(CXFA_LayoutItem* pChildItem);
void InsertChild(CXFA_LayoutItem* pBeforeItem, CXFA_LayoutItem* pChildItem);
- public:
CXFA_Node* m_pFormNode;
CXFA_LayoutItem* m_pParent;
CXFA_LayoutItem* m_pNextSibling;
CXFA_LayoutItem* m_pFirstChild;
+
+ protected:
+ CXFA_LayoutItem(CXFA_Node* pNode, FX_BOOL bIsContentLayoutItem);
+
FX_BOOL m_bIsContentLayoutItem;
};
+
class CXFA_ContainerLayoutItem : public CXFA_LayoutItem {
public:
CXFA_ContainerLayoutItem(CXFA_Node* pNode);
- public:
CXFA_Node* m_pOldSubform;
};
+
#define XFA_WIDGETSTATUS_Access 0x80000000
#define XFA_WIDGETSTATUS_Disabled 0x40000000
#define XFA_WIDGETSTATUS_RectCached 0x20000000
#define XFA_WIDGETSTATUS_ButtonDown 0x10000000
#define XFA_WIDGETSTATUS_Highlight 0x08000000
#define XFA_WIDGETSTATUS_TextEditValueChanged 0x04000000
+
class CXFA_ContentLayoutItem : public CXFA_LayoutItem {
public:
CXFA_ContentLayoutItem(CXFA_Node* pNode);
virtual ~CXFA_ContentLayoutItem();
- public:
CXFA_ContentLayoutItem* m_pPrev;
CXFA_ContentLayoutItem* m_pNext;
CFX_PointF m_sPos;
CFX_SizeF m_sSize;
FX_DWORD m_dwStatus;
};
+
+CXFA_ContainerLayoutItem* CXFA_LayoutItem::AsContainerLayoutItem() {
+ return IsContainerLayoutItem() ? static_cast<CXFA_ContainerLayoutItem*>(this)
+ : nullptr;
+}
+CXFA_ContentLayoutItem* CXFA_LayoutItem::AsContentLayoutItem() {
+ return IsContentLayoutItem() ? static_cast<CXFA_ContentLayoutItem*>(this)
+ : nullptr;
+}
+inline CXFA_ContainerLayoutItem* ToContainerLayoutItem(CXFA_LayoutItem* pItem) {
+ return pItem ? pItem->AsContainerLayoutItem() : nullptr;
+}
+inline CXFA_ContentLayoutItem* ToContentLayoutItem(CXFA_LayoutItem* pItem) {
+ return pItem ? pItem->AsContentLayoutItem() : nullptr;
+}
+
class CXFA_TraverseStrategy_LayoutItem {
public:
static inline CXFA_LayoutItem* GetFirstChild(CXFA_LayoutItem* pLayoutItem) {
@@ -78,6 +103,7 @@ class CXFA_TraverseStrategy_LayoutItem {
return pLayoutItem->m_pParent;
}
};
+
class IXFA_LayoutPage {
public:
IXFA_DocLayout* GetLayout() const;
diff --git a/xfa/src/fxfa/src/parser/xfa_layout_appadapter.h b/xfa/src/fxfa/src/parser/xfa_layout_appadapter.h
index 66d61dbfde..66bde24d1a 100644
--- a/xfa/src/fxfa/src/parser/xfa_layout_appadapter.h
+++ b/xfa/src/fxfa/src/parser/xfa_layout_appadapter.h
@@ -30,23 +30,23 @@ class CXFA_TraverseStrategy_ContentAreaContainerLayoutItem {
CXFA_ContainerLayoutItem* pLayoutItem) {
for (CXFA_LayoutItem* pChildItem = pLayoutItem->m_pFirstChild; pChildItem;
pChildItem = pChildItem->m_pNextSibling) {
- if (pChildItem->IsContentLayoutItem()) {
- continue;
+ if (CXFA_ContainerLayoutItem* pContainer =
+ pChildItem->AsContainerLayoutItem()) {
+ return pContainer;
}
- return (CXFA_ContainerLayoutItem*)pChildItem;
}
- return NULL;
+ return nullptr;
}
static inline CXFA_ContainerLayoutItem* GetNextSibling(
CXFA_ContainerLayoutItem* pLayoutItem) {
for (CXFA_LayoutItem* pChildItem = pLayoutItem->m_pNextSibling; pChildItem;
pChildItem = pChildItem->m_pNextSibling) {
- if (pChildItem->IsContentLayoutItem()) {
- continue;
+ if (CXFA_ContainerLayoutItem* pContainer =
+ pChildItem->AsContainerLayoutItem()) {
+ return pContainer;
}
- return (CXFA_ContainerLayoutItem*)pChildItem;
}
- return NULL;
+ return nullptr;
}
static inline CXFA_ContainerLayoutItem* GetParent(
CXFA_ContainerLayoutItem* pLayoutItem) {
diff --git a/xfa/src/fxfa/src/parser/xfa_layout_itemlayout.cpp b/xfa/src/fxfa/src/parser/xfa_layout_itemlayout.cpp
index 4cb1192d20..263d36dbc7 100644
--- a/xfa/src/fxfa/src/parser/xfa_layout_itemlayout.cpp
+++ b/xfa/src/fxfa/src/parser/xfa_layout_itemlayout.cpp
@@ -385,8 +385,9 @@ void CXFA_LayoutItem::GetRect(CFX_RectF& rtLayout, FX_BOOL bRelative) const {
if (!bRelative) {
for (CXFA_LayoutItem* pLayoutItem = pThis->m_pParent; pLayoutItem;
pLayoutItem = pLayoutItem->m_pParent) {
- if (pLayoutItem->IsContentLayoutItem()) {
- sPos += static_cast<CXFA_ContentLayoutItem*>(pLayoutItem)->m_sPos;
+ if (CXFA_ContentLayoutItem* pContent =
+ pLayoutItem->AsContentLayoutItem()) {
+ sPos += pContent->m_sPos;
if (CXFA_Node* pMarginNode =
pLayoutItem->m_pFormNode->GetFirstChildByClass(
XFA_ELEMENT_Margin)) {
@@ -556,7 +557,7 @@ CXFA_ContentLayoutItem* CXFA_ItemLayoutProcessor::ExtractLayoutItem() {
}
#ifdef _XFA_LAYOUTITEM_ProcessCACHE_
if (m_nCurChildNodeStage == XFA_ItemLayoutProcessorStages_Done &&
- m_pOldLayoutItem && m_pOldLayoutItem->IsContentLayoutItem()) {
+ ToContentLayoutItem(m_pOldLayoutItem)) {
if (m_pOldLayoutItem->m_pPrev) {
m_pOldLayoutItem->m_pPrev->m_pNext = NULL;
}
diff --git a/xfa/src/fxfa/src/parser/xfa_layout_pagemgr_new.cpp b/xfa/src/fxfa/src/parser/xfa_layout_pagemgr_new.cpp
index 3d1959f46c..42d0bcab02 100644
--- a/xfa/src/fxfa/src/parser/xfa_layout_pagemgr_new.cpp
+++ b/xfa/src/fxfa/src/parser/xfa_layout_pagemgr_new.cpp
@@ -543,11 +543,10 @@ void CXFA_LayoutPageMgr::FinishPaginatedPageSets() {
pContentChildLayoutItem;
pContentChildLayoutItem =
pContentChildLayoutItem->m_pNextSibling) {
- if (!pContentChildLayoutItem->IsContentLayoutItem()) {
- continue;
+ if (CXFA_ContentLayoutItem* pContent =
+ pContentChildLayoutItem->AsContentLayoutItem()) {
+ fUsedHeight += pContent->m_sSize.y;
}
- fUsedHeight +=
- ((CXFA_ContentLayoutItem*)pContentChildLayoutItem)->m_sSize.y;
}
rgUsedHeights.Add(fUsedHeight);
}
@@ -1865,15 +1864,12 @@ void XFA_SyncContainer(IXFA_Notify* pNotify,
pNotify->OnLayoutEvent(pDocLayout, pContainerItem, XFA_LAYOUTEVENT_ItemAdded,
(void*)(uintptr_t)nPageIndex,
(void*)(uintptr_t)dwStatus);
- CXFA_LayoutItem* pChild = pContainerItem->m_pFirstChild;
- while (pChild) {
- if (!pChild->IsContentLayoutItem()) {
- pChild = pChild->m_pNextSibling;
- continue;
+ for (CXFA_LayoutItem* pChild = pContainerItem->m_pFirstChild; pChild;
+ pChild = pChild->m_pNextSibling) {
+ if (pChild->IsContentLayoutItem()) {
+ XFA_SyncContainer(pNotify, pDocLayout, pChild, dwRelevantContainer,
+ bVisibleItem, nPageIndex);
}
- XFA_SyncContainer(pNotify, pDocLayout, pChild, dwRelevantContainer,
- bVisibleItem, nPageIndex);
- pChild = pChild->m_pNextSibling;
}
}
void CXFA_LayoutPageMgr::SyncLayoutData() {
@@ -1900,14 +1896,14 @@ void CXFA_LayoutPageMgr::SyncLayoutData() {
CXFA_NodeIteratorTemplate<CXFA_LayoutItem,
CXFA_TraverseStrategy_LayoutItem>
iterator(pContainerItem);
- for (CXFA_LayoutItem* pChildLayoutItem = iterator.GetCurrent();
- pChildLayoutItem;) {
- if (!pChildLayoutItem->IsContentLayoutItem()) {
+ CXFA_LayoutItem* pChildLayoutItem = iterator.GetCurrent();
+ while (pChildLayoutItem) {
+ CXFA_ContentLayoutItem* pContentItem =
+ pChildLayoutItem->AsContentLayoutItem();
+ if (!pContentItem) {
pChildLayoutItem = iterator.MoveToNext();
continue;
}
- CXFA_ContentLayoutItem* pContentItem =
- (CXFA_ContentLayoutItem*)pChildLayoutItem;
FX_BOOL bVisible =
(pContentItem->m_pFormNode->GetEnum(XFA_ATTRIBUTE_Presence) ==
XFA_ATTRIBUTEENUM_Visible);