1 // Copyright 2014 The PDFium Authors 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 6 7 #ifndef XFA_FXFA_CXFA_FFPAGEVIEW_H_ 8 #define XFA_FXFA_CXFA_FFPAGEVIEW_H_ 9 10 #include <vector> 11 12 #include "core/fxcrt/mask.h" 13 #include "core/fxcrt/widestring.h" 14 #include "fxjs/gc/heap.h" 15 #include "v8/include/cppgc/garbage-collected.h" 16 #include "v8/include/cppgc/member.h" 17 #include "v8/include/cppgc/visitor.h" 18 #include "xfa/fxfa/cxfa_ffwidget.h" 19 #include "xfa/fxfa/layout/cxfa_contentlayoutitem.h" 20 #include "xfa/fxfa/layout/cxfa_traversestrategy_layoutitem.h" 21 #include "xfa/fxfa/layout/cxfa_viewlayoutitem.h" 22 23 class CXFA_FFWidget; 24 class CXFA_FFDocView; 25 26 class CXFA_FFPageView final : public cppgc::GarbageCollected<CXFA_FFPageView> { 27 public: 28 CONSTRUCT_VIA_MAKE_GARBAGE_COLLECTED; 29 ~CXFA_FFPageView(); 30 31 void Trace(cppgc::Visitor* visitor) const; 32 GetLayoutItem()33 CXFA_ViewLayoutItem* GetLayoutItem() const { return m_pLayoutItem; } SetLayoutItem(CXFA_ViewLayoutItem * pItem)34 void SetLayoutItem(CXFA_ViewLayoutItem* pItem) { m_pLayoutItem = pItem; } 35 36 CXFA_FFDocView* GetDocView() const; 37 CFX_RectF GetPageViewRect() const; 38 CFX_Matrix GetDisplayMatrix(const FX_RECT& rtDisp, int32_t iRotate) const; 39 40 // This always returns a non-null iterator from the gc heap. 41 CXFA_FFWidget::IteratorIface* CreateGCedTraverseWidgetIterator( 42 Mask<XFA_WidgetStatus> dwWidgetFilter); 43 44 private: 45 CXFA_FFPageView(CXFA_FFDocView* pDocView, CXFA_Node* pPageArea); 46 47 cppgc::Member<CXFA_Node> const m_pPageArea; 48 cppgc::Member<CXFA_FFDocView> const m_pDocView; 49 cppgc::Member<CXFA_ViewLayoutItem> m_pLayoutItem; 50 }; 51 52 class CXFA_FFPageWidgetIterator final : public CXFA_FFWidget::IteratorIface { 53 CPPGC_STACK_ALLOCATED(); 54 55 public: 56 CXFA_FFPageWidgetIterator(CXFA_FFPageView* pPageView, 57 Mask<XFA_WidgetStatus> dwFilter); 58 ~CXFA_FFPageWidgetIterator() override; 59 60 // CXFA_FFWidget::IteratorIface: 61 CXFA_FFWidget* MoveToFirst() override; 62 CXFA_FFWidget* MoveToLast() override; 63 CXFA_FFWidget* MoveToNext() override; 64 CXFA_FFWidget* MoveToPrevious() override; 65 CXFA_FFWidget* GetCurrentWidget() override; 66 bool SetCurrentWidget(CXFA_FFWidget* hWidget) override; 67 68 private: 69 CXFA_LayoutItemIterator m_sIterator; 70 const Mask<XFA_WidgetStatus> m_dwFilter; 71 const bool m_bIgnoreRelevant; 72 }; 73 74 class CXFA_FFTabOrderPageWidgetIterator final 75 : public cppgc::GarbageCollected<CXFA_FFTabOrderPageWidgetIterator>, 76 public CXFA_FFWidget::IteratorIface { 77 public: 78 CONSTRUCT_VIA_MAKE_GARBAGE_COLLECTED; 79 ~CXFA_FFTabOrderPageWidgetIterator() override; 80 81 void Trace(cppgc::Visitor* visitor) const; 82 83 // CXFA_FFWidget::IteratorIface: 84 CXFA_FFWidget* MoveToFirst() override; 85 CXFA_FFWidget* MoveToLast() override; 86 CXFA_FFWidget* MoveToNext() override; 87 CXFA_FFWidget* MoveToPrevious() override; 88 CXFA_FFWidget* GetCurrentWidget() override; 89 bool SetCurrentWidget(CXFA_FFWidget* hWidget) override; 90 91 private: 92 CXFA_FFTabOrderPageWidgetIterator(CXFA_FFPageView* pPageView, 93 Mask<XFA_WidgetStatus> dwFilter); 94 95 CXFA_FFWidget* GetTraverseWidget(CXFA_FFWidget* pWidget); 96 CXFA_FFWidget* FindWidgetByName(const WideString& wsWidgetName, 97 CXFA_FFWidget* pRefWidget); 98 void CreateTabOrderWidgetArray(); 99 std::vector<CXFA_ContentLayoutItem*> CreateSpaceOrderLayoutItems(); 100 101 cppgc::Member<CXFA_ViewLayoutItem> const m_pPageViewLayout; 102 std::vector<cppgc::Member<CXFA_ContentLayoutItem>> m_TabOrderWidgetArray; 103 const Mask<XFA_WidgetStatus> m_dwFilter; 104 int32_t m_iCurWidget = -1; 105 const bool m_bIgnoreRelevant; 106 }; 107 108 #endif // XFA_FXFA_CXFA_FFPAGEVIEW_H_ 109