#include "xfa/fxfa/layout/cxfa_viewlayoutprocessor.h"
#include <utility>
#include "core/fxcrt/check.h"
#include "core/fxcrt/stl_util.h"
#include "fxjs/gc/container_trace.h"
#include "fxjs/xfa/cfxjse_engine.h"
#include "fxjs/xfa/cjx_object.h"
#include "xfa/fxfa/cxfa_ffnotify.h"
#include "xfa/fxfa/cxfa_ffpageview.h"
#include "xfa/fxfa/layout/cxfa_contentlayoutitem.h"
#include "xfa/fxfa/layout/cxfa_contentlayoutprocessor.h"
#include "xfa/fxfa/layout/cxfa_layoutprocessor.h"
#include "xfa/fxfa/layout/cxfa_traversestrategy_layoutitem.h"
#include "xfa/fxfa/layout/cxfa_viewlayoutitem.h"
#include "xfa/fxfa/parser/cxfa_contentarea.h"
#include "xfa/fxfa/parser/cxfa_document.h"
#include "xfa/fxfa/parser/cxfa_localemgr.h"
#include "xfa/fxfa/parser/cxfa_measurement.h"
#include "xfa/fxfa/parser/cxfa_medium.h"
#include "xfa/fxfa/parser/cxfa_node.h"
#include "xfa/fxfa/parser/cxfa_nodeiteratortemplate.h"
#include "xfa/fxfa/parser/cxfa_object.h"
#include "xfa/fxfa/parser/cxfa_occur.h"
#include "xfa/fxfa/parser/cxfa_pageset.h"
#include "xfa/fxfa/parser/cxfa_subform.h"
#include "xfa/fxfa/parser/cxfa_traversestrategy_xfacontainernode.h"
#include "xfa/fxfa/parser/cxfa_traversestrategy_xfanode.h"
#include "xfa/fxfa/parser/xfa_document_datamerger_imp.h"
namespace {
class TraverseStrategy_ViewLayoutItem { … };
ViewLayoutItemIterator;
class TraverseStrategy_PageSet { … };
PageSetIterator;
Mask<XFA_WidgetStatus> GetRelevant(CXFA_Node* pFormItem,
Mask<XFA_WidgetStatus> dwParentRelvant) { … }
void SyncContainer(CXFA_FFNotify* pNotify,
CXFA_LayoutProcessor* pDocLayout,
CXFA_LayoutItem* pViewItem,
Mask<XFA_WidgetStatus> dwRelevant,
bool bVisible,
int32_t nPageIndex) { … }
CXFA_Node* ResolveBreakTarget(CXFA_Node* pPageSetRoot,
bool bNewExprStyle,
WideString* pTargetAll) { … }
void SetLayoutGeneratedNodeFlag(CXFA_Node* pNode) { … }
std::optional<CXFA_ViewLayoutItem*> CheckContentAreaNotUsed(
CXFA_ViewLayoutItem* pPageAreaLayoutItem,
CXFA_Node* pContentArea) { … }
void SyncRemoveLayoutItem(CXFA_LayoutItem* pLayoutItem,
CXFA_FFNotify* pNotify,
CXFA_LayoutProcessor* pDocLayout) { … }
bool RunBreakTestScript(CXFA_Script* pTestScript) { … }
float CalculateLayoutItemHeight(const CXFA_LayoutItem* pItem) { … }
std::vector<float> GetHeightsForContentAreas(const CXFA_LayoutItem* pItem) { … }
std::pair<size_t, CXFA_LayoutItem*> GetPageAreaCountAndLastPageAreaFromPageSet(
CXFA_ViewLayoutItem* pPageSetLayoutItem) { … }
bool ContentAreasFitInPageAreas(const CXFA_Node* pNode,
const std::vector<float>& rgUsedHeights) { … }
}
CXFA_ViewLayoutProcessor::CXFA_ViewRecord::CXFA_ViewRecord() = default;
CXFA_ViewLayoutProcessor::CXFA_ViewRecord::~CXFA_ViewRecord() = default;
void CXFA_ViewLayoutProcessor::CXFA_ViewRecord::Trace(
cppgc::Visitor* visitor) const { … }
CXFA_ViewLayoutProcessor::CXFA_ViewLayoutProcessor(
cppgc::Heap* pHeap,
CXFA_LayoutProcessor* pLayoutProcessor)
: … { … }
CXFA_ViewLayoutProcessor::~CXFA_ViewLayoutProcessor() = default;
void CXFA_ViewLayoutProcessor::PreFinalize() { … }
void CXFA_ViewLayoutProcessor::Trace(cppgc::Visitor* visitor) const { … }
bool CXFA_ViewLayoutProcessor::InitLayoutPage(CXFA_Node* pFormNode) { … }
bool CXFA_ViewLayoutProcessor::PrepareFirstPage(CXFA_Node* pRootSubform) { … }
bool CXFA_ViewLayoutProcessor::AppendNewPage(bool bFirstTemPage) { … }
void CXFA_ViewLayoutProcessor::RemoveLayoutRecord(
CXFA_ViewRecord* pNewRecord,
CXFA_ViewRecord* pPrevRecord) { … }
void CXFA_ViewLayoutProcessor::SubmitContentItem(
CXFA_ContentLayoutItem* pContentLayoutItem,
CXFA_ContentLayoutProcessor::Result eStatus) { … }
float CXFA_ViewLayoutProcessor::GetAvailHeight() { … }
void CXFA_ViewLayoutProcessor::AppendNewRecord(CXFA_ViewRecord* pNewRecord) { … }
CXFA_ViewLayoutProcessor::CXFA_ViewRecord*
CXFA_ViewLayoutProcessor::CreateViewRecord(CXFA_Node* pPageNode,
bool bCreateNew) { … }
CXFA_ViewLayoutProcessor::CXFA_ViewRecord*
CXFA_ViewLayoutProcessor::CreateViewRecordSimple() { … }
void CXFA_ViewLayoutProcessor::AddPageAreaLayoutItem(
CXFA_ViewRecord* pNewRecord,
CXFA_Node* pNewPageArea) { … }
void CXFA_ViewLayoutProcessor::AddContentAreaLayoutItem(
CXFA_ViewRecord* pNewRecord,
CXFA_Node* pContentArea) { … }
void CXFA_ViewLayoutProcessor::FinishPaginatedPageSets() { … }
int32_t CXFA_ViewLayoutProcessor::GetPageCount() const { … }
CXFA_ViewLayoutItem* CXFA_ViewLayoutProcessor::GetPage(int32_t index) const { … }
int32_t CXFA_ViewLayoutProcessor::GetPageIndex(
const CXFA_ViewLayoutItem* pPage) const { … }
bool CXFA_ViewLayoutProcessor::RunBreak(XFA_Element eBreakType,
XFA_AttributeValue eTargetType,
CXFA_Node* pTarget,
bool bStartNew) { … }
bool CXFA_ViewLayoutProcessor::ShouldGetNextPageArea(CXFA_Node* pTarget,
bool bStartNew) const { … }
CXFA_ViewLayoutProcessor::BreakData
CXFA_ViewLayoutProcessor::ExecuteBreakBeforeOrAfter(const CXFA_Node* pCurNode,
bool bBefore) { … }
std::optional<CXFA_ViewLayoutProcessor::BreakData>
CXFA_ViewLayoutProcessor::ProcessBreakBefore(const CXFA_Node* pBreakNode) { … }
std::optional<CXFA_ViewLayoutProcessor::BreakData>
CXFA_ViewLayoutProcessor::ProcessBreakAfter(const CXFA_Node* pBreakNode) { … }
std::optional<CXFA_ViewLayoutProcessor::BreakData>
CXFA_ViewLayoutProcessor::ProcessBreakBeforeOrAfter(const CXFA_Node* pBreakNode,
bool bBefore) { … }
CXFA_Node* CXFA_ViewLayoutProcessor::ProcessBookendLeader(
const CXFA_Node* pBookendNode) { … }
CXFA_Node* CXFA_ViewLayoutProcessor::ProcessBookendTrailer(
const CXFA_Node* pBookendNode) { … }
CXFA_Node* CXFA_ViewLayoutProcessor::ProcessBookendLeaderOrTrailer(
const CXFA_Node* pBookendNode,
bool bLeader) { … }
bool CXFA_ViewLayoutProcessor::BreakOverflow(const CXFA_Node* pOverflowNode,
bool bCreatePage,
CXFA_Node** pLeaderTemplate,
CXFA_Node** pTrailerTemplate) { … }
std::optional<CXFA_ViewLayoutProcessor::OverflowData>
CXFA_ViewLayoutProcessor::ProcessOverflow(CXFA_Node* pFormNode,
bool bCreatePage) { … }
CXFA_Node* CXFA_ViewLayoutProcessor::ResolveBookendLeaderOrTrailer(
const CXFA_Node* pBookendNode,
bool bLeader) { … }
bool CXFA_ViewLayoutProcessor::FindPageAreaFromPageSet(
CXFA_Node* pPageSet,
CXFA_Node* pStartChild,
CXFA_Node* pTargetPageArea,
CXFA_Node* pTargetContentArea,
bool bNewPage,
bool bQuery) { … }
bool CXFA_ViewLayoutProcessor::FindPageAreaFromPageSet_Ordered(
CXFA_Node* pPageSet,
CXFA_Node* pStartChild,
CXFA_Node* pTargetPageArea,
CXFA_Node* pTargetContentArea,
bool bNewPage,
bool bQuery) { … }
bool CXFA_ViewLayoutProcessor::FindPageAreaFromPageSet_SimplexDuplex(
CXFA_Node* pPageSet,
CXFA_Node* pStartChild,
CXFA_Node* pTargetPageArea,
CXFA_Node* pTargetContentArea,
bool bNewPage,
bool bQuery,
XFA_AttributeValue ePreferredPosition) { … }
bool CXFA_ViewLayoutProcessor::MatchPageAreaOddOrEven(CXFA_Node* pPageArea) { … }
CXFA_Node* CXFA_ViewLayoutProcessor::GetNextAvailPageArea(
CXFA_Node* pTargetPageArea,
CXFA_Node* pTargetContentArea,
bool bNewPage,
bool bQuery) { … }
bool CXFA_ViewLayoutProcessor::GetNextContentArea(CXFA_Node* pContentArea) { … }
void CXFA_ViewLayoutProcessor::InitPageSetMap() { … }
int32_t CXFA_ViewLayoutProcessor::CreateMinPageRecord(CXFA_Node* pPageArea,
bool bTargetPageArea,
bool bCreateLast) { … }
void CXFA_ViewLayoutProcessor::CreateMinPageSetRecord(CXFA_Node* pPageSet,
bool bCreateAll) { … }
void CXFA_ViewLayoutProcessor::CreateNextMinRecord(CXFA_Node* pRecordNode) { … }
void CXFA_ViewLayoutProcessor::ProcessLastPageSet() { … }
bool CXFA_ViewLayoutProcessor::GetNextAvailContentHeight(float fChildHeight) { … }
void CXFA_ViewLayoutProcessor::ClearData() { … }
void CXFA_ViewLayoutProcessor::SaveLayoutItemChildren(
CXFA_LayoutItem* pParentLayoutItem) { … }
CXFA_Node* CXFA_ViewLayoutProcessor::QueryOverflow(CXFA_Node* pFormNode) { … }
void CXFA_ViewLayoutProcessor::MergePageSetContents() { … }
void CXFA_ViewLayoutProcessor::LayoutPageSetContents() { … }
void CXFA_ViewLayoutProcessor::SyncLayoutData() { … }
void CXFA_ViewLayoutProcessor::PrepareLayout() { … }
void CXFA_ViewLayoutProcessor::ProcessSimplexOrDuplexPageSets(
CXFA_ViewLayoutItem* pPageSetLayoutItem,
bool bIsSimplex) { … }