diff options
author | dsinclair <dsinclair@chromium.org> | 2016-09-07 05:46:55 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-09-07 05:46:55 -0700 |
commit | ce04a458828b45035dab46c13e14a1f0ae67a2b7 (patch) | |
tree | 089f5eb29d12518d8de99d9c30dba8da3d441e1f /fpdfsdk/cpdfsdk_widget.cpp | |
parent | 0a765b832c5b9dd0a46fb5a25ce09d52dedb336b (diff) | |
download | pdfium-ce04a458828b45035dab46c13e14a1f0ae67a2b7.tar.xz |
Add observer for BAAnnots from Javascript
This Cl moves the observer code from the CPDFSDK_Widget up into the
CPDFSDK_Annot base class and then adds a second observer for CPDFSDK_BAAnnot
objects.
This allows us to attach an observer to the Annot javascript class which will
update its internal pointer to the BAAnnot if the BAAnnot is destroyed by
the CPDFSDK_PageView being destroyed.
BUG=chromium:642307
Review-Url: https://codereview.chromium.org/2306663002
Diffstat (limited to 'fpdfsdk/cpdfsdk_widget.cpp')
-rw-r--r-- | fpdfsdk/cpdfsdk_widget.cpp | 32 |
1 files changed, 1 insertions, 31 deletions
diff --git a/fpdfsdk/cpdfsdk_widget.cpp b/fpdfsdk/cpdfsdk_widget.cpp index 73ba23d076..2ddbccc28c 100644 --- a/fpdfsdk/cpdfsdk_widget.cpp +++ b/fpdfsdk/cpdfsdk_widget.cpp @@ -26,7 +26,6 @@ #include "fpdfsdk/include/fsdk_mgr.h" #include "fpdfsdk/pdfwindow/PWL_Edit.h" #include "fpdfsdk/pdfwindow/PWL_Utils.h" -#include "third_party/base/stl_util.h" #ifdef PDF_ENABLE_XFA #include "fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h" @@ -37,22 +36,6 @@ #include "xfa/fxfa/include/xfa_ffwidgethandler.h" #endif // PDF_ENABLE_XFA -CPDFSDK_Widget::Observer::Observer(CPDFSDK_Widget** pWatchedPtr) - : m_pWatchedPtr(pWatchedPtr) { - (*m_pWatchedPtr)->AddObserver(this); -} - -CPDFSDK_Widget::Observer::~Observer() { - if (m_pWatchedPtr) - (*m_pWatchedPtr)->RemoveObserver(this); -} - -void CPDFSDK_Widget::Observer::OnWidgetDestroyed() { - ASSERT(m_pWatchedPtr); - *m_pWatchedPtr = nullptr; - m_pWatchedPtr = nullptr; -} - CPDFSDK_Widget::CPDFSDK_Widget(CPDF_Annot* pAnnot, CPDFSDK_PageView* pPageView, CPDFSDK_InterForm* pInterForm) @@ -68,20 +51,7 @@ CPDFSDK_Widget::CPDFSDK_Widget(CPDF_Annot* pAnnot, { } -CPDFSDK_Widget::~CPDFSDK_Widget() { - for (auto* pObserver : m_Observers) - pObserver->OnWidgetDestroyed(); -} - -void CPDFSDK_Widget::AddObserver(Observer* pObserver) { - ASSERT(!pdfium::ContainsKey(m_Observers, pObserver)); - m_Observers.insert(pObserver); -} - -void CPDFSDK_Widget::RemoveObserver(Observer* pObserver) { - ASSERT(pdfium::ContainsKey(m_Observers, pObserver)); - m_Observers.erase(pObserver); -} +CPDFSDK_Widget::~CPDFSDK_Widget() {} #ifdef PDF_ENABLE_XFA CXFA_FFWidget* CPDFSDK_Widget::GetMixXFAWidget() const { |