Chromium Code Reviews| Index: xfa/fwl/lightwidget/cfwl_widget.cpp |
| diff --git a/xfa/fwl/lightwidget/cfwl_widget.cpp b/xfa/fwl/lightwidget/cfwl_widget.cpp |
| index 8022f0afb046dcc4ebca545dbbb2f86572c462ca..8c809dbbcd84fd5158dc97db9b8ab27418d78b9f 100644 |
| --- a/xfa/fwl/lightwidget/cfwl_widget.cpp |
| +++ b/xfa/fwl/lightwidget/cfwl_widget.cpp |
| @@ -20,7 +20,11 @@ |
| #define FWL_WGT_CalcMultiLineDefWidth 120.0f |
| IFWL_Widget* CFWL_Widget::GetWidget() { |
| - return m_pIface; |
| + return m_pIface.get(); |
| +} |
| + |
| +const IFWL_Widget* CFWL_Widget::GetWidget() const { |
| + return m_pIface.get(); |
| } |
| FWL_Error CFWL_Widget::GetClassName(CFX_WideString& wsClass) const { |
| @@ -208,18 +212,14 @@ IFWL_WidgetDelegate* CFWL_Widget::SetDelegate(IFWL_WidgetDelegate* pDelegate) { |
| } |
| CFWL_Widget::CFWL_Widget() |
| - : m_pIface(nullptr), m_pDelegate(nullptr), m_pProperties(nullptr) { |
| - m_pProperties = new CFWL_WidgetProperties; |
| + : m_pDelegate(nullptr), m_pProperties(new CFWL_WidgetProperties) { |
| m_pWidgetMgr = CFWL_WidgetMgr::GetInstance(); |
|
Lei Zhang
2016/08/05 17:34:18
Put this in the initializer list and make it a con
Wei Li
2016/08/08 23:55:37
Done.
|
| ASSERT(m_pWidgetMgr); |
| } |
| CFWL_Widget::~CFWL_Widget() { |
| - delete m_pProperties; |
| - if (m_pIface) { |
| + if (m_pIface) |
| m_pIface->Finalize(); |
| - delete m_pIface; |
| - } |
| } |
| FWL_Error CFWL_Widget::Repaint(const CFX_RectF* pRect) { |
| @@ -233,7 +233,7 @@ FWL_Error CFWL_Widget::Repaint(const CFX_RectF* pRect) { |
| m_pIface->GetWidgetRect(rect); |
| rect.left = rect.top = 0; |
| } |
| - return m_pWidgetMgr->RepaintWidget(m_pIface, &rect); |
| + return m_pWidgetMgr->RepaintWidget(m_pIface.get(), &rect); |
| } |
| FWL_Error CFWL_Widget::SetFocus(FX_BOOL bFocus) { |
| @@ -249,9 +249,9 @@ FWL_Error CFWL_Widget::SetFocus(FX_BOOL bFocus) { |
| return FWL_Error::Indefinite; |
| if (bFocus) { |
| - pDriver->SetFocus(m_pIface); |
| + pDriver->SetFocus(m_pIface.get()); |
| } else { |
| - if (pDriver->GetFocus() == m_pIface) { |
| + if (pDriver->GetFocus() == m_pIface.get()) { |
| pDriver->SetFocus(nullptr); |
| } |
| } |
| @@ -270,7 +270,7 @@ FWL_Error CFWL_Widget::SetGrab(FX_BOOL bSet) { |
| if (!pDriver) |
| return FWL_Error::Indefinite; |
| - pDriver->SetGrab(m_pIface, bSet); |
| + pDriver->SetGrab(m_pIface.get(), bSet); |
| return FWL_Error::Succeeded; |
| } |
| @@ -320,7 +320,7 @@ CFX_SizeF CFWL_Widget::CalcTextSize(const CFX_WideString& wsText, |
| return CFX_SizeF(); |
| CFWL_ThemeText calPart; |
| - calPart.m_pWidget = m_pIface; |
| + calPart.m_pWidget = m_pIface.get(); |
| calPart.m_wsText = wsText; |
| calPart.m_dwTTOStyles = |
| bMultiLine ? FDE_TTOSTYLE_LineWrap : FDE_TTOSTYLE_SingleLine; |