From 9ec22175f945d227e71c459e7e0b7c464159c18b Mon Sep 17 00:00:00 2001 From: dsinclair Date: Tue, 1 Nov 2016 08:33:02 -0700 Subject: Rename IFWL_Widget::SetDelegate The ::SetDelegate method was misleading. The primary use was SetDelegate(nullptr) which returned the current delegate and didn't actually set anything. When a value was passed it would set the |m_pCurDelegate| not the |m_pDelegate|. This Cl breaks ::SetDelegate into ::GetCurrentDelegate and ::SetCurrentDelegate to make it clear what is happening and that this does not effect the |m_pDelegate| variable. Review-Url: https://codereview.chromium.org/2459423003 --- xfa/fwl/core/ifwl_widget.cpp | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) (limited to 'xfa/fwl/core/ifwl_widget.cpp') diff --git a/xfa/fwl/core/ifwl_widget.cpp b/xfa/fwl/core/ifwl_widget.cpp index eb8b1281e9..da90c4892d 100644 --- a/xfa/fwl/core/ifwl_widget.cpp +++ b/xfa/fwl/core/ifwl_widget.cpp @@ -100,10 +100,9 @@ FWL_Error IFWL_Widget::SetWidgetRect(const CFX_RectF& rect) { ev.m_pSrcTarget = this; ev.m_rtOld = rtOld; ev.m_rtNew = rect; - IFWL_WidgetDelegate* pDelegate = SetDelegate(nullptr); - if (pDelegate) { + + if (IFWL_WidgetDelegate* pDelegate = GetCurrentDelegate()) pDelegate->OnProcessEvent(&ev); - } } return FWL_Error::Succeeded; } @@ -353,16 +352,14 @@ FWL_Error IFWL_Widget::SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) { return FWL_Error::Succeeded; } -IFWL_WidgetDelegate* IFWL_Widget::SetDelegate(IFWL_WidgetDelegate* pDelegate) { - if (!m_pCurDelegate) { +IFWL_WidgetDelegate* IFWL_Widget::GetCurrentDelegate() { + if (!m_pCurDelegate) m_pCurDelegate = m_pDelegate; - } - if (!pDelegate) { - return m_pCurDelegate; - } - IFWL_WidgetDelegate* pOldDelegate = m_pCurDelegate; + return m_pCurDelegate; +} + +void IFWL_Widget::SetCurrentDelegate(IFWL_WidgetDelegate* pDelegate) { m_pCurDelegate = pDelegate; - return pOldDelegate; } const IFWL_App* IFWL_Widget::GetOwnerApp() const { @@ -727,8 +724,7 @@ void IFWL_Widget::DispatchKeyEvent(CFWL_MsgKey* pNote) { void IFWL_Widget::DispatchEvent(CFWL_Event* pEvent) { if (m_pOuter) { - IFWL_WidgetDelegate* pDelegate = m_pOuter->SetDelegate(nullptr); - pDelegate->OnProcessEvent(pEvent); + m_pOuter->GetCurrentDelegate()->OnProcessEvent(pEvent); return; } const IFWL_App* pApp = GetOwnerApp(); -- cgit v1.2.3