diff options
author | Dan Sinclair <dsinclair@chromium.org> | 2016-09-13 14:52:55 -0400 |
---|---|---|
committer | Dan Sinclair <dsinclair@chromium.org> | 2016-09-13 14:52:55 -0400 |
commit | 0703fa810bc79a335ddfdab3e7661159caf88e2d (patch) | |
tree | b5793cf84419aa426acf3b28cac6af9ef9fe55f8 /fpdfsdk/cpdfsdk_widget.cpp | |
parent | ccf7734cad06cb9383d55190d6cd6aa6ccc91ab2 (diff) | |
download | pdfium-0703fa810bc79a335ddfdab3e7661159caf88e2d.tar.xz |
[Merge to 54] Add observer for BAAnnots from Javascriptchromium/2840
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
R=tsepez@chromium.org
Review URL: https://codereview.chromium.org/2333383002 .
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 dcccf0ce1a..4cd93913a2 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 { |