From 05b9a317d66c29f740e4b0e89ea87143a11d61fc Mon Sep 17 00:00:00 2001 From: dsinclair Date: Tue, 15 Nov 2016 12:00:41 -0800 Subject: Cleaning methods and visibility in cfwl_* files. First pass at cleaning up visibility, return values and const'ness of cfwl_* class. Review-Url: https://codereview.chromium.org/2501743002 --- xfa/fwl/core/cfwl_widgetmgr.cpp | 268 ++++++++++++---------------------------- xfa/fwl/core/cfwl_widgetmgr.h | 110 +++++++++-------- xfa/fwl/core/fwl_noteimp.cpp | 4 +- xfa/fwl/core/ifwl_widget.cpp | 17 +-- xfa/fwl/core/ifwl_widget.h | 2 +- xfa/fxfa/app/xfa_ffapp.cpp | 2 +- xfa/fxfa/app/xfa_fwladapter.cpp | 9 +- xfa/fxfa/app/xfa_fwladapter.h | 2 +- xfa/fxfa/xfa_ffapp.h | 8 +- 9 files changed, 161 insertions(+), 261 deletions(-) (limited to 'xfa') diff --git a/xfa/fwl/core/cfwl_widgetmgr.cpp b/xfa/fwl/core/cfwl_widgetmgr.cpp index 90dcd6e121..310577c1f5 100644 --- a/xfa/fwl/core/cfwl_widgetmgr.cpp +++ b/xfa/fwl/core/cfwl_widgetmgr.cpp @@ -35,9 +35,7 @@ bool FWL_UseOffscreen(IFWL_Widget* pWidget) { } CFWL_WidgetMgr::CFWL_WidgetMgr(CXFA_FFApp* pAdapterNative) - : m_dwCapability(0), - m_pDelegate(new CFWL_WidgetMgrDelegate(this)), - m_pAdapter(pAdapterNative->GetWidgetMgr(m_pDelegate.get())) { + : m_dwCapability(0), m_pAdapter(pAdapterNative->GetWidgetMgr(this)) { ASSERT(m_pAdapter); m_mapWidgetItem[nullptr].reset(new CFWL_WidgetMgrItem); #if (_FX_OS_ == _FX_WIN32_DESKTOP_) || (_FX_OS_ == _FX_WIN64_) @@ -76,15 +74,6 @@ IFWL_Widget* CFWL_WidgetMgr::GetNextSiblingWidget(IFWL_Widget* pWidget) const { return pItem && pItem->pNext ? pItem->pNext->pWidget : nullptr; } -IFWL_Widget* CFWL_WidgetMgr::GetLastSiblingWidget(IFWL_Widget* pWidget) const { - CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); - pItem = pItem ? pItem->pNext : nullptr; // Not self. - while (pItem && pItem->pNext) - pItem = pItem->pNext; - - return pItem ? pItem->pWidget : nullptr; -} - IFWL_Widget* CFWL_WidgetMgr::GetFirstChildWidget(IFWL_Widget* pWidget) const { CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); return pItem && pItem->pChild ? pItem->pChild->pWidget : nullptr; @@ -109,19 +98,18 @@ IFWL_Widget* CFWL_WidgetMgr::GetSystemFormWidget(IFWL_Widget* pWidget) const { return nullptr; } -bool CFWL_WidgetMgr::SetWidgetIndex(IFWL_Widget* pWidget, int32_t nIndex) { +void CFWL_WidgetMgr::SetWidgetIndex(IFWL_Widget* pWidget, int32_t nIndex) { CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); if (!pItem) - return false; + return; if (!pItem->pParent) - return false; + return; CFWL_WidgetMgrItem* pChild = pItem->pParent->pChild; int32_t i = 0; while (pChild) { if (pChild == pItem) { - if (i == nIndex) { - return true; - } + if (i == nIndex) + return; if (pChild->pPrevious) { pChild->pPrevious->pNext = pChild->pNext; } @@ -150,7 +138,7 @@ bool CFWL_WidgetMgr::SetWidgetIndex(IFWL_Widget* pWidget, int32_t nIndex) { pChild->pNext = pItem; pItem->pPrevious = pChild; pItem->pNext = nullptr; - return true; + return; } i = 0; while (i < nIndex && pChild->pNext) { @@ -161,7 +149,7 @@ bool CFWL_WidgetMgr::SetWidgetIndex(IFWL_Widget* pWidget, int32_t nIndex) { pChild->pNext = pItem; pItem->pPrevious = pChild; pItem->pNext = nullptr; - return true; + return; } if (pChild->pPrevious) { pItem->pPrevious = pChild->pPrevious; @@ -177,12 +165,13 @@ bool CFWL_WidgetMgr::SetWidgetIndex(IFWL_Widget* pWidget, int32_t nIndex) { pItem->pPrevious = nullptr; pItem->pNext = nullptr; } - return true; } -FWL_Error CFWL_WidgetMgr::RepaintWidget(IFWL_Widget* pWidget, - const CFX_RectF* pRect) { + +void CFWL_WidgetMgr::RepaintWidget(IFWL_Widget* pWidget, + const CFX_RectF* pRect) { if (!m_pAdapter) - return FWL_Error::Indefinite; + return; + IFWL_Widget* pNative = pWidget; CFX_RectF rect(*pRect); if (IsFormDisabled()) { @@ -198,33 +187,14 @@ FWL_Error CFWL_WidgetMgr::RepaintWidget(IFWL_Widget* pWidget, } else if (!IsAbleNative(pWidget)) { pNative = GetSystemFormWidget(pWidget); if (!pNative) - return FWL_Error::Indefinite; + return; + pWidget->TransformTo(pNative, rect.left, rect.top); } AddRedrawCounts(pNative); - return m_pAdapter->RepaintWidget(pNative, &rect); -} -void CFWL_WidgetMgr::AddWidget(IFWL_Widget* pWidget) { - CFWL_WidgetMgrItem* pParentItem = GetWidgetMgrItem(nullptr); - CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); - if (!pItem) { - pItem = new CFWL_WidgetMgrItem(pWidget); - m_mapWidgetItem[pWidget].reset(pItem); - } - if (pItem->pParent && pItem->pParent != pParentItem) { - if (pItem->pPrevious) { - pItem->pPrevious->pNext = pItem->pNext; - } - if (pItem->pNext) { - pItem->pNext->pPrevious = pItem->pPrevious; - } - if (pItem->pParent->pChild == pItem) { - pItem->pParent->pChild = pItem->pNext; - } - } - pItem->pParent = pParentItem; - SetWidgetIndex(pWidget, -1); + m_pAdapter->RepaintWidget(pNative, &rect); } + void CFWL_WidgetMgr::InsertWidget(IFWL_Widget* pParent, IFWL_Widget* pChild, int32_t nIndex) { @@ -313,18 +283,8 @@ void CFWL_WidgetMgr::SetParent(IFWL_Widget* pParent, IFWL_Widget* pChild) { SetWidgetIndex(pChild, -1); } -bool CFWL_WidgetMgr::IsChild(IFWL_Widget* pChild, IFWL_Widget* pParent) { - IFWL_Widget* pTemp = pChild; - do { - if (pTemp == pParent) - return true; - pTemp = GetParentWidget(pTemp); - } while (pTemp); - return false; -} - -FWL_Error CFWL_WidgetMgr::SetWidgetRect_Native(IFWL_Widget* pWidget, - const CFX_RectF& rect) { +void CFWL_WidgetMgr::SetWidgetRect_Native(IFWL_Widget* pWidget, + const CFX_RectF& rect) { if (FWL_UseOffscreen(pWidget)) { CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); pItem->iRedrawCounter++; @@ -342,7 +302,6 @@ FWL_Error CFWL_WidgetMgr::SetWidgetRect_Native(IFWL_Widget* pWidget, pItem->bOutsideChanged = !m_rtScreen.Contains(rect); #endif } - return FWL_Error::Succeeded; } IFWL_Widget* CFWL_WidgetMgr::GetWidgetAtPoint(IFWL_Widget* parent, @@ -383,7 +342,7 @@ void CFWL_WidgetMgr::NotifySizeChanged(IFWL_Widget* pForm, GetWidgetMgrItem(pForm)->pOffscreen.reset(); } -IFWL_Widget* CFWL_WidgetMgr::nextTab(IFWL_Widget* parent, +IFWL_Widget* CFWL_WidgetMgr::NextTab(IFWL_Widget* parent, IFWL_Widget* focus, bool& bFind) { CFWL_WidgetMgr* pMgr = parent->GetOwnerApp()->GetWidgetMgr(); @@ -396,7 +355,7 @@ IFWL_Widget* CFWL_WidgetMgr::nextTab(IFWL_Widget* parent, (!focus || (focus != child && bFind))) { return child; } - IFWL_Widget* bRet = nextTab(child, focus, bFind); + IFWL_Widget* bRet = NextTab(child, focus, bFind); if (bRet) return bRet; @@ -405,7 +364,7 @@ IFWL_Widget* CFWL_WidgetMgr::nextTab(IFWL_Widget* parent, return nullptr; } -int32_t CFWL_WidgetMgr::CountRadioButtonGroup(IFWL_Widget* pFirst) { +int32_t CFWL_WidgetMgr::CountRadioButtonGroup(IFWL_Widget* pFirst) const { int32_t iRet = 0; IFWL_Widget* pChild = pFirst; while (pChild) { @@ -414,51 +373,29 @@ int32_t CFWL_WidgetMgr::CountRadioButtonGroup(IFWL_Widget* pFirst) { } return iRet; } -IFWL_Widget* CFWL_WidgetMgr::GetSiblingRadioButton(IFWL_Widget* pWidget, - bool bNext) { - return nullptr; -} + IFWL_Widget* CFWL_WidgetMgr::GetRadioButtonGroupHeader( - IFWL_Widget* pRadioButton) { + IFWL_Widget* pRadioButton) const { IFWL_Widget* pNext = pRadioButton; - while (pNext) { - if (pNext->GetStyles() & FWL_WGTSTYLE_Group) - return pNext; - pNext = GetSiblingRadioButton(pNext, false); - } - pNext = GetLastSiblingWidget(pRadioButton); - while ((pNext = GetSiblingRadioButton(pNext, false)) != nullptr && - pNext != pRadioButton) { - if (pNext->GetStyles() & FWL_WGTSTYLE_Group) - return pNext; - } - pNext = GetFirstSiblingWidget(pRadioButton); - return GetSiblingRadioButton(pNext, true); + if (pNext && (pNext->GetStyles() & FWL_WGTSTYLE_Group)) + return pNext; + return nullptr; } + void CFWL_WidgetMgr::GetSameGroupRadioButton( IFWL_Widget* pRadioButton, - CFX_ArrayTemplate& group) { + CFX_ArrayTemplate& group) const { IFWL_Widget* pFirst = GetFirstSiblingWidget(pRadioButton); if (!pFirst) { pFirst = pRadioButton; } int32_t iGroup = CountRadioButtonGroup(pFirst); - if (iGroup < 2) { - IFWL_Widget* pNext = pFirst; - while ((pNext = GetSiblingRadioButton(pNext, true)) != nullptr) { - group.Add(pNext); - } + if (iGroup < 2) return; - } - IFWL_Widget* pNext = GetRadioButtonGroupHeader(pRadioButton); - do { - group.Add(pNext); - pNext = GetSiblingRadioButton(pNext, true); - if (!pNext) - pNext = GetSiblingRadioButton(pFirst, true); - } while (pNext && ((pNext->GetStyles() & FWL_WGTSTYLE_Group) == 0)); + group.Add(GetRadioButtonGroupHeader(pRadioButton)); } -IFWL_Widget* CFWL_WidgetMgr::GetDefaultButton(IFWL_Widget* pParent) { + +IFWL_Widget* CFWL_WidgetMgr::GetDefaultButton(IFWL_Widget* pParent) const { if ((pParent->GetClassID() == FWL_Type::PushButton) && (pParent->GetStates() & (1 << (FWL_WGTSTATE_MAX + 2)))) { return pParent; @@ -478,14 +415,15 @@ IFWL_Widget* CFWL_WidgetMgr::GetDefaultButton(IFWL_Widget* pParent) { } return nullptr; } + void CFWL_WidgetMgr::AddRedrawCounts(IFWL_Widget* pWidget) { - CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); - (pItem->iRedrawCounter)++; + GetWidgetMgrItem(pWidget)->iRedrawCounter++; } + void CFWL_WidgetMgr::ResetRedrawCounts(IFWL_Widget* pWidget) { - CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); - pItem->iRedrawCounter = 0; + GetWidgetMgrItem(pWidget)->iRedrawCounter = 0; } + CFWL_WidgetMgrItem* CFWL_WidgetMgr::GetWidgetMgrItem( IFWL_Widget* pWidget) const { auto it = m_mapWidgetItem.find(pWidget); @@ -493,36 +431,6 @@ CFWL_WidgetMgrItem* CFWL_WidgetMgr::GetWidgetMgrItem( ? static_cast(it->second.get()) : nullptr; } -int32_t CFWL_WidgetMgr::TravelWidgetMgr(CFWL_WidgetMgrItem* pParent, - int32_t* pIndex, - CFWL_WidgetMgrItem* pItem, - IFWL_Widget** pWidget) { - if (!pParent) { - return 0; - } - int32_t iCount = 0; - CFWL_WidgetMgrItem* pChild = pParent->pChild; - while (pChild) { - iCount++; - if (pIndex) { - if (*pIndex == 0) { - *pWidget = pChild->pWidget; - return iCount; - } - pIndex--; - } - if (pItem && pItem == pChild) { - return iCount - 1; - } - pChild = pChild->pNext; - } - if (pIndex) { - return 0; - } else if (pItem) { - return -1; - } - return iCount - 1; -} bool CFWL_WidgetMgr::IsAbleNative(IFWL_Widget* pWidget) const { if (!pWidget) @@ -536,31 +444,19 @@ bool CFWL_WidgetMgr::IsAbleNative(IFWL_Widget* pWidget) const { (dwStyles & FWL_WGTSTYLE_Popup); } -bool CFWL_WidgetMgr::IsThreadEnabled() { - return !(m_dwCapability & FWL_WGTMGR_DisableThread); -} - -bool CFWL_WidgetMgr::IsFormDisabled() { - return !!(m_dwCapability & FWL_WGTMGR_DisableForm); -} - -bool CFWL_WidgetMgr::GetAdapterPopupPos(IFWL_Widget* pWidget, +void CFWL_WidgetMgr::GetAdapterPopupPos(IFWL_Widget* pWidget, FX_FLOAT fMinHeight, FX_FLOAT fMaxHeight, const CFX_RectF& rtAnchor, - CFX_RectF& rtPopup) { - CXFA_FWLAdapterWidgetMgr* pSDApapter = GetAdapterWidgetMgr(); - return pSDApapter->GetPopupPos(pWidget, fMinHeight, fMaxHeight, rtAnchor, - rtPopup); + CFX_RectF& rtPopup) const { + m_pAdapter->GetPopupPos(pWidget, fMinHeight, fMaxHeight, rtAnchor, rtPopup); } -CFWL_WidgetMgrDelegate::CFWL_WidgetMgrDelegate(CFWL_WidgetMgr* pWidgetMgr) - : m_pWidgetMgr(pWidgetMgr) {} -FWL_Error CFWL_WidgetMgrDelegate::OnSetCapability(uint32_t dwCapability) { - m_pWidgetMgr->m_dwCapability = dwCapability; - return FWL_Error::Succeeded; + +void CFWL_WidgetMgr::OnSetCapability(uint32_t dwCapability) { + m_dwCapability = dwCapability; } -void CFWL_WidgetMgrDelegate::OnProcessMessageToForm(CFWL_Message* pMessage) { +void CFWL_WidgetMgr::OnProcessMessageToForm(CFWL_Message* pMessage) { if (!pMessage) return; if (!pMessage->m_pDstTarget) @@ -576,9 +472,9 @@ void CFWL_WidgetMgrDelegate::OnProcessMessageToForm(CFWL_Message* pMessage) { if (!pNoteDriver) return; - if (m_pWidgetMgr->IsThreadEnabled()) + if (IsThreadEnabled()) pMessage = static_cast(pMessage->Clone()); - if (m_pWidgetMgr->IsFormDisabled()) + if (IsFormDisabled()) pNoteDriver->ProcessMessage(pMessage); else pNoteDriver->QueueMessage(pMessage); @@ -589,15 +485,15 @@ void CFWL_WidgetMgrDelegate::OnProcessMessageToForm(CFWL_Message* pMessage) { pNoteDriver->UnqueueMessage(pTopLoop); #endif - if (m_pWidgetMgr->IsThreadEnabled()) + if (IsThreadEnabled()) pMessage->Release(); return; } -void CFWL_WidgetMgrDelegate::OnDrawWidget(IFWL_Widget* pWidget, - CFX_Graphics* pGraphics, - const CFX_Matrix* pMatrix) { +void CFWL_WidgetMgr::OnDrawWidget(IFWL_Widget* pWidget, + CFX_Graphics* pGraphics, + const CFX_Matrix* pMatrix) { if (!pWidget || !pGraphics) return; @@ -605,7 +501,7 @@ void CFWL_WidgetMgrDelegate::OnDrawWidget(IFWL_Widget* pWidget, CFX_RectF clipCopy; pWidget->GetWidgetRect(clipCopy); clipCopy.left = clipCopy.top = 0; - if (bUseOffscreenDirect(pWidget)) { + if (UseOffscreenDirect(pWidget)) { DrawWidgetAfter(pWidget, pGraphics, clipCopy, pMatrix); return; } @@ -617,7 +513,7 @@ void CFWL_WidgetMgrDelegate::OnDrawWidget(IFWL_Widget* pWidget, pGraphics->GetClipRect(clipBounds); clipCopy = clipBounds; #elif _FX_OS_ == _FX_MACOSX_ - if (m_pWidgetMgr->IsFormDisabled()) { + if (IsFormDisabled()) { pWidget->GetDelegate()->OnDrawWidget(pTemp, pMatrix); pGraphics->GetClipRect(clipBounds); clipCopy = clipBounds; @@ -628,7 +524,7 @@ void CFWL_WidgetMgrDelegate::OnDrawWidget(IFWL_Widget* pWidget, } #endif // _FX_OS_ == _FX_MACOSX_ - if (!m_pWidgetMgr->IsFormDisabled()) { + if (!IsFormDisabled()) { CFX_RectF rtClient; pWidget->GetClientRect(rtClient); clipBounds.Intersect(rtClient); @@ -637,21 +533,21 @@ void CFWL_WidgetMgrDelegate::OnDrawWidget(IFWL_Widget* pWidget, DrawChild(pWidget, clipBounds, pTemp, pMatrix); DrawWidgetAfter(pWidget, pGraphics, clipCopy, pMatrix); - m_pWidgetMgr->ResetRedrawCounts(pWidget); + ResetRedrawCounts(pWidget); } -void CFWL_WidgetMgrDelegate::DrawChild(IFWL_Widget* parent, - const CFX_RectF& rtClip, - CFX_Graphics* pGraphics, - const CFX_Matrix* pMatrix) { +void CFWL_WidgetMgr::DrawChild(IFWL_Widget* parent, + const CFX_RectF& rtClip, + CFX_Graphics* pGraphics, + const CFX_Matrix* pMatrix) { if (!parent) return; - bool bFormDisable = m_pWidgetMgr->IsFormDisabled(); - IFWL_Widget* pNextChild = m_pWidgetMgr->GetFirstChildWidget(parent); + bool bFormDisable = IsFormDisabled(); + IFWL_Widget* pNextChild = GetFirstChildWidget(parent); while (pNextChild) { IFWL_Widget* child = pNextChild; - pNextChild = m_pWidgetMgr->GetNextSiblingWidget(child); + pNextChild = GetNextSiblingWidget(child); if (child->GetStates() & FWL_WGTSTATE_Invisible) continue; @@ -679,8 +575,7 @@ void CFWL_WidgetMgrDelegate::DrawChild(IFWL_Widget* parent, widgetMatrix.Translate(rtWidget.left, rtWidget.top, true); if (IFWL_WidgetDelegate* pDelegate = child->GetDelegate()) { - if (m_pWidgetMgr->IsFormDisabled() || - IsNeedRepaint(child, &widgetMatrix, rtClip)) { + if (IsFormDisabled() || IsNeedRepaint(child, &widgetMatrix, rtClip)) { pDelegate->OnDrawWidget(pGraphics, &widgetMatrix); } } @@ -689,18 +584,17 @@ void CFWL_WidgetMgrDelegate::DrawChild(IFWL_Widget* parent, DrawChild(child, clipBounds, pGraphics, bFormDisable ? &widgetMatrix : pMatrix); - child = m_pWidgetMgr->GetNextSiblingWidget(child); + child = GetNextSiblingWidget(child); } } -CFX_Graphics* CFWL_WidgetMgrDelegate::DrawWidgetBefore( - IFWL_Widget* pWidget, - CFX_Graphics* pGraphics, - const CFX_Matrix* pMatrix) { +CFX_Graphics* CFWL_WidgetMgr::DrawWidgetBefore(IFWL_Widget* pWidget, + CFX_Graphics* pGraphics, + const CFX_Matrix* pMatrix) { if (!FWL_UseOffscreen(pWidget)) return pGraphics; - CFWL_WidgetMgrItem* pItem = m_pWidgetMgr->GetWidgetMgrItem(pWidget); + CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); if (!pItem->pOffscreen) { pItem->pOffscreen.reset(new CFX_Graphics); CFX_RectF rect; @@ -714,26 +608,26 @@ CFX_Graphics* CFWL_WidgetMgrDelegate::DrawWidgetBefore( return pItem->pOffscreen.get(); } -void CFWL_WidgetMgrDelegate::DrawWidgetAfter(IFWL_Widget* pWidget, - CFX_Graphics* pGraphics, - CFX_RectF& rtClip, - const CFX_Matrix* pMatrix) { +void CFWL_WidgetMgr::DrawWidgetAfter(IFWL_Widget* pWidget, + CFX_Graphics* pGraphics, + CFX_RectF& rtClip, + const CFX_Matrix* pMatrix) { if (FWL_UseOffscreen(pWidget)) { - CFWL_WidgetMgrItem* pItem = m_pWidgetMgr->GetWidgetMgrItem(pWidget); + CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); pGraphics->Transfer(pItem->pOffscreen.get(), rtClip.left, rtClip.top, rtClip, pMatrix); #ifdef _WIN32 pItem->pOffscreen->ClearClip(); #endif } - CFWL_WidgetMgrItem* pItem = m_pWidgetMgr->GetWidgetMgrItem(pWidget); + CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); pItem->iRedrawCounter = 0; } -bool CFWL_WidgetMgrDelegate::IsNeedRepaint(IFWL_Widget* pWidget, - CFX_Matrix* pMatrix, - const CFX_RectF& rtDirty) { - CFWL_WidgetMgrItem* pItem = m_pWidgetMgr->GetWidgetMgrItem(pWidget); +bool CFWL_WidgetMgr::IsNeedRepaint(IFWL_Widget* pWidget, + CFX_Matrix* pMatrix, + const CFX_RectF& rtDirty) { + CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); if (pItem && pItem->iRedrawCounter > 0) { pItem->iRedrawCounter = 0; return true; @@ -829,8 +723,8 @@ bool CFWL_WidgetMgrDelegate::IsNeedRepaint(IFWL_Widget* pWidget, return true; } -bool CFWL_WidgetMgrDelegate::bUseOffscreenDirect(IFWL_Widget* pWidget) { - CFWL_WidgetMgrItem* pItem = m_pWidgetMgr->GetWidgetMgrItem(pWidget); +bool CFWL_WidgetMgr::UseOffscreenDirect(IFWL_Widget* pWidget) const { + CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); if (!FWL_UseOffscreen(pWidget) || !(pItem->pOffscreen)) return false; @@ -838,7 +732,7 @@ bool CFWL_WidgetMgrDelegate::bUseOffscreenDirect(IFWL_Widget* pWidget) { if (pItem->bOutsideChanged) { CFX_RectF r; pWidget->GetWidgetRect(r); - CFX_RectF temp(m_pWidgetMgr->m_rtScreen); + CFX_RectF temp(m_rtScreen); temp.Deflate(50, 50); if (!temp.Contains(r)) return false; diff --git a/xfa/fwl/core/cfwl_widgetmgr.h b/xfa/fwl/core/cfwl_widgetmgr.h index 25c5735a98..10176c2598 100644 --- a/xfa/fwl/core/cfwl_widgetmgr.h +++ b/xfa/fwl/core/cfwl_widgetmgr.h @@ -18,7 +18,6 @@ #define FWL_WGTMGR_DisableForm 0x00000002 class CFWL_Message; -class CFWL_WidgetMgrDelegate; class CXFA_FFApp; class CXFA_FWLAdapterWidgetMgr; class CFX_Graphics; @@ -44,86 +43,84 @@ class CFWL_WidgetMgrItem { #endif }; -class CFWL_WidgetMgr { +class IFWL_WidgetMgrDelegate { + public: + virtual void OnSetCapability( + uint32_t dwCapability = FWL_WGTMGR_DisableThread) = 0; + virtual void OnProcessMessageToForm(CFWL_Message* pMessage) = 0; + virtual void OnDrawWidget(IFWL_Widget* pWidget, + CFX_Graphics* pGraphics, + const CFX_Matrix* pMatrix) = 0; +}; + +class CFWL_WidgetMgr : public IFWL_WidgetMgrDelegate { public: explicit CFWL_WidgetMgr(CXFA_FFApp* pAdapterNative); ~CFWL_WidgetMgr(); + // IFWL_WidgetMgrDelegate + void OnSetCapability( + uint32_t dwCapability = FWL_WGTMGR_DisableThread) override; + void OnProcessMessageToForm(CFWL_Message* pMessage) override; + void OnDrawWidget(IFWL_Widget* pWidget, + CFX_Graphics* pGraphics, + const CFX_Matrix* pMatrix) override; + IFWL_Widget* GetParentWidget(IFWL_Widget* pWidget) const; IFWL_Widget* GetOwnerWidget(IFWL_Widget* pWidget) const; - IFWL_Widget* GetFirstSiblingWidget(IFWL_Widget* pWidget) const; - IFWL_Widget* GetPriorSiblingWidget(IFWL_Widget* pWidget) const; IFWL_Widget* GetNextSiblingWidget(IFWL_Widget* pWidget) const; - IFWL_Widget* GetLastSiblingWidget(IFWL_Widget* pWidget) const; IFWL_Widget* GetFirstChildWidget(IFWL_Widget* pWidget) const; - IFWL_Widget* GetLastChildWidget(IFWL_Widget* pWidget) const; IFWL_Widget* GetSystemFormWidget(IFWL_Widget* pWidget) const; - bool SetWidgetIndex(IFWL_Widget* pWidget, int32_t nIndex); - FWL_Error RepaintWidget(IFWL_Widget* pWidget, - const CFX_RectF* pRect = nullptr); + void RepaintWidget(IFWL_Widget* pWidget, const CFX_RectF* pRect = nullptr); - void AddWidget(IFWL_Widget* pWidget); void InsertWidget(IFWL_Widget* pParent, IFWL_Widget* pChild, int32_t nIndex = -1); void RemoveWidget(IFWL_Widget* pWidget); void SetOwner(IFWL_Widget* pOwner, IFWL_Widget* pOwned); void SetParent(IFWL_Widget* pParent, IFWL_Widget* pChild); - bool IsChild(IFWL_Widget* pChild, IFWL_Widget* pParent); - FWL_Error SetWidgetRect_Native(IFWL_Widget* pWidget, const CFX_RectF& rect); + + void SetWidgetRect_Native(IFWL_Widget* pWidget, const CFX_RectF& rect); + IFWL_Widget* GetWidgetAtPoint(IFWL_Widget* pParent, FX_FLOAT fx, FX_FLOAT fy); + void NotifySizeChanged(IFWL_Widget* pForm, FX_FLOAT fx, FX_FLOAT fy); - IFWL_Widget* nextTab(IFWL_Widget* parent, IFWL_Widget* focus, bool& bFind); - int32_t CountRadioButtonGroup(IFWL_Widget* pFirst); - IFWL_Widget* GetSiblingRadioButton(IFWL_Widget* pWidget, bool bNext); - IFWL_Widget* GetRadioButtonGroupHeader(IFWL_Widget* pRadioButton); + + IFWL_Widget* NextTab(IFWL_Widget* parent, IFWL_Widget* focus, bool& bFind); + void GetSameGroupRadioButton(IFWL_Widget* pRadioButton, - CFX_ArrayTemplate& group); - IFWL_Widget* GetDefaultButton(IFWL_Widget* pParent); + CFX_ArrayTemplate& group) const; + IFWL_Widget* GetDefaultButton(IFWL_Widget* pParent) const; void AddRedrawCounts(IFWL_Widget* pWidget); - void ResetRedrawCounts(IFWL_Widget* pWidget); - CXFA_FWLAdapterWidgetMgr* GetAdapterWidgetMgr() const { return m_pAdapter; } - CFWL_WidgetMgrDelegate* GetDelegate() const { return m_pDelegate.get(); } - CFWL_WidgetMgrItem* GetWidgetMgrItem(IFWL_Widget* pWidget) const; - bool IsThreadEnabled(); - bool IsFormDisabled(); - bool GetAdapterPopupPos(IFWL_Widget* pWidget, + + bool IsFormDisabled() const { + return !!(m_dwCapability & FWL_WGTMGR_DisableForm); + } + + void GetAdapterPopupPos(IFWL_Widget* pWidget, FX_FLOAT fMinHeight, FX_FLOAT fMaxHeight, const CFX_RectF& rtAnchor, - CFX_RectF& rtPopup); + CFX_RectF& rtPopup) const; - protected: - friend class CFWL_WidgetMgrDelegate; + private: + IFWL_Widget* GetFirstSiblingWidget(IFWL_Widget* pWidget) const; + IFWL_Widget* GetPriorSiblingWidget(IFWL_Widget* pWidget) const; + IFWL_Widget* GetLastChildWidget(IFWL_Widget* pWidget) const; + CFWL_WidgetMgrItem* GetWidgetMgrItem(IFWL_Widget* pWidget) const; - int32_t TravelWidgetMgr(CFWL_WidgetMgrItem* pParent, - int32_t* pIndex, - CFWL_WidgetMgrItem* pItem, - IFWL_Widget** pWidget = nullptr); - bool IsAbleNative(IFWL_Widget* pWidget) const; + void SetWidgetIndex(IFWL_Widget* pWidget, int32_t nIndex); - uint32_t m_dwCapability; - std::unique_ptr m_pDelegate; - std::map> m_mapWidgetItem; - CXFA_FWLAdapterWidgetMgr* const m_pAdapter; -#if (_FX_OS_ == _FX_WIN32_DESKTOP_) || (_FX_OS_ == _FX_WIN64_) - CFX_RectF m_rtScreen; -#endif -}; + int32_t CountRadioButtonGroup(IFWL_Widget* pFirst) const; + IFWL_Widget* GetRadioButtonGroupHeader(IFWL_Widget* pRadioButton) const; -class CFWL_WidgetMgrDelegate { - public: - explicit CFWL_WidgetMgrDelegate(CFWL_WidgetMgr* pWidgetMgr); - ~CFWL_WidgetMgrDelegate() {} + void ResetRedrawCounts(IFWL_Widget* pWidget); - FWL_Error OnSetCapability(uint32_t dwCapability = FWL_WGTMGR_DisableThread); - void OnProcessMessageToForm(CFWL_Message* pMessage); - void OnDrawWidget(IFWL_Widget* pWidget, - CFX_Graphics* pGraphics, - const CFX_Matrix* pMatrix); + bool IsThreadEnabled() const { + return !(m_dwCapability & FWL_WGTMGR_DisableThread); + } - protected: void DrawChild(IFWL_Widget* pParent, const CFX_RectF& rtClip, CFX_Graphics* pGraphics, @@ -138,9 +135,16 @@ class CFWL_WidgetMgrDelegate { bool IsNeedRepaint(IFWL_Widget* pWidget, CFX_Matrix* pMatrix, const CFX_RectF& rtDirty); - bool bUseOffscreenDirect(IFWL_Widget* pWidget); + bool UseOffscreenDirect(IFWL_Widget* pWidget) const; - CFWL_WidgetMgr* m_pWidgetMgr; + bool IsAbleNative(IFWL_Widget* pWidget) const; + + uint32_t m_dwCapability; + std::map> m_mapWidgetItem; + CXFA_FWLAdapterWidgetMgr* const m_pAdapter; +#if (_FX_OS_ == _FX_WIN32_DESKTOP_) || (_FX_OS_ == _FX_WIN64_) + CFX_RectF m_rtScreen; +#endif }; #endif // XFA_FWL_CORE_CFWL_WIDGETMGR_H_ diff --git a/xfa/fwl/core/fwl_noteimp.cpp b/xfa/fwl/core/fwl_noteimp.cpp index c17105a3f7..f04d38d81b 100644 --- a/xfa/fwl/core/fwl_noteimp.cpp +++ b/xfa/fwl/core/fwl_noteimp.cpp @@ -386,10 +386,10 @@ bool CFWL_NoteDriver::DoKey(CFWL_MsgKey* pMsg, IFWL_Widget* pMessageForm) { pFocus = nullptr; } bool bFind = false; - IFWL_Widget* pNextTabStop = pWidgetMgr->nextTab(pForm, pFocus, bFind); + IFWL_Widget* pNextTabStop = pWidgetMgr->NextTab(pForm, pFocus, bFind); if (!pNextTabStop) { bFind = false; - pNextTabStop = pWidgetMgr->nextTab(pForm, nullptr, bFind); + pNextTabStop = pWidgetMgr->NextTab(pForm, nullptr, bFind); } if (pNextTabStop == pFocus) { return true; diff --git a/xfa/fwl/core/ifwl_widget.cpp b/xfa/fwl/core/ifwl_widget.cpp index 0768f38915..c9decffe24 100644 --- a/xfa/fwl/core/ifwl_widget.cpp +++ b/xfa/fwl/core/ifwl_widget.cpp @@ -416,23 +416,26 @@ void IFWL_Widget::SetGrab(bool bSet) { pDriver->SetGrab(this, bSet); } -bool IFWL_Widget::GetPopupPos(FX_FLOAT fMinHeight, +void IFWL_Widget::GetPopupPos(FX_FLOAT fMinHeight, FX_FLOAT fMaxHeight, const CFX_RectF& rtAnchor, CFX_RectF& rtPopup) { if (GetClassID() == FWL_Type::ComboBox) { if (m_pWidgetMgr->IsFormDisabled()) { - return m_pWidgetMgr->GetAdapterPopupPos(this, fMinHeight, fMaxHeight, - rtAnchor, rtPopup); + m_pWidgetMgr->GetAdapterPopupPos(this, fMinHeight, fMaxHeight, rtAnchor, + rtPopup); + return; } - return GetPopupPosComboBox(fMinHeight, fMaxHeight, rtAnchor, rtPopup); + GetPopupPosComboBox(fMinHeight, fMaxHeight, rtAnchor, rtPopup); + return; } if (GetClassID() == FWL_Type::DateTimePicker && m_pWidgetMgr->IsFormDisabled()) { - return m_pWidgetMgr->GetAdapterPopupPos(this, fMinHeight, fMaxHeight, - rtAnchor, rtPopup); + m_pWidgetMgr->GetAdapterPopupPos(this, fMinHeight, fMaxHeight, rtAnchor, + rtPopup); + return; } - return GetPopupPosGeneral(fMinHeight, fMaxHeight, rtAnchor, rtPopup); + GetPopupPosGeneral(fMinHeight, fMaxHeight, rtAnchor, rtPopup); } bool IFWL_Widget::GetPopupPosMenu(FX_FLOAT fMinHeight, diff --git a/xfa/fwl/core/ifwl_widget.h b/xfa/fwl/core/ifwl_widget.h index 36c587b3ea..221c29d51a 100644 --- a/xfa/fwl/core/ifwl_widget.h +++ b/xfa/fwl/core/ifwl_widget.h @@ -171,7 +171,7 @@ class IFWL_Widget : public IFWL_WidgetDelegate { int32_t iTTOAlign, CFX_RectF& rect); void SetGrab(bool bSet); - bool GetPopupPos(FX_FLOAT fMinHeight, + void GetPopupPos(FX_FLOAT fMinHeight, FX_FLOAT fMaxHeight, const CFX_RectF& rtAnchor, CFX_RectF& rtPopup); diff --git a/xfa/fxfa/app/xfa_ffapp.cpp b/xfa/fxfa/app/xfa_ffapp.cpp index ccdd6427ef..b38e59090e 100644 --- a/xfa/fxfa/app/xfa_ffapp.cpp +++ b/xfa/fxfa/app/xfa_ffapp.cpp @@ -131,7 +131,7 @@ CXFA_FWLTheme* CXFA_FFApp::GetFWLTheme() { } CXFA_FWLAdapterWidgetMgr* CXFA_FFApp::GetWidgetMgr( - CFWL_WidgetMgrDelegate* pDelegate) { + IFWL_WidgetMgrDelegate* pDelegate) { if (!m_pAdapterWidgetMgr) { m_pAdapterWidgetMgr.reset(new CXFA_FWLAdapterWidgetMgr); pDelegate->OnSetCapability(FWL_WGTMGR_DisableThread | diff --git a/xfa/fxfa/app/xfa_fwladapter.cpp b/xfa/fxfa/app/xfa_fwladapter.cpp index d827ad101f..ba38f853a6 100644 --- a/xfa/fxfa/app/xfa_fwladapter.cpp +++ b/xfa/fxfa/app/xfa_fwladapter.cpp @@ -13,18 +13,17 @@ CXFA_FWLAdapterWidgetMgr::CXFA_FWLAdapterWidgetMgr() {} CXFA_FWLAdapterWidgetMgr::~CXFA_FWLAdapterWidgetMgr() {} -FWL_Error CXFA_FWLAdapterWidgetMgr::RepaintWidget(IFWL_Widget* pWidget, - const CFX_RectF* pRect) { +void CXFA_FWLAdapterWidgetMgr::RepaintWidget(IFWL_Widget* pWidget, + const CFX_RectF* pRect) { if (!pWidget) - return FWL_Error::Indefinite; + return; CXFA_FFWidget* pFFWidget = static_cast(pWidget->GetLayoutItem()); if (!pFFWidget) - return FWL_Error::Indefinite; + return; pFFWidget->AddInvalidateRect(nullptr); - return FWL_Error::Succeeded; } bool CXFA_FWLAdapterWidgetMgr::GetPopupPos(IFWL_Widget* pWidget, diff --git a/xfa/fxfa/app/xfa_fwladapter.h b/xfa/fxfa/app/xfa_fwladapter.h index cb10399ae7..489d8709ac 100644 --- a/xfa/fxfa/app/xfa_fwladapter.h +++ b/xfa/fxfa/app/xfa_fwladapter.h @@ -18,7 +18,7 @@ class CXFA_FWLAdapterWidgetMgr { CXFA_FWLAdapterWidgetMgr(); ~CXFA_FWLAdapterWidgetMgr(); - FWL_Error RepaintWidget(IFWL_Widget* pWidget, const CFX_RectF* pRect); + void RepaintWidget(IFWL_Widget* pWidget, const CFX_RectF* pRect); bool GetPopupPos(IFWL_Widget* pWidget, FX_FLOAT fMinHeight, FX_FLOAT fMaxHeight, diff --git a/xfa/fxfa/xfa_ffapp.h b/xfa/fxfa/xfa_ffapp.h index e7475de889..554b7b9328 100644 --- a/xfa/fxfa/xfa_ffapp.h +++ b/xfa/fxfa/xfa_ffapp.h @@ -16,13 +16,13 @@ #include "xfa/fwl/core/ifwl_app.h" #include "xfa/fxfa/fxfa.h" -class CFWL_WidgetMgrDelegate; class CXFA_DefFontMgr; class CXFA_FWLAdapterWidgetMgr; class CXFA_FWLTheme; class CXFA_FFDocHandler; class CXFA_FontMgr; class IFWL_AdapterTimerMgr; +class IFWL_WidgetMgrDelegate; class CXFA_FileRead : public IFX_SeekableReadStream { public: @@ -51,7 +51,7 @@ class CXFA_FFApp { void SetDefaultFontMgr(std::unique_ptr pFontMgr); CXFA_FFDocHandler* GetDocHandler(); - CXFA_FWLAdapterWidgetMgr* GetWidgetMgr(CFWL_WidgetMgrDelegate* pDelegate); + CXFA_FWLAdapterWidgetMgr* GetWidgetMgr(IFWL_WidgetMgrDelegate* pDelegate); CFGAS_FontMgr* GetFDEFontMgr(); CXFA_FWLTheme* GetFWLTheme(); @@ -59,7 +59,7 @@ class CXFA_FFApp { const IFWL_App* GetFWLApp() const { return m_pFWLApp.get(); } IFWL_AdapterTimerMgr* GetTimerMgr() const; CXFA_FontMgr* GetXFAFontMgr() const; - CFWL_WidgetMgrDelegate* GetWidgetMgrDelegate() const { + IFWL_WidgetMgrDelegate* GetWidgetMgrDelegate() const { return m_pWidgetMgrDelegate; } @@ -86,7 +86,7 @@ class CXFA_FFApp { std::unique_ptr m_pFontSource; #endif std::unique_ptr m_pAdapterWidgetMgr; - CFWL_WidgetMgrDelegate* m_pWidgetMgrDelegate; // not owned. + IFWL_WidgetMgrDelegate* m_pWidgetMgrDelegate; // not owned. // |m_pFWLApp| has to be released first, then |m_pFWLTheme| since the former // may refers to theme manager and the latter refers to font manager. -- cgit v1.2.3