From 5d8e5aa882fe8d37d32b71137f039165581ddb82 Mon Sep 17 00:00:00 2001 From: weili Date: Mon, 8 Aug 2016 17:30:37 -0700 Subject: Use virtual function to retrieve interface pointer Use virtual function to return the actual interface type instead of the base interface type to avoid a lot of casts. Also tidy up CFWL_Widget by encapsulating variables, and use smart pointers for class owned member variables. Review-Url: https://codereview.chromium.org/2209153002 --- xfa/fwl/lightwidget/cfwl_widget.h | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'xfa/fwl/lightwidget/cfwl_widget.h') diff --git a/xfa/fwl/lightwidget/cfwl_widget.h b/xfa/fwl/lightwidget/cfwl_widget.h index 2c180bad8f..80e278e161 100644 --- a/xfa/fwl/lightwidget/cfwl_widget.h +++ b/xfa/fwl/lightwidget/cfwl_widget.h @@ -7,6 +7,8 @@ #ifndef XFA_FWL_LIGHTWIDGET_CFWL_WIDGET_H_ #define XFA_FWL_LIGHTWIDGET_CFWL_WIDGET_H_ +#include + #include "xfa/fwl/core/cfwl_event.h" #include "xfa/fwl/lightwidget/cfwl_widgetproperties.h" #include "xfa/fwl/core/ifwl_widget.h" @@ -21,7 +23,9 @@ class CFWL_Widget { public: virtual ~CFWL_Widget(); - IFWL_Widget* GetWidget(); + virtual IFWL_Widget* GetWidget(); + virtual const IFWL_Widget* GetWidget() const; + FWL_Error GetClassName(CFX_WideString& wsClass) const; FWL_Type GetClassID() const; virtual FX_BOOL IsInstance(const CFX_WideStringC& wsClass) const; @@ -70,13 +74,14 @@ class CFWL_Widget { CFX_SizeF CalcTextSize(const CFX_WideString& wsText, FX_BOOL bMultiLine = FALSE, int32_t iLineWidth = -1); - IFWL_Widget* m_pIface; - IFWL_WidgetDelegate* m_pDelegate; - CFWL_WidgetMgr* m_pWidgetMgr; - CFWL_WidgetProperties* m_pProperties; protected: FWL_Error Initialize(const CFWL_WidgetProperties* pProperties = nullptr); + + std::unique_ptr m_pIface; + IFWL_WidgetDelegate* m_pDelegate; + CFWL_WidgetMgr* const m_pWidgetMgr; + std::unique_ptr m_pProperties; }; #endif // XFA_FWL_LIGHTWIDGET_CFWL_WIDGET_H_ -- cgit v1.2.3