summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/fpdftext/cpdf_textpage.cpp35
-rw-r--r--core/fpdftext/cpdf_textpage.h3
-rw-r--r--core/fxcodec/codec/fx_codec_flate.cpp16
-rw-r--r--core/fxcodec/codec/fx_codec_gif.cpp4
-rw-r--r--core/fxcodec/lgif/fx_gif.cpp60
-rw-r--r--core/fxcodec/lgif/fx_gif.h5
6 files changed, 56 insertions, 67 deletions
diff --git a/core/fpdftext/cpdf_textpage.cpp b/core/fpdftext/cpdf_textpage.cpp
index f7654f3e87..9cde4f5026 100644
--- a/core/fpdftext/cpdf_textpage.cpp
+++ b/core/fpdftext/cpdf_textpage.cpp
@@ -589,10 +589,10 @@ void CPDF_TextPage::ProcessObject() {
}
}
}
- for (int i = 0; i < m_LineObj.GetSize(); i++)
- ProcessTextObject(m_LineObj.GetAt(i));
+ for (const auto& obj : m_LineObj)
+ ProcessTextObject(obj);
- m_LineObj.RemoveAll();
+ m_LineObj.clear();
CloseTempLine();
}
@@ -740,17 +740,17 @@ void CPDF_TextPage::ProcessTextObject(
pTextObj->m_Top);
if (FXSYS_fabs(pTextObj->m_Right - pTextObj->m_Left) < 0.01f)
return;
- int count = m_LineObj.GetSize();
+ size_t count = m_LineObj.size();
PDFTEXT_Obj Obj;
Obj.m_pTextObj = pTextObj;
Obj.m_formMatrix = formMatrix;
if (count == 0) {
- m_LineObj.Add(Obj);
+ m_LineObj.push_back(Obj);
return;
}
if (IsSameAsPreTextObject(pTextObj, pObjList, ObjPos))
return;
- PDFTEXT_Obj prev_Obj = m_LineObj.GetAt(count - 1);
+ PDFTEXT_Obj prev_Obj = m_LineObj[count - 1];
CPDF_TextObjectItem item;
int nItem = prev_Obj.m_pTextObj->CountItems();
prev_Obj.m_pTextObj->GetItemInfo(nItem - 1, &item);
@@ -781,29 +781,26 @@ void CPDF_TextPage::ProcessTextObject(
formMatrix.Transform(this_x, this_y);
m_DisplayMatrix.Transform(this_x, this_y);
if (FXSYS_fabs(this_y - prev_y) > threshold * 2) {
- for (int i = 0; i < count; i++)
- ProcessTextObject(m_LineObj.GetAt(i));
- m_LineObj.RemoveAll();
- m_LineObj.Add(Obj);
+ for (size_t i = 0; i < count; i++)
+ ProcessTextObject(m_LineObj[i]);
+ m_LineObj.clear();
+ m_LineObj.push_back(Obj);
return;
}
- int i = 0;
- for (i = count - 1; i >= 0; i--) {
- PDFTEXT_Obj prev_text_obj = m_LineObj.GetAt(i);
+ size_t i;
+ for (i = count; i > 0; --i) {
+ PDFTEXT_Obj prev_text_obj = m_LineObj[i - 1];
FX_FLOAT Prev_x = prev_text_obj.m_pTextObj->GetPosX(),
Prev_y = prev_text_obj.m_pTextObj->GetPosY();
prev_text_obj.m_formMatrix.Transform(Prev_x, Prev_y);
m_DisplayMatrix.Transform(Prev_x, Prev_y);
if (this_x >= Prev_x) {
- if (i == count - 1)
- m_LineObj.Add(Obj);
- else
- m_LineObj.InsertAt(i + 1, Obj);
+ m_LineObj.insert(m_LineObj.begin() + i, Obj);
break;
}
}
- if (i < 0)
- m_LineObj.InsertAt(0, Obj);
+ if (i == 0)
+ m_LineObj.insert(m_LineObj.begin(), Obj);
}
FPDFText_MarkedContent CPDF_TextPage::PreMarkedContent(PDFTEXT_Obj Obj) {
diff --git a/core/fpdftext/cpdf_textpage.h b/core/fpdftext/cpdf_textpage.h
index aa1fc5bb03..85ee7058b6 100644
--- a/core/fpdftext/cpdf_textpage.h
+++ b/core/fpdftext/cpdf_textpage.h
@@ -170,9 +170,8 @@ class CPDF_TextPage {
CFX_Matrix m_perMatrix;
bool m_bIsParsed;
CFX_Matrix m_DisplayMatrix;
- CFX_ArrayTemplate<FPDF_SEGMENT> m_Segments;
std::vector<CFX_FloatRect> m_SelRects;
- CFX_ArrayTemplate<PDFTEXT_Obj> m_LineObj;
+ std::vector<PDFTEXT_Obj> m_LineObj;
TextOrientation m_TextlineDir;
CFX_FloatRect m_CurlineRect;
};
diff --git a/core/fxcodec/codec/fx_codec_flate.cpp b/core/fxcodec/codec/fx_codec_flate.cpp
index d01b40f318..3cffc0b7cf 100644
--- a/core/fxcodec/codec/fx_codec_flate.cpp
+++ b/core/fxcodec/codec/fx_codec_flate.cpp
@@ -9,6 +9,7 @@
#include <algorithm>
#include <memory>
#include <utility>
+#include <vector>
#include "core/fxcodec/fx_codec.h"
#include "core/fxcrt/fx_ext.h"
@@ -567,37 +568,36 @@ void FlateUncompress(const uint8_t* src_buf,
}
dest_buf = guess_buf.release();
} else {
- CFX_ArrayTemplate<uint8_t*> result_tmp_bufs;
+ std::vector<uint8_t*> result_tmp_bufs;
uint8_t* cur_buf = guess_buf.release();
while (1) {
int32_t ret = FPDFAPI_FlateOutput(context, cur_buf, buf_size);
int32_t avail_buf_size = FPDFAPI_FlateGetAvailOut(context);
if (ret != Z_OK) {
last_buf_size = buf_size - avail_buf_size;
- result_tmp_bufs.Add(cur_buf);
+ result_tmp_bufs.push_back(cur_buf);
break;
}
if (avail_buf_size != 0) {
last_buf_size = buf_size - avail_buf_size;
- result_tmp_bufs.Add(cur_buf);
+ result_tmp_bufs.push_back(cur_buf);
break;
}
-
- result_tmp_bufs.Add(cur_buf);
+ result_tmp_bufs.push_back(cur_buf);
cur_buf = FX_Alloc(uint8_t, buf_size + 1);
cur_buf[buf_size] = '\0';
}
dest_size = FPDFAPI_FlateGetTotalOut(context);
offset = FPDFAPI_FlateGetTotalIn(context);
- if (result_tmp_bufs.GetSize() == 1) {
+ if (result_tmp_bufs.size() == 1) {
dest_buf = result_tmp_bufs[0];
} else {
uint8_t* result_buf = FX_Alloc(uint8_t, dest_size);
uint32_t result_pos = 0;
- for (int32_t i = 0; i < result_tmp_bufs.GetSize(); i++) {
+ for (size_t i = 0; i < result_tmp_bufs.size(); i++) {
uint8_t* tmp_buf = result_tmp_bufs[i];
uint32_t tmp_buf_size = buf_size;
- if (i == result_tmp_bufs.GetSize() - 1) {
+ if (i == result_tmp_bufs.size() - 1) {
tmp_buf_size = last_buf_size;
}
FXSYS_memcpy(result_buf + result_pos, tmp_buf, tmp_buf_size);
diff --git a/core/fxcodec/codec/fx_codec_gif.cpp b/core/fxcodec/codec/fx_codec_gif.cpp
index 9d67652f86..fadf18f251 100644
--- a/core/fxcodec/codec/fx_codec_gif.cpp
+++ b/core/fxcodec/codec/fx_codec_gif.cpp
@@ -147,9 +147,9 @@ int32_t CCodec_GifModule::LoadFrame(FXGIF_Context* ctx,
if (ret == 1) {
if (pAttribute) {
pAttribute->m_nGifLeft =
- ctx->gif_ptr->img_ptr_arr_ptr->GetAt(frame_num)->image_info_ptr->left;
+ (*ctx->gif_ptr->img_ptr_arr_ptr)[frame_num]->image_info_ptr->left;
pAttribute->m_nGifTop =
- ctx->gif_ptr->img_ptr_arr_ptr->GetAt(frame_num)->image_info_ptr->top;
+ (*ctx->gif_ptr->img_ptr_arr_ptr)[frame_num]->image_info_ptr->top;
pAttribute->m_fAspectRatio = ctx->gif_ptr->pixel_aspect;
if (ctx->gif_ptr->cmt_data_ptr) {
const uint8_t* buf =
diff --git a/core/fxcodec/lgif/fx_gif.cpp b/core/fxcodec/lgif/fx_gif.cpp
index b509c8ccfd..0e2626984b 100644
--- a/core/fxcodec/lgif/fx_gif.cpp
+++ b/core/fxcodec/lgif/fx_gif.cpp
@@ -7,6 +7,7 @@
#include "core/fxcodec/lgif/fx_gif.h"
#include "core/fxcodec/lbmp/fx_bmp.h"
+#include "third_party/base/stl_util.h"
void CGifLZWDecoder::Input(uint8_t* src_buf, uint32_t src_size) {
next_in = src_buf;
@@ -372,16 +373,12 @@ void CGifLZWEncoder::Finish(uint8_t*& dst_buf,
ClearTable();
}
gif_decompress_struct_p gif_create_decompress() {
- gif_decompress_struct_p gif_ptr =
- (gif_decompress_struct*)FX_Alloc(uint8_t, sizeof(gif_decompress_struct));
- if (!gif_ptr)
- return nullptr;
-
+ gif_decompress_struct_p gif_ptr = FX_Alloc(gif_decompress_struct, 1);
FXSYS_memset(gif_ptr, 0, sizeof(gif_decompress_struct));
gif_ptr->decode_status = GIF_D_STATUS_SIG;
- gif_ptr->img_ptr_arr_ptr = new CFX_ArrayTemplate<GifImage*>;
+ gif_ptr->img_ptr_arr_ptr = new std::vector<GifImage*>;
gif_ptr->cmt_data_ptr = new CFX_ByteString;
- gif_ptr->pt_ptr_arr_ptr = new CFX_ArrayTemplate<GifPlainText*>;
+ gif_ptr->pt_ptr_arr_ptr = new std::vector<GifPlainText*>;
return gif_ptr;
}
void gif_destroy_decompress(gif_decompress_struct_pp gif_ptr_ptr) {
@@ -393,9 +390,9 @@ void gif_destroy_decompress(gif_decompress_struct_pp gif_ptr_ptr) {
FX_Free(gif_ptr->global_pal_ptr);
delete gif_ptr->img_decoder_ptr;
if (gif_ptr->img_ptr_arr_ptr) {
- int32_t size_img_arr = gif_ptr->img_ptr_arr_ptr->GetSize();
- for (int32_t i = 0; i < size_img_arr; i++) {
- GifImage* p = gif_ptr->img_ptr_arr_ptr->GetAt(i);
+ size_t size_img_arr = gif_ptr->img_ptr_arr_ptr->size();
+ for (size_t i = 0; i < size_img_arr; i++) {
+ GifImage* p = (*gif_ptr->img_ptr_arr_ptr)[i];
FX_Free(p->image_info_ptr);
FX_Free(p->image_gce_ptr);
FX_Free(p->image_row_buf);
@@ -404,31 +401,27 @@ void gif_destroy_decompress(gif_decompress_struct_pp gif_ptr_ptr) {
}
FX_Free(p);
}
- gif_ptr->img_ptr_arr_ptr->RemoveAll();
+ gif_ptr->img_ptr_arr_ptr->clear();
delete gif_ptr->img_ptr_arr_ptr;
}
delete gif_ptr->cmt_data_ptr;
FX_Free(gif_ptr->gce_ptr);
if (gif_ptr->pt_ptr_arr_ptr) {
- int32_t size_pt_arr = gif_ptr->pt_ptr_arr_ptr->GetSize();
- for (int32_t i = 0; i < size_pt_arr; i++) {
- GifPlainText* p = gif_ptr->pt_ptr_arr_ptr->GetAt(i);
+ size_t size_pt_arr = gif_ptr->pt_ptr_arr_ptr->size();
+ for (size_t i = 0; i < size_pt_arr; i++) {
+ GifPlainText* p = (*gif_ptr->pt_ptr_arr_ptr)[i];
FX_Free(p->gce_ptr);
FX_Free(p->pte_ptr);
delete p->string_ptr;
FX_Free(p);
}
- gif_ptr->pt_ptr_arr_ptr->RemoveAll();
+ gif_ptr->pt_ptr_arr_ptr->clear();
delete gif_ptr->pt_ptr_arr_ptr;
}
FX_Free(gif_ptr);
}
gif_compress_struct_p gif_create_compress() {
- gif_compress_struct_p gif_ptr =
- (gif_compress_struct*)FX_Alloc(uint8_t, sizeof(gif_compress_struct));
- if (!gif_ptr)
- return nullptr;
-
+ gif_compress_struct_p gif_ptr = FX_Alloc(gif_compress_struct, 1);
FXSYS_memset(gif_ptr, 0, sizeof(gif_compress_struct));
gif_ptr->img_encoder_ptr = new CGifLZWEncoder;
gif_ptr->header_ptr = (GifHeader*)FX_Alloc(uint8_t, sizeof(GifHeader));
@@ -724,7 +717,7 @@ int32_t gif_decode_extension(gif_decompress_struct_p gif_ptr) {
*(gif_pt_ptr->string_ptr) +=
CFX_ByteString((const FX_CHAR*)data_ptr, data_size);
}
- gif_ptr->pt_ptr_arr_ptr->Add(gif_pt_ptr);
+ gif_ptr->pt_ptr_arr_ptr->push_back(gif_pt_ptr);
} break;
case GIF_D_STATUS_EXT_GCE: {
ASSERT(sizeof(GifGCE) == 5);
@@ -829,19 +822,19 @@ int32_t gif_decode_image_info(gif_decompress_struct_p gif_ptr) {
&gif_image_ptr->image_data_pos);
gif_image_ptr->image_data_pos += gif_ptr->skip_size;
gif_takeover_gce_ptr(gif_ptr, &gif_image_ptr->image_gce_ptr);
- gif_ptr->img_ptr_arr_ptr->Add(gif_image_ptr);
+ gif_ptr->img_ptr_arr_ptr->push_back(gif_image_ptr);
gif_save_decoding_status(gif_ptr, GIF_D_STATUS_IMG_DATA);
return 1;
}
int32_t gif_load_frame(gif_decompress_struct_p gif_ptr, int32_t frame_num) {
if (!gif_ptr || frame_num < 0 ||
- frame_num >= gif_ptr->img_ptr_arr_ptr->GetSize()) {
+ frame_num >= pdfium::CollectionSize<int>(*gif_ptr->img_ptr_arr_ptr)) {
return 0;
}
uint8_t* data_size_ptr = nullptr;
uint8_t* data_ptr = nullptr;
uint32_t skip_size_org = gif_ptr->skip_size;
- GifImage* gif_image_ptr = gif_ptr->img_ptr_arr_ptr->GetAt(frame_num);
+ GifImage* gif_image_ptr = (*gif_ptr->img_ptr_arr_ptr)[frame_num];
uint32_t gif_img_row_bytes = gif_image_ptr->image_info_ptr->width;
if (gif_ptr->decode_status == GIF_D_STATUS_TAIL) {
if (gif_image_ptr->image_row_buf) {
@@ -1034,7 +1027,7 @@ uint32_t gif_get_avail_input(gif_decompress_struct_p gif_ptr,
return gif_ptr->avail_in;
}
int32_t gif_get_frame_num(gif_decompress_struct_p gif_ptr) {
- return gif_ptr->img_ptr_arr_ptr->GetSize();
+ return pdfium::CollectionSize<int32_t>(*gif_ptr->img_ptr_arr_ptr);
}
static bool gif_write_header(gif_compress_struct_p gif_ptr,
uint8_t*& dst_buf,
@@ -1068,12 +1061,11 @@ static bool gif_write_header(gif_compress_struct_p gif_ptr,
return true;
}
void interlace_buf(const uint8_t* buf, uint32_t pitch, uint32_t height) {
- CFX_ArrayTemplate<uint8_t*> pass[4];
- int i, j;
- uint32_t row;
- row = 0;
+ std::vector<uint8_t*> pass[4];
+ uint32_t row = 0;
uint8_t* temp;
while (row < height) {
+ size_t j;
if (row % 8 == 0) {
j = 0;
} else if (row % 4 == 0) {
@@ -1085,13 +1077,13 @@ void interlace_buf(const uint8_t* buf, uint32_t pitch, uint32_t height) {
}
temp = FX_Alloc(uint8_t, pitch);
FXSYS_memcpy(temp, &buf[pitch * row], pitch);
- pass[j].Add(temp);
+ pass[j].push_back(temp);
row++;
}
- for (i = 0, row = 0; i < 4; i++) {
- for (j = 0; j < pass[i].GetSize(); j++, row++) {
- FXSYS_memcpy((uint8_t*)&buf[pitch * row], pass[i].GetAt(j), pitch);
- FX_Free(pass[i].GetAt(j));
+ for (size_t i = 0, row = 0; i < 4; i++) {
+ for (size_t j = 0; j < pass[i].size(); j++, row++) {
+ FXSYS_memcpy((uint8_t*)&buf[pitch * row], pass[i][j], pitch);
+ FX_Free(pass[i][j]);
}
}
}
diff --git a/core/fxcodec/lgif/fx_gif.h b/core/fxcodec/lgif/fx_gif.h
index eb5f85a187..a8b780b099 100644
--- a/core/fxcodec/lgif/fx_gif.h
+++ b/core/fxcodec/lgif/fx_gif.h
@@ -8,6 +8,7 @@
#define CORE_FXCODEC_LGIF_FX_GIF_H_
#include <setjmp.h>
+#include <vector>
#include "core/fxcrt/fx_basic.h"
@@ -223,7 +224,7 @@ struct tag_gif_decompress_struct {
uint32_t img_row_offset;
uint32_t img_row_avail_size;
uint8_t img_pass_num;
- CFX_ArrayTemplate<GifImage*>* img_ptr_arr_ptr;
+ std::vector<GifImage*>* img_ptr_arr_ptr;
uint8_t* (*gif_ask_buf_for_pal_fn)(gif_decompress_struct_p gif_ptr,
int32_t pal_size);
uint8_t* next_in;
@@ -250,7 +251,7 @@ struct tag_gif_decompress_struct {
bool interlace);
CFX_ByteString* cmt_data_ptr;
GifGCE* gce_ptr;
- CFX_ArrayTemplate<GifPlainText*>* pt_ptr_arr_ptr;
+ std::vector<GifPlainText*>* pt_ptr_arr_ptr;
};
typedef struct tag_gif_compress_struct gif_compress_struct;
typedef gif_compress_struct* gif_compress_struct_p;