#ifndef SVGRenderStyle_h
#define SVGRenderStyle_h
#if ENABLE(SVG)
#include "CSSValueList.h"
#include "DataRef.h"
#include "GraphicsTypes.h"
#include "Path.h"
#include "SVGPaint.h"
#include "SVGRenderStyleDefs.h"
namespace WebCore {
class FloatRect;
class IntRect;
class RenderObject;
class RenderStyle;
class SVGRenderStyle : public RefCounted<SVGRenderStyle> {
public:
static PassRefPtr<SVGRenderStyle> create() { return adoptRef(new SVGRenderStyle); }
PassRefPtr<SVGRenderStyle> copy() const { return adoptRef(new SVGRenderStyle(*this));}
~SVGRenderStyle();
bool inheritedNotEqual(const SVGRenderStyle*) const;
void inheritFrom(const SVGRenderStyle*);
void inflateForShadow(IntRect&) const;
void inflateForShadow(FloatRect&) const;
bool operator==(const SVGRenderStyle&) const;
bool operator!=(const SVGRenderStyle& o) const { return !(*this == o); }
SVG_RS_DEFINE_ATTRIBUTE(EAlignmentBaseline, AlignmentBaseline, alignmentBaseline, AB_AUTO)
SVG_RS_DEFINE_ATTRIBUTE(EDominantBaseline, DominantBaseline, dominantBaseline, DB_AUTO)
SVG_RS_DEFINE_ATTRIBUTE(EBaselineShift, BaselineShift, baselineShift, BS_BASELINE)
SVG_RS_DEFINE_ATTRIBUTE_INHERITED(LineCap, CapStyle, capStyle, ButtCap)
SVG_RS_DEFINE_ATTRIBUTE_INHERITED(WindRule, ClipRule, clipRule, RULE_NONZERO)
SVG_RS_DEFINE_ATTRIBUTE_INHERITED(EColorInterpolation, ColorInterpolation, colorInterpolation, CI_SRGB)
SVG_RS_DEFINE_ATTRIBUTE_INHERITED(EColorInterpolation, ColorInterpolationFilters, colorInterpolationFilters, CI_LINEARRGB)
SVG_RS_DEFINE_ATTRIBUTE_INHERITED(EColorRendering, ColorRendering, colorRendering, CR_AUTO)
SVG_RS_DEFINE_ATTRIBUTE_INHERITED(WindRule, FillRule, fillRule, RULE_NONZERO)
SVG_RS_DEFINE_ATTRIBUTE_INHERITED(EImageRendering, ImageRendering, imageRendering, IR_AUTO)
SVG_RS_DEFINE_ATTRIBUTE_INHERITED(LineJoin, JoinStyle, joinStyle, MiterJoin)
SVG_RS_DEFINE_ATTRIBUTE_INHERITED(EShapeRendering, ShapeRendering, shapeRendering, SR_AUTO)
SVG_RS_DEFINE_ATTRIBUTE_INHERITED(ETextAnchor, TextAnchor, textAnchor, TA_START)
SVG_RS_DEFINE_ATTRIBUTE_INHERITED(EWritingMode, WritingMode, writingMode, WM_LRTB)
SVG_RS_DEFINE_ATTRIBUTE_INHERITED(EGlyphOrientation, GlyphOrientationHorizontal, glyphOrientationHorizontal, GO_0DEG)
SVG_RS_DEFINE_ATTRIBUTE_INHERITED(EGlyphOrientation, GlyphOrientationVertical, glyphOrientationVertical, GO_AUTO)
SVG_RS_DEFINE_ATTRIBUTE_DATAREF_WITH_INITIAL(float, fill, opacity, FillOpacity, fillOpacity, 1.0f)
SVG_RS_DEFINE_ATTRIBUTE_DATAREF_WITH_INITIAL_REFCOUNTED(SVGPaint, fill, paint, FillPaint, fillPaint, SVGPaint::defaultFill())
SVG_RS_DEFINE_ATTRIBUTE_DATAREF_WITH_INITIAL(float, stroke, opacity, StrokeOpacity, strokeOpacity, 1.0f)
SVG_RS_DEFINE_ATTRIBUTE_DATAREF_WITH_INITIAL_REFCOUNTED(SVGPaint, stroke, paint, StrokePaint, strokePaint, SVGPaint::defaultStroke())
SVG_RS_DEFINE_ATTRIBUTE_DATAREF_WITH_INITIAL_REFCOUNTED(CSSValueList, stroke, dashArray, StrokeDashArray, strokeDashArray, 0)
SVG_RS_DEFINE_ATTRIBUTE_DATAREF_WITH_INITIAL(float, stroke, miterLimit, StrokeMiterLimit, strokeMiterLimit, 4.0f)
SVG_RS_DEFINE_ATTRIBUTE_DATAREF_WITH_INITIAL_REFCOUNTED(CSSValue, stroke, width, StrokeWidth, strokeWidth, 0)
SVG_RS_DEFINE_ATTRIBUTE_DATAREF_WITH_INITIAL_REFCOUNTED(CSSValue, stroke, dashOffset, StrokeDashOffset, strokeDashOffset, 0);
SVG_RS_DEFINE_ATTRIBUTE_DATAREF_WITH_INITIAL_REFCOUNTED(CSSValue, text, kerning, Kerning, kerning, 0)
SVG_RS_DEFINE_ATTRIBUTE_DATAREF_WITH_INITIAL(float, stops, opacity, StopOpacity, stopOpacity, 1.0f)
SVG_RS_DEFINE_ATTRIBUTE_DATAREF_WITH_INITIAL(Color, stops, color, StopColor, stopColor, Color(0, 0, 0))
SVG_RS_DEFINE_ATTRIBUTE_DATAREF_WITH_INITIAL(float, misc, floodOpacity, FloodOpacity, floodOpacity, 1.0f)
SVG_RS_DEFINE_ATTRIBUTE_DATAREF_WITH_INITIAL(Color, misc, floodColor, FloodColor, floodColor, Color(0, 0, 0))
SVG_RS_DEFINE_ATTRIBUTE_DATAREF_WITH_INITIAL(Color, misc, lightingColor, LightingColor, lightingColor, Color(255, 255, 255))
SVG_RS_DEFINE_ATTRIBUTE_DATAREF_WITH_INITIAL_REFCOUNTED(CSSValue, misc, baselineShiftValue, BaselineShiftValue, baselineShiftValue, 0)
SVG_RS_DEFINE_ATTRIBUTE_DATAREF_WITH_INITIAL_OWNPTR(ShadowData, shadowSVG, shadow, Shadow, shadow, 0)
SVG_RS_DEFINE_ATTRIBUTE_DATAREF_WITH_INITIAL(String, resources, clipper, ClipperResource, clipperResource, String())
SVG_RS_DEFINE_ATTRIBUTE_DATAREF_WITH_INITIAL(String, resources, filter, FilterResource, filterResource, String())
SVG_RS_DEFINE_ATTRIBUTE_DATAREF_WITH_INITIAL(String, resources, masker, MaskerResource, maskerResource, String())
SVG_RS_DEFINE_ATTRIBUTE_DATAREF_WITH_INITIAL(String, inheritedResources, markerStart, MarkerStartResource, markerStartResource, String())
SVG_RS_DEFINE_ATTRIBUTE_DATAREF_WITH_INITIAL(String, inheritedResources, markerMid, MarkerMidResource, markerMidResource, String())
SVG_RS_DEFINE_ATTRIBUTE_DATAREF_WITH_INITIAL(String, inheritedResources, markerEnd, MarkerEndResource, markerEndResource, String())
bool hasClipper() const { return !clipperResource().isEmpty(); }
bool hasMasker() const { return !maskerResource().isEmpty(); }
bool hasFilter() const { return !filterResource().isEmpty(); }
bool hasMarkers() const { return !markerStartResource().isEmpty() || !markerMidResource().isEmpty() || !markerEndResource().isEmpty(); }
bool hasStroke() const { return strokePaint()->paintType() != SVGPaint::SVG_PAINTTYPE_NONE; }
bool hasFill() const { return fillPaint()->paintType() != SVGPaint::SVG_PAINTTYPE_NONE; }
static float cssPrimitiveToLength(const RenderObject*, CSSValue*, float defaultValue = 0.0f);
protected:
struct InheritedFlags {
bool operator==(const InheritedFlags& other) const
{
return (_colorRendering == other._colorRendering)
&& (_imageRendering == other._imageRendering)
&& (_shapeRendering == other._shapeRendering)
&& (_clipRule == other._clipRule)
&& (_fillRule == other._fillRule)
&& (_capStyle == other._capStyle)
&& (_joinStyle == other._joinStyle)
&& (_textAnchor == other._textAnchor)
&& (_colorInterpolation == other._colorInterpolation)
&& (_colorInterpolationFilters == other._colorInterpolationFilters)
&& (_writingMode == other._writingMode)
&& (_glyphOrientationHorizontal == other._glyphOrientationHorizontal)
&& (_glyphOrientationVertical == other._glyphOrientationVertical);
}
bool operator!=(const InheritedFlags& other) const
{
return !(*this == other);
}
unsigned _colorRendering : 2; unsigned _imageRendering : 2; unsigned _shapeRendering : 2; unsigned _clipRule : 1; unsigned _fillRule : 1; unsigned _capStyle : 2; unsigned _joinStyle : 2; unsigned _textAnchor : 2; unsigned _colorInterpolation : 2; unsigned _colorInterpolationFilters : 2; unsigned _writingMode : 3; unsigned _glyphOrientationHorizontal : 3; unsigned _glyphOrientationVertical : 3; } svg_inherited_flags;
struct NonInheritedFlags {
bool operator==(const NonInheritedFlags &other) const { return _niflags == other._niflags; }
bool operator!=(const NonInheritedFlags &other) const { return _niflags != other._niflags; }
union {
struct {
unsigned _alignmentBaseline : 4; unsigned _dominantBaseline : 4; unsigned _baselineShift : 2; } f;
uint32_t _niflags;
};
} svg_noninherited_flags;
DataRef<StyleFillData> fill;
DataRef<StyleStrokeData> stroke;
DataRef<StyleTextData> text;
DataRef<StyleInheritedResourceData> inheritedResources;
DataRef<StyleStopData> stops;
DataRef<StyleMiscData> misc;
DataRef<StyleShadowSVGData> shadowSVG;
DataRef<StyleResourceData> resources;
private:
enum CreateDefaultType { CreateDefault };
SVGRenderStyle();
SVGRenderStyle(const SVGRenderStyle&);
SVGRenderStyle(CreateDefaultType);
void setBitDefaults()
{
svg_inherited_flags._clipRule = initialClipRule();
svg_inherited_flags._colorRendering = initialColorRendering();
svg_inherited_flags._fillRule = initialFillRule();
svg_inherited_flags._imageRendering = initialImageRendering();
svg_inherited_flags._shapeRendering = initialShapeRendering();
svg_inherited_flags._textAnchor = initialTextAnchor();
svg_inherited_flags._capStyle = initialCapStyle();
svg_inherited_flags._joinStyle = initialJoinStyle();
svg_inherited_flags._colorInterpolation = initialColorInterpolation();
svg_inherited_flags._colorInterpolationFilters = initialColorInterpolationFilters();
svg_inherited_flags._writingMode = initialWritingMode();
svg_inherited_flags._glyphOrientationHorizontal = initialGlyphOrientationHorizontal();
svg_inherited_flags._glyphOrientationVertical = initialGlyphOrientationVertical();
svg_noninherited_flags._niflags = 0;
svg_noninherited_flags.f._alignmentBaseline = initialAlignmentBaseline();
svg_noninherited_flags.f._dominantBaseline = initialDominantBaseline();
svg_noninherited_flags.f._baselineShift = initialBaselineShift();
}
};
}
#endif // ENABLE(SVG)
#endif // SVGRenderStyle_h