From 8ab2b2b2869f769dc169b4a96bb67ec596d5278b Mon Sep 17 00:00:00 2001 From: Henrique Nakashima Date: Wed, 2 May 2018 15:50:42 +0000 Subject: Remove out params from CalculateAccWidthAndHeight. Return CFX_Size. Change-Id: I1088abd4ce8f6276043213218867c4d6fb0a46a9 Reviewed-on: https://pdfium-review.googlesource.com/31914 Commit-Queue: Henrique Nakashima Reviewed-by: Lei Zhang Reviewed-by: Ryan Harrison --- xfa/fxfa/parser/cxfa_node.cpp | 37 ++++++++++++++++++++----------------- xfa/fxfa/parser/cxfa_node.h | 4 +--- 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/xfa/fxfa/parser/cxfa_node.cpp b/xfa/fxfa/parser/cxfa_node.cpp index c3fbf62eb7..7a6a2ba7d6 100644 --- a/xfa/fxfa/parser/cxfa_node.cpp +++ b/xfa/fxfa/parser/cxfa_node.cpp @@ -3046,10 +3046,13 @@ void CXFA_Node::StartWidgetLayout(CXFA_FFDoc* doc, float fWidth = 0; if (*pCalcWidth > 0 && *pCalcHeight < 0) { Optional height = TryHeight(); - if (height) + if (height) { *pCalcHeight = *height; - else - CalculateAccWidthAndHeight(doc, pCalcWidth, pCalcHeight); + } else { + CFX_SizeF size = CalculateAccWidthAndHeight(doc, *pCalcWidth); + *pCalcWidth = size.width; + *pCalcHeight = size.height; + } m_pLayoutData->m_fWidgetHeight = *pCalcHeight; return; @@ -3064,18 +3067,19 @@ void CXFA_Node::StartWidgetLayout(CXFA_FFDoc* doc, if (height) *pCalcHeight = *height; } - if (!width || !height) - CalculateAccWidthAndHeight(doc, &fWidth, pCalcHeight); - - *pCalcWidth = fWidth; + if (!width || !height) { + CFX_SizeF size = CalculateAccWidthAndHeight(doc, fWidth); + *pCalcWidth = size.width; + *pCalcHeight = size.height; + } else { + *pCalcWidth = fWidth; + } } m_pLayoutData->m_fWidgetHeight = *pCalcHeight; } -void CXFA_Node::CalculateAccWidthAndHeight(CXFA_FFDoc* doc, - float* pWidth, - float* pCalcHeight) { - CFX_SizeF sz(*pWidth, m_pLayoutData->m_fWidgetHeight); +CFX_SizeF CXFA_Node::CalculateAccWidthAndHeight(CXFA_FFDoc* doc, float fWidth) { + CFX_SizeF sz(fWidth, m_pLayoutData->m_fWidgetHeight); switch (GetFFWidgetType()) { case XFA_FFWidgetType::kBarcode: case XFA_FFWidgetType::kChoiceList: @@ -3112,9 +3116,8 @@ void CXFA_Node::CalculateAccWidthAndHeight(CXFA_FFDoc* doc, break; } - *pWidth = sz.width; m_pLayoutData->m_fWidgetHeight = sz.height; - *pCalcHeight = sz.height; + return sz; } bool CXFA_Node::FindSplitPos(CXFA_FFDocView* docView, @@ -3197,11 +3200,11 @@ bool CXFA_Node::FindSplitPos(CXFA_FFDocView* docView, iLinesCount = 1; } else { if (!pFieldData->m_pTextOut) { - // TODO(dsinclair): Inline fWidth when the 2nd param of - // CalculateAccWidthAndHeight isn't an in/out param. - float fWidth = TryWidth().value_or(0); - CalculateAccWidthAndHeight(docView->GetDoc(), &fWidth, &fHeight); + CFX_SizeF size = + CalculateAccWidthAndHeight(docView->GetDoc(), TryWidth().value_or(0)); + fHeight = size.height; } + iLinesCount = pFieldData->m_pTextOut->GetTotalLines(); } std::vector* pFieldArray = &pFieldData->m_FieldSplitArray; diff --git a/xfa/fxfa/parser/cxfa_node.h b/xfa/fxfa/parser/cxfa_node.h index b12a26ef3b..11fc38f4cc 100644 --- a/xfa/fxfa/parser/cxfa_node.h +++ b/xfa/fxfa/parser/cxfa_node.h @@ -460,9 +460,7 @@ class CXFA_Node : public CXFA_Object { float GetWidthWithoutMargin(float fWidthCalc); float GetHeightWithoutMargin(float fHeightCalc); void CalculateTextContentSize(CXFA_FFDoc* doc, CFX_SizeF* pSize); - void CalculateAccWidthAndHeight(CXFA_FFDoc* doc, - float* pWidth, - float* pCalcHeight); + CFX_SizeF CalculateAccWidthAndHeight(CXFA_FFDoc* doc, float fWidth); void InitLayoutData(); void StartTextLayout(CXFA_FFDoc* doc, float* pCalcWidth, float* pCalcHeight); -- cgit v1.2.3