24 #include "wtf/Platform.h"
29 #include "css/cssstyleselector.h"
30 #include "RenderPath.h"
31 #include "RenderSVGHiddenContainer.h"
42 SVGGradientElement::SVGGradientElement(
const QualifiedName& tagName, Document* doc)
43 : SVGStyledElement(tagName, doc)
45 , SVGExternalResourcesRequired()
47 , m_gradientUnits(SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX)
52 SVGGradientElement::~SVGGradientElement()
56 ANIMATED_PROPERTY_DEFINITIONS(SVGGradientElement,
int, Enumeration, enumeration, GradientUnits, gradientUnits,
SVGNames::gradientUnitsAttr, m_gradientUnits)
57 ANIMATED_PROPERTY_DEFINITIONS(SVGGradientElement, SVGTransformList*, TransformList, transformList, GradientTransform, gradientTransform, SVGNames::
gradientTransformAttr, m_gradientTransform.get())
58 ANIMATED_PROPERTY_DEFINITIONS(SVGGradientElement,
int, Enumeration, enumeration, SpreadMethod, spreadMethod, SVGNames::
spreadMethodAttr, m_spreadMethod)
60 void SVGGradientElement::parseMappedAttribute(MappedAttribute* attr)
63 if (attr->value() ==
"userSpaceOnUse")
64 setGradientUnitsBaseValue(SVGUnitTypes::SVG_UNIT_TYPE_USERSPACEONUSE);
65 else if (attr->value() ==
"objectBoundingBox")
66 setGradientUnitsBaseValue(SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX);
68 SVGTransformList* gradientTransforms = gradientTransformBaseValue();
69 if (!SVGTransformable::parseTransformAttribute(gradientTransforms, attr->value())) {
71 gradientTransforms->clear(ec);
74 if (attr->value() ==
"reflect")
75 setSpreadMethodBaseValue(SVG_SPREADMETHOD_REFLECT);
76 else if (attr->value() ==
"repeat")
77 setSpreadMethodBaseValue(SVG_SPREADMETHOD_REPEAT);
78 else if (attr->value() ==
"pad")
79 setSpreadMethodBaseValue(SVG_SPREADMETHOD_PAD);
81 if (SVGURIReference::parseMappedAttribute(attr))
83 if (SVGExternalResourcesRequired::parseMappedAttribute(attr))
86 SVGStyledElement::parseMappedAttribute(attr);
90 void SVGGradientElement::svgAttributeChanged(
const QualifiedName& attrName)
92 SVGStyledElement::svgAttributeChanged(attrName);
100 SVGURIReference::isKnownAttribute(attrName) ||
101 SVGExternalResourcesRequired::isKnownAttribute(attrName) ||
102 SVGStyledElement::isKnownAttribute(attrName))
103 m_resource->invalidate();
106 void SVGGradientElement::childrenChanged(
bool changedByParser, Node* beforeChange, Node* afterChange,
int childCountDelta)
108 SVGStyledElement::childrenChanged(changedByParser, beforeChange, afterChange, childCountDelta);
111 m_resource->invalidate();
114 RenderObject* SVGGradientElement::createRenderer(RenderArena* arena, RenderStyle*)
116 return new (arena) RenderSVGHiddenContainer(
this);
119 SVGResource* SVGGradientElement::canvasResource()
121 kDebug() <<
"request gradient paint server" << endl;
123 if (gradientType() == LinearGradientPaintServer)
124 m_resource = SVGPaintServerLinearGradient::create(
this);
126 m_resource = SVGPaintServerRadialGradient::create(
this);
129 return m_resource.get();
132 Vector<SVGGradientStop> SVGGradientElement::buildStops()
const
134 Vector<SVGGradientStop> stops;
136 for (Node* n = firstChild(); n; n = n->nextSibling()) {
137 SVGElement* element = n->isSVGElement() ?
static_cast<SVGElement*
>(n) : 0;
139 if (element && element->isGradientStop()) {
140 SVGStopElement*
stop =
static_cast<SVGStopElement*
>(element);
141 float stopOffset = stop->offset();
143 RenderStyle* stopStyle = stop->computedStyle();
144 QColor color = stopStyle->svgStyle()->stopColor();
145 float opacity = stopStyle->svgStyle()->stopOpacity();
147 stops.append(makeGradientStop(stopOffset,
QColor(color.red(), color.green(), color.blue(), int(opacity * 255.))));
156 #endif // ENABLE(SVG)
DOM::QualifiedName spreadMethodAttr
static QDebug kDebug(bool cond, int area=KDE_DEFAULT_DEBUG_AREA)
KAction * create(StandardAction id, const QObject *recvr, const char *slot, QObject *parent)
DOM::QualifiedName gradientTransformAttr
DOM::QualifiedName gradientUnitsAttr