#include "xfa/fxfa/layout/cxfa_contentlayoutprocessor.h"
#include <algorithm>
#include <array>
#include <utility>
#include <vector>
#include "core/fxcrt/check.h"
#include "core/fxcrt/containers/adapters.h"
#include "core/fxcrt/notreached.h"
#include "core/fxcrt/stl_util.h"
#include "fxjs/gc/container_trace.h"
#include "fxjs/xfa/cjx_object.h"
#include "xfa/fxfa/cxfa_ffdoc.h"
#include "xfa/fxfa/cxfa_ffnotify.h"
#include "xfa/fxfa/cxfa_ffwidget.h"
#include "xfa/fxfa/layout/cxfa_contentlayoutitem.h"
#include "xfa/fxfa/layout/cxfa_layoutprocessor.h"
#include "xfa/fxfa/layout/cxfa_viewlayoutitem.h"
#include "xfa/fxfa/layout/cxfa_viewlayoutprocessor.h"
#include "xfa/fxfa/parser/cxfa_document.h"
#include "xfa/fxfa/parser/cxfa_keep.h"
#include "xfa/fxfa/parser/cxfa_localemgr.h"
#include "xfa/fxfa/parser/cxfa_margin.h"
#include "xfa/fxfa/parser/cxfa_measurement.h"
#include "xfa/fxfa/parser/cxfa_node.h"
#include "xfa/fxfa/parser/cxfa_nodeiteratortemplate.h"
#include "xfa/fxfa/parser/cxfa_occur.h"
#include "xfa/fxfa/parser/cxfa_para.h"
#include "xfa/fxfa/parser/cxfa_traversestrategy_xfanode.h"
#include "xfa/fxfa/parser/xfa_utils.h"
namespace {
NextPosRow;
constexpr std::array<const NextPosRow, 4> kNextPosTable = …;
std::vector<WideString> SeparateStringOnSpace(
pdfium::span<const wchar_t> spStr) { … }
void UpdateWidgetSize(CXFA_ContentLayoutItem* pLayoutItem,
float* pWidth,
float* pHeight) { … }
CFX_SizeF CalculateContainerSpecifiedSize(CXFA_Node* pFormNode,
bool* bContainerWidthAutoSize,
bool* bContainerHeightAutoSize) { … }
CFX_SizeF CalculateContainerComponentSizeFromContentSize(
CXFA_Node* pFormNode,
bool bContainerWidthAutoSize,
float fContentCalculatedWidth,
bool bContainerHeightAutoSize,
float fContentCalculatedHeight,
const CFX_SizeF& currentContainerSize) { … }
CFX_FloatRect GetMarginInset(const CXFA_Margin* pMargin) { … }
void RelocateTableRowCells(CXFA_ContentLayoutItem* pLayoutRow,
const std::vector<float>& rgSpecifiedColumnWidths,
XFA_AttributeValue eLayout) { … }
XFA_AttributeValue GetLayout(CXFA_Node* pFormNode, bool* bRootForceTb) { … }
bool ExistContainerKeep(CXFA_Node* pCurNode, bool bPreFind) { … }
std::optional<CXFA_ContentLayoutProcessor::Stage> FindBreakBeforeNode(
CXFA_Node* pContainerNode,
CXFA_Node** pCurActionNode) { … }
std::optional<CXFA_ContentLayoutProcessor::Stage> FindBreakAfterNode(
CXFA_Node* pContainerNode,
CXFA_Node** pCurActionNode) { … }
void DeleteLayoutGeneratedNode(CXFA_Node* pGenerateNode) { … }
uint8_t HAlignEnumToInt(XFA_AttributeValue eHAlign) { … }
bool FindLayoutItemSplitPos(CXFA_ContentLayoutItem* pLayoutItem,
float fCurVerticalOffset,
float* fProposedSplitPos,
bool* bAppChange,
bool bCalculateMargin) { … }
CFX_PointF CalculatePositionedContainerPos(CXFA_Node* pNode,
const CFX_SizeF& size) { … }
}
CXFA_ContentLayoutProcessor::CXFA_ContentLayoutProcessor(
cppgc::Heap* pHeap,
CXFA_Node* pNode,
CXFA_ViewLayoutProcessor* pViewLayoutProcessor)
: … { … }
CXFA_ContentLayoutProcessor::~CXFA_ContentLayoutProcessor() = default;
void CXFA_ContentLayoutProcessor::Trace(cppgc::Visitor* visitor) const { … }
CXFA_ContentLayoutItem* CXFA_ContentLayoutProcessor::CreateContentLayoutItem(
CXFA_Node* pFormNode) { … }
float CXFA_ContentLayoutProcessor::FindSplitPos(float fProposedSplitPos) { … }
void CXFA_ContentLayoutProcessor::SplitLayoutItem(
CXFA_ContentLayoutItem* pLayoutItem,
CXFA_ContentLayoutItem* pSecondParent,
float fSplitPos) { … }
void CXFA_ContentLayoutProcessor::SplitLayoutItem(float fSplitPos) { … }
CXFA_ContentLayoutItem* CXFA_ContentLayoutProcessor::ExtractLayoutItem() { … }
void CXFA_ContentLayoutProcessor::GotoNextContainerNodeSimple() { … }
std::pair<CXFA_ContentLayoutProcessor::Stage, CXFA_Node*>
CXFA_ContentLayoutProcessor::GotoNextContainerNode(Stage nCurStage,
CXFA_Node* pParentContainer,
CXFA_Node* pCurActionNode) { … }
std::optional<CXFA_ContentLayoutProcessor::Stage>
CXFA_ContentLayoutProcessor::ProcessKeepNodesForCheckNext(
CXFA_Node** pCurActionNode,
CXFA_Node** pNextContainer,
bool* pLastKeepNode) { … }
std::optional<CXFA_ContentLayoutProcessor::Stage>
CXFA_ContentLayoutProcessor::ProcessKeepNodesForBreakBefore(
CXFA_Node** pCurActionNode,
CXFA_Node* pContainerNode) { … }
void CXFA_ContentLayoutProcessor::DoLayoutPageArea(
CXFA_ViewLayoutItem* pPageAreaLayoutItem) { … }
void CXFA_ContentLayoutProcessor::DoLayoutPositionedContainer(
Context* pContext) { … }
void CXFA_ContentLayoutProcessor::DoLayoutTableContainer(
CXFA_Node* pLayoutNode) { … }
bool CXFA_ContentLayoutProcessor::IsAddNewRowForTrailer(
CXFA_ContentLayoutItem* pTrailerItem) { … }
float CXFA_ContentLayoutProcessor::InsertKeepLayoutItems() { … }
bool CXFA_ContentLayoutProcessor::ProcessKeepForSplit(
CXFA_ContentLayoutProcessor* pChildProcessor,
Result eRetValue,
ContentLayoutItemVector& rgCurLineLayoutItem,
float* fContentCurRowAvailWidth,
float* fContentCurRowHeight,
float* fContentCurRowY,
bool* bAddedItemInRow,
bool* bForceEndPage,
Result* result) { … }
bool CXFA_ContentLayoutProcessor::JudgePutNextPage(
CXFA_ContentLayoutItem* pParentLayoutItem,
float fChildHeight,
std::vector<CXFA_ContentLayoutItem*>* pKeepItems) { … }
void CXFA_ContentLayoutProcessor::ProcessUnUseBinds(CXFA_Node* pFormNode) { … }
void CXFA_ContentLayoutProcessor::ProcessUnUseOverFlow(
CXFA_Node* pLeaderNode,
CXFA_Node* pTrailerNode,
CXFA_ContentLayoutItem* pTrailerItem,
CXFA_Node* pFormNode) { … }
CXFA_ContentLayoutProcessor::Result
CXFA_ContentLayoutProcessor::DoLayoutFlowedContainer(
bool bUseBreakControl,
XFA_AttributeValue eFlowStrategy,
float fHeightLimit,
float fRealHeight,
Context* pContext,
bool bRootForceTb) { … }
bool CXFA_ContentLayoutProcessor::CalculateRowChildPosition(
std::array<ContentLayoutItemVector, 3>& rgCurLineLayoutItems,
XFA_AttributeValue eFlowStrategy,
bool bContainerHeightAutoSize,
bool bContainerWidthAutoSize,
float* fContentCalculatedWidth,
float* fContentCalculatedHeight,
float* fContentCurRowY,
float fContentCurRowHeight,
float fContentWidthLimit,
bool bRootForceTb) { … }
CXFA_Node* CXFA_ContentLayoutProcessor::GetSubformSetParent(
CXFA_Node* pSubformSet) { … }
void CXFA_ContentLayoutProcessor::DoLayoutField() { … }
CXFA_ContentLayoutProcessor::Result CXFA_ContentLayoutProcessor::DoLayout(
bool bUseBreakControl,
float fHeightLimit,
float fRealHeight) { … }
CXFA_ContentLayoutProcessor::Result
CXFA_ContentLayoutProcessor::DoLayoutInternal(bool bUseBreakControl,
float fHeightLimit,
float fRealHeight,
Context* pContext) { … }
CFX_SizeF CXFA_ContentLayoutProcessor::GetCurrentComponentSize() { … }
void CXFA_ContentLayoutProcessor::SetCurrentComponentPos(
const CFX_PointF& pos) { … }
void CXFA_ContentLayoutProcessor::SetCurrentComponentSize(
const CFX_SizeF& size) { … }
bool CXFA_ContentLayoutProcessor::JudgeLeaderOrTrailerForOccur(
CXFA_Node* pFormNode) { … }
void CXFA_ContentLayoutProcessor::UpdatePendingItemLayout(
CXFA_ContentLayoutItem* pLayoutItem) { … }
void CXFA_ContentLayoutProcessor::AddTrailerBeforeSplit(
float fSplitPos,
CXFA_ContentLayoutItem* pTrailerLayoutItem,
bool bUseInherited) { … }
void CXFA_ContentLayoutProcessor::AddLeaderAfterSplit(
CXFA_ContentLayoutItem* pLeaderLayoutItem) { … }
void CXFA_ContentLayoutProcessor::AddPendingNode(CXFA_Node* pPendingNode,
bool bBreakPending) { … }
float CXFA_ContentLayoutProcessor::InsertPendingItems(
CXFA_Node* pCurChildNode) { … }
CXFA_ContentLayoutProcessor::Result
CXFA_ContentLayoutProcessor::InsertFlowedItem(
CXFA_ContentLayoutProcessor* pProcessor,
bool bContainerWidthAutoSize,
bool bContainerHeightAutoSize,
float fContainerHeight,
XFA_AttributeValue eFlowStrategy,
uint8_t* uCurHAlignState,
std::array<ContentLayoutItemVector, 3>& rgCurLineLayoutItems,
bool bUseBreakControl,
float fAvailHeight,
float fRealHeight,
float fContentWidthLimit,
float* fContentCurRowY,
float* fContentCurRowAvailWidth,
float* fContentCurRowHeight,
bool* bAddedItemInRow,
bool* bForceEndPage,
Context* pLayoutContext,
bool bNewRow) { … }
std::optional<CXFA_ContentLayoutProcessor::Stage>
CXFA_ContentLayoutProcessor::HandleKeep(CXFA_Node* pBreakAfterNode,
CXFA_Node** pCurActionNode) { … }
std::optional<CXFA_ContentLayoutProcessor::Stage>
CXFA_ContentLayoutProcessor::HandleBookendLeader(CXFA_Node* pParentContainer,
CXFA_Node** pCurActionNode) { … }
std::optional<CXFA_ContentLayoutProcessor::Stage>
CXFA_ContentLayoutProcessor::HandleBreakBefore(CXFA_Node* pChildContainer,
CXFA_Node** pCurActionNode) { … }
std::optional<CXFA_ContentLayoutProcessor::Stage>
CXFA_ContentLayoutProcessor::HandleBreakAfter(CXFA_Node* pChildContainer,
CXFA_Node** pCurActionNode) { … }
std::optional<CXFA_ContentLayoutProcessor::Stage>
CXFA_ContentLayoutProcessor::HandleCheckNextChildContainer(
CXFA_Node* pParentContainer,
CXFA_Node* pChildContainer,
CXFA_Node** pCurActionNode) { … }
std::optional<CXFA_ContentLayoutProcessor::Stage>
CXFA_ContentLayoutProcessor::HandleBookendTrailer(CXFA_Node* pParentContainer,
CXFA_Node** pCurActionNode) { … }
void CXFA_ContentLayoutProcessor::ProcessKeepNodesEnd() { … }
void CXFA_ContentLayoutProcessor::AdjustContainerSpecifiedSize(
Context* pContext,
CFX_SizeF* pSize,
bool* pContainerWidthAutoSize,
bool* pContainerHeightAutoSize) { … }
CXFA_ContentLayoutItem* CXFA_ContentLayoutProcessor::FindLastContentLayoutItem(
XFA_AttributeValue eFlowStrategy) { … }
CFX_SizeF CXFA_ContentLayoutProcessor::CalculateLayoutItemSize(
const CXFA_ContentLayoutItem* pLastChild) { … }
CXFA_ContentLayoutProcessor::Context::Context() = default;
CXFA_ContentLayoutProcessor::Context::~Context() = default;