From aab84f9a9fcb19296e45625901243e87ae813a4e Mon Sep 17 00:00:00 2001 From: Nicolas Pena Date: Fri, 1 Dec 2017 19:10:32 +0000 Subject: Remove unneded structs from CFX_CTTGSUBTable part 2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This CL continues removing structs from CFX_CTTGSUBTable Change-Id: I1ede1e3e736f87292b6119406fd5f12a0bb7e7cb Reviewed-on: https://pdfium-review.googlesource.com/20170 Reviewed-by: Ryan Harrison Commit-Queue: Nicolás Peña Moreno --- core/fpdfapi/font/cfx_cttgsubtable.cpp | 106 +++++++++++----------- core/fpdfapi/font/cfx_cttgsubtable.h | 160 +++++++-------------------------- 2 files changed, 88 insertions(+), 178 deletions(-) diff --git a/core/fpdfapi/font/cfx_cttgsubtable.cpp b/core/fpdfapi/font/cfx_cttgsubtable.cpp index 901e57b60d..4870756ca0 100644 --- a/core/fpdfapi/font/cfx_cttgsubtable.cpp +++ b/core/fpdfapi/font/cfx_cttgsubtable.cpp @@ -12,8 +12,7 @@ #include "third_party/base/ptr_util.h" #include "third_party/base/stl_util.h" -CFX_CTTGSUBTable::CFX_CTTGSUBTable() - : m_bFeautureMapLoad(false), loaded(false) {} +CFX_CTTGSUBTable::CFX_CTTGSUBTable() : m_bFeautureMapLoad(false) {} CFX_CTTGSUBTable::~CFX_CTTGSUBTable() {} @@ -35,8 +34,8 @@ bool CFX_CTTGSUBTable::GetVerticalGlyph(uint32_t glyphnum, }; if (!m_bFeautureMapLoad) { for (const TScriptRecord& script : ScriptList) { - for (const auto& record : script.Script.LangSysRecords) { - for (const auto& index : record.LangSys.FeatureIndices) { + for (const auto& record : script.LangSysRecords) { + for (const auto& index : record.FeatureIndices) { if (FeatureList[index].FeatureTag == tag[0] || FeatureList[index].FeatureTag == tag[1]) { m_featureSet.insert(index); @@ -55,7 +54,7 @@ bool CFX_CTTGSUBTable::GetVerticalGlyph(uint32_t glyphnum, m_bFeautureMapLoad = true; } for (const auto& item : m_featureSet) { - if (GetVerticalGlyphSub(glyphnum, vglyphnum, &FeatureList[item].Feature)) { + if (GetVerticalGlyphSub(glyphnum, vglyphnum, &FeatureList[item])) { return true; } } @@ -64,7 +63,7 @@ bool CFX_CTTGSUBTable::GetVerticalGlyph(uint32_t glyphnum, bool CFX_CTTGSUBTable::GetVerticalGlyphSub(uint32_t glyphnum, uint32_t* vglyphnum, - TFeature* Feature) { + TFeatureRecord* Feature) { for (int index : Feature->LookupListIndices) { if (!pdfium::IndexInBounds(LookupList, index)) continue; @@ -82,7 +81,7 @@ bool CFX_CTTGSUBTable::GetVerticalGlyphSub2(uint32_t glyphnum, for (const auto& subTable : Lookup->SubTables) { switch (subTable->SubstFormat) { case 1: { - auto* tbl1 = static_cast(subTable.get()); + auto* tbl1 = static_cast(subTable.get()); if (GetCoverageIndex(tbl1->Coverage.get(), glyphnum) >= 0) { *vglyphnum = glyphnum + tbl1->DeltaGlyphID; return true; @@ -90,7 +89,7 @@ bool CFX_CTTGSUBTable::GetVerticalGlyphSub2(uint32_t glyphnum, break; } case 2: { - auto* tbl2 = static_cast(subTable.get()); + auto* tbl2 = static_cast(subTable.get()); int index = GetCoverageIndex(tbl2->Coverage.get(), glyphnum); if (pdfium::IndexInBounds(tbl2->Substitutes, index)) { *vglyphnum = tbl2->Substitutes[index]; @@ -111,7 +110,7 @@ int CFX_CTTGSUBTable::GetCoverageIndex(TCoverageFormatBase* Coverage, switch (Coverage->CoverageFormat) { case 1: { int i = 0; - TCoverageFormat1* c1 = (TCoverageFormat1*)Coverage; + TCoverageFormat1* c1 = static_cast(Coverage); for (const auto& glyph : c1->GlyphArray) { if (static_cast(glyph) == g) return i; @@ -120,7 +119,7 @@ int CFX_CTTGSUBTable::GetCoverageIndex(TCoverageFormatBase* Coverage, return -1; } case 2: { - TCoverageFormat2* c2 = (TCoverageFormat2*)Coverage; + TCoverageFormat2* c2 = static_cast(Coverage); for (const auto& rangeRec : c2->RangeRecords) { uint32_t s = rangeRec.Start; uint32_t e = rangeRec.End; @@ -178,21 +177,21 @@ void CFX_CTTGSUBTable::ParseScriptList(FT_Bytes raw) { ScriptList = std::vector(GetUInt16(sp)); for (auto& scriptRec : ScriptList) { scriptRec.ScriptTag = GetUInt32(sp); - ParseScript(&raw[GetUInt16(sp)], &scriptRec.Script); + ParseScript(&raw[GetUInt16(sp)], &scriptRec); } } -void CFX_CTTGSUBTable::ParseScript(FT_Bytes raw, TScript* rec) { +void CFX_CTTGSUBTable::ParseScript(FT_Bytes raw, TScriptRecord* rec) { FT_Bytes sp = raw; rec->DefaultLangSys = GetUInt16(sp); rec->LangSysRecords = std::vector(GetUInt16(sp)); for (auto& sysRecord : rec->LangSysRecords) { sysRecord.LangSysTag = GetUInt32(sp); - ParseLangSys(&raw[GetUInt16(sp)], &sysRecord.LangSys); + ParseLangSys(&raw[GetUInt16(sp)], &sysRecord); } } -void CFX_CTTGSUBTable::ParseLangSys(FT_Bytes raw, TLangSys* rec) { +void CFX_CTTGSUBTable::ParseLangSys(FT_Bytes raw, TLangSysRecord* rec) { FT_Bytes sp = raw; rec->LookupOrder = GetUInt16(sp); rec->ReqFeatureIndex = GetUInt16(sp); @@ -206,11 +205,11 @@ void CFX_CTTGSUBTable::ParseFeatureList(FT_Bytes raw) { FeatureList = std::vector(GetUInt16(sp)); for (auto& featureRec : FeatureList) { featureRec.FeatureTag = GetUInt32(sp); - ParseFeature(&raw[GetUInt16(sp)], &featureRec.Feature); + ParseFeature(&raw[GetUInt16(sp)], &featureRec); } } -void CFX_CTTGSUBTable::ParseFeature(FT_Bytes raw, TFeature* rec) { +void CFX_CTTGSUBTable::ParseFeature(FT_Bytes raw, TFeatureRecord* rec) { FT_Bytes sp = raw; rec->FeatureParams = GetUInt16(sp); rec->LookupListIndices = std::vector(GetUInt16(sp)); @@ -244,12 +243,12 @@ CFX_CTTGSUBTable::ParseCoverage(FT_Bytes raw) { if (format == 1) { auto rec = pdfium::MakeUnique(); ParseCoverageFormat1(raw, rec.get()); - return std::move(rec); + return rec; } if (format == 2) { auto rec = pdfium::MakeUnique(); ParseCoverageFormat2(raw, rec.get()); - return std::move(rec); + return rec; } return nullptr; } @@ -281,20 +280,17 @@ void CFX_CTTGSUBTable::ParseSingleSubst(FT_Bytes raw, uint16_t Format = GetUInt16(sp); switch (Format) { case 1: - *rec = pdfium::MakeUnique(); - ParseSingleSubstFormat1(raw, - static_cast(rec->get())); + *rec = pdfium::MakeUnique(); + ParseSingleSubstFormat1(raw, static_cast(rec->get())); break; case 2: - *rec = pdfium::MakeUnique(); - ParseSingleSubstFormat2(raw, - static_cast(rec->get())); + *rec = pdfium::MakeUnique(); + ParseSingleSubstFormat2(raw, static_cast(rec->get())); break; } } -void CFX_CTTGSUBTable::ParseSingleSubstFormat1(FT_Bytes raw, - TSingleSubstFormat1* rec) { +void CFX_CTTGSUBTable::ParseSingleSubstFormat1(FT_Bytes raw, TSubTable1* rec) { FT_Bytes sp = raw; GetUInt16(sp); uint16_t offset = GetUInt16(sp); @@ -302,8 +298,7 @@ void CFX_CTTGSUBTable::ParseSingleSubstFormat1(FT_Bytes raw, rec->DeltaGlyphID = GetInt16(sp); } -void CFX_CTTGSUBTable::ParseSingleSubstFormat2(FT_Bytes raw, - TSingleSubstFormat2* rec) { +void CFX_CTTGSUBTable::ParseSingleSubstFormat2(FT_Bytes raw, TSubTable2* rec) { FT_Bytes sp = raw; (void)GetUInt16(sp); uint16_t offset = GetUInt16(sp); @@ -313,41 +308,52 @@ void CFX_CTTGSUBTable::ParseSingleSubstFormat2(FT_Bytes raw, substitute = GetUInt16(sp); } -CFX_CTTGSUBTable::TCoverageFormat1::TCoverageFormat1() - : TCoverageFormatBase(1) {} +CFX_CTTGSUBTable::TLangSysRecord::TLangSysRecord() + : LangSysTag(0), LookupOrder(0), ReqFeatureIndex(0) {} -CFX_CTTGSUBTable::TCoverageFormat1::~TCoverageFormat1() {} +CFX_CTTGSUBTable::TLangSysRecord::~TLangSysRecord() {} -CFX_CTTGSUBTable::TRangeRecord::TRangeRecord() - : Start(0), End(0), StartCoverageIndex(0) {} +CFX_CTTGSUBTable::TScriptRecord::TScriptRecord() + : ScriptTag(0), DefaultLangSys(0) {} -CFX_CTTGSUBTable::TCoverageFormat2::TCoverageFormat2() - : TCoverageFormatBase(2) {} +CFX_CTTGSUBTable::TScriptRecord::~TScriptRecord() {} -CFX_CTTGSUBTable::TCoverageFormat2::~TCoverageFormat2() {} +CFX_CTTGSUBTable::TFeatureRecord::TFeatureRecord() + : FeatureTag(0), FeatureParams(0) {} -CFX_CTTGSUBTable::TSingleSubstFormat1::TSingleSubstFormat1() - : TSubTableBase(1), DeltaGlyphID(0) {} +CFX_CTTGSUBTable::TFeatureRecord::~TFeatureRecord() {} -CFX_CTTGSUBTable::TSingleSubstFormat1::~TSingleSubstFormat1() {} +CFX_CTTGSUBTable::TRangeRecord::TRangeRecord() + : Start(0), End(0), StartCoverageIndex(0) {} -CFX_CTTGSUBTable::TSingleSubstFormat2::TSingleSubstFormat2() - : TSubTableBase(2) {} +CFX_CTTGSUBTable::TCoverageFormat1::TCoverageFormat1() { + CoverageFormat = 1; +} -CFX_CTTGSUBTable::TSingleSubstFormat2::~TSingleSubstFormat2() {} +CFX_CTTGSUBTable::TCoverageFormat1::~TCoverageFormat1() {} -CFX_CTTGSUBTable::TLookup::TLookup() : LookupType(0), LookupFlag(0) {} +CFX_CTTGSUBTable::TCoverageFormat2::TCoverageFormat2() { + CoverageFormat = 2; +} -CFX_CTTGSUBTable::TLookup::~TLookup() {} +CFX_CTTGSUBTable::TCoverageFormat2::~TCoverageFormat2() {} -CFX_CTTGSUBTable::TScript::TScript() : DefaultLangSys(0) {} +CFX_CTTGSUBTable::TSubTableBase::TSubTableBase() {} -CFX_CTTGSUBTable::TScript::~TScript() {} +CFX_CTTGSUBTable::TSubTableBase::~TSubTableBase() {} -CFX_CTTGSUBTable::TFeature::TFeature() : FeatureParams(0) {} +CFX_CTTGSUBTable::TSubTable1::TSubTable1() { + SubstFormat = 1; +} -CFX_CTTGSUBTable::TFeature::~TFeature() {} +CFX_CTTGSUBTable::TSubTable1::~TSubTable1() {} -CFX_CTTGSUBTable::TLangSys::TLangSys() : LookupOrder(0), ReqFeatureIndex(0) {} +CFX_CTTGSUBTable::TSubTable2::TSubTable2() { + SubstFormat = 2; +} -CFX_CTTGSUBTable::TLangSys::~TLangSys() {} +CFX_CTTGSUBTable::TSubTable2::~TSubTable2() {} + +CFX_CTTGSUBTable::TLookup::TLookup() : LookupType(0), LookupFlag(0) {} + +CFX_CTTGSUBTable::TLookup::~TLookup() {} diff --git a/core/fpdfapi/font/cfx_cttgsubtable.h b/core/fpdfapi/font/cfx_cttgsubtable.h index fc8d125f3e..8722bf665c 100644 --- a/core/fpdfapi/font/cfx_cttgsubtable.h +++ b/core/fpdfapi/font/cfx_cttgsubtable.h @@ -25,95 +25,45 @@ class CFX_CTTGSUBTable { bool GetVerticalGlyph(uint32_t glyphnum, uint32_t* vglyphnum); private: - struct TLangSys { - TLangSys(); - ~TLangSys(); + struct TLangSysRecord { + TLangSysRecord(); + ~TLangSysRecord(); + uint32_t LangSysTag; uint16_t LookupOrder; uint16_t ReqFeatureIndex; std::vector FeatureIndices; - - private: - TLangSys(const TLangSys&) = delete; - TLangSys& operator=(const TLangSys&) = delete; - }; - - struct TLangSysRecord { - TLangSysRecord() : LangSysTag(0) {} - - uint32_t LangSysTag; - TLangSys LangSys; - - private: - TLangSysRecord(const TLangSysRecord&) = delete; - TLangSysRecord& operator=(const TLangSysRecord&) = delete; - }; - - struct TScript { - TScript(); - ~TScript(); - - uint16_t DefaultLangSys; - std::vector LangSysRecords; - - private: - TScript(const TScript&) = delete; - TScript& operator=(const TScript&) = delete; }; struct TScriptRecord { - TScriptRecord() : ScriptTag(0) {} + TScriptRecord(); + ~TScriptRecord(); uint32_t ScriptTag; - TScript Script; - - private: - TScriptRecord(const TScriptRecord&) = delete; - TScriptRecord& operator=(const TScriptRecord&) = delete; + uint16_t DefaultLangSys; + std::vector LangSysRecords; }; - struct TFeature { - TFeature(); - ~TFeature(); + struct TFeatureRecord { + TFeatureRecord(); + ~TFeatureRecord(); + uint32_t FeatureTag; uint16_t FeatureParams; std::vector LookupListIndices; - - private: - TFeature(const TFeature&) = delete; - TFeature& operator=(const TFeature&) = delete; }; - struct TFeatureRecord { - TFeatureRecord() : FeatureTag(0) {} - - uint32_t FeatureTag; - TFeature Feature; - - private: - TFeatureRecord(const TFeatureRecord&) = delete; - TFeatureRecord& operator=(const TFeatureRecord&) = delete; - }; + struct TRangeRecord { + TRangeRecord(); - enum TLookupFlag { - LOOKUPFLAG_RightToLeft = 0x0001, - LOOKUPFLAG_IgnoreBaseGlyphs = 0x0002, - LOOKUPFLAG_IgnoreLigatures = 0x0004, - LOOKUPFLAG_IgnoreMarks = 0x0008, - LOOKUPFLAG_Reserved = 0x00F0, - LOOKUPFLAG_MarkAttachmentType = 0xFF00, + uint16_t Start; + uint16_t End; + uint16_t StartCoverageIndex; }; struct TCoverageFormatBase { - TCoverageFormatBase() : CoverageFormat(0) {} - explicit TCoverageFormatBase(uint16_t format) : CoverageFormat(format) {} virtual ~TCoverageFormatBase() {} - uint16_t CoverageFormat; - - private: - TCoverageFormatBase(const TCoverageFormatBase&); - TCoverageFormatBase& operator=(const TCoverageFormatBase&); }; struct TCoverageFormat1 : public TCoverageFormatBase { @@ -121,25 +71,6 @@ class CFX_CTTGSUBTable { ~TCoverageFormat1() override; std::vector GlyphArray; - - private: - TCoverageFormat1(const TCoverageFormat1&) = delete; - TCoverageFormat1& operator=(const TCoverageFormat1&) = delete; - }; - - struct TRangeRecord { - TRangeRecord(); - - friend bool operator>(const TRangeRecord& r1, const TRangeRecord& r2) { - return r1.Start > r2.Start; - } - - uint16_t Start; - uint16_t End; - uint16_t StartCoverageIndex; - - private: - TRangeRecord(const TRangeRecord&) = delete; }; struct TCoverageFormat2 : public TCoverageFormatBase { @@ -147,10 +78,6 @@ class CFX_CTTGSUBTable { ~TCoverageFormat2() override; std::vector RangeRecords; - - private: - TCoverageFormat2(const TCoverageFormat2&) = delete; - TCoverageFormat2& operator=(const TCoverageFormat2&) = delete; }; struct TDevice { @@ -159,46 +86,28 @@ class CFX_CTTGSUBTable { uint16_t StartSize; uint16_t EndSize; uint16_t DeltaFormat; - - private: - TDevice(const TDevice&) = delete; - TDevice& operator=(const TDevice&) = delete; }; struct TSubTableBase { - TSubTableBase() : SubstFormat(0) {} - explicit TSubTableBase(uint16_t format) : SubstFormat(format) {} - virtual ~TSubTableBase() {} + TSubTableBase(); + virtual ~TSubTableBase(); + std::unique_ptr Coverage; uint16_t SubstFormat; - - private: - TSubTableBase(const TSubTableBase&) = delete; - TSubTableBase& operator=(const TSubTableBase&) = delete; }; - struct TSingleSubstFormat1 : public TSubTableBase { - TSingleSubstFormat1(); - ~TSingleSubstFormat1() override; + struct TSubTable1 : public TSubTableBase { + TSubTable1(); + ~TSubTable1() override; - std::unique_ptr Coverage; int16_t DeltaGlyphID; - - private: - TSingleSubstFormat1(const TSingleSubstFormat1&) = delete; - TSingleSubstFormat1& operator=(const TSingleSubstFormat1&) = delete; }; - struct TSingleSubstFormat2 : public TSubTableBase { - TSingleSubstFormat2(); - ~TSingleSubstFormat2() override; + struct TSubTable2 : public TSubTableBase { + TSubTable2(); + ~TSubTable2() override; - std::unique_ptr Coverage; std::vector Substitutes; - - private: - TSingleSubstFormat2(const TSingleSubstFormat2&) = delete; - TSingleSubstFormat2& operator=(const TSingleSubstFormat2&) = delete; }; struct TLookup { @@ -208,30 +117,26 @@ class CFX_CTTGSUBTable { uint16_t LookupType; uint16_t LookupFlag; std::vector> SubTables; - - private: - TLookup(const TLookup&) = delete; - TLookup& operator=(const TLookup&) = delete; }; bool Parse(FT_Bytes scriptlist, FT_Bytes featurelist, FT_Bytes lookuplist); void ParseScriptList(FT_Bytes raw); - void ParseScript(FT_Bytes raw, TScript* rec); - void ParseLangSys(FT_Bytes raw, TLangSys* rec); + void ParseScript(FT_Bytes raw, TScriptRecord* rec); + void ParseLangSys(FT_Bytes raw, TLangSysRecord* rec); void ParseFeatureList(FT_Bytes raw); - void ParseFeature(FT_Bytes raw, TFeature* rec); + void ParseFeature(FT_Bytes raw, TFeatureRecord* rec); void ParseLookupList(FT_Bytes raw); void ParseLookup(FT_Bytes raw, TLookup* rec); std::unique_ptr 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* rec); - void ParseSingleSubstFormat1(FT_Bytes raw, TSingleSubstFormat1* rec); - void ParseSingleSubstFormat2(FT_Bytes raw, TSingleSubstFormat2* rec); + void ParseSingleSubstFormat1(FT_Bytes raw, TSubTable1* rec); + void ParseSingleSubstFormat2(FT_Bytes raw, TSubTable2* rec); bool GetVerticalGlyphSub(uint32_t glyphnum, uint32_t* vglyphnum, - TFeature* Feature); + TFeatureRecord* Feature); bool GetVerticalGlyphSub2(uint32_t glyphnum, uint32_t* vglyphnum, TLookup* Lookup); @@ -245,7 +150,6 @@ class CFX_CTTGSUBTable { std::set m_featureSet; bool m_bFeautureMapLoad; - bool loaded; std::vector ScriptList; std::vector FeatureList; std::vector LookupList; -- cgit v1.2.3