summaryrefslogtreecommitdiff
path: root/xfa/fxfa/fm2js
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2017-03-17 15:14:19 -0700
committerChromium commit bot <commit-bot@chromium.org>2017-03-17 22:54:26 +0000
commit85f019a8e7d33cbba368a6c6b75fd091269e14a1 (patch)
tree8dcf6fcd98309a48ebbd9e46cc8c0d23a57c0965 /xfa/fxfa/fm2js
parent240fe6d79f234896a966ddce0b9a125776dc9171 (diff)
downloadpdfium-85f019a8e7d33cbba368a6c6b75fd091269e14a1.tar.xz
Add pdfium::clamp() as a placeholder for std::clamp().chromium/3046
Ue it to fix a typo as well. BUG=pdfium:634 Change-Id: I2d686242ffb841aedc2fae6a3cf7a00bea667404 Reviewed-on: https://pdfium-review.googlesource.com/3113 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'xfa/fxfa/fm2js')
-rw-r--r--xfa/fxfa/fm2js/xfa_fm2jscontext.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp b/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp
index 21d91395c2..e951716802 100644
--- a/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp
+++ b/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp
@@ -15,6 +15,7 @@
#include "fxjs/cfxjse_class.h"
#include "fxjs/cfxjse_value.h"
#include "third_party/base/ptr_util.h"
+#include "third_party/base/stl_util.h"
#include "xfa/fgas/localization/fgas_locale.h"
#include "xfa/fxfa/app/xfa_ffnotify.h"
#include "xfa/fxfa/fm2js/xfa_program.h"
@@ -910,8 +911,7 @@ void CXFA_FM2JSContext::Round(CFXJSE_Value* pThis,
return;
}
- uPrecision =
- static_cast<uint8_t>(std::min(std::max(dPrecision, 0.0), 12.0));
+ uPrecision = static_cast<uint8_t>(pdfium::clamp(dPrecision, 0.0, 12.0));
}
CFX_Decimal decimalValue((float)dValue, uPrecision);
@@ -4494,8 +4494,9 @@ void CXFA_FM2JSContext::Stuff(CFXJSE_Value* pThis,
!deleteValue->IsNull()) {
ValueToUTF8String(sourceValue.get(), sourceString);
iLength = sourceString.GetLength();
- iStart = std::min(iLength, std::max(1, static_cast<int32_t>(ValueToFloat(
- pThis, startValue.get()))));
+ iStart = pdfium::clamp(
+ static_cast<int32_t>(ValueToFloat(pThis, startValue.get())), 1,
+ iLength);
iDelete = std::max(
0, static_cast<int32_t>(ValueToFloat(pThis, deleteValue.get())));
}
@@ -4551,9 +4552,8 @@ void CXFA_FM2JSContext::Substr(CFXJSE_Value* pThis,
return;
}
- iStart = std::min(
- iLength,
- std::max(1, static_cast<int32_t>(ValueToFloat(pThis, startValue.get()))));
+ iStart = pdfium::clamp(
+ iLength, 1, static_cast<int32_t>(ValueToFloat(pThis, startValue.get())));
iCount =
std::max(0, static_cast<int32_t>(ValueToFloat(pThis, endValue.get())));