1 /* 2 Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org> 3 2004, 2005 Rob Buis <buis@kde.org> 4 Copyright (C) Research In Motion Limited 2010. All rights reserved. 5 6 Based on khtml code by: 7 Copyright (C) 2000-2003 Lars Knoll (knoll@kde.org) 8 (C) 2000 Antti Koivisto (koivisto@kde.org) 9 (C) 2000-2003 Dirk Mueller (mueller@kde.org) 10 (C) 2002-2003 Apple Computer, Inc. 11 12 This library is free software; you can redistribute it and/or 13 modify it under the terms of the GNU Library General Public 14 License as published by the Free Software Foundation; either 15 version 2 of the License, or (at your option) any later version. 16 17 This library is distributed in the hope that it will be useful, 18 but WITHOUT ANY WARRANTY; without even the implied warranty of 19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20 Library General Public License for more details. 21 22 You should have received a copy of the GNU Library General Public License 23 along with this library; see the file COPYING.LIB. If not, write to 24 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 25 Boston, MA 02110-1301, USA. 26 */ 27 28 #ifndef SVGRenderStyleDefs_h 29 #define SVGRenderStyleDefs_h 30 31 #include "core/svg/SVGLength.h" 32 #include "core/svg/SVGLengthList.h" 33 #include "wtf/OwnPtr.h" 34 #include "wtf/PassOwnPtr.h" 35 #include "wtf/RefCounted.h" 36 #include "wtf/RefPtr.h" 37 38 namespace blink { 39 40 enum SVGPaintType { 41 SVG_PAINTTYPE_RGBCOLOR, 42 SVG_PAINTTYPE_NONE, 43 SVG_PAINTTYPE_CURRENTCOLOR, 44 SVG_PAINTTYPE_URI_NONE, 45 SVG_PAINTTYPE_URI_CURRENTCOLOR, 46 SVG_PAINTTYPE_URI_RGBCOLOR, 47 SVG_PAINTTYPE_URI 48 }; 49 50 enum EBaselineShift { 51 BS_BASELINE, BS_SUB, BS_SUPER, BS_LENGTH 52 }; 53 54 enum ETextAnchor { 55 TA_START, TA_MIDDLE, TA_END 56 }; 57 58 enum EColorInterpolation { 59 CI_AUTO, CI_SRGB, CI_LINEARRGB 60 }; 61 62 enum EColorRendering { 63 CR_AUTO, CR_OPTIMIZESPEED, CR_OPTIMIZEQUALITY 64 }; 65 enum EShapeRendering { 66 SR_AUTO, SR_OPTIMIZESPEED, SR_CRISPEDGES, SR_GEOMETRICPRECISION 67 }; 68 69 enum SVGWritingMode { 70 WM_LRTB, WM_LR, WM_RLTB, WM_RL, WM_TBRL, WM_TB 71 }; 72 73 enum EGlyphOrientation { 74 GO_0DEG, GO_90DEG, GO_180DEG, GO_270DEG, GO_AUTO 75 }; 76 77 enum EAlignmentBaseline { 78 AB_AUTO, AB_BASELINE, AB_BEFORE_EDGE, AB_TEXT_BEFORE_EDGE, 79 AB_MIDDLE, AB_CENTRAL, AB_AFTER_EDGE, AB_TEXT_AFTER_EDGE, 80 AB_IDEOGRAPHIC, AB_ALPHABETIC, AB_HANGING, AB_MATHEMATICAL 81 }; 82 83 enum EDominantBaseline { 84 DB_AUTO, DB_USE_SCRIPT, DB_NO_CHANGE, DB_RESET_SIZE, 85 DB_IDEOGRAPHIC, DB_ALPHABETIC, DB_HANGING, DB_MATHEMATICAL, 86 DB_CENTRAL, DB_MIDDLE, DB_TEXT_AFTER_EDGE, DB_TEXT_BEFORE_EDGE 87 }; 88 89 enum EVectorEffect { 90 VE_NONE, 91 VE_NON_SCALING_STROKE 92 }; 93 94 enum EBufferedRendering { 95 BR_AUTO, 96 BR_DYNAMIC, 97 BR_STATIC 98 }; 99 100 enum EMaskType { 101 MT_LUMINANCE, 102 MT_ALPHA 103 }; 104 105 enum EPaintOrderType { 106 PT_NONE = 0, 107 PT_FILL = 1, 108 PT_STROKE = 2, 109 PT_MARKERS = 3 110 }; 111 112 const int kPaintOrderBitwidth = 2; 113 typedef unsigned EPaintOrder; 114 const unsigned PO_NORMAL = PT_FILL | PT_STROKE << 2 | PT_MARKERS << 4; 115 116 // Inherited/Non-Inherited Style Datastructures 117 class StyleFillData : public RefCounted<StyleFillData> { 118 public: create()119 static PassRefPtr<StyleFillData> create() { return adoptRef(new StyleFillData); } copy()120 PassRefPtr<StyleFillData> copy() const { return adoptRef(new StyleFillData(*this)); } 121 122 bool operator==(const StyleFillData&) const; 123 bool operator!=(const StyleFillData& other) const 124 { 125 return !(*this == other); 126 } 127 128 float opacity; 129 SVGPaintType paintType; 130 Color paintColor; 131 String paintUri; 132 SVGPaintType visitedLinkPaintType; 133 Color visitedLinkPaintColor; 134 String visitedLinkPaintUri; 135 136 private: 137 StyleFillData(); 138 StyleFillData(const StyleFillData&); 139 }; 140 141 class StyleStrokeData : public RefCounted<StyleStrokeData> { 142 public: create()143 static PassRefPtr<StyleStrokeData> create() { return adoptRef(new StyleStrokeData); } copy()144 PassRefPtr<StyleStrokeData> copy() const { return adoptRef(new StyleStrokeData(*this)); } 145 146 bool operator==(const StyleStrokeData&) const; 147 bool operator!=(const StyleStrokeData& other) const 148 { 149 return !(*this == other); 150 } 151 152 float opacity; 153 float miterLimit; 154 155 RefPtr<SVGLength> width; 156 RefPtr<SVGLength> dashOffset; 157 RefPtr<SVGLengthList> dashArray; 158 159 SVGPaintType paintType; 160 Color paintColor; 161 String paintUri; 162 SVGPaintType visitedLinkPaintType; 163 Color visitedLinkPaintColor; 164 String visitedLinkPaintUri; 165 166 private: 167 StyleStrokeData(); 168 StyleStrokeData(const StyleStrokeData&); 169 }; 170 171 class StyleStopData : public RefCounted<StyleStopData> { 172 public: create()173 static PassRefPtr<StyleStopData> create() { return adoptRef(new StyleStopData); } copy()174 PassRefPtr<StyleStopData> copy() const { return adoptRef(new StyleStopData(*this)); } 175 176 bool operator==(const StyleStopData&) const; 177 bool operator!=(const StyleStopData& other) const 178 { 179 return !(*this == other); 180 } 181 182 float opacity; 183 Color color; 184 185 private: 186 StyleStopData(); 187 StyleStopData(const StyleStopData&); 188 }; 189 190 // Note: the rule for this class is, *no inheritance* of these props 191 class StyleMiscData : public RefCounted<StyleMiscData> { 192 public: create()193 static PassRefPtr<StyleMiscData> create() { return adoptRef(new StyleMiscData); } copy()194 PassRefPtr<StyleMiscData> copy() const { return adoptRef(new StyleMiscData(*this)); } 195 196 bool operator==(const StyleMiscData&) const; 197 bool operator!=(const StyleMiscData& other) const 198 { 199 return !(*this == other); 200 } 201 202 Color floodColor; 203 float floodOpacity; 204 Color lightingColor; 205 206 RefPtr<SVGLength> baselineShiftValue; 207 208 private: 209 StyleMiscData(); 210 StyleMiscData(const StyleMiscData&); 211 }; 212 213 // Non-inherited resources 214 class StyleResourceData : public RefCounted<StyleResourceData> { 215 public: create()216 static PassRefPtr<StyleResourceData> create() { return adoptRef(new StyleResourceData); } copy()217 PassRefPtr<StyleResourceData> copy() const { return adoptRef(new StyleResourceData(*this)); } 218 219 bool operator==(const StyleResourceData&) const; 220 bool operator!=(const StyleResourceData& other) const 221 { 222 return !(*this == other); 223 } 224 225 AtomicString clipper; 226 AtomicString filter; 227 AtomicString masker; 228 229 private: 230 StyleResourceData(); 231 StyleResourceData(const StyleResourceData&); 232 }; 233 234 // Inherited resources 235 class StyleInheritedResourceData : public RefCounted<StyleInheritedResourceData> { 236 public: create()237 static PassRefPtr<StyleInheritedResourceData> create() { return adoptRef(new StyleInheritedResourceData); } copy()238 PassRefPtr<StyleInheritedResourceData> copy() const { return adoptRef(new StyleInheritedResourceData(*this)); } 239 240 bool operator==(const StyleInheritedResourceData&) const; 241 bool operator!=(const StyleInheritedResourceData& other) const 242 { 243 return !(*this == other); 244 } 245 246 AtomicString markerStart; 247 AtomicString markerMid; 248 AtomicString markerEnd; 249 250 private: 251 StyleInheritedResourceData(); 252 StyleInheritedResourceData(const StyleInheritedResourceData&); 253 }; 254 255 } // namespace blink 256 257 #endif // SVGRenderStyleDefs_h 258