summaryrefslogtreecommitdiff
path: root/xfa/fxfa/fm2js
diff options
context:
space:
mode:
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())));