summaryrefslogtreecommitdiff
path: root/xfa/fwl/cfwl_combobox.cpp
diff options
context:
space:
mode:
authorHenrique Nakashima <hnakashima@chromium.org>2018-05-02 20:46:38 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-05-02 20:46:38 +0000
commit20c62003660cc7bf7ab28a5e638556e22d5a525b (patch)
treee8c45ca96b1441a8743b8a1cd8934e4e2523ee7e /xfa/fwl/cfwl_combobox.cpp
parentcef665eb28bbf4caaa5625332be8f891e3ec2a8e (diff)
downloadpdfium-20c62003660cc7bf7ab28a5e638556e22d5a525b.tar.xz
Use pointers instead of refs for GetPopupPos() params.
Change-Id: Ic19b91f91f08b1867437b22de04a2c54045ce8ae Reviewed-on: https://pdfium-review.googlesource.com/31992 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Diffstat (limited to 'xfa/fwl/cfwl_combobox.cpp')
-rw-r--r--xfa/fwl/cfwl_combobox.cpp34
1 files changed, 14 insertions, 20 deletions
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);
}