diff options
-rw-r--r-- | xfa/fxfa/cxfa_ffpageview.cpp | 61 | ||||
-rw-r--r-- | xfa/fxfa/cxfa_ffpageview.h | 8 | ||||
-rw-r--r-- | xfa/fxfa/cxfa_ffwidget.cpp | 4 | ||||
-rw-r--r-- | xfa/fxfa/cxfa_ffwidget.h | 8 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_contentlayoutitem.h | 2 |
5 files changed, 52 insertions, 31 deletions
diff --git a/xfa/fxfa/cxfa_ffpageview.cpp b/xfa/fxfa/cxfa_ffpageview.cpp index e64aee58ba..4c0b3cf638 100644 --- a/xfa/fxfa/cxfa_ffpageview.cpp +++ b/xfa/fxfa/cxfa_ffpageview.cpp @@ -151,6 +151,7 @@ CXFA_FFPageWidgetIterator::~CXFA_FFPageWidgetIterator() {} void CXFA_FFPageWidgetIterator::Reset() { m_sIterator.Reset(); } + CXFA_FFWidget* CXFA_FFPageWidgetIterator::MoveToFirst() { m_sIterator.Reset(); for (CXFA_LayoutItem* pLayoutItem = m_sIterator.GetCurrent(); pLayoutItem; @@ -161,10 +162,12 @@ CXFA_FFWidget* CXFA_FFPageWidgetIterator::MoveToFirst() { } return nullptr; } + CXFA_FFWidget* CXFA_FFPageWidgetIterator::MoveToLast() { m_sIterator.SetCurrent(nullptr); return MoveToPrevious(); } + CXFA_FFWidget* CXFA_FFPageWidgetIterator::MoveToNext() { for (CXFA_LayoutItem* pLayoutItem = m_sIterator.MoveToNext(); pLayoutItem; pLayoutItem = m_sIterator.MoveToNext()) { @@ -174,6 +177,7 @@ CXFA_FFWidget* CXFA_FFPageWidgetIterator::MoveToNext() { } return nullptr; } + CXFA_FFWidget* CXFA_FFPageWidgetIterator::MoveToPrevious() { for (CXFA_LayoutItem* pLayoutItem = m_sIterator.MoveToPrev(); pLayoutItem; pLayoutItem = m_sIterator.MoveToPrev()) { @@ -183,26 +187,40 @@ CXFA_FFWidget* CXFA_FFPageWidgetIterator::MoveToPrevious() { } return nullptr; } + CXFA_FFWidget* CXFA_FFPageWidgetIterator::GetCurrentWidget() { CXFA_LayoutItem* pLayoutItem = m_sIterator.GetCurrent(); return pLayoutItem ? XFA_GetWidgetFromLayoutItem(pLayoutItem) : nullptr; } + bool CXFA_FFPageWidgetIterator::SetCurrentWidget(CXFA_FFWidget* hWidget) { return hWidget && m_sIterator.SetCurrent(hWidget); } + CXFA_FFWidget* CXFA_FFPageWidgetIterator::GetWidget( CXFA_LayoutItem* pLayoutItem) { - if (CXFA_FFWidget* pWidget = XFA_GetWidgetFromLayoutItem(pLayoutItem)) { - if (!PageWidgetFilter(pWidget, m_dwFilter, false, m_bIgnorerelevant)) { - return nullptr; - } - if (!pWidget->IsLoaded() && - (pWidget->GetStatus() & XFA_WidgetStatus_Visible) != 0) { - pWidget->LoadWidget(); - } - return pWidget; + CXFA_FFWidget* pWidget = XFA_GetWidgetFromLayoutItem(pLayoutItem); + if (!pWidget) + return nullptr; + + if (!PageWidgetFilter(pWidget, m_dwFilter, false, m_bIgnorerelevant)) + return nullptr; + + if (!pWidget->IsLoaded() && + !!(pWidget->GetStatus() & XFA_WidgetStatus_Visible)) { + pWidget->LoadWidget(); } - return nullptr; + return pWidget; +} + +void CXFA_TabParam::AppendTabParam(CXFA_TabParam* pParam) { + m_Children.push_back(pParam->GetWidget()); + m_Children.insert(m_Children.end(), pParam->GetChildren().begin(), + pParam->GetChildren().end()); +} + +void CXFA_TabParam::ClearChildren() { + m_Children.clear(); } CXFA_FFTabOrderPageWidgetIterator::CXFA_FFTabOrderPageWidgetIterator( @@ -398,19 +416,16 @@ void CXFA_FFTabOrderPageWidgetIterator::OrderContainer( std::sort(tabParams.begin(), tabParams.end(), [](const std::unique_ptr<CXFA_TabParam>& arg1, const std::unique_ptr<CXFA_TabParam>& arg2) { - CFX_RectF rt1 = arg1->m_pWidget->GetWidgetRect(); - CFX_RectF rt2 = arg2->m_pWidget->GetWidgetRect(); + const CFX_RectF& rt1 = arg1->GetWidget()->GetWidgetRect(); + const CFX_RectF& rt2 = arg2->GetWidget()->GetWidgetRect(); if (rt1.top - rt2.top >= XFA_FLOAT_PERCISION) return rt1.top < rt2.top; return rt1.left < rt2.left; }); - for (const auto& pParam : tabParams) { - pContainer->m_Children.push_back(pParam->m_pWidget); - pContainer->m_Children.insert(pContainer->m_Children.end(), - pParam->m_Children.begin(), - pParam->m_Children.end()); - } + for (const auto& pParam : tabParams) + pContainer->AppendTabParam(pParam.get()); } + void CXFA_FFTabOrderPageWidgetIterator::CreateSpaceOrderWidgetArray( std::vector<CXFA_FFWidget*>* WidgetArray) { CXFA_LayoutItemIterator sIterator(m_pPageView); @@ -418,17 +433,17 @@ void CXFA_FFTabOrderPageWidgetIterator::CreateSpaceOrderWidgetArray( bool bCurrentItem = false; bool bContentArea = false; OrderContainer(&sIterator, nullptr, pParam.get(), bCurrentItem, bContentArea); - WidgetArray->insert(WidgetArray->end(), pParam->m_Children.begin(), - pParam->m_Children.end()); + WidgetArray->insert(WidgetArray->end(), pParam->GetChildren().begin(), + pParam->GetChildren().end()); sIterator.Reset(); bCurrentItem = false; bContentArea = false; - pParam->m_Children.clear(); + pParam->ClearChildren(); OrderContainer(&sIterator, nullptr, pParam.get(), bCurrentItem, bContentArea, true); - WidgetArray->insert(WidgetArray->end(), pParam->m_Children.begin(), - pParam->m_Children.end()); + WidgetArray->insert(WidgetArray->end(), pParam->GetChildren().begin(), + pParam->GetChildren().end()); } CXFA_FFWidget* CXFA_FFTabOrderPageWidgetIterator::GetWidget( diff --git a/xfa/fxfa/cxfa_ffpageview.h b/xfa/fxfa/cxfa_ffpageview.h index 9fcca3add6..a0aa5227c1 100644 --- a/xfa/fxfa/cxfa_ffpageview.h +++ b/xfa/fxfa/cxfa_ffpageview.h @@ -65,7 +65,13 @@ class CXFA_TabParam { explicit CXFA_TabParam(CXFA_FFWidget* pWidget); ~CXFA_TabParam(); - CXFA_FFWidget* m_pWidget; + void AppendTabParam(CXFA_TabParam* pParam); + void ClearChildren(); + CXFA_FFWidget* GetWidget() { return m_pWidget; } + const std::vector<CXFA_FFWidget*>& GetChildren() const { return m_Children; } + + private: + CXFA_FFWidget* const m_pWidget; std::vector<CXFA_FFWidget*> m_Children; }; diff --git a/xfa/fxfa/cxfa_ffwidget.cpp b/xfa/fxfa/cxfa_ffwidget.cpp index 2e9c9a6ac8..a74c6d7057 100644 --- a/xfa/fxfa/cxfa_ffwidget.cpp +++ b/xfa/fxfa/cxfa_ffwidget.cpp @@ -43,13 +43,13 @@ const CFWL_App* CXFA_FFWidget::GetFWLApp() { return GetPageView()->GetDocView()->GetDoc()->GetApp()->GetFWLApp(); } -CFX_RectF CXFA_FFWidget::GetWidgetRect() { +const CFX_RectF& CXFA_FFWidget::GetWidgetRect() const { if ((m_dwStatus & XFA_WidgetStatus_RectCached) == 0) RecacheWidgetRect(); return m_rtWidget; } -CFX_RectF CXFA_FFWidget::RecacheWidgetRect() { +const CFX_RectF& CXFA_FFWidget::RecacheWidgetRect() const { m_dwStatus |= XFA_WidgetStatus_RectCached; m_rtWidget = GetRect(false); return m_rtWidget; diff --git a/xfa/fxfa/cxfa_ffwidget.h b/xfa/fxfa/cxfa_ffwidget.h index 8c83c4cf4c..ef3d908221 100644 --- a/xfa/fxfa/cxfa_ffwidget.h +++ b/xfa/fxfa/cxfa_ffwidget.h @@ -142,8 +142,8 @@ class CXFA_FFWidget : public CXFA_ContentLayoutItem { CXFA_FFPageView* GetPageView() const { return m_pPageView; } void SetPageView(CXFA_FFPageView* pPageView) { m_pPageView = pPageView; } - CFX_RectF GetWidgetRect(); - CFX_RectF RecacheWidgetRect(); + const CFX_RectF& GetWidgetRect() const; + const CFX_RectF& RecacheWidgetRect() const; uint32_t GetStatus(); void ModifyStatus(uint32_t dwAdded, uint32_t dwRemoved); @@ -183,8 +183,8 @@ class CXFA_FFWidget : public CXFA_ContentLayoutItem { CXFA_FFDocView* m_pDocView; CXFA_FFPageView* m_pPageView; - CXFA_WidgetAcc* m_pDataAcc; - CFX_RectF m_rtWidget; + CXFA_WidgetAcc* const m_pDataAcc; + mutable CFX_RectF m_rtWidget; }; #endif // XFA_FXFA_CXFA_FFWIDGET_H_ diff --git a/xfa/fxfa/parser/cxfa_contentlayoutitem.h b/xfa/fxfa/parser/cxfa_contentlayoutitem.h index 9ac1dceb42..500d3e4959 100644 --- a/xfa/fxfa/parser/cxfa_contentlayoutitem.h +++ b/xfa/fxfa/parser/cxfa_contentlayoutitem.h @@ -18,7 +18,7 @@ class CXFA_ContentLayoutItem : public CXFA_LayoutItem { CXFA_ContentLayoutItem* m_pNext; CFX_PointF m_sPos; CFX_SizeF m_sSize; - uint32_t m_dwStatus; + mutable uint32_t m_dwStatus; }; inline CXFA_ContentLayoutItem* ToContentLayoutItem(CXFA_LayoutItem* pItem) { |