From 6f4f2335cfd22d26db154fbd51ab553fb9902918 Mon Sep 17 00:00:00 2001 From: tsepez Date: Mon, 6 Jun 2016 13:23:55 -0700 Subject: Remove FWL_HTIMER in favor of IWFL_TimerInfo Review-Url: https://codereview.chromium.org/2037573003 --- fpdfsdk/fpdfxfa/fpdfxfa_util.cpp | 15 +++++---- fpdfsdk/fpdfxfa/include/fpdfxfa_util.h | 13 ++++---- xfa/fwl/basewidget/fwl_caretimp.cpp | 27 +++++++-------- xfa/fwl/basewidget/fwl_caretimp.h | 4 +-- xfa/fwl/basewidget/fwl_scrollbarimp.cpp | 28 ++++++++-------- xfa/fwl/basewidget/fwl_scrollbarimp.h | 4 +-- xfa/fwl/basewidget/fwl_spinbuttonimp.cpp | 31 ++++++++++-------- xfa/fwl/basewidget/fwl_spinbuttonimp.h | 5 +-- xfa/fwl/basewidget/fwl_tooltipctrlimp.cpp | 51 ++++++++++++++--------------- xfa/fwl/basewidget/fwl_tooltipctrlimp.h | 10 +++--- xfa/fwl/core/fwl_timerimp.cpp | 21 ++++++------ xfa/fwl/core/ifwl_timer.h | 16 +++++---- xfa/fwl/core/include/ifwl_adaptertimermgr.h | 8 ++--- 13 files changed, 118 insertions(+), 115 deletions(-) diff --git a/fpdfsdk/fpdfxfa/fpdfxfa_util.cpp b/fpdfsdk/fpdfxfa/fpdfxfa_util.cpp index b6deaef17b..9971f5d165 100644 --- a/fpdfsdk/fpdfxfa/fpdfxfa_util.cpp +++ b/fpdfsdk/fpdfxfa/fpdfxfa_util.cpp @@ -15,24 +15,25 @@ std::vector* CXFA_FWLAdapterTimerMgr::s_TimerArray = nullptr; FWL_Error CXFA_FWLAdapterTimerMgr::Start(IFWL_Timer* pTimer, uint32_t dwElapse, - FWL_HTIMER& hTimer, - FX_BOOL bImmediately) { + bool bImmediately, + IFWL_TimerInfo** pTimerInfo) { if (!m_pEnv) return FWL_Error::Indefinite; int32_t id_event = m_pEnv->FFI_SetTimer(dwElapse, TimerProc); if (!s_TimerArray) s_TimerArray = new std::vector; + s_TimerArray->push_back(new CFWL_TimerInfo(id_event, pTimer)); - hTimer = reinterpret_cast(s_TimerArray->back()); + *pTimerInfo = s_TimerArray->back(); return FWL_Error::Succeeded; } -FWL_Error CXFA_FWLAdapterTimerMgr::Stop(FWL_HTIMER hTimer) { - if (!hTimer || !m_pEnv) +FWL_Error CXFA_FWLAdapterTimerMgr::Stop(IFWL_TimerInfo* pTimerInfo) { + if (!pTimerInfo || !m_pEnv) return FWL_Error::Indefinite; - CFWL_TimerInfo* pInfo = reinterpret_cast(hTimer); + CFWL_TimerInfo* pInfo = static_cast(pTimerInfo); m_pEnv->FFI_KillTimer(pInfo->idEvent); if (s_TimerArray) { auto it = std::find(s_TimerArray->begin(), s_TimerArray->end(), pInfo); @@ -51,7 +52,7 @@ void CXFA_FWLAdapterTimerMgr::TimerProc(int32_t idEvent) { for (CFWL_TimerInfo* pInfo : *s_TimerArray) { if (pInfo->idEvent == idEvent) { - pInfo->pTimer->Run(reinterpret_cast(pInfo)); + pInfo->pTimer->Run(pInfo); break; } } diff --git a/fpdfsdk/fpdfxfa/include/fpdfxfa_util.h b/fpdfsdk/fpdfxfa/include/fpdfxfa_util.h index dce9a74229..fb5bd0d1b7 100644 --- a/fpdfsdk/fpdfxfa/include/fpdfxfa_util.h +++ b/fpdfsdk/fpdfxfa/include/fpdfxfa_util.h @@ -22,11 +22,12 @@ struct CFWL_TimerInfo; class CXFA_FWLAdapterTimerMgr : public IFWL_AdapterTimerMgr { public: CXFA_FWLAdapterTimerMgr(CPDFDoc_Environment* pEnv) : m_pEnv(pEnv) {} - virtual FWL_Error Start(IFWL_Timer* pTimer, - uint32_t dwElapse, - FWL_HTIMER& hTimer, - FX_BOOL bImmediately = TRUE); - virtual FWL_Error Stop(FWL_HTIMER hTimer); + + FWL_Error Start(IFWL_Timer* pTimer, + uint32_t dwElapse, + bool bImmediately, + IFWL_TimerInfo** pTimerInfo) override; + FWL_Error Stop(IFWL_TimerInfo* pTimerInfo) override; protected: static void TimerProc(int32_t idEvent); @@ -35,7 +36,7 @@ class CXFA_FWLAdapterTimerMgr : public IFWL_AdapterTimerMgr { CPDFDoc_Environment* const m_pEnv; }; -struct CFWL_TimerInfo { +struct CFWL_TimerInfo : public IFWL_TimerInfo { CFWL_TimerInfo() : pTimer(nullptr) {} CFWL_TimerInfo(int32_t event, IFWL_Timer* timer) : idEvent(event), pTimer(timer) {} diff --git a/xfa/fwl/basewidget/fwl_caretimp.cpp b/xfa/fwl/basewidget/fwl_caretimp.cpp index c67c0c4291..dbe8e50bc2 100644 --- a/xfa/fwl/basewidget/fwl_caretimp.cpp +++ b/xfa/fwl/basewidget/fwl_caretimp.cpp @@ -38,7 +38,7 @@ FWL_Error IFWL_Caret::SetColor(CFX_Color crFill) { CFWL_CaretImp::CFWL_CaretImp(const CFWL_WidgetImpProperties& properties, IFWL_Widget* pOuter) : CFWL_WidgetImp(properties, pOuter), - m_hTimer(nullptr), + m_pTimerInfo(nullptr), m_dwElapse(400), m_bSetColor(FALSE) { m_pTimer = new CFWL_CaretTimer(this); @@ -67,9 +67,9 @@ FWL_Error CFWL_CaretImp::Initialize() { } FWL_Error CFWL_CaretImp::Finalize() { - if (m_hTimer) { - FWL_StopTimer(m_hTimer); - m_hTimer = NULL; + if (m_pTimerInfo) { + m_pTimerInfo->StopTimer(); + m_pTimerInfo = nullptr; } delete m_pDelegate; m_pDelegate = nullptr; @@ -89,12 +89,12 @@ FWL_Error CFWL_CaretImp::DrawWidget(CFX_Graphics* pGraphics, } void CFWL_CaretImp::ShowCaret(FX_BOOL bFlag) { - if (m_hTimer) { - FWL_StopTimer(m_hTimer); - m_hTimer = nullptr; + if (m_pTimerInfo) { + m_pTimerInfo->StopTimer(); + m_pTimerInfo = nullptr; } if (bFlag) - m_hTimer = FWL_StartTimer(m_pTimer, m_dwElapse); + m_pTimerInfo = m_pTimer->StartTimer(m_dwElapse, true); SetStates(FWL_WGTSTATE_Invisible, !bFlag); } @@ -138,17 +138,14 @@ void CFWL_CaretImp::DrawCaretBK(CFX_Graphics* pGraphics, CFWL_CaretImp::CFWL_CaretTimer::CFWL_CaretTimer(CFWL_CaretImp* pCaret) : m_pCaret(pCaret) {} -int32_t CFWL_CaretImp::CFWL_CaretTimer::Run(FWL_HTIMER hTimer) { - if (m_pCaret->GetStates() & FWL_STATE_CAT_HightLight) { - m_pCaret->SetStates(FWL_STATE_CAT_HightLight, FALSE); - } else { - m_pCaret->SetStates(FWL_STATE_CAT_HightLight); - } +void CFWL_CaretImp::CFWL_CaretTimer::Run(IFWL_TimerInfo* pTimerInfo) { + bool toggle = !(m_pCaret->GetStates() & FWL_STATE_CAT_HightLight); + m_pCaret->SetStates(FWL_STATE_CAT_HightLight, toggle); + CFX_RectF rt; m_pCaret->GetWidgetRect(rt); rt.Set(0, 0, rt.width + 1, rt.height); m_pCaret->Repaint(&rt); - return 1; } CFWL_CaretImpDelegate::CFWL_CaretImpDelegate(CFWL_CaretImp* pOwner) diff --git a/xfa/fwl/basewidget/fwl_caretimp.h b/xfa/fwl/basewidget/fwl_caretimp.h index b1ebcfa184..e7484e6edc 100644 --- a/xfa/fwl/basewidget/fwl_caretimp.h +++ b/xfa/fwl/basewidget/fwl_caretimp.h @@ -43,7 +43,7 @@ class CFWL_CaretImp : public CFWL_WidgetImp { public: explicit CFWL_CaretTimer(CFWL_CaretImp* pCaret); ~CFWL_CaretTimer() override {} - int32_t Run(FWL_HTIMER hTimer) override; + void Run(IFWL_TimerInfo* hTimer) override; CFWL_CaretImp* const m_pCaret; }; @@ -52,7 +52,7 @@ class CFWL_CaretImp : public CFWL_WidgetImp { const CFX_Matrix* pMatrix); CFWL_CaretTimer* m_pTimer; - FWL_HTIMER m_hTimer; + IFWL_TimerInfo* m_pTimerInfo; uint32_t m_dwElapse; CFX_Color m_crFill; FX_BOOL m_bSetColor; diff --git a/xfa/fwl/basewidget/fwl_scrollbarimp.cpp b/xfa/fwl/basewidget/fwl_scrollbarimp.cpp index 17f98059be..15b1d911b5 100644 --- a/xfa/fwl/basewidget/fwl_scrollbarimp.cpp +++ b/xfa/fwl/basewidget/fwl_scrollbarimp.cpp @@ -67,7 +67,7 @@ FX_BOOL IFWL_ScrollBar::DoScroll(uint32_t dwCode, FX_FLOAT fPos) { CFWL_ScrollBarImp::CFWL_ScrollBarImp(const CFWL_WidgetImpProperties& properties, IFWL_Widget* pOuter) : CFWL_WidgetImp(properties, pOuter), - m_hTimer(nullptr), + m_pTimerInfo(nullptr), m_fRangeMin(0), m_fRangeMax(-1), m_fPageSize(0), @@ -233,15 +233,15 @@ FX_BOOL CFWL_ScrollBarImp::DoScroll(uint32_t dwCode, FX_FLOAT fPos) { } return OnScroll(dwCode, fPos); } -int32_t CFWL_ScrollBarImp::Run(FWL_HTIMER hTimer) { - if (m_hTimer) { - FWL_StopTimer(m_hTimer); - } - if (!SendEvent()) { - m_hTimer = FWL_StartTimer(this, 0); - } - return 1; + +void CFWL_ScrollBarImp::Run(IFWL_TimerInfo* pTimerInfo) { + if (m_pTimerInfo) + m_pTimerInfo->StopTimer(); + + if (!SendEvent()) + m_pTimerInfo = StartTimer(0, true); } + FWL_Error CFWL_ScrollBarImp::SetOuter(IFWL_Widget* pOuter) { m_pOuter = pOuter; return FWL_Error::Succeeded; @@ -281,8 +281,6 @@ void CFWL_ScrollBarImp::DrawArrowBtn(CFX_Graphics* pGraphics, void CFWL_ScrollBarImp::DrawThumb(CFX_Graphics* pGraphics, IFWL_ThemeProvider* pTheme, const CFX_Matrix* pMatrix) { - if (!IsEnabled()) { - } CFWL_ThemeBackground param; param.m_pWidget = m_pInterface; param.m_iPart = CFWL_Part::Thumb; @@ -706,14 +704,14 @@ void CFWL_ScrollBarImpDelegate::OnLButtonDown(uint32_t dwFlags, } } } - if (!m_pOwner->SendEvent()) { - m_pOwner->m_hTimer = FWL_StartTimer(m_pOwner, FWL_SCROLLBAR_Elapse); - } + if (!m_pOwner->SendEvent()) + m_pOwner->m_pTimerInfo = m_pOwner->StartTimer(FWL_SCROLLBAR_Elapse, true); } + void CFWL_ScrollBarImpDelegate::OnLButtonUp(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy) { - FWL_StopTimer(m_pOwner->m_hTimer); + m_pOwner->m_pTimerInfo->StopTimer(); m_pOwner->m_bMouseDown = FALSE; DoMouseUp(0, m_pOwner->m_rtMinBtn, m_pOwner->m_iMinButtonState, fx, fy); DoMouseUp(1, m_pOwner->m_rtThumb, m_pOwner->m_iThumbButtonState, fx, fy); diff --git a/xfa/fwl/basewidget/fwl_scrollbarimp.h b/xfa/fwl/basewidget/fwl_scrollbarimp.h index ad10e207db..4410830707 100644 --- a/xfa/fwl/basewidget/fwl_scrollbarimp.h +++ b/xfa/fwl/basewidget/fwl_scrollbarimp.h @@ -32,7 +32,7 @@ class CFWL_ScrollBarImp : public CFWL_WidgetImp, public IFWL_Timer { const CFX_Matrix* pMatrix = nullptr) override; // IFWL_Timer - int32_t Run(FWL_HTIMER hTimer) override; + void Run(IFWL_TimerInfo* pTimerInfo) override; FX_BOOL IsVertical(); FWL_Error GetRange(FX_FLOAT& fMin, FX_FLOAT& fMax); @@ -74,7 +74,7 @@ class CFWL_ScrollBarImp : public CFWL_WidgetImp, public IFWL_Timer { FX_BOOL SendEvent(); FX_BOOL OnScroll(uint32_t dwCode, FX_FLOAT fPos); - FWL_HTIMER m_hTimer; + IFWL_TimerInfo* m_pTimerInfo; FX_FLOAT m_fRangeMin; FX_FLOAT m_fRangeMax; FX_FLOAT m_fPageSize; diff --git a/xfa/fwl/basewidget/fwl_spinbuttonimp.cpp b/xfa/fwl/basewidget/fwl_spinbuttonimp.cpp index 25c8a35983..4eddce7439 100644 --- a/xfa/fwl/basewidget/fwl_spinbuttonimp.cpp +++ b/xfa/fwl/basewidget/fwl_spinbuttonimp.cpp @@ -52,7 +52,7 @@ CFWL_SpinButtonImp::CFWL_SpinButtonImp( m_dwDnState(CFWL_PartState_Normal), m_iButtonIndex(0), m_bLButtonDwn(FALSE), - m_hTimer(NULL) { + m_pTimerInfo(nullptr) { m_rtClient.Reset(); m_rtUpButton.Reset(); m_rtDnButton.Reset(); @@ -133,7 +133,7 @@ FWL_Error CFWL_SpinButtonImp::DrawWidget(CFX_Graphics* pGraphics, if (!pGraphics) return FWL_Error::Indefinite; CFX_RectF rtClip(m_rtClient); - if (pMatrix != NULL) { + if (pMatrix) { pMatrix->TransformRect(rtClip); } IFWL_ThemeProvider* pTheme = GetAvailableTheme(); @@ -147,15 +147,17 @@ FWL_Error CFWL_SpinButtonImp::DrawWidget(CFX_Graphics* pGraphics, DrawDownButton(pGraphics, pTheme, pMatrix); return FWL_Error::Succeeded; } -int32_t CFWL_SpinButtonImp::Run(FWL_HTIMER hTimer) { - if (m_hTimer) { - CFWL_EvtSpbClick wmPosChanged; - wmPosChanged.m_pSrcTarget = m_pInterface; - wmPosChanged.m_bUp = m_iButtonIndex == 0; - DispatchEvent(&wmPosChanged); - } - return 1; + +void CFWL_SpinButtonImp::Run(IFWL_TimerInfo* pTimerInfo) { + if (!m_pTimerInfo) + return; + + CFWL_EvtSpbClick wmPosChanged; + wmPosChanged.m_pSrcTarget = m_pInterface; + wmPosChanged.m_bUp = m_iButtonIndex == 0; + DispatchEvent(&wmPosChanged); } + FWL_Error CFWL_SpinButtonImp::EnableButton(FX_BOOL bEnable, FX_BOOL bUp) { if (bUp) { if (bEnable) { @@ -305,8 +307,9 @@ void CFWL_SpinButtonImpDelegate::OnLButtonDown(CFWL_MsgMouse* pMsg) { m_pOwner->DispatchEvent(&wmPosChanged); m_pOwner->Repaint(bUpPress ? &m_pOwner->m_rtUpButton : &m_pOwner->m_rtDnButton); - m_pOwner->m_hTimer = FWL_StartTimer(m_pOwner, kElapseTime); + m_pOwner->m_pTimerInfo = m_pOwner->StartTimer(kElapseTime, true); } + void CFWL_SpinButtonImpDelegate::OnLButtonUp(CFWL_MsgMouse* pMsg) { if (m_pOwner->m_pProperties->m_dwStates & CFWL_PartState_Disabled) { return; @@ -314,9 +317,9 @@ void CFWL_SpinButtonImpDelegate::OnLButtonUp(CFWL_MsgMouse* pMsg) { m_pOwner->m_bLButtonDwn = FALSE; m_pOwner->SetGrab(FALSE); m_pOwner->SetFocus(FALSE); - if (m_pOwner->m_hTimer) { - FWL_StopTimer(m_pOwner->m_hTimer); - m_pOwner->m_hTimer = NULL; + if (m_pOwner->m_pTimerInfo) { + m_pOwner->m_pTimerInfo->StopTimer(); + m_pOwner->m_pTimerInfo = nullptr; } FX_BOOL bRepaint = FALSE; CFX_RectF rtInvalidate; diff --git a/xfa/fwl/basewidget/fwl_spinbuttonimp.h b/xfa/fwl/basewidget/fwl_spinbuttonimp.h index 068fbd888f..d986f31cd2 100644 --- a/xfa/fwl/basewidget/fwl_spinbuttonimp.h +++ b/xfa/fwl/basewidget/fwl_spinbuttonimp.h @@ -33,7 +33,7 @@ class CFWL_SpinButtonImp : public CFWL_WidgetImp, public IFWL_Timer { const CFX_Matrix* pMatrix = nullptr) override; // IFWL_Timer - int32_t Run(FWL_HTIMER hTimer) override; + void Run(IFWL_TimerInfo* pTimerInfo) override; FWL_Error EnableButton(FX_BOOL bEnable, FX_BOOL bUp = TRUE); FX_BOOL IsButtonEnable(FX_BOOL bUp = TRUE); @@ -55,8 +55,9 @@ class CFWL_SpinButtonImp : public CFWL_WidgetImp, public IFWL_Timer { uint32_t m_dwDnState; int32_t m_iButtonIndex; FX_BOOL m_bLButtonDwn; - FWL_HTIMER m_hTimer; + IFWL_TimerInfo* m_pTimerInfo; }; + class CFWL_SpinButtonImpDelegate : public CFWL_WidgetImpDelegate { public: CFWL_SpinButtonImpDelegate(CFWL_SpinButtonImp* pOwner); diff --git a/xfa/fwl/basewidget/fwl_tooltipctrlimp.cpp b/xfa/fwl/basewidget/fwl_tooltipctrlimp.cpp index 9ac9c31160..e09113e19e 100644 --- a/xfa/fwl/basewidget/fwl_tooltipctrlimp.cpp +++ b/xfa/fwl/basewidget/fwl_tooltipctrlimp.cpp @@ -48,9 +48,9 @@ CFWL_ToolTipImp::CFWL_ToolTipImp(const CFWL_WidgetImpProperties& properties, m_bBtnDown(FALSE), m_dwTTOStyles(FDE_TTOSTYLE_SingleLine), m_iTTOAlign(FDE_TTOALIGNMENT_Center), - m_hTimerShow(NULL), - m_hTimerHide(NULL), - m_pTimer(NULL) { + m_pTimerInfoShow(nullptr), + m_pTimerInfoHide(nullptr), + m_pTimer(nullptr) { m_rtClient.Set(0, 0, 0, 0); m_rtCaption.Set(0, 0, 0, 0); m_rtAnchor.Set(0, 0, 0, 0); @@ -59,10 +59,8 @@ CFWL_ToolTipImp::CFWL_ToolTipImp(const CFWL_WidgetImpProperties& properties, } CFWL_ToolTipImp::~CFWL_ToolTipImp() { - if (m_pTimer) { - delete m_pTimer; - m_pTimer = NULL; - } + delete m_pTimer; + m_pTimer = nullptr; } FWL_Error CFWL_ToolTipImp::GetClassName(CFX_WideString& wsClass) const { @@ -92,7 +90,7 @@ FWL_Error CFWL_ToolTipImp::Finalize() { FWL_Error CFWL_ToolTipImp::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) { if (bAutoSize) { rect.Set(0, 0, 0, 0); - if (m_pProperties->m_pThemeProvider == NULL) { + if (!m_pProperties->m_pThemeProvider) { m_pProperties->m_pThemeProvider = GetAvailableTheme(); } CFX_WideString wsCaption; @@ -221,18 +219,18 @@ void CFWL_ToolTipImp::Show() { static_cast(m_pProperties->m_pDataProvider); int32_t nInitDelay = pData->GetInitialDelay(m_pInterface); if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Invisible)) - m_hTimerShow = FWL_StartTimer(&m_TimerShow, nInitDelay, FALSE); + m_pTimerInfoShow = m_TimerShow.StartTimer(nInitDelay, false); } void CFWL_ToolTipImp::Hide() { SetStates(FWL_WGTSTATE_Invisible, TRUE); - if (m_hTimerHide) { - FWL_StopTimer(m_hTimerHide); - m_hTimerHide = nullptr; + if (m_pTimerInfoHide) { + m_pTimerInfoHide->StopTimer(); + m_pTimerInfoHide = nullptr; } - if (m_hTimerShow) { - FWL_StopTimer(m_hTimerShow); - m_hTimerShow = nullptr; + if (m_pTimerInfoShow) { + m_pTimerInfoShow->StopTimer(); + m_pTimerInfoShow = nullptr; } } @@ -241,7 +239,7 @@ void CFWL_ToolTipImp::SetStates(uint32_t dwStates, FX_BOOL bSet) { IFWL_ToolTipDP* pData = static_cast(m_pProperties->m_pDataProvider); int32_t nAutoPopDelay = pData->GetAutoPopDelay(m_pInterface); - m_hTimerHide = FWL_StartTimer(&m_TimerHide, nAutoPopDelay, FALSE); + m_pTimerInfoHide = m_TimerHide.StartTimer(nAutoPopDelay, false); } CFWL_WidgetImp::SetStates(dwStates, bSet); } @@ -276,23 +274,24 @@ void CFWL_ToolTipImp::RefreshToolTipPos() { } CFWL_ToolTipImp::CFWL_ToolTipTimer::CFWL_ToolTipTimer(CFWL_ToolTipImp* pToolTip) : m_pToolTip(pToolTip) {} -int32_t CFWL_ToolTipImp::CFWL_ToolTipTimer::Run(FWL_HTIMER hTimer) { - if (m_pToolTip->m_hTimerShow == hTimer && m_pToolTip->m_hTimerShow) { + +void CFWL_ToolTipImp::CFWL_ToolTipTimer::Run(IFWL_TimerInfo* pTimerInfo) { + if (m_pToolTip->m_pTimerInfoShow == pTimerInfo && + m_pToolTip->m_pTimerInfoShow) { if (m_pToolTip->GetStates() & FWL_WGTSTATE_Invisible) { m_pToolTip->SetStates(FWL_WGTSTATE_Invisible, FALSE); m_pToolTip->RefreshToolTipPos(); - FWL_StopTimer(m_pToolTip->m_hTimerShow); - m_pToolTip->m_hTimerShow = NULL; - return TRUE; + m_pToolTip->m_pTimerInfoShow->StopTimer(); + m_pToolTip->m_pTimerInfoShow = nullptr; + return; } } - if (m_pToolTip->m_hTimerHide == hTimer && m_pToolTip->m_hTimerHide) { + if (m_pToolTip->m_pTimerInfoHide == pTimerInfo && + m_pToolTip->m_pTimerInfoHide) { m_pToolTip->SetStates(FWL_WGTSTATE_Invisible, TRUE); - FWL_StopTimer(m_pToolTip->m_hTimerHide); - m_pToolTip->m_hTimerHide = NULL; - return TRUE; + m_pToolTip->m_pTimerInfoHide->StopTimer(); + m_pToolTip->m_pTimerInfoHide = nullptr; } - return TRUE; } CFWL_ToolTipImpDelegate::CFWL_ToolTipImpDelegate(CFWL_ToolTipImp* pOwner) diff --git a/xfa/fwl/basewidget/fwl_tooltipctrlimp.h b/xfa/fwl/basewidget/fwl_tooltipctrlimp.h index 6d7af8dc89..c21a47ec07 100644 --- a/xfa/fwl/basewidget/fwl_tooltipctrlimp.h +++ b/xfa/fwl/basewidget/fwl_tooltipctrlimp.h @@ -44,10 +44,10 @@ class CFWL_ToolTipImp : public CFWL_FormImp { class CFWL_ToolTipTimer : public IFWL_Timer { public: CFWL_ToolTipTimer() {} - ~CFWL_ToolTipTimer() {} + explicit CFWL_ToolTipTimer(CFWL_ToolTipImp* pToolTip); + ~CFWL_ToolTipTimer() override {} - CFWL_ToolTipTimer(CFWL_ToolTipImp* pToolTip); - virtual int32_t Run(FWL_HTIMER hTimer); + void Run(IFWL_TimerInfo* pTimerInfo) override; CFWL_ToolTipImp* m_pToolTip; }; @@ -67,8 +67,8 @@ class CFWL_ToolTipImp : public CFWL_FormImp { uint32_t m_dwTTOStyles; int32_t m_iTTOAlign; CFX_RectF m_rtAnchor; - FWL_HTIMER m_hTimerShow; - FWL_HTIMER m_hTimerHide; + IFWL_TimerInfo* m_pTimerInfoShow; + IFWL_TimerInfo* m_pTimerInfoHide; CFWL_ToolTipTimer* m_pTimer; CFWL_ToolTipTimer m_TimerShow; CFWL_ToolTipTimer m_TimerHide; diff --git a/xfa/fwl/core/fwl_timerimp.cpp b/xfa/fwl/core/fwl_timerimp.cpp index ced5adeb9d..22b28c8c67 100644 --- a/xfa/fwl/core/fwl_timerimp.cpp +++ b/xfa/fwl/core/fwl_timerimp.cpp @@ -10,21 +10,21 @@ #include "xfa/fwl/core/include/ifwl_adaptertimermgr.h" #include "xfa/fxfa/include/xfa_ffapp.h" -FWL_HTIMER FWL_StartTimer(IFWL_Timer* pTimer, - uint32_t dwElapse, - FX_BOOL bImmediately) { +IFWL_TimerInfo* IFWL_Timer::StartTimer(uint32_t dwElapse, bool bImmediately) { CXFA_FFApp* pAdapterNative = FWL_GetAdapterNative(); if (!pAdapterNative) - return NULL; + return nullptr; + IFWL_AdapterTimerMgr* pAdapterTimerMgr = pAdapterNative->GetTimerMgr(); if (!pAdapterTimerMgr) - return NULL; - FWL_HTIMER hTimer = NULL; - pAdapterTimerMgr->Start(pTimer, dwElapse, hTimer, bImmediately); - return hTimer; + return nullptr; + + IFWL_TimerInfo* pTimerInfo = nullptr; + pAdapterTimerMgr->Start(this, dwElapse, bImmediately, &pTimerInfo); + return pTimerInfo; } -FWL_Error FWL_StopTimer(FWL_HTIMER hTimer) { +FWL_Error IFWL_TimerInfo::StopTimer() { CXFA_FFApp* pAdapterNative = FWL_GetAdapterNative(); if (!pAdapterNative) return FWL_Error::Indefinite; @@ -32,5 +32,6 @@ FWL_Error FWL_StopTimer(FWL_HTIMER hTimer) { IFWL_AdapterTimerMgr* pAdapterTimerMgr = pAdapterNative->GetTimerMgr(); if (!pAdapterTimerMgr) return FWL_Error::Indefinite; - return pAdapterTimerMgr->Stop(hTimer); + + return pAdapterTimerMgr->Stop(this); } diff --git a/xfa/fwl/core/ifwl_timer.h b/xfa/fwl/core/ifwl_timer.h index 0143560410..162fef9692 100644 --- a/xfa/fwl/core/ifwl_timer.h +++ b/xfa/fwl/core/ifwl_timer.h @@ -8,17 +8,21 @@ #define XFA_FWL_CORE_IFWL_TIMER_H_ #include "core/fxcrt/include/fx_system.h" +#include "xfa/fwl/core/fwl_error.h" -typedef struct FWL_HTIMER_ { void* pData; } * FWL_HTIMER; +class IFWL_TimerInfo; class IFWL_Timer { public: virtual ~IFWL_Timer() {} - virtual int32_t Run(FWL_HTIMER hTimer) = 0; + virtual void Run(IFWL_TimerInfo* hTimer) = 0; + IFWL_TimerInfo* StartTimer(uint32_t dwElapse, bool bImmediately); +}; + +class IFWL_TimerInfo { + public: + virtual ~IFWL_TimerInfo() {} + FWL_Error StopTimer(); }; -FWL_HTIMER FWL_StartTimer(IFWL_Timer* pTimer, - uint32_t dwElapse, - FX_BOOL bImmediately = TRUE); -FWL_Error FWL_StopTimer(FWL_HTIMER hTimer); #endif // XFA_FWL_CORE_IFWL_TIMER_H_ diff --git a/xfa/fwl/core/include/ifwl_adaptertimermgr.h b/xfa/fwl/core/include/ifwl_adaptertimermgr.h index 7859e31fd8..111c3ebf84 100644 --- a/xfa/fwl/core/include/ifwl_adaptertimermgr.h +++ b/xfa/fwl/core/include/ifwl_adaptertimermgr.h @@ -10,16 +10,14 @@ #include "xfa/fwl/core/fwl_error.h" #include "xfa/fwl/core/ifwl_timer.h" -class IFWL_Timer; - class IFWL_AdapterTimerMgr { public: virtual ~IFWL_AdapterTimerMgr() {} virtual FWL_Error Start(IFWL_Timer* pTimer, uint32_t dwElapse, - FWL_HTIMER& hTimer, - FX_BOOL bImmediately = TRUE) = 0; - virtual FWL_Error Stop(FWL_HTIMER hTimer) = 0; + bool bImmediately, + IFWL_TimerInfo** pTimerInfo) = 0; + virtual FWL_Error Stop(IFWL_TimerInfo* pTimerInfo) = 0; }; #endif // XFA_FWL_CORE_INCLUDE_IFWL_ADAPTERTIMERMGR_H_ -- cgit v1.2.3