Home | History | Annotate | Download | only in style
      1 /*
      2     Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann (at) kde.org>
      3                   2004, 2005 Rob Buis <buis (at) 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 (at) kde.org)
      8               (C) 2000 Antti Koivisto (koivisto (at) kde.org)
      9               (C) 2000-2003 Dirk Mueller (mueller (at) 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 "core/svg/SVGPaint.h"
     34 #include "wtf/OwnPtr.h"
     35 #include "wtf/PassOwnPtr.h"
     36 #include "wtf/RefCounted.h"
     37 #include "wtf/RefPtr.h"
     38 
     39 namespace WebCore {
     40 
     41     enum EBaselineShift {
     42         BS_BASELINE, BS_SUB, BS_SUPER, BS_LENGTH
     43     };
     44 
     45     enum ETextAnchor {
     46         TA_START, TA_MIDDLE, TA_END
     47     };
     48 
     49     enum EColorInterpolation {
     50         CI_AUTO, CI_SRGB, CI_LINEARRGB
     51     };
     52 
     53     enum EColorRendering {
     54         CR_AUTO, CR_OPTIMIZESPEED, CR_OPTIMIZEQUALITY
     55     };
     56     enum EShapeRendering {
     57         SR_AUTO, SR_OPTIMIZESPEED, SR_CRISPEDGES, SR_GEOMETRICPRECISION
     58     };
     59 
     60     enum SVGWritingMode {
     61         WM_LRTB, WM_LR, WM_RLTB, WM_RL, WM_TBRL, WM_TB
     62     };
     63 
     64     enum EGlyphOrientation {
     65         GO_0DEG, GO_90DEG, GO_180DEG, GO_270DEG, GO_AUTO
     66     };
     67 
     68     enum EAlignmentBaseline {
     69         AB_AUTO, AB_BASELINE, AB_BEFORE_EDGE, AB_TEXT_BEFORE_EDGE,
     70         AB_MIDDLE, AB_CENTRAL, AB_AFTER_EDGE, AB_TEXT_AFTER_EDGE,
     71         AB_IDEOGRAPHIC, AB_ALPHABETIC, AB_HANGING, AB_MATHEMATICAL
     72     };
     73 
     74     enum EDominantBaseline {
     75         DB_AUTO, DB_USE_SCRIPT, DB_NO_CHANGE, DB_RESET_SIZE,
     76         DB_IDEOGRAPHIC, DB_ALPHABETIC, DB_HANGING, DB_MATHEMATICAL,
     77         DB_CENTRAL, DB_MIDDLE, DB_TEXT_AFTER_EDGE, DB_TEXT_BEFORE_EDGE
     78     };
     79 
     80     enum EVectorEffect {
     81         VE_NONE,
     82         VE_NON_SCALING_STROKE
     83     };
     84 
     85     enum EBufferedRendering {
     86         BR_AUTO,
     87         BR_DYNAMIC,
     88         BR_STATIC
     89     };
     90 
     91     enum EMaskType {
     92         MT_LUMINANCE,
     93         MT_ALPHA
     94     };
     95 
     96     enum EPaintOrderType {
     97         PT_NONE    = 0,
     98         PT_FILL    = 1,
     99         PT_STROKE  = 2,
    100         PT_MARKERS = 3
    101     };
    102 
    103     const int kPaintOrderBitwidth = 2;
    104     typedef unsigned EPaintOrder;
    105     const unsigned PO_NORMAL = PT_FILL | PT_STROKE << 2 | PT_MARKERS << 4;
    106 
    107     // Inherited/Non-Inherited Style Datastructures
    108     class StyleFillData : public RefCounted<StyleFillData> {
    109     public:
    110         static PassRefPtr<StyleFillData> create() { return adoptRef(new StyleFillData); }
    111         PassRefPtr<StyleFillData> copy() const { return adoptRef(new StyleFillData(*this)); }
    112 
    113         bool operator==(const StyleFillData&) const;
    114         bool operator!=(const StyleFillData& other) const
    115         {
    116             return !(*this == other);
    117         }
    118 
    119         float opacity;
    120         SVGPaint::SVGPaintType paintType;
    121         Color paintColor;
    122         String paintUri;
    123         SVGPaint::SVGPaintType visitedLinkPaintType;
    124         Color visitedLinkPaintColor;
    125         String visitedLinkPaintUri;
    126 
    127     private:
    128         StyleFillData();
    129         StyleFillData(const StyleFillData&);
    130     };
    131 
    132     class StyleStrokeData : public RefCounted<StyleStrokeData> {
    133     public:
    134         static PassRefPtr<StyleStrokeData> create() { return adoptRef(new StyleStrokeData); }
    135         PassRefPtr<StyleStrokeData> copy() const { return adoptRef(new StyleStrokeData(*this)); }
    136 
    137         bool operator==(const StyleStrokeData&) const;
    138         bool operator!=(const StyleStrokeData& other) const
    139         {
    140             return !(*this == other);
    141         }
    142 
    143         float opacity;
    144         float miterLimit;
    145 
    146         RefPtr<SVGLength> width;
    147         RefPtr<SVGLength> dashOffset;
    148         RefPtr<SVGLengthList> dashArray;
    149 
    150         SVGPaint::SVGPaintType paintType;
    151         Color paintColor;
    152         String paintUri;
    153         SVGPaint::SVGPaintType visitedLinkPaintType;
    154         Color visitedLinkPaintColor;
    155         String visitedLinkPaintUri;
    156 
    157     private:
    158         StyleStrokeData();
    159         StyleStrokeData(const StyleStrokeData&);
    160     };
    161 
    162     class StyleStopData : public RefCounted<StyleStopData> {
    163     public:
    164         static PassRefPtr<StyleStopData> create() { return adoptRef(new StyleStopData); }
    165         PassRefPtr<StyleStopData> copy() const { return adoptRef(new StyleStopData(*this)); }
    166 
    167         bool operator==(const StyleStopData&) const;
    168         bool operator!=(const StyleStopData& other) const
    169         {
    170             return !(*this == other);
    171         }
    172 
    173         float opacity;
    174         Color color;
    175 
    176     private:
    177         StyleStopData();
    178         StyleStopData(const StyleStopData&);
    179     };
    180 
    181     // Note: the rule for this class is, *no inheritance* of these props
    182     class StyleMiscData : public RefCounted<StyleMiscData> {
    183     public:
    184         static PassRefPtr<StyleMiscData> create() { return adoptRef(new StyleMiscData); }
    185         PassRefPtr<StyleMiscData> copy() const { return adoptRef(new StyleMiscData(*this)); }
    186 
    187         bool operator==(const StyleMiscData&) const;
    188         bool operator!=(const StyleMiscData& other) const
    189         {
    190             return !(*this == other);
    191         }
    192 
    193         Color floodColor;
    194         float floodOpacity;
    195         Color lightingColor;
    196 
    197         RefPtr<SVGLength> baselineShiftValue;
    198 
    199     private:
    200         StyleMiscData();
    201         StyleMiscData(const StyleMiscData&);
    202     };
    203 
    204     // Non-inherited resources
    205     class StyleResourceData : public RefCounted<StyleResourceData> {
    206     public:
    207         static PassRefPtr<StyleResourceData> create() { return adoptRef(new StyleResourceData); }
    208         PassRefPtr<StyleResourceData> copy() const { return adoptRef(new StyleResourceData(*this)); }
    209 
    210         bool operator==(const StyleResourceData&) const;
    211         bool operator!=(const StyleResourceData& other) const
    212         {
    213             return !(*this == other);
    214         }
    215 
    216         AtomicString clipper;
    217         AtomicString filter;
    218         AtomicString masker;
    219 
    220     private:
    221         StyleResourceData();
    222         StyleResourceData(const StyleResourceData&);
    223     };
    224 
    225     // Inherited resources
    226     class StyleInheritedResourceData : public RefCounted<StyleInheritedResourceData> {
    227     public:
    228         static PassRefPtr<StyleInheritedResourceData> create() { return adoptRef(new StyleInheritedResourceData); }
    229         PassRefPtr<StyleInheritedResourceData> copy() const { return adoptRef(new StyleInheritedResourceData(*this)); }
    230 
    231         bool operator==(const StyleInheritedResourceData&) const;
    232         bool operator!=(const StyleInheritedResourceData& other) const
    233         {
    234             return !(*this == other);
    235         }
    236 
    237         AtomicString markerStart;
    238         AtomicString markerMid;
    239         AtomicString markerEnd;
    240 
    241     private:
    242         StyleInheritedResourceData();
    243         StyleInheritedResourceData(const StyleInheritedResourceData&);
    244     };
    245 
    246 } // namespace WebCore
    247 
    248 #endif // SVGRenderStyleDefs_h
    249