26 #if ENABLE(SVG) && ENABLE(SVG_FILTERS)
38 SVGFilterElement::SVGFilterElement(
const QualifiedName& tagName, Document* doc)
39 : SVGStyledElement(tagName, doc)
42 , SVGExternalResourcesRequired()
43 , m_filterUnits(SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX)
44 , m_primitiveUnits(SVGUnitTypes::SVG_UNIT_TYPE_USERSPACEONUSE)
45 , m_x(this, LengthModeWidth)
46 , m_y(this, LengthModeHeight)
47 , m_width(this, LengthModeWidth)
48 , m_height(this, LengthModeHeight)
53 setXBaseValue(SVGLength(
this, LengthModeWidth,
"-10%"));
54 setYBaseValue(SVGLength(
this, LengthModeHeight,
"-10%"));
57 setWidthBaseValue(SVGLength(
this, LengthModeWidth,
"120%"));
58 setHeightBaseValue(SVGLength(
this, LengthModeHeight,
"120%"));
61 SVGFilterElement::~SVGFilterElement()
65 ANIMATED_PROPERTY_DEFINITIONS(SVGFilterElement,
int, Enumeration, enumeration, FilterUnits, filterUnits,
SVGNames::filterUnitsAttr, m_filterUnits)
66 ANIMATED_PROPERTY_DEFINITIONS(SVGFilterElement,
int, Enumeration, enumeration, PrimitiveUnits, primitiveUnits, SVGNames::
primitiveUnitsAttr, m_primitiveUnits)
67 ANIMATED_PROPERTY_DEFINITIONS(SVGFilterElement, SVGLength, Length, length, X, x, SVGNames::
xAttr, m_x)
68 ANIMATED_PROPERTY_DEFINITIONS(SVGFilterElement, SVGLength, Length, length, Y, y, SVGNames::
yAttr, m_y)
69 ANIMATED_PROPERTY_DEFINITIONS(SVGFilterElement, SVGLength, Length, length, Width, width, SVGNames::
widthAttr, m_width)
70 ANIMATED_PROPERTY_DEFINITIONS(SVGFilterElement, SVGLength, Length, length, Height, height, SVGNames::
heightAttr, m_height)
71 ANIMATED_PROPERTY_DEFINITIONS_WITH_CUSTOM_IDENTIFIER(SVGFilterElement,
long, Integer, integer, FilterResX, filterResX, SVGNames::
filterResAttr, "filterResX", m_filterResX)
72 ANIMATED_PROPERTY_DEFINITIONS_WITH_CUSTOM_IDENTIFIER(SVGFilterElement,
long, Integer, integer, FilterResY, filterResY, SVGNames::filterResAttr, "filterResY", m_filterResY)
74 void SVGFilterElement::setFilterRes(
unsigned long,
unsigned long)
const
78 void SVGFilterElement::parseMappedAttribute(MappedAttribute* attr)
80 const String& value = attr->value();
82 if (value ==
"userSpaceOnUse")
83 setFilterUnitsBaseValue(SVGUnitTypes::SVG_UNIT_TYPE_USERSPACEONUSE);
84 else if (value ==
"objectBoundingBox")
85 setFilterUnitsBaseValue(SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX);
87 if (value ==
"userSpaceOnUse")
88 setPrimitiveUnitsBaseValue(SVGUnitTypes::SVG_UNIT_TYPE_USERSPACEONUSE);
89 else if (value ==
"objectBoundingBox")
90 setPrimitiveUnitsBaseValue(SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX);
92 setXBaseValue(SVGLength(
this, LengthModeWidth, value));
94 setYBaseValue(SVGLength(
this, LengthModeHeight, value));
96 setWidthBaseValue(SVGLength(
this, LengthModeWidth, value));
98 setHeightBaseValue(SVGLength(
this, LengthModeHeight, value));
100 if (SVGURIReference::parseMappedAttribute(attr))
return;
101 if (SVGLangSpace::parseMappedAttribute(attr))
return;
102 if (SVGExternalResourcesRequired::parseMappedAttribute(attr))
return;
104 SVGStyledElement::parseMappedAttribute(attr);
108 SVGResource* SVGFilterElement::canvasResource()
114 m_filter =
new SVGResourceFilter();
116 bool filterBBoxMode = filterUnits() == SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX;
117 m_filter->setFilterBoundingBoxMode(filterBBoxMode);
119 float _x, _y, _width, _height;
121 if (filterBBoxMode) {
122 _x = x().valueAsPercentage();
123 _y = y().valueAsPercentage();
124 _width = width().valueAsPercentage();
125 _height = height().valueAsPercentage();
127 m_filter->setXBoundingBoxMode(x().unitType() == LengthTypePercentage);
128 m_filter->setYBoundingBoxMode(y().unitType() == LengthTypePercentage);
132 _width = width().value();
133 _height = height().value();
136 m_filter->setFilterRect(FloatRect(_x, _y, _width, _height));
138 bool primitiveBBoxMode = primitiveUnits() == SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX;
139 m_filter->setEffectBoundingBoxMode(primitiveBBoxMode);
142 m_filter->clearEffects();
143 for (Node* n = firstChild(); n != 0; n = n->nextSibling()) {
144 SVGElement* element = 0;
145 if (n->isSVGElement())
146 element = static_cast<SVGElement*>(n);
147 if (element && element->isFilterEffect()) {
148 SVGFilterPrimitiveStandardAttributes* filterAttributes =
static_cast<SVGFilterPrimitiveStandardAttributes*
>(element);
149 SVGFilterEffect* filterEffect = filterAttributes->filterEffect(m_filter.get());
153 m_filter->addFilterEffect(filterEffect);
157 return m_filter.get();
162 #endif // ENABLE(SVG)
DOM::QualifiedName widthAttr
DOM::QualifiedName filterUnitsAttr
DOM::QualifiedName filterResAttr
DOM::QualifiedName primitiveUnitsAttr
DOM::QualifiedName heightAttr