diff options
author | tsepez <tsepez@chromium.org> | 2016-05-16 13:21:03 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-05-16 13:21:03 -0700 |
commit | cc4d6d85b58a7a1d9d7b798c63d3343f3dac06a9 (patch) | |
tree | fda580a573f97d15c9484c57ebf8fae66342ab83 /xfa/fxfa | |
parent | e699c66433049396e438d983a1837b9d4a4cf766 (diff) | |
download | pdfium-cc4d6d85b58a7a1d9d7b798c63d3343f3dac06a9.tar.xz |
Remove { delete this; } anti-pattern from IXFA_WidgetIterator
Review-Url: https://codereview.chromium.org/1976123003
Diffstat (limited to 'xfa/fxfa')
-rw-r--r-- | xfa/fxfa/app/xfa_ffpageview.cpp | 6 | ||||
-rw-r--r-- | xfa/fxfa/app/xfa_rendercontext.cpp | 6 | ||||
-rw-r--r-- | xfa/fxfa/include/fxfa.h | 6 | ||||
-rw-r--r-- | xfa/fxfa/include/xfa_ffdocview.h | 22 | ||||
-rw-r--r-- | xfa/fxfa/include/xfa_ffpageview.h | 9 |
5 files changed, 21 insertions, 28 deletions
diff --git a/xfa/fxfa/app/xfa_ffpageview.cpp b/xfa/fxfa/app/xfa_ffpageview.cpp index f1898c83f1..e5a05734dc 100644 --- a/xfa/fxfa/app/xfa_ffpageview.cpp +++ b/xfa/fxfa/app/xfa_ffpageview.cpp @@ -197,6 +197,7 @@ CXFA_FFWidget* CXFA_FFPageWidgetIterator::GetWidget( } return NULL; } + CXFA_FFTabOrderPageWidgetIterator::CXFA_FFTabOrderPageWidgetIterator( CXFA_FFPageView* pPageView, uint32_t dwFilter) @@ -206,10 +207,9 @@ CXFA_FFTabOrderPageWidgetIterator::CXFA_FFTabOrderPageWidgetIterator( ->GetCurVersionMode() < XFA_VERSION_205; Reset(); } + CXFA_FFTabOrderPageWidgetIterator::~CXFA_FFTabOrderPageWidgetIterator() {} -void CXFA_FFTabOrderPageWidgetIterator::Release() { - delete this; -} + void CXFA_FFTabOrderPageWidgetIterator::Reset() { CreateTabOrderWidgetArray(); m_iCurWidget = -1; diff --git a/xfa/fxfa/app/xfa_rendercontext.cpp b/xfa/fxfa/app/xfa_rendercontext.cpp index cc2ea4b9ac..e7bacec281 100644 --- a/xfa/fxfa/app/xfa_rendercontext.cpp +++ b/xfa/fxfa/app/xfa_rendercontext.cpp @@ -68,8 +68,6 @@ int32_t CXFA_RenderContext::DoRender(IFX_Pause* pPause) { return XFA_RENDERSTATUS_Done; } void CXFA_RenderContext::StopRender() { - if (m_pWidgetIterator) { - m_pWidgetIterator->Release(); - m_pWidgetIterator = NULL; - } + delete m_pWidgetIterator; + m_pWidgetIterator = nullptr; } diff --git a/xfa/fxfa/include/fxfa.h b/xfa/fxfa/include/fxfa.h index 871ab71164..a173a0e299 100644 --- a/xfa/fxfa/include/fxfa.h +++ b/xfa/fxfa/include/fxfa.h @@ -541,7 +541,8 @@ class CXFA_RenderOptions { class IXFA_WidgetIterator { public: - virtual void Release() = 0; + virtual ~IXFA_WidgetIterator() {} + virtual void Reset() = 0; virtual CXFA_FFWidget* MoveToFirst() = 0; virtual CXFA_FFWidget* MoveToLast() = 0; @@ -549,9 +550,6 @@ class IXFA_WidgetIterator { virtual CXFA_FFWidget* MoveToPrevious() = 0; virtual CXFA_FFWidget* GetCurrentWidget() = 0; virtual FX_BOOL SetCurrentWidget(CXFA_FFWidget* hWidget) = 0; - - protected: - virtual ~IXFA_WidgetIterator() {} }; #endif // XFA_FXFA_INCLUDE_FXFA_H_ diff --git a/xfa/fxfa/include/xfa_ffdocview.h b/xfa/fxfa/include/xfa_ffdocview.h index 7f1c631da3..473b820def 100644 --- a/xfa/fxfa/include/xfa_ffdocview.h +++ b/xfa/fxfa/include/xfa_ffdocview.h @@ -125,20 +125,20 @@ class CXFA_FFDocView { int32_t m_iLock; friend class CXFA_FFNotify; }; + class CXFA_FFDocWidgetIterator : public IXFA_WidgetIterator { public: CXFA_FFDocWidgetIterator(CXFA_FFDocView* pDocView, CXFA_Node* pTravelRoot); - virtual ~CXFA_FFDocWidgetIterator(); - - virtual void Release() { delete this; } - - virtual void Reset(); - virtual CXFA_FFWidget* MoveToFirst(); - virtual CXFA_FFWidget* MoveToLast(); - virtual CXFA_FFWidget* MoveToNext(); - virtual CXFA_FFWidget* MoveToPrevious(); - virtual CXFA_FFWidget* GetCurrentWidget(); - virtual FX_BOOL SetCurrentWidget(CXFA_FFWidget* hWidget); + ~CXFA_FFDocWidgetIterator() override; + + // IXFA_WidgetIterator: + void Reset() override; + CXFA_FFWidget* MoveToFirst() override; + CXFA_FFWidget* MoveToLast() override; + CXFA_FFWidget* MoveToNext() override; + CXFA_FFWidget* MoveToPrevious() override; + CXFA_FFWidget* GetCurrentWidget() override; + FX_BOOL SetCurrentWidget(CXFA_FFWidget* hWidget) override; protected: CXFA_ContainerIterator m_ContentIterator; diff --git a/xfa/fxfa/include/xfa_ffpageview.h b/xfa/fxfa/include/xfa_ffpageview.h index 75e418b25b..79b0afb602 100644 --- a/xfa/fxfa/include/xfa_ffpageview.h +++ b/xfa/fxfa/include/xfa_ffpageview.h @@ -36,12 +36,11 @@ class CXFA_FFPageView : public CXFA_ContainerLayoutItem { typedef CXFA_NodeIteratorTemplate<CXFA_LayoutItem, CXFA_TraverseStrategy_LayoutItem> CXFA_LayoutItemIterator; + class CXFA_FFPageWidgetIterator : public IXFA_WidgetIterator { public: CXFA_FFPageWidgetIterator(CXFA_FFPageView* pPageView, uint32_t dwFilter); - virtual ~CXFA_FFPageWidgetIterator(); - - void Release() override { delete this; } + ~CXFA_FFPageWidgetIterator() override; void Reset() override; CXFA_FFWidget* MoveToFirst() override; @@ -73,9 +72,7 @@ class CXFA_FFTabOrderPageWidgetIterator : public IXFA_WidgetIterator { public: CXFA_FFTabOrderPageWidgetIterator(CXFA_FFPageView* pPageView, uint32_t dwFilter); - virtual ~CXFA_FFTabOrderPageWidgetIterator(); - - void Release() override; + ~CXFA_FFTabOrderPageWidgetIterator() override; void Reset() override; CXFA_FFWidget* MoveToFirst() override; |