1 // Copyright 2014 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_CSS_H_ 8 #define CORE_FXCRT_CSS_CFX_CSS_H_ 9 10 #include <stdint.h> 11 12 enum CFX_CSSVALUETYPE { 13 CFX_CSSVALUETYPE_Primitive = 1 << 0, 14 CFX_CSSVALUETYPE_List = 1 << 1, 15 CFX_CSSVALUETYPE_Shorthand = 1 << 2, 16 // Note the values below this comment must be > 0x0F so we can mask the above. 17 CFX_CSSVALUETYPE_MaybeNumber = 1 << 4, 18 CFX_CSSVALUETYPE_MaybeEnum = 1 << 5, 19 CFX_CSSVALUETYPE_MaybeString = 1 << 7, 20 CFX_CSSVALUETYPE_MaybeColor = 1 << 8 21 }; 22 23 enum class CFX_CSSPrimitiveType : uint8_t { 24 Unknown = 0, 25 Number, 26 String, 27 RGB, 28 Enum, 29 Function, 30 List, 31 }; 32 33 // Any entries added/removed here, will need to be mirrored in 34 // propertyValueTable, in core/fxcrt/css/cfx_cssdata.cpp. 35 enum class CFX_CSSPropertyValue : uint8_t { 36 Bolder = 0, 37 None, 38 Dot, 39 Sub, 40 Top, 41 Right, 42 Normal, 43 Auto, 44 Text, 45 XSmall, 46 Thin, 47 Small, 48 Bottom, 49 Underline, 50 Double, 51 Lighter, 52 Oblique, 53 Super, 54 Center, 55 XxLarge, 56 Smaller, 57 Baseline, 58 Thick, 59 Justify, 60 Middle, 61 Medium, 62 ListItem, 63 XxSmall, 64 Bold, 65 SmallCaps, 66 Inline, 67 Overline, 68 TextBottom, 69 Larger, 70 InlineTable, 71 InlineBlock, 72 Blink, 73 Block, 74 Italic, 75 LineThrough, 76 XLarge, 77 Large, 78 Left, 79 TextTop, 80 }; 81 82 // Any entries added/removed here, will need to be mirrored in 83 // propertyTable, in core/fxcrt/css/cfx_cssdata.cpp. 84 enum class CFX_CSSProperty : uint8_t { 85 BorderLeft = 0, 86 Top, 87 Margin, 88 TextIndent, 89 Right, 90 PaddingLeft, 91 MarginLeft, 92 Border, 93 BorderTop, 94 Bottom, 95 PaddingRight, 96 BorderBottom, 97 FontFamily, 98 FontWeight, 99 Color, 100 LetterSpacing, 101 TextAlign, 102 BorderRightWidth, 103 VerticalAlign, 104 PaddingTop, 105 FontVariant, 106 BorderWidth, 107 BorderBottomWidth, 108 BorderRight, 109 FontSize, 110 BorderSpacing, 111 FontStyle, 112 Font, 113 LineHeight, 114 MarginRight, 115 BorderLeftWidth, 116 Display, 117 PaddingBottom, 118 BorderTopWidth, 119 WordSpacing, 120 Left, 121 TextDecoration, 122 Padding, 123 MarginBottom, 124 MarginTop, 125 }; 126 127 enum class CFX_CSSSelectorType : uint8_t { Element = 0, Descendant }; 128 129 enum class CFX_CSSLengthUnit : uint8_t { 130 Auto, 131 None, 132 Normal, 133 Point, 134 Percent, 135 }; 136 137 enum class CFX_CSSDisplay : uint8_t { 138 None, 139 ListItem, 140 Block, 141 Inline, 142 InlineBlock, 143 InlineTable, 144 }; 145 146 enum class CFX_CSSFontStyle : uint8_t { 147 Normal, 148 Italic, 149 }; 150 151 enum class CFX_CSSTextAlign : uint8_t { 152 Left, 153 Right, 154 Center, 155 Justify, 156 JustifyAll, 157 }; 158 159 enum class CFX_CSSVerticalAlign : uint8_t { 160 Baseline, 161 Sub, 162 Super, 163 Top, 164 TextTop, 165 Middle, 166 Bottom, 167 TextBottom, 168 Number, 169 }; 170 171 enum class CFX_CSSFontVariant : uint8_t { 172 Normal, 173 SmallCaps, 174 }; 175 176 enum CFX_CSSTEXTDECORATION { 177 CFX_CSSTEXTDECORATION_None = 0, 178 CFX_CSSTEXTDECORATION_Underline = 1 << 0, 179 CFX_CSSTEXTDECORATION_Overline = 1 << 1, 180 CFX_CSSTEXTDECORATION_LineThrough = 1 << 2, 181 CFX_CSSTEXTDECORATION_Blink = 1 << 3, 182 CFX_CSSTEXTDECORATION_Double = 1 << 4, 183 }; 184 185 class CFX_CSSLength { 186 public: CFX_CSSLength()187 CFX_CSSLength() {} 188 CFX_CSSLength(CFX_CSSLengthUnit eUnit,float fValue)189 CFX_CSSLength(CFX_CSSLengthUnit eUnit, float fValue) 190 : m_unit(eUnit), m_fValue(fValue) {} 191 Set(CFX_CSSLengthUnit eUnit)192 CFX_CSSLength& Set(CFX_CSSLengthUnit eUnit) { 193 m_unit = eUnit; 194 return *this; 195 } 196 Set(CFX_CSSLengthUnit eUnit,float fValue)197 CFX_CSSLength& Set(CFX_CSSLengthUnit eUnit, float fValue) { 198 m_unit = eUnit; 199 m_fValue = fValue; 200 return *this; 201 } 202 GetUnit()203 CFX_CSSLengthUnit GetUnit() const { return m_unit; } 204 GetValue()205 float GetValue() const { return m_fValue; } NonZero()206 bool NonZero() const { return static_cast<int>(m_fValue) != 0; } 207 208 private: 209 CFX_CSSLengthUnit m_unit; 210 float m_fValue; 211 }; 212 213 class CFX_CSSRect { 214 public: CFX_CSSRect()215 CFX_CSSRect() {} 216 CFX_CSSRect(CFX_CSSLengthUnit eUnit,float val)217 CFX_CSSRect(CFX_CSSLengthUnit eUnit, float val) 218 : left(eUnit, val), 219 top(eUnit, val), 220 right(eUnit, val), 221 bottom(eUnit, val) {} 222 Set(CFX_CSSLengthUnit eUnit)223 CFX_CSSRect& Set(CFX_CSSLengthUnit eUnit) { 224 left.Set(eUnit); 225 top.Set(eUnit); 226 right.Set(eUnit); 227 bottom.Set(eUnit); 228 return *this; 229 } Set(CFX_CSSLengthUnit eUnit,float fValue)230 CFX_CSSRect& Set(CFX_CSSLengthUnit eUnit, float fValue) { 231 left.Set(eUnit, fValue); 232 top.Set(eUnit, fValue); 233 right.Set(eUnit, fValue); 234 bottom.Set(eUnit, fValue); 235 return *this; 236 } 237 238 CFX_CSSLength left; 239 CFX_CSSLength top; 240 CFX_CSSLength right; 241 CFX_CSSLength bottom; 242 }; 243 244 #endif // CORE_FXCRT_CSS_CFX_CSS_H_ 245