Merge to XFA: Remove Release() combo patch.
authorTom Sepez <tsepez@chromium.org>
Mon, 20 Apr 2015 23:33:30 +0000 (16:33 -0700)
committerTom Sepez <tsepez@chromium.org>
Mon, 20 Apr 2015 23:33:30 +0000 (16:33 -0700)
Includes:
Original Review URL: https://codereview.chromium.org/1098043002
Original Review URL: https://codereview.chromium.org/1097843003
Original Review URL: https://codereview.chromium.org/1093213002

R=thestig@chromium.org

Review URL: https://codereview.chromium.org/1092033004

core/include/fpdfapi/fpdf_pageobj.h
core/src/fpdfapi/fpdf_page/fpdf_page.cpp
core/src/fpdfapi/fpdf_page/fpdf_page_graph_state.cpp
core/src/fpdfdoc/doc_annot.cpp
fpdfsdk/include/formfiller/FFL_TextField.h
fpdfsdk/include/fsdk_baseform.h
fpdfsdk/include/fxedit/fx_edit.h
fpdfsdk/include/fxedit/fxet_edit.h
fpdfsdk/src/formfiller/FFL_TextField.cpp
fpdfsdk/src/fsdk_baseform.cpp
fpdfsdk/src/fxedit/fxet_edit.cpp

index bd11a20..e78c9bb 100644 (file)
@@ -455,10 +455,8 @@ public:
 class CPDF_PageObject : public CPDF_GraphicStates
 {
 public:
-
     static CPDF_PageObject* Create(int type);
-
-    void                               Release();
+    virtual ~CPDF_PageObject();
 
     CPDF_PageObject*   Clone() const;
 
@@ -505,7 +503,6 @@ protected:
 
     CPDF_PageObject() {}
 
-    virtual ~CPDF_PageObject() {}
 };
 struct CPDF_TextObjectItem  {
 
index ccdfb9f..c9b1705 100644 (file)
@@ -7,10 +7,6 @@
 #include "../../../include/fpdfapi/fpdf_page.h"
 #include "../../../include/fpdfapi/fpdf_module.h"
 #include "pageint.h"
-void CPDF_PageObject::Release()
-{
-    delete this;
-}
 CPDF_PageObject* CPDF_PageObject::Create(int type)
 {
     switch (type) {
@@ -27,6 +23,9 @@ CPDF_PageObject* CPDF_PageObject::Create(int type)
     }
     return NULL;
 }
+CPDF_PageObject::~CPDF_PageObject()
+{
+}
 CPDF_PageObject* CPDF_PageObject::Clone() const
 {
     CPDF_PageObject* pObj = Create(m_Type);
@@ -689,11 +688,7 @@ CPDF_PageObjects::~CPDF_PageObjects()
     }
     FX_POSITION pos = m_ObjectList.GetHeadPosition();
     while (pos) {
-        CPDF_PageObject* pPageObj = (CPDF_PageObject*)m_ObjectList.GetNext(pos);
-        if (!pPageObj) {
-            continue;
-        }
-        pPageObj->Release();
+        delete (CPDF_PageObject*)m_ObjectList.GetNext(pos);
     }
 }
 void CPDF_PageObjects::ContinueParse(IFX_Pause* pPause)
@@ -808,11 +803,7 @@ void CPDF_PageObjects::ClearCacheObjects()
     if (m_bReleaseMembers) {
         FX_POSITION pos = m_ObjectList.GetHeadPosition();
         while (pos) {
-            CPDF_PageObject* pPageObj = (CPDF_PageObject*)m_ObjectList.GetNext(pos);
-            if (!pPageObj) {
-                continue;
-            }
-            pPageObj->Release();
+            delete (CPDF_PageObject*)m_ObjectList.GetNext(pos);
         }
     }
     m_ObjectList.RemoveAll();
index 559d850..612b0e3 100644 (file)
@@ -192,8 +192,7 @@ void CPDF_ClipPath::AppendTexts(CPDF_TextObject** pTexts, int count)
     CPDF_ClipPathData* pData = GetModify();
     if (pData->m_TextCount + count > FPDF_CLIPPATH_MAX_TEXTS) {
         for (int i = 0; i < count; i ++) {
-            if (pTexts[i])
-                pTexts[i]->Release();
+            delete pTexts[i];
         }
         return;
     }
index 8952845..3285487 100644 (file)
@@ -4,8 +4,10 @@
  
 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
 
+#include "../../../third_party/base/nonstd_unique_ptr.h"
 #include "../../include/fpdfdoc/fpdf_doc.h"
 #include "../../include/fpdfapi/fpdf_pageobj.h"
+
 CPDF_AnnotList::CPDF_AnnotList(CPDF_Page* pPage)
 {
     ASSERT(pPage != NULL);
@@ -323,19 +325,14 @@ CPDF_PageObject* CPDF_Annot::GetBorder(FX_BOOL bPrint, const CPDF_RenderOptions*
         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;
-    }
+    nonstd::unique_ptr<CPDF_PathObject> pPathObject(new CPDF_PathObject());
     CPDF_GraphStateData *pGraphState = pPathObject->m_GraphState.GetModify();
     if (!pGraphState) {
-        pPathObject->Release();
         return NULL;
     }
     pGraphState->m_LineWidth = width;
     CPDF_ColorStateData *pColorData = pPathObject->m_ColorState.GetModify();
     if (!pColorData) {
-        pPathObject->Release();
         return NULL;
     }
     pColorData->m_StrokeRGB = argb;
@@ -349,7 +346,6 @@ CPDF_PageObject* CPDF_Annot::GetBorder(FX_BOOL bPrint, const CPDF_RenderOptions*
             }
             pGraphState->m_DashArray = FX_Alloc(FX_FLOAT, dash_count);
             if (pGraphState->m_DashArray == NULL) {
-                pPathObject->Release();
                 return NULL;
             }
             pGraphState->m_DashCount = dash_count;
@@ -363,7 +359,6 @@ CPDF_PageObject* CPDF_Annot::GetBorder(FX_BOOL bPrint, const CPDF_RenderOptions*
         } else {
             pGraphState->m_DashArray = FX_Alloc(FX_FLOAT, 2);
             if (pGraphState->m_DashArray == NULL) {
-                pPathObject->Release();
                 return NULL;
             }
             pGraphState->m_DashCount = 2;
@@ -378,7 +373,7 @@ CPDF_PageObject* CPDF_Annot::GetBorder(FX_BOOL bPrint, const CPDF_RenderOptions*
         pPathData->AppendRect(rect.left + width, rect.bottom + width, rect.right - width, rect.top - width);
     }
     pPathObject->CalcBoundingBox();
-    return pPathObject;
+    return pPathObject.release();
 }
 void CPDF_Annot::DrawBorder(CFX_RenderDevice* pDevice, const CFX_AffineMatrix* pUser2Device, const CPDF_RenderOptions* pOptions)
 {
index b987a9c..8351878 100644 (file)
 
 class CBA_FontMap;
 
-
-class CFFL_EditUndoItem
-{
-public:
-       CFFL_EditUndoItem(CPWL_Edit* pEdit);
-       virtual ~CFFL_EditUndoItem();
-       
-       virtual void                                    Undo();
-       virtual void                                    Redo();
-       virtual CFX_WideString                  GetDescr();
-       virtual void                                    Release();
-};
-
 struct FFL_TextFieldState
 {
        int nStart;
@@ -81,9 +68,8 @@ public:
        
 private:
        CBA_FontMap*                            m_pFontMap;
-//     CBA_SpellCheck*                         m_pSpellCheck;
        FFL_TextFieldState                      m_State;
-//     CFFL_IM_BOX                                     m_IMBox;
+
 };
 
 #endif // !defined(AFX_FFL_EDIT_H__8E0C9456_CBA2_4EFB_9F31_53C6D8C1A8AC__INCLUDED_)
index ff9dfa1..615be45 100644 (file)
@@ -333,32 +333,27 @@ private:
 
 #define CPDFSDK_Annots                         CFX_ArrayTemplate<CPDFSDK_Annot*>
 #define CPDFSDK_SortAnnots                     CGW_ArrayTemplate<CPDFSDK_Annot*>
-class CBA_AnnotIterator 
+class CBA_AnnotIterator
 {
 public:
        CBA_AnnotIterator(CPDFSDK_PageView* pPageView, const CFX_ByteString& sType, const CFX_ByteString& sSubType);
-       virtual ~CBA_AnnotIterator();
-       
-       virtual CPDFSDK_Annot*                          GetFirstAnnot();
-       virtual CPDFSDK_Annot*                          GetLastAnnot();
-       virtual CPDFSDK_Annot*                          GetNextAnnot(CPDFSDK_Annot* pAnnot);
-       virtual CPDFSDK_Annot*                          GetPrevAnnot(CPDFSDK_Annot* pAnnot);
-       
-       virtual void                                            Release(){delete this;}
-       
+       ~CBA_AnnotIterator();
+
+       CPDFSDK_Annot*                          GetFirstAnnot();
+       CPDFSDK_Annot*                          GetLastAnnot();
+       CPDFSDK_Annot*                          GetNextAnnot(CPDFSDK_Annot* pAnnot);
+       CPDFSDK_Annot*                          GetPrevAnnot(CPDFSDK_Annot* pAnnot);
+
 private:
        void                                                            GenerateResults();
        static int                                                      CompareByLeft(CPDFSDK_Annot* p1, CPDFSDK_Annot* p2);
        static int                                                      CompareByTop(CPDFSDK_Annot* p1, CPDFSDK_Annot* p2);
-       
        static CPDF_Rect                                        GetAnnotRect(CPDFSDK_Annot* pAnnot);
-       
-private:
+
        CPDFSDK_PageView*                                       m_pPageView;
        CFX_ByteString                                          m_sType;
        CFX_ByteString                                          m_sSubType;
        int                                                                     m_nTabs;
-       
        CPDFSDK_Annots                                          m_Annots;
 };
 
index a842fd6..bf00995 100644 (file)
@@ -164,13 +164,11 @@ public:
 class IFX_Edit_UndoItem
 {
 public:
-       virtual void                                                    Release() = 0;
+       virtual ~IFX_Edit_UndoItem() { }
+
        virtual void                                                    Undo() = 0;
        virtual void                                                    Redo() = 0;
        virtual CFX_WideString                                  GetUndoTitle() = 0;
-
-protected:
-        ~IFX_Edit_UndoItem() { }
 };
 
 class FXET_CLASS IFX_Edit
index 8aa44a4..9e5c40f 100644 (file)
@@ -325,12 +325,9 @@ class CFX_Edit_UndoItem : public IFX_Edit_UndoItem
 {
 public:
        CFX_Edit_UndoItem() : m_bFirst(TRUE), m_bLast(TRUE) {}
-       virtual ~CFX_Edit_UndoItem(){}
 
-       virtual CFX_WideString                                  GetUndoTitle() {return L"";}
-       virtual void                                                    Release(){delete this;}
+       CFX_WideString GetUndoTitle() override { return L""; }
 
-public:
        void                                                                    SetFirst(FX_BOOL bFirst){m_bFirst = bFirst;}
        FX_BOOL                                                                 IsFirst(){return m_bFirst;}
        void                                                                    SetLast(FX_BOOL bLast){m_bLast = bLast;}
@@ -345,17 +342,15 @@ class CFX_Edit_GroupUndoItem : public IFX_Edit_UndoItem
 {
 public:
        CFX_Edit_GroupUndoItem(const CFX_WideString& sTitle);
-       virtual ~CFX_Edit_GroupUndoItem();
+       ~CFX_Edit_GroupUndoItem() override;
+
+       void                                                    Undo() override;
+       void                                                    Redo() override;
+       CFX_WideString                                  GetUndoTitle() override;
 
        void                                                                    AddUndoItem(CFX_Edit_UndoItem* pUndoItem);
        void                                                                    UpdateItems();
 
-public:
-       virtual void                                                    Undo();
-       virtual void                                                    Redo();
-       virtual CFX_WideString                                  GetUndoTitle();
-       virtual void                                                    Release();
-
 private:
        CFX_WideString                                                  m_sTitle;
        CFX_ArrayTemplate<CFX_Edit_UndoItem*>   m_Items;
index dce1662..274806f 100644 (file)
@@ -4,37 +4,8 @@
  
 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
 
-//#include "../include/FormFiller.h"
-//#include "../include/FFL_FormFiller.h"
 #include "../../include/formfiller/FFL_TextField.h"
 #include "../../include/formfiller/FFL_CBA_Fontmap.h"
-//#include "../include/FFL_Notify.h"
-
-CFFL_EditUndoItem::CFFL_EditUndoItem(CPWL_Edit* pEdit)
-{
-}
-
-CFFL_EditUndoItem::~CFFL_EditUndoItem()
-{
-}
-
-void CFFL_EditUndoItem::Undo()
-{
-}
-
-void CFFL_EditUndoItem::Redo()
-{
-}
-
-CFX_WideString CFFL_EditUndoItem::GetDescr()
-{
-       return L"Input";
-}
-
-void CFFL_EditUndoItem::Release()
-{
-       delete this;
-}
 
 /* ------------------------------- CFFL_TextField ------------------------------- */
 
index 86c43f1..723a25b 100644 (file)
@@ -4,6 +4,7 @@
  
 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
 
+#include "../../third_party/base/nonstd_unique_ptr.h"
 #include "../include/fsdk_define.h"
 #include "../include/fpdfxfa/fpdfxfa_doc.h"
 #include "../include/fpdfxfa/fpdfxfa_util.h"
@@ -2459,22 +2460,13 @@ FX_BOOL CPDFSDK_InterForm::HighlightWidgets()
 
 CPDFSDK_Widget* CPDFSDK_InterForm::GetSibling(CPDFSDK_Widget* pWidget, FX_BOOL bNext) const
 {
-       ASSERT(pWidget != NULL);
-
-       CBA_AnnotIterator* pIterator = new CBA_AnnotIterator(pWidget->GetPageView(), "Widget", "");//XfA?
-       ASSERT(pIterator != NULL);
-
-       CPDFSDK_Widget* pRet = NULL;
-
-       if (bNext)
-               pRet = (CPDFSDK_Widget*)pIterator->GetNextAnnot(pWidget);
-       else
-               pRet = (CPDFSDK_Widget*)pIterator->GetPrevAnnot(pWidget);
-
-       pIterator->Release();
-       
-       return pRet;
+    nonstd::unique_ptr<CBA_AnnotIterator> pIterator(
+        new CBA_AnnotIterator(pWidget->GetPageView(), "Widget", ""));
 
+    if (bNext) {
+        return (CPDFSDK_Widget*)pIterator->GetNextAnnot(pWidget);
+    }
+    return (CPDFSDK_Widget*)pIterator->GetPrevAnnot(pWidget);
 }
 
 CPDFSDK_Widget*        CPDFSDK_InterForm::GetWidget(CPDF_FormControl* pControl) const
index 2d25ba3..c7f7ce5 100644 (file)
@@ -453,10 +453,7 @@ void CFX_Edit_Undo::RemoveHeads()
 {
        ASSERT(m_UndoItemStack.GetSize() > 1);
 
-       IFX_Edit_UndoItem* pItem = m_UndoItemStack.GetAt(0);
-       ASSERT(pItem != NULL);
-
-       pItem->Release();
+       delete m_UndoItemStack.GetAt(0);
        m_UndoItemStack.RemoveAt(0);
 }
 
@@ -464,10 +461,7 @@ void CFX_Edit_Undo::RemoveTails()
 {
        for (FX_INT32 i = m_UndoItemStack.GetSize()-1; i >= m_nCurUndoPos; i--)
        {
-               IFX_Edit_UndoItem* pItem = m_UndoItemStack.GetAt(i);
-               ASSERT(pItem != NULL);
-
-               pItem->Release();
+               delete m_UndoItemStack.GetAt(i);
                m_UndoItemStack.RemoveAt(i);
        }
 }
@@ -476,10 +470,7 @@ void CFX_Edit_Undo::Reset()
 {
        for (FX_INT32 i=0, sz=m_UndoItemStack.GetSize(); i < sz; i++)
        {
-               IFX_Edit_UndoItem * pItem = m_UndoItemStack.GetAt(i);
-               ASSERT(pItem != NULL);
-
-               pItem->Release();
+               delete m_UndoItemStack.GetAt(i);
        }
        m_nCurUndoPos = 0;
        m_UndoItemStack.RemoveAll();
@@ -495,10 +486,7 @@ CFX_Edit_GroupUndoItem::~CFX_Edit_GroupUndoItem()
 {
        for (int i=0,sz=m_Items.GetSize(); i<sz; i++)
        {
-               CFX_Edit_UndoItem* pUndoItem = m_Items[i];
-               ASSERT(pUndoItem != NULL);
-
-               pUndoItem->Release();
+               delete m_Items[i];
        }
 
        m_Items.RemoveAll();
@@ -558,11 +546,6 @@ CFX_WideString CFX_Edit_GroupUndoItem::GetUndoTitle()
        return m_sTitle;
 }
 
-void CFX_Edit_GroupUndoItem::Release()
-{
-       delete this;
-}
-
 /* ------------------------------------- CFX_Edit_UndoItem derived classes ------------------------------------- */
 
 CFXEU_InsertWord::CFXEU_InsertWord(CFX_Edit * pEdit, const CPVT_WordPlace & wpOldPlace, const CPVT_WordPlace & wpNewPlace,