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 XFA_FDE_CSS_FDE_CSS_H_ 8 #define XFA_FDE_CSS_FDE_CSS_H_ 9 10 #include "core/fxge/fx_dib.h" 11 #include "xfa/fgas/crt/fgas_stream.h" 12 #include "xfa/fgas/crt/fgas_utils.h" 13 #include "xfa/fgas/font/cfgas_fontmgr.h" 14 15 enum FDE_CSSVALUETYPE { 16 FDE_CSSVALUETYPE_Primitive = 1 << 0, 17 FDE_CSSVALUETYPE_List = 1 << 1, 18 FDE_CSSVALUETYPE_Shorthand = 1 << 2, 19 // Note the values below this comment must be > 0x0F so we can mask the above. 20 FDE_CSSVALUETYPE_MaybeNumber = 1 << 4, 21 FDE_CSSVALUETYPE_MaybeEnum = 1 << 5, 22 FDE_CSSVALUETYPE_MaybeString = 1 << 7, 23 FDE_CSSVALUETYPE_MaybeColor = 1 << 8 24 }; 25 26 enum class FDE_CSSPrimitiveType : uint8_t { 27 Unknown = 0, 28 Number, 29 String, 30 RGB, 31 Enum, 32 Function, 33 List, 34 }; 35 36 enum class FDE_CSSPropertyValue : uint8_t { 37 Bolder = 0, 38 None, 39 Dot, 40 Sub, 41 Top, 42 Right, 43 Normal, 44 Auto, 45 Text, 46 XSmall, 47 Thin, 48 Small, 49 Bottom, 50 Underline, 51 Double, 52 Lighter, 53 Oblique, 54 Super, 55 Center, 56 XxLarge, 57 Smaller, 58 Baseline, 59 Thick, 60 Justify, 61 Middle, 62 Medium, 63 ListItem, 64 XxSmall, 65 Bold, 66 SmallCaps, 67 Inline, 68 Overline, 69 TextBottom, 70 Larger, 71 InlineTable, 72 InlineBlock, 73 Blink, 74 Block, 75 Italic, 76 LineThrough, 77 XLarge, 78 Large, 79 Left, 80 TextTop, 81 LAST_MARKER 82 }; 83 84 enum class FDE_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 LAST_MARKER 126 }; 127 128 enum class FDE_CSSSelectorType : uint8_t { Element = 0, Descendant }; 129 130 enum class FDE_CSSLengthUnit : uint8_t { 131 Auto, 132 None, 133 Normal, 134 Point, 135 Percent, 136 }; 137 138 enum class FDE_CSSDisplay : uint8_t { 139 None, 140 ListItem, 141 Block, 142 Inline, 143 InlineBlock, 144 InlineTable, 145 }; 146 147 enum class FDE_CSSFontStyle : uint8_t { 148 Normal, 149 Italic, 150 }; 151 152 enum class FDE_CSSTextAlign : uint8_t { 153 Left, 154 Right, 155 Center, 156 Justify, 157 JustifyAll, 158 }; 159 160 enum class FDE_CSSVerticalAlign : uint8_t { 161 Baseline, 162 Sub, 163 Super, 164 Top, 165 TextTop, 166 Middle, 167 Bottom, 168 TextBottom, 169 Number, 170 }; 171 172 enum class FDE_CSSFontVariant : uint8_t { 173 Normal, 174 SmallCaps, 175 }; 176 177 enum FDE_CSSTEXTDECORATION { 178 FDE_CSSTEXTDECORATION_None = 0, 179 FDE_CSSTEXTDECORATION_Underline = 1 << 0, 180 FDE_CSSTEXTDECORATION_Overline = 1 << 1, 181 FDE_CSSTEXTDECORATION_LineThrough = 1 << 2, 182 FDE_CSSTEXTDECORATION_Blink = 1 << 3, 183 FDE_CSSTEXTDECORATION_Double = 1 << 4, 184 }; 185 186 class FDE_CSSLength { 187 public: FDE_CSSLength()188 FDE_CSSLength() {} 189 FDE_CSSLength(FDE_CSSLengthUnit eUnit)190 explicit FDE_CSSLength(FDE_CSSLengthUnit eUnit) : m_unit(eUnit) {} 191 FDE_CSSLength(FDE_CSSLengthUnit eUnit,FX_FLOAT fValue)192 FDE_CSSLength(FDE_CSSLengthUnit eUnit, FX_FLOAT fValue) 193 : m_unit(eUnit), m_fValue(fValue) {} 194 Set(FDE_CSSLengthUnit eUnit)195 FDE_CSSLength& Set(FDE_CSSLengthUnit eUnit) { 196 m_unit = eUnit; 197 return *this; 198 } 199 Set(FDE_CSSLengthUnit eUnit,FX_FLOAT fValue)200 FDE_CSSLength& Set(FDE_CSSLengthUnit eUnit, FX_FLOAT fValue) { 201 m_unit = eUnit; 202 m_fValue = fValue; 203 return *this; 204 } 205 GetUnit()206 FDE_CSSLengthUnit GetUnit() const { return m_unit; } 207 GetValue()208 FX_FLOAT GetValue() const { return m_fValue; } NonZero()209 bool NonZero() const { return static_cast<int>(m_fValue) != 0; } 210 211 private: 212 FDE_CSSLengthUnit m_unit; 213 FX_FLOAT m_fValue; 214 }; 215 216 class FDE_CSSRect { 217 public: FDE_CSSRect()218 FDE_CSSRect() {} 219 FDE_CSSRect(FDE_CSSLengthUnit eUnit,FX_FLOAT val)220 FDE_CSSRect(FDE_CSSLengthUnit eUnit, FX_FLOAT val) 221 : left(eUnit, val), 222 top(eUnit, val), 223 right(eUnit, val), 224 bottom(eUnit, val) {} 225 Set(FDE_CSSLengthUnit eUnit)226 FDE_CSSRect& Set(FDE_CSSLengthUnit eUnit) { 227 left.Set(eUnit); 228 top.Set(eUnit); 229 right.Set(eUnit); 230 bottom.Set(eUnit); 231 return *this; 232 } Set(FDE_CSSLengthUnit eUnit,FX_FLOAT fValue)233 FDE_CSSRect& Set(FDE_CSSLengthUnit eUnit, FX_FLOAT fValue) { 234 left.Set(eUnit, fValue); 235 top.Set(eUnit, fValue); 236 right.Set(eUnit, fValue); 237 bottom.Set(eUnit, fValue); 238 return *this; 239 } 240 241 FDE_CSSLength left, top, right, bottom; 242 }; 243 244 #endif // XFA_FDE_CSS_FDE_CSS_H_ 245