summaryrefslogtreecommitdiff
path: root/core/fpdfapi
diff options
context:
space:
mode:
Diffstat (limited to 'core/fpdfapi')
-rw-r--r--core/fpdfapi/font/cpdf_type3font.cpp4
-rw-r--r--core/fpdfapi/page/cpdf_streamcontentparser.cpp14
-rw-r--r--core/fpdfapi/parser/cpdf_array_unittest.cpp13
-rw-r--r--core/fpdfapi/parser/cpdf_object_unittest.cpp19
-rw-r--r--core/fpdfapi/render/cpdf_dibsource.cpp14
5 files changed, 32 insertions, 32 deletions
diff --git a/core/fpdfapi/font/cpdf_type3font.cpp b/core/fpdfapi/font/cpdf_type3font.cpp
index b9a05a0588..59702aed6a 100644
--- a/core/fpdfapi/font/cpdf_type3font.cpp
+++ b/core/fpdfapi/font/cpdf_type3font.cpp
@@ -105,9 +105,9 @@ CPDF_Type3Char* CPDF_Type3Font::LoadChar(uint32_t charcode) {
if (!pStream)
return nullptr;
- std::unique_ptr<CPDF_Type3Char> pNewChar(new CPDF_Type3Char(new CPDF_Form(
+ auto pNewChar = pdfium::MakeUnique<CPDF_Type3Char>(new CPDF_Form(
m_pDocument, m_pFontResources ? m_pFontResources : m_pPageResources,
- pStream, nullptr)));
+ pStream, nullptr));
// This can trigger recursion into this method. The content of |m_CacheMap|
// can change as a result. Thus after it returns, check the cache again for
diff --git a/core/fpdfapi/page/cpdf_streamcontentparser.cpp b/core/fpdfapi/page/cpdf_streamcontentparser.cpp
index 312996ba11..4c64e13b06 100644
--- a/core/fpdfapi/page/cpdf_streamcontentparser.cpp
+++ b/core/fpdfapi/page/cpdf_streamcontentparser.cpp
@@ -262,7 +262,7 @@ CPDF_StreamContentParser::CPDF_StreamContentParser(
m_Level(level),
m_ParamStartPos(0),
m_ParamCount(0),
- m_pCurStates(new CPDF_AllStates),
+ m_pCurStates(pdfium::MakeUnique<CPDF_AllStates>()),
m_pLastTextObject(nullptr),
m_DefFontSize(0),
m_PathStartX(0.0f),
@@ -765,9 +765,9 @@ void CPDF_StreamContentParser::Handle_ExecuteXObject() {
}
void CPDF_StreamContentParser::AddForm(CPDF_Stream* pStream) {
- std::unique_ptr<CPDF_FormObject> pFormObj(new CPDF_FormObject);
- pFormObj->m_pForm.reset(
- new CPDF_Form(m_pDocument, m_pPageResources, pStream, m_pResources));
+ auto pFormObj = pdfium::MakeUnique<CPDF_FormObject>();
+ pFormObj->m_pForm = pdfium::MakeUnique<CPDF_Form>(
+ m_pDocument, m_pPageResources, pStream, m_pResources);
pFormObj->m_FormMatrix = m_pCurStates->m_CTM;
pFormObj->m_FormMatrix.Concat(m_mtContentToUser);
CPDF_AllStates status;
@@ -957,7 +957,7 @@ void CPDF_StreamContentParser::Handle_EndPath() {
}
void CPDF_StreamContentParser::Handle_SaveGraphState() {
- std::unique_ptr<CPDF_AllStates> pStates(new CPDF_AllStates);
+ auto pStates = pdfium::MakeUnique<CPDF_AllStates>();
pStates->Copy(*m_pCurStates);
m_StateStack.push_back(std::move(pStates));
}
@@ -1110,7 +1110,7 @@ void CPDF_StreamContentParser::Handle_ShadeFill() {
if (!pShading->IsShadingObject() || !pShading->Load())
return;
- std::unique_ptr<CPDF_ShadingObject> pObj(new CPDF_ShadingObject);
+ auto pObj = pdfium::MakeUnique<CPDF_ShadingObject>();
pObj->m_pShading = pShading;
SetGraphicStates(pObj.get(), false, false, false);
pObj->m_Matrix = m_pCurStates->m_CTM;
@@ -1248,7 +1248,7 @@ void CPDF_StreamContentParser::AddTextObject(CFX_ByteString* pStrs,
pFont->IsType3Font() ? TextRenderingMode::MODE_FILL
: m_pCurStates->m_TextState.GetTextMode();
{
- std::unique_ptr<CPDF_TextObject> pText(new CPDF_TextObject);
+ auto pText = pdfium::MakeUnique<CPDF_TextObject>();
m_pLastTextObject = pText.get();
SetGraphicStates(m_pLastTextObject, true, true, true);
if (TextRenderingModeIsStrokeMode(text_mode)) {
diff --git a/core/fpdfapi/parser/cpdf_array_unittest.cpp b/core/fpdfapi/parser/cpdf_array_unittest.cpp
index 6d458d83cd..1e92b32716 100644
--- a/core/fpdfapi/parser/cpdf_array_unittest.cpp
+++ b/core/fpdfapi/parser/cpdf_array_unittest.cpp
@@ -15,7 +15,7 @@
TEST(cpdf_array, RemoveAt) {
{
int elems[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
- std::unique_ptr<CPDF_Array> arr(new CPDF_Array);
+ auto arr = pdfium::MakeUnique<CPDF_Array>();
for (size_t i = 0; i < FX_ArraySize(elems); ++i)
arr->AddNew<CPDF_Number>(elems[i]);
arr->RemoveAt(3, 3);
@@ -32,7 +32,7 @@ TEST(cpdf_array, RemoveAt) {
{
// When the range is out of bound, RemoveAt has no effect.
int elems[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
- std::unique_ptr<CPDF_Array> arr(new CPDF_Array);
+ auto arr = pdfium::MakeUnique<CPDF_Array>();
for (size_t i = 0; i < FX_ArraySize(elems); ++i)
arr->AddNew<CPDF_Number>(elems[i]);
arr->RemoveAt(8, 5);
@@ -102,14 +102,13 @@ TEST(cpdf_array, Clone) {
static const size_t kNumOfRowElems = 5;
int elems[kNumOfRows][kNumOfRowElems] = {
{1, 2, 3, 4, 5}, {10, 9, 8, 7, 6}, {11, 12, 13, 14, 15}};
- std::unique_ptr<CPDF_Array> arr(new CPDF_Array);
+ auto arr = pdfium::MakeUnique<CPDF_Array>();
// Indirect references to indirect objects.
- std::unique_ptr<CPDF_IndirectObjectHolder> obj_holder(
- new CPDF_IndirectObjectHolder());
+ auto obj_holder = pdfium::MakeUnique<CPDF_IndirectObjectHolder>();
for (size_t i = 0; i < kNumOfRows; ++i) {
auto arr_elem = pdfium::MakeUnique<CPDF_Array>();
for (size_t j = 0; j < kNumOfRowElems; ++j) {
- std::unique_ptr<CPDF_Number> obj(new CPDF_Number(elems[i][j]));
+ auto obj = pdfium::MakeUnique<CPDF_Number>(elems[i][j]);
// Starts object number from 1.
int obj_num = i * kNumOfRowElems + j + 1;
obj_holder->ReplaceIndirectObjectIfHigherGeneration(obj_num,
@@ -168,7 +167,7 @@ TEST(cpdf_array, Clone) {
TEST(cpdf_array, Iterator) {
const int elems[] = {-23, -11, 3, 455, 2345877,
0, 7895330, -12564334, 10000, -100000};
- std::unique_ptr<CPDF_Array> arr(new CPDF_Array);
+ auto arr = pdfium::MakeUnique<CPDF_Array>();
for (size_t i = 0; i < FX_ArraySize(elems); ++i)
arr->InsertNewAt<CPDF_Number>(i, elems[i]);
size_t index = 0;
diff --git a/core/fpdfapi/parser/cpdf_object_unittest.cpp b/core/fpdfapi/parser/cpdf_object_unittest.cpp
index b25d40a029..3b5374b637 100644
--- a/core/fpdfapi/parser/cpdf_object_unittest.cpp
+++ b/core/fpdfapi/parser/cpdf_object_unittest.cpp
@@ -484,8 +484,8 @@ TEST(PDFArrayTest, GetTypeAt) {
// String and name array
const char* const vals[] = {"this", "adsde$%^", "\r\t", "\"012",
".", "EYREW", "It is a joke :)"};
- std::unique_ptr<CPDF_Array> string_array(new CPDF_Array);
- std::unique_ptr<CPDF_Array> name_array(new CPDF_Array);
+ auto string_array = pdfium::MakeUnique<CPDF_Array>();
+ auto name_array = pdfium::MakeUnique<CPDF_Array>();
for (size_t i = 0; i < FX_ArraySize(vals); ++i) {
string_array->InsertNewAt<CPDF_String>(i, vals[i], false);
name_array->InsertNewAt<CPDF_Name>(i, vals[i]);
@@ -695,8 +695,8 @@ TEST(PDFArrayTest, AddInteger) {
TEST(PDFArrayTest, AddStringAndName) {
const char* vals[] = {"", "a", "ehjhRIOYTTFdfcdnv", "122323",
"$#%^&**", " ", "This is a test.\r\n"};
- std::unique_ptr<CPDF_Array> string_array(new CPDF_Array);
- std::unique_ptr<CPDF_Array> name_array(new CPDF_Array);
+ auto string_array = pdfium::MakeUnique<CPDF_Array>();
+ auto name_array = pdfium::MakeUnique<CPDF_Array>();
for (size_t i = 0; i < FX_ArraySize(vals); ++i) {
string_array->AddNew<CPDF_String>(vals[i], false);
name_array->AddNew<CPDF_Name>(vals[i]);
@@ -710,8 +710,7 @@ TEST(PDFArrayTest, AddStringAndName) {
}
TEST(PDFArrayTest, AddReferenceAndGetObjectAt) {
- std::unique_ptr<CPDF_IndirectObjectHolder> holder(
- new CPDF_IndirectObjectHolder());
+ auto holder = pdfium::MakeUnique<CPDF_IndirectObjectHolder>();
CPDF_Boolean* boolean_obj = new CPDF_Boolean(true);
CPDF_Number* int_obj = new CPDF_Number(-1234);
CPDF_Number* float_obj = new CPDF_Number(2345.089f);
@@ -723,7 +722,7 @@ TEST(PDFArrayTest, AddReferenceAndGetObjectAt) {
str_obj, name_obj, null_obj};
unsigned int obj_nums[] = {2, 4, 7, 2345, 799887, 1};
auto arr = pdfium::MakeUnique<CPDF_Array>();
- std::unique_ptr<CPDF_Array> arr1(new CPDF_Array);
+ auto arr1 = pdfium::MakeUnique<CPDF_Array>();
// Create two arrays of references by different AddReference() APIs.
for (size_t i = 0; i < FX_ArraySize(indirect_objs); ++i) {
holder->ReplaceIndirectObjectIfHigherGeneration(
@@ -748,7 +747,7 @@ TEST(PDFArrayTest, AddReferenceAndGetObjectAt) {
TEST(PDFArrayTest, CloneDirectObject) {
CPDF_IndirectObjectHolder objects_holder;
- std::unique_ptr<CPDF_Array> array(new CPDF_Array);
+ auto array = pdfium::MakeUnique<CPDF_Array>();
array->AddNew<CPDF_Reference>(&objects_holder, 1234);
ASSERT_EQ(1U, array->GetCount());
CPDF_Object* obj = array->GetObjectAt(0);
@@ -782,7 +781,7 @@ TEST(PDFArrayTest, ConvertIndirect) {
TEST(PDFDictionaryTest, CloneDirectObject) {
CPDF_IndirectObjectHolder objects_holder;
- std::unique_ptr<CPDF_Dictionary> dict(new CPDF_Dictionary());
+ auto dict = pdfium::MakeUnique<CPDF_Dictionary>();
dict->SetNewFor<CPDF_Reference>("foo", &objects_holder, 1234);
ASSERT_EQ(1U, dict->GetCount());
CPDF_Object* obj = dict->GetObjectFor("foo");
@@ -867,7 +866,7 @@ TEST(PDFObjectTest, CloneCheckLoop) {
TEST(PDFDictionaryTest, ConvertIndirect) {
CPDF_IndirectObjectHolder objects_holder;
- std::unique_ptr<CPDF_Dictionary> dict(new CPDF_Dictionary);
+ auto dict = pdfium::MakeUnique<CPDF_Dictionary>();
CPDF_Object* pObj = dict->SetNewFor<CPDF_Number>("clams", 42);
dict->ConvertToIndirectObjectFor("clams", &objects_holder);
CPDF_Object* pRef = dict->GetObjectFor("clams");
diff --git a/core/fpdfapi/render/cpdf_dibsource.cpp b/core/fpdfapi/render/cpdf_dibsource.cpp
index f3703dd23a..cb8e9c9eee 100644
--- a/core/fpdfapi/render/cpdf_dibsource.cpp
+++ b/core/fpdfapi/render/cpdf_dibsource.cpp
@@ -21,6 +21,7 @@
#include "core/fpdfapi/parser/fpdf_parser_decode.h"
#include "core/fpdfapi/render/cpdf_pagerendercache.h"
#include "core/fpdfapi/render/cpdf_renderstatus.h"
+#include "core/fxcodec/codec/cjpx_decoder.h"
#include "core/fxcodec/fx_codec.h"
#include "core/fxcrt/fx_safe_types.h"
#include "third_party/base/ptr_util.h"
@@ -79,16 +80,17 @@ class JpxBitMapContext {
explicit JpxBitMapContext(CCodec_JpxModule* jpx_module)
: jpx_module_(jpx_module), decoder_(nullptr) {}
- ~JpxBitMapContext() { jpx_module_->DestroyDecoder(decoder_); }
+ ~JpxBitMapContext() {}
- // Takes ownership of |decoder|.
- void set_decoder(CJPX_Decoder* decoder) { decoder_ = decoder; }
+ void set_decoder(std::unique_ptr<CJPX_Decoder> decoder) {
+ decoder_ = std::move(decoder);
+ }
- CJPX_Decoder* decoder() { return decoder_; }
+ CJPX_Decoder* decoder() { return decoder_.get(); }
private:
CCodec_JpxModule* const jpx_module_; // Weak pointer.
- CJPX_Decoder* decoder_; // Decoder, owned.
+ std::unique_ptr<CJPX_Decoder> decoder_;
// Disallow evil constructors
JpxBitMapContext(const JpxBitMapContext&);
@@ -613,7 +615,7 @@ void CPDF_DIBSource::LoadJpxBitmap() {
if (!pJpxModule)
return;
- std::unique_ptr<JpxBitMapContext> context(new JpxBitMapContext(pJpxModule));
+ auto context = pdfium::MakeUnique<JpxBitMapContext>(pJpxModule);
context->set_decoder(pJpxModule->CreateDecoder(
m_pStreamAcc->GetData(), m_pStreamAcc->GetSize(), m_pColorSpace));
if (!context->decoder())