diff --git a/core/fpdfapi/font/ttgsubtable.cpp b/core/fpdfapi/font/ttgsubtable.cpp index 51e8e9c..4f4f696 100644 --- a/core/fpdfapi/font/ttgsubtable.cpp +++ b/core/fpdfapi/font/ttgsubtable.cpp @@ -94,29 +94,33 @@ bool CFX_CTTGSUBTable::GetVerticalGlyph(uint32_t glyphnum, (uint8_t)'t', }; if (!m_bFeautureMapLoad) { - for (const auto& script : ScriptList.ScriptRecords) { - for (const auto& record : script.Script.LangSysRecords) { - for (const auto& index : record.LangSys.FeatureIndices) { - if (FeatureList.FeatureRecords[index].FeatureTag == tag[0] || - FeatureList.FeatureRecords[index].FeatureTag == tag[1]) { - m_featureSet.insert(index); + for (int i = 0; i < ScriptList.ScriptCount; i++) { + for (int j = 0; j < ScriptList.ScriptRecord[i].Script.LangSysCount; ++j) { + const auto& record = ScriptList.ScriptRecord[i].Script.LangSysRecord[j]; + for (int k = 0; k < record.LangSys.FeatureCount; ++k) { + uint32_t index = record.LangSys.FeatureIndex[k]; + if (FeatureList.FeatureRecord[index].FeatureTag == tag[0] || + FeatureList.FeatureRecord[index].FeatureTag == tag[1]) { + if (!pdfium::ContainsKey(m_featureMap, index)) { + m_featureMap[index] = index; + } } } } } - if (m_featureSet.empty()) { - int i = 0; - for (const auto& feature : FeatureList.FeatureRecords) { - if (feature.FeatureTag == tag[0] || feature.FeatureTag == tag[1]) - m_featureSet.insert(i); - ++i; + if (m_featureMap.empty()) { + for (int i = 0; i < FeatureList.FeatureCount; i++) { + if (FeatureList.FeatureRecord[i].FeatureTag == tag[0] || + FeatureList.FeatureRecord[i].FeatureTag == tag[1]) { + m_featureMap[i] = i; + } } } m_bFeautureMapLoad = true; } - for (const auto& item : m_featureSet) { + for (const auto& pair : m_featureMap) { if (GetVerticalGlyphSub(glyphnum, vglyphnum, - &FeatureList.FeatureRecords[item].Feature)) { + &FeatureList.FeatureRecord[pair.second].Feature)) { return true; } } @@ -126,13 +130,16 @@ bool CFX_CTTGSUBTable::GetVerticalGlyph(uint32_t glyphnum, bool CFX_CTTGSUBTable::GetVerticalGlyphSub(uint32_t glyphnum, uint32_t* vglyphnum, TFeature* Feature) { - for (int index : Feature->LookupListIndices) { - if (index < 0 || index >= pdfium::CollectionSize(LookupList.Lookups)) + for (int i = 0; i < Feature->LookupCount; i++) { + int index = Feature->LookupListIndex[i]; + if (index < 0 || LookupList.LookupCount < index) { continue; - - if (LookupList.Lookups[index].LookupType == 1 && - GetVerticalGlyphSub2(glyphnum, vglyphnum, &LookupList.Lookups[index])) { - return true; + } + if (LookupList.Lookup[index].LookupType == 1) { + if (GetVerticalGlyphSub2(glyphnum, vglyphnum, + &LookupList.Lookup[index])) { + return true; + } } } return false; @@ -141,10 +148,10 @@ bool CFX_CTTGSUBTable::GetVerticalGlyphSub(uint32_t glyphnum, bool CFX_CTTGSUBTable::GetVerticalGlyphSub2(uint32_t glyphnum, uint32_t* vglyphnum, TLookup* Lookup) { - for (const auto& subTable : Lookup->SubTables) { - switch (subTable->SubstFormat) { + for (int i = 0; i < Lookup->SubTableCount; i++) { + switch (Lookup->SubTable[i]->SubstFormat) { case 1: { - auto tbl1 = static_cast(subTable.get()); + TSingleSubstFormat1* tbl1 = (TSingleSubstFormat1*)Lookup->SubTable[i]; if (GetCoverageIndex(tbl1->Coverage.get(), glyphnum) >= 0) { *vglyphnum = glyphnum + tbl1->DeltaGlyphID; return true; @@ -152,11 +159,11 @@ bool CFX_CTTGSUBTable::GetVerticalGlyphSub2(uint32_t glyphnum, break; } case 2: { - auto tbl2 = static_cast(subTable.get()); - int index = GetCoverageIndex(tbl2->Coverage.get(), glyphnum); - if (index >= 0 && - index < pdfium::CollectionSize(tbl2->Substitutes)) { - *vglyphnum = tbl2->Substitutes[index]; + TSingleSubstFormat2* tbl2 = (TSingleSubstFormat2*)Lookup->SubTable[i]; + int index = -1; + index = GetCoverageIndex(tbl2->Coverage.get(), glyphnum); + if (0 <= index && index < tbl2->GlyphCount) { + *vglyphnum = tbl2->Substitute[index]; return true; } break; @@ -168,28 +175,29 @@ bool CFX_CTTGSUBTable::GetVerticalGlyphSub2(uint32_t glyphnum, int CFX_CTTGSUBTable::GetCoverageIndex(TCoverageFormatBase* Coverage, uint32_t g) const { - if (!Coverage) + int i = 0; + if (!Coverage) { return -1; - + } switch (Coverage->CoverageFormat) { case 1: { - int i = 0; TCoverageFormat1* c1 = (TCoverageFormat1*)Coverage; - for (const auto& glyph : c1->GlyphArray) { - if (static_cast(glyph) == g) + for (i = 0; i < c1->GlyphCount; i++) { + if ((uint32_t)c1->GlyphArray[i] == g) { return i; - ++i; + } } return -1; } case 2: { TCoverageFormat2* c2 = (TCoverageFormat2*)Coverage; - for (const auto& rangeRec : c2->RangeRecords) { - uint32_t s = rangeRec.Start; - uint32_t e = rangeRec.End; - uint32_t si = rangeRec.StartCoverageIndex; - if (s <= g && g <= e) + for (i = 0; i < c2->RangeCount; i++) { + uint32_t s = c2->RangeRecord[i].Start; + uint32_t e = c2->RangeRecord[i].End; + uint32_t si = c2->RangeRecord[i].StartCoverageIndex; + if (s <= g && g <= e) { return si + g - s; + } } return -1; } @@ -237,21 +245,33 @@ bool CFX_CTTGSUBTable::Parse(FT_Bytes scriptlist, } void CFX_CTTGSUBTable::ParseScriptList(FT_Bytes raw, TScriptList* rec) { + int i; FT_Bytes sp = raw; - rec->ScriptRecords = std::vector(GetUInt16(sp)); - for (auto& scriptRec : rec->ScriptRecords) { - scriptRec.ScriptTag = GetUInt32(sp); - ParseScript(&raw[GetUInt16(sp)], &scriptRec.Script); + rec->ScriptCount = GetUInt16(sp); + if (rec->ScriptCount <= 0) { + return; + } + rec->ScriptRecord.reset(new TScriptRecord[rec->ScriptCount]); + for (i = 0; i < rec->ScriptCount; i++) { + rec->ScriptRecord[i].ScriptTag = GetUInt32(sp); + uint16_t offset = GetUInt16(sp); + ParseScript(&raw[offset], &rec->ScriptRecord[i].Script); } } void CFX_CTTGSUBTable::ParseScript(FT_Bytes raw, TScript* rec) { + int i; 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); + rec->LangSysCount = GetUInt16(sp); + if (rec->LangSysCount <= 0) { + return; + } + rec->LangSysRecord.reset(new TLangSysRecord[rec->LangSysCount]); + for (i = 0; i < rec->LangSysCount; i++) { + rec->LangSysRecord[i].LangSysTag = GetUInt32(sp); + uint16_t offset = GetUInt16(sp); + ParseLangSys(&raw[offset], &rec->LangSysRecord[i].LangSys); } } @@ -259,45 +279,81 @@ void CFX_CTTGSUBTable::ParseLangSys(FT_Bytes raw, TLangSys* rec) { FT_Bytes sp = raw; rec->LookupOrder = GetUInt16(sp); rec->ReqFeatureIndex = GetUInt16(sp); - rec->FeatureIndices = std::vector(GetUInt16(sp)); - for (auto& element : rec->FeatureIndices) - element = GetUInt16(sp); + rec->FeatureCount = GetUInt16(sp); + if (rec->FeatureCount <= 0) { + return; + } + rec->FeatureIndex.reset(new uint16_t[rec->FeatureCount]); + FXSYS_memset(rec->FeatureIndex.get(), 0, + sizeof(uint16_t) * rec->FeatureCount); + for (int i = 0; i < rec->FeatureCount; ++i) { + rec->FeatureIndex[i] = GetUInt16(sp); + } } void CFX_CTTGSUBTable::ParseFeatureList(FT_Bytes raw, TFeatureList* rec) { + int i; FT_Bytes sp = raw; - rec->FeatureRecords = std::vector(GetUInt16(sp)); - for (auto& featureRec : rec->FeatureRecords) { - featureRec.FeatureTag = GetUInt32(sp); - ParseFeature(&raw[GetUInt16(sp)], &featureRec.Feature); + rec->FeatureCount = GetUInt16(sp); + if (rec->FeatureCount <= 0) { + return; + } + rec->FeatureRecord.reset(new TFeatureRecord[rec->FeatureCount]); + for (i = 0; i < rec->FeatureCount; i++) { + rec->FeatureRecord[i].FeatureTag = GetUInt32(sp); + uint16_t offset = GetUInt16(sp); + ParseFeature(&raw[offset], &rec->FeatureRecord[i].Feature); } } void CFX_CTTGSUBTable::ParseFeature(FT_Bytes raw, TFeature* rec) { + int i; FT_Bytes sp = raw; rec->FeatureParams = GetUInt16(sp); - rec->LookupListIndices = std::vector(GetUInt16(sp)); - for (auto& listIndex : rec->LookupListIndices) - listIndex = GetUInt16(sp); + rec->LookupCount = GetUInt16(sp); + if (rec->LookupCount <= 0) { + return; + } + rec->LookupListIndex.reset(new uint16_t[rec->LookupCount]); + for (i = 0; i < rec->LookupCount; i++) { + rec->LookupListIndex[i] = GetUInt16(sp); + } } void CFX_CTTGSUBTable::ParseLookupList(FT_Bytes raw, TLookupList* rec) { + int i; FT_Bytes sp = raw; - rec->Lookups = std::vector(GetUInt16(sp)); - for (auto& lookup : rec->Lookups) - ParseLookup(&raw[GetUInt16(sp)], &lookup); + rec->LookupCount = GetUInt16(sp); + if (rec->LookupCount <= 0) { + return; + } + rec->Lookup.reset(new TLookup[rec->LookupCount]); + for (i = 0; i < rec->LookupCount; i++) { + uint16_t offset = GetUInt16(sp); + ParseLookup(&raw[offset], &rec->Lookup[i]); + } } void CFX_CTTGSUBTable::ParseLookup(FT_Bytes raw, TLookup* rec) { + int i; FT_Bytes sp = raw; rec->LookupType = GetUInt16(sp); rec->LookupFlag = GetUInt16(sp); - rec->SubTables = std::vector>(GetUInt16(sp)); - if (rec->LookupType != 1) + rec->SubTableCount = GetUInt16(sp); + if (rec->SubTableCount <= 0) { return; - - for (auto& subTable : rec->SubTables) - ParseSingleSubst(&raw[GetUInt16(sp)], &subTable); + } + rec->SubTable.reset(new TSubTableBase*[rec->SubTableCount]); + for (i = 0; i < rec->SubTableCount; i++) { + rec->SubTable[i] = nullptr; + } + if (rec->LookupType != 1) { + return; + } + for (i = 0; i < rec->SubTableCount; i++) { + uint16_t offset = GetUInt16(sp); + ParseSingleSubst(&raw[offset], &rec->SubTable[i]); + } } CFX_CTTGSUBTable::TCoverageFormatBase* CFX_CTTGSUBTable::ParseCoverage( @@ -317,39 +373,47 @@ CFX_CTTGSUBTable::TCoverageFormatBase* CFX_CTTGSUBTable::ParseCoverage( void CFX_CTTGSUBTable::ParseCoverageFormat1(FT_Bytes raw, TCoverageFormat1* rec) { + int i; FT_Bytes sp = raw; - (void)GetUInt16(sp); - rec->GlyphArray = std::vector(GetUInt16(sp)); - for (auto& glyph : rec->GlyphArray) - glyph = GetUInt16(sp); + GetUInt16(sp); + rec->GlyphCount = GetUInt16(sp); + if (rec->GlyphCount <= 0) { + return; + } + rec->GlyphArray.reset(new uint16_t[rec->GlyphCount]); + for (i = 0; i < rec->GlyphCount; i++) { + rec->GlyphArray[i] = GetUInt16(sp); + } } void CFX_CTTGSUBTable::ParseCoverageFormat2(FT_Bytes raw, TCoverageFormat2* rec) { + int i; FT_Bytes sp = raw; - (void)GetUInt16(sp); - rec->RangeRecords = std::vector(GetUInt16(sp)); - for (auto& rangeRec : rec->RangeRecords) { - rangeRec.Start = GetUInt16(sp); - rangeRec.End = GetUInt16(sp); - rangeRec.StartCoverageIndex = GetUInt16(sp); + GetUInt16(sp); + rec->RangeCount = GetUInt16(sp); + if (rec->RangeCount <= 0) { + return; + } + rec->RangeRecord.reset(new TRangeRecord[rec->RangeCount]); + for (i = 0; i < rec->RangeCount; i++) { + rec->RangeRecord[i].Start = GetUInt16(sp); + rec->RangeRecord[i].End = GetUInt16(sp); + rec->RangeRecord[i].StartCoverageIndex = GetUInt16(sp); } } -void CFX_CTTGSUBTable::ParseSingleSubst(FT_Bytes raw, - std::unique_ptr* rec) { +void CFX_CTTGSUBTable::ParseSingleSubst(FT_Bytes raw, TSubTableBase** rec) { FT_Bytes sp = raw; uint16_t Format = GetUInt16(sp); switch (Format) { case 1: - *rec = pdfium::MakeUnique(); - ParseSingleSubstFormat1(raw, - static_cast(rec->get())); + *rec = new TSingleSubstFormat1(); + ParseSingleSubstFormat1(raw, (TSingleSubstFormat1*)*rec); break; case 2: - *rec = pdfium::MakeUnique(); - ParseSingleSubstFormat2(raw, - static_cast(rec->get())); + *rec = new TSingleSubstFormat2(); + ParseSingleSubstFormat2(raw, (TSingleSubstFormat2*)*rec); break; } } @@ -365,17 +429,23 @@ void CFX_CTTGSUBTable::ParseSingleSubstFormat1(FT_Bytes raw, void CFX_CTTGSUBTable::ParseSingleSubstFormat2(FT_Bytes raw, TSingleSubstFormat2* rec) { + int i; FT_Bytes sp = raw; - (void)GetUInt16(sp); + GetUInt16(sp); uint16_t offset = GetUInt16(sp); rec->Coverage.reset(ParseCoverage(&raw[offset])); - rec->Substitutes = std::vector(GetUInt16(sp)); - for (auto& substitute : rec->Substitutes) - substitute = GetUInt16(sp); + rec->GlyphCount = GetUInt16(sp); + if (rec->GlyphCount <= 0) { + return; + } + rec->Substitute.reset(new uint16_t[rec->GlyphCount]); + for (i = 0; i < rec->GlyphCount; i++) { + rec->Substitute[i] = GetUInt16(sp); + } } CFX_CTTGSUBTable::TCoverageFormat1::TCoverageFormat1() - : TCoverageFormatBase(1) {} + : TCoverageFormatBase(1), GlyphCount(0) {} CFX_CTTGSUBTable::TCoverageFormat1::~TCoverageFormat1() {} @@ -383,7 +453,7 @@ CFX_CTTGSUBTable::TRangeRecord::TRangeRecord() : Start(0), End(0), StartCoverageIndex(0) {} CFX_CTTGSUBTable::TCoverageFormat2::TCoverageFormat2() - : TCoverageFormatBase(2) {} + : TCoverageFormatBase(2), RangeCount(0) {} CFX_CTTGSUBTable::TCoverageFormat2::~TCoverageFormat2() {} @@ -393,34 +463,41 @@ CFX_CTTGSUBTable::TSingleSubstFormat1::TSingleSubstFormat1() CFX_CTTGSUBTable::TSingleSubstFormat1::~TSingleSubstFormat1() {} CFX_CTTGSUBTable::TSingleSubstFormat2::TSingleSubstFormat2() - : TSubTableBase(2) {} + : TSubTableBase(2), GlyphCount(0) {} CFX_CTTGSUBTable::TSingleSubstFormat2::~TSingleSubstFormat2() {} -CFX_CTTGSUBTable::TLookup::TLookup() : LookupType(0), LookupFlag(0) {} +CFX_CTTGSUBTable::TLookup::TLookup() + : LookupType(0), LookupFlag(0), SubTableCount(0) {} -CFX_CTTGSUBTable::TLookup::~TLookup() {} +CFX_CTTGSUBTable::TLookup::~TLookup() { + if (SubTable) { + for (int i = 0; i < SubTableCount; ++i) + delete SubTable[i]; + } +} -CFX_CTTGSUBTable::TScript::TScript() : DefaultLangSys(0) {} +CFX_CTTGSUBTable::TScript::TScript() : DefaultLangSys(0), LangSysCount(0) {} CFX_CTTGSUBTable::TScript::~TScript() {} -CFX_CTTGSUBTable::TScriptList::TScriptList() {} +CFX_CTTGSUBTable::TScriptList::TScriptList() : ScriptCount(0) {} CFX_CTTGSUBTable::TScriptList::~TScriptList() {} -CFX_CTTGSUBTable::TFeature::TFeature() : FeatureParams(0) {} +CFX_CTTGSUBTable::TFeature::TFeature() : FeatureParams(0), LookupCount(0) {} CFX_CTTGSUBTable::TFeature::~TFeature() {} -CFX_CTTGSUBTable::TFeatureList::TFeatureList() {} +CFX_CTTGSUBTable::TFeatureList::TFeatureList() : FeatureCount(0) {} CFX_CTTGSUBTable::TFeatureList::~TFeatureList() {} -CFX_CTTGSUBTable::TLookupList::TLookupList() {} +CFX_CTTGSUBTable::TLookupList::TLookupList() : LookupCount(0) {} CFX_CTTGSUBTable::TLookupList::~TLookupList() {} -CFX_CTTGSUBTable::TLangSys::TLangSys() : LookupOrder(0), ReqFeatureIndex(0) {} +CFX_CTTGSUBTable::TLangSys::TLangSys() + : LookupOrder(0), ReqFeatureIndex(0), FeatureCount(0) {} CFX_CTTGSUBTable::TLangSys::~TLangSys() {} diff --git a/core/fpdfapi/font/ttgsubtable.h b/core/fpdfapi/font/ttgsubtable.h index f927269..59ee4ca 100644 --- a/core/fpdfapi/font/ttgsubtable.h +++ b/core/fpdfapi/font/ttgsubtable.h @@ -9,9 +9,8 @@ #include +#include #include -#include -#include #include "core/fxcrt/fx_basic.h" #include "core/fxge/fx_font.h" @@ -53,7 +52,8 @@ class CFX_CTTGSUBTable { uint16_t LookupOrder; uint16_t ReqFeatureIndex; - std::vector FeatureIndices; + uint16_t FeatureCount; + std::unique_ptr FeatureIndex; private: TLangSys(const TLangSys&) = delete; @@ -76,7 +76,8 @@ class CFX_CTTGSUBTable { ~TScript(); uint16_t DefaultLangSys; - std::vector LangSysRecords; + uint16_t LangSysCount; + std::unique_ptr LangSysRecord; private: TScript(const TScript&) = delete; @@ -98,7 +99,8 @@ class CFX_CTTGSUBTable { TScriptList(); ~TScriptList(); - std::vector ScriptRecords; + uint16_t ScriptCount; + std::unique_ptr ScriptRecord; private: TScriptList(const TScriptList&) = delete; @@ -110,13 +112,13 @@ class CFX_CTTGSUBTable { ~TFeature(); uint16_t FeatureParams; - std::vector LookupListIndices; + int LookupCount; + std::unique_ptr LookupListIndex; private: TFeature(const TFeature&) = delete; TFeature& operator=(const TFeature&) = delete; }; - struct TFeatureRecord { TFeatureRecord() : FeatureTag(0) {} @@ -132,7 +134,8 @@ class CFX_CTTGSUBTable { TFeatureList(); ~TFeatureList(); - std::vector FeatureRecords; + int FeatureCount; + std::unique_ptr FeatureRecord; private: TFeatureList(const TFeatureList&) = delete; @@ -165,7 +168,8 @@ class CFX_CTTGSUBTable { TCoverageFormat1(); ~TCoverageFormat1() override; - std::vector GlyphArray; + uint16_t GlyphCount; + std::unique_ptr GlyphArray; private: TCoverageFormat1(const TCoverageFormat1&) = delete; @@ -191,7 +195,8 @@ class CFX_CTTGSUBTable { TCoverageFormat2(); ~TCoverageFormat2() override; - std::vector RangeRecords; + uint16_t RangeCount; + std::unique_ptr RangeRecord; private: TCoverageFormat2(const TCoverageFormat2&) = delete; @@ -239,7 +244,8 @@ class CFX_CTTGSUBTable { ~TSingleSubstFormat2() override; std::unique_ptr Coverage; - std::vector Substitutes; + uint16_t GlyphCount; + std::unique_ptr Substitute; private: TSingleSubstFormat2(const TSingleSubstFormat2&) = delete; @@ -252,7 +258,8 @@ class CFX_CTTGSUBTable { uint16_t LookupType; uint16_t LookupFlag; - std::vector> SubTables; + uint16_t SubTableCount; + std::unique_ptr SubTable; private: TLookup(const TLookup&) = delete; @@ -263,7 +270,8 @@ class CFX_CTTGSUBTable { TLookupList(); ~TLookupList(); - std::vector Lookups; + int LookupCount; + std::unique_ptr Lookup; private: TLookupList(const TLookupList&) = delete; @@ -281,7 +289,7 @@ class CFX_CTTGSUBTable { 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* rec); + void ParseSingleSubst(FT_Bytes raw, TSubTableBase** rec); void ParseSingleSubstFormat1(FT_Bytes raw, TSingleSubstFormat1* rec); void ParseSingleSubstFormat2(FT_Bytes raw, TSingleSubstFormat2* rec); @@ -299,7 +307,7 @@ class CFX_CTTGSUBTable { int32_t GetInt32(FT_Bytes& p) const; uint32_t GetUInt32(FT_Bytes& p) const; - std::set m_featureSet; + std::map m_featureMap; bool m_bFeautureMapLoad; bool loaded; tt_gsub_header header; diff --git a/core/fpdfapi/page/cpdf_contentmarkitem.h b/core/fpdfapi/page/cpdf_contentmarkitem.h index ed27371..2d08a8e 100644 --- a/core/fpdfapi/page/cpdf_contentmarkitem.h +++ b/core/fpdfapi/page/cpdf_contentmarkitem.h @@ -23,8 +23,6 @@ class CPDF_ContentMarkItem { CPDF_ContentMarkItem(const CPDF_ContentMarkItem& that); ~CPDF_ContentMarkItem(); - CPDF_ContentMarkItem& operator=(CPDF_ContentMarkItem&& other) = default; - CFX_ByteString GetName() const { return m_MarkName; } ParamType GetParamType() const { return m_ParamType; } CPDF_Dictionary* GetParam() const; diff --git a/core/fpdfapi/page/cpdf_psengine.h b/core/fpdfapi/page/cpdf_psengine.h index 659ca82..0c94959 100644 --- a/core/fpdfapi/page/cpdf_psengine.h +++ b/core/fpdfapi/page/cpdf_psengine.h @@ -63,7 +63,7 @@ enum PDF_PSOP { PSOP_CONST }; -constexpr uint32_t PSENGINE_STACKSIZE = 100; +const uint32_t PSENGINE_STACKSIZE = 100; class CPDF_PSProc { public: diff --git a/core/fxge/ge/cfx_facecache.cpp b/core/fxge/ge/cfx_facecache.cpp index cbaa07e..95338c2 100644 --- a/core/fxge/ge/cfx_facecache.cpp +++ b/core/fxge/ge/cfx_facecache.cpp @@ -25,7 +25,7 @@ namespace { -constexpr uint32_t kInvalidGlyphIndex = static_cast(-1); +const uint32_t kInvalidGlyphIndex = static_cast(-1); void GammaAdjust(uint8_t* pData, int nHeight, diff --git a/third_party/base/numerics/safe_conversions.h b/third_party/base/numerics/safe_conversions.h index dc61d9c..ae25d70 100644 --- a/third_party/base/numerics/safe_conversions.h +++ b/third_party/base/numerics/safe_conversions.h @@ -51,7 +51,7 @@ namespace base { // Convenience function that returns true if the supplied value is in range // for the destination type. template -constexpr bool IsValueInRangeForNumericType(Src value) { +bool IsValueInRangeForNumericType(Src value) { return internal::DstRangeRelationToSrcRange(value).IsValid(); } @@ -72,7 +72,7 @@ struct CheckOnFailure { // except that it CHECKs that the specified numeric conversion will not // overflow or underflow. NaN source will always trigger a CHECK. template -constexpr Dst checked_cast(Src value) { +Dst checked_cast(Src value) { // This throws a compile-time error on evaluating the constexpr if it can be // determined at compile-time as failing, otherwise it will CHECK at runtime. using SrcType = typename internal::UnderlyingType::type; @@ -84,19 +84,19 @@ constexpr Dst checked_cast(Src value) { // Default boundaries for integral/float: max/infinity, lowest/-infinity, 0/NaN. template struct SaturationDefaultHandler { - static constexpr T NaN() { + static T NaN() { return std::numeric_limits::has_quiet_NaN ? std::numeric_limits::quiet_NaN() : T(); } - static constexpr T max() { return std::numeric_limits::max(); } - static constexpr T Overflow() { + static T max() { return std::numeric_limits::max(); } + static T Overflow() { return std::numeric_limits::has_infinity ? std::numeric_limits::infinity() : std::numeric_limits::max(); } - static constexpr T lowest() { return std::numeric_limits::lowest(); } - static constexpr T Underflow() { + static T lowest() { return std::numeric_limits::lowest(); } + static T Underflow() { return std::numeric_limits::has_infinity ? std::numeric_limits::infinity() * -1 : std::numeric_limits::lowest(); @@ -106,7 +106,7 @@ struct SaturationDefaultHandler { namespace internal { template class S, typename Src> -constexpr Dst saturated_cast_impl(Src value, RangeCheck constraint) { +Dst saturated_cast_impl(Src value, RangeCheck constraint) { // For some reason clang generates much better code when the branch is // structured exactly this way, rather than a sequence of checks. return !constraint.IsOverflowFlagSet() @@ -126,7 +126,7 @@ template class SaturationHandler = SaturationDefaultHandler, typename Src> -constexpr Dst saturated_cast(Src value) { +Dst saturated_cast(Src value) { using SrcType = typename UnderlyingType::type; return saturated_cast_impl( value, @@ -137,7 +137,7 @@ constexpr Dst saturated_cast(Src value) { // it will cause a compile failure if the destination type is not large enough // to contain any value in the source type. It performs no runtime checking. template -constexpr Dst strict_cast(Src value) { +Dst strict_cast(Src value) { using SrcType = typename UnderlyingType::type; static_assert(UnderlyingType::is_numeric, "Argument must be numeric."); static_assert(std::is_arithmetic::value, "Result must be numeric."); @@ -187,17 +187,17 @@ class StrictNumeric { public: using type = T; - constexpr StrictNumeric() : value_(0) {} + StrictNumeric() : value_(0) {} // Copy constructor. template - constexpr StrictNumeric(const StrictNumeric& rhs) + StrictNumeric(const StrictNumeric& rhs) : value_(strict_cast(rhs.value_)) {} // This is not an explicit constructor because we implicitly upgrade regular // numerics to StrictNumerics to make them easier to use. template - constexpr StrictNumeric(Src value) // NOLINT(runtime/explicit) + StrictNumeric(Src value) // NOLINT(runtime/explicit) : value_(strict_cast(value)) {} // If you got here from a compiler error, it's because you tried to assign @@ -215,7 +215,7 @@ class StrictNumeric { template ::value>::type* = nullptr> - constexpr operator Dst() const { + operator Dst() const { return static_cast::type>(value_); } @@ -225,7 +225,7 @@ class StrictNumeric { // Convience wrapper returns a StrictNumeric from the provided arithmetic type. template -constexpr StrictNumeric::type> MakeStrictNum( +StrictNumeric::type> MakeStrictNum( const T value) { return value; } @@ -241,7 +241,7 @@ std::ostream& operator<<(std::ostream& os, const StrictNumeric& value) { template ::value>::type* = nullptr> \ - constexpr bool operator OP(const L lhs, const R rhs) { \ + bool operator OP(const L lhs, const R rhs) { \ return SafeCompare::type, \ typename UnderlyingType::type>(lhs, rhs); \ } diff --git a/third_party/base/numerics/safe_conversions_impl.h b/third_party/base/numerics/safe_conversions_impl.h index 2a7ce14..4a1b386 100644 --- a/third_party/base/numerics/safe_conversions_impl.h +++ b/third_party/base/numerics/safe_conversions_impl.h @@ -42,14 +42,14 @@ struct PositionOfSignBit { // warnings on: unsigned(value) < 0. template ::value>::type* = nullptr> -constexpr bool IsValueNegative(T value) { +bool IsValueNegative(T value) { static_assert(std::is_arithmetic::value, "Argument must be numeric."); return value < 0; } template ::value>::type* = nullptr> -constexpr bool IsValueNegative(T) { +bool IsValueNegative(T) { static_assert(std::is_arithmetic::value, "Argument must be numeric."); return false; } @@ -58,7 +58,7 @@ constexpr bool IsValueNegative(T) { // arguments, but probably doesn't do what you want for any unsigned value // larger than max / 2 + 1 (i.e. signed min cast to unsigned). template -constexpr typename std::make_signed::type ConditionalNegate( +typename std::make_signed::type ConditionalNegate( T x, bool is_negative) { static_assert(std::is_integral::value, "Type must be integral"); @@ -70,7 +70,7 @@ constexpr typename std::make_signed::type ConditionalNegate( // This performs a safe, absolute value via unsigned overflow. template -constexpr typename std::make_unsigned::type SafeUnsignedAbs(T value) { +typename std::make_unsigned::type SafeUnsignedAbs(T value) { static_assert(std::is_integral::value, "Type must be integral"); using UnsignedT = typename std::make_unsigned::type; return IsValueNegative(value) ? 0 - static_cast(value) @@ -141,20 +141,20 @@ struct StaticDstRangeRelationToSrcRange::value, ""); static_assert(kShift < DstLimits::digits, ""); return static_cast( @@ -214,14 +214,14 @@ struct NarrowingRange { template ::value>::type* = nullptr> - static constexpr T Adjust(T value) { + static T Adjust(T value) { static_assert(std::is_same::value, ""); static_assert(kShift == 0, ""); return value; } - static constexpr Dst max() { return Adjust(Bounds::max()); } - static constexpr Dst lowest() { return Adjust(Bounds::lowest()); } + static Dst max() { return Adjust(Bounds::max()); } + static Dst lowest() { return Adjust(Bounds::lowest()); } }; template { - static constexpr RangeCheck Check(Src value) { + static RangeCheck Check(Src value) { using SrcLimits = std::numeric_limits; using DstLimits = NarrowingRange; return RangeCheck( @@ -273,7 +273,7 @@ struct DstRangeRelationToSrcRangeImpl { - static constexpr RangeCheck Check(Src value) { + static RangeCheck Check(Src value) { using DstLimits = NarrowingRange; return RangeCheck(value >= DstLimits::lowest(), value <= DstLimits::max()); } @@ -288,7 +288,7 @@ struct DstRangeRelationToSrcRangeImpl { - static constexpr RangeCheck Check(Src value) { + static RangeCheck Check(Src value) { using DstLimits = NarrowingRange; return RangeCheck( DstLimits::lowest() == Dst(0) || value >= DstLimits::lowest(), @@ -304,7 +304,7 @@ struct DstRangeRelationToSrcRangeImpl { - static constexpr RangeCheck Check(Src value) { + static RangeCheck Check(Src value) { using DstLimits = NarrowingRange; using Promotion = decltype(Src() + Dst()); return RangeCheck(DstLimits::lowest() <= Dst(0) || @@ -324,7 +324,7 @@ struct DstRangeRelationToSrcRangeImpl { - static constexpr RangeCheck Check(Src value) { + static RangeCheck Check(Src value) { using SrcLimits = std::numeric_limits; using DstLimits = NarrowingRange; using Promotion = decltype(Src() + Dst()); @@ -341,10 +341,9 @@ struct DstRangeRelationToSrcRangeImpl class Bounds = std::numeric_limits, typename Src> -constexpr RangeCheck DstRangeRelationToSrcRange(Src value) { +RangeCheck DstRangeRelationToSrcRange(Src value) { static_assert(std::is_arithmetic::value, "Argument must be numeric."); static_assert(std::is_arithmetic::value, "Result must be numeric."); - static_assert(Bounds::lowest() < Bounds::max(), ""); return DstRangeRelationToSrcRangeImpl::Check(value); } @@ -603,7 +602,7 @@ struct IsStrictOp { }; template -constexpr bool IsLessImpl(const L lhs, +bool IsLessImpl(const L lhs, const R rhs, const RangeCheck l_range, const RangeCheck r_range) { @@ -617,14 +616,14 @@ template struct IsLess { static_assert(std::is_arithmetic::value && std::is_arithmetic::value, "Types must be numeric."); - static constexpr bool Test(const L lhs, const R rhs) { + static bool Test(const L lhs, const R rhs) { return IsLessImpl(lhs, rhs, DstRangeRelationToSrcRange(lhs), DstRangeRelationToSrcRange(rhs)); } }; template -constexpr bool IsLessOrEqualImpl(const L lhs, +bool IsLessOrEqualImpl(const L lhs, const R rhs, const RangeCheck l_range, const RangeCheck r_range) { @@ -638,14 +637,14 @@ template struct IsLessOrEqual { static_assert(std::is_arithmetic::value && std::is_arithmetic::value, "Types must be numeric."); - static constexpr bool Test(const L lhs, const R rhs) { + static bool Test(const L lhs, const R rhs) { return IsLessOrEqualImpl(lhs, rhs, DstRangeRelationToSrcRange(lhs), DstRangeRelationToSrcRange(rhs)); } }; template -constexpr bool IsGreaterImpl(const L lhs, +bool IsGreaterImpl(const L lhs, const R rhs, const RangeCheck l_range, const RangeCheck r_range) { @@ -659,14 +658,14 @@ template struct IsGreater { static_assert(std::is_arithmetic::value && std::is_arithmetic::value, "Types must be numeric."); - static constexpr bool Test(const L lhs, const R rhs) { + static bool Test(const L lhs, const R rhs) { return IsGreaterImpl(lhs, rhs, DstRangeRelationToSrcRange(lhs), DstRangeRelationToSrcRange(rhs)); } }; template -constexpr bool IsGreaterOrEqualImpl(const L lhs, +bool IsGreaterOrEqualImpl(const L lhs, const R rhs, const RangeCheck l_range, const RangeCheck r_range) { @@ -680,7 +679,7 @@ template struct IsGreaterOrEqual { static_assert(std::is_arithmetic::value && std::is_arithmetic::value, "Types must be numeric."); - static constexpr bool Test(const L lhs, const R rhs) { + static bool Test(const L lhs, const R rhs) { return IsGreaterOrEqualImpl(lhs, rhs, DstRangeRelationToSrcRange(lhs), DstRangeRelationToSrcRange(rhs)); } @@ -690,7 +689,7 @@ template struct IsEqual { static_assert(std::is_arithmetic::value && std::is_arithmetic::value, "Types must be numeric."); - static constexpr bool Test(const L lhs, const R rhs) { + static bool Test(const L lhs, const R rhs) { return DstRangeRelationToSrcRange(lhs) == DstRangeRelationToSrcRange(rhs) && static_cast(lhs) == @@ -702,7 +701,7 @@ template struct IsNotEqual { static_assert(std::is_arithmetic::value && std::is_arithmetic::value, "Types must be numeric."); - static constexpr bool Test(const L lhs, const R rhs) { + static bool Test(const L lhs, const R rhs) { return DstRangeRelationToSrcRange(lhs) != DstRangeRelationToSrcRange(rhs) || static_cast(lhs) != @@ -713,7 +712,7 @@ struct IsNotEqual { // These perform the actual math operations on the CheckedNumerics. // Binary arithmetic operations. template