summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2018-06-26 19:48:59 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-06-26 19:48:59 +0000
commitc4dce690f433a41c4429e872c2306e09b14c5d9f (patch)
tree43990b61718628e7731fb8b6bf7c12e4df04b8ff
parentca386ad150be28116997b713056a4a2197c7b7e8 (diff)
downloadpdfium-c4dce690f433a41c4429e872c2306e09b14c5d9f.tar.xz
Use pdfium::span<> in cpdf_fontglobals.h
Required moving some sizes to .h file for default construction of spans from c-style arrays. Change-Id: I45c42103f3575bc83e57a085ad4e8f16698468d3 Reviewed-on: https://pdfium-review.googlesource.com/36190 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
-rw-r--r--core/fpdfapi/cmaps/CNS1/cmaps_cns1.cpp6
-rw-r--r--core/fpdfapi/cmaps/CNS1/cmaps_cns1.h2
-rw-r--r--core/fpdfapi/cmaps/GB1/cmaps_gb1.cpp6
-rw-r--r--core/fpdfapi/cmaps/GB1/cmaps_gb1.h2
-rw-r--r--core/fpdfapi/cmaps/Japan1/cmaps_japan1.cpp5
-rw-r--r--core/fpdfapi/cmaps/Japan1/cmaps_japan1.h2
-rw-r--r--core/fpdfapi/cmaps/Korea1/cmaps_korea1.cpp5
-rw-r--r--core/fpdfapi/cmaps/Korea1/cmaps_korea1.h2
-rw-r--r--core/fpdfapi/cmaps/fpdf_cmaps.cpp9
-rw-r--r--core/fpdfapi/font/cpdf_fontglobals.h29
10 files changed, 26 insertions, 42 deletions
diff --git a/core/fpdfapi/cmaps/CNS1/cmaps_cns1.cpp b/core/fpdfapi/cmaps/CNS1/cmaps_cns1.cpp
index 5076fcdd88..1291fa1c40 100644
--- a/core/fpdfapi/cmaps/CNS1/cmaps_cns1.cpp
+++ b/core/fpdfapi/cmaps/CNS1/cmaps_cns1.cpp
@@ -41,8 +41,6 @@ static const FXCMAP_CMap g_FXCMAP_CNS1_cmaps[] = {
void CPDF_ModuleMgr::LoadEmbeddedCNS1CMaps() {
CPDF_FontGlobals* pFontGlobals =
CPDF_ModuleMgr::Get()->GetPageModule()->GetFontGlobals();
- pFontGlobals->SetEmbeddedCharset(CIDSET_CNS1, g_FXCMAP_CNS1_cmaps,
- FX_ArraySize(g_FXCMAP_CNS1_cmaps));
- pFontGlobals->SetEmbeddedToUnicode(CIDSET_CNS1, g_FXCMAP_CNS1CID2Unicode_5,
- 19088);
+ pFontGlobals->SetEmbeddedCharset(CIDSET_CNS1, g_FXCMAP_CNS1_cmaps);
+ pFontGlobals->SetEmbeddedToUnicode(CIDSET_CNS1, g_FXCMAP_CNS1CID2Unicode_5);
}
diff --git a/core/fpdfapi/cmaps/CNS1/cmaps_cns1.h b/core/fpdfapi/cmaps/CNS1/cmaps_cns1.h
index 627feb7bed..483fd66fc2 100644
--- a/core/fpdfapi/cmaps/CNS1/cmaps_cns1.h
+++ b/core/fpdfapi/cmaps/CNS1/cmaps_cns1.h
@@ -26,6 +26,6 @@ extern const FXCMAP_DWordCIDMap g_FXCMAP_CNS_EUC_V_0_DWord[];
extern const uint16_t g_FXCMAP_UniCNS_UCS2_H_3[];
extern const uint16_t g_FXCMAP_UniCNS_UCS2_V_3[];
extern const uint16_t g_FXCMAP_UniCNS_UTF16_H_0[];
-extern const uint16_t g_FXCMAP_CNS1CID2Unicode_5[];
+extern const uint16_t g_FXCMAP_CNS1CID2Unicode_5[19088];
#endif // CORE_FPDFAPI_CMAPS_CNS1_CMAPS_CNS1_H_
diff --git a/core/fpdfapi/cmaps/GB1/cmaps_gb1.cpp b/core/fpdfapi/cmaps/GB1/cmaps_gb1.cpp
index f35161ab97..26022c623d 100644
--- a/core/fpdfapi/cmaps/GB1/cmaps_gb1.cpp
+++ b/core/fpdfapi/cmaps/GB1/cmaps_gb1.cpp
@@ -41,8 +41,6 @@ static const FXCMAP_CMap g_FXCMAP_GB1_cmaps[] = {
void CPDF_ModuleMgr::LoadEmbeddedGB1CMaps() {
CPDF_FontGlobals* pFontGlobals =
CPDF_ModuleMgr::Get()->GetPageModule()->GetFontGlobals();
- pFontGlobals->SetEmbeddedCharset(CIDSET_GB1, g_FXCMAP_GB1_cmaps,
- FX_ArraySize(g_FXCMAP_GB1_cmaps));
- pFontGlobals->SetEmbeddedToUnicode(CIDSET_GB1, g_FXCMAP_GB1CID2Unicode_5,
- 30284);
+ pFontGlobals->SetEmbeddedCharset(CIDSET_GB1, g_FXCMAP_GB1_cmaps);
+ pFontGlobals->SetEmbeddedToUnicode(CIDSET_GB1, g_FXCMAP_GB1CID2Unicode_5);
}
diff --git a/core/fpdfapi/cmaps/GB1/cmaps_gb1.h b/core/fpdfapi/cmaps/GB1/cmaps_gb1.h
index a475af1568..989d9ce163 100644
--- a/core/fpdfapi/cmaps/GB1/cmaps_gb1.h
+++ b/core/fpdfapi/cmaps/GB1/cmaps_gb1.h
@@ -24,6 +24,6 @@ extern const FXCMAP_DWordCIDMap g_FXCMAP_GBK2K_H_5_DWord[];
extern const uint16_t g_FXCMAP_GBK2K_V_5[];
extern const uint16_t g_FXCMAP_UniGB_UCS2_H_4[];
extern const uint16_t g_FXCMAP_UniGB_UCS2_V_4[];
-extern const uint16_t g_FXCMAP_GB1CID2Unicode_5[];
+extern const uint16_t g_FXCMAP_GB1CID2Unicode_5[30284];
#endif // CORE_FPDFAPI_CMAPS_GB1_CMAPS_GB1_H_
diff --git a/core/fpdfapi/cmaps/Japan1/cmaps_japan1.cpp b/core/fpdfapi/cmaps/Japan1/cmaps_japan1.cpp
index f640fdd597..ecc2b3fd3b 100644
--- a/core/fpdfapi/cmaps/Japan1/cmaps_japan1.cpp
+++ b/core/fpdfapi/cmaps/Japan1/cmaps_japan1.cpp
@@ -53,8 +53,7 @@ static const FXCMAP_CMap g_FXCMAP_Japan1_cmaps[] = {
void CPDF_ModuleMgr::LoadEmbeddedJapan1CMaps() {
CPDF_FontGlobals* pFontGlobals =
CPDF_ModuleMgr::Get()->GetPageModule()->GetFontGlobals();
- pFontGlobals->SetEmbeddedCharset(CIDSET_JAPAN1, g_FXCMAP_Japan1_cmaps,
- FX_ArraySize(g_FXCMAP_Japan1_cmaps));
+ pFontGlobals->SetEmbeddedCharset(CIDSET_JAPAN1, g_FXCMAP_Japan1_cmaps);
pFontGlobals->SetEmbeddedToUnicode(CIDSET_JAPAN1,
- g_FXCMAP_Japan1CID2Unicode_4, 15444);
+ g_FXCMAP_Japan1CID2Unicode_4);
}
diff --git a/core/fpdfapi/cmaps/Japan1/cmaps_japan1.h b/core/fpdfapi/cmaps/Japan1/cmaps_japan1.h
index 27777f2dec..0979d2a40d 100644
--- a/core/fpdfapi/cmaps/Japan1/cmaps_japan1.h
+++ b/core/fpdfapi/cmaps/Japan1/cmaps_japan1.h
@@ -30,6 +30,6 @@ extern const uint16_t g_FXCMAP_UniJIS_UCS2_HW_V_4[];
extern const uint16_t g_FXCMAP_UniJIS_UTF16_H_0[];
extern const uint16_t g_FXCMAP_UniJIS_UTF16_H_0_DWord[];
extern const uint16_t g_FXCMAP_UniJIS_UTF16_V_0[];
-extern const uint16_t g_FXCMAP_Japan1CID2Unicode_4[];
+extern const uint16_t g_FXCMAP_Japan1CID2Unicode_4[15444];
#endif // CORE_FPDFAPI_CMAPS_JAPAN1_CMAPS_JAPAN1_H_
diff --git a/core/fpdfapi/cmaps/Korea1/cmaps_korea1.cpp b/core/fpdfapi/cmaps/Korea1/cmaps_korea1.cpp
index daec8259e9..4c9201269c 100644
--- a/core/fpdfapi/cmaps/Korea1/cmaps_korea1.cpp
+++ b/core/fpdfapi/cmaps/Korea1/cmaps_korea1.cpp
@@ -37,8 +37,7 @@ static const FXCMAP_CMap g_FXCMAP_Korea1_cmaps[] = {
void CPDF_ModuleMgr::LoadEmbeddedKorea1CMaps() {
CPDF_FontGlobals* pFontGlobals =
CPDF_ModuleMgr::Get()->GetPageModule()->GetFontGlobals();
- pFontGlobals->SetEmbeddedCharset(CIDSET_KOREA1, g_FXCMAP_Korea1_cmaps,
- FX_ArraySize(g_FXCMAP_Korea1_cmaps));
+ pFontGlobals->SetEmbeddedCharset(CIDSET_KOREA1, g_FXCMAP_Korea1_cmaps);
pFontGlobals->SetEmbeddedToUnicode(CIDSET_KOREA1,
- g_FXCMAP_Korea1CID2Unicode_2, 18352);
+ g_FXCMAP_Korea1CID2Unicode_2);
}
diff --git a/core/fpdfapi/cmaps/Korea1/cmaps_korea1.h b/core/fpdfapi/cmaps/Korea1/cmaps_korea1.h
index 5005ff2dea..27b9b0b7c4 100644
--- a/core/fpdfapi/cmaps/Korea1/cmaps_korea1.h
+++ b/core/fpdfapi/cmaps/Korea1/cmaps_korea1.h
@@ -19,6 +19,6 @@ extern const uint16_t g_FXCMAP_KSCpc_EUC_H_0[];
extern const uint16_t g_FXCMAP_UniKS_UCS2_H_1[];
extern const uint16_t g_FXCMAP_UniKS_UCS2_V_1[];
extern const uint16_t g_FXCMAP_UniKS_UTF16_H_0[];
-extern const uint16_t g_FXCMAP_Korea1CID2Unicode_2[];
+extern const uint16_t g_FXCMAP_Korea1CID2Unicode_2[18352];
#endif // CORE_FPDFAPI_CMAPS_KOREA1_CMAPS_KOREA1_H_
diff --git a/core/fpdfapi/cmaps/fpdf_cmaps.cpp b/core/fpdfapi/cmaps/fpdf_cmaps.cpp
index bba8d2173d..bb4a397aa4 100644
--- a/core/fpdfapi/cmaps/fpdf_cmaps.cpp
+++ b/core/fpdfapi/cmaps/fpdf_cmaps.cpp
@@ -11,6 +11,7 @@
#include "core/fpdfapi/cpdf_modulemgr.h"
#include "core/fpdfapi/font/cpdf_fontglobals.h"
#include "core/fpdfapi/page/cpdf_pagemodule.h"
+#include "third_party/base/span.h"
namespace {
@@ -26,10 +27,10 @@ const FXCMAP_CMap* FPDFAPI_FindEmbeddedCMap(const ByteString& bsName,
CPDF_FontGlobals* pFontGlobals =
CPDF_ModuleMgr::Get()->GetPageModule()->GetFontGlobals();
- const FXCMAP_CMap* pCMaps;
- uint32_t count;
- std::tie(count, pCMaps) = pFontGlobals->GetEmbeddedCharset(charset);
- for (uint32_t i = 0; i < count; i++) {
+ pdfium::span<const FXCMAP_CMap> pCMaps =
+ pFontGlobals->GetEmbeddedCharset(charset);
+
+ for (size_t i = 0; i < pCMaps.size(); i++) {
if (bsName == pCMaps[i].m_Name)
return &pCMaps[i];
}
diff --git a/core/fpdfapi/font/cpdf_fontglobals.h b/core/fpdfapi/font/cpdf_fontglobals.h
index 2663490925..d5156aae65 100644
--- a/core/fpdfapi/font/cpdf_fontglobals.h
+++ b/core/fpdfapi/font/cpdf_fontglobals.h
@@ -29,36 +29,25 @@ class CPDF_FontGlobals {
uint32_t index,
std::unique_ptr<CPDF_Font> pFont);
- void SetEmbeddedCharset(size_t idx, const FXCMAP_CMap* map, uint32_t count) {
- m_EmbeddedCharsets[idx].m_pMapList = map;
- m_EmbeddedCharsets[idx].m_Count = count;
+ void SetEmbeddedCharset(size_t idx, pdfium::span<const FXCMAP_CMap> map) {
+ m_EmbeddedCharsets[idx] = map;
}
- std::pair<uint32_t, const FXCMAP_CMap*> GetEmbeddedCharset(size_t idx) const {
- return {m_EmbeddedCharsets[idx].m_Count,
- m_EmbeddedCharsets[idx].m_pMapList.Get()};
+ pdfium::span<const FXCMAP_CMap> GetEmbeddedCharset(size_t idx) const {
+ return m_EmbeddedCharsets[idx];
}
- void SetEmbeddedToUnicode(size_t idx, const uint16_t* map, uint32_t count) {
- m_EmbeddedToUnicodes[idx].m_pMap = map;
- m_EmbeddedToUnicodes[idx].m_Count = count;
+ void SetEmbeddedToUnicode(size_t idx, pdfium::span<const uint16_t> map) {
+ m_EmbeddedToUnicodes[idx] = map;
}
pdfium::span<const uint16_t> GetEmbeddedToUnicode(size_t idx) {
- return pdfium::make_span(m_EmbeddedToUnicodes[idx].m_pMap,
- m_EmbeddedToUnicodes[idx].m_Count);
+ return m_EmbeddedToUnicodes[idx];
}
CPDF_CMapManager* GetCMapManager() { return &m_CMapManager; }
private:
CPDF_CMapManager m_CMapManager;
- struct {
- UnownedPtr<const FXCMAP_CMap> m_pMapList;
- uint32_t m_Count;
- } m_EmbeddedCharsets[CIDSET_NUM_SETS];
- struct {
- const uint16_t* m_pMap;
- uint32_t m_Count;
- } m_EmbeddedToUnicodes[CIDSET_NUM_SETS];
-
+ pdfium::span<const FXCMAP_CMap> m_EmbeddedCharsets[CIDSET_NUM_SETS];
+ pdfium::span<const uint16_t> m_EmbeddedToUnicodes[CIDSET_NUM_SETS];
std::map<CPDF_Document*, std::unique_ptr<CFX_StockFontArray>> m_StockMap;
};