Remove release method from CBA_AnnotItetator.
authorTom Sepez <tsepez@chromium.org>
Mon, 20 Apr 2015 20:38:38 +0000 (13:38 -0700)
committerTom Sepez <tsepez@chromium.org>
Mon, 20 Apr 2015 20:38:38 +0000 (13:38 -0700)
Also remove virtual methods, since this is neither subclassed nor a
subclass.

BUG=https://code.google.com/p/pdfium/issues/detail?id=140
R=thestig@chromium.org

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

fpdfsdk/include/fsdk_baseform.h
fpdfsdk/src/fsdk_baseform.cpp

index b15fba6..16a23bf 100644 (file)
@@ -261,32 +261,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 6c8069b..0c0492d 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/fsdk_mgr.h"
 #include "../include/fsdk_baseannot.h"
@@ -1727,22 +1728,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", "");
-       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