• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2017 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_FDE_CSS_CFDE_CSSCOMPUTEDSTYLE_H_
8 #define XFA_FDE_CSS_CFDE_CSSCOMPUTEDSTYLE_H_
9 
10 #include <vector>
11 
12 #include "core/fxcrt/fx_basic.h"
13 #include "core/fxcrt/fx_string.h"
14 #include "xfa/fde/css/cfde_csscustomproperty.h"
15 #include "xfa/fde/css/fde_css.h"
16 
17 class CFDE_CSSValueList;
18 
19 class CFDE_CSSComputedStyle : public CFX_Retainable {
20  public:
21   class InheritedData {
22    public:
23     InheritedData();
24     ~InheritedData();
25 
26     FDE_CSSLength m_LetterSpacing;
27     FDE_CSSLength m_WordSpacing;
28     FDE_CSSLength m_TextIndent;
29     CFX_RetainPtr<CFDE_CSSValueList> m_pFontFamily;
30     FX_FLOAT m_fFontSize;
31     FX_FLOAT m_fLineHeight;
32     FX_ARGB m_dwFontColor;
33     uint16_t m_wFontWeight;
34     FDE_CSSFontVariant m_eFontVariant;
35     FDE_CSSFontStyle m_eFontStyle;
36     FDE_CSSTextAlign m_eTextAlign;
37   };
38 
39   class NonInheritedData {
40    public:
41     NonInheritedData();
42 
43     FDE_CSSRect m_MarginWidth;
44     FDE_CSSRect m_BorderWidth;
45     FDE_CSSRect m_PaddingWidth;
46     FDE_CSSLength m_Top;
47     FDE_CSSLength m_Bottom;
48     FDE_CSSLength m_Left;
49     FDE_CSSLength m_Right;
50     FX_FLOAT m_fVerticalAlign;
51     FDE_CSSDisplay m_eDisplay;
52     FDE_CSSVerticalAlign m_eVerticalAlign;
53     uint8_t m_dwTextDecoration;
54     bool m_bHasMargin;
55     bool m_bHasBorder;
56     bool m_bHasPadding;
57   };
58 
59   int32_t CountFontFamilies() const;
60   const CFX_WideString GetFontFamily(int32_t index) const;
61   uint16_t GetFontWeight() const;
62   FDE_CSSFontVariant GetFontVariant() const;
63   FDE_CSSFontStyle GetFontStyle() const;
64   FX_FLOAT GetFontSize() const;
65   FX_ARGB GetColor() const;
66   void SetFontWeight(uint16_t wFontWeight);
67   void SetFontVariant(FDE_CSSFontVariant eFontVariant);
68   void SetFontStyle(FDE_CSSFontStyle eFontStyle);
69   void SetFontSize(FX_FLOAT fFontSize);
70   void SetColor(FX_ARGB dwFontColor);
71 
72   const FDE_CSSRect* GetBorderWidth() const;
73   const FDE_CSSRect* GetMarginWidth() const;
74   const FDE_CSSRect* GetPaddingWidth() const;
75   void SetMarginWidth(const FDE_CSSRect& rect);
76   void SetPaddingWidth(const FDE_CSSRect& rect);
77 
78   FDE_CSSDisplay GetDisplay() const;
79 
80   FX_FLOAT GetLineHeight() const;
81   const FDE_CSSLength& GetTextIndent() const;
82   FDE_CSSTextAlign GetTextAlign() const;
83   FDE_CSSVerticalAlign GetVerticalAlign() const;
84   FX_FLOAT GetNumberVerticalAlign() const;
85   uint32_t GetTextDecoration() const;
86   const FDE_CSSLength& GetLetterSpacing() const;
87   void SetLineHeight(FX_FLOAT fLineHeight);
88   void SetTextIndent(const FDE_CSSLength& textIndent);
89   void SetTextAlign(FDE_CSSTextAlign eTextAlign);
90   void SetNumberVerticalAlign(FX_FLOAT fAlign);
91   void SetTextDecoration(uint32_t dwTextDecoration);
92   void SetLetterSpacing(const FDE_CSSLength& letterSpacing);
93   void AddCustomStyle(const CFDE_CSSCustomProperty& prop);
94 
95   bool GetCustomStyle(const CFX_WideString& wsName,
96                       CFX_WideString& wsValue) const;
97 
98   InheritedData m_InheritedData;
99   NonInheritedData m_NonInheritedData;
100 
101  private:
102   template <typename T, typename... Args>
103   friend CFX_RetainPtr<T> pdfium::MakeRetain(Args&&... args);
104 
105   CFDE_CSSComputedStyle();
106   ~CFDE_CSSComputedStyle() override;
107 
108   std::vector<CFDE_CSSCustomProperty> m_CustomProperties;
109 };
110 
111 #endif  // XFA_FDE_CSS_CFDE_CSSCOMPUTEDSTYLE_H_
112