From e00660b5fa41956db06c557807b68a1117d1b70b Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Thu, 13 Aug 2015 15:40:18 -0700 Subject: Merge to XFA: Remove if checks after new. R=tsepez@chromium.org Review URL: https://codereview.chromium.org/1287863002 . (cherry picked from commit 388a3b0b8d6f75d47978c08299300f121f04884c) Review URL: https://codereview.chromium.org/1292653002 . --- core/src/fxge/apple/fx_quartz_device.cpp | 6 ------ fpdfsdk/include/fxedit/fxet_edit.h | 19 +++++++++---------- fpdfsdk/include/javascript/JS_Object.h | 9 ++++----- fpdfsdk/src/fxedit/fxet_list.cpp | 11 +++++------ fpdfsdk/src/javascript/app.cpp | 13 +++---------- fpdfsdk/src/pdfwindow/PWL_Wnd.cpp | 4 ++-- samples/pdfium_test.cc | 26 ++++++++++++-------------- 7 files changed, 35 insertions(+), 53 deletions(-) diff --git a/core/src/fxge/apple/fx_quartz_device.cpp b/core/src/fxge/apple/fx_quartz_device.cpp index 323b8eac3c..0407a5e612 100644 --- a/core/src/fxge/apple/fx_quartz_device.cpp +++ b/core/src/fxge/apple/fx_quartz_device.cpp @@ -93,9 +93,6 @@ FX_BOOL CQuartz2D::drawGraphicsString(void* graphics, CGContextSaveGState(context); #if CGFLOAT_IS_DOUBLE CGPoint* glyphPositionsCG = new CGPoint[charsCount]; - if (!glyphPositionsCG) { - return FALSE; - } for (int index = 0; index < charsCount; ++index) { glyphPositionsCG[index].x = glyphPositions[index].x; glyphPositionsCG[index].y = glyphPositions[index].y; @@ -908,9 +905,6 @@ void CFX_QuartzDeviceDriver::setStrokeInfo(const CFX_GraphStateData* graphState, if (graphState->m_DashCount) { #if CGFLOAT_IS_DOUBLE CGFloat* dashArray = new CGFloat[graphState->m_DashCount]; - if (!dashArray) { - return; - } for (int index = 0; index < graphState->m_DashCount; ++index) { dashArray[index] = graphState->m_DashArray[index]; } diff --git a/fpdfsdk/include/fxedit/fxet_edit.h b/fpdfsdk/include/fxedit/fxet_edit.h index d654ebc451..2cb7c99720 100644 --- a/fpdfsdk/include/fxedit/fxet_edit.h +++ b/fpdfsdk/include/fxedit/fxet_edit.h @@ -115,8 +115,7 @@ class CFX_Edit_LineRectArray { } void Add(const CPVT_WordRange& wrLine, const CPDF_Rect& rcLine) { - if (CFX_Edit_LineRect* pRect = new CFX_Edit_LineRect(wrLine, rcLine)) - m_LineRects.Add(pRect); + m_LineRects.Add(new CFX_Edit_LineRect(wrLine, rcLine)); } int32_t GetSize() const { return m_LineRects.GetSize(); } @@ -145,14 +144,14 @@ class CFX_Edit_RectArray { } void Add(const CPDF_Rect& rect) { - // check for overlaped area - for (int32_t i = 0, sz = m_Rects.GetSize(); i < sz; i++) - if (CPDF_Rect* pRect = m_Rects.GetAt(i)) - if (pRect->Contains(rect)) - return; - - if (CPDF_Rect* pNewRect = new CPDF_Rect(rect)) - m_Rects.Add(pNewRect); + // check for overlapped area + for (int32_t i = 0, sz = m_Rects.GetSize(); i < sz; i++) { + CPDF_Rect* pRect = m_Rects.GetAt(i); + if (pRect && pRect->Contains(rect)) + return; + } + + m_Rects.Add(new CPDF_Rect(rect)); } int32_t GetSize() const { return m_Rects.GetSize(); } diff --git a/fpdfsdk/include/javascript/JS_Object.h b/fpdfsdk/include/javascript/JS_Object.h index fe8a91f471..caed92b034 100644 --- a/fpdfsdk/include/javascript/JS_Object.h +++ b/fpdfsdk/include/javascript/JS_Object.h @@ -109,11 +109,10 @@ struct JS_TIMER_MAPARRAY { if (JS_TIMER_MAP* pMap = m_Array.GetAt(i)) pMap->pTimer = pTimer; } else { - if (JS_TIMER_MAP* pMap = new JS_TIMER_MAP) { - pMap->nID = nIndex; - pMap->pTimer = pTimer; - m_Array.Add(pMap); - } + JS_TIMER_MAP* pMap = new JS_TIMER_MAP; + pMap->nID = nIndex; + pMap->pTimer = pTimer; + m_Array.Add(pMap); } } diff --git a/fpdfsdk/src/fxedit/fxet_list.cpp b/fpdfsdk/src/fxedit/fxet_list.cpp index 70dc8d5262..ff4723e514 100644 --- a/fpdfsdk/src/fxedit/fxet_list.cpp +++ b/fpdfsdk/src/fxedit/fxet_list.cpp @@ -128,12 +128,11 @@ void CFX_List::SetFontSize(FX_FLOAT fFontSize) { } void CFX_List::AddItem(const FX_WCHAR* str) { - if (CFX_ListItem* pListItem = new CFX_ListItem()) { - pListItem->SetFontMap(m_pFontMap); - pListItem->SetFontSize(m_fFontSize); - pListItem->SetText(str); - m_aListItems.Add(pListItem); - } + CFX_ListItem* pListItem = new CFX_ListItem(); + pListItem->SetFontMap(m_pFontMap); + pListItem->SetFontSize(m_fFontSize); + pListItem->SetText(str); + m_aListItems.Add(pListItem); } void CFX_List::ReArrange(int32_t nItemIndex) { diff --git a/fpdfsdk/src/javascript/app.cpp b/fpdfsdk/src/javascript/app.cpp index 136b544142..aff491a084 100644 --- a/fpdfsdk/src/javascript/app.cpp +++ b/fpdfsdk/src/javascript/app.cpp @@ -304,19 +304,12 @@ FX_BOOL app::alert(IFXJS_Context* cc, if (swMsg == L"") { CJS_Array carray(isolate); if (params[0].ConvertToArray(carray)) { - int iLenth = carray.GetLength(); + int iLength = carray.GetLength(); CJS_Value* pValue = new CJS_Value(isolate); - // if (iLenth == 1) - // pValue = new - // CJS_Value(isolate); - // else if (iLenth > 1) - // pValue = new - // CJS_Value[iLenth]; - - for (int i = 0; i < iLenth; i++) { + for (int i = 0; i < iLength; ++i) { carray.GetElement(i, *pValue); swMsg += (*pValue).ToCFXWideString(); - if (i < iLenth - 1) + if (i < iLength - 1) swMsg += L", "; } diff --git a/fpdfsdk/src/pdfwindow/PWL_Wnd.cpp b/fpdfsdk/src/pdfwindow/PWL_Wnd.cpp index 81bbbbfe8e..7b765f3e4f 100644 --- a/fpdfsdk/src/pdfwindow/PWL_Wnd.cpp +++ b/fpdfsdk/src/pdfwindow/PWL_Wnd.cpp @@ -685,8 +685,8 @@ void CPWL_Wnd::CreateVScrollBar(const PWL_CREATEPARAM& cp) { scp.eCursorType = FXCT_ARROW; scp.nTransparency = PWL_SCROLLBAR_TRANSPARANCY; - if ((m_pVScrollBar = new CPWL_ScrollBar(SBT_VSCROLL))) - m_pVScrollBar->Create(scp); + m_pVScrollBar = new CPWL_ScrollBar(SBT_VSCROLL); + m_pVScrollBar->Create(scp); } } diff --git a/samples/pdfium_test.cc b/samples/pdfium_test.cc index 7ecd9a2aee..83a8f7620b 100644 --- a/samples/pdfium_test.cc +++ b/samples/pdfium_test.cc @@ -145,22 +145,20 @@ static void WritePpm(const char* pdf_name, int num, const void* buffer_void, // Source data is B, G, R, unused. // Dest data is R, G, B. char* result = new char[out_len]; - if (result) { - for (int h = 0; h < height; ++h) { - const char* src_line = buffer + (stride * h); - char* dest_line = result + (width * h * 3); - for (int w = 0; w < width; ++w) { - // R - dest_line[w * 3] = src_line[(w * 4) + 2]; - // G - dest_line[(w * 3) + 1] = src_line[(w * 4) + 1]; - // B - dest_line[(w * 3) + 2] = src_line[w * 4]; - } + for (int h = 0; h < height; ++h) { + const char* src_line = buffer + (stride * h); + char* dest_line = result + (width * h * 3); + for (int w = 0; w < width; ++w) { + // R + dest_line[w * 3] = src_line[(w * 4) + 2]; + // G + dest_line[(w * 3) + 1] = src_line[(w * 4) + 1]; + // B + dest_line[(w * 3) + 2] = src_line[w * 4]; } - fwrite(result, out_len, 1, fp); - delete [] result; } + fwrite(result, out_len, 1, fp); + delete[] result; fclose(fp); } -- cgit v1.2.3