diff options
Diffstat (limited to 'xfa/fxfa')
-rw-r--r-- | xfa/fxfa/fm2js/xfa_fm2jscontext.cpp | 14 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_widetextread.cpp | 3 |
2 files changed, 9 insertions, 8 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()))); diff --git a/xfa/fxfa/parser/cxfa_widetextread.cpp b/xfa/fxfa/parser/cxfa_widetextread.cpp index bba7cbdaa1..73da5c670b 100644 --- a/xfa/fxfa/parser/cxfa_widetextread.cpp +++ b/xfa/fxfa/parser/cxfa_widetextread.cpp @@ -9,6 +9,7 @@ #include <algorithm> #include "core/fxcrt/fx_ext.h" +#include "third_party/base/stl_util.h" #include "xfa/fgas/crt/fgas_codepage.h" CXFA_WideTextRead::CXFA_WideTextRead(const CFX_WideString& wsBuffer) @@ -36,7 +37,7 @@ int32_t CXFA_WideTextRead::Seek(FX_STREAMSEEK eSeek, int32_t iOffset) { m_iPosition = m_wsBuffer.GetLength() + iOffset; break; } - m_iPosition = std::min(std::max(0, m_iPosition), m_wsBuffer.GetLength()); + m_iPosition = pdfium::clamp(0, m_iPosition, m_wsBuffer.GetLength()); return GetPosition(); } |