OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org> | 2 * Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org> |
3 * Copyright (C) 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org> | 3 * Copyright (C) 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org> |
4 * Copyright (C) Research In Motion Limited 2010. All rights reserved. | 4 * Copyright (C) Research In Motion Limited 2010. All rights reserved. |
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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 | 42 |
43 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGGradientElement) | 43 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGGradientElement) |
44 REGISTER_LOCAL_ANIMATED_PROPERTY(spreadMethod) | 44 REGISTER_LOCAL_ANIMATED_PROPERTY(spreadMethod) |
45 REGISTER_LOCAL_ANIMATED_PROPERTY(gradientUnits) | 45 REGISTER_LOCAL_ANIMATED_PROPERTY(gradientUnits) |
46 REGISTER_LOCAL_ANIMATED_PROPERTY(gradientTransform) | 46 REGISTER_LOCAL_ANIMATED_PROPERTY(gradientTransform) |
47 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGElement) | 47 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGElement) |
48 END_REGISTER_ANIMATED_PROPERTIES | 48 END_REGISTER_ANIMATED_PROPERTIES |
49 | 49 |
50 SVGGradientElement::SVGGradientElement(const QualifiedName& tagName, Document& d
ocument) | 50 SVGGradientElement::SVGGradientElement(const QualifiedName& tagName, Document& d
ocument) |
51 : SVGElement(tagName, document) | 51 : SVGElement(tagName, document) |
52 , m_href(SVGAnimatedString::create(this, XLinkNames::hrefAttr, SVGString::cr
eate())) | 52 , SVGURIReference(this) |
53 , m_spreadMethod(SVGSpreadMethodPad) | 53 , m_spreadMethod(SVGSpreadMethodPad) |
54 , m_gradientUnits(SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) | 54 , m_gradientUnits(SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) |
55 { | 55 { |
56 ScriptWrappable::init(this); | 56 ScriptWrappable::init(this); |
57 addToPropertyMap(m_href); | |
58 registerAnimatedPropertiesForSVGGradientElement(); | 57 registerAnimatedPropertiesForSVGGradientElement(); |
59 } | 58 } |
60 | 59 |
61 bool SVGGradientElement::isSupportedAttribute(const QualifiedName& attrName) | 60 bool SVGGradientElement::isSupportedAttribute(const QualifiedName& attrName) |
62 { | 61 { |
63 DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, supportedAttributes, ()); | 62 DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, supportedAttributes, ()); |
64 if (supportedAttributes.isEmpty()) { | 63 if (supportedAttributes.isEmpty()) { |
65 SVGURIReference::addSupportedAttributes(supportedAttributes); | 64 SVGURIReference::addSupportedAttributes(supportedAttributes); |
66 supportedAttributes.add(SVGNames::gradientUnitsAttr); | 65 supportedAttributes.add(SVGNames::gradientUnitsAttr); |
67 supportedAttributes.add(SVGNames::gradientTransformAttr); | 66 supportedAttributes.add(SVGNames::gradientTransformAttr); |
(...skipping 26 matching lines...) Expand all Loading... |
94 | 93 |
95 if (name == SVGNames::spreadMethodAttr) { | 94 if (name == SVGNames::spreadMethodAttr) { |
96 SVGSpreadMethodType propertyValue = SVGPropertyTraits<SVGSpreadMethodTyp
e>::fromString(value); | 95 SVGSpreadMethodType propertyValue = SVGPropertyTraits<SVGSpreadMethodTyp
e>::fromString(value); |
97 if (propertyValue > 0) | 96 if (propertyValue > 0) |
98 setSpreadMethodBaseValue(propertyValue); | 97 setSpreadMethodBaseValue(propertyValue); |
99 return; | 98 return; |
100 } | 99 } |
101 | 100 |
102 SVGParsingError parseError = NoError; | 101 SVGParsingError parseError = NoError; |
103 | 102 |
104 if (name.matches(XLinkNames::hrefAttr)) | 103 if (SVGURIReference::parseAttribute(name, value, parseError)) { |
105 m_href->setBaseValueAsString(value, parseError); | 104 } else { |
106 else | |
107 ASSERT_NOT_REACHED(); | 105 ASSERT_NOT_REACHED(); |
| 106 } |
108 | 107 |
109 reportAttributeParsingError(parseError, name, value); | 108 reportAttributeParsingError(parseError, name, value); |
110 } | 109 } |
111 | 110 |
112 void SVGGradientElement::svgAttributeChanged(const QualifiedName& attrName) | 111 void SVGGradientElement::svgAttributeChanged(const QualifiedName& attrName) |
113 { | 112 { |
114 if (!isSupportedAttribute(attrName)) { | 113 if (!isSupportedAttribute(attrName)) { |
115 SVGElement::svgAttributeChanged(attrName); | 114 SVGElement::svgAttributeChanged(attrName); |
116 return; | 115 return; |
117 } | 116 } |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 float r, g, b, a; | 156 float r, g, b, a; |
158 color.getRGBA(r, g, b, a); | 157 color.getRGBA(r, g, b, a); |
159 | 158 |
160 stops.append(Gradient::ColorStop(offset, r, g, b, a)); | 159 stops.append(Gradient::ColorStop(offset, r, g, b, a)); |
161 } | 160 } |
162 | 161 |
163 return stops; | 162 return stops; |
164 } | 163 } |
165 | 164 |
166 } | 165 } |
OLD | NEW |