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