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 THIRD_PARTY_BLINK_RENDERER_CORE_STYLE_SVG_COMPUTED_STYLE_DEFS_H_ 29 #define THIRD_PARTY_BLINK_RENDERER_CORE_STYLE_SVG_COMPUTED_STYLE_DEFS_H_ 30 31 #include "base/memory/scoped_refptr.h" 32 #include "third_party/blink/renderer/core/core_export.h" 33 #include "third_party/blink/renderer/core/css/style_color.h" 34 #include "third_party/blink/renderer/core/style/style_path.h" 35 #include "third_party/blink/renderer/platform/geometry/length.h" 36 #include "third_party/blink/renderer/platform/wtf/allocator/allocator.h" 37 #include "third_party/blink/renderer/platform/wtf/ref_counted.h" 38 #include "third_party/blink/renderer/platform/wtf/text/wtf_string.h" 39 40 namespace blink { 41 42 class StyleSVGResource; 43 44 typedef base::RefCountedData<WTF::Vector<Length>> SVGDashArray; 45 46 enum SVGPaintType { 47 SVG_PAINTTYPE_COLOR, 48 SVG_PAINTTYPE_NONE, 49 SVG_PAINTTYPE_URI_NONE, 50 SVG_PAINTTYPE_URI_COLOR, 51 SVG_PAINTTYPE_URI 52 }; 53 54 enum EBaselineShift { BS_LENGTH, BS_SUB, BS_SUPER }; 55 56 enum ETextAnchor { TA_START, TA_MIDDLE, TA_END }; 57 58 enum EColorInterpolation { CI_AUTO, CI_SRGB, CI_LINEARRGB }; 59 60 enum EColorRendering { CR_AUTO, CR_OPTIMIZESPEED, CR_OPTIMIZEQUALITY }; 61 enum EShapeRendering { 62 SR_AUTO, 63 SR_OPTIMIZESPEED, 64 SR_CRISPEDGES, 65 SR_GEOMETRICPRECISION 66 }; 67 68 enum EAlignmentBaseline { 69 AB_AUTO, 70 AB_BASELINE, 71 AB_BEFORE_EDGE, 72 AB_TEXT_BEFORE_EDGE, 73 AB_MIDDLE, 74 AB_CENTRAL, 75 AB_AFTER_EDGE, 76 AB_TEXT_AFTER_EDGE, 77 AB_IDEOGRAPHIC, 78 AB_ALPHABETIC, 79 AB_HANGING, 80 AB_MATHEMATICAL 81 }; 82 83 enum EDominantBaseline { 84 DB_AUTO, 85 DB_USE_SCRIPT, 86 DB_NO_CHANGE, 87 DB_RESET_SIZE, 88 DB_IDEOGRAPHIC, 89 DB_ALPHABETIC, 90 DB_HANGING, 91 DB_MATHEMATICAL, 92 DB_CENTRAL, 93 DB_MIDDLE, 94 DB_TEXT_AFTER_EDGE, 95 DB_TEXT_BEFORE_EDGE 96 }; 97 98 enum EVectorEffect { VE_NONE, VE_NON_SCALING_STROKE }; 99 100 enum EBufferedRendering { BR_AUTO, BR_DYNAMIC, BR_STATIC }; 101 102 enum EMaskType { MT_LUMINANCE, MT_ALPHA }; 103 104 enum EPaintOrderType { 105 PT_NONE = 0, 106 PT_FILL = 1, 107 PT_STROKE = 2, 108 PT_MARKERS = 3 109 }; 110 111 enum EPaintOrder { 112 kPaintOrderNormal = 0, 113 kPaintOrderFillStrokeMarkers = 1, 114 kPaintOrderFillMarkersStroke = 2, 115 kPaintOrderStrokeFillMarkers = 3, 116 kPaintOrderStrokeMarkersFill = 4, 117 kPaintOrderMarkersFillStroke = 5, 118 kPaintOrderMarkersStrokeFill = 6 119 }; 120 121 struct SVGPaint { 122 CORE_EXPORT SVGPaint(); 123 SVGPaint(Color color); 124 SVGPaint(const SVGPaint& paint); 125 CORE_EXPORT ~SVGPaint(); 126 CORE_EXPORT SVGPaint& operator=(const SVGPaint& paint); 127 128 CORE_EXPORT bool operator==(const SVGPaint&) const; 129 bool operator!=(const SVGPaint& other) const { return !(*this == other); } 130 IsNoneSVGPaint131 bool IsNone() const { return type == SVG_PAINTTYPE_NONE; } IsColorSVGPaint132 bool IsColor() const { return type == SVG_PAINTTYPE_COLOR; } 133 // Used by CSSPropertyEquality::PropertiesEqual. EqualTypeOrColorSVGPaint134 bool EqualTypeOrColor(const SVGPaint& other) const { 135 return type == other.type && 136 (type != SVG_PAINTTYPE_COLOR || color == other.color); 137 } HasColorSVGPaint138 bool HasColor() const { return IsColor() || type == SVG_PAINTTYPE_URI_COLOR; } HasUrlSVGPaint139 bool HasUrl() const { return type >= SVG_PAINTTYPE_URI_NONE; } HasCurrentColorSVGPaint140 bool HasCurrentColor() const { return HasColor() && color.IsCurrentColor(); } ResourceSVGPaint141 StyleSVGResource* Resource() const { return resource.get(); } 142 GetColorSVGPaint143 const StyleColor& GetColor() const { return color; } 144 const AtomicString& GetUrl() const; 145 146 scoped_refptr<StyleSVGResource> resource; 147 StyleColor color; 148 SVGPaintType type{SVG_PAINTTYPE_NONE}; 149 }; 150 151 // Inherited/Non-Inherited Style Datastructures 152 class StyleFillData : public RefCounted<StyleFillData> { 153 USING_FAST_MALLOC(StyleFillData); 154 155 public: Create()156 static scoped_refptr<StyleFillData> Create() { 157 return base::AdoptRef(new StyleFillData); 158 } Copy()159 scoped_refptr<StyleFillData> Copy() const { 160 return base::AdoptRef(new StyleFillData(*this)); 161 } 162 163 bool operator==(const StyleFillData&) const; 164 bool operator!=(const StyleFillData& other) const { 165 return !(*this == other); 166 } 167 168 float opacity; 169 SVGPaint paint; 170 SVGPaint visited_link_paint; 171 172 private: 173 StyleFillData(); 174 StyleFillData(const StyleFillData&); 175 }; 176 177 class UnzoomedLength { 178 DISALLOW_NEW(); 179 180 public: UnzoomedLength(const Length & length)181 explicit UnzoomedLength(const Length& length) : length_(length) {} 182 IsZero()183 bool IsZero() const { return length_.IsZero(); } 184 185 bool operator==(const UnzoomedLength& other) const { 186 return length_ == other.length_; 187 } 188 bool operator!=(const UnzoomedLength& other) const { 189 return !operator==(other); 190 } 191 length()192 const Length& length() const { return length_; } 193 194 private: 195 Length length_; 196 }; 197 198 class CORE_EXPORT StyleStrokeData : public RefCounted<StyleStrokeData> { 199 USING_FAST_MALLOC(StyleStrokeData); 200 201 public: Create()202 static scoped_refptr<StyleStrokeData> Create() { 203 return base::AdoptRef(new StyleStrokeData); 204 } 205 Copy()206 scoped_refptr<StyleStrokeData> Copy() const { 207 return base::AdoptRef(new StyleStrokeData(*this)); 208 } 209 210 bool operator==(const StyleStrokeData&) const; 211 bool operator!=(const StyleStrokeData& other) const { 212 return !(*this == other); 213 } 214 215 float opacity; 216 float miter_limit; 217 218 UnzoomedLength width; 219 Length dash_offset; 220 scoped_refptr<SVGDashArray> dash_array; 221 222 SVGPaint paint; 223 SVGPaint visited_link_paint; 224 225 private: 226 StyleStrokeData(); 227 StyleStrokeData(const StyleStrokeData&); 228 }; 229 230 class StyleStopData : public RefCounted<StyleStopData> { 231 USING_FAST_MALLOC(StyleStopData); 232 233 public: Create()234 static scoped_refptr<StyleStopData> Create() { 235 return base::AdoptRef(new StyleStopData); 236 } Copy()237 scoped_refptr<StyleStopData> Copy() const { 238 return base::AdoptRef(new StyleStopData(*this)); 239 } 240 241 bool operator==(const StyleStopData&) const; 242 bool operator!=(const StyleStopData& other) const { 243 return !(*this == other); 244 } 245 246 StyleColor color; 247 float opacity; 248 249 private: 250 StyleStopData(); 251 StyleStopData(const StyleStopData&); 252 }; 253 254 // Note: the rule for this class is, *no inheritance* of these props 255 class CORE_EXPORT StyleMiscData : public RefCounted<StyleMiscData> { 256 USING_FAST_MALLOC(StyleMiscData); 257 258 public: Create()259 static scoped_refptr<StyleMiscData> Create() { 260 return base::AdoptRef(new StyleMiscData); 261 } Copy()262 scoped_refptr<StyleMiscData> Copy() const { 263 return base::AdoptRef(new StyleMiscData(*this)); 264 } 265 266 bool operator==(const StyleMiscData&) const; 267 bool operator!=(const StyleMiscData& other) const { 268 return !(*this == other); 269 } 270 271 Length baseline_shift_value; 272 273 StyleColor flood_color; 274 StyleColor lighting_color; 275 276 float flood_opacity; 277 278 private: 279 StyleMiscData(); 280 StyleMiscData(const StyleMiscData&); 281 }; 282 283 // Non-inherited resources 284 class StyleResourceData : public RefCounted<StyleResourceData> { 285 USING_FAST_MALLOC(StyleResourceData); 286 287 public: Create()288 static scoped_refptr<StyleResourceData> Create() { 289 return base::AdoptRef(new StyleResourceData); 290 } 291 ~StyleResourceData(); Copy()292 scoped_refptr<StyleResourceData> Copy() const { 293 return base::AdoptRef(new StyleResourceData(*this)); 294 } 295 296 bool operator==(const StyleResourceData&) const; 297 bool operator!=(const StyleResourceData& other) const { 298 return !(*this == other); 299 } 300 301 scoped_refptr<StyleSVGResource> masker; 302 303 private: 304 StyleResourceData(); 305 StyleResourceData(const StyleResourceData&); 306 }; 307 308 // Inherited resources 309 class StyleInheritedResourceData 310 : public RefCounted<StyleInheritedResourceData> { 311 USING_FAST_MALLOC(StyleInheritedResourceData); 312 313 public: Create()314 static scoped_refptr<StyleInheritedResourceData> Create() { 315 return base::AdoptRef(new StyleInheritedResourceData); 316 } 317 ~StyleInheritedResourceData(); Copy()318 scoped_refptr<StyleInheritedResourceData> Copy() const { 319 return base::AdoptRef(new StyleInheritedResourceData(*this)); 320 } 321 322 bool operator==(const StyleInheritedResourceData&) const; 323 bool operator!=(const StyleInheritedResourceData& other) const { 324 return !(*this == other); 325 } 326 327 scoped_refptr<StyleSVGResource> marker_start; 328 scoped_refptr<StyleSVGResource> marker_mid; 329 scoped_refptr<StyleSVGResource> marker_end; 330 331 private: 332 StyleInheritedResourceData(); 333 StyleInheritedResourceData(const StyleInheritedResourceData&); 334 }; 335 336 // Geometry properties 337 class StyleGeometryData : public RefCounted<StyleGeometryData> { 338 USING_FAST_MALLOC(StyleGeometryData); 339 340 public: Create()341 static scoped_refptr<StyleGeometryData> Create() { 342 return base::AdoptRef(new StyleGeometryData); 343 } 344 scoped_refptr<StyleGeometryData> Copy() const; 345 bool operator==(const StyleGeometryData&) const; 346 bool operator!=(const StyleGeometryData& other) const { 347 return !(*this == other); 348 } 349 scoped_refptr<StylePath> d; 350 Length cx; 351 Length cy; 352 Length x; 353 Length y; 354 Length r; 355 Length rx; 356 Length ry; 357 358 private: 359 StyleGeometryData(); 360 StyleGeometryData(const StyleGeometryData&); 361 }; 362 363 } // namespace blink 364 365 #endif // THIRD_PARTY_BLINK_RENDERER_CORE_STYLE_SVG_COMPUTED_STYLE_DEFS_H_ 366