OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org> | 2 * Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org> |
3 * Copyright (C) 2004, 2005, 2006 Rob Buis <buis@kde.org> | 3 * Copyright (C) 2004, 2005, 2006 Rob Buis <buis@kde.org> |
4 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> | 4 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> |
5 * | 5 * |
6 * This library is free software; you can redistribute it and/or | 6 * This library is free software; you can redistribute it and/or |
7 * modify it under the terms of the GNU Library General Public | 7 * modify it under the terms of the GNU Library General Public |
8 * License as published by the Free Software Foundation; either | 8 * License as published by the Free Software Foundation; either |
9 * version 2 of the License, or (at your option) any later version. | 9 * version 2 of the License, or (at your option) any later version. |
10 * | 10 * |
(...skipping 10 matching lines...) Expand all Loading... |
21 | 21 |
22 #include "config.h" | 22 #include "config.h" |
23 | 23 |
24 #include "core/svg/SVGFilterPrimitiveStandardAttributes.h" | 24 #include "core/svg/SVGFilterPrimitiveStandardAttributes.h" |
25 | 25 |
26 #include "SVGNames.h" | 26 #include "SVGNames.h" |
27 #include "core/platform/graphics/filters/FilterEffect.h" | 27 #include "core/platform/graphics/filters/FilterEffect.h" |
28 #include "core/rendering/svg/RenderSVGResourceFilterPrimitive.h" | 28 #include "core/rendering/svg/RenderSVGResourceFilterPrimitive.h" |
29 #include "core/svg/SVGElementInstance.h" | 29 #include "core/svg/SVGElementInstance.h" |
30 #include "core/svg/SVGLength.h" | 30 #include "core/svg/SVGLength.h" |
31 #include "core/svg/SVGStyledElement.h" | |
32 | 31 |
33 namespace WebCore { | 32 namespace WebCore { |
34 | 33 |
35 // Animated property definitions | 34 // Animated property definitions |
36 DEFINE_ANIMATED_LENGTH(SVGFilterPrimitiveStandardAttributes, SVGNames::xAttr, X,
x) | 35 DEFINE_ANIMATED_LENGTH(SVGFilterPrimitiveStandardAttributes, SVGNames::xAttr, X,
x) |
37 DEFINE_ANIMATED_LENGTH(SVGFilterPrimitiveStandardAttributes, SVGNames::yAttr, Y,
y) | 36 DEFINE_ANIMATED_LENGTH(SVGFilterPrimitiveStandardAttributes, SVGNames::yAttr, Y,
y) |
38 DEFINE_ANIMATED_LENGTH(SVGFilterPrimitiveStandardAttributes, SVGNames::widthAttr
, Width, width) | 37 DEFINE_ANIMATED_LENGTH(SVGFilterPrimitiveStandardAttributes, SVGNames::widthAttr
, Width, width) |
39 DEFINE_ANIMATED_LENGTH(SVGFilterPrimitiveStandardAttributes, SVGNames::heightAtt
r, Height, height) | 38 DEFINE_ANIMATED_LENGTH(SVGFilterPrimitiveStandardAttributes, SVGNames::heightAtt
r, Height, height) |
40 DEFINE_ANIMATED_STRING(SVGFilterPrimitiveStandardAttributes, SVGNames::resultAtt
r, Result, result) | 39 DEFINE_ANIMATED_STRING(SVGFilterPrimitiveStandardAttributes, SVGNames::resultAtt
r, Result, result) |
41 | 40 |
42 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGFilterPrimitiveStandardAttributes) | 41 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGFilterPrimitiveStandardAttributes) |
43 REGISTER_LOCAL_ANIMATED_PROPERTY(x) | 42 REGISTER_LOCAL_ANIMATED_PROPERTY(x) |
44 REGISTER_LOCAL_ANIMATED_PROPERTY(y) | 43 REGISTER_LOCAL_ANIMATED_PROPERTY(y) |
45 REGISTER_LOCAL_ANIMATED_PROPERTY(width) | 44 REGISTER_LOCAL_ANIMATED_PROPERTY(width) |
46 REGISTER_LOCAL_ANIMATED_PROPERTY(height) | 45 REGISTER_LOCAL_ANIMATED_PROPERTY(height) |
47 REGISTER_LOCAL_ANIMATED_PROPERTY(result) | 46 REGISTER_LOCAL_ANIMATED_PROPERTY(result) |
48 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGStyledElement) | 47 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGElement) |
49 END_REGISTER_ANIMATED_PROPERTIES | 48 END_REGISTER_ANIMATED_PROPERTIES |
50 | 49 |
51 SVGFilterPrimitiveStandardAttributes::SVGFilterPrimitiveStandardAttributes(const
QualifiedName& tagName, Document* document) | 50 SVGFilterPrimitiveStandardAttributes::SVGFilterPrimitiveStandardAttributes(const
QualifiedName& tagName, Document* document) |
52 : SVGStyledElement(tagName, document) | 51 : SVGElement(tagName, document) |
53 , m_x(LengthModeWidth, "0%") | 52 , m_x(LengthModeWidth, "0%") |
54 , m_y(LengthModeHeight, "0%") | 53 , m_y(LengthModeHeight, "0%") |
55 , m_width(LengthModeWidth, "100%") | 54 , m_width(LengthModeWidth, "100%") |
56 , m_height(LengthModeHeight, "100%") | 55 , m_height(LengthModeHeight, "100%") |
57 { | 56 { |
58 // Spec: If the x/y attribute is not specified, the effect is as if a value
of "0%" were specified. | 57 // Spec: If the x/y attribute is not specified, the effect is as if a value
of "0%" were specified. |
59 // Spec: If the width/height attribute is not specified, the effect is as if
a value of "100%" were specified. | 58 // Spec: If the width/height attribute is not specified, the effect is as if
a value of "100%" were specified. |
60 registerAnimatedPropertiesForSVGFilterPrimitiveStandardAttributes(); | 59 registerAnimatedPropertiesForSVGFilterPrimitiveStandardAttributes(); |
61 } | 60 } |
62 | 61 |
63 bool SVGFilterPrimitiveStandardAttributes::isSupportedAttribute(const QualifiedN
ame& attrName) | 62 bool SVGFilterPrimitiveStandardAttributes::isSupportedAttribute(const QualifiedN
ame& attrName) |
64 { | 63 { |
65 DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, supportedAttributes, ()); | 64 DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, supportedAttributes, ()); |
66 if (supportedAttributes.isEmpty()) { | 65 if (supportedAttributes.isEmpty()) { |
67 supportedAttributes.add(SVGNames::xAttr); | 66 supportedAttributes.add(SVGNames::xAttr); |
68 supportedAttributes.add(SVGNames::yAttr); | 67 supportedAttributes.add(SVGNames::yAttr); |
69 supportedAttributes.add(SVGNames::widthAttr); | 68 supportedAttributes.add(SVGNames::widthAttr); |
70 supportedAttributes.add(SVGNames::heightAttr); | 69 supportedAttributes.add(SVGNames::heightAttr); |
71 supportedAttributes.add(SVGNames::resultAttr); | 70 supportedAttributes.add(SVGNames::resultAttr); |
72 } | 71 } |
73 return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName); | 72 return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName); |
74 } | 73 } |
75 | 74 |
76 void SVGFilterPrimitiveStandardAttributes::parseAttribute(const QualifiedName& n
ame, const AtomicString& value) | 75 void SVGFilterPrimitiveStandardAttributes::parseAttribute(const QualifiedName& n
ame, const AtomicString& value) |
77 { | 76 { |
78 SVGParsingError parseError = NoError; | 77 SVGParsingError parseError = NoError; |
79 | 78 |
80 if (!isSupportedAttribute(name)) | 79 if (!isSupportedAttribute(name)) |
81 SVGStyledElement::parseAttribute(name, value); | 80 SVGElement::parseAttribute(name, value); |
82 else if (name == SVGNames::xAttr) | 81 else if (name == SVGNames::xAttr) |
83 setXBaseValue(SVGLength::construct(LengthModeWidth, value, parseError)); | 82 setXBaseValue(SVGLength::construct(LengthModeWidth, value, parseError)); |
84 else if (name == SVGNames::yAttr) | 83 else if (name == SVGNames::yAttr) |
85 setYBaseValue(SVGLength::construct(LengthModeHeight, value, parseError))
; | 84 setYBaseValue(SVGLength::construct(LengthModeHeight, value, parseError))
; |
86 else if (name == SVGNames::widthAttr) | 85 else if (name == SVGNames::widthAttr) |
87 setWidthBaseValue(SVGLength::construct(LengthModeWidth, value, parseErro
r)); | 86 setWidthBaseValue(SVGLength::construct(LengthModeWidth, value, parseErro
r)); |
88 else if (name == SVGNames::heightAttr) | 87 else if (name == SVGNames::heightAttr) |
89 setHeightBaseValue(SVGLength::construct(LengthModeHeight, value, parseEr
ror)); | 88 setHeightBaseValue(SVGLength::construct(LengthModeHeight, value, parseEr
ror)); |
90 else if (name == SVGNames::resultAttr) | 89 else if (name == SVGNames::resultAttr) |
91 setResultBaseValue(value); | 90 setResultBaseValue(value); |
92 else | 91 else |
93 ASSERT_NOT_REACHED(); | 92 ASSERT_NOT_REACHED(); |
94 | 93 |
95 reportAttributeParsingError(parseError, name, value); | 94 reportAttributeParsingError(parseError, name, value); |
96 } | 95 } |
97 | 96 |
98 bool SVGFilterPrimitiveStandardAttributes::setFilterEffectAttribute(FilterEffect
*, const QualifiedName&) | 97 bool SVGFilterPrimitiveStandardAttributes::setFilterEffectAttribute(FilterEffect
*, const QualifiedName&) |
99 { | 98 { |
100 // When all filters support this method, it will be changed to a pure virtua
l method. | 99 // When all filters support this method, it will be changed to a pure virtua
l method. |
101 ASSERT_NOT_REACHED(); | 100 ASSERT_NOT_REACHED(); |
102 return false; | 101 return false; |
103 } | 102 } |
104 | 103 |
105 void SVGFilterPrimitiveStandardAttributes::svgAttributeChanged(const QualifiedNa
me& attrName) | 104 void SVGFilterPrimitiveStandardAttributes::svgAttributeChanged(const QualifiedNa
me& attrName) |
106 { | 105 { |
107 if (!isSupportedAttribute(attrName)) { | 106 if (!isSupportedAttribute(attrName)) { |
108 SVGStyledElement::svgAttributeChanged(attrName); | 107 SVGElement::svgAttributeChanged(attrName); |
109 return; | 108 return; |
110 } | 109 } |
111 | 110 |
112 SVGElementInstance::InvalidationGuard invalidationGuard(this); | 111 SVGElementInstance::InvalidationGuard invalidationGuard(this); |
113 invalidate(); | 112 invalidate(); |
114 } | 113 } |
115 | 114 |
116 void SVGFilterPrimitiveStandardAttributes::childrenChanged(bool changedByParser,
Node* beforeChange, Node* afterChange, int childCountDelta) | 115 void SVGFilterPrimitiveStandardAttributes::childrenChanged(bool changedByParser,
Node* beforeChange, Node* afterChange, int childCountDelta) |
117 { | 116 { |
118 SVGStyledElement::childrenChanged(changedByParser, beforeChange, afterChange
, childCountDelta); | 117 SVGElement::childrenChanged(changedByParser, beforeChange, afterChange, chil
dCountDelta); |
119 | 118 |
120 if (!changedByParser) | 119 if (!changedByParser) |
121 invalidate(); | 120 invalidate(); |
122 } | 121 } |
123 | 122 |
124 void SVGFilterPrimitiveStandardAttributes::setStandardAttributes(FilterEffect* f
ilterEffect) const | 123 void SVGFilterPrimitiveStandardAttributes::setStandardAttributes(FilterEffect* f
ilterEffect) const |
125 { | 124 { |
126 ASSERT(filterEffect); | 125 ASSERT(filterEffect); |
127 if (!filterEffect) | 126 if (!filterEffect) |
128 return; | 127 return; |
129 | 128 |
130 if (hasAttribute(SVGNames::xAttr)) | 129 if (hasAttribute(SVGNames::xAttr)) |
131 filterEffect->setHasX(true); | 130 filterEffect->setHasX(true); |
132 if (hasAttribute(SVGNames::yAttr)) | 131 if (hasAttribute(SVGNames::yAttr)) |
133 filterEffect->setHasY(true); | 132 filterEffect->setHasY(true); |
134 if (hasAttribute(SVGNames::widthAttr)) | 133 if (hasAttribute(SVGNames::widthAttr)) |
135 filterEffect->setHasWidth(true); | 134 filterEffect->setHasWidth(true); |
136 if (hasAttribute(SVGNames::heightAttr)) | 135 if (hasAttribute(SVGNames::heightAttr)) |
137 filterEffect->setHasHeight(true); | 136 filterEffect->setHasHeight(true); |
138 } | 137 } |
139 | 138 |
140 RenderObject* SVGFilterPrimitiveStandardAttributes::createRenderer(RenderStyle*) | 139 RenderObject* SVGFilterPrimitiveStandardAttributes::createRenderer(RenderStyle*) |
141 { | 140 { |
142 return new RenderSVGResourceFilterPrimitive(this); | 141 return new RenderSVGResourceFilterPrimitive(this); |
143 } | 142 } |
144 | 143 |
145 bool SVGFilterPrimitiveStandardAttributes::rendererIsNeeded(const NodeRenderingC
ontext& context) | 144 bool SVGFilterPrimitiveStandardAttributes::rendererIsNeeded(const NodeRenderingC
ontext& context) |
146 { | 145 { |
147 if (parentNode() && (parentNode()->hasTagName(SVGNames::filterTag))) | 146 if (parentNode() && (parentNode()->hasTagName(SVGNames::filterTag))) |
148 return SVGStyledElement::rendererIsNeeded(context); | 147 return rendererIsNeededInternal(context); |
149 | 148 |
150 return false; | 149 return false; |
151 } | 150 } |
152 | 151 |
153 void SVGFilterPrimitiveStandardAttributes::primitiveAttributeChanged(const Quali
fiedName& attribute) | 152 void SVGFilterPrimitiveStandardAttributes::primitiveAttributeChanged(const Quali
fiedName& attribute) |
154 { | 153 { |
155 if (RenderObject* primitiveRenderer = renderer()) | 154 if (RenderObject* primitiveRenderer = renderer()) |
156 static_cast<RenderSVGResourceFilterPrimitive*>(primitiveRenderer)->primi
tiveAttributeChanged(attribute); | 155 static_cast<RenderSVGResourceFilterPrimitive*>(primitiveRenderer)->primi
tiveAttributeChanged(attribute); |
157 } | 156 } |
158 | 157 |
159 void invalidateFilterPrimitiveParent(SVGElement* element) | 158 void invalidateFilterPrimitiveParent(SVGElement* element) |
160 { | 159 { |
161 if (!element) | 160 if (!element) |
162 return; | 161 return; |
163 | 162 |
164 ContainerNode* parent = element->parentNode(); | 163 ContainerNode* parent = element->parentNode(); |
165 | 164 |
166 if (!parent) | 165 if (!parent) |
167 return; | 166 return; |
168 | 167 |
169 RenderObject* renderer = parent->renderer(); | 168 RenderObject* renderer = parent->renderer(); |
170 if (!renderer || !renderer->isSVGResourceFilterPrimitive()) | 169 if (!renderer || !renderer->isSVGResourceFilterPrimitive()) |
171 return; | 170 return; |
172 | 171 |
173 RenderSVGResource::markForLayoutAndParentResourceInvalidation(renderer, fals
e); | 172 RenderSVGResource::markForLayoutAndParentResourceInvalidation(renderer, fals
e); |
174 } | 173 } |
175 | 174 |
176 } | 175 } |
OLD | NEW |