From 4eb4d7f6c707cc2c23c806aa540d055c8832b55d Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Wed, 22 Jul 2015 15:04:26 -0700 Subject: Revert "Fix else-after-returns throughout pdfium." This reverts commit 7cc97521db1e52d5927f5605de5f9a7102f8af40. --- core/src/fxge/ge/fx_ge_device.cpp | 9 +++--- core/src/fxge/ge/fx_ge_font.cpp | 27 ++++++++++-------- core/src/fxge/ge/fx_ge_fontmap.cpp | 12 +++++--- core/src/fxge/ge/fx_ge_linux.cpp | 9 +++--- core/src/fxge/ge/fx_ge_path.cpp | 6 ++-- core/src/fxge/ge/fx_ge_text.cpp | 57 +++++++++++++++++++------------------- 6 files changed, 63 insertions(+), 57 deletions(-) (limited to 'core/src/fxge/ge') diff --git a/core/src/fxge/ge/fx_ge_device.cpp b/core/src/fxge/ge/fx_ge_device.cpp index 0baa99cdc7..793dfc5ee2 100644 --- a/core/src/fxge/ge/fx_ge_device.cpp +++ b/core/src/fxge/ge/fx_ge_device.cpp @@ -64,14 +64,13 @@ FX_BOOL CFX_RenderDevice::CreateCompatibleBitmap(CFX_DIBitmap* pDIB, int width, { if (m_RenderCaps & FXRC_CMYK_OUTPUT) { return pDIB->Create(width, height, m_RenderCaps & FXRC_ALPHA_OUTPUT ? FXDIB_Cmyka : FXDIB_Cmyk); - } - if (m_RenderCaps & FXRC_BYTEMASK_OUTPUT) { + } else if (m_RenderCaps & FXRC_BYTEMASK_OUTPUT) { return pDIB->Create(width, height, FXDIB_8bppMask); - } + } else #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ - return pDIB->Create(width, height, m_RenderCaps & FXRC_ALPHA_OUTPUT ? FXDIB_Argb : FXDIB_Rgb32); + return pDIB->Create(width, height, m_RenderCaps & FXRC_ALPHA_OUTPUT ? FXDIB_Argb : FXDIB_Rgb32); #else - return pDIB->Create(width, height, m_RenderCaps & FXRC_ALPHA_OUTPUT ? FXDIB_Argb : FXDIB_Rgb); + return pDIB->Create(width, height, m_RenderCaps & FXRC_ALPHA_OUTPUT ? FXDIB_Argb : FXDIB_Rgb); #endif } FX_BOOL CFX_RenderDevice::SetClip_PathFill(const CFX_PathData* pPathData, diff --git a/core/src/fxge/ge/fx_ge_font.cpp b/core/src/fxge/ge/fx_ge_font.cpp index 6a950bf20b..f88cbaacde 100644 --- a/core/src/fxge/ge/fx_ge_font.cpp +++ b/core/src/fxge/ge/fx_ge_font.cpp @@ -309,8 +309,9 @@ CFX_ByteString CFX_Font::GetFamilyName() const } if (m_Face) { return CFX_ByteString(FXFT_Get_Face_Family_Name(m_Face)); + } else { + return m_pSubstFont->m_Family; } - return m_pSubstFont->m_Family; } CFX_ByteString CFX_Font::GetFaceName() const { @@ -328,8 +329,9 @@ CFX_ByteString CFX_Font::GetFaceName() const facename += " " + style; } return facename; + } else { + return m_pSubstFont->m_Family; } - return m_pSubstFont->m_Family; } FX_BOOL CFX_Font::GetBBox(FX_RECT &bbox) { @@ -408,20 +410,21 @@ FX_DWORD CFX_UnicodeEncoding::GlyphFromCharCode(FX_DWORD charcode) } FX_DWORD CFX_UnicodeEncoding::GlyphFromCharCodeEx(FX_DWORD charcode, int encoding) { - FXFT_Face face = m_pFont->GetFace(); + FXFT_Face face = m_pFont->GetFace(); if (!face) { return charcode; } if (encoding == ENCODING_UNICODE) { - return GlyphFromCharCode(charcode); - } - int nmaps = FXFT_Get_Face_CharmapCount(m_pFont->m_Face); - int i = 0; - while (i < nmaps) { - int encoding = FXFT_Get_Charmap_Encoding(FXFT_Get_Face_Charmaps(face)[i++]); - if (encoding != FXFT_ENCODING_UNICODE) { - FXFT_Select_Charmap(face, encoding); - break; + return GlyphFromCharCode(charcode); + } else { + int nmaps = FXFT_Get_Face_CharmapCount(m_pFont->m_Face); + int i = 0; + while (i < nmaps) { + int encoding = FXFT_Get_Charmap_Encoding(FXFT_Get_Face_Charmaps(face)[i++]); + if (encoding != FXFT_ENCODING_UNICODE) { + FXFT_Select_Charmap(face, encoding); + break; + } } } return FXFT_Get_Char_Index(face, charcode); diff --git a/core/src/fxge/ge/fx_ge_fontmap.cpp b/core/src/fxge/ge/fx_ge_fontmap.cpp index 4674589911..8956cd1c88 100644 --- a/core/src/fxge/ge/fx_ge_fontmap.cpp +++ b/core/src/fxge/ge/fx_ge_fontmap.cpp @@ -688,8 +688,7 @@ uint8_t _GetCharsetFromCodePage(FX_WORD codepage) const CHARSET_MAP & cp = g_Codepage2CharsetTable[iMid]; if (codepage == cp.codepage) { return cp.charset; - } - if (codepage < cp.codepage) { + } else if (codepage < cp.codepage) { iEnd = iMid - 1; } else { iStart = iMid + 1; @@ -1160,10 +1159,14 @@ FXFT_Face CFX_FontMapper::FindSubstFont(const CFX_ByteString& name, FX_BOOL bTru m_pFontMgr->GetStandardFont(pFontData, size, 12); m_FoxitFaces[12] = m_pFontMgr->GetFixedFace(pFontData, size, 0); return m_FoxitFaces[12]; + } else { + pSubstFont->m_SubstFlags |= FXFONT_SUBST_NONSYMBOL; + return FindSubstFont(family, bTrueType, flags & ~FXFONT_SYMBOLIC, weight, italic_angle, 0, pSubstFont); } -#endif +#else pSubstFont->m_SubstFlags |= FXFONT_SUBST_NONSYMBOL; return FindSubstFont(family, bTrueType, flags & ~FXFONT_SYMBOLIC, weight, italic_angle, 0, pSubstFont); +#endif } if (Charset == FXFONT_ANSI_CHARSET) { pSubstFont->m_SubstFlags |= FXFONT_SUBST_STANDARD; @@ -1172,8 +1175,9 @@ FXFT_Face CFX_FontMapper::FindSubstFont(const CFX_ByteString& name, FX_BOOL bTru int index = m_CharsetArray.Find(Charset); if (index < 0) { return UseInternalSubst(pSubstFont, iBaseFont, italic_angle, old_weight, PitchFamily); + } else { + hFont = m_pFontInfo->GetFont(m_FaceArray[index]); } - hFont = m_pFontInfo->GetFont(m_FaceArray[index]); } } pSubstFont->m_ExtHandle = m_pFontInfo->RetainFont(hFont); diff --git a/core/src/fxge/ge/fx_ge_linux.cpp b/core/src/fxge/ge/fx_ge_linux.cpp index 4e7334596b..631ff8e93f 100644 --- a/core/src/fxge/ge/fx_ge_linux.cpp +++ b/core/src/fxge/ge/fx_ge_linux.cpp @@ -63,14 +63,15 @@ static int32_t GetJapanesePreference(const FX_CHAR* facearr, int weight, int pic if (face.Find("Gothic") >= 0 || face.Find("\x83\x53\x83\x56\x83\x62\x83\x4e") >= 0) { if (face.Find("PGothic") >= 0 || face.Find("\x82\x6f\x83\x53\x83\x56\x83\x62\x83\x4e") >= 0) { return 0; + } else { + return 1; } - return 1; - } - if (face.Find("Mincho") >= 0 || face.Find("\x96\xbe\x92\xa9") >= 0) { + } else if (face.Find("Mincho") >= 0 || face.Find("\x96\xbe\x92\xa9") >= 0) { if (face.Find("PMincho") >= 0 || face.Find("\x82\x6f\x96\xbe\x92\xa9") >= 0) { return 2; + } else { + return 3; } - return 3; } if (!(picth_family & FXFONT_FF_ROMAN) && weight > 400) { return 0; diff --git a/core/src/fxge/ge/fx_ge_path.cpp b/core/src/fxge/ge/fx_ge_path.cpp index b1410b3911..ea1d80390b 100644 --- a/core/src/fxge/ge/fx_ge_path.cpp +++ b/core/src/fxge/ge/fx_ge_path.cpp @@ -55,8 +55,7 @@ void CFX_ClipRgn::IntersectMaskRect(FX_RECT rect, FX_RECT mask_rect, CFX_DIBitma if (m_Box.IsEmpty()) { m_Type = RectI; return; - } - if (m_Box == mask_rect) { + } else if (m_Box == mask_rect) { m_Mask = Mask; return; } @@ -230,8 +229,7 @@ static void _UpdateLineEndPoints(CFX_FloatRect& rect, FX_FLOAT start_x, FX_FLOAT rect.UpdateRect(end_x + hw, point_y); rect.UpdateRect(end_x - hw, point_y); return; - } - if (start_y == end_y) { + } else if (start_y == end_y) { FX_FLOAT point_x; if (end_x < start_x) { point_x = end_x - hw; diff --git a/core/src/fxge/ge/fx_ge_text.cpp b/core/src/fxge/ge/fx_ge_text.cpp index 233ed94963..76c7cf429e 100644 --- a/core/src/fxge/ge/fx_ge_text.cpp +++ b/core/src/fxge/ge/fx_ge_text.cpp @@ -1154,37 +1154,38 @@ const CFX_GlyphBitmap* CFX_FaceCache::LoadGlyphBitmap(CFX_Font* pFont, FX_DWORD #else if (text_flags & FXTEXT_NO_NATIVETEXT) { return LookUpGlyphBitmap(pFont, pMatrix, FaceGlyphsKey, glyph_index, bFontStyle, dest_width, anti_alias); - } - CFX_GlyphBitmap* pGlyphBitmap; - CFX_SizeGlyphCache* pSizeCache = NULL; - if (m_SizeMap.Lookup(FaceGlyphsKey, (void*&)pSizeCache)) { - if (pSizeCache->m_GlyphMap.Lookup((void*)(uintptr_t)glyph_index, (void*&)pGlyphBitmap)) { - return pGlyphBitmap; - } - pGlyphBitmap = RenderGlyph_Nativetext(pFont, glyph_index, pMatrix, dest_width, anti_alias); - if (pGlyphBitmap) { - pSizeCache->m_GlyphMap.SetAt((void*)(uintptr_t)glyph_index, pGlyphBitmap); - return pGlyphBitmap; - } } else { - pGlyphBitmap = RenderGlyph_Nativetext(pFont, glyph_index, pMatrix, dest_width, anti_alias); - if (pGlyphBitmap) { - pSizeCache = new CFX_SizeGlyphCache; - m_SizeMap.SetAt(FaceGlyphsKey, pSizeCache); - pSizeCache->m_GlyphMap.SetAt((void*)(uintptr_t)glyph_index, pGlyphBitmap); - return pGlyphBitmap; + CFX_GlyphBitmap* pGlyphBitmap; + CFX_SizeGlyphCache* pSizeCache = NULL; + if (m_SizeMap.Lookup(FaceGlyphsKey, (void*&)pSizeCache)) { + if (pSizeCache->m_GlyphMap.Lookup((void*)(uintptr_t)glyph_index, (void*&)pGlyphBitmap)) { + return pGlyphBitmap; + } + pGlyphBitmap = RenderGlyph_Nativetext(pFont, glyph_index, pMatrix, dest_width, anti_alias); + if (pGlyphBitmap) { + pSizeCache->m_GlyphMap.SetAt((void*)(uintptr_t)glyph_index, pGlyphBitmap); + return pGlyphBitmap; + } + } else { + pGlyphBitmap = RenderGlyph_Nativetext(pFont, glyph_index, pMatrix, dest_width, anti_alias); + if (pGlyphBitmap) { + pSizeCache = new CFX_SizeGlyphCache; + m_SizeMap.SetAt(FaceGlyphsKey, pSizeCache); + pSizeCache->m_GlyphMap.SetAt((void*)(uintptr_t)glyph_index, pGlyphBitmap); + return pGlyphBitmap; + } } + if (pFont->GetSubstFont()) + keygen.Generate(9, (int)(pMatrix->a * 10000), (int)(pMatrix->b * 10000), + (int)(pMatrix->c * 10000), (int)(pMatrix->d * 10000), dest_width, anti_alias, + pFont->GetSubstFont()->m_Weight, pFont->GetSubstFont()->m_ItalicAngle, pFont->IsVertical()); + else + keygen.Generate(6, (int)(pMatrix->a * 10000), (int)(pMatrix->b * 10000), + (int)(pMatrix->c * 10000), (int)(pMatrix->d * 10000), dest_width, anti_alias); + CFX_ByteStringC FaceGlyphsKey(keygen.m_Key, keygen.m_KeyLen); + text_flags |= FXTEXT_NO_NATIVETEXT; + return LookUpGlyphBitmap(pFont, pMatrix, FaceGlyphsKey, glyph_index, bFontStyle, dest_width, anti_alias); } - if (pFont->GetSubstFont()) - keygen.Generate(9, (int)(pMatrix->a * 10000), (int)(pMatrix->b * 10000), - (int)(pMatrix->c * 10000), (int)(pMatrix->d * 10000), dest_width, anti_alias, - pFont->GetSubstFont()->m_Weight, pFont->GetSubstFont()->m_ItalicAngle, pFont->IsVertical()); - else - keygen.Generate(6, (int)(pMatrix->a * 10000), (int)(pMatrix->b * 10000), - (int)(pMatrix->c * 10000), (int)(pMatrix->d * 10000), dest_width, anti_alias); - CFX_ByteStringC FaceGlyphsKey(keygen.m_Key, keygen.m_KeyLen); - text_flags |= FXTEXT_NO_NATIVETEXT; - return LookUpGlyphBitmap(pFont, pMatrix, FaceGlyphsKey, glyph_index, bFontStyle, dest_width, anti_alias); #endif } CFX_SizeGlyphCache::~CFX_SizeGlyphCache() -- cgit v1.2.3