summaryrefslogtreecommitdiff
path: root/core/src/fxcodec
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2016-01-11 11:59:17 -0800
committerLei Zhang <thestig@chromium.org>2016-01-11 11:59:17 -0800
commit375a86403b7fa8d17d7b142c270e2d8e33bb924f (patch)
tree1db1ffddb2bbbcd429cd1d7954b1949bfa54e1ab /core/src/fxcodec
parent492961df3011ccc25646eae12ac6e6dcfe7f26da (diff)
downloadpdfium-375a86403b7fa8d17d7b142c270e2d8e33bb924f.tar.xz
Merge to XFA: Switch most min/max macros to std::min/max.
Fix lint errors along the way. R=tsepez@chromium.org TBR=tsepez@chromium.org Review URL: https://codereview.chromium.org/1567343002 . (cherry picked from commit 9adfbb0920a258e916003b1ee9515e97879db82a) Review URL: https://codereview.chromium.org/1577503002 .
Diffstat (limited to 'core/src/fxcodec')
-rw-r--r--core/src/fxcodec/codec/fx_codec_png.cpp12
-rw-r--r--core/src/fxcodec/lbmp/fx_bmp.cpp23
2 files changed, 25 insertions, 10 deletions
diff --git a/core/src/fxcodec/codec/fx_codec_png.cpp b/core/src/fxcodec/codec/fx_codec_png.cpp
index 6401081ea3..3acfc19442 100644
--- a/core/src/fxcodec/codec/fx_codec_png.cpp
+++ b/core/src/fxcodec/codec/fx_codec_png.cpp
@@ -4,6 +4,8 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+#include <algorithm>
+
#include "core/include/fxcodec/fx_codec.h"
#include "core/include/fxge/fx_dib.h"
#include "codec_int.h"
@@ -62,24 +64,24 @@ static void _png_load_bmp_attribute(png_structp png_ptr,
#endif
#if defined(PNG_TEXT_SUPPORTED)
int i;
- FX_DWORD len;
+ FX_STRSIZE len;
const FX_CHAR* buf;
int num_text;
png_textp text = NULL;
png_get_text(png_ptr, info_ptr, &text, &num_text);
for (i = 0; i < num_text; i++) {
- len = (FX_DWORD)FXSYS_strlen(text[i].key);
+ len = FXSYS_strlen(text[i].key);
buf = "Time";
- if (!FXSYS_memcmp(buf, text[i].key, FX_MIN(len, FXSYS_strlen(buf)))) {
+ if (!FXSYS_memcmp(buf, text[i].key, std::min(len, FXSYS_strlen(buf)))) {
if (!bTime) {
FXSYS_memset(pAttribute->m_strTime, 0, sizeof(pAttribute->m_strTime));
FXSYS_memcpy(
pAttribute->m_strTime, text[i].text,
- FX_MIN(sizeof(pAttribute->m_strTime) - 1, text[i].text_length));
+ std::min(sizeof(pAttribute->m_strTime) - 1, text[i].text_length));
}
} else {
buf = "Author";
- if (!FXSYS_memcmp(buf, text[i].key, FX_MIN(len, FXSYS_strlen(buf)))) {
+ if (!FXSYS_memcmp(buf, text[i].key, std::min(len, FXSYS_strlen(buf)))) {
pAttribute->m_strAuthor.Empty();
pAttribute->m_strAuthor.Load((uint8_t*)text[i].text,
(FX_STRSIZE)text[i].text_length);
diff --git a/core/src/fxcodec/lbmp/fx_bmp.cpp b/core/src/fxcodec/lbmp/fx_bmp.cpp
index 98bcefdaba..00477581a1 100644
--- a/core/src/fxcodec/lbmp/fx_bmp.cpp
+++ b/core/src/fxcodec/lbmp/fx_bmp.cpp
@@ -5,6 +5,16 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
#include "fx_bmp.h"
+
+#include <algorithm>
+
+namespace {
+
+const size_t kBmpCoreHeaderSize = 12;
+const size_t kBmpInfoHeaderSize = 40;
+
+} // namespace
+
FX_DWORD _GetDWord_LSBFirst(uint8_t* p) {
return p[0] | (p[1] << 8) | (p[2] << 16) | (p[3] << 24);
}
@@ -80,10 +90,12 @@ int32_t _bmp_read_header(bmp_decompress_struct_p bmp_ptr) {
bmp_ptr->img_ifh_size =
_GetDWord_LSBFirst(bmp_ptr->next_in + bmp_ptr->skip_size);
bmp_ptr->pal_type = 0;
- ASSERT(sizeof(BmpCoreHeader) == 12);
- ASSERT(sizeof(BmpInfoHeader) == 40);
+ static_assert(sizeof(BmpCoreHeader) == kBmpCoreHeaderSize,
+ "BmpCoreHeader has wrong size");
+ static_assert(sizeof(BmpInfoHeader) == kBmpInfoHeaderSize,
+ "BmpInfoHeader has wrong size");
switch (bmp_ptr->img_ifh_size) {
- case FX_MIN(12, sizeof(BmpCoreHeader)): {
+ case kBmpCoreHeaderSize: {
bmp_ptr->pal_type = 1;
BmpCoreHeaderPtr bmp_core_header_ptr = NULL;
if (_bmp_read_data(bmp_ptr, (uint8_t**)&bmp_core_header_ptr,
@@ -100,7 +112,7 @@ int32_t _bmp_read_header(bmp_decompress_struct_p bmp_ptr) {
bmp_ptr->compress_flag = BMP_RGB;
bmp_ptr->imgTB_flag = FALSE;
} break;
- case FX_MIN(40, sizeof(BmpInfoHeader)): {
+ case kBmpInfoHeaderSize: {
BmpInfoHeaderPtr bmp_info_header_ptr = NULL;
if (_bmp_read_data(bmp_ptr, (uint8_t**)&bmp_info_header_ptr,
bmp_ptr->img_ifh_size) == NULL) {
@@ -127,7 +139,8 @@ int32_t _bmp_read_header(bmp_decompress_struct_p bmp_ptr) {
}
} break;
default: {
- if (bmp_ptr->img_ifh_size > FX_MIN(40, sizeof(BmpInfoHeader))) {
+ if (bmp_ptr->img_ifh_size >
+ std::min(kBmpInfoHeaderSize, sizeof(BmpInfoHeader))) {
BmpInfoHeaderPtr bmp_info_header_ptr = NULL;
if (_bmp_read_data(bmp_ptr, (uint8_t**)&bmp_info_header_ptr,
bmp_ptr->img_ifh_size) == NULL) {