From 77221d4b4288ada80e34464ef4a402ea232b402b Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Tue, 8 Dec 2015 11:20:08 -0800 Subject: FWL refcounts never incremented (part 1) BUG=pdfium:282 R=thestig@chromium.org Review URL: https://codereview.chromium.org/1509203002 . --- xfa/include/fwl/basewidget/fwl_barcode.h | 5 +---- xfa/include/fwl/basewidget/fwl_caret.h | 5 +---- xfa/include/fwl/basewidget/fwl_checkbox.h | 9 ++------- xfa/include/fwl/basewidget/fwl_combobox.h | 5 +---- xfa/include/fwl/basewidget/fwl_datetimepicker.h | 5 +---- xfa/include/fwl/basewidget/fwl_edit.h | 6 ++---- xfa/include/fwl/basewidget/fwl_listbox.h | 6 ++---- xfa/include/fwl/basewidget/fwl_picturebox.h | 6 +----- xfa/include/fwl/basewidget/fwl_pushbutton.h | 5 +---- xfa/include/fwl/basewidget/fwl_scrollbar.h | 5 +---- xfa/include/fwl/basewidget/fwl_spinbutton.h | 7 ++----- xfa/include/fwl/basewidget/fwl_tooltipctrl.h | 5 +---- xfa/include/fwl/core/fwl_form.h | 5 +---- xfa/include/fwl/core/fwl_note.h | 7 +++++-- xfa/include/fwl/core/fwl_target.h | 9 ++------- xfa/include/fwl/lightwidget/widget.h | 6 ++---- 16 files changed, 26 insertions(+), 70 deletions(-) (limited to 'xfa/include') diff --git a/xfa/include/fwl/basewidget/fwl_barcode.h b/xfa/include/fwl/basewidget/fwl_barcode.h index ac54ab8d39..28b40baad1 100644 --- a/xfa/include/fwl/basewidget/fwl_barcode.h +++ b/xfa/include/fwl/basewidget/fwl_barcode.h @@ -49,13 +49,10 @@ class IFWL_BarcodeDP : public IFWL_EditDP { }; class IFWL_Barcode : public IFWL_Edit { public: - static IFWL_Barcode* Create(); + IFWL_Barcode(); FWL_ERR Initialize(const CFWL_WidgetImpProperties& properties, IFWL_Widget* pOuter); void SetType(BC_TYPE type); FX_BOOL IsProtectedType(); - - protected: - IFWL_Barcode(); }; #endif diff --git a/xfa/include/fwl/basewidget/fwl_caret.h b/xfa/include/fwl/basewidget/fwl_caret.h index 547f1c9ba8..d2e8a807ce 100644 --- a/xfa/include/fwl/basewidget/fwl_caret.h +++ b/xfa/include/fwl/basewidget/fwl_caret.h @@ -16,7 +16,7 @@ class IFWL_Caret; #define FWL_PARTSTATE_CAT_HightLight 1 class IFWL_Caret : public IFWL_Widget { public: - static IFWL_Caret* Create(); + IFWL_Caret(); FWL_ERR Initialize(IFWL_Widget* pOuter = NULL); FWL_ERR Initialize(const CFWL_WidgetImpProperties& properties, @@ -26,8 +26,5 @@ class IFWL_Caret : public IFWL_Widget { FWL_ERR GetFrequency(FX_DWORD& elapse); FWL_ERR SetFrequency(FX_DWORD elapse); FWL_ERR SetColor(CFX_Color crFill); - - protected: - IFWL_Caret(); }; #endif diff --git a/xfa/include/fwl/basewidget/fwl_checkbox.h b/xfa/include/fwl/basewidget/fwl_checkbox.h index 989430acc1..3e08a63972 100644 --- a/xfa/include/fwl/basewidget/fwl_checkbox.h +++ b/xfa/include/fwl/basewidget/fwl_checkbox.h @@ -70,24 +70,19 @@ class IFWL_CheckBoxDP : public IFWL_DataProvider { }; class IFWL_CheckBox : public IFWL_Widget { public: - static IFWL_CheckBox* Create(); + IFWL_CheckBox(); FWL_ERR Initialize(const CFWL_WidgetImpProperties& properties, IFWL_Widget* pOuter); int32_t GetCheckState(); FWL_ERR SetCheckState(int32_t iCheck); - protected: - IFWL_CheckBox(); }; class IFWL_RadioButton : public IFWL_Widget { public: - static IFWL_RadioButton* Create(); + IFWL_RadioButton(); FWL_ERR Initialize(const CFWL_WidgetImpProperties& properties, IFWL_Widget* pOuter); int32_t GetCheckState(); FWL_ERR SetCheckState(int32_t iCheck); - - protected: - IFWL_RadioButton(); }; #endif diff --git a/xfa/include/fwl/basewidget/fwl_combobox.h b/xfa/include/fwl/basewidget/fwl_combobox.h index c3311e5200..184d0107a4 100644 --- a/xfa/include/fwl/basewidget/fwl_combobox.h +++ b/xfa/include/fwl/basewidget/fwl_combobox.h @@ -97,7 +97,7 @@ class IFWL_ComboBoxDP : public IFWL_ListBoxDP { }; class IFWL_ComboBox : public IFWL_Widget { public: - static IFWL_ComboBox* Create(); + IFWL_ComboBox(); FWL_ERR Initialize(const CFWL_WidgetImpProperties& properties, IFWL_Widget* pOuter); int32_t GetCurSel(); @@ -133,8 +133,5 @@ class IFWL_ComboBox : public IFWL_Widget { FWL_ERR GetBBox(CFX_RectF& rect); FWL_ERR EditModifyStylesEx(FX_DWORD dwStylesExAdded, FX_DWORD dwStylesExRemoved); - - protected: - IFWL_ComboBox(); }; #endif diff --git a/xfa/include/fwl/basewidget/fwl_datetimepicker.h b/xfa/include/fwl/basewidget/fwl_datetimepicker.h index f311185d1d..1f3750aaca 100644 --- a/xfa/include/fwl/basewidget/fwl_datetimepicker.h +++ b/xfa/include/fwl/basewidget/fwl_datetimepicker.h @@ -70,7 +70,7 @@ class IFWL_DateTimePickerDP : public IFWL_DataProvider { }; class IFWL_DateTimePicker : public IFWL_Widget { public: - static IFWL_DateTimePicker* Create(); + IFWL_DateTimePicker(); FWL_ERR Initialize(const CFWL_WidgetImpProperties& properties, IFWL_Widget* pOuter); FWL_ERR GetCurSel(int32_t& iYear, int32_t& iMonth, int32_t& iDay); @@ -98,8 +98,5 @@ class IFWL_DateTimePicker : public IFWL_Widget { FWL_ERR SetEditLimit(int32_t nLimit); FWL_ERR ModifyEditStylesEx(FX_DWORD dwStylesExAdded, FX_DWORD dwStylesExRemoved); - - protected: - IFWL_DateTimePicker(); }; #endif diff --git a/xfa/include/fwl/basewidget/fwl_edit.h b/xfa/include/fwl/basewidget/fwl_edit.h index c804af7ae1..207e6ef614 100644 --- a/xfa/include/fwl/basewidget/fwl_edit.h +++ b/xfa/include/fwl/basewidget/fwl_edit.h @@ -112,7 +112,8 @@ class IFWL_EditDP : public IFWL_DataProvider {}; typedef struct _FWL_HEDTFIND { void* pData; } * FWL_HEDTFIND; class IFWL_Edit : public IFWL_Widget { public: - static IFWL_Edit* Create(); + IFWL_Edit(); + FWL_ERR Initialize(const CFWL_WidgetImpProperties& properties, IFWL_Widget* pOuter); FWL_ERR SetText(const CFX_WideString& wsText); @@ -158,8 +159,5 @@ class IFWL_Edit : public IFWL_Widget { FX_BOOL GetSuggestWords(CFX_PointF pointf, CFX_ByteStringArray& sSuggest); FX_BOOL ReplaceSpellCheckWord(CFX_PointF pointf, const CFX_ByteStringC& bsReplace); - - protected: - IFWL_Edit(); }; #endif diff --git a/xfa/include/fwl/basewidget/fwl_listbox.h b/xfa/include/fwl/basewidget/fwl_listbox.h index 569e00ea0c..cc2fe91feb 100644 --- a/xfa/include/fwl/basewidget/fwl_listbox.h +++ b/xfa/include/fwl/basewidget/fwl_listbox.h @@ -109,7 +109,8 @@ class IFWL_ListBoxCompare { }; class IFWL_ListBox : public IFWL_Widget { public: - static IFWL_ListBox* Create(); + IFWL_ListBox(); + FWL_ERR Initialize(const CFWL_WidgetImpProperties& properties, IFWL_Widget* pOuter); int32_t CountSelItems(); @@ -119,8 +120,5 @@ class IFWL_ListBox : public IFWL_Widget { FWL_ERR GetItemText(FWL_HLISTITEM hItem, CFX_WideString& wsText); FWL_ERR GetScrollPos(FX_FLOAT& fPos, FX_BOOL bVert = TRUE); FWL_ERR* Sort(IFWL_ListBoxCompare* pCom); - - protected: - IFWL_ListBox(); }; #endif diff --git a/xfa/include/fwl/basewidget/fwl_picturebox.h b/xfa/include/fwl/basewidget/fwl_picturebox.h index 7ca8f526d7..b55d4c30d9 100644 --- a/xfa/include/fwl/basewidget/fwl_picturebox.h +++ b/xfa/include/fwl/basewidget/fwl_picturebox.h @@ -42,12 +42,8 @@ class IFWL_PictureBoxDP : public IFWL_DataProvider { }; class IFWL_PictureBox : public IFWL_Widget { public: - static IFWL_PictureBox* Create(); - + IFWL_PictureBox(); FWL_ERR Initialize(const CFWL_WidgetImpProperties& properties, IFWL_Widget* pOuter); - - protected: - IFWL_PictureBox(); }; #endif diff --git a/xfa/include/fwl/basewidget/fwl_pushbutton.h b/xfa/include/fwl/basewidget/fwl_pushbutton.h index 55a650e23e..e0239190ad 100644 --- a/xfa/include/fwl/basewidget/fwl_pushbutton.h +++ b/xfa/include/fwl/basewidget/fwl_pushbutton.h @@ -45,11 +45,8 @@ class IFWL_PushButtonDP : public IFWL_DataProvider { }; class IFWL_PushButton : public IFWL_Widget { public: - static IFWL_PushButton* Create(); + IFWL_PushButton(); FWL_ERR Initialize(const CFWL_WidgetImpProperties& properties, IFWL_Widget* pOuter); - - protected: - IFWL_PushButton(); }; #endif diff --git a/xfa/include/fwl/basewidget/fwl_scrollbar.h b/xfa/include/fwl/basewidget/fwl_scrollbar.h index 1dd7dd2d5c..10ce5f2688 100644 --- a/xfa/include/fwl/basewidget/fwl_scrollbar.h +++ b/xfa/include/fwl/basewidget/fwl_scrollbar.h @@ -47,7 +47,7 @@ enum FWL_SCBCODE { class IFWL_ScrollBarDP : public IFWL_DataProvider {}; class IFWL_ScrollBar : public IFWL_Widget { public: - static IFWL_ScrollBar* Create(); + IFWL_ScrollBar(); FWL_ERR Initialize(const CFWL_WidgetImpProperties& properties, IFWL_Widget* pOuter); FX_BOOL IsVertical(); @@ -62,8 +62,5 @@ class IFWL_ScrollBar : public IFWL_Widget { FX_FLOAT GetTrackPos(); FWL_ERR SetTrackPos(FX_FLOAT fTrackPos); FX_BOOL DoScroll(FX_DWORD dwCode, FX_FLOAT fPos = 0.0f); - - protected: - IFWL_ScrollBar(); }; #endif diff --git a/xfa/include/fwl/basewidget/fwl_spinbutton.h b/xfa/include/fwl/basewidget/fwl_spinbutton.h index 521cfca277..79e3f68b5b 100644 --- a/xfa/include/fwl/basewidget/fwl_spinbutton.h +++ b/xfa/include/fwl/basewidget/fwl_spinbutton.h @@ -27,16 +27,13 @@ class IFWL_SpinButton; BEGIN_FWL_EVENT_DEF(CFWL_EvtSpbClick, FWL_EVTHASH_SPB_Click) FX_BOOL m_bUp; END_FWL_EVENT_DEF + class IFWL_SpinButton : public IFWL_Widget { public: - static IFWL_SpinButton* Create(); - + IFWL_SpinButton(); FWL_ERR Initialize(const CFWL_WidgetImpProperties& properties, IFWL_Widget* pOuter); FWL_ERR EnableButton(FX_BOOL bEnable, FX_BOOL bUp = TRUE); FX_BOOL IsButtonEnable(FX_BOOL bUp = TRUE); - - protected: - IFWL_SpinButton(); }; #endif diff --git a/xfa/include/fwl/basewidget/fwl_tooltipctrl.h b/xfa/include/fwl/basewidget/fwl_tooltipctrl.h index 2dce69383f..ac467556d8 100644 --- a/xfa/include/fwl/basewidget/fwl_tooltipctrl.h +++ b/xfa/include/fwl/basewidget/fwl_tooltipctrl.h @@ -31,14 +31,11 @@ class IFWL_ToolTipDP : public IFWL_DataProvider { }; class IFWL_ToolTip : public IFWL_Form { public: - static IFWL_ToolTip* Create(); + IFWL_ToolTip(); FWL_ERR Initialize(const CFWL_WidgetImpProperties& properties, IFWL_Widget* pOuter); FWL_ERR SetAnchor(const CFX_RectF& rtAnchor); FWL_ERR Show(); FWL_ERR Hide(); - - protected: - IFWL_ToolTip(); }; #endif diff --git a/xfa/include/fwl/core/fwl_form.h b/xfa/include/fwl/core/fwl_form.h index 6d76c614d0..439d1cb554 100644 --- a/xfa/include/fwl/core/fwl_form.h +++ b/xfa/include/fwl/core/fwl_form.h @@ -65,7 +65,7 @@ enum FWL_COMMANDID { }; class IFWL_Form : public IFWL_Panel { public: - static IFWL_Form* Create(); + IFWL_Form(); FWL_ERR Initialize(CFWL_WidgetImpProperties& properties, CFX_WideString* classname, IFWL_Widget* pOuter); @@ -75,8 +75,5 @@ class IFWL_Form : public IFWL_Panel { IFWL_Widget* DoModal(FX_DWORD& dwCommandID); FWL_ERR EndDoModal(); FWL_ERR SetBorderRegion(CFX_Path* pPath); - - protected: - IFWL_Form(); }; #endif diff --git a/xfa/include/fwl/core/fwl_note.h b/xfa/include/fwl/core/fwl_note.h index 66366e92e4..e6579bff10 100644 --- a/xfa/include/fwl/core/fwl_note.h +++ b/xfa/include/fwl/core/fwl_note.h @@ -120,6 +120,9 @@ class IFWL_NoteLoop; #define FWL_KEYFLAG_LButton (1 << 4) #define FWL_KEYFLAG_RButton (1 << 5) #define FWL_KEYFLAG_MButton (1 << 6) + +// Separate hierarchy not related to IFWL_* hierarchy. These should not +// get cast to IFWL_* types. class CFWL_Note { public: virtual FX_DWORD Release() { @@ -130,9 +133,9 @@ class CFWL_Note { } return dwRefCount; } - virtual IFWL_Target* Retain() { + virtual CFWL_Note* Retain() { m_dwRefCount++; - return (IFWL_Target*)this; + return this; } virtual FWL_ERR GetClassName(CFX_WideString& wsClass) const { wsClass = L"CFWL_Note"; diff --git a/xfa/include/fwl/core/fwl_target.h b/xfa/include/fwl/core/fwl_target.h index bf5cf83f3a..dc10ca5399 100644 --- a/xfa/include/fwl/core/fwl_target.h +++ b/xfa/include/fwl/core/fwl_target.h @@ -16,7 +16,7 @@ // (nonesuch) IFWL_Target ----------> CFWL_TargetImp // | | // A A -// m_pIface | | +// m_pIface | | // CFWL_Widget ----------> IFWL_Widget CFWL_WidgetImp // | | | // A A A @@ -29,10 +29,8 @@ class CFWL_TargetImp; class IFWL_Target { public: IFWL_Target() : m_pImpl(nullptr) {} + virtual ~IFWL_Target(); - FX_DWORD Release(); - IFWL_Target* Retain(); - FX_DWORD GetRefCount() const; FWL_ERR GetClassName(CFX_WideString& wsClass) const; FX_DWORD GetClassID() const; FX_BOOL IsInstance(const CFX_WideStringC& wsClass) const; @@ -42,9 +40,6 @@ class IFWL_Target { CFWL_TargetImp* GetImpl() const { return m_pImpl; } void SetImpl(CFWL_TargetImp* pImpl) { m_pImpl = pImpl; } - protected: - virtual ~IFWL_Target(); - private: CFWL_TargetImp* m_pImpl; }; diff --git a/xfa/include/fwl/lightwidget/widget.h b/xfa/include/fwl/lightwidget/widget.h index 97096a783c..e884db38ad 100644 --- a/xfa/include/fwl/lightwidget/widget.h +++ b/xfa/include/fwl/lightwidget/widget.h @@ -41,10 +41,8 @@ class CFWL_WidgetProperties { class CFWL_Widget { public: + virtual ~CFWL_Widget(); IFWL_Widget* GetWidget(); - FX_DWORD Release(); - CFWL_Widget* Retain(); - FX_DWORD GetRefCount() const; FWL_ERR GetClassName(CFX_WideString& wsClass) const; FX_DWORD GetClassID() const; virtual FX_BOOL IsInstance(const CFX_WideStringC& wsClass) const; @@ -85,7 +83,7 @@ class CFWL_Widget { FWL_ERR SetFocus(FX_BOOL bFocus); FWL_ERR SetGrab(FX_BOOL bSet); CFWL_Widget(); - virtual ~CFWL_Widget(); + void RegisterEventTarget(CFWL_Widget* pEventSource = NULL, FX_DWORD dwFilter = FWL_EVENT_ALL_MASK); void DispatchEvent(CFWL_Event* pEvent); -- cgit v1.2.3