summaryrefslogtreecommitdiff
path: root/core/fpdfdoc/csection.cpp
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 /core/fpdfdoc/csection.cpp
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 'core/fpdfdoc/csection.cpp')
-rw-r--r--core/fpdfdoc/csection.cpp13
1 files changed, 5 insertions, 8 deletions
diff --git a/core/fpdfdoc/csection.cpp b/core/fpdfdoc/csection.cpp
index 981f6d0b54..0c7825585c 100644
--- a/core/fpdfdoc/csection.cpp
+++ b/core/fpdfdoc/csection.cpp
@@ -29,9 +29,8 @@ void CSection::ResetLineArray() {
}
void CSection::ResetWordArray() {
- for (int32_t i = 0, sz = m_WordArray.GetSize(); i < sz; i++) {
+ for (int32_t i = 0, sz = m_WordArray.GetSize(); i < sz; i++)
delete m_WordArray.GetAt(i);
- }
m_WordArray.RemoveAll();
}
@@ -47,12 +46,11 @@ CPVT_WordPlace CSection::AddWord(const CPVT_WordPlace& place,
const CPVT_WordInfo& wordinfo) {
CPVT_WordInfo* pWord = new CPVT_WordInfo(wordinfo);
int32_t nWordIndex =
- std::max(std::min(place.nWordIndex, m_WordArray.GetSize()), 0);
- if (nWordIndex == m_WordArray.GetSize()) {
+ pdfium::clamp(place.nWordIndex, 0, m_WordArray.GetSize());
+ if (nWordIndex == m_WordArray.GetSize())
m_WordArray.Add(pWord);
- } else {
+ else
m_WordArray.InsertAt(nWordIndex, pWord);
- }
return place;
}
@@ -62,9 +60,8 @@ CPVT_WordPlace CSection::AddLine(const CPVT_LineInfo& lineinfo) {
}
CPVT_FloatRect CSection::Rearrange() {
- if (m_pVT->m_nCharArray > 0) {
+ if (m_pVT->m_nCharArray > 0)
return CTypeset(this).CharArray();
- }
return CTypeset(this).Typeset();
}