From 4997b22f84307521a62838f874928bf56cd3423c Mon Sep 17 00:00:00 2001 From: thestig Date: Tue, 7 Jun 2016 10:46:22 -0700 Subject: Get rid of NULLs in core/ Review-Url: https://codereview.chromium.org/2032613003 --- core/fxge/ge/fx_ge.cpp | 18 +++++++++--------- core/fxge/ge/fx_ge_device.cpp | 8 ++++---- core/fxge/ge/fx_ge_font.cpp | 34 +++++++++++++++++----------------- core/fxge/ge/fx_ge_fontmap.cpp | 42 +++++++++++++++++++++--------------------- core/fxge/ge/fx_ge_linux.cpp | 6 +++--- core/fxge/ge/fx_ge_path.cpp | 12 ++++++------ core/fxge/ge/fx_ge_text.cpp | 24 ++++++++++++------------ core/fxge/ge/fx_text_int.h | 2 +- 8 files changed, 73 insertions(+), 73 deletions(-) (limited to 'core/fxge/ge') diff --git a/core/fxge/ge/fx_ge.cpp b/core/fxge/ge/fx_ge.cpp index 9e45dc7434..360a4eb417 100644 --- a/core/fxge/ge/fx_ge.cpp +++ b/core/fxge/ge/fx_ge.cpp @@ -8,20 +8,20 @@ #include "core/fxge/ge/fx_text_int.h" -static CFX_GEModule* g_pGEModule = NULL; +static CFX_GEModule* g_pGEModule = nullptr; CFX_GEModule::CFX_GEModule(const char** pUserFontPaths) { - m_pFontCache = NULL; - m_pFontMgr = NULL; - m_FTLibrary = NULL; - m_pCodecModule = NULL; - m_pPlatformData = NULL; + m_pFontCache = nullptr; + m_pFontMgr = nullptr; + m_FTLibrary = nullptr; + m_pCodecModule = nullptr; + m_pPlatformData = nullptr; m_pUserFontPaths = pUserFontPaths; } CFX_GEModule::~CFX_GEModule() { delete m_pFontCache; - m_pFontCache = NULL; + m_pFontCache = nullptr; delete m_pFontMgr; - m_pFontMgr = NULL; + m_pFontMgr = nullptr; DestroyPlatform(); } CFX_GEModule* CFX_GEModule::Get() { @@ -38,7 +38,7 @@ void CFX_GEModule::Use(CFX_GEModule* pModule) { } void CFX_GEModule::Destroy() { delete g_pGEModule; - g_pGEModule = NULL; + g_pGEModule = nullptr; } CFX_FontCache* CFX_GEModule::GetFontCache() { if (!m_pFontCache) { diff --git a/core/fxge/ge/fx_ge_device.cpp b/core/fxge/ge/fx_ge_device.cpp index 96e0e55cd1..7763d91363 100644 --- a/core/fxge/ge/fx_ge_device.cpp +++ b/core/fxge/ge/fx_ge_device.cpp @@ -7,8 +7,8 @@ #include "core/fxge/include/fx_ge.h" CFX_RenderDevice::CFX_RenderDevice() { - m_pDeviceDriver = NULL; - m_pBitmap = NULL; + m_pDeviceDriver = nullptr; + m_pBitmap = nullptr; } CFX_RenderDevice::~CFX_RenderDevice() { delete m_pDeviceDriver; @@ -193,7 +193,7 @@ FX_BOOL CFX_RenderDevice::DrawPathWithBlend( if (bThin) { strokecolor = (((fill_alpha >> 2) << 24) | (strokecolor & 0x00ffffff)); } - CFX_Matrix* pMatrix = NULL; + CFX_Matrix* pMatrix = nullptr; if (pObject2Device && !pObject2Device->IsIdentity()) { pMatrix = (CFX_Matrix*)pObject2Device; } @@ -255,7 +255,7 @@ FX_BOOL CFX_RenderDevice::DrawFillStrokePath( bitmap.Clear(0); Backdrop.Copy(&bitmap); } else { - if (!m_pDeviceDriver->GetDIBits(&bitmap, rect.left, rect.top, NULL)) { + if (!m_pDeviceDriver->GetDIBits(&bitmap, rect.left, rect.top, nullptr)) { return FALSE; } Backdrop.Copy(&bitmap); diff --git a/core/fxge/ge/fx_ge_font.cpp b/core/fxge/ge/fx_ge_font.cpp index ba53be7ab5..22b7aa38bf 100644 --- a/core/fxge/ge/fx_ge_font.cpp +++ b/core/fxge/ge/fx_ge_font.cpp @@ -39,30 +39,30 @@ FXFT_Face FT_LoadFont(const uint8_t* pData, int size) { } // namespace CFX_Font::CFX_Font() { - m_pSubstFont = NULL; - m_Face = NULL; + m_pSubstFont = nullptr; + m_Face = nullptr; m_bEmbedded = FALSE; m_bVertical = FALSE; - m_pFontData = NULL; - m_pFontDataAllocation = NULL; + m_pFontData = nullptr; + m_pFontDataAllocation = nullptr; m_dwSize = 0; - m_pGsubData = NULL; - m_pPlatformFont = NULL; - m_pPlatformFontCollection = NULL; - m_pDwFont = NULL; - m_hHandle = NULL; + m_pGsubData = nullptr; + m_pPlatformFont = nullptr; + m_pPlatformFontCollection = nullptr; + m_pDwFont = nullptr; + m_hHandle = nullptr; m_bDwLoaded = FALSE; #ifdef PDF_ENABLE_XFA m_bLogic = FALSE; - m_pOwnedStream = NULL; + m_pOwnedStream = nullptr; #endif // PDF_ENABLE_XFA } #ifdef PDF_ENABLE_XFA FX_BOOL CFX_Font::LoadClone(const CFX_Font* pFont) { - if (pFont == NULL) { + if (!pFont) return FALSE; - } + m_bLogic = TRUE; if (pFont->m_pSubstFont) { m_pSubstFont = new CFX_SubstFont; @@ -124,7 +124,7 @@ CFX_Font::~CFX_Font() { } void CFX_Font::DeleteFace() { FXFT_Done_Face(m_Face); - m_Face = NULL; + m_Face = nullptr; } void CFX_Font::LoadSubst(const CFX_ByteString& face_name, FX_BOOL bTrueType, @@ -142,7 +142,7 @@ void CFX_Font::LoadSubst(const CFX_ByteString& face_name, #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ if (m_pSubstFont->m_ExtHandle) { m_pPlatformFont = m_pSubstFont->m_ExtHandle; - m_pSubstFont->m_ExtHandle = NULL; + m_pSubstFont->m_ExtHandle = nullptr; } #endif if (m_Face) { @@ -174,7 +174,7 @@ FX_BOOL _LoadFile(FXFT_Library library, FXFT_Stream* stream, int32_t faceIndex = 0) { FXFT_Stream stream1 = (FXFT_Stream)FX_Alloc(uint8_t, sizeof(FXFT_StreamRec)); - stream1->base = NULL; + stream1->base = nullptr; stream1->size = (unsigned long)pFile->GetSize(); stream1->pos = 0; stream1->descriptor.pointer = pFile; @@ -239,7 +239,7 @@ FX_BOOL CFX_Font::LoadEmbedded(const uint8_t* data, uint32_t size) { m_pFontData = m_pFontDataAllocation; m_bEmbedded = TRUE; m_dwSize = size; - return m_Face != NULL; + return !!m_Face; } FX_BOOL CFX_Font::IsTTFont() const { @@ -534,6 +534,6 @@ CFX_UnicodeEncodingEx* FX_CreateFontEncodingEx(CFX_Font* pFont, return pFontEncoding; } } - return NULL; + return nullptr; } #endif // PDF_ENABLE_XFA diff --git a/core/fxge/ge/fx_ge_fontmap.cpp b/core/fxge/ge/fx_ge_fontmap.cpp index 83690c7181..fa53898ecc 100644 --- a/core/fxge/ge/fx_ge_fontmap.cpp +++ b/core/fxge/ge/fx_ge_fontmap.cpp @@ -336,7 +336,7 @@ int32_t GetStyleType(const CFX_ByteString& bsStyle, FX_BOOL bRevert) { return -1; } int iSize = sizeof(g_FontStyles) / sizeof(FX_FontStyle); - const FX_FontStyle* pStyle = NULL; + const FX_FontStyle* pStyle = nullptr; for (int i = iSize - 1; i >= 0; --i) { pStyle = g_FontStyles + i; if (!pStyle || pStyle->len > iLen) { @@ -410,7 +410,7 @@ int32_t GetSimilarValue(int weight, } // namespace CFX_SubstFont::CFX_SubstFont() { - m_ExtHandle = NULL; + m_ExtHandle = nullptr; m_Charset = 0; m_SubstFlags = 0; m_Weight = 0; @@ -517,7 +517,7 @@ FXFT_Face CFX_FontMgr::AddCachedFace(const CFX_ByteString& face_name, int face_index) { CTTFontDesc* pFontDesc = new CTTFontDesc; pFontDesc->m_Type = 1; - pFontDesc->m_SingleFace.m_pFace = NULL; + pFontDesc->m_SingleFace.m_pFace = nullptr; pFontDesc->m_SingleFace.m_bBold = weight; pFontDesc->m_SingleFace.m_bItalic = bItalic; pFontDesc->m_pFontData = pData; @@ -529,12 +529,12 @@ FXFT_Face CFX_FontMgr::AddCachedFace(const CFX_ByteString& face_name, &pFontDesc->m_SingleFace.m_pFace); if (ret) { delete pFontDesc; - return NULL; + return nullptr; } ret = FXFT_Set_Pixel_Sizes(pFontDesc->m_SingleFace.m_pFace, 64, 64); if (ret) { delete pFontDesc; - return NULL; + return nullptr; } m_FaceMap[KeyNameFromFace(face_name, weight, bItalic)] = pFontDesc; return pFontDesc->m_SingleFace.m_pFace; @@ -587,7 +587,7 @@ FXFT_Face CFX_FontMgr::AddCachedTTCFace(int ttc_size, pFontDesc->m_Type = 2; pFontDesc->m_pFontData = pData; for (int i = 0; i < 16; i++) { - pFontDesc->m_TTCFace.m_pFaces[i] = NULL; + pFontDesc->m_TTCFace.m_pFaces[i] = nullptr; } pFontDesc->m_RefCount++; m_FaceMap[KeyNameFromSize(ttc_size, checksum)] = pFontDesc; @@ -815,7 +815,7 @@ FXFT_Face CFX_FontMapper::UseInternalSubst(CFX_SubstFont* pSubstFont, if (m_FoxitFaces[iBaseFont]) { return m_FoxitFaces[iBaseFont]; } - const uint8_t* pFontData = NULL; + const uint8_t* pFontData = nullptr; uint32_t size = 0; if (m_pFontMgr->GetBuiltinFont(iBaseFont, &pFontData, &size)) { m_FoxitFaces[iBaseFont] = m_pFontMgr->GetFixedFace(pFontData, size, 0); @@ -833,7 +833,7 @@ FXFT_Face CFX_FontMapper::UseInternalSubst(CFX_SubstFont* pSubstFont, if (m_MMFaces[1]) { return m_MMFaces[1]; } - const uint8_t* pFontData = NULL; + const uint8_t* pFontData = nullptr; uint32_t size = 0; m_pFontMgr->GetBuiltinFont(14, &pFontData, &size); m_MMFaces[1] = m_pFontMgr->GetFixedFace(pFontData, size, 0); @@ -843,7 +843,7 @@ FXFT_Face CFX_FontMapper::UseInternalSubst(CFX_SubstFont* pSubstFont, if (m_MMFaces[0]) { return m_MMFaces[0]; } - const uint8_t* pFontData = NULL; + const uint8_t* pFontData = nullptr; uint32_t size = 0; m_pFontMgr->GetBuiltinFont(15, &pFontData, &size); m_MMFaces[0] = m_pFontMgr->GetFixedFace(pFontData, size, 0); @@ -876,7 +876,7 @@ FXFT_Face CFX_FontMapper::FindSubstFont(const CFX_ByteString& name, if (m_FoxitFaces[12]) { return m_FoxitFaces[12]; } - const uint8_t* pFontData = NULL; + const uint8_t* pFontData = nullptr; uint32_t size = 0; m_pFontMgr->GetBuiltinFont(12, &pFontData, &size); m_FoxitFaces[12] = m_pFontMgr->GetFixedFace(pFontData, size, 0); @@ -889,7 +889,7 @@ FXFT_Face CFX_FontMapper::FindSubstFont(const CFX_ByteString& name, if (m_FoxitFaces[13]) { return m_FoxitFaces[13]; } - const uint8_t* pFontData = NULL; + const uint8_t* pFontData = nullptr; uint32_t size = 0; m_pFontMgr->GetBuiltinFont(13, &pFontData, &size); m_FoxitFaces[13] = m_pFontMgr->GetFixedFace(pFontData, size, 0); @@ -1106,7 +1106,7 @@ FXFT_Face CFX_FontMapper::FindSubstFont(const CFX_ByteString& name, if (!hFont) { #ifdef PDF_ENABLE_XFA if (flags & FXFONT_EXACTMATCH) { - return NULL; + return nullptr; } #endif // PDF_ENABLE_XFA if (bCJK) { @@ -1134,7 +1134,7 @@ FXFT_Face CFX_FontMapper::FindSubstFont(const CFX_ByteString& name, if (m_FoxitFaces[12]) { return m_FoxitFaces[12]; } - const uint8_t* pFontData = NULL; + const uint8_t* pFontData = nullptr; uint32_t size = 0; m_pFontMgr->GetBuiltinFont(12, &pFontData, &size); m_FoxitFaces[12] = m_pFontMgr->GetFixedFace(pFontData, size, 0); @@ -1207,7 +1207,7 @@ FXFT_Face CFX_FontMapper::FindSubstFont(const CFX_ByteString& name, } if (!face) { m_pFontInfo->DeleteFont(hFont); - return NULL; + return nullptr; } pSubstFont->m_Family = SubstName; pSubstFont->m_Charset = Charset; @@ -1263,13 +1263,13 @@ FXFT_Face CFX_FontMapper::FindSubstFontByUnicode(uint32_t dwUnicode, if (!hFont) return nullptr; - uint32_t ttc_size = m_pFontInfo->GetFontData(hFont, 0x74746366, NULL, 0); - uint32_t font_size = m_pFontInfo->GetFontData(hFont, 0, NULL, 0); + uint32_t ttc_size = m_pFontInfo->GetFontData(hFont, 0x74746366, nullptr, 0); + uint32_t font_size = m_pFontInfo->GetFontData(hFont, 0, nullptr, 0); if (font_size == 0 && ttc_size == 0) { m_pFontInfo->DeleteFont(hFont); - return NULL; + return nullptr; } - FXFT_Face face = NULL; + FXFT_Face face = nullptr; if (ttc_size) { uint8_t temp[1024]; m_pFontInfo->GetFontData(hFont, 0x74746366, temp, 1024); @@ -1322,7 +1322,7 @@ int IFX_SystemFontInfo::GetFaceIndex(void* hFont) { } void* IFX_SystemFontInfo::RetainFont(void* hFont) { - return NULL; + return nullptr; } int CFX_FontMapper::GetFaceSize() const { @@ -1566,7 +1566,7 @@ void* CFX_FolderFontInfo::MapFont(int weight, int pitch_family, const FX_CHAR* family, int& iExact) { - return NULL; + return nullptr; } #ifdef PDF_ENABLE_XFA @@ -1574,7 +1574,7 @@ void* CFX_FolderFontInfo::MapFontByUnicode(uint32_t dwUnicode, int weight, FX_BOOL bItalic, int pitch_family) { - return NULL; + return nullptr; } #endif // PDF_ENABLE_XFA diff --git a/core/fxge/ge/fx_ge_linux.cpp b/core/fxge/ge/fx_ge_linux.cpp index 46d7146026..712d9e07b0 100644 --- a/core/fxge/ge/fx_ge_linux.cpp +++ b/core/fxge/ge/fx_ge_linux.cpp @@ -28,11 +28,11 @@ static const struct { } LinuxGpFontList[] = { {{"TakaoPGothic", "VL PGothic", "IPAPGothic", "VL Gothic", "Kochi Gothic", "VL Gothic regular"}}, - {{"TakaoGothic", "VL Gothic", "IPAGothic", "Kochi Gothic", NULL, + {{"TakaoGothic", "VL Gothic", "IPAGothic", "Kochi Gothic", nullptr, "VL Gothic regular"}}, - {{"TakaoPMincho", "IPAPMincho", "VL Gothic", "Kochi Mincho", NULL, + {{"TakaoPMincho", "IPAPMincho", "VL Gothic", "Kochi Mincho", nullptr, "VL Gothic regular"}}, - {{"TakaoMincho", "IPAMincho", "VL Gothic", "Kochi Mincho", NULL, + {{"TakaoMincho", "IPAMincho", "VL Gothic", "Kochi Mincho", nullptr, "VL Gothic regular"}}, }; static const FX_CHAR* const g_LinuxGbFontList[] = { diff --git a/core/fxge/ge/fx_ge_path.cpp b/core/fxge/ge/fx_ge_path.cpp index baa391fef2..2abc45f499 100644 --- a/core/fxge/ge/fx_ge_path.cpp +++ b/core/fxge/ge/fx_ge_path.cpp @@ -114,7 +114,7 @@ void CFX_ClipRgn::IntersectMaskF(int left, int top, CFX_DIBitmapRef Mask) { } CFX_PathData::CFX_PathData() { m_PointCount = m_AllocCount = 0; - m_pPoints = NULL; + m_pPoints = nullptr; } CFX_PathData::~CFX_PathData() { FX_Free(m_pPoints); @@ -460,7 +460,7 @@ FX_BOOL CFX_PathData::GetZeroAreaPath(CFX_PathData& NewPath, m_pPoints[mid - i - 1].m_PointY, FXPT_LINETO); } if (!bZeroArea) { - NewPath.Append(&t_path, NULL); + NewPath.Append(&t_path, nullptr); bThin = TRUE; return TRUE; } @@ -620,21 +620,21 @@ void CFX_PathData::Copy(const CFX_PathData& src) { CFX_GraphStateData::CFX_GraphStateData() { m_LineCap = LineCapButt; m_DashCount = 0; - m_DashArray = NULL; + m_DashArray = nullptr; m_DashPhase = 0; m_LineJoin = LineJoinMiter; m_MiterLimit = 10 * 1.0f; m_LineWidth = 1.0f; } CFX_GraphStateData::CFX_GraphStateData(const CFX_GraphStateData& src) { - m_DashArray = NULL; + m_DashArray = nullptr; Copy(src); } void CFX_GraphStateData::Copy(const CFX_GraphStateData& src) { m_LineCap = src.m_LineCap; m_DashCount = src.m_DashCount; FX_Free(m_DashArray); - m_DashArray = NULL; + m_DashArray = nullptr; m_DashPhase = src.m_DashPhase; m_LineJoin = src.m_LineJoin; m_MiterLimit = src.m_MiterLimit; @@ -649,7 +649,7 @@ CFX_GraphStateData::~CFX_GraphStateData() { } void CFX_GraphStateData::SetDashCount(int count) { FX_Free(m_DashArray); - m_DashArray = NULL; + m_DashArray = nullptr; m_DashCount = count; if (count == 0) { return; diff --git a/core/fxge/ge/fx_ge_text.cpp b/core/fxge/ge/fx_ge_text.cpp index 3243b505b1..c63b292435 100644 --- a/core/fxge/ge/fx_ge_text.cpp +++ b/core/fxge/ge/fx_ge_text.cpp @@ -374,7 +374,7 @@ void Color2Argb(FX_ARGB& argb, } if (!CFX_GEModule::Get()->GetCodecModule() || !CFX_GEModule::Get()->GetCodecModule()->GetIccModule()) { - pIccTransform = NULL; + pIccTransform = nullptr; } uint8_t bgra[4]; if (pIccTransform) { @@ -846,7 +846,7 @@ const CFX_GlyphBitmap* CFX_FaceCache::LoadGlyphBitmap(CFX_Font* pFont, int anti_alias, int& text_flags) { if (glyph_index == (uint32_t)-1) { - return NULL; + return nullptr; } _CFX_UniqueKeyGen keygen; #if _FXM_PLATFORM_ != _FXM_PLATFORM_APPLE_ @@ -940,7 +940,7 @@ CFX_SizeGlyphCache::~CFX_SizeGlyphCache() { } #define CONTRAST_RAMP_STEP 1 void CFX_Font::AdjustMMParams(int glyph_index, int dest_width, int weight) { - FXFT_MM_Var pMasters = NULL; + FXFT_MM_Var pMasters = nullptr; FXFT_Get_MM_Var(m_Face, &pMasters); if (!pMasters) { return; @@ -1076,7 +1076,7 @@ CFX_GlyphBitmap* CFX_FaceCache::RenderGlyph(CFX_Font* pFont, int dest_width, int anti_alias) { if (!m_Face) { - return NULL; + return nullptr; } FXFT_Matrix ft_matrix; ft_matrix.xx = (signed long)(pMatrix->GetA() / 64 * 65536); @@ -1120,14 +1120,14 @@ CFX_GlyphBitmap* CFX_FaceCache::RenderGlyph(CFX_Font* pFont, if (error) { // if an error is returned, try to reload glyphs without hinting. if (load_flags & FT_LOAD_NO_HINTING || load_flags & FT_LOAD_NO_SCALE) { - return NULL; + return nullptr; } load_flags |= FT_LOAD_NO_HINTING; error = FXFT_Load_Glyph(m_Face, glyph_index, load_flags); if (error) { - return NULL; + return nullptr; } } int weight = 0; @@ -1140,7 +1140,7 @@ CFX_GlyphBitmap* CFX_FaceCache::RenderGlyph(CFX_Font* pFont, weight > 400) { uint32_t index = (weight - 400) / 10; if (index >= WEIGHTPOW_ARRAY_SIZE) - return NULL; + return nullptr; int level = 0; if (pSubstFont->m_Charset == FXFONT_SHIFTJIS_CHARSET) { level = @@ -1158,12 +1158,12 @@ CFX_GlyphBitmap* CFX_FaceCache::RenderGlyph(CFX_Font* pFont, FT_LCD_FILTER_DEFAULT); error = FXFT_Render_Glyph(m_Face, anti_alias); if (error) { - return NULL; + return nullptr; } int bmwidth = FXFT_Get_Bitmap_Width(FXFT_Get_Glyph_Bitmap(m_Face)); int bmheight = FXFT_Get_Bitmap_Rows(FXFT_Get_Glyph_Bitmap(m_Face)); if (bmwidth > 2048 || bmheight > 2048) { - return NULL; + return nullptr; } int dib_width = bmwidth; CFX_GlyphBitmap* pGlyphBitmap = new CFX_GlyphBitmap; @@ -1357,7 +1357,7 @@ static int _Outline_CubicTo(const FXFT_Vector* control1, }; CFX_PathData* CFX_Font::LoadGlyphPath(uint32_t glyph_index, int dest_width) { if (!m_Face) { - return NULL; + return nullptr; } FXFT_Set_Pixel_Sizes(m_Face, 0, 64); FXFT_Matrix ft_matrix = {65536, 0, 0, 65536}; @@ -1387,7 +1387,7 @@ CFX_PathData* CFX_Font::LoadGlyphPath(uint32_t glyph_index, int dest_width) { load_flags |= FT_LOAD_NO_HINTING; } if (FXFT_Load_Glyph(m_Face, glyph_index, load_flags)) - return NULL; + return nullptr; if (m_pSubstFont && !(m_pSubstFont->m_SubstFlags & FXFONT_SUBST_MM) && m_pSubstFont->m_Weight > 400) { uint32_t index = (m_pSubstFont->m_Weight - 400) / 10; @@ -1412,7 +1412,7 @@ CFX_PathData* CFX_Font::LoadGlyphPath(uint32_t glyph_index, int dest_width) { params.m_PointCount = 0; FXFT_Outline_Decompose(FXFT_Get_Glyph_Outline(m_Face), &funcs, ¶ms); if (params.m_PointCount == 0) { - return NULL; + return nullptr; } CFX_PathData* pPath = new CFX_PathData; pPath->SetPointCount(params.m_PointCount); diff --git a/core/fxge/ge/fx_text_int.h b/core/fxge/ge/fx_text_int.h index c3e9cd7679..2ca23217c7 100644 --- a/core/fxge/ge/fx_text_int.h +++ b/core/fxge/ge/fx_text_int.h @@ -27,7 +27,7 @@ class CTTFontDesc { public: CTTFontDesc() { m_Type = 0; - m_pFontData = NULL; + m_pFontData = nullptr; m_RefCount = 0; } ~CTTFontDesc(); -- cgit v1.2.3