summaryrefslogtreecommitdiff
path: root/fpdfsdk/formfiller/cffl_interactiveformfiller.cpp
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2017-05-31 23:52:00 -0700
committerChromium commit bot <commit-bot@chromium.org>2017-06-01 19:00:20 +0000
commit7bef7c8bf8691174653bd734de4cf187dcf08648 (patch)
tree737734240fbe351f37ad7bf9236d4c26d3c3918c /fpdfsdk/formfiller/cffl_interactiveformfiller.cpp
parentf6ca07b3fda40f0c5d5690caad8ac931cb46ccf6 (diff)
downloadpdfium-7bef7c8bf8691174653bd734de4cf187dcf08648.tar.xz
Clarify IPWL_Filler_Notify::QueryWherePopup() parameters.
Update implementation and caller, and clean up surrounding code. Change-Id: I40975f79a5d4f560d6a7ee0d327b2e97241d29bd Reviewed-on: https://pdfium-review.googlesource.com/6172 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'fpdfsdk/formfiller/cffl_interactiveformfiller.cpp')
-rw-r--r--fpdfsdk/formfiller/cffl_interactiveformfiller.cpp52
1 files changed, 21 insertions, 31 deletions
diff --git a/fpdfsdk/formfiller/cffl_interactiveformfiller.cpp b/fpdfsdk/formfiller/cffl_interactiveformfiller.cpp
index 5a35852005..491186e39c 100644
--- a/fpdfsdk/formfiller/cffl_interactiveformfiller.cpp
+++ b/fpdfsdk/formfiller/cffl_interactiveformfiller.cpp
@@ -23,6 +23,7 @@
#include "fpdfsdk/formfiller/cffl_radiobutton.h"
#include "fpdfsdk/formfiller/cffl_textfield.h"
#include "fpdfsdk/pdfwindow/PWL_Utils.h"
+#include "third_party/base/stl_util.h"
#define FFL_MAXLISTBOXHEIGHT 140.0f
@@ -528,8 +529,8 @@ void CFFL_InteractiveFormFiller::UnRegisterFormFiller(CPDFSDK_Annot* pAnnot) {
void CFFL_InteractiveFormFiller::QueryWherePopup(void* pPrivateData,
float fPopupMin,
float fPopupMax,
- int32_t& nRet,
- float& fPopupRet) {
+ bool* bBottom,
+ float* fPopupRet) {
CFFL_PrivateData* pData = (CFFL_PrivateData*)pPrivateData;
CFX_FloatRect rcPageView(0, 0, 0, 0);
@@ -563,39 +564,28 @@ void CFFL_InteractiveFormFiller::QueryWherePopup(void* pPrivateData,
break;
}
- float fFactHeight = 0;
- bool bBottom = true;
- float fMaxListBoxHeight = 0;
- if (fPopupMax > FFL_MAXLISTBOXHEIGHT) {
- if (fPopupMin > FFL_MAXLISTBOXHEIGHT) {
- fMaxListBoxHeight = fPopupMin;
- } else {
- fMaxListBoxHeight = FFL_MAXLISTBOXHEIGHT;
- }
- } else {
- fMaxListBoxHeight = fPopupMax;
- }
+ const float fMaxListBoxHeight =
+ pdfium::clamp(FFL_MAXLISTBOXHEIGHT, fPopupMin, fPopupMax);
if (fBottom > fMaxListBoxHeight) {
- fFactHeight = fMaxListBoxHeight;
- bBottom = true;
- } else {
- if (fTop > fMaxListBoxHeight) {
- fFactHeight = fMaxListBoxHeight;
- bBottom = false;
- } else {
- if (fTop > fBottom) {
- fFactHeight = fTop;
- bBottom = false;
- } else {
- fFactHeight = fBottom;
- bBottom = true;
- }
- }
+ *fPopupRet = fMaxListBoxHeight;
+ *bBottom = true;
+ return;
+ }
+
+ if (fTop > fMaxListBoxHeight) {
+ *fPopupRet = fMaxListBoxHeight;
+ *bBottom = false;
+ return;
}
- nRet = bBottom ? 0 : 1;
- fPopupRet = fFactHeight;
+ if (fTop > fBottom) {
+ *fPopupRet = fTop;
+ *bBottom = false;
+ } else {
+ *fPopupRet = fBottom;
+ *bBottom = true;
+ }
}
void CFFL_InteractiveFormFiller::OnKeyStrokeCommit(