summaryrefslogtreecommitdiff
path: root/core/fpdfapi/font
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2017-04-26 13:50:33 -0700
committerChromium commit bot <commit-bot@chromium.org>2017-04-26 21:25:42 +0000
commit827db14d7f3d0085253b686587717361ffbcad1b (patch)
treedd2039623b87ba0c40b48f9a0344a463b1f3fb53 /core/fpdfapi/font
parente47e0c96009b8633294eebbb9eb0e84caf525c57 (diff)
downloadpdfium-827db14d7f3d0085253b686587717361ffbcad1b.tar.xz
Remove a few more |new|s.
Change-Id: I8a50ed680c1e101f855644fca8d282dd21470577 Reviewed-on: https://pdfium-review.googlesource.com/4533 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'core/fpdfapi/font')
-rw-r--r--core/fpdfapi/font/cpdf_type3char.cpp6
-rw-r--r--core/fpdfapi/font/cpdf_type3char.h3
-rw-r--r--core/fpdfapi/font/cpdf_type3font.cpp7
-rw-r--r--core/fpdfapi/font/ttgsubtable.cpp26
-rw-r--r--core/fpdfapi/font/ttgsubtable.h2
5 files changed, 25 insertions, 19 deletions
diff --git a/core/fpdfapi/font/cpdf_type3char.cpp b/core/fpdfapi/font/cpdf_type3char.cpp
index 4f116a1afb..8ac062568d 100644
--- a/core/fpdfapi/font/cpdf_type3char.cpp
+++ b/core/fpdfapi/font/cpdf_type3char.cpp
@@ -6,14 +6,16 @@
#include "core/fpdfapi/font/cpdf_type3char.h"
+#include <utility>
+
#include "core/fpdfapi/page/cpdf_form.h"
#include "core/fpdfapi/page/cpdf_image.h"
#include "core/fpdfapi/page/cpdf_imageobject.h"
#include "core/fpdfapi/page/cpdf_pageobject.h"
#include "core/fxge/fx_dib.h"
-CPDF_Type3Char::CPDF_Type3Char(CPDF_Form* pForm)
- : m_pForm(pForm), m_bColored(false) {}
+CPDF_Type3Char::CPDF_Type3Char(std::unique_ptr<CPDF_Form> pForm)
+ : m_pForm(std::move(pForm)), m_bColored(false) {}
CPDF_Type3Char::~CPDF_Type3Char() {}
diff --git a/core/fpdfapi/font/cpdf_type3char.h b/core/fpdfapi/font/cpdf_type3char.h
index 3215802e0c..18c564150c 100644
--- a/core/fpdfapi/font/cpdf_type3char.h
+++ b/core/fpdfapi/font/cpdf_type3char.h
@@ -18,8 +18,7 @@ class CPDF_RenderContext;
class CPDF_Type3Char {
public:
- // Takes ownership of |pForm|.
- explicit CPDF_Type3Char(CPDF_Form* pForm);
+ explicit CPDF_Type3Char(std::unique_ptr<CPDF_Form> pForm);
~CPDF_Type3Char();
bool LoadBitmap(CPDF_RenderContext* pContext);
diff --git a/core/fpdfapi/font/cpdf_type3font.cpp b/core/fpdfapi/font/cpdf_type3font.cpp
index da3b183c13..79f6617ce3 100644
--- a/core/fpdfapi/font/cpdf_type3font.cpp
+++ b/core/fpdfapi/font/cpdf_type3font.cpp
@@ -105,9 +105,10 @@ CPDF_Type3Char* CPDF_Type3Font::LoadChar(uint32_t charcode) {
if (!pStream)
return nullptr;
- auto pNewChar = pdfium::MakeUnique<CPDF_Type3Char>(new CPDF_Form(
- m_pDocument, m_pFontResources ? m_pFontResources : m_pPageResources,
- pStream, nullptr));
+ auto pNewChar =
+ pdfium::MakeUnique<CPDF_Type3Char>(pdfium::MakeUnique<CPDF_Form>(
+ m_pDocument, m_pFontResources ? m_pFontResources : m_pPageResources,
+ 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/font/ttgsubtable.cpp b/core/fpdfapi/font/ttgsubtable.cpp
index d2a6b9ab52..5b3d4cd4b9 100644
--- a/core/fpdfapi/font/ttgsubtable.cpp
+++ b/core/fpdfapi/font/ttgsubtable.cpp
@@ -6,6 +6,8 @@
#include "core/fpdfapi/font/ttgsubtable.h"
+#include <utility>
+
#include "core/fxge/fx_freetype.h"
#include "third_party/base/ptr_util.h"
#include "third_party/base/stl_util.h"
@@ -298,19 +300,21 @@ void CFX_CTTGSUBTable::ParseLookup(FT_Bytes raw, TLookup* rec) {
ParseSingleSubst(&raw[GetUInt16(sp)], &subTable);
}
-CFX_CTTGSUBTable::TCoverageFormatBase* CFX_CTTGSUBTable::ParseCoverage(
- FT_Bytes raw) {
+std::unique_ptr<CFX_CTTGSUBTable::TCoverageFormatBase>
+CFX_CTTGSUBTable::ParseCoverage(FT_Bytes raw) {
FT_Bytes sp = raw;
uint16_t format = GetUInt16(sp);
- TCoverageFormatBase* rec = nullptr;
if (format == 1) {
- rec = new TCoverageFormat1();
- ParseCoverageFormat1(raw, static_cast<TCoverageFormat1*>(rec));
- } else if (format == 2) {
- rec = new TCoverageFormat2();
- ParseCoverageFormat2(raw, static_cast<TCoverageFormat2*>(rec));
+ auto rec = pdfium::MakeUnique<TCoverageFormat1>();
+ ParseCoverageFormat1(raw, rec.get());
+ return std::move(rec);
+ }
+ if (format == 2) {
+ auto rec = pdfium::MakeUnique<TCoverageFormat2>();
+ ParseCoverageFormat2(raw, rec.get());
+ return std::move(rec);
}
- return rec;
+ return nullptr;
}
void CFX_CTTGSUBTable::ParseCoverageFormat1(FT_Bytes raw,
@@ -357,7 +361,7 @@ void CFX_CTTGSUBTable::ParseSingleSubstFormat1(FT_Bytes raw,
FT_Bytes sp = raw;
GetUInt16(sp);
uint16_t offset = GetUInt16(sp);
- rec->Coverage.reset(ParseCoverage(&raw[offset]));
+ rec->Coverage = ParseCoverage(&raw[offset]);
rec->DeltaGlyphID = GetInt16(sp);
}
@@ -366,7 +370,7 @@ void CFX_CTTGSUBTable::ParseSingleSubstFormat2(FT_Bytes raw,
FT_Bytes sp = raw;
(void)GetUInt16(sp);
uint16_t offset = GetUInt16(sp);
- rec->Coverage.reset(ParseCoverage(&raw[offset]));
+ rec->Coverage = ParseCoverage(&raw[offset]);
rec->Substitutes = std::vector<uint16_t>(GetUInt16(sp));
for (auto& substitute : rec->Substitutes)
substitute = GetUInt16(sp);
diff --git a/core/fpdfapi/font/ttgsubtable.h b/core/fpdfapi/font/ttgsubtable.h
index f927269540..4b937f0473 100644
--- a/core/fpdfapi/font/ttgsubtable.h
+++ b/core/fpdfapi/font/ttgsubtable.h
@@ -278,7 +278,7 @@ class CFX_CTTGSUBTable {
void ParseFeature(FT_Bytes raw, TFeature* rec);
void ParseLookupList(FT_Bytes raw, TLookupList* rec);
void ParseLookup(FT_Bytes raw, TLookup* rec);
- TCoverageFormatBase* ParseCoverage(FT_Bytes raw);
+ std::unique_ptr<TCoverageFormatBase> ParseCoverage(FT_Bytes raw);
void ParseCoverageFormat1(FT_Bytes raw, TCoverageFormat1* rec);
void ParseCoverageFormat2(FT_Bytes raw, TCoverageFormat2* rec);
void ParseSingleSubst(FT_Bytes raw, std::unique_ptr<TSubTableBase>* rec);