Replace FX_NEW with new, remove tests in fpdfdoc.

R=thestig@chromium.org

Review URL: https://codereview.chromium.org/1090693002
diff --git a/core/src/fpdfdoc/doc_annot.cpp b/core/src/fpdfdoc/doc_annot.cpp
index 8952845..cc6b5cc 100644
--- a/core/src/fpdfdoc/doc_annot.cpp
+++ b/core/src/fpdfdoc/doc_annot.cpp
@@ -37,10 +37,7 @@
             pAnnots->RemoveAt(i + 1);
             pDict = pAnnots->GetDict(i);
         }
-        CPDF_Annot* pAnnot = FX_NEW CPDF_Annot(pDict);
-        if (pAnnot == NULL) {
-            break;
-        }
+        CPDF_Annot* pAnnot = new CPDF_Annot(pDict);
         pAnnot->m_pList = this;
         m_AnnotList.Add(pAnnot);
         if (bRegenerateAP && pDict->GetConstString(FX_BSTRC("Subtype")) == FX_BSTRC("Widget"))
@@ -225,10 +222,7 @@
     if (m_APMap.Lookup(pStream, (void*&)pForm)) {
         return pForm;
     }
-    pForm = FX_NEW CPDF_Form(m_pList->m_pDocument, pPage->m_pResources, pStream);
-    if (pForm == NULL) {
-        return NULL;
-    }
+    pForm = new CPDF_Form(m_pList->m_pDocument, pPage->m_pResources, pStream);
     pForm->ParseContent(NULL, NULL, NULL, NULL);
     m_APMap.SetAt(pStream, pForm);
     return pForm;
@@ -323,10 +317,7 @@
         int B = (FX_INT32)(pColor->GetNumber(2) * 255);
         argb = ArgbEncode(0xff, R, G, B);
     }
-    CPDF_PathObject *pPathObject = FX_NEW CPDF_PathObject();
-    if (!pPathObject) {
-        return NULL;
-    }
+    CPDF_PathObject *pPathObject = new CPDF_PathObject();
     CPDF_GraphStateData *pGraphState = pPathObject->m_GraphState.GetModify();
     if (!pGraphState) {
         pPathObject->Release();
diff --git a/core/src/fpdfdoc/doc_form.cpp b/core/src/fpdfdoc/doc_form.cpp
index d8ca525..47f4a91 100644
--- a/core/src/fpdfdoc/doc_form.cpp
+++ b/core/src/fpdfdoc/doc_form.cpp
@@ -126,10 +126,7 @@
     if (pParent == NULL) {
         return NULL;
     }
-    _Node *pNode = FX_NEW _Node;
-    if (pNode == NULL) {
-        return NULL;
-    }
+    _Node* pNode = new _Node;
     pNode->parent = pParent;
     pNode->short_name = short_name;
     pNode->field_ptr = field_ptr;
@@ -270,7 +267,7 @@
     m_bGenerateAP = bGenerateAP;
     m_pFormNotify = NULL;
     m_bUpdated = FALSE;
-    m_pFieldTree = FX_NEW CFieldTree;
+    m_pFieldTree = new CFieldTree;
     CPDF_Dictionary* pRoot = m_pDocument->GetRoot();
     m_pFormDict = pRoot->GetDict("AcroForm");
     if (m_pFormDict == NULL) {
@@ -1334,7 +1331,7 @@
                 }
             }
         }
-        pField = FX_NEW CPDF_FormField(this, pParent);
+        pField = new CPDF_FormField(this, pParent);
         CPDF_Object* pTObj = pDict->GetElement("T");
         if (pTObj && pTObj->GetType() == PDFOBJ_REFERENCE) {
             CPDF_Object* pClone = pTObj->Clone(TRUE);
@@ -1371,10 +1368,7 @@
     if (m_ControlMap.Lookup((CPDF_Dictionary*)pWidgetDict, rValue)) {
         return (CPDF_FormControl*)rValue;
     }
-    CPDF_FormControl* pControl = FX_NEW CPDF_FormControl((CPDF_FormField*)pField, (CPDF_Dictionary*)pWidgetDict);
-    if (pControl == NULL) {
-        return NULL;
-    }
+    CPDF_FormControl* pControl = new CPDF_FormControl((CPDF_FormField*)pField, (CPDF_Dictionary*)pWidgetDict);
     m_ControlMap.SetAt((CPDF_Dictionary*)pWidgetDict, pControl);
     ((CPDF_FormField*)pField)->m_ControlList.Add(pControl);
     return pControl;
diff --git a/core/src/fpdfdoc/doc_link.cpp b/core/src/fpdfdoc/doc_link.cpp
index 4a42e21..9a08d15 100644
--- a/core/src/fpdfdoc/doc_link.cpp
+++ b/core/src/fpdfdoc/doc_link.cpp
@@ -24,10 +24,7 @@
     }
     CFX_PtrArray* pPageLinkList = NULL;
     if (!m_PageMap.Lookup((FX_LPVOID)(FX_UINTPTR)objnum, (FX_LPVOID&)pPageLinkList)) {
-        pPageLinkList = FX_NEW CFX_PtrArray;
-        if (pPageLinkList == NULL) {
-            return NULL;
-        }
+        pPageLinkList = new CFX_PtrArray;
         m_PageMap.SetAt((FX_LPVOID)(FX_UINTPTR)objnum, pPageLinkList);
         LoadPageLinks(pPage, pPageLinkList);
     }
diff --git a/core/src/fpdfdoc/doc_metadata.cpp b/core/src/fpdfdoc/doc_metadata.cpp
index 232f6ee..e6c7a64 100644
--- a/core/src/fpdfdoc/doc_metadata.cpp
+++ b/core/src/fpdfdoc/doc_metadata.cpp
@@ -28,14 +28,13 @@
 {
     m_pData = FX_Alloc(PDFDOC_METADATA, 1);
     CFX_CMapByteStringToPtr *&pStringMap = ((PDFDOC_LPMETADATA)m_pData)->m_pStringMap;
-    pStringMap = FX_NEW CFX_CMapByteStringToPtr;
-    if (pStringMap != NULL) {
-        CFX_ByteString bstr;
-        for (int i = 0; i < 18; i += 2) {
-            bstr = gs_FPDFDOC_Metadata_Titles[i];
-            pStringMap->AddValue(bstr, (void*)gs_FPDFDOC_Metadata_Titles[i + 1]);
-        }
+    pStringMap = new CFX_CMapByteStringToPtr;
+    CFX_ByteString bstr;
+    for (int i = 0; i < 18; i += 2) {
+        bstr = gs_FPDFDOC_Metadata_Titles[i];
+        pStringMap->AddValue(bstr, (void*)gs_FPDFDOC_Metadata_Titles[i + 1]);
     }
+
 }
 CPDF_Metadata::~CPDF_Metadata()
 {
diff --git a/core/src/fpdfdoc/doc_tagged.cpp b/core/src/fpdfdoc/doc_tagged.cpp
index c5fe39b..e3cd744 100644
--- a/core/src/fpdfdoc/doc_tagged.cpp
+++ b/core/src/fpdfdoc/doc_tagged.cpp
@@ -20,10 +20,7 @@
     if (!IsTagged(pDoc)) {
         return NULL;
     }
-    CPDF_StructTreeImpl* pTree = FX_NEW CPDF_StructTreeImpl(pDoc);
-    if (pTree == NULL) {
-        return NULL;
-    }
+    CPDF_StructTreeImpl* pTree = new CPDF_StructTreeImpl(pDoc);
     pTree->LoadPageTree(pPageDict);
     return pTree;
 }
@@ -32,10 +29,7 @@
     if (!IsTagged(pDoc)) {
         return NULL;
     }
-    CPDF_StructTreeImpl* pTree = FX_NEW CPDF_StructTreeImpl(pDoc);
-    if (pTree == NULL) {
-        return NULL;
-    }
+    CPDF_StructTreeImpl* pTree = new CPDF_StructTreeImpl(pDoc);
     pTree->LoadDocTree();
     return pTree;
 }
@@ -66,10 +60,7 @@
         return;
     }
     if (pKids->GetType() == PDFOBJ_DICTIONARY) {
-        CPDF_StructElementImpl* pStructElementImpl = FX_NEW CPDF_StructElementImpl(this, NULL, (CPDF_Dictionary*)pKids);
-        if (pStructElementImpl == NULL) {
-            return;
-        }
+        CPDF_StructElementImpl* pStructElementImpl = new CPDF_StructElementImpl(this, NULL, (CPDF_Dictionary*)pKids);
         m_Kids.Add(pStructElementImpl);
         return;
     }
@@ -79,10 +70,7 @@
     CPDF_Array* pArray = (CPDF_Array*)pKids;
     for (FX_DWORD i = 0; i < pArray->GetCount(); i ++) {
         CPDF_Dictionary* pKid = pArray->GetDict(i);
-        CPDF_StructElementImpl* pStructElementImpl = FX_NEW CPDF_StructElementImpl(this, NULL, pKid);
-        if (pStructElementImpl == NULL) {
-            return;
-        }
+        CPDF_StructElementImpl* pStructElementImpl = new CPDF_StructElementImpl(this, NULL, pKid);
         m_Kids.Add(pStructElementImpl);
     }
 }
@@ -140,10 +128,7 @@
     if (map.Lookup(pDict, (FX_LPVOID&)pElement)) {
         return pElement;
     }
-    pElement = FX_NEW CPDF_StructElementImpl(this, NULL, pDict);
-    if (pElement == NULL) {
-        return NULL;
-    }
+    pElement = new CPDF_StructElementImpl(this, NULL, pDict);
     map.SetAt(pDict, pElement);
     CPDF_Dictionary* pParent = pDict->GetDict(FX_BSTRC("P"));
     if (pParent == NULL || pParent->GetString(FX_BSTRC("Type")) == FX_BSTRC("StructTreeRoot")) {
@@ -321,7 +306,7 @@
         pKid->m_Type = CPDF_StructKid::Element;
         pKid->m_Element.m_pDict = pKidDict;
         if (m_pTree->m_pPage == NULL) {
-            pKid->m_Element.m_pElement = FX_NEW CPDF_StructElementImpl(m_pTree, this, pKidDict);
+            pKid->m_Element.m_pElement = new CPDF_StructElementImpl(m_pTree, this, pKidDict);
         } else {
             pKid->m_Element.m_pElement = NULL;
         }
diff --git a/core/src/fpdfdoc/doc_vt.cpp b/core/src/fpdfdoc/doc_vt.cpp
index fd3f5ba..3ae23ff 100644
--- a/core/src/fpdfdoc/doc_vt.cpp
+++ b/core/src/fpdfdoc/doc_vt.cpp
@@ -77,13 +77,12 @@
 }
 CPVT_WordPlace CSection::AddWord(const CPVT_WordPlace & place, const CPVT_WordInfo & wordinfo)
 {
-    if (CPVT_WordInfo * pWord = FX_NEW CPVT_WordInfo(wordinfo)) {
-        FX_INT32 nWordIndex = FPDF_MAX(FPDF_MIN(place.nWordIndex, this->m_WordArray.GetSize()), 0);
-        if (nWordIndex == m_WordArray.GetSize()) {
-            m_WordArray.Add(pWord);
-        } else {
-            m_WordArray.InsertAt(nWordIndex, pWord);
-        }
+    CPVT_WordInfo * pWord = new CPVT_WordInfo(wordinfo);
+    FX_INT32 nWordIndex = FPDF_MAX(FPDF_MIN(place.nWordIndex, this->m_WordArray.GetSize()), 0);
+    if (nWordIndex == m_WordArray.GetSize()) {
+        m_WordArray.Add(pWord);
+    } else {
+        m_WordArray.InsertAt(nWordIndex, pWord);
     }
     return place;
 }
@@ -834,8 +833,8 @@
     if (!m_bInitial) {
         CPVT_SectionInfo secinfo;
         if (m_bRichText) {
-            secinfo.pSecProps = FX_NEW CPVT_SecProps(0.0f, 0.0f, 0);
-            secinfo.pWordProps = FX_NEW CPVT_WordProps(GetDefaultFontIndex(), PVT_DEFAULT_FONTSIZE, 0, 0, 0);
+            secinfo.pSecProps = new CPVT_SecProps(0.0f, 0.0f, 0);
+            secinfo.pWordProps = new CPVT_WordProps(GetDefaultFontIndex(), PVT_DEFAULT_FONTSIZE, 0, 0, 0);
         }
         CPVT_WordPlace place;
         place.nSecIndex = 0;
@@ -868,11 +867,9 @@
     CPVT_WordPlace newplace = place;
     newplace.nWordIndex ++;
     if (m_bRichText) {
-        CPVT_WordProps * pNewProps = pWordProps ? FX_NEW CPVT_WordProps(*pWordProps) : FX_NEW CPVT_WordProps();
-        if (pNewProps) {
-            pNewProps->nFontIndex = GetWordFontIndex(word, charset, pWordProps->nFontIndex);
-            return AddWord(newplace, CPVT_WordInfo(word, charset, -1, pNewProps));
-        }
+        CPVT_WordProps * pNewProps = pWordProps ? new CPVT_WordProps(*pWordProps) : new CPVT_WordProps();
+        pNewProps->nFontIndex = GetWordFontIndex(word, charset, pWordProps->nFontIndex);
+        return AddWord(newplace, CPVT_WordInfo(word, charset, -1, pNewProps));
     } else {
         FX_INT32 nFontIndex = GetSubWord() > 0 ? GetDefaultFontIndex() : GetWordFontIndex(word, charset, GetDefaultFontIndex());
         return AddWord(newplace, CPVT_WordInfo(word, charset, nFontIndex, NULL));
@@ -900,10 +897,10 @@
         CPVT_SectionInfo secinfo;
         if (m_bRichText) {
             if (pSecProps) {
-                secinfo.pSecProps = FX_NEW CPVT_SecProps(*pSecProps);
+                secinfo.pSecProps = new CPVT_SecProps(*pSecProps);
             }
             if (pWordProps) {
-                secinfo.pWordProps = FX_NEW CPVT_WordProps(*pWordProps);
+                secinfo.pWordProps = new CPVT_WordProps(*pWordProps);
             }
         }
         AddSection(NewPlace, secinfo);
@@ -989,10 +986,10 @@
     CPVT_SectionInfo secinfo;
     if (m_bRichText) {
         if (pSecProps) {
-            secinfo.pSecProps = FX_NEW CPVT_SecProps(*pSecProps);
+            secinfo.pSecProps = new CPVT_SecProps(*pSecProps);
         }
         if (pWordProps) {
-            secinfo.pWordProps = FX_NEW CPVT_WordProps(*pWordProps);
+            secinfo.pWordProps = new CPVT_WordProps(*pWordProps);
         }
     }
     if (CSection * pSection = m_SectionArray.GetAt(0)) {
@@ -1280,10 +1277,7 @@
         return place;
     }
     FX_INT32 nSecIndex = FPDF_MAX(FPDF_MIN(place.nSecIndex, m_SectionArray.GetSize()), 0);
-    CSection * pSection = FX_NEW CSection(this);
-    if (!pSection) {
-        return place;
-    }
+    CSection * pSection = new CSection(this);
     pSection->m_SecInfo = secinfo;
     pSection->SecPlace.nSecIndex = nSecIndex;
     if (nSecIndex == m_SectionArray.GetSize()) {
@@ -1676,7 +1670,7 @@
 IPDF_VariableText_Iterator * CPDF_VariableText::GetIterator()
 {
     if (!m_pVTIterator) {
-        return m_pVTIterator = FX_NEW CPDF_VariableText_Iterator(this);
+        m_pVTIterator = new CPDF_VariableText_Iterator(this);
     }
     return m_pVTIterator;
 }
diff --git a/core/src/fpdfdoc/doc_vtmodule.cpp b/core/src/fpdfdoc/doc_vtmodule.cpp
index c44cbac..f82de25 100644
--- a/core/src/fpdfdoc/doc_vtmodule.cpp
+++ b/core/src/fpdfdoc/doc_vtmodule.cpp
@@ -9,7 +9,7 @@
 #include "pdf_vt.h"
 IPDF_VariableText* IPDF_VariableText::NewVariableText()
 {
-    return FX_NEW CPDF_VariableText();
+    return new CPDF_VariableText();
 }
 void IPDF_VariableText::DelVariableText(IPDF_VariableText* pVT)
 {
diff --git a/core/src/fpdfdoc/pdf_vt.h b/core/src/fpdfdoc/pdf_vt.h
index f910dfd..19c7547 100644
--- a/core/src/fpdfdoc/pdf_vt.h
+++ b/core/src/fpdfdoc/pdf_vt.h
@@ -106,14 +106,14 @@
             if (pSecProps) {
                 *pSecProps = *other.pSecProps;
             } else {
-                pSecProps = FX_NEW CPVT_SecProps(*other.pSecProps);
+                pSecProps = new CPVT_SecProps(*other.pSecProps);
             }
         }
         if (other.pWordProps) {
             if (pWordProps) {
                 *pWordProps = *other.pWordProps;
             } else {
-                pWordProps = FX_NEW CPVT_WordProps(*other.pWordProps);
+                pWordProps = new CPVT_WordProps(*other.pWordProps);
             }
         }
     }
@@ -169,7 +169,7 @@
             if (pWordProps) {
                 *pWordProps = *word.pWordProps;
             } else {
-                pWordProps = FX_NEW CPVT_WordProps(*word.pWordProps);
+                pWordProps = new CPVT_WordProps(*word.pWordProps);
             }
         }
     }
@@ -258,18 +258,13 @@
     FX_INT32								Add(const CPVT_LineInfo & lineinfo)
     {
         if (m_nTotal >= GetSize()) {
-            if (CLine * pLine = FX_NEW CLine) {
-                pLine->m_LineInfo = lineinfo;
-                m_Lines.Add(pLine);
-                return m_nTotal++;
-            }
-            return m_nTotal;
-        } else {
-            if (CLine * pLine = GetAt(m_nTotal)) {
-                pLine->m_LineInfo = lineinfo;
-            }
-            return m_nTotal++;
+            CLine* pLine = new CLine;
+            pLine->m_LineInfo = lineinfo;
+            m_Lines.Add(pLine);
+        } else if (CLine* pLine = GetAt(m_nTotal)) {
+            pLine->m_LineInfo = lineinfo;
         }
+        return m_nTotal++;
     }
     void									Clear()
     {