From 20c62003660cc7bf7ab28a5e638556e22d5a525b Mon Sep 17 00:00:00 2001 From: Henrique Nakashima Date: Wed, 2 May 2018 20:46:38 +0000 Subject: Use pointers instead of refs for GetPopupPos() params. Change-Id: Ic19b91f91f08b1867437b22de04a2c54045ce8ae Reviewed-on: https://pdfium-review.googlesource.com/31992 Commit-Queue: Ryan Harrison Reviewed-by: Ryan Harrison --- xfa/fwl/cfwl_combobox.cpp | 34 ++++++++++++++-------------------- 1 file changed, 14 insertions(+), 20 deletions(-) (limited to 'xfa/fwl/cfwl_combobox.cpp') diff --git a/xfa/fwl/cfwl_combobox.cpp b/xfa/fwl/cfwl_combobox.cpp index 0a5ccd0e7c..20134a830b 100644 --- a/xfa/fwl/cfwl_combobox.cpp +++ b/xfa/fwl/cfwl_combobox.cpp @@ -332,7 +332,7 @@ void CFWL_ComboBox::ShowDropList(bool bActivate) { m_rtList.width = std::max(m_rtList.width, m_rtClient.width); m_rtProxy = m_rtList; - GetPopupPos(0, m_rtProxy.height, rtAnchor, m_rtProxy); + GetPopupPos(0, m_rtProxy.height, rtAnchor, &m_rtProxy); m_pComboBoxProxy->SetWidgetRect(m_rtProxy); m_pComboBoxProxy->Update(); @@ -551,7 +551,7 @@ void CFWL_ComboBox::DisForm_ShowDropList(bool bActivate) { float fPopupMax = fItemHeight * iItems + fBorder * 2; CFX_RectF rtList(m_rtClient.left, 0, m_pProperties->m_rtWidget.width, 0); - GetPopupPos(fPopupMin, fPopupMax, m_pProperties->m_rtWidget, rtList); + GetPopupPos(fPopupMin, fPopupMax, m_pProperties->m_rtWidget, &rtList); m_pListBox->SetWidgetRect(rtList); m_pListBox->Update(); @@ -1018,28 +1018,22 @@ void CFWL_ComboBox::DisForm_OnKey(CFWL_MessageKey* pMsg) { void CFWL_ComboBox::GetPopupPos(float fMinHeight, float fMaxHeight, const CFX_RectF& rtAnchor, - CFX_RectF& rtPopup) { + CFX_RectF* pPopupRect) { if (m_pWidgetMgr->IsFormDisabled()) { m_pWidgetMgr->GetAdapterPopupPos(this, fMinHeight, fMaxHeight, rtAnchor, - rtPopup); + pPopupRect); return; } - float fPopHeight = rtPopup.height; - if (rtPopup.height > fMaxHeight) - fPopHeight = fMaxHeight; - else if (rtPopup.height < fMinHeight) - fPopHeight = fMinHeight; - - float fWidth = std::max(rtAnchor.width, rtPopup.width); - float fBottom = rtAnchor.bottom() + fPopHeight; CFX_PointF point = TransformTo(nullptr, CFX_PointF()); - if (fBottom + point.y > 0.0f) { - rtPopup = - CFX_RectF(rtAnchor.left, rtAnchor.top - fPopHeight, fWidth, fPopHeight); - } else { - rtPopup = CFX_RectF(rtAnchor.left, rtAnchor.bottom(), fWidth, fPopHeight); - } - - rtPopup.Offset(point.x, point.y); + float fPopupHeight = + pdfium::clamp(pPopupRect->height, fMinHeight, fMaxHeight); + float fPopupWidth = std::max(rtAnchor.width, pPopupRect->width); + float fPopupBottom = rtAnchor.bottom() + fPopupHeight; + float fPopupTop = (fPopupBottom + point.y > 0.0f) + ? rtAnchor.top - fPopupHeight + : rtAnchor.bottom(); + + *pPopupRect = CFX_RectF(rtAnchor.left, fPopupTop, fPopupWidth, fPopupHeight); + pPopupRect->Offset(point.x, point.y); } -- cgit v1.2.3