Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Unified Diff: fpdfsdk/include/fsdk_baseform.h

Issue 2197793002: Watch for destruction of widget during callback (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: fpdfsdk/include/fsdk_baseform.h
diff --git a/fpdfsdk/include/fsdk_baseform.h b/fpdfsdk/include/fsdk_baseform.h
index f6df689984f02fdf1bcadb5cfaf880978d5911b5..de0ddfe50b2f22990dc7d6b98ccccfa9c98d9fdb 100644
--- a/fpdfsdk/include/fsdk_baseform.h
+++ b/fpdfsdk/include/fsdk_baseform.h
@@ -8,6 +8,7 @@
#define FPDFSDK_INCLUDE_FSDK_BASEFORM_H_
#include <map>
+#include <set>
#include <vector>
#include "core/fpdfdoc/include/fpdf_doc.h"
@@ -60,6 +61,16 @@ struct PDFSDK_FieldAction {
class CPDFSDK_Widget : public CPDFSDK_BAAnnot {
public:
+ class Observer {
+ public:
+ Observer(CPDFSDK_Widget** pWatchedPtr);
Lei Zhang 2016/07/29 22:30:06 explicit
Tom Sepez 2016/08/01 16:24:54 Done.
+ ~Observer();
+ void OnWidgetDestroyed();
Lei Zhang 2016/07/29 22:30:06 new line before
Tom Sepez 2016/08/01 16:24:54 Done.
+
+ private:
+ CPDFSDK_Widget** m_pWatchedPtr;
+ };
+
#ifdef PDF_ENABLE_XFA
CXFA_FFWidget* GetMixXFAWidget() const;
CXFA_FFWidget* GetGroupMixXFAWidget();
@@ -89,6 +100,9 @@ class CPDFSDK_Widget : public CPDFSDK_BAAnnot {
CPDFSDK_InterForm* pInterForm);
~CPDFSDK_Widget() override;
+ void AddObserver(Observer* observer);
+ void RemoveObserver(Observer* observer);
+
// CPDFSDK_Annot
CFX_ByteString GetSubType() const override;
CPDF_Action GetAAction(CPDF_AAction::AActionType eAAT) override;
@@ -170,6 +184,14 @@ class CPDFSDK_Widget : public CPDFSDK_BAAnnot {
int32_t GetAppearanceAge() const;
int32_t GetValueAge() const;
+ FX_BOOL IsWidgetAppearanceValid(CPDF_Annot::AppearanceMode mode);
+ void DrawAppearance(CFX_RenderDevice* pDevice,
+ const CFX_Matrix* pUser2Device,
+ CPDF_Annot::AppearanceMode mode,
+ const CPDF_RenderOptions* pOptions) override;
+
+ FX_BOOL HitTest(FX_FLOAT pageX, FX_FLOAT pageY);
+
private:
void ResetAppearance_PushButton();
void ResetAppearance_CheckBox();
@@ -192,20 +214,11 @@ class CPDFSDK_Widget : public CPDFSDK_BAAnnot {
void AddImageToAppearance(const CFX_ByteString& sAPType, CPDF_Stream* pImage);
void RemoveAppearance(const CFX_ByteString& sAPType);
- public:
- FX_BOOL IsWidgetAppearanceValid(CPDF_Annot::AppearanceMode mode);
- void DrawAppearance(CFX_RenderDevice* pDevice,
- const CFX_Matrix* pUser2Device,
- CPDF_Annot::AppearanceMode mode,
- const CPDF_RenderOptions* pOptions) override;
-
- FX_BOOL HitTest(FX_FLOAT pageX, FX_FLOAT pageY);
-
- private:
CPDFSDK_InterForm* const m_pInterForm;
FX_BOOL m_bAppModified;
int32_t m_nAppAge;
int32_t m_nValueAge;
+ std::set<Observer*> m_Observers;
#ifdef PDF_ENABLE_XFA
mutable CXFA_FFWidget* m_hMixXFAWidget;

Powered by Google App Engine
This is Rietveld 408576698