From 421b4612439ee3a81d675b542038c6c3ff25e977 Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Fri, 2 Oct 2015 10:22:14 -0700 Subject: XFA: Remove test for new. R=tsepez@chromium.org Review URL: https://codereview.chromium.org/1377853004 . --- xfa/include/fxfa/fxfa_widget.h | 2 +- xfa/src/fdp/src/css/fde_cssstylesheet.cpp | 6 --- xfa/src/fdp/src/fde/fde_gedevice.cpp | 8 +--- xfa/src/fdp/src/xml/fde_xml.cpp | 2 +- xfa/src/fgas/src/crt/fx_stream.cpp | 75 +++--------------------------- xfa/src/fgas/src/font/fx_stdfontmgr.cpp | 24 +--------- xfa/src/fxbarcode/BC_Writer.cpp | 7 +-- xfa/src/fxfa/src/app/xfa_ffapp.cpp | 6 --- xfa/src/fxfa/src/app/xfa_ffdoc.cpp | 3 -- xfa/src/fxfa/src/app/xfa_ffwidgetacc.cpp | 19 ++++---- xfa/src/fxfa/src/parser/xfa_object_imp.cpp | 6 --- xfa/src/fxjse/src/class.cpp | 1 - 12 files changed, 21 insertions(+), 138 deletions(-) (limited to 'xfa') diff --git a/xfa/include/fxfa/fxfa_widget.h b/xfa/include/fxfa/fxfa_widget.h index 88ab1ac3e5..634a287628 100644 --- a/xfa/include/fxfa/fxfa_widget.h +++ b/xfa/include/fxfa/fxfa_widget.h @@ -52,7 +52,7 @@ class CXFA_WidgetAcc : public CXFA_WidgetData { void StartWidgetLayout(FX_FLOAT& fCalcWidth, FX_FLOAT& fCalcHeight); FX_BOOL FindSplitPos(int32_t iBlockIndex, FX_FLOAT& fCalcHeight); FX_BOOL LoadCaption(); - FX_BOOL LoadText(); + void LoadText(); FX_BOOL LoadImageImage(); FX_BOOL LoadImageEditImage(); void GetImageDpi(int32_t& iImageXDpi, int32_t& iImageYDpi); diff --git a/xfa/src/fdp/src/css/fde_cssstylesheet.cpp b/xfa/src/fdp/src/css/fde_cssstylesheet.cpp index c94236d346..0ba1751b9f 100644 --- a/xfa/src/fdp/src/css/fde_cssstylesheet.cpp +++ b/xfa/src/fdp/src/css/fde_cssstylesheet.cpp @@ -48,9 +48,6 @@ IFDE_CSSStyleSheet* IFDE_CSSStyleSheet::LoadFromStream( FX_WORD wCodePage, FX_DWORD dwMediaList) { CFDE_CSSStyleSheet* pStyleSheet = new CFDE_CSSStyleSheet(dwMediaList); - if (pStyleSheet == NULL) { - return NULL; - } if (!pStyleSheet->LoadFromStream(szUrl, pStream, wCodePage)) { pStyleSheet->Release(); pStyleSheet = NULL; @@ -64,9 +61,6 @@ IFDE_CSSStyleSheet* IFDE_CSSStyleSheet::LoadFromBuffer( FX_WORD wCodePage, FX_DWORD dwMediaList) { CFDE_CSSStyleSheet* pStyleSheet = new CFDE_CSSStyleSheet(dwMediaList); - if (pStyleSheet == NULL) { - return NULL; - } if (!pStyleSheet->LoadFromBuffer(szUrl, pBuffer, iBufSize, wCodePage)) { pStyleSheet->Release(); pStyleSheet = NULL; diff --git a/xfa/src/fdp/src/fde/fde_gedevice.cpp b/xfa/src/fdp/src/fde/fde_gedevice.cpp index 81741a4cbb..4b716b4941 100644 --- a/xfa/src/fdp/src/fde/fde_gedevice.cpp +++ b/xfa/src/fdp/src/fde/fde_gedevice.cpp @@ -31,17 +31,11 @@ IFDE_RenderDevice* IFDE_RenderDevice::Create(CFX_DIBitmap* pBitmap, return NULL; } CFX_FxgeDevice* pDevice = new CFX_FxgeDevice; - if (pDevice == NULL) { - return NULL; - } pDevice->Attach(pBitmap, 0, bRgbByteOrder); return new CFDE_FxgeDevice(pDevice, TRUE); } IFDE_RenderDevice* IFDE_RenderDevice::Create(CFX_RenderDevice* pDevice) { - if (pDevice == NULL) { - return NULL; - } - return new CFDE_FxgeDevice(pDevice, FALSE); + return pDevice ? new CFDE_FxgeDevice(pDevice, FALSE) : nullptr; } CFDE_FxgeDevice::CFDE_FxgeDevice(CFX_RenderDevice* pDevice, FX_BOOL bOwnerDevice) diff --git a/xfa/src/fdp/src/xml/fde_xml.cpp b/xfa/src/fdp/src/xml/fde_xml.cpp index db1e8fc23e..056254a149 100644 --- a/xfa/src/fdp/src/xml/fde_xml.cpp +++ b/xfa/src/fdp/src/xml/fde_xml.cpp @@ -925,7 +925,7 @@ FX_BOOL CFDE_XMLDoc::LoadXML(IFX_Stream* pXMLStream, } else { m_pXMLParser = new CFDE_XMLSAXParser(pHandler, m_pSyntaxParser); } - return m_pXMLParser != NULL; + return TRUE; } FX_BOOL CFDE_XMLDoc::LoadXML(IFDE_XMLParser* pXMLParser) { if (pXMLParser == NULL) { diff --git a/xfa/src/fgas/src/crt/fx_stream.cpp b/xfa/src/fgas/src/crt/fx_stream.cpp index 0fdf810301..21b5ea3764 100644 --- a/xfa/src/fgas/src/crt/fx_stream.cpp +++ b/xfa/src/fgas/src/crt/fx_stream.cpp @@ -11,81 +11,49 @@ IFX_Stream* IFX_Stream::CreateStream(IFX_BufferRead* pBufferRead, int32_t iFileSize, FX_BOOL bReleaseBufferRead) { CFX_Stream* pSR = new CFX_Stream; - if (!pSR) { - return NULL; - } if (!pSR->LoadBufferRead(pBufferRead, iFileSize, dwAccess, bReleaseBufferRead)) { pSR->Release(); return NULL; } if (dwAccess & FX_STREAMACCESS_Text) { - IFX_Stream* pTR = new CFX_TextStream(pSR, TRUE); - if (!pTR) { - pTR->Release(); - pTR = NULL; - } - return pTR; + return new CFX_TextStream(pSR, TRUE); } return pSR; } IFX_Stream* IFX_Stream::CreateStream(IFX_FileRead* pFileRead, FX_DWORD dwAccess) { CFX_Stream* pSR = new CFX_Stream; - if (pSR == NULL) { - return NULL; - } if (!pSR->LoadFileRead(pFileRead, dwAccess)) { pSR->Release(); return NULL; } if (dwAccess & FX_STREAMACCESS_Text) { - IFX_Stream* pTR = new CFX_TextStream(pSR, TRUE); - if (pTR == NULL) { - pSR->Release(); - return NULL; - } - return pTR; + return new CFX_TextStream(pSR, TRUE); } return pSR; } IFX_Stream* IFX_Stream::CreateStream(IFX_FileWrite* pFileWrite, FX_DWORD dwAccess) { CFX_Stream* pSR = new CFX_Stream; - if (pSR == NULL) { - return NULL; - } if (!pSR->LoadFileWrite(pFileWrite, dwAccess)) { pSR->Release(); return NULL; } if (dwAccess & FX_STREAMACCESS_Text) { - IFX_Stream* pTR = new CFX_TextStream(pSR, TRUE); - if (pTR == NULL) { - pSR->Release(); - return NULL; - } - return pTR; + return new CFX_TextStream(pSR, TRUE); } return pSR; } IFX_Stream* IFX_Stream::CreateStream(const FX_WCHAR* pszFileName, FX_DWORD dwAccess) { CFX_Stream* pSR = new CFX_Stream; - if (pSR == NULL) { - return NULL; - } if (!pSR->LoadFile(pszFileName, dwAccess)) { pSR->Release(); return NULL; } if (dwAccess & FX_STREAMACCESS_Text) { - IFX_Stream* pTR = new CFX_TextStream(pSR, TRUE); - if (pTR == NULL) { - pSR->Release(); - return NULL; - } - return pTR; + return new CFX_TextStream(pSR, TRUE); } return pSR; } @@ -93,20 +61,12 @@ IFX_Stream* IFX_Stream::CreateStream(uint8_t* pData, int32_t length, FX_DWORD dwAccess) { CFX_Stream* pSR = new CFX_Stream; - if (pSR == NULL) { - return NULL; - } if (!pSR->LoadBuffer(pData, length, dwAccess)) { pSR->Release(); return NULL; } if (dwAccess & FX_STREAMACCESS_Text) { - IFX_Stream* pTR = new CFX_TextStream(pSR, TRUE); - if (pTR == NULL) { - pSR->Release(); - return NULL; - } - return pTR; + return new CFX_TextStream(pSR, TRUE); } return pSR; } @@ -778,12 +738,7 @@ IFX_Stream* CFX_TextStream::CreateSharedStream(FX_DWORD dwAccess, return NULL; } if (dwAccess & FX_STREAMACCESS_Text) { - IFX_Stream* pTR = new CFX_TextStream(pSR, TRUE); - if (pTR == NULL) { - pSR->Release(); - return NULL; - } - return pTR; + return new CFX_TextStream(pSR, TRUE); } return pSR; } @@ -901,9 +856,6 @@ FX_BOOL CFX_Stream::LoadFile(const FX_WCHAR* pszSrcFileName, return FALSE; } m_pStreamImp = new CFX_FileStreamImp(); - if (m_pStreamImp == NULL) { - return FALSE; - } FX_BOOL bRet = ((CFX_FileStreamImp*)m_pStreamImp)->LoadFile(pszSrcFileName, dwAccess); if (!bRet) { @@ -924,9 +876,6 @@ FX_BOOL CFX_Stream::LoadFileRead(IFX_FileRead* pFileRead, FX_DWORD dwAccess) { return FALSE; } m_pStreamImp = new CFX_FileReadStreamImp(); - if (m_pStreamImp == NULL) { - return FALSE; - } FX_BOOL bRet = ((CFX_FileReadStreamImp*)m_pStreamImp)->LoadFileRead(pFileRead, dwAccess); if (!bRet) { @@ -948,9 +897,6 @@ FX_BOOL CFX_Stream::LoadFileWrite(IFX_FileWrite* pFileWrite, return FALSE; } m_pStreamImp = new CFX_FileWriteStreamImp(); - if (m_pStreamImp == NULL) { - return FALSE; - } FX_BOOL bRet = ((CFX_FileWriteStreamImp*)m_pStreamImp) ->LoadFileWrite(pFileWrite, dwAccess); if (!bRet) { @@ -973,9 +919,6 @@ FX_BOOL CFX_Stream::LoadBuffer(uint8_t* pData, return FALSE; } m_pStreamImp = new CFX_BufferStreamImp(); - if (m_pStreamImp == NULL) { - return FALSE; - } FX_BOOL bRet = ((CFX_BufferStreamImp*)m_pStreamImp) ->LoadBuffer(pData, iTotalSize, dwAccess); if (!bRet) { @@ -999,9 +942,6 @@ FX_BOOL CFX_Stream::LoadBufferRead(IFX_BufferRead* pBufferRead, return FALSE; } m_pStreamImp = new CFX_BufferReadStreamImp; - if (m_pStreamImp == NULL) { - return FALSE; - } FX_BOOL bRet = ((CFX_BufferReadStreamImp*)m_pStreamImp) ->LoadBufferRead(pBufferRead, iFileSize, dwAccess, bReleaseBufferRead); @@ -1245,9 +1185,6 @@ IFX_Stream* CFX_Stream::CreateSharedStream(FX_DWORD dwAccess, return NULL; } CFX_Stream* pShared = new CFX_Stream; - if (pShared == NULL) { - return NULL; - } pShared->m_eStreamType = FX_STREAMTYPE_Stream; pShared->m_pStreamImp = m_pStreamImp; pShared->m_dwAccess = dwAccess; diff --git a/xfa/src/fgas/src/font/fx_stdfontmgr.cpp b/xfa/src/fgas/src/font/fx_stdfontmgr.cpp index a3769140cc..f339555c6b 100644 --- a/xfa/src/fgas/src/font/fx_stdfontmgr.cpp +++ b/xfa/src/fgas/src/font/fx_stdfontmgr.cpp @@ -131,9 +131,6 @@ IFX_Font* CFX_StdFontMgrImp::GetDefFontByUnicode( return NULL; } CFX_Font* pFXFont = new CFX_Font; - if (pFXFont == NULL) { - return NULL; - } pFXFont->m_Face = ftFace; pFXFont->m_pFontData = FXFT_Get_Face_Stream_Base(ftFace); pFXFont->m_dwSize = FXFT_Get_Face_Stream_Size(ftFace); @@ -601,9 +598,6 @@ IFX_FontMgr* IFX_FontMgr::Create(IFX_FontSourceEnum* pFontEnum, } CFX_FontMgrImp* pFontMgr = new CFX_FontMgrImp(pFontEnum, pDelegate, pUserData); - if (NULL == pFontMgr) { - return NULL; - } if (pFontMgr->EnumFonts()) { return pFontMgr; } @@ -756,12 +750,8 @@ IFX_Font* CFX_FontMgrImp::GetFontByCodePage(FX_WORD wCodePage, return pFonts->GetAt(0)->Retain(); } } - if (NULL == pFonts) { + if (!pFonts) pFonts = new CFX_ArrayTemplate; - } - if (NULL == pFonts) { - return NULL; - } m_Hash2Fonts.SetAt(dwHash, pFonts); CFX_FontDescriptorInfos* sortedFonts = NULL; if (!m_Hash2CandidateList.Lookup(dwHash, sortedFonts)) { @@ -818,12 +808,8 @@ IFX_Font* CFX_FontMgrImp::GetFontByUnicode(FX_WCHAR wUnicode, } } } - if (NULL == pFonts) { + if (!pFonts) pFonts = new CFX_ArrayTemplate; - } - if (NULL == pFonts) { - return NULL; - } m_Hash2Fonts.SetAt(dwHash, pFonts); CFX_FontDescriptorInfos* sortedFonts = NULL; if (!m_Hash2CandidateList.Lookup(dwHash, sortedFonts)) { @@ -974,9 +960,6 @@ IFX_Font* CFX_FontMgrImp::LoadFont(IFX_FileAccess* pFontAccess, } } CFX_Font* pInternalFont = new CFX_Font; - if (NULL == pInternalFont) { - return NULL; - } IFX_FileRead* pFontStream = pFontAccess->CreateFileStream(FX_FILEMODE_ReadOnly); if (NULL == pFontStream) { @@ -1277,9 +1260,6 @@ void CFX_FontMgrImp::ReportFace(FXFT_Face pFace, return; } CFX_FontDescriptor* pFont = new CFX_FontDescriptor; - if (NULL == pFont) { - return; - } pFont->m_dwFontStyles |= FXFT_Is_Face_Bold(pFace) ? FX_FONTSTYLE_Bold : 0; pFont->m_dwFontStyles |= FXFT_Is_Face_Italic(pFace) ? FX_FONTSTYLE_Italic : 0; pFont->m_dwFontStyles |= GetFlags(pFace); diff --git a/xfa/src/fxbarcode/BC_Writer.cpp b/xfa/src/fxbarcode/BC_Writer.cpp index e98c6f5537..889d6728d3 100644 --- a/xfa/src/fxbarcode/BC_Writer.cpp +++ b/xfa/src/fxbarcode/BC_Writer.cpp @@ -50,10 +50,7 @@ void CBC_Writer::SetBarcodeColor(FX_ARGB foregroundColor) { m_barColor = foregroundColor; } CFX_DIBitmap* CBC_Writer::CreateDIBitmap(int32_t width, int32_t height) { - CFX_DIBitmap* pDIBitmap = NULL; - pDIBitmap = new CFX_DIBitmap; - if (pDIBitmap != NULL) { - pDIBitmap->Create(width, height, m_colorSpace); - } + CFX_DIBitmap* pDIBitmap = new CFX_DIBitmap; + pDIBitmap->Create(width, height, m_colorSpace); return pDIBitmap; } diff --git a/xfa/src/fxfa/src/app/xfa_ffapp.cpp b/xfa/src/fxfa/src/app/xfa_ffapp.cpp index 14c59e93f0..5cdbb3661b 100644 --- a/xfa/src/fxfa/src/app/xfa_ffapp.cpp +++ b/xfa/src/fxfa/src/app/xfa_ffapp.cpp @@ -210,9 +210,6 @@ IXFA_Doc* CXFA_FFApp::CreateDoc(IXFA_DocProvider* pProvider, IFX_FileRead* pStream, FX_BOOL bTakeOverFile) { CXFA_FFDoc* pDoc = new CXFA_FFDoc(this, pProvider); - if (!pDoc) { - return NULL; - } FX_BOOL bSuccess = pDoc->OpenDoc(pStream, bTakeOverFile); if (!bSuccess) { delete pDoc; @@ -226,9 +223,6 @@ IXFA_Doc* CXFA_FFApp::CreateDoc(IXFA_DocProvider* pProvider, return NULL; } CXFA_FFDoc* pDoc = new CXFA_FFDoc(this, pProvider); - if (!pDoc) { - return NULL; - } FX_BOOL bSuccess = pDoc->OpenDoc(pPDFDoc); if (!bSuccess) { delete pDoc; diff --git a/xfa/src/fxfa/src/app/xfa_ffdoc.cpp b/xfa/src/fxfa/src/app/xfa_ffdoc.cpp index 7846bdafcd..84beae9b8b 100644 --- a/xfa/src/fxfa/src/app/xfa_ffdoc.cpp +++ b/xfa/src/fxfa/src/app/xfa_ffdoc.cpp @@ -253,9 +253,6 @@ FX_BOOL CXFA_FFDoc::OpenDoc(CPDF_Document* pPDFDoc) { return FALSE; } IFX_FileRead* pFileRead = new CXFA_FileRead2(xfaStreams); - if (!pFileRead) { - return FALSE; - } m_pPDFDoc = pPDFDoc; if (m_pStream) { m_pStream->Release(); diff --git a/xfa/src/fxfa/src/app/xfa_ffwidgetacc.cpp b/xfa/src/fxfa/src/app/xfa_ffwidgetacc.cpp index 6185ade383..8a4c18823c 100644 --- a/xfa/src/fxfa/src/app/xfa_ffwidgetacc.cpp +++ b/xfa/src/fxfa/src/app/xfa_ffwidgetacc.cpp @@ -45,13 +45,12 @@ class CXFA_TextLayoutData : public CXFA_WidgetLayoutData { } m_pTextProvider = NULL; } - FX_BOOL LoadText(CXFA_WidgetAcc* pAcc) { - if (m_pTextLayout) { - return TRUE; - } + void LoadText(CXFA_WidgetAcc* pAcc) { + if (m_pTextLayout) + return; + m_pTextProvider = new CXFA_TextProvider(pAcc, XFA_TEXTPROVIDERTYPE_Text); m_pTextLayout = new CXFA_TextLayout(m_pTextProvider); - return m_pTextLayout != NULL; } CXFA_TextLayout* m_pTextLayout; CXFA_TextProvider* m_pTextProvider; @@ -130,7 +129,7 @@ class CXFA_FieldLayoutData : public CXFA_WidgetLayoutData { m_pCapTextProvider = new CXFA_TextProvider(pAcc, XFA_TEXTPROVIDERTYPE_Caption); m_pCapTextLayout = new CXFA_TextLayout(m_pCapTextProvider); - return m_pCapTextLayout != NULL; + return TRUE; } return FALSE; } @@ -1043,9 +1042,7 @@ void CXFA_WidgetAcc::GetImageEditDpi(int32_t& iImageXDpi, int32_t& iImageYDpi) { iImageYDpi = ((CXFA_ImageEditData*)m_pLayoutData)->m_iImageYDpi; } FX_BOOL CXFA_WidgetAcc::CalculateTextAutoSize(CFX_SizeF& size) { - if (!LoadText()) { - return FALSE; - } + LoadText(); CXFA_TextLayout* pTextLayout = ((CXFA_TextLayoutData*)m_pLayoutData)->m_pTextLayout; if (pTextLayout) { @@ -1054,9 +1051,9 @@ FX_BOOL CXFA_WidgetAcc::CalculateTextAutoSize(CFX_SizeF& size) { } return CalculateWidgetAutoSize(size); } -FX_BOOL CXFA_WidgetAcc::LoadText() { +void CXFA_WidgetAcc::LoadText() { InitLayoutData(); - return ((CXFA_TextLayoutData*)m_pLayoutData)->LoadText(this); + ((CXFA_TextLayoutData*)m_pLayoutData)->LoadText(this); } FX_FLOAT CXFA_WidgetAcc::CalculateWidgetAutoWidth(FX_FLOAT fWidthCalc) { CXFA_Margin mgWidget = this->GetMargin(); diff --git a/xfa/src/fxfa/src/parser/xfa_object_imp.cpp b/xfa/src/fxfa/src/parser/xfa_object_imp.cpp index 65f5f6fc8f..db059675f8 100644 --- a/xfa/src/fxfa/src/parser/xfa_object_imp.cpp +++ b/xfa/src/fxfa/src/parser/xfa_object_imp.cpp @@ -3977,9 +3977,6 @@ FX_BOOL CXFA_Node::SetCData(XFA_ATTRIBUTE eAttr, OnChanging(eAttr, (void*)(const FX_WCHAR*)wsValue, bNotify); if (eAttr == XFA_ATTRIBUTE_Value) { CFX_WideString* pClone = new CFX_WideString(wsValue); - if (pClone == NULL) { - return FALSE; - } SetUserData(pKey, pClone, &deleteWideStringCallBack); } else { SetMapModuleString(pKey, wsValue); @@ -4056,9 +4053,6 @@ FX_BOOL CXFA_Node::SetAttributeValue(const CFX_WideString& wsValue, } OnChanging(XFA_ATTRIBUTE_Value, (void*)(const FX_WCHAR*)wsValue, bNotify); CFX_WideString* pClone = new CFX_WideString(wsValue); - if (pClone == NULL) { - return FALSE; - } SetUserData(pKey, pClone, &deleteWideStringCallBack); OnChanged(XFA_ATTRIBUTE_Value, (void*)(const FX_WCHAR*)wsValue, bNotify, bScriptModify); diff --git a/xfa/src/fxjse/src/class.cpp b/xfa/src/fxjse/src/class.cpp index 5f6f99a0d4..891c7e1002 100644 --- a/xfa/src/fxjse/src/class.cpp +++ b/xfa/src/fxjse/src/class.cpp @@ -248,7 +248,6 @@ CFXJSE_Class* CFXJSE_Class::Create(CFXJSE_Context* lpContext, } v8::Isolate* pIsolate = lpContext->m_pIsolate; pClass = new CFXJSE_Class(lpContext); - ASSERT(pClass); pClass->m_szClassName = lpClassDefinition->name; CFXJSE_ScopeUtil_IsolateHandleRootContext scope(pIsolate); v8::Local hFunctionTemplate = v8::FunctionTemplate::New( -- cgit v1.2.3