XFA: Take CTTFontDesc::ReleaseFace() changes from master.
Return true if object destroyed. Also get rid of
FXFT_Done_Face() call not present on master.
R=thestig@chromium.org
Review URL: https://codereview.chromium.org/1426103002 .
diff --git a/core/src/fxge/ge/fx_ge_fontmap.cpp b/core/src/fxge/ge/fx_ge_fontmap.cpp
index 63cbecd..1360fc7 100644
--- a/core/src/fxge/ge/fx_ge_fontmap.cpp
+++ b/core/src/fxge/ge/fx_ge_fontmap.cpp
@@ -58,10 +58,10 @@
}
FX_Free(m_pFontData);
}
-int32_t CTTFontDesc::ReleaseFace(FXFT_Face face) {
+FX_BOOL CTTFontDesc::ReleaseFace(FXFT_Face face) {
if (m_Type == 1) {
if (m_SingleFace.m_pFace != face) {
- return -1;
+ return FALSE;
}
} else if (m_Type == 2) {
int i;
@@ -70,15 +70,15 @@
break;
}
if (i == 16) {
- return -1;
+ return FALSE;
}
}
m_RefCount--;
if (m_RefCount) {
- return m_RefCount;
+ return FALSE;
}
delete this;
- return 0;
+ return TRUE;
}
CFX_FontMgr::CFX_FontMgr() : m_FTLibrary(nullptr) {
@@ -357,21 +357,13 @@
if (!face) {
return;
}
- FX_BOOL bNeedFaceDone = TRUE;
auto it = m_FaceMap.begin();
while (it != m_FaceMap.end()) {
auto temp = it++;
- int nRet = temp->second->ReleaseFace(face);
- if (nRet == 0) {
+ if (temp->second->ReleaseFace(face)) {
m_FaceMap.erase(temp);
- bNeedFaceDone = FALSE;
- } else if (nRet > 0) {
- bNeedFaceDone = FALSE;
}
}
- if (bNeedFaceDone && !m_pBuiltinMapper->IsBuiltinFace(face)) {
- FXFT_Done_Face(face);
- }
}
const FoxitFonts g_FoxitFonts[14] = {
{g_FoxitFixedFontData, 17597},
@@ -421,10 +413,10 @@
FXSYS_memset(m_FoxitFaces, 0, sizeof(m_FoxitFaces));
}
CFX_FontMapper::~CFX_FontMapper() {
- for (int i = 0; i < 14; i++)
- if (m_FoxitFaces[i]) {
+ for (size_t i = 0; i < FX_ArraySize(m_FoxitFaces); ++i) {
+ if (m_FoxitFaces[i])
FXFT_Done_Face(m_FoxitFaces[i]);
- }
+ }
if (m_MMFaces[0]) {
FXFT_Done_Face(m_MMFaces[0]);
}
diff --git a/core/src/fxge/ge/text_int.h b/core/src/fxge/ge/text_int.h
index 2a81f55..1b16ced 100644
--- a/core/src/fxge/ge/text_int.h
+++ b/core/src/fxge/ge/text_int.h
@@ -28,7 +28,7 @@
m_RefCount = 0;
}
~CTTFontDesc();
- int32_t ReleaseFace(FXFT_Face face);
+ FX_BOOL ReleaseFace(FXFT_Face face);
int m_Type;
union {
struct {