• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2016 PDFium Authors. All rights reserved.
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_LAYOUT_CXFA_CONTENTLAYOUTITEM_H_
8 #define XFA_FXFA_LAYOUT_CXFA_CONTENTLAYOUTITEM_H_
9 
10 #include <memory>
11 
12 #include "core/fxcrt/retain_ptr.h"
13 #include "core/fxcrt/unowned_ptr.h"
14 #include "xfa/fxfa/layout/cxfa_layoutitem.h"
15 
16 class CXFA_FFWidget;
17 
18 class CXFA_ContentLayoutItem : public CXFA_LayoutItem {
19  public:
20   template <typename T, typename... Args>
21   friend RetainPtr<T> pdfium::MakeRetain(Args&&... args);
22 
23   ~CXFA_ContentLayoutItem() override;
24 
GetFFWidget()25   CXFA_FFWidget* GetFFWidget() { return m_pFFWidget.get(); }
26 
27   CXFA_ContentLayoutItem* GetFirst();
28   CXFA_ContentLayoutItem* GetLast();
GetPrev()29   CXFA_ContentLayoutItem* GetPrev() const { return m_pPrev.Get(); }
GetNext()30   CXFA_ContentLayoutItem* GetNext() const { return m_pNext.Get(); }
31   void InsertAfter(CXFA_ContentLayoutItem* pNext);
32 
33   CFX_RectF GetRect(bool bRelative) const;
34   size_t GetIndex() const;
35 
SetStatusBits(uint32_t val)36   void SetStatusBits(uint32_t val) { m_dwStatus |= val; }
ClearStatusBits(uint32_t val)37   void ClearStatusBits(uint32_t val) { m_dwStatus &= ~val; }
38 
39   // TRUE if all (not any) bits set in |val| are set in |m_dwStatus|.
TestStatusBits(uint32_t val)40   bool TestStatusBits(uint32_t val) const { return (m_dwStatus & val) == val; }
41 
42   CFX_PointF m_sPos;
43   CFX_SizeF m_sSize;
44 
45  private:
46   CXFA_ContentLayoutItem(CXFA_Node* pNode,
47                          std::unique_ptr<CXFA_FFWidget> pFFWidget);
48 
49   void RemoveSelf();
50 
51   mutable uint32_t m_dwStatus = 0;
52   UnownedPtr<CXFA_ContentLayoutItem> m_pPrev;
53   UnownedPtr<CXFA_ContentLayoutItem> m_pNext;
54   std::unique_ptr<CXFA_FFWidget> const m_pFFWidget;
55 };
56 
GetFFWidget(CXFA_ContentLayoutItem * item)57 inline CXFA_FFWidget* GetFFWidget(CXFA_ContentLayoutItem* item) {
58   return item ? item->GetFFWidget() : nullptr;
59 }
60 
61 #endif  // XFA_FXFA_LAYOUT_CXFA_CONTENTLAYOUTITEM_H_
62