summaryrefslogtreecommitdiff
path: root/xfa/fxfa
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2018-01-31 20:13:44 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-01-31 20:13:44 +0000
commit405f17ae3f297d28917370d013d95adc31e7c4a1 (patch)
tree0afaaaa4f8652903dfd49a381dd871c1da8a017b /xfa/fxfa
parent990c09373b733346a06b03167ca43252cb93e986 (diff)
downloadpdfium-405f17ae3f297d28917370d013d95adc31e7c4a1.tar.xz
Cleanup visibility in CXFA_ItemLayoutProcessor
This CL moves anonymous namespace methods in CXFA_ItemLayoutProcessor to be private methods and then fixes the visibility on most of the methods/data to be private. Change-Id: Idfccbc53b94628b18bc3576e4466391b0f704b44 Reviewed-on: https://pdfium-review.googlesource.com/24851 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'xfa/fxfa')
-rw-r--r--xfa/fxfa/parser/cxfa_itemlayoutprocessor.cpp1196
-rw-r--r--xfa/fxfa/parser/cxfa_itemlayoutprocessor.h72
-rw-r--r--xfa/fxfa/parser/cxfa_layoutprocessor.cpp12
3 files changed, 635 insertions, 645 deletions
diff --git a/xfa/fxfa/parser/cxfa_itemlayoutprocessor.cpp b/xfa/fxfa/parser/cxfa_itemlayoutprocessor.cpp
index f5392a584c..b4bea75fb2 100644
--- a/xfa/fxfa/parser/cxfa_itemlayoutprocessor.cpp
+++ b/xfa/fxfa/parser/cxfa_itemlayoutprocessor.cpp
@@ -321,189 +321,6 @@ void RelocateTableRowCells(CXFA_ContentLayoutItem* pLayoutRow,
bContainerHeightAutoSize, fContentCalculatedHeight, containerSize);
}
-void UpdatePendingItemLayout(CXFA_ItemLayoutProcessor* pProcessor,
- CXFA_ContentLayoutItem* pLayoutItem) {
- XFA_AttributeEnum eLayout =
- pLayoutItem->m_pFormNode->JSObject()->GetEnum(XFA_Attribute::Layout);
- switch (eLayout) {
- case XFA_AttributeEnum::Row:
- case XFA_AttributeEnum::Rl_row:
- RelocateTableRowCells(pLayoutItem, pProcessor->m_rgSpecifiedColumnWidths,
- eLayout);
- break;
- default:
- break;
- }
-}
-
-void AddTrailerBeforeSplit(CXFA_ItemLayoutProcessor* pProcessor,
- float fSplitPos,
- CXFA_ContentLayoutItem* pTrailerLayoutItem,
- bool bUseInherited) {
- if (!pTrailerLayoutItem)
- return;
-
- float fHeight = pTrailerLayoutItem->m_sSize.height;
- if (bUseInherited) {
- float fNewSplitPos = 0;
- if (fSplitPos - fHeight > XFA_LAYOUT_FLOAT_PERCISION)
- fNewSplitPos = pProcessor->FindSplitPos(fSplitPos - fHeight);
- if (fNewSplitPos > XFA_LAYOUT_FLOAT_PERCISION)
- pProcessor->SplitLayoutItem(fNewSplitPos);
- return;
- }
-
- UpdatePendingItemLayout(pProcessor, pTrailerLayoutItem);
- CXFA_Margin* pMarginNode =
- pProcessor->m_pFormNode->GetFirstChildByClass<CXFA_Margin>(
- XFA_Element::Margin);
- float fLeftInset = 0;
- float fTopInset = 0;
- float fRightInset = 0;
- float fBottomInset = 0;
- if (pMarginNode) {
- fLeftInset = pMarginNode->JSObject()
- ->GetMeasure(XFA_Attribute::LeftInset)
- .ToUnit(XFA_Unit::Pt);
- fTopInset = pMarginNode->JSObject()
- ->GetMeasure(XFA_Attribute::TopInset)
- .ToUnit(XFA_Unit::Pt);
- fRightInset = pMarginNode->JSObject()
- ->GetMeasure(XFA_Attribute::RightInset)
- .ToUnit(XFA_Unit::Pt);
- fBottomInset = pMarginNode->JSObject()
- ->GetMeasure(XFA_Attribute::BottomInset)
- .ToUnit(XFA_Unit::Pt);
- }
-
- if (!pProcessor->IsAddNewRowForTrailer(pTrailerLayoutItem)) {
- pTrailerLayoutItem->m_sPos.y = pProcessor->m_fLastRowY;
- pTrailerLayoutItem->m_sPos.x = pProcessor->m_fLastRowWidth;
- pProcessor->m_pLayoutItem->m_sSize.width +=
- pTrailerLayoutItem->m_sSize.width;
- pProcessor->m_pLayoutItem->AddChild(pTrailerLayoutItem);
- return;
- }
-
- float fNewSplitPos = 0;
- if (fSplitPos - fHeight > XFA_LAYOUT_FLOAT_PERCISION)
- fNewSplitPos = pProcessor->FindSplitPos(fSplitPos - fHeight);
-
- if (fNewSplitPos > XFA_LAYOUT_FLOAT_PERCISION) {
- pProcessor->SplitLayoutItem(fNewSplitPos);
- pTrailerLayoutItem->m_sPos.y = fNewSplitPos - fTopInset - fBottomInset;
- } else {
- pTrailerLayoutItem->m_sPos.y = fSplitPos - fTopInset - fBottomInset;
- }
-
- switch (pTrailerLayoutItem->m_pFormNode->JSObject()->GetEnum(
- XFA_Attribute::HAlign)) {
- case XFA_AttributeEnum::Right:
- pTrailerLayoutItem->m_sPos.x = pProcessor->m_pLayoutItem->m_sSize.width -
- fRightInset -
- pTrailerLayoutItem->m_sSize.width;
- break;
- case XFA_AttributeEnum::Center:
- pTrailerLayoutItem->m_sPos.x =
- (pProcessor->m_pLayoutItem->m_sSize.width - fLeftInset - fRightInset -
- pTrailerLayoutItem->m_sSize.width) /
- 2;
- break;
- case XFA_AttributeEnum::Left:
- default:
- pTrailerLayoutItem->m_sPos.x = fLeftInset;
- break;
- }
- pProcessor->m_pLayoutItem->m_sSize.height += fHeight;
- pProcessor->m_pLayoutItem->AddChild(pTrailerLayoutItem);
-}
-
-void AddLeaderAfterSplit(CXFA_ItemLayoutProcessor* pProcessor,
- CXFA_ContentLayoutItem* pLeaderLayoutItem) {
- UpdatePendingItemLayout(pProcessor, pLeaderLayoutItem);
-
- CXFA_Margin* pMarginNode =
- pProcessor->m_pFormNode->GetFirstChildByClass<CXFA_Margin>(
- XFA_Element::Margin);
- float fLeftInset = 0;
- float fRightInset = 0;
- if (pMarginNode) {
- fLeftInset = pMarginNode->JSObject()
- ->GetMeasure(XFA_Attribute::LeftInset)
- .ToUnit(XFA_Unit::Pt);
- fRightInset = pMarginNode->JSObject()
- ->GetMeasure(XFA_Attribute::RightInset)
- .ToUnit(XFA_Unit::Pt);
- }
-
- float fHeight = pLeaderLayoutItem->m_sSize.height;
- for (CXFA_ContentLayoutItem* pChildItem =
- (CXFA_ContentLayoutItem*)pProcessor->m_pLayoutItem->m_pFirstChild;
- pChildItem;
- pChildItem = (CXFA_ContentLayoutItem*)pChildItem->m_pNextSibling) {
- pChildItem->m_sPos.y += fHeight;
- }
- pLeaderLayoutItem->m_sPos.y = 0;
-
- switch (pLeaderLayoutItem->m_pFormNode->JSObject()->GetEnum(
- XFA_Attribute::HAlign)) {
- case XFA_AttributeEnum::Right:
- pLeaderLayoutItem->m_sPos.x = pProcessor->m_pLayoutItem->m_sSize.width -
- fRightInset -
- pLeaderLayoutItem->m_sSize.width;
- break;
- case XFA_AttributeEnum::Center:
- pLeaderLayoutItem->m_sPos.x =
- (pProcessor->m_pLayoutItem->m_sSize.width - fLeftInset - fRightInset -
- pLeaderLayoutItem->m_sSize.width) /
- 2;
- break;
- case XFA_AttributeEnum::Left:
- default:
- pLeaderLayoutItem->m_sPos.x = fLeftInset;
- break;
- }
- pProcessor->m_pLayoutItem->m_sSize.height += fHeight;
- pProcessor->m_pLayoutItem->AddChild(pLeaderLayoutItem);
-}
-
-void AddPendingNode(CXFA_ItemLayoutProcessor* pProcessor,
- CXFA_Node* pPendingNode,
- bool bBreakPending) {
- pProcessor->m_PendingNodes.push_back(pPendingNode);
- pProcessor->m_bBreakPending = bBreakPending;
-}
-
-float InsertPendingItems(CXFA_ItemLayoutProcessor* pProcessor,
- CXFA_Node* pCurChildNode) {
- float fTotalHeight = 0;
- if (pProcessor->m_PendingNodes.empty())
- return fTotalHeight;
-
- if (!pProcessor->m_pLayoutItem) {
- pProcessor->m_pLayoutItem =
- pProcessor->CreateContentLayoutItem(pCurChildNode);
- pProcessor->m_pLayoutItem->m_sSize.clear();
- }
-
- while (!pProcessor->m_PendingNodes.empty()) {
- auto pPendingProcessor = pdfium::MakeUnique<CXFA_ItemLayoutProcessor>(
- pProcessor->m_PendingNodes.front(), nullptr);
- pProcessor->m_PendingNodes.pop_front();
- pPendingProcessor->DoLayout(false, FLT_MAX, FLT_MAX, nullptr);
- CXFA_ContentLayoutItem* pPendingLayoutItem =
- pPendingProcessor->HasLayoutItem()
- ? pPendingProcessor->ExtractLayoutItem()
- : nullptr;
- if (pPendingLayoutItem) {
- AddLeaderAfterSplit(pProcessor, pPendingLayoutItem);
- if (pProcessor->m_bBreakPending)
- fTotalHeight += pPendingLayoutItem->m_sSize.height;
- }
- }
- return fTotalHeight;
-}
-
XFA_AttributeEnum GetLayout(CXFA_Node* pFormNode, bool* bRootForceTb) {
*bRootForceTb = false;
Optional<XFA_AttributeEnum> layoutMode =
@@ -646,342 +463,6 @@ uint8_t HAlignEnumToInt(XFA_AttributeEnum eHAlign) {
}
}
-XFA_ItemLayoutProcessorResult InsertFlowedItem(
- CXFA_ItemLayoutProcessor* pThis,
- CXFA_ItemLayoutProcessor* pProcessor,
- bool bContainerWidthAutoSize,
- bool bContainerHeightAutoSize,
- float fContainerHeight,
- XFA_AttributeEnum eFlowStrategy,
- uint8_t* uCurHAlignState,
- std::vector<CXFA_ContentLayoutItem*> (&rgCurLineLayoutItems)[3],
- bool bUseBreakControl,
- float fAvailHeight,
- float fRealHeight,
- float fContentWidthLimit,
- float* fContentCurRowY,
- float* fContentCurRowAvailWidth,
- float* fContentCurRowHeight,
- bool* bAddedItemInRow,
- bool* bForceEndPage,
- CXFA_LayoutContext* pLayoutContext,
- bool bNewRow) {
- bool bTakeSpace = pProcessor->m_pFormNode->PresenceRequiresSpace();
- uint8_t uHAlign = HAlignEnumToInt(
- pThis->m_pCurChildNode->JSObject()->GetEnum(XFA_Attribute::HAlign));
- if (bContainerWidthAutoSize)
- uHAlign = 0;
-
- if ((eFlowStrategy != XFA_AttributeEnum::Rl_tb &&
- uHAlign < *uCurHAlignState) ||
- (eFlowStrategy == XFA_AttributeEnum::Rl_tb &&
- uHAlign > *uCurHAlignState)) {
- return XFA_ItemLayoutProcessorResult::RowFullBreak;
- }
-
- *uCurHAlignState = uHAlign;
- bool bIsOwnSplit =
- pProcessor->m_pFormNode->GetIntact() == XFA_AttributeEnum::None;
- bool bUseRealHeight = bTakeSpace && bContainerHeightAutoSize && bIsOwnSplit &&
- pProcessor->m_pFormNode->GetParent()->GetIntact() ==
- XFA_AttributeEnum::None;
- bool bIsTransHeight = bTakeSpace;
- if (bIsTransHeight && !bIsOwnSplit) {
- bool bRootForceTb = false;
- XFA_AttributeEnum eLayoutStrategy =
- GetLayout(pProcessor->m_pFormNode, &bRootForceTb);
- if (eLayoutStrategy == XFA_AttributeEnum::Lr_tb ||
- eLayoutStrategy == XFA_AttributeEnum::Rl_tb) {
- bIsTransHeight = false;
- }
- }
-
- bool bUseInherited = false;
- CXFA_LayoutContext layoutContext;
- if (pThis->m_pPageMgr) {
- CXFA_Node* pOverflowNode =
- pThis->m_pPageMgr->QueryOverflow(pThis->m_pFormNode);
- if (pOverflowNode) {
- layoutContext.m_pOverflowNode = pOverflowNode;
- layoutContext.m_pOverflowProcessor = pThis;
- pLayoutContext = &layoutContext;
- }
- }
-
- XFA_ItemLayoutProcessorResult eRetValue = XFA_ItemLayoutProcessorResult::Done;
- if (!bNewRow ||
- pProcessor->m_ePreProcessRs == XFA_ItemLayoutProcessorResult::Done) {
- eRetValue = pProcessor->DoLayout(
- bTakeSpace ? bUseBreakControl : false,
- bUseRealHeight ? fRealHeight - *fContentCurRowY : FLT_MAX,
- bIsTransHeight ? fRealHeight - *fContentCurRowY : FLT_MAX,
- pLayoutContext);
- pProcessor->m_ePreProcessRs = eRetValue;
- } else {
- eRetValue = pProcessor->m_ePreProcessRs;
- pProcessor->m_ePreProcessRs = XFA_ItemLayoutProcessorResult::Done;
- }
- if (pProcessor->HasLayoutItem() == false)
- return eRetValue;
-
- CFX_SizeF childSize = pProcessor->GetCurrentComponentSize();
- if (bUseRealHeight && fRealHeight < XFA_LAYOUT_FLOAT_PERCISION) {
- fRealHeight = FLT_MAX;
- fAvailHeight = FLT_MAX;
- }
- if (bTakeSpace && (childSize.width >
- *fContentCurRowAvailWidth + XFA_LAYOUT_FLOAT_PERCISION) &&
- (fContentWidthLimit - *fContentCurRowAvailWidth >
- XFA_LAYOUT_FLOAT_PERCISION)) {
- return XFA_ItemLayoutProcessorResult::RowFullBreak;
- }
-
- CXFA_Node* pOverflowLeaderNode = nullptr;
- CXFA_Node* pOverflowTrailerNode = nullptr;
- CXFA_Node* pFormNode = nullptr;
- CXFA_ContentLayoutItem* pTrailerLayoutItem = nullptr;
- bool bIsAddTrailerHeight = false;
- if (pThis->m_pPageMgr &&
- pProcessor->m_pFormNode->GetIntact() == XFA_AttributeEnum::None) {
- pFormNode = pThis->m_pPageMgr->QueryOverflow(pProcessor->m_pFormNode);
- if (!pFormNode && pLayoutContext && pLayoutContext->m_pOverflowProcessor) {
- pFormNode = pLayoutContext->m_pOverflowNode;
- bUseInherited = true;
- }
- if (pThis->m_pPageMgr->ProcessOverflow(pFormNode, pOverflowLeaderNode,
- pOverflowTrailerNode, false,
- false)) {
- if (pProcessor->JudgeLeaderOrTrailerForOccur(pOverflowTrailerNode)) {
- if (pOverflowTrailerNode) {
- auto pOverflowLeaderProcessor =
- pdfium::MakeUnique<CXFA_ItemLayoutProcessor>(pOverflowTrailerNode,
- nullptr);
- pOverflowLeaderProcessor->DoLayout(false, FLT_MAX, FLT_MAX, nullptr);
- pTrailerLayoutItem =
- pOverflowLeaderProcessor->HasLayoutItem()
- ? pOverflowLeaderProcessor->ExtractLayoutItem()
- : nullptr;
- }
-
- bIsAddTrailerHeight =
- bUseInherited
- ? pThis->IsAddNewRowForTrailer(pTrailerLayoutItem)
- : pProcessor->IsAddNewRowForTrailer(pTrailerLayoutItem);
- if (bIsAddTrailerHeight) {
- childSize.height += pTrailerLayoutItem->m_sSize.height;
- bIsAddTrailerHeight = true;
- }
- }
- }
- }
-
- if (!bTakeSpace ||
- *fContentCurRowY + childSize.height <=
- fAvailHeight + XFA_LAYOUT_FLOAT_PERCISION ||
- (!bContainerHeightAutoSize &&
- pThis->m_fUsedSize + fAvailHeight + XFA_LAYOUT_FLOAT_PERCISION >=
- fContainerHeight)) {
- if (!bTakeSpace || eRetValue == XFA_ItemLayoutProcessorResult::Done) {
- if (pProcessor->m_bUseInheriated) {
- if (pTrailerLayoutItem)
- AddTrailerBeforeSplit(pProcessor, childSize.height,
- pTrailerLayoutItem, false);
- if (pProcessor->JudgeLeaderOrTrailerForOccur(pOverflowLeaderNode))
- AddPendingNode(pProcessor, pOverflowLeaderNode, false);
-
- pProcessor->m_bUseInheriated = false;
- } else {
- if (bIsAddTrailerHeight)
- childSize.height -= pTrailerLayoutItem->m_sSize.height;
-
- pProcessor->ProcessUnUseOverFlow(pOverflowLeaderNode,
- pOverflowTrailerNode,
- pTrailerLayoutItem, pFormNode);
- }
-
- CXFA_ContentLayoutItem* pChildLayoutItem =
- pProcessor->ExtractLayoutItem();
- if (ExistContainerKeep(pProcessor->m_pFormNode, false) &&
- pProcessor->m_pFormNode->GetIntact() == XFA_AttributeEnum::None) {
- pThis->m_arrayKeepItems.push_back(pChildLayoutItem);
- } else {
- pThis->m_arrayKeepItems.clear();
- }
- rgCurLineLayoutItems[uHAlign].push_back(pChildLayoutItem);
- *bAddedItemInRow = true;
- if (bTakeSpace) {
- *fContentCurRowAvailWidth -= childSize.width;
- *fContentCurRowHeight =
- std::max(*fContentCurRowHeight, childSize.height);
- }
- return XFA_ItemLayoutProcessorResult::Done;
- }
-
- if (eRetValue == XFA_ItemLayoutProcessorResult::PageFullBreak) {
- if (pProcessor->m_bUseInheriated) {
- if (pTrailerLayoutItem) {
- AddTrailerBeforeSplit(pProcessor, childSize.height,
- pTrailerLayoutItem, false);
- }
- if (pProcessor->JudgeLeaderOrTrailerForOccur(pOverflowLeaderNode))
- AddPendingNode(pProcessor, pOverflowLeaderNode, false);
-
- pProcessor->m_bUseInheriated = false;
- } else {
- if (bIsAddTrailerHeight)
- childSize.height -= pTrailerLayoutItem->m_sSize.height;
-
- pProcessor->ProcessUnUseOverFlow(pOverflowLeaderNode,
- pOverflowTrailerNode,
- pTrailerLayoutItem, pFormNode);
- }
- }
- rgCurLineLayoutItems[uHAlign].push_back(pProcessor->ExtractLayoutItem());
- *bAddedItemInRow = true;
- *fContentCurRowAvailWidth -= childSize.width;
- *fContentCurRowHeight = std::max(*fContentCurRowHeight, childSize.height);
- return eRetValue;
- }
-
- XFA_ItemLayoutProcessorResult eResult;
- if (pThis->ProcessKeepForSplit(
- pThis, pProcessor, eRetValue, &rgCurLineLayoutItems[uHAlign],
- fContentCurRowAvailWidth, fContentCurRowHeight, fContentCurRowY,
- bAddedItemInRow, bForceEndPage, &eResult)) {
- return eResult;
- }
-
- *bForceEndPage = true;
- float fSplitPos = pProcessor->FindSplitPos(fAvailHeight - *fContentCurRowY);
- if (fSplitPos > XFA_LAYOUT_FLOAT_PERCISION) {
- XFA_AttributeEnum eLayout =
- pProcessor->m_pFormNode->JSObject()->GetEnum(XFA_Attribute::Layout);
- if (eLayout == XFA_AttributeEnum::Tb &&
- eRetValue == XFA_ItemLayoutProcessorResult::Done) {
- pProcessor->ProcessUnUseOverFlow(pOverflowLeaderNode,
- pOverflowTrailerNode, pTrailerLayoutItem,
- pFormNode);
- rgCurLineLayoutItems[uHAlign].push_back(pProcessor->ExtractLayoutItem());
- *bAddedItemInRow = true;
- if (bTakeSpace) {
- *fContentCurRowAvailWidth -= childSize.width;
- *fContentCurRowHeight =
- std::max(*fContentCurRowHeight, childSize.height);
- }
- return XFA_ItemLayoutProcessorResult::PageFullBreak;
- }
-
- CXFA_Node* pTempLeaderNode = nullptr;
- CXFA_Node* pTempTrailerNode = nullptr;
- if (pThis->m_pPageMgr && !pProcessor->m_bUseInheriated &&
- eRetValue != XFA_ItemLayoutProcessorResult::PageFullBreak) {
- pThis->m_pPageMgr->ProcessOverflow(pFormNode, pTempLeaderNode,
- pTempTrailerNode, false, true);
- }
- if (pTrailerLayoutItem && bIsAddTrailerHeight) {
- AddTrailerBeforeSplit(pProcessor, fSplitPos, pTrailerLayoutItem,
- bUseInherited);
- } else {
- pProcessor->SplitLayoutItem(fSplitPos);
- }
-
- if (bUseInherited) {
- pProcessor->ProcessUnUseOverFlow(pOverflowLeaderNode,
- pOverflowTrailerNode, pTrailerLayoutItem,
- pFormNode);
- pThis->m_bUseInheriated = true;
- } else {
- CXFA_LayoutItem* firstChild = pProcessor->m_pLayoutItem->m_pFirstChild;
- if (firstChild && !firstChild->m_pNextSibling &&
- firstChild->m_pFormNode->IsLayoutGeneratedNode()) {
- pProcessor->ProcessUnUseOverFlow(pOverflowLeaderNode,
- pOverflowTrailerNode,
- pTrailerLayoutItem, pFormNode);
- } else if (pProcessor->JudgeLeaderOrTrailerForOccur(
- pOverflowLeaderNode)) {
- AddPendingNode(pProcessor, pOverflowLeaderNode, false);
- }
- }
-
- if (pProcessor->m_pLayoutItem->m_pNextSibling) {
- childSize = pProcessor->GetCurrentComponentSize();
- rgCurLineLayoutItems[uHAlign].push_back(pProcessor->ExtractLayoutItem());
- *bAddedItemInRow = true;
- if (bTakeSpace) {
- *fContentCurRowAvailWidth -= childSize.width;
- *fContentCurRowHeight =
- std::max(*fContentCurRowHeight, childSize.height);
- }
- }
- return XFA_ItemLayoutProcessorResult::PageFullBreak;
- }
-
- if (*fContentCurRowY <= XFA_LAYOUT_FLOAT_PERCISION) {
- childSize = pProcessor->GetCurrentComponentSize();
- if (pProcessor->m_pPageMgr->GetNextAvailContentHeight(childSize.height)) {
- CXFA_Node* pTempLeaderNode = nullptr;
- CXFA_Node* pTempTrailerNode = nullptr;
- if (pThis->m_pPageMgr) {
- if (!pFormNode && pLayoutContext)
- pFormNode = pLayoutContext->m_pOverflowProcessor->m_pFormNode;
-
- pThis->m_pPageMgr->ProcessOverflow(pFormNode, pTempLeaderNode,
- pTempTrailerNode, false, true);
- }
- if (bUseInherited) {
- pProcessor->ProcessUnUseOverFlow(pOverflowLeaderNode,
- pOverflowTrailerNode,
- pTrailerLayoutItem, pFormNode);
- pThis->m_bUseInheriated = true;
- }
- return XFA_ItemLayoutProcessorResult::PageFullBreak;
- }
-
- rgCurLineLayoutItems[uHAlign].push_back(pProcessor->ExtractLayoutItem());
- *bAddedItemInRow = true;
- if (bTakeSpace) {
- *fContentCurRowAvailWidth -= childSize.width;
- *fContentCurRowHeight = std::max(*fContentCurRowHeight, childSize.height);
- }
- if (eRetValue == XFA_ItemLayoutProcessorResult::Done)
- *bForceEndPage = false;
-
- return eRetValue;
- }
-
- XFA_AttributeEnum eLayout =
- pProcessor->m_pFormNode->JSObject()->GetEnum(XFA_Attribute::Layout);
- if (pProcessor->m_pFormNode->GetIntact() == XFA_AttributeEnum::None &&
- eLayout == XFA_AttributeEnum::Tb) {
- if (pThis->m_pPageMgr) {
- pThis->m_pPageMgr->ProcessOverflow(pFormNode, pOverflowLeaderNode,
- pOverflowTrailerNode, false, true);
- }
- if (pTrailerLayoutItem)
- AddTrailerBeforeSplit(pProcessor, fSplitPos, pTrailerLayoutItem, false);
- if (pProcessor->JudgeLeaderOrTrailerForOccur(pOverflowLeaderNode))
- AddPendingNode(pProcessor, pOverflowLeaderNode, false);
-
- return XFA_ItemLayoutProcessorResult::PageFullBreak;
- }
-
- if (eRetValue != XFA_ItemLayoutProcessorResult::Done)
- return XFA_ItemLayoutProcessorResult::PageFullBreak;
-
- if (!pFormNode && pLayoutContext)
- pFormNode = pLayoutContext->m_pOverflowProcessor->m_pFormNode;
- if (pThis->m_pPageMgr) {
- pThis->m_pPageMgr->ProcessOverflow(pFormNode, pOverflowLeaderNode,
- pOverflowTrailerNode, false, true);
- }
- if (bUseInherited) {
- pProcessor->ProcessUnUseOverFlow(pOverflowLeaderNode, pOverflowTrailerNode,
- pTrailerLayoutItem, pFormNode);
- pThis->m_bUseInheriated = true;
- }
- return XFA_ItemLayoutProcessorResult::PageFullBreak;
-}
-
bool FindLayoutItemSplitPos(CXFA_ContentLayoutItem* pLayoutItem,
float fCurVerticalOffset,
float* fProposedSplitPos,
@@ -1373,12 +854,12 @@ CXFA_ContentLayoutItem* CXFA_ItemLayoutProcessor::ExtractLayoutItem() {
void CXFA_ItemLayoutProcessor::GotoNextContainerNode(
CXFA_Node*& pCurActionNode,
- XFA_ItemLayoutProcessorStages& nCurStage,
+ XFA_ItemLayoutProcessorStages* nCurStage,
CXFA_Node* pParentContainer,
bool bUsePageBreak) {
CXFA_Node* pEntireContainer = pParentContainer;
CXFA_Node* pChildContainer = XFA_LAYOUT_INVALIDNODE;
- switch (nCurStage) {
+ switch (*nCurStage) {
case XFA_ItemLayoutProcessorStages::BreakBefore:
case XFA_ItemLayoutProcessorStages::BreakAfter: {
pChildContainer = pCurActionNode->GetParent();
@@ -1393,11 +874,11 @@ void CXFA_ItemLayoutProcessor::GotoNextContainerNode(
break;
}
- switch (nCurStage) {
+ switch (*nCurStage) {
case XFA_ItemLayoutProcessorStages::Keep: {
CXFA_Node* pBreakAfterNode = pChildContainer->GetFirstChild();
if (!m_bKeepBreakFinish &&
- FindBreakNode(pBreakAfterNode, pCurActionNode, &nCurStage, false)) {
+ FindBreakNode(pBreakAfterNode, pCurActionNode, nCurStage, false)) {
return;
}
goto CheckNextChildContainer;
@@ -1413,7 +894,7 @@ void CXFA_ItemLayoutProcessor::GotoNextContainerNode(
case XFA_Element::Bookend:
case XFA_Element::Break:
pCurActionNode = pBookendNode;
- nCurStage = XFA_ItemLayoutProcessorStages::BookendLeader;
+ *nCurStage = XFA_ItemLayoutProcessorStages::BookendLeader;
return;
default:
break;
@@ -1426,7 +907,7 @@ void CXFA_ItemLayoutProcessor::GotoNextContainerNode(
if (pCurActionNode != XFA_LAYOUT_INVALIDNODE) {
CXFA_Node* pBreakBeforeNode = pCurActionNode->GetNextSibling();
if (!m_bKeepBreakFinish &&
- FindBreakNode(pBreakBeforeNode, pCurActionNode, &nCurStage,
+ FindBreakNode(pBreakBeforeNode, pCurActionNode, nCurStage,
true)) {
return;
}
@@ -1438,7 +919,7 @@ void CXFA_ItemLayoutProcessor::GotoNextContainerNode(
goto CheckNextChildContainer;
}
pCurActionNode = pChildContainer;
- nCurStage = XFA_ItemLayoutProcessorStages::Container;
+ *nCurStage = XFA_ItemLayoutProcessorStages::Container;
return;
}
goto CheckNextChildContainer;
@@ -1449,13 +930,13 @@ void CXFA_ItemLayoutProcessor::GotoNextContainerNode(
if (pCurActionNode == XFA_LAYOUT_INVALIDNODE) {
CXFA_Node* pBreakAfterNode = pChildContainer->GetFirstChild();
if (!m_bKeepBreakFinish &&
- FindBreakNode(pBreakAfterNode, pCurActionNode, &nCurStage,
+ FindBreakNode(pBreakAfterNode, pCurActionNode, nCurStage,
false)) {
return;
}
} else {
CXFA_Node* pBreakAfterNode = pCurActionNode->GetNextSibling();
- if (FindBreakNode(pBreakAfterNode, pCurActionNode, &nCurStage,
+ if (FindBreakNode(pBreakAfterNode, pCurActionNode, nCurStage,
false)) {
return;
}
@@ -1486,14 +967,14 @@ void CXFA_ItemLayoutProcessor::GotoNextContainerNode(
}
if (!m_bKeepBreakFinish && !bLastKeep &&
FindBreakNode(pNextChildContainer->GetFirstChild(), pCurActionNode,
- &nCurStage, true)) {
+ nCurStage, true)) {
return;
}
pCurActionNode = pNextChildContainer;
if (m_bIsProcessKeep)
- nCurStage = XFA_ItemLayoutProcessorStages::Keep;
+ *nCurStage = XFA_ItemLayoutProcessorStages::Keep;
else
- nCurStage = XFA_ItemLayoutProcessorStages::Container;
+ *nCurStage = XFA_ItemLayoutProcessorStages::Container;
return;
}
@@ -1508,7 +989,7 @@ void CXFA_ItemLayoutProcessor::GotoNextContainerNode(
case XFA_Element::Bookend:
case XFA_Element::Break:
pCurActionNode = pBookendNode;
- nCurStage = XFA_ItemLayoutProcessorStages::BookendTrailer;
+ *nCurStage = XFA_ItemLayoutProcessorStages::BookendTrailer;
return;
default:
break;
@@ -1517,13 +998,13 @@ void CXFA_ItemLayoutProcessor::GotoNextContainerNode(
}
default:
pCurActionNode = nullptr;
- nCurStage = XFA_ItemLayoutProcessorStages::Done;
+ *nCurStage = XFA_ItemLayoutProcessorStages::Done;
}
}
bool CXFA_ItemLayoutProcessor::ProcessKeepNodesForCheckNext(
CXFA_Node*& pCurActionNode,
- XFA_ItemLayoutProcessorStages& nCurStage,
+ XFA_ItemLayoutProcessorStages* nCurStage,
CXFA_Node*& pNextContainer,
bool& bLastKeepNode) {
const bool bCanSplit = pNextContainer->GetIntact() == XFA_AttributeEnum::None;
@@ -1541,9 +1022,8 @@ bool CXFA_ItemLayoutProcessor::ProcessKeepNodesForCheckNext(
if (m_bIsProcessKeep && m_pKeepHeadNode) {
m_pKeepTailNode = pNextContainer;
- if (!m_bKeepBreakFinish &&
- FindBreakNode(pNextContainer->GetFirstChild(), pCurActionNode,
- &nCurStage, true)) {
+ if (!m_bKeepBreakFinish && FindBreakNode(pNextContainer->GetFirstChild(),
+ pCurActionNode, nCurStage, true)) {
return true;
}
@@ -1563,7 +1043,7 @@ bool CXFA_ItemLayoutProcessor::ProcessKeepNodesForCheckNext(
bool CXFA_ItemLayoutProcessor::ProcessKeepNodesForBreakBefore(
CXFA_Node*& pCurActionNode,
- XFA_ItemLayoutProcessorStages& nCurStage,
+ XFA_ItemLayoutProcessorStages* nCurStage,
CXFA_Node* pContainerNode) {
if (m_pKeepTailNode == pContainerNode) {
pCurActionNode = m_pKeepHeadNode;
@@ -1571,19 +1051,12 @@ bool CXFA_ItemLayoutProcessor::ProcessKeepNodesForBreakBefore(
m_pKeepHeadNode = nullptr;
m_pKeepTailNode = nullptr;
m_bIsProcessKeep = false;
- nCurStage = XFA_ItemLayoutProcessorStages::Container;
+ *nCurStage = XFA_ItemLayoutProcessorStages::Container;
return true;
}
CXFA_Node* pBreakAfterNode = pContainerNode->GetFirstChild();
- return FindBreakNode(pBreakAfterNode, pCurActionNode, &nCurStage, false);
-}
-
-bool CXFA_ItemLayoutProcessor::IncrementRelayoutNode(
- CXFA_LayoutProcessor* pLayoutProcessor,
- CXFA_Node* pNode,
- CXFA_Node* pParentNode) {
- return false;
+ return FindBreakNode(pBreakAfterNode, pCurActionNode, nCurStage, false);
}
void CXFA_ItemLayoutProcessor::DoLayoutPageArea(
@@ -1593,9 +1066,9 @@ void CXFA_ItemLayoutProcessor::DoLayoutPageArea(
XFA_ItemLayoutProcessorStages nCurChildNodeStage =
XFA_ItemLayoutProcessorStages::None;
CXFA_LayoutItem* pBeforeItem = nullptr;
- for (GotoNextContainerNode(pCurChildNode, nCurChildNodeStage, pFormNode,
+ for (GotoNextContainerNode(pCurChildNode, &nCurChildNodeStage, pFormNode,
false);
- pCurChildNode; GotoNextContainerNode(pCurChildNode, nCurChildNodeStage,
+ pCurChildNode; GotoNextContainerNode(pCurChildNode, &nCurChildNodeStage,
pFormNode, false)) {
if (nCurChildNodeStage != XFA_ItemLayoutProcessorStages::Container)
continue;
@@ -1662,13 +1135,13 @@ void CXFA_ItemLayoutProcessor::DoLayoutPositionedContainer(
float fHiddenContentCalculatedWidth = 0;
float fHiddenContentCalculatedHeight = 0;
if (m_pCurChildNode == XFA_LAYOUT_INVALIDNODE) {
- GotoNextContainerNode(m_pCurChildNode, m_nCurChildNodeStage, m_pFormNode,
+ GotoNextContainerNode(m_pCurChildNode, &m_nCurChildNodeStage, m_pFormNode,
false);
}
int32_t iColIndex = 0;
for (; m_pCurChildNode; GotoNextContainerNode(
- m_pCurChildNode, m_nCurChildNodeStage, m_pFormNode, false)) {
+ m_pCurChildNode, &m_nCurChildNodeStage, m_pFormNode, false)) {
if (m_nCurChildNodeStage != XFA_ItemLayoutProcessorStages::Container)
continue;
if (m_pCurChildNode->GetElementType() == XFA_Element::Variables)
@@ -1806,12 +1279,12 @@ void CXFA_ItemLayoutProcessor::DoLayoutTableContainer(CXFA_Node* pLayoutNode) {
CXFA_LayoutContext* pLayoutContext =
iSpecifiedColumnCount > 0 ? &layoutContext : nullptr;
if (m_pCurChildNode == XFA_LAYOUT_INVALIDNODE) {
- GotoNextContainerNode(m_pCurChildNode, m_nCurChildNodeStage, m_pFormNode,
+ GotoNextContainerNode(m_pCurChildNode, &m_nCurChildNodeStage, m_pFormNode,
false);
}
for (; m_pCurChildNode; GotoNextContainerNode(
- m_pCurChildNode, m_nCurChildNodeStage, m_pFormNode, false)) {
+ m_pCurChildNode, &m_nCurChildNodeStage, m_pFormNode, false)) {
layoutContext.m_bCurColumnWidthAvaiable = false;
layoutContext.m_fCurColumnWidth = 0;
if (m_nCurChildNodeStage != XFA_ItemLayoutProcessorStages::Container)
@@ -1889,8 +1362,9 @@ void CXFA_ItemLayoutProcessor::DoLayoutTableContainer(CXFA_Node* pLayoutNode) {
continue;
if (iColCount >= iSpecifiedColumnCount) {
- int32_t c = iColCount + 1 - pdfium::CollectionSize<int32_t>(
- m_rgSpecifiedColumnWidths);
+ int32_t c =
+ iColCount + 1 -
+ pdfium::CollectionSize<int32_t>(m_rgSpecifiedColumnWidths);
for (int32_t j = 0; j < c; j++)
m_rgSpecifiedColumnWidths.push_back(0);
}
@@ -2003,7 +1477,7 @@ float CXFA_ItemLayoutProcessor::InsertKeepLayoutItems() {
float fTotalHeight = 0;
for (auto iter = m_arrayKeepItems.rbegin(); iter != m_arrayKeepItems.rend();
iter++) {
- AddLeaderAfterSplit(this, *iter);
+ AddLeaderAfterSplit(*iter);
fTotalHeight += (*iter)->m_sSize.height;
}
m_arrayKeepItems.clear();
@@ -2012,7 +1486,6 @@ float CXFA_ItemLayoutProcessor::InsertKeepLayoutItems() {
}
bool CXFA_ItemLayoutProcessor::ProcessKeepForSplit(
- CXFA_ItemLayoutProcessor* pParentProcessor,
CXFA_ItemLayoutProcessor* pChildProcessor,
XFA_ItemLayoutProcessorResult eRetValue,
std::vector<CXFA_ContentLayoutItem*>* rgCurLineLayoutItem,
@@ -2022,25 +1495,23 @@ bool CXFA_ItemLayoutProcessor::ProcessKeepForSplit(
bool* bAddedItemInRow,
bool* bForceEndPage,
XFA_ItemLayoutProcessorResult* result) {
- if (!pParentProcessor || !pChildProcessor)
+ if (!pChildProcessor)
return false;
- if (pParentProcessor->m_pCurChildNode->GetIntact() ==
- XFA_AttributeEnum::None &&
+ if (m_pCurChildNode->GetIntact() == XFA_AttributeEnum::None &&
pChildProcessor->m_bHasAvailHeight)
return false;
- if (!ExistContainerKeep(pParentProcessor->m_pCurChildNode, true))
+ if (!ExistContainerKeep(m_pCurChildNode, true))
return false;
CFX_SizeF childSize = pChildProcessor->GetCurrentComponentSize();
std::vector<CXFA_ContentLayoutItem*> keepLayoutItems;
- if (pParentProcessor->JudgePutNextPage(pParentProcessor->m_pLayoutItem,
- childSize.height, &keepLayoutItems)) {
+ if (JudgePutNextPage(m_pLayoutItem, childSize.height, &keepLayoutItems)) {
m_arrayKeepItems.clear();
for (auto* item : keepLayoutItems) {
- pParentProcessor->m_pLayoutItem->RemoveChild(item);
+ m_pLayoutItem->RemoveChild(item);
*fContentCurRowY -= item->m_sSize.height;
m_arrayKeepItems.push_back(item);
}
@@ -2232,11 +1703,11 @@ XFA_ItemLayoutProcessorResult CXFA_ItemLayoutProcessor::DoLayoutFlowedContainer(
fContentCurRowY += InsertKeepLayoutItems();
if (m_nCurChildNodeStage == XFA_ItemLayoutProcessorStages::None) {
- GotoNextContainerNode(m_pCurChildNode, m_nCurChildNodeStage, m_pFormNode,
+ GotoNextContainerNode(m_pCurChildNode, &m_nCurChildNodeStage, m_pFormNode,
true);
}
- fContentCurRowY += InsertPendingItems(this, m_pFormNode);
+ fContentCurRowY += InsertPendingItems(m_pFormNode);
if (m_pCurChildPreprocessor &&
m_nCurChildNodeStage == XFA_ItemLayoutProcessorStages::Container) {
if (ExistContainerKeep(m_pCurChildPreprocessor->GetFormNode(), false)) {
@@ -2311,7 +1782,7 @@ XFA_ItemLayoutProcessorResult CXFA_ItemLayoutProcessor::DoLayoutFlowedContainer(
while (m_pCurChildNode) {
std::unique_ptr<CXFA_ItemLayoutProcessor> pProcessor;
bool bAddedItemInRow = false;
- fContentCurRowY += InsertPendingItems(this, m_pFormNode);
+ fContentCurRowY += InsertPendingItems(m_pFormNode);
switch (m_nCurChildNodeStage) {
case XFA_ItemLayoutProcessorStages::Keep:
case XFA_ItemLayoutProcessorStages::None:
@@ -2335,19 +1806,19 @@ XFA_ItemLayoutProcessorResult CXFA_ItemLayoutProcessor::DoLayoutFlowedContainer(
}
if (JudgeLeaderOrTrailerForOccur(pLeaderNode))
- AddPendingNode(this, pLeaderNode, true);
+ AddPendingNode(pLeaderNode, true);
if (JudgeLeaderOrTrailerForOccur(pTrailerNode)) {
if (m_pFormNode->GetParent()->GetElementType() ==
XFA_Element::Form &&
!m_pLayoutItem) {
- AddPendingNode(this, pTrailerNode, true);
+ AddPendingNode(pTrailerNode, true);
} else {
auto pTempProcessor =
pdfium::MakeUnique<CXFA_ItemLayoutProcessor>(pTrailerNode,
nullptr);
InsertFlowedItem(
- this, pTempProcessor.get(), bContainerWidthAutoSize,
+ pTempProcessor.get(), bContainerWidthAutoSize,
bContainerHeightAutoSize, containerSize.height, eFlowStrategy,
&uCurHAlignState, rgCurLineLayoutItems, false, FLT_MAX,
FLT_MAX, fContentWidthLimit, &fContentCurRowY,
@@ -2355,7 +1826,7 @@ XFA_ItemLayoutProcessorResult CXFA_ItemLayoutProcessor::DoLayoutFlowedContainer(
&bAddedItemInRow, &bForceEndPage, pContext, false);
}
}
- GotoNextContainerNode(m_pCurChildNode, m_nCurChildNodeStage,
+ GotoNextContainerNode(m_pCurChildNode, &m_nCurChildNodeStage,
m_pFormNode, true);
bForceEndPage = true;
bIsManualBreak = true;
@@ -2376,13 +1847,13 @@ XFA_ItemLayoutProcessorResult CXFA_ItemLayoutProcessor::DoLayoutFlowedContainer(
if (JudgeLeaderOrTrailerForOccur(pTrailerNode)) {
auto pTempProcessor = pdfium::MakeUnique<CXFA_ItemLayoutProcessor>(
pTrailerNode, nullptr);
- InsertFlowedItem(
- this, pTempProcessor.get(), bContainerWidthAutoSize,
- bContainerHeightAutoSize, containerSize.height, eFlowStrategy,
- &uCurHAlignState, rgCurLineLayoutItems, false, FLT_MAX, FLT_MAX,
- fContentWidthLimit, &fContentCurRowY, &fContentCurRowAvailWidth,
- &fContentCurRowHeight, &bAddedItemInRow, &bForceEndPage,
- pContext, false);
+ InsertFlowedItem(pTempProcessor.get(), bContainerWidthAutoSize,
+ bContainerHeightAutoSize, containerSize.height,
+ eFlowStrategy, &uCurHAlignState,
+ rgCurLineLayoutItems, false, FLT_MAX, FLT_MAX,
+ fContentWidthLimit, &fContentCurRowY,
+ &fContentCurRowAvailWidth, &fContentCurRowHeight,
+ &bAddedItemInRow, &bForceEndPage, pContext, false);
}
if (!bCreatePage) {
if (JudgeLeaderOrTrailerForOccur(pLeaderNode)) {
@@ -2396,7 +1867,7 @@ XFA_ItemLayoutProcessorResult CXFA_ItemLayoutProcessor::DoLayoutFlowedContainer(
pdfium::MakeUnique<CXFA_ItemLayoutProcessor>(pLeaderNode,
nullptr);
InsertFlowedItem(
- this, pTempProcessor.get(), bContainerWidthAutoSize,
+ pTempProcessor.get(), bContainerWidthAutoSize,
bContainerHeightAutoSize, containerSize.height, eFlowStrategy,
&uCurHAlignState, rgCurLineLayoutItems, false, FLT_MAX,
FLT_MAX, fContentWidthLimit, &fContentCurRowY,
@@ -2405,10 +1876,10 @@ XFA_ItemLayoutProcessorResult CXFA_ItemLayoutProcessor::DoLayoutFlowedContainer(
}
} else {
if (JudgeLeaderOrTrailerForOccur(pLeaderNode))
- AddPendingNode(this, pLeaderNode, true);
+ AddPendingNode(pLeaderNode, true);
}
- GotoNextContainerNode(m_pCurChildNode, m_nCurChildNodeStage,
+ GotoNextContainerNode(m_pCurChildNode, &m_nCurChildNodeStage,
m_pFormNode, true);
if (bCreatePage) {
bForceEndPage = true;
@@ -2423,23 +1894,22 @@ XFA_ItemLayoutProcessorResult CXFA_ItemLayoutProcessor::DoLayoutFlowedContainer(
if (m_pCurChildPreprocessor) {
pProcessor.reset(m_pCurChildPreprocessor);
m_pCurChildPreprocessor = nullptr;
- } else if (m_pPageMgr &&
- m_pPageMgr->ProcessBookendLeaderOrTrailer(
- m_pCurChildNode, true, pLeaderNode)) {
+ } else if (m_pPageMgr && m_pPageMgr->ProcessBookendLeaderOrTrailer(
+ m_pCurChildNode, true, pLeaderNode)) {
pProcessor = pdfium::MakeUnique<CXFA_ItemLayoutProcessor>(
pLeaderNode, m_pPageMgr);
}
if (pProcessor) {
- if (InsertFlowedItem(
- this, pProcessor.get(), bContainerWidthAutoSize,
- bContainerHeightAutoSize, containerSize.height,
- eFlowStrategy, &uCurHAlignState, rgCurLineLayoutItems,
- bUseBreakControl, fAvailHeight, fRealHeight,
- fContentWidthLimit, &fContentCurRowY,
- &fContentCurRowAvailWidth, &fContentCurRowHeight,
- &bAddedItemInRow, &bForceEndPage, pContext,
- false) != XFA_ItemLayoutProcessorResult::Done) {
+ if (InsertFlowedItem(pProcessor.get(), bContainerWidthAutoSize,
+ bContainerHeightAutoSize, containerSize.height,
+ eFlowStrategy, &uCurHAlignState,
+ rgCurLineLayoutItems, bUseBreakControl,
+ fAvailHeight, fRealHeight, fContentWidthLimit,
+ &fContentCurRowY, &fContentCurRowAvailWidth,
+ &fContentCurRowHeight, &bAddedItemInRow,
+ &bForceEndPage, pContext, false) !=
+ XFA_ItemLayoutProcessorResult::Done) {
goto SuspendAndCreateNewRow;
} else {
pProcessor.reset();
@@ -2452,22 +1922,21 @@ XFA_ItemLayoutProcessorResult CXFA_ItemLayoutProcessor::DoLayoutFlowedContainer(
if (m_pCurChildPreprocessor) {
pProcessor.reset(m_pCurChildPreprocessor);
m_pCurChildPreprocessor = nullptr;
- } else if (m_pPageMgr &&
- m_pPageMgr->ProcessBookendLeaderOrTrailer(
- m_pCurChildNode, false, pTrailerNode)) {
+ } else if (m_pPageMgr && m_pPageMgr->ProcessBookendLeaderOrTrailer(
+ m_pCurChildNode, false, pTrailerNode)) {
pProcessor = pdfium::MakeUnique<CXFA_ItemLayoutProcessor>(
pTrailerNode, m_pPageMgr);
}
if (pProcessor) {
- if (InsertFlowedItem(
- this, pProcessor.get(), bContainerWidthAutoSize,
- bContainerHeightAutoSize, containerSize.height,
- eFlowStrategy, &uCurHAlignState, rgCurLineLayoutItems,
- bUseBreakControl, fAvailHeight, fRealHeight,
- fContentWidthLimit, &fContentCurRowY,
- &fContentCurRowAvailWidth, &fContentCurRowHeight,
- &bAddedItemInRow, &bForceEndPage, pContext,
- false) != XFA_ItemLayoutProcessorResult::Done) {
+ if (InsertFlowedItem(pProcessor.get(), bContainerWidthAutoSize,
+ bContainerHeightAutoSize, containerSize.height,
+ eFlowStrategy, &uCurHAlignState,
+ rgCurLineLayoutItems, bUseBreakControl,
+ fAvailHeight, fRealHeight, fContentWidthLimit,
+ &fContentCurRowY, &fContentCurRowAvailWidth,
+ &fContentCurRowHeight, &bAddedItemInRow,
+ &bForceEndPage, pContext, false) !=
+ XFA_ItemLayoutProcessorResult::Done) {
goto SuspendAndCreateNewRow;
} else {
pProcessor.reset();
@@ -2497,9 +1966,9 @@ XFA_ItemLayoutProcessorResult CXFA_ItemLayoutProcessor::DoLayoutFlowedContainer(
m_pCurChildNode, m_pPageMgr);
}
- InsertPendingItems(pProcessor.get(), m_pCurChildNode);
+ pProcessor->InsertPendingItems(m_pCurChildNode);
XFA_ItemLayoutProcessorResult rs = InsertFlowedItem(
- this, pProcessor.get(), bContainerWidthAutoSize,
+ pProcessor.get(), bContainerWidthAutoSize,
bContainerHeightAutoSize, containerSize.height, eFlowStrategy,
&uCurHAlignState, rgCurLineLayoutItems, bUseBreakControl,
fAvailHeight, fRealHeight, fContentWidthLimit, &fContentCurRowY,
@@ -2515,7 +1984,7 @@ XFA_ItemLayoutProcessorResult CXFA_ItemLayoutProcessor::DoLayoutFlowedContainer(
case XFA_ItemLayoutProcessorResult::Done:
default:
fContentCurRowY +=
- InsertPendingItems(pProcessor.get(), m_pCurChildNode);
+ pProcessor->InsertPendingItems(m_pCurChildNode);
pProcessor.reset();
}
break;
@@ -2525,7 +1994,7 @@ XFA_ItemLayoutProcessorResult CXFA_ItemLayoutProcessor::DoLayoutFlowedContainer(
default:
break;
}
- GotoNextContainerNode(m_pCurChildNode, m_nCurChildNodeStage, m_pFormNode,
+ GotoNextContainerNode(m_pCurChildNode, &m_nCurChildNodeStage, m_pFormNode,
true);
if (bAddedItemInRow && eFlowStrategy == XFA_AttributeEnum::Tb)
break;
@@ -2822,3 +2291,512 @@ bool CXFA_ItemLayoutProcessor::JudgeLeaderOrTrailerForOccur(
m_PendingNodesCount[pTemplate] = iCount + 1;
return true;
}
+
+void CXFA_ItemLayoutProcessor::UpdatePendingItemLayout(
+ CXFA_ContentLayoutItem* pLayoutItem) {
+ XFA_AttributeEnum eLayout =
+ pLayoutItem->m_pFormNode->JSObject()->GetEnum(XFA_Attribute::Layout);
+ switch (eLayout) {
+ case XFA_AttributeEnum::Row:
+ case XFA_AttributeEnum::Rl_row:
+ RelocateTableRowCells(pLayoutItem, m_rgSpecifiedColumnWidths, eLayout);
+ break;
+ default:
+ break;
+ }
+}
+
+void CXFA_ItemLayoutProcessor::AddTrailerBeforeSplit(
+ float fSplitPos,
+ CXFA_ContentLayoutItem* pTrailerLayoutItem,
+ bool bUseInherited) {
+ if (!pTrailerLayoutItem)
+ return;
+
+ float fHeight = pTrailerLayoutItem->m_sSize.height;
+ if (bUseInherited) {
+ float fNewSplitPos = 0;
+ if (fSplitPos - fHeight > XFA_LAYOUT_FLOAT_PERCISION)
+ fNewSplitPos = FindSplitPos(fSplitPos - fHeight);
+ if (fNewSplitPos > XFA_LAYOUT_FLOAT_PERCISION)
+ SplitLayoutItem(fNewSplitPos);
+ return;
+ }
+
+ UpdatePendingItemLayout(pTrailerLayoutItem);
+ CXFA_Margin* pMarginNode =
+ m_pFormNode->GetFirstChildByClass<CXFA_Margin>(XFA_Element::Margin);
+ float fLeftInset = 0;
+ float fTopInset = 0;
+ float fRightInset = 0;
+ float fBottomInset = 0;
+ if (pMarginNode) {
+ fLeftInset = pMarginNode->JSObject()
+ ->GetMeasure(XFA_Attribute::LeftInset)
+ .ToUnit(XFA_Unit::Pt);
+ fTopInset = pMarginNode->JSObject()
+ ->GetMeasure(XFA_Attribute::TopInset)
+ .ToUnit(XFA_Unit::Pt);
+ fRightInset = pMarginNode->JSObject()
+ ->GetMeasure(XFA_Attribute::RightInset)
+ .ToUnit(XFA_Unit::Pt);
+ fBottomInset = pMarginNode->JSObject()
+ ->GetMeasure(XFA_Attribute::BottomInset)
+ .ToUnit(XFA_Unit::Pt);
+ }
+
+ if (!IsAddNewRowForTrailer(pTrailerLayoutItem)) {
+ pTrailerLayoutItem->m_sPos.y = m_fLastRowY;
+ pTrailerLayoutItem->m_sPos.x = m_fLastRowWidth;
+ m_pLayoutItem->m_sSize.width += pTrailerLayoutItem->m_sSize.width;
+ m_pLayoutItem->AddChild(pTrailerLayoutItem);
+ return;
+ }
+
+ float fNewSplitPos = 0;
+ if (fSplitPos - fHeight > XFA_LAYOUT_FLOAT_PERCISION)
+ fNewSplitPos = FindSplitPos(fSplitPos - fHeight);
+
+ if (fNewSplitPos > XFA_LAYOUT_FLOAT_PERCISION) {
+ SplitLayoutItem(fNewSplitPos);
+ pTrailerLayoutItem->m_sPos.y = fNewSplitPos - fTopInset - fBottomInset;
+ } else {
+ pTrailerLayoutItem->m_sPos.y = fSplitPos - fTopInset - fBottomInset;
+ }
+
+ switch (pTrailerLayoutItem->m_pFormNode->JSObject()->GetEnum(
+ XFA_Attribute::HAlign)) {
+ case XFA_AttributeEnum::Right:
+ pTrailerLayoutItem->m_sPos.x = m_pLayoutItem->m_sSize.width -
+ fRightInset -
+ pTrailerLayoutItem->m_sSize.width;
+ break;
+ case XFA_AttributeEnum::Center:
+ pTrailerLayoutItem->m_sPos.x =
+ (m_pLayoutItem->m_sSize.width - fLeftInset - fRightInset -
+ pTrailerLayoutItem->m_sSize.width) /
+ 2;
+ break;
+ case XFA_AttributeEnum::Left:
+ default:
+ pTrailerLayoutItem->m_sPos.x = fLeftInset;
+ break;
+ }
+ m_pLayoutItem->m_sSize.height += fHeight;
+ m_pLayoutItem->AddChild(pTrailerLayoutItem);
+}
+
+void CXFA_ItemLayoutProcessor::AddLeaderAfterSplit(
+ CXFA_ContentLayoutItem* pLeaderLayoutItem) {
+ UpdatePendingItemLayout(pLeaderLayoutItem);
+
+ CXFA_Margin* pMarginNode =
+ m_pFormNode->GetFirstChildByClass<CXFA_Margin>(XFA_Element::Margin);
+ float fLeftInset = 0;
+ float fRightInset = 0;
+ if (pMarginNode) {
+ fLeftInset = pMarginNode->JSObject()
+ ->GetMeasure(XFA_Attribute::LeftInset)
+ .ToUnit(XFA_Unit::Pt);
+ fRightInset = pMarginNode->JSObject()
+ ->GetMeasure(XFA_Attribute::RightInset)
+ .ToUnit(XFA_Unit::Pt);
+ }
+
+ float fHeight = pLeaderLayoutItem->m_sSize.height;
+ for (CXFA_ContentLayoutItem* pChildItem =
+ (CXFA_ContentLayoutItem*)m_pLayoutItem->m_pFirstChild;
+ pChildItem;
+ pChildItem = (CXFA_ContentLayoutItem*)pChildItem->m_pNextSibling) {
+ pChildItem->m_sPos.y += fHeight;
+ }
+ pLeaderLayoutItem->m_sPos.y = 0;
+
+ switch (pLeaderLayoutItem->m_pFormNode->JSObject()->GetEnum(
+ XFA_Attribute::HAlign)) {
+ case XFA_AttributeEnum::Right:
+ pLeaderLayoutItem->m_sPos.x = m_pLayoutItem->m_sSize.width - fRightInset -
+ pLeaderLayoutItem->m_sSize.width;
+ break;
+ case XFA_AttributeEnum::Center:
+ pLeaderLayoutItem->m_sPos.x =
+ (m_pLayoutItem->m_sSize.width - fLeftInset - fRightInset -
+ pLeaderLayoutItem->m_sSize.width) /
+ 2;
+ break;
+ case XFA_AttributeEnum::Left:
+ default:
+ pLeaderLayoutItem->m_sPos.x = fLeftInset;
+ break;
+ }
+ m_pLayoutItem->m_sSize.height += fHeight;
+ m_pLayoutItem->AddChild(pLeaderLayoutItem);
+}
+
+void CXFA_ItemLayoutProcessor::AddPendingNode(CXFA_Node* pPendingNode,
+ bool bBreakPending) {
+ m_PendingNodes.push_back(pPendingNode);
+ m_bBreakPending = bBreakPending;
+}
+
+float CXFA_ItemLayoutProcessor::InsertPendingItems(CXFA_Node* pCurChildNode) {
+ float fTotalHeight = 0;
+ if (m_PendingNodes.empty())
+ return fTotalHeight;
+
+ if (!m_pLayoutItem) {
+ m_pLayoutItem = CreateContentLayoutItem(pCurChildNode);
+ m_pLayoutItem->m_sSize.clear();
+ }
+
+ while (!m_PendingNodes.empty()) {
+ auto pPendingProcessor = pdfium::MakeUnique<CXFA_ItemLayoutProcessor>(
+ m_PendingNodes.front(), nullptr);
+ m_PendingNodes.pop_front();
+ pPendingProcessor->DoLayout(false, FLT_MAX, FLT_MAX, nullptr);
+ CXFA_ContentLayoutItem* pPendingLayoutItem =
+ pPendingProcessor->HasLayoutItem()
+ ? pPendingProcessor->ExtractLayoutItem()
+ : nullptr;
+ if (pPendingLayoutItem) {
+ AddLeaderAfterSplit(pPendingLayoutItem);
+ if (m_bBreakPending)
+ fTotalHeight += pPendingLayoutItem->m_sSize.height;
+ }
+ }
+ return fTotalHeight;
+}
+
+XFA_ItemLayoutProcessorResult CXFA_ItemLayoutProcessor::InsertFlowedItem(
+ CXFA_ItemLayoutProcessor* pProcessor,
+ bool bContainerWidthAutoSize,
+ bool bContainerHeightAutoSize,
+ float fContainerHeight,
+ XFA_AttributeEnum eFlowStrategy,
+ uint8_t* uCurHAlignState,
+ std::vector<CXFA_ContentLayoutItem*> (&rgCurLineLayoutItems)[3],
+ bool bUseBreakControl,
+ float fAvailHeight,
+ float fRealHeight,
+ float fContentWidthLimit,
+ float* fContentCurRowY,
+ float* fContentCurRowAvailWidth,
+ float* fContentCurRowHeight,
+ bool* bAddedItemInRow,
+ bool* bForceEndPage,
+ CXFA_LayoutContext* pLayoutContext,
+ bool bNewRow) {
+ bool bTakeSpace = pProcessor->m_pFormNode->PresenceRequiresSpace();
+ uint8_t uHAlign = HAlignEnumToInt(
+ m_pCurChildNode->JSObject()->GetEnum(XFA_Attribute::HAlign));
+ if (bContainerWidthAutoSize)
+ uHAlign = 0;
+
+ if ((eFlowStrategy != XFA_AttributeEnum::Rl_tb &&
+ uHAlign < *uCurHAlignState) ||
+ (eFlowStrategy == XFA_AttributeEnum::Rl_tb &&
+ uHAlign > *uCurHAlignState)) {
+ return XFA_ItemLayoutProcessorResult::RowFullBreak;
+ }
+
+ *uCurHAlignState = uHAlign;
+ bool bIsOwnSplit =
+ pProcessor->m_pFormNode->GetIntact() == XFA_AttributeEnum::None;
+ bool bUseRealHeight = bTakeSpace && bContainerHeightAutoSize && bIsOwnSplit &&
+ pProcessor->m_pFormNode->GetParent()->GetIntact() ==
+ XFA_AttributeEnum::None;
+ bool bIsTransHeight = bTakeSpace;
+ if (bIsTransHeight && !bIsOwnSplit) {
+ bool bRootForceTb = false;
+ XFA_AttributeEnum eLayoutStrategy =
+ GetLayout(pProcessor->m_pFormNode, &bRootForceTb);
+ if (eLayoutStrategy == XFA_AttributeEnum::Lr_tb ||
+ eLayoutStrategy == XFA_AttributeEnum::Rl_tb) {
+ bIsTransHeight = false;
+ }
+ }
+
+ bool bUseInherited = false;
+ CXFA_LayoutContext layoutContext;
+ if (m_pPageMgr) {
+ CXFA_Node* pOverflowNode = m_pPageMgr->QueryOverflow(m_pFormNode);
+ if (pOverflowNode) {
+ layoutContext.m_pOverflowNode = pOverflowNode;
+ layoutContext.m_pOverflowProcessor = this;
+ pLayoutContext = &layoutContext;
+ }
+ }
+
+ XFA_ItemLayoutProcessorResult eRetValue = XFA_ItemLayoutProcessorResult::Done;
+ if (!bNewRow ||
+ pProcessor->m_ePreProcessRs == XFA_ItemLayoutProcessorResult::Done) {
+ eRetValue = pProcessor->DoLayout(
+ bTakeSpace ? bUseBreakControl : false,
+ bUseRealHeight ? fRealHeight - *fContentCurRowY : FLT_MAX,
+ bIsTransHeight ? fRealHeight - *fContentCurRowY : FLT_MAX,
+ pLayoutContext);
+ pProcessor->m_ePreProcessRs = eRetValue;
+ } else {
+ eRetValue = pProcessor->m_ePreProcessRs;
+ pProcessor->m_ePreProcessRs = XFA_ItemLayoutProcessorResult::Done;
+ }
+ if (pProcessor->HasLayoutItem() == false)
+ return eRetValue;
+
+ CFX_SizeF childSize = pProcessor->GetCurrentComponentSize();
+ if (bUseRealHeight && fRealHeight < XFA_LAYOUT_FLOAT_PERCISION) {
+ fRealHeight = FLT_MAX;
+ fAvailHeight = FLT_MAX;
+ }
+ if (bTakeSpace &&
+ (childSize.width >
+ *fContentCurRowAvailWidth + XFA_LAYOUT_FLOAT_PERCISION) &&
+ (fContentWidthLimit - *fContentCurRowAvailWidth >
+ XFA_LAYOUT_FLOAT_PERCISION)) {
+ return XFA_ItemLayoutProcessorResult::RowFullBreak;
+ }
+
+ CXFA_Node* pOverflowLeaderNode = nullptr;
+ CXFA_Node* pOverflowTrailerNode = nullptr;
+ CXFA_Node* pFormNode = nullptr;
+ CXFA_ContentLayoutItem* pTrailerLayoutItem = nullptr;
+ bool bIsAddTrailerHeight = false;
+ if (m_pPageMgr &&
+ pProcessor->m_pFormNode->GetIntact() == XFA_AttributeEnum::None) {
+ pFormNode = m_pPageMgr->QueryOverflow(pProcessor->m_pFormNode);
+ if (!pFormNode && pLayoutContext && pLayoutContext->m_pOverflowProcessor) {
+ pFormNode = pLayoutContext->m_pOverflowNode;
+ bUseInherited = true;
+ }
+ if (m_pPageMgr->ProcessOverflow(pFormNode, pOverflowLeaderNode,
+ pOverflowTrailerNode, false, false)) {
+ if (pProcessor->JudgeLeaderOrTrailerForOccur(pOverflowTrailerNode)) {
+ if (pOverflowTrailerNode) {
+ auto pOverflowLeaderProcessor =
+ pdfium::MakeUnique<CXFA_ItemLayoutProcessor>(pOverflowTrailerNode,
+ nullptr);
+ pOverflowLeaderProcessor->DoLayout(false, FLT_MAX, FLT_MAX, nullptr);
+ pTrailerLayoutItem =
+ pOverflowLeaderProcessor->HasLayoutItem()
+ ? pOverflowLeaderProcessor->ExtractLayoutItem()
+ : nullptr;
+ }
+
+ bIsAddTrailerHeight =
+ bUseInherited
+ ? IsAddNewRowForTrailer(pTrailerLayoutItem)
+ : pProcessor->IsAddNewRowForTrailer(pTrailerLayoutItem);
+ if (bIsAddTrailerHeight) {
+ childSize.height += pTrailerLayoutItem->m_sSize.height;
+ bIsAddTrailerHeight = true;
+ }
+ }
+ }
+ }
+
+ if (!bTakeSpace ||
+ *fContentCurRowY + childSize.height <=
+ fAvailHeight + XFA_LAYOUT_FLOAT_PERCISION ||
+ (!bContainerHeightAutoSize &&
+ m_fUsedSize + fAvailHeight + XFA_LAYOUT_FLOAT_PERCISION >=
+ fContainerHeight)) {
+ if (!bTakeSpace || eRetValue == XFA_ItemLayoutProcessorResult::Done) {
+ if (pProcessor->m_bUseInheriated) {
+ if (pTrailerLayoutItem)
+ pProcessor->AddTrailerBeforeSplit(childSize.height,
+ pTrailerLayoutItem, false);
+ if (pProcessor->JudgeLeaderOrTrailerForOccur(pOverflowLeaderNode))
+ pProcessor->AddPendingNode(pOverflowLeaderNode, false);
+
+ pProcessor->m_bUseInheriated = false;
+ } else {
+ if (bIsAddTrailerHeight)
+ childSize.height -= pTrailerLayoutItem->m_sSize.height;
+
+ pProcessor->ProcessUnUseOverFlow(pOverflowLeaderNode,
+ pOverflowTrailerNode,
+ pTrailerLayoutItem, pFormNode);
+ }
+
+ CXFA_ContentLayoutItem* pChildLayoutItem =
+ pProcessor->ExtractLayoutItem();
+ if (ExistContainerKeep(pProcessor->m_pFormNode, false) &&
+ pProcessor->m_pFormNode->GetIntact() == XFA_AttributeEnum::None) {
+ m_arrayKeepItems.push_back(pChildLayoutItem);
+ } else {
+ m_arrayKeepItems.clear();
+ }
+ rgCurLineLayoutItems[uHAlign].push_back(pChildLayoutItem);
+ *bAddedItemInRow = true;
+ if (bTakeSpace) {
+ *fContentCurRowAvailWidth -= childSize.width;
+ *fContentCurRowHeight =
+ std::max(*fContentCurRowHeight, childSize.height);
+ }
+ return XFA_ItemLayoutProcessorResult::Done;
+ }
+
+ if (eRetValue == XFA_ItemLayoutProcessorResult::PageFullBreak) {
+ if (pProcessor->m_bUseInheriated) {
+ if (pTrailerLayoutItem) {
+ pProcessor->AddTrailerBeforeSplit(childSize.height,
+ pTrailerLayoutItem, false);
+ }
+ if (pProcessor->JudgeLeaderOrTrailerForOccur(pOverflowLeaderNode))
+ pProcessor->AddPendingNode(pOverflowLeaderNode, false);
+
+ pProcessor->m_bUseInheriated = false;
+ } else {
+ if (bIsAddTrailerHeight)
+ childSize.height -= pTrailerLayoutItem->m_sSize.height;
+
+ pProcessor->ProcessUnUseOverFlow(pOverflowLeaderNode,
+ pOverflowTrailerNode,
+ pTrailerLayoutItem, pFormNode);
+ }
+ }
+ rgCurLineLayoutItems[uHAlign].push_back(pProcessor->ExtractLayoutItem());
+ *bAddedItemInRow = true;
+ *fContentCurRowAvailWidth -= childSize.width;
+ *fContentCurRowHeight = std::max(*fContentCurRowHeight, childSize.height);
+ return eRetValue;
+ }
+
+ XFA_ItemLayoutProcessorResult eResult;
+ if (ProcessKeepForSplit(pProcessor, eRetValue, &rgCurLineLayoutItems[uHAlign],
+ fContentCurRowAvailWidth, fContentCurRowHeight,
+ fContentCurRowY, bAddedItemInRow, bForceEndPage,
+ &eResult)) {
+ return eResult;
+ }
+
+ *bForceEndPage = true;
+ float fSplitPos = pProcessor->FindSplitPos(fAvailHeight - *fContentCurRowY);
+ if (fSplitPos > XFA_LAYOUT_FLOAT_PERCISION) {
+ XFA_AttributeEnum eLayout =
+ pProcessor->m_pFormNode->JSObject()->GetEnum(XFA_Attribute::Layout);
+ if (eLayout == XFA_AttributeEnum::Tb &&
+ eRetValue == XFA_ItemLayoutProcessorResult::Done) {
+ pProcessor->ProcessUnUseOverFlow(pOverflowLeaderNode,
+ pOverflowTrailerNode, pTrailerLayoutItem,
+ pFormNode);
+ rgCurLineLayoutItems[uHAlign].push_back(pProcessor->ExtractLayoutItem());
+ *bAddedItemInRow = true;
+ if (bTakeSpace) {
+ *fContentCurRowAvailWidth -= childSize.width;
+ *fContentCurRowHeight =
+ std::max(*fContentCurRowHeight, childSize.height);
+ }
+ return XFA_ItemLayoutProcessorResult::PageFullBreak;
+ }
+
+ CXFA_Node* pTempLeaderNode = nullptr;
+ CXFA_Node* pTempTrailerNode = nullptr;
+ if (m_pPageMgr && !pProcessor->m_bUseInheriated &&
+ eRetValue != XFA_ItemLayoutProcessorResult::PageFullBreak) {
+ m_pPageMgr->ProcessOverflow(pFormNode, pTempLeaderNode, pTempTrailerNode,
+ false, true);
+ }
+ if (pTrailerLayoutItem && bIsAddTrailerHeight) {
+ pProcessor->AddTrailerBeforeSplit(fSplitPos, pTrailerLayoutItem,
+ bUseInherited);
+ } else {
+ pProcessor->SplitLayoutItem(fSplitPos);
+ }
+
+ if (bUseInherited) {
+ pProcessor->ProcessUnUseOverFlow(pOverflowLeaderNode,
+ pOverflowTrailerNode, pTrailerLayoutItem,
+ pFormNode);
+ m_bUseInheriated = true;
+ } else {
+ CXFA_LayoutItem* firstChild = pProcessor->m_pLayoutItem->m_pFirstChild;
+ if (firstChild && !firstChild->m_pNextSibling &&
+ firstChild->m_pFormNode->IsLayoutGeneratedNode()) {
+ pProcessor->ProcessUnUseOverFlow(pOverflowLeaderNode,
+ pOverflowTrailerNode,
+ pTrailerLayoutItem, pFormNode);
+ } else if (pProcessor->JudgeLeaderOrTrailerForOccur(
+ pOverflowLeaderNode)) {
+ pProcessor->AddPendingNode(pOverflowLeaderNode, false);
+ }
+ }
+
+ if (pProcessor->m_pLayoutItem->m_pNextSibling) {
+ childSize = pProcessor->GetCurrentComponentSize();
+ rgCurLineLayoutItems[uHAlign].push_back(pProcessor->ExtractLayoutItem());
+ *bAddedItemInRow = true;
+ if (bTakeSpace) {
+ *fContentCurRowAvailWidth -= childSize.width;
+ *fContentCurRowHeight =
+ std::max(*fContentCurRowHeight, childSize.height);
+ }
+ }
+ return XFA_ItemLayoutProcessorResult::PageFullBreak;
+ }
+
+ if (*fContentCurRowY <= XFA_LAYOUT_FLOAT_PERCISION) {
+ childSize = pProcessor->GetCurrentComponentSize();
+ if (pProcessor->m_pPageMgr->GetNextAvailContentHeight(childSize.height)) {
+ CXFA_Node* pTempLeaderNode = nullptr;
+ CXFA_Node* pTempTrailerNode = nullptr;
+ if (m_pPageMgr) {
+ if (!pFormNode && pLayoutContext)
+ pFormNode = pLayoutContext->m_pOverflowProcessor->m_pFormNode;
+
+ m_pPageMgr->ProcessOverflow(pFormNode, pTempLeaderNode,
+ pTempTrailerNode, false, true);
+ }
+ if (bUseInherited) {
+ pProcessor->ProcessUnUseOverFlow(pOverflowLeaderNode,
+ pOverflowTrailerNode,
+ pTrailerLayoutItem, pFormNode);
+ m_bUseInheriated = true;
+ }
+ return XFA_ItemLayoutProcessorResult::PageFullBreak;
+ }
+
+ rgCurLineLayoutItems[uHAlign].push_back(pProcessor->ExtractLayoutItem());
+ *bAddedItemInRow = true;
+ if (bTakeSpace) {
+ *fContentCurRowAvailWidth -= childSize.width;
+ *fContentCurRowHeight = std::max(*fContentCurRowHeight, childSize.height);
+ }
+ if (eRetValue == XFA_ItemLayoutProcessorResult::Done)
+ *bForceEndPage = false;
+
+ return eRetValue;
+ }
+
+ XFA_AttributeEnum eLayout =
+ pProcessor->m_pFormNode->JSObject()->GetEnum(XFA_Attribute::Layout);
+ if (pProcessor->m_pFormNode->GetIntact() == XFA_AttributeEnum::None &&
+ eLayout == XFA_AttributeEnum::Tb) {
+ if (m_pPageMgr) {
+ m_pPageMgr->ProcessOverflow(pFormNode, pOverflowLeaderNode,
+ pOverflowTrailerNode, false, true);
+ }
+ if (pTrailerLayoutItem)
+ pProcessor->AddTrailerBeforeSplit(fSplitPos, pTrailerLayoutItem, false);
+ if (pProcessor->JudgeLeaderOrTrailerForOccur(pOverflowLeaderNode))
+ pProcessor->AddPendingNode(pOverflowLeaderNode, false);
+
+ return XFA_ItemLayoutProcessorResult::PageFullBreak;
+ }
+
+ if (eRetValue != XFA_ItemLayoutProcessorResult::Done)
+ return XFA_ItemLayoutProcessorResult::PageFullBreak;
+
+ if (!pFormNode && pLayoutContext)
+ pFormNode = pLayoutContext->m_pOverflowProcessor->m_pFormNode;
+ if (m_pPageMgr) {
+ m_pPageMgr->ProcessOverflow(pFormNode, pOverflowLeaderNode,
+ pOverflowTrailerNode, false, true);
+ }
+ if (bUseInherited) {
+ pProcessor->ProcessUnUseOverFlow(pOverflowLeaderNode, pOverflowTrailerNode,
+ pTrailerLayoutItem, pFormNode);
+ m_bUseInheriated = true;
+ }
+ return XFA_ItemLayoutProcessorResult::PageFullBreak;
+}
diff --git a/xfa/fxfa/parser/cxfa_itemlayoutprocessor.h b/xfa/fxfa/parser/cxfa_itemlayoutprocessor.h
index 7dbc754ec6..fdca14285f 100644
--- a/xfa/fxfa/parser/cxfa_itemlayoutprocessor.h
+++ b/xfa/fxfa/parser/cxfa_itemlayoutprocessor.h
@@ -48,10 +48,6 @@ enum class XFA_ItemLayoutProcessorStages {
class CXFA_ItemLayoutProcessor {
public:
- static bool IncrementRelayoutNode(CXFA_LayoutProcessor* pLayoutProcessor,
- CXFA_Node* pNode,
- CXFA_Node* pParentNode);
-
CXFA_ItemLayoutProcessor(CXFA_Node* pNode, CXFA_LayoutPageMgr* pPageMgr);
~CXFA_ItemLayoutProcessor();
@@ -61,16 +57,17 @@ class CXFA_ItemLayoutProcessor {
CXFA_LayoutContext* pContext);
void DoLayoutPageArea(CXFA_ContainerLayoutItem* pPageAreaLayoutItem);
- CFX_SizeF GetCurrentComponentSize();
CXFA_Node* GetFormNode() { return m_pFormNode; }
- bool HasLayoutItem() const { return !!m_pLayoutItem; }
CXFA_ContentLayoutItem* ExtractLayoutItem();
+
+ private:
+ CFX_SizeF GetCurrentComponentSize();
+ bool HasLayoutItem() const { return !!m_pLayoutItem; }
void SplitLayoutItem(float fSplitPos);
float FindSplitPos(float fProposedSplitPos);
bool ProcessKeepForSplit(
- CXFA_ItemLayoutProcessor* pParentProcessor,
CXFA_ItemLayoutProcessor* pChildProcessor,
XFA_ItemLayoutProcessorResult eRetValue,
std::vector<CXFA_ContentLayoutItem*>* rgCurLineLayoutItem,
@@ -89,21 +86,6 @@ class CXFA_ItemLayoutProcessor {
CXFA_ContentLayoutItem* CreateContentLayoutItem(CXFA_Node* pFormNode);
- CXFA_Node* m_pFormNode;
- CXFA_ContentLayoutItem* m_pLayoutItem;
- CXFA_Node* m_pCurChildNode;
- float m_fUsedSize;
- CXFA_LayoutPageMgr* m_pPageMgr;
- std::list<CXFA_Node*> m_PendingNodes;
- bool m_bBreakPending;
- std::vector<float> m_rgSpecifiedColumnWidths;
- std::vector<CXFA_ContentLayoutItem*> m_arrayKeepItems;
- float m_fLastRowWidth;
- float m_fLastRowY;
- bool m_bUseInheriated;
- XFA_ItemLayoutProcessorResult m_ePreProcessRs;
-
- private:
void SetCurrentComponentPos(const CFX_PointF& pos);
void SetCurrentComponentSize(const CFX_SizeF& size);
@@ -139,21 +121,61 @@ class CXFA_ItemLayoutProcessor {
void DoLayoutField();
void GotoNextContainerNode(CXFA_Node*& pCurActionNode,
- XFA_ItemLayoutProcessorStages& nCurStage,
+ XFA_ItemLayoutProcessorStages* nCurStage,
CXFA_Node* pParentContainer,
bool bUsePageBreak);
bool ProcessKeepNodesForCheckNext(CXFA_Node*& pCurActionNode,
- XFA_ItemLayoutProcessorStages& nCurStage,
+ XFA_ItemLayoutProcessorStages* nCurStage,
CXFA_Node*& pNextContainer,
bool& bLastKeepNode);
bool ProcessKeepNodesForBreakBefore(CXFA_Node*& pCurActionNode,
- XFA_ItemLayoutProcessorStages& nCurStage,
+ XFA_ItemLayoutProcessorStages* nCurStage,
CXFA_Node* pContainerNode);
CXFA_Node* GetSubformSetParent(CXFA_Node* pSubformSet);
+ void UpdatePendingItemLayout(CXFA_ContentLayoutItem* pLayoutItem);
+ void AddTrailerBeforeSplit(float fSplitPos,
+ CXFA_ContentLayoutItem* pTrailerLayoutItem,
+ bool bUseInherited);
+ void AddLeaderAfterSplit(CXFA_ContentLayoutItem* pLeaderLayoutItem);
+ void AddPendingNode(CXFA_Node* pPendingNode, bool bBreakPending);
+ float InsertPendingItems(CXFA_Node* pCurChildNode);
+ XFA_ItemLayoutProcessorResult InsertFlowedItem(
+ CXFA_ItemLayoutProcessor* pProcessor,
+ bool bContainerWidthAutoSize,
+ bool bContainerHeightAutoSize,
+ float fContainerHeight,
+ XFA_AttributeEnum eFlowStrategy,
+ uint8_t* uCurHAlignState,
+ std::vector<CXFA_ContentLayoutItem*> (&rgCurLineLayoutItems)[3],
+ bool bUseBreakControl,
+ float fAvailHeight,
+ float fRealHeight,
+ float fContentWidthLimit,
+ float* fContentCurRowY,
+ float* fContentCurRowAvailWidth,
+ float* fContentCurRowHeight,
+ bool* bAddedItemInRow,
+ bool* bForceEndPage,
+ CXFA_LayoutContext* pLayoutContext,
+ bool bNewRow);
+
+ CXFA_Node* m_pFormNode;
+ CXFA_ContentLayoutItem* m_pLayoutItem;
+ CXFA_Node* m_pCurChildNode;
+ float m_fUsedSize;
+ CXFA_LayoutPageMgr* m_pPageMgr;
+ std::list<CXFA_Node*> m_PendingNodes;
+ bool m_bBreakPending;
+ std::vector<float> m_rgSpecifiedColumnWidths;
+ std::vector<CXFA_ContentLayoutItem*> m_arrayKeepItems;
+ float m_fLastRowWidth;
+ float m_fLastRowY;
+ bool m_bUseInheriated;
+ XFA_ItemLayoutProcessorResult m_ePreProcessRs;
bool m_bKeepBreakFinish;
bool m_bIsProcessKeep;
CXFA_Node* m_pKeepHeadNode;
diff --git a/xfa/fxfa/parser/cxfa_layoutprocessor.cpp b/xfa/fxfa/parser/cxfa_layoutprocessor.cpp
index 540e1c9156..c31766f6f6 100644
--- a/xfa/fxfa/parser/cxfa_layoutprocessor.cpp
+++ b/xfa/fxfa/parser/cxfa_layoutprocessor.cpp
@@ -101,17 +101,7 @@ bool CXFA_LayoutProcessor::IncrementLayout() {
StartLayout(true);
return DoLayout() == 100;
}
- for (CXFA_Node* pNode : m_rgChangedContainers) {
- CXFA_Node* pParentNode = pNode->GetContainerParent();
- if (!pParentNode)
- return false;
- if (!CXFA_ItemLayoutProcessor::IncrementRelayoutNode(this, pNode,
- pParentNode)) {
- return false;
- }
- }
- m_rgChangedContainers.clear();
- return true;
+ return m_rgChangedContainers.empty();
}
int32_t CXFA_LayoutProcessor::CountPages() const {