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