7#ifndef XFA_FXFA_LAYOUT_CXFA_VIEWLAYOUTPROCESSOR_H_
8#define XFA_FXFA_LAYOUT_CXFA_VIEWLAYOUTPROCESSOR_H_
15#include "core/fxcrt/unowned_ptr.h"
16#include "core/fxcrt/unowned_ptr_exclusion.h"
17#include "fxjs/gc/heap.h"
18#include "third_party/abseil-cpp/absl/types/optional.h"
19#include "v8/include/cppgc/garbage-collected.h"
20#include "v8/include/cppgc/member.h"
21#include "v8/include/cppgc/prefinalizer.h"
22#include "v8/include/cppgc/visitor.h"
23#include "xfa/fxfa/layout/cxfa_contentlayoutprocessor.h"
26class CXFA_LayoutProcessor;
53 void Trace(cppgc::Visitor* visitor)
const;
65 CXFA_ViewLayoutItem*
GetPage(int32_t index)
const;
66 int32_t
GetPageIndex(
const CXFA_ViewLayoutItem* pPage)
const;
68 return m_pPageSetRootLayoutItem;
79 class CXFA_ViewRecord :
public cppgc::GarbageCollected<CXFA_ViewRecord> {
84 void Trace(cppgc::Visitor* visitor)
const;
86 cppgc::Member<CXFA_ViewLayoutItem> pCurPageSet;
87 cppgc::Member<CXFA_ViewLayoutItem> pCurPageArea;
88 cppgc::Member<CXFA_ViewLayoutItem> pCurContentArea;
94 CXFA_ViewLayoutProcessor(
cppgc::Heap* pHeap,
95 CXFA_LayoutProcessor* pLayoutProcessor);
97 bool AppendNewPage(
bool bFirstTemPage);
98 void RemoveLayoutRecord(CXFA_ViewRecord* pNewRecord,
99 CXFA_ViewRecord* pPrevRecord);
100 bool HasCurrentViewRecord()
const {
101 return m_CurrentViewRecordIter != m_ProposedViewRecords.end();
103 CXFA_ViewRecord* GetCurrentViewRecord() {
104 return HasCurrentViewRecord() ? m_CurrentViewRecordIter->Get() :
nullptr;
106 const CXFA_ViewRecord* GetCurrentViewRecord()
const {
107 return HasCurrentViewRecord() ? m_CurrentViewRecordIter->Get() :
nullptr;
109 void ResetToFirstViewRecord() {
110 m_CurrentViewRecordIter = m_ProposedViewRecords.begin();
117 CXFA_ViewRecord* CreateViewRecord(
CXFA_Node* pPageNode,
bool bCreateNew);
118 CXFA_ViewRecord* CreateViewRecordSimple();
119 void AddPageAreaLayoutItem(CXFA_ViewRecord* pNewRecord,
121 void AddContentAreaLayoutItem(CXFA_ViewRecord* pNewRecord,
127 bool ShouldGetNextPageArea(
CXFA_Node* pTarget,
bool bStartNew)
const;
128 bool BreakOverflow(
const CXFA_Node* pOverflowNode,
136 absl::optional<BreakData> ProcessBreakBeforeOrAfter(
141 int32_t CreateMinPageRecord(
CXFA_Node* pPageArea,
142 bool bTargetPageArea,
144 void CreateMinPageSetRecord(
CXFA_Node* pPageSet,
bool bCreateAll);
145 void CreateNextMinRecord(
CXFA_Node* pRecordNode);
146 bool FindPageAreaFromPageSet(
CXFA_Node* pPageSet,
152 bool FindPageAreaFromPageSet_Ordered(
CXFA_Node* pPageSet,
158 bool FindPageAreaFromPageSet_SimplexDuplex(
166 bool MatchPageAreaOddOrEven(
CXFA_Node* pPageArea);
171 bool GetNextContentArea(
CXFA_Node* pTargetContentArea);
172 void InitPageSetMap();
173 void ProcessLastPageSet();
174 bool IsPageSetRootOrderedOccurrence()
const {
178 void MergePageSetContents();
179 void LayoutPageSetContents();
180 void PrepareLayout();
182 void ProcessSimplexOrDuplexPageSets(CXFA_ViewLayoutItem* pPageSetLayoutItem,
186 cppgc::Member<CXFA_LayoutProcessor> m_pLayoutProcessor;
187 cppgc::Member<CXFA_Node> m_pPageSetNode;
188 cppgc::Member<CXFA_Node> m_pCurPageArea;
189 cppgc::Member<CXFA_ViewLayoutItem> m_pPageSetRootLayoutItem;
190 cppgc::Member<CXFA_ViewLayoutItem> m_pPageSetCurLayoutItem;
193 int32_t m_nAvailPages = 0;
194 int32_t m_nCurPageCount = 0;
196 bool m_bCreateOverFlowPage =
false;
void InsertAfter(CXFA_ContentLayoutItem *pNext)
CXFA_ContentLayoutItem * GetNext() const
CXFA_ContentLayoutItem * GetLast()
~CXFA_ContentLayoutProcessor()
Result DoLayout(bool bUseBreakControl, float fHeightLimit, float fRealHeight)
void DoLayoutPageArea(CXFA_ViewLayoutItem *pPageAreaLayoutItem)
cppgc::Heap * GetHeap() const
CXFA_ContentLayoutItem * ExtractLayoutItem()
void Trace(cppgc::Visitor *visitor) const
CXFA_Node * GetFormNode()
CXFA_FFNotify * GetNotify() const
void StartFieldDrawLayout(CXFA_Node *pItem, float *pCalcWidth, float *pCalcHeight)
void OnLayoutItemRemoving(CXFA_LayoutProcessor *pLayout, CXFA_LayoutItem *pSender)
bool IsContentLayoutItem() const
CXFA_ContentLayoutItem * AsContentLayoutItem()
CXFA_Node * GetFormNode() const
static CXFA_LayoutProcessor * FromDocument(const CXFA_Document *pXFADoc)
void RemoveChildAndNotify(CXFA_Node *pNode, bool bNotify)
CXFA_Node * GetFirstContainerChild() const
CXFA_Node * GetNextContainerSibling() const
XFA_AttributeValue GetIntact()
bool IsLayoutGeneratedNode() const
void SetBindingNode(CXFA_Node *node)
void SetFlag(XFA_NodeFlag dwFlag)
CXFA_Node * GetTemplateNodeIfExists() const
CXFA_Node * GetPrevContainerSibling() const
CXFA_Node * GetBindData()
bool RemoveBindItem(CXFA_Node *pFormNode)
bool IsUnusedNode() const
bool PresenceRequiresSpace() const
XFA_Element GetElementType() const
CXFA_Document * GetDocument() const
bool IsContainerNode() const
void FinishPaginatedPageSets()
int32_t GetPageIndex(const CXFA_ViewLayoutItem *pPage) const
CXFA_ViewLayoutItem * GetPage(int32_t index) const
CXFA_Node * QueryOverflow(CXFA_Node *pFormNode)
absl::optional< BreakData > ProcessBreakAfter(const CXFA_Node *pBreakNode)
absl::optional< OverflowData > ProcessOverflow(CXFA_Node *pFormNode, bool bCreatePage)
bool PrepareFirstPage(CXFA_Node *pRootSubform)
bool InitLayoutPage(CXFA_Node *pFormNode)
CXFA_Node * ProcessBookendTrailer(const CXFA_Node *pBookendNode)
CXFA_ViewLayoutItem * GetRootLayoutItem() const
int32_t GetPageCount() const
void Trace(cppgc::Visitor *visitor) const
CXFA_Node * ProcessBookendLeader(const CXFA_Node *pBookendNode)
cppgc::Heap * GetHeap() const
absl::optional< BreakData > ProcessBreakBefore(const CXFA_Node *pBreakNode)
void SubmitContentItem(CXFA_ContentLayoutItem *pContentLayoutItem, CXFA_ContentLayoutProcessor::Result eStatus)
~CXFA_ViewLayoutProcessor()
bool GetNextAvailContentHeight(float fChildHeight)
constexpr float kXFALayoutPrecision
#define CONSTRUCT_VIA_MAKE_GARBAGE_COLLECTED
UNOWNED_PTR_EXCLUSION CXFA_Node * pTrailer
UNOWNED_PTR_EXCLUSION CXFA_Node * pLeader
UNOWNED_PTR_EXCLUSION CXFA_Node * pTrailer
UNOWNED_PTR_EXCLUSION CXFA_Node * pLeader
#define UNOWNED_PTR_EXCLUSION