summaryrefslogtreecommitdiff
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
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>
-rw-r--r--fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp28
-rw-r--r--fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.h2
-rw-r--r--xfa/fwl/cfwl_combobox.cpp34
-rw-r--r--xfa/fwl/cfwl_combobox.h2
-rw-r--r--xfa/fwl/cfwl_datetimepicker.cpp22
-rw-r--r--xfa/fwl/cfwl_datetimepicker.h2
-rw-r--r--xfa/fwl/cfwl_widgetmgr.cpp5
-rw-r--r--xfa/fwl/cfwl_widgetmgr.h2
-rw-r--r--xfa/fxfa/cxfa_fwladapterwidgetmgr.cpp4
-rw-r--r--xfa/fxfa/cxfa_fwladapterwidgetmgr.h2
-rw-r--r--xfa/fxfa/fxfa.h2
11 files changed, 49 insertions, 56 deletions
diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp b/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp
index 984fff715c..dc6686548b 100644
--- a/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp
+++ b/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp
@@ -107,7 +107,7 @@ bool CPDFXFA_DocEnvironment::GetPopupPos(CXFA_FFWidget* hWidget,
float fMinPopup,
float fMaxPopup,
const CFX_RectF& rtAnchor,
- CFX_RectF& rtPopup) {
+ CFX_RectF* pPopupRect) {
if (!hWidget)
return false;
@@ -139,9 +139,9 @@ bool CPDFXFA_DocEnvironment::GetPopupPos(CXFA_FFWidget* hWidget,
static_cast<int>(rtAnchor.top - page_view_rect.top);
if (rtAnchor.left < page_view_rect.left)
- rtPopup.left += page_view_rect.left - rtAnchor.left;
+ pPopupRect->left += page_view_rect.left - rtAnchor.left;
if (rtAnchor.right() > page_view_rect.right)
- rtPopup.left -= rtAnchor.right() - page_view_rect.right;
+ pPopupRect->left -= rtAnchor.right() - page_view_rect.right;
break;
}
case 90: {
@@ -151,9 +151,9 @@ bool CPDFXFA_DocEnvironment::GetPopupPos(CXFA_FFWidget* hWidget,
static_cast<int>(rtAnchor.left - page_view_rect.left);
if (rtAnchor.bottom() > page_view_rect.bottom)
- rtPopup.left += rtAnchor.bottom() - page_view_rect.bottom;
+ pPopupRect->left += rtAnchor.bottom() - page_view_rect.bottom;
if (rtAnchor.top < page_view_rect.top)
- rtPopup.left -= page_view_rect.top - rtAnchor.top;
+ pPopupRect->left -= page_view_rect.top - rtAnchor.top;
break;
}
case 180: {
@@ -163,9 +163,9 @@ bool CPDFXFA_DocEnvironment::GetPopupPos(CXFA_FFWidget* hWidget,
static_cast<int>(page_view_rect.bottom - rtAnchor.bottom());
if (rtAnchor.right() > page_view_rect.right)
- rtPopup.left += rtAnchor.right() - page_view_rect.right;
+ pPopupRect->left += rtAnchor.right() - page_view_rect.right;
if (rtAnchor.left < page_view_rect.left)
- rtPopup.left -= page_view_rect.left - rtAnchor.left;
+ pPopupRect->left -= page_view_rect.left - rtAnchor.left;
break;
}
case 270: {
@@ -175,9 +175,9 @@ bool CPDFXFA_DocEnvironment::GetPopupPos(CXFA_FFWidget* hWidget,
static_cast<int>(page_view_rect.right - rtAnchor.right());
if (rtAnchor.top < page_view_rect.top)
- rtPopup.left += page_view_rect.top - rtAnchor.top;
+ pPopupRect->left += page_view_rect.top - rtAnchor.top;
if (rtAnchor.bottom() > page_view_rect.bottom)
- rtPopup.left -= rtAnchor.bottom() - page_view_rect.bottom;
+ pPopupRect->left -= rtAnchor.bottom() - page_view_rect.bottom;
break;
}
}
@@ -213,24 +213,24 @@ bool CPDFXFA_DocEnvironment::GetPopupPos(CXFA_FFWidget* hWidget,
case 0:
case 180: {
if (draw_below_anchor)
- rtPopup.top = rtAnchor.height;
+ pPopupRect->top = rtAnchor.height;
else
- rtPopup.top = -popup_height;
+ pPopupRect->top = -popup_height;
break;
}
case 90:
case 270: {
if (draw_below_anchor)
- rtPopup.top = rtAnchor.width;
+ pPopupRect->top = rtAnchor.width;
else
- rtPopup.top = -popup_height;
+ pPopupRect->top = -popup_height;
break;
}
default:
break;
}
- rtPopup.height = popup_height;
+ pPopupRect->height = popup_height;
return true;
}
diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.h b/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.h
index 03aae3d765..1c46a37fe8 100644
--- a/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.h
+++ b/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.h
@@ -33,7 +33,7 @@ class CPDFXFA_DocEnvironment : public IXFA_DocEnvironment {
float fMinPopup,
float fMaxPopup,
const CFX_RectF& rtAnchor,
- CFX_RectF& rtPopup) override;
+ CFX_RectF* pPopupRect) override;
bool PopupMenu(CXFA_FFWidget* hWidget, CFX_PointF ptPopup) override;
// dwFlags XFA_PAGEVIEWEVENT_Added, XFA_PAGEVIEWEVENT_Removing
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);
}
diff --git a/xfa/fwl/cfwl_combobox.h b/xfa/fwl/cfwl_combobox.h
index 6dbd05df78..bd8cd056eb 100644
--- a/xfa/fwl/cfwl_combobox.h
+++ b/xfa/fwl/cfwl_combobox.h
@@ -119,7 +119,7 @@ class CFWL_ComboBox : public CFWL_Widget {
void GetPopupPos(float fMinHeight,
float fMaxHeight,
const CFX_RectF& rtAnchor,
- CFX_RectF& rtPopup);
+ CFX_RectF* pPopupRect);
void OnFocusChanged(CFWL_Message* pMsg, bool bSet);
void OnLButtonDown(CFWL_MessageMouse* pMsg);
diff --git a/xfa/fwl/cfwl_datetimepicker.cpp b/xfa/fwl/cfwl_datetimepicker.cpp
index 101540ffc0..66e55dea9c 100644
--- a/xfa/fwl/cfwl_datetimepicker.cpp
+++ b/xfa/fwl/cfwl_datetimepicker.cpp
@@ -241,7 +241,7 @@ void CFWL_DateTimePicker::ShowMonthCalendar(bool bActivate) {
CFX_RectF rtAnchor(0, 0, m_pProperties->m_rtWidget.width,
m_pProperties->m_rtWidget.height);
- GetPopupPos(0, rtMonth.height, rtAnchor, rtMonth);
+ GetPopupPos(0, rtMonth.height, rtAnchor, &rtMonth);
m_pForm->SetWidgetRect(rtMonth);
rtMonth.left = rtMonth.top = 0;
@@ -356,7 +356,7 @@ void CFWL_DateTimePicker::DisForm_ShowMonthCalendar(bool bActivate) {
rtAnchor.width = rtMonthCal.width;
rtMonthCal.left = m_rtClient.left;
rtMonthCal.top = rtAnchor.Height();
- GetPopupPos(fPopupMin, fPopupMax, rtAnchor, rtMonthCal);
+ GetPopupPos(fPopupMin, fPopupMax, rtAnchor, &rtMonthCal);
m_pMonthCal->SetWidgetRect(rtMonthCal);
if (m_iYear > 0 && m_iMonth > 0 && m_iDay > 0)
m_pMonthCal->SetSelect(m_iYear, m_iMonth, m_iDay);
@@ -608,20 +608,18 @@ void CFWL_DateTimePicker::DisForm_OnFocusChanged(CFWL_Message* pMsg,
void CFWL_DateTimePicker::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;
}
CFX_PointF point = TransformTo(nullptr, CFX_PointF());
- if (rtAnchor.bottom() + point.y > 0.0f) {
- rtPopup = CFX_RectF(rtAnchor.left, rtAnchor.top - rtPopup.height,
- rtPopup.width, rtPopup.height);
- } else {
- rtPopup = CFX_RectF(rtAnchor.left, rtAnchor.bottom(), rtPopup.width,
- rtPopup.height);
- }
- rtPopup.Offset(point.x, point.y);
+ float fPopupTop = (rtAnchor.bottom() + point.y > 0.0f)
+ ? rtAnchor.top - pPopupRect->height
+ : rtAnchor.bottom();
+ *pPopupRect = CFX_RectF(rtAnchor.left, fPopupTop, pPopupRect->width,
+ pPopupRect->height);
+ pPopupRect->Offset(point.x, point.y);
}
diff --git a/xfa/fwl/cfwl_datetimepicker.h b/xfa/fwl/cfwl_datetimepicker.h
index d20df084be..4bfd3d022a 100644
--- a/xfa/fwl/cfwl_datetimepicker.h
+++ b/xfa/fwl/cfwl_datetimepicker.h
@@ -78,7 +78,7 @@ class CFWL_DateTimePicker : public CFWL_Widget {
void GetPopupPos(float fMinHeight,
float fMaxHeight,
const CFX_RectF& rtAnchor,
- CFX_RectF& rtPopup);
+ CFX_RectF* pPopupRect);
void OnFocusChanged(CFWL_Message* pMsg, bool bSet);
void OnLButtonDown(CFWL_MessageMouse* pMsg);
void OnLButtonUp(CFWL_MessageMouse* pMsg);
diff --git a/xfa/fwl/cfwl_widgetmgr.cpp b/xfa/fwl/cfwl_widgetmgr.cpp
index 0860556665..32b275cd2e 100644
--- a/xfa/fwl/cfwl_widgetmgr.cpp
+++ b/xfa/fwl/cfwl_widgetmgr.cpp
@@ -382,8 +382,9 @@ void CFWL_WidgetMgr::GetAdapterPopupPos(CFWL_Widget* pWidget,
float fMinHeight,
float fMaxHeight,
const CFX_RectF& rtAnchor,
- CFX_RectF& rtPopup) const {
- m_pAdapter->GetPopupPos(pWidget, fMinHeight, fMaxHeight, rtAnchor, rtPopup);
+ CFX_RectF* pPopupRect) const {
+ m_pAdapter->GetPopupPos(pWidget, fMinHeight, fMaxHeight, rtAnchor,
+ pPopupRect);
}
void CFWL_WidgetMgr::OnProcessMessageToForm(CFWL_Message* pMessage) {
diff --git a/xfa/fwl/cfwl_widgetmgr.h b/xfa/fwl/cfwl_widgetmgr.h
index 153d0a903e..8a6e974447 100644
--- a/xfa/fwl/cfwl_widgetmgr.h
+++ b/xfa/fwl/cfwl_widgetmgr.h
@@ -64,7 +64,7 @@ class CFWL_WidgetMgr {
float fMinHeight,
float fMaxHeight,
const CFX_RectF& rtAnchor,
- CFX_RectF& rtPopup) const;
+ CFX_RectF* pPopupRect) const;
private:
class Item {
diff --git a/xfa/fxfa/cxfa_fwladapterwidgetmgr.cpp b/xfa/fxfa/cxfa_fwladapterwidgetmgr.cpp
index befa8303a1..3d6b75b5e1 100644
--- a/xfa/fxfa/cxfa_fwladapterwidgetmgr.cpp
+++ b/xfa/fxfa/cxfa_fwladapterwidgetmgr.cpp
@@ -28,11 +28,11 @@ bool CXFA_FWLAdapterWidgetMgr::GetPopupPos(CFWL_Widget* pWidget,
float fMinHeight,
float fMaxHeight,
const CFX_RectF& rtAnchor,
- CFX_RectF& rtPopup) {
+ CFX_RectF* pPopupRect) {
CXFA_FFWidget* pFFWidget = pWidget->GetLayoutItem();
CFX_RectF rtRotateAnchor =
pFFWidget->GetRotateMatrix().TransformRect(rtAnchor);
pFFWidget->GetDoc()->GetDocEnvironment()->GetPopupPos(
- pFFWidget, fMinHeight, fMaxHeight, rtRotateAnchor, rtPopup);
+ pFFWidget, fMinHeight, fMaxHeight, rtRotateAnchor, pPopupRect);
return true;
}
diff --git a/xfa/fxfa/cxfa_fwladapterwidgetmgr.h b/xfa/fxfa/cxfa_fwladapterwidgetmgr.h
index f5c4ce160e..f0cc373b6c 100644
--- a/xfa/fxfa/cxfa_fwladapterwidgetmgr.h
+++ b/xfa/fxfa/cxfa_fwladapterwidgetmgr.h
@@ -22,7 +22,7 @@ class CXFA_FWLAdapterWidgetMgr {
float fMinHeight,
float fMaxHeight,
const CFX_RectF& rtAnchor,
- CFX_RectF& rtPopup);
+ CFX_RectF* pPopupRect);
};
#endif // XFA_FXFA_CXFA_FWLADAPTERWIDGETMGR_H_
diff --git a/xfa/fxfa/fxfa.h b/xfa/fxfa/fxfa.h
index 82ad90fc36..8a2c4e0296 100644
--- a/xfa/fxfa/fxfa.h
+++ b/xfa/fxfa/fxfa.h
@@ -218,7 +218,7 @@ class IXFA_DocEnvironment {
float fMinPopup,
float fMaxPopup,
const CFX_RectF& rtAnchor,
- CFX_RectF& rtPopup) = 0;
+ CFX_RectF* pPopupRect) = 0;
virtual bool PopupMenu(CXFA_FFWidget* hWidget, CFX_PointF ptPopup) = 0;
virtual void PageViewEvent(CXFA_FFPageView* pPageView, uint32_t dwFlags) = 0;
virtual void WidgetPostAdd(CXFA_FFWidget* hWidget) = 0;