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 
      5     Based on khtml code by:
      6     Copyright (C) 2000-2003 Lars Knoll (knoll (at) kde.org)
      7               (C) 2000 Antti Koivisto (koivisto (at) kde.org)
      8               (C) 2000-2003 Dirk Mueller (mueller (at) kde.org)
      9               (C) 2002-2003 Apple Computer, Inc.
     10 
     11     This library is free software; you can redistribute it and/or
     12     modify it under the terms of the GNU Library General Public
     13     License as published by the Free Software Foundation; either
     14     version 2 of the License, or (at your option) any later version.
     15 
     16     This library is distributed in the hope that it will be useful,
     17     but WITHOUT ANY WARRANTY; without even the implied warranty of
     18     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     19     Library General Public License for more details.
     20 
     21     You should have received a copy of the GNU Library General Public License
     22     along with this library; see the file COPYING.LIB.  If not, write to
     23     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
     24     Boston, MA 02110-1301, USA.
     25 */
     26 
     27 #ifndef SVGRenderStyleDefs_h
     28 #define SVGRenderStyleDefs_h
     29 
     30 #if ENABLE(SVG)
     31 #include "Color.h"
     32 #include "Path.h"
     33 #include "PlatformString.h"
     34 #include "ShadowData.h"
     35 #include <wtf/OwnPtr.h>
     36 #include <wtf/PassOwnPtr.h>
     37 #include <wtf/RefCounted.h>
     38 #include <wtf/RefPtr.h>
     39 
     40 // Helper macros for 'SVGRenderStyle'
     41 #define SVG_RS_DEFINE_ATTRIBUTE(Data, Type, Name, Initial) \
     42     void set##Type(Data val) { svg_noninherited_flags.f._##Name = val; } \
     43     Data Name() const { return (Data) svg_noninherited_flags.f._##Name; } \
     44     static Data initial##Type() { return Initial; }
     45 
     46 #define SVG_RS_DEFINE_ATTRIBUTE_INHERITED(Data, Type, Name, Initial) \
     47     void set##Type(Data val) { svg_inherited_flags._##Name = val; } \
     48     Data Name() const { return (Data) svg_inherited_flags._##Name; } \
     49     static Data initial##Type() { return Initial; }
     50 
     51 // "Helper" macros for SVG's RenderStyle properties
     52 // FIXME: These are impossible to work with or debug.
     53 #define SVG_RS_DEFINE_ATTRIBUTE_DATAREF(Data, Group, Variable, Type, Name) \
     54     Data Name() const { return Group->Variable; } \
     55     void set##Type(Data obj) { SVG_RS_SET_VARIABLE(Group, Variable, obj) }
     56 
     57 #define SVG_RS_DEFINE_ATTRIBUTE_DATAREF_WITH_INITIAL(Data, Group, Variable, Type, Name, Initial) \
     58     SVG_RS_DEFINE_ATTRIBUTE_DATAREF(Data, Group, Variable, Type, Name) \
     59     static Data initial##Type() { return Initial; }
     60 
     61 #define SVG_RS_DEFINE_ATTRIBUTE_DATAREF_WITH_INITIAL_REFCOUNTED(Data, Group, Variable, Type, Name, Initial) \
     62     Data* Name() const { return Group->Variable.get(); } \
     63     void set##Type(PassRefPtr<Data> obj) { \
     64         if (!(Group->Variable == obj)) \
     65             Group.access()->Variable = obj; \
     66     } \
     67     static Data* initial##Type() { return Initial; }
     68 
     69 #define SVG_RS_DEFINE_ATTRIBUTE_DATAREF_WITH_INITIAL_OWNPTR(Data, Group, Variable, Type, Name, Initial) \
     70     Data* Name() const { return Group->Variable.get(); } \
     71     void set##Type(Data* obj) { \
     72         Group.access()->Variable.set(obj); \
     73     } \
     74     static Data* initial##Type() { return Initial; }
     75 
     76 #define SVG_RS_SET_VARIABLE(Group, Variable, Value) \
     77     if (!(Group->Variable == Value)) \
     78         Group.access()->Variable = Value;
     79 
     80 namespace WebCore {
     81 
     82     enum EBaselineShift {
     83         BS_BASELINE, BS_SUB, BS_SUPER, BS_LENGTH
     84     };
     85 
     86     enum ETextAnchor {
     87         TA_START, TA_MIDDLE, TA_END
     88     };
     89 
     90     enum EColorInterpolation {
     91         CI_AUTO, CI_SRGB, CI_LINEARRGB
     92     };
     93 
     94     enum EColorRendering {
     95         CR_AUTO, CR_OPTIMIZESPEED, CR_OPTIMIZEQUALITY
     96     };
     97 
     98     enum EImageRendering {
     99         IR_AUTO, IR_OPTIMIZESPEED, IR_OPTIMIZEQUALITY
    100     };
    101 
    102     enum EShapeRendering {
    103         SR_AUTO, SR_OPTIMIZESPEED, SR_CRISPEDGES, SR_GEOMETRICPRECISION
    104     };
    105 
    106     enum EWritingMode {
    107         WM_LRTB, WM_LR, WM_RLTB, WM_RL, WM_TBRL, WM_TB
    108     };
    109 
    110     enum EGlyphOrientation {
    111         GO_0DEG, GO_90DEG, GO_180DEG, GO_270DEG, GO_AUTO
    112     };
    113 
    114     enum EAlignmentBaseline {
    115         AB_AUTO, AB_BASELINE, AB_BEFORE_EDGE, AB_TEXT_BEFORE_EDGE,
    116         AB_MIDDLE, AB_CENTRAL, AB_AFTER_EDGE, AB_TEXT_AFTER_EDGE,
    117         AB_IDEOGRAPHIC, AB_ALPHABETIC, AB_HANGING, AB_MATHEMATICAL
    118     };
    119 
    120     enum EDominantBaseline {
    121         DB_AUTO, DB_USE_SCRIPT, DB_NO_CHANGE, DB_RESET_SIZE,
    122         DB_IDEOGRAPHIC, DB_ALPHABETIC, DB_HANGING, DB_MATHEMATICAL,
    123         DB_CENTRAL, DB_MIDDLE, DB_TEXT_AFTER_EDGE, DB_TEXT_BEFORE_EDGE
    124     };
    125 
    126     class CSSValue;
    127     class CSSValueList;
    128     class SVGPaint;
    129 
    130     // Inherited/Non-Inherited Style Datastructures
    131     class StyleFillData : public RefCounted<StyleFillData> {
    132     public:
    133         static PassRefPtr<StyleFillData> create() { return adoptRef(new StyleFillData); }
    134         PassRefPtr<StyleFillData> copy() const { return adoptRef(new StyleFillData(*this)); }
    135 
    136         bool operator==(const StyleFillData &other) const;
    137         bool operator!=(const StyleFillData &other) const
    138         {
    139             return !(*this == other);
    140         }
    141 
    142         float opacity;
    143         RefPtr<SVGPaint> paint;
    144 
    145     private:
    146         StyleFillData();
    147         StyleFillData(const StyleFillData&);
    148     };
    149 
    150     class StyleStrokeData : public RefCounted<StyleStrokeData> {
    151     public:
    152         static PassRefPtr<StyleStrokeData> create() { return adoptRef(new StyleStrokeData); }
    153         PassRefPtr<StyleStrokeData> copy() const { return adoptRef(new StyleStrokeData(*this)); }
    154 
    155         bool operator==(const StyleStrokeData&) const;
    156         bool operator!=(const StyleStrokeData& other) const
    157         {
    158             return !(*this == other);
    159         }
    160 
    161         float opacity;
    162         float miterLimit;
    163 
    164         RefPtr<CSSValue> width;
    165         RefPtr<CSSValue> dashOffset;
    166 
    167         RefPtr<SVGPaint> paint;
    168         RefPtr<CSSValueList> dashArray;
    169 
    170     private:
    171         StyleStrokeData();
    172         StyleStrokeData(const StyleStrokeData&);
    173     };
    174 
    175     class StyleStopData : public RefCounted<StyleStopData> {
    176     public:
    177         static PassRefPtr<StyleStopData> create() { return adoptRef(new StyleStopData); }
    178         PassRefPtr<StyleStopData> copy() const { return adoptRef(new StyleStopData(*this)); }
    179 
    180         bool operator==(const StyleStopData &other) const;
    181         bool operator!=(const StyleStopData &other) const
    182         {
    183             return !(*this == other);
    184         }
    185 
    186         float opacity;
    187         Color color;
    188 
    189     private:
    190         StyleStopData();
    191         StyleStopData(const StyleStopData&);
    192     };
    193 
    194     class StyleTextData : public RefCounted<StyleTextData> {
    195     public:
    196         static PassRefPtr<StyleTextData> create() { return adoptRef(new StyleTextData); }
    197         PassRefPtr<StyleTextData> copy() const { return adoptRef(new StyleTextData(*this)); }
    198 
    199         bool operator==(const StyleTextData& other) const;
    200         bool operator!=(const StyleTextData& other) const
    201         {
    202             return !(*this == other);
    203         }
    204 
    205         RefPtr<CSSValue> kerning;
    206 
    207     private:
    208         StyleTextData();
    209         StyleTextData(const StyleTextData& other);
    210     };
    211 
    212     class StyleClipData : public RefCounted<StyleClipData> {
    213     public:
    214         static PassRefPtr<StyleClipData> create() { return adoptRef(new StyleClipData); }
    215         PassRefPtr<StyleClipData> copy() const { return adoptRef(new StyleClipData(*this)); }
    216 
    217         bool operator==(const StyleClipData &other) const;
    218         bool operator!=(const StyleClipData &other) const
    219         {
    220             return !(*this == other);
    221         }
    222 
    223         String clipPath;
    224 
    225     private:
    226         StyleClipData();
    227         StyleClipData(const StyleClipData&);
    228     };
    229 
    230     class StyleMaskData : public RefCounted<StyleMaskData> {
    231     public:
    232         static PassRefPtr<StyleMaskData> create() { return adoptRef(new StyleMaskData); }
    233         PassRefPtr<StyleMaskData> copy() const { return adoptRef(new StyleMaskData(*this)); }
    234 
    235         bool operator==(const StyleMaskData &other) const;
    236         bool operator!=(const StyleMaskData &other) const { return !(*this == other); }
    237 
    238         String maskElement;
    239 
    240     private:
    241         StyleMaskData();
    242         StyleMaskData(const StyleMaskData&);
    243     };
    244 
    245     class StyleMarkerData : public RefCounted<StyleMarkerData> {
    246     public:
    247         static PassRefPtr<StyleMarkerData> create() { return adoptRef(new StyleMarkerData); }
    248         PassRefPtr<StyleMarkerData> copy() const { return adoptRef(new StyleMarkerData(*this)); }
    249 
    250         bool operator==(const StyleMarkerData &other) const;
    251         bool operator!=(const StyleMarkerData &other) const
    252         {
    253             return !(*this == other);
    254         }
    255 
    256         String startMarker;
    257         String midMarker;
    258         String endMarker;
    259 
    260     private:
    261         StyleMarkerData();
    262         StyleMarkerData(const StyleMarkerData&);
    263     };
    264 
    265     // Note : the rule for this class is, *no inheritance* of these props
    266     class StyleMiscData : public RefCounted<StyleMiscData> {
    267     public:
    268         static PassRefPtr<StyleMiscData> create() { return adoptRef(new StyleMiscData); }
    269         PassRefPtr<StyleMiscData> copy() const { return adoptRef(new StyleMiscData(*this)); }
    270 
    271         bool operator==(const StyleMiscData &other) const;
    272         bool operator!=(const StyleMiscData &other) const
    273         {
    274             return !(*this == other);
    275         }
    276 
    277         String filter;
    278         Color floodColor;
    279         float floodOpacity;
    280 
    281         Color lightingColor;
    282 
    283         // non-inherited text stuff lives here not in StyleTextData.
    284         RefPtr<CSSValue> baselineShiftValue;
    285 
    286     private:
    287         StyleMiscData();
    288         StyleMiscData(const StyleMiscData&);
    289     };
    290 
    291     class StyleShadowSVGData : public RefCounted<StyleShadowSVGData> {
    292     public:
    293         static PassRefPtr<StyleShadowSVGData> create() { return adoptRef(new StyleShadowSVGData); }
    294         PassRefPtr<StyleShadowSVGData> copy() const { return adoptRef(new StyleShadowSVGData(*this)); }
    295 
    296         bool operator==(const StyleShadowSVGData& other) const;
    297         bool operator!=(const StyleShadowSVGData& other) const
    298         {
    299             return !(*this == other);
    300         }
    301 
    302         OwnPtr<ShadowData> shadow;
    303 
    304     private:
    305         StyleShadowSVGData();
    306         StyleShadowSVGData(const StyleShadowSVGData& other);
    307     };
    308 
    309 } // namespace WebCore
    310 
    311 #endif // ENABLE(SVG)
    312 #endif // SVGRenderStyleDefs_h
    313 
    314 // vim:ts=4:noet
    315