OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Nikolas Zimmermann <zimmermann@kde
.org> | 2 * Copyright (C) 2004, 2005, 2006, 2007, 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 28 matching lines...) Expand all Loading... |
39 | 39 |
40 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGPatternElement) | 40 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGPatternElement) |
41 REGISTER_LOCAL_ANIMATED_PROPERTY(patternUnits) | 41 REGISTER_LOCAL_ANIMATED_PROPERTY(patternUnits) |
42 REGISTER_LOCAL_ANIMATED_PROPERTY(patternContentUnits) | 42 REGISTER_LOCAL_ANIMATED_PROPERTY(patternContentUnits) |
43 REGISTER_LOCAL_ANIMATED_PROPERTY(patternTransform) | 43 REGISTER_LOCAL_ANIMATED_PROPERTY(patternTransform) |
44 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGElement) | 44 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGElement) |
45 END_REGISTER_ANIMATED_PROPERTIES | 45 END_REGISTER_ANIMATED_PROPERTIES |
46 | 46 |
47 inline SVGPatternElement::SVGPatternElement(Document& document) | 47 inline SVGPatternElement::SVGPatternElement(Document& document) |
48 : SVGElement(SVGNames::patternTag, document) | 48 : SVGElement(SVGNames::patternTag, document) |
| 49 , SVGURIReference(this) |
49 , SVGTests(this) | 50 , SVGTests(this) |
50 , m_x(SVGAnimatedLength::create(this, SVGNames::xAttr, SVGLength::create(Len
gthModeWidth))) | 51 , m_x(SVGAnimatedLength::create(this, SVGNames::xAttr, SVGLength::create(Len
gthModeWidth))) |
51 , m_y(SVGAnimatedLength::create(this, SVGNames::yAttr, SVGLength::create(Len
gthModeHeight))) | 52 , m_y(SVGAnimatedLength::create(this, SVGNames::yAttr, SVGLength::create(Len
gthModeHeight))) |
52 , m_width(SVGAnimatedLength::create(this, SVGNames::widthAttr, SVGLength::cr
eate(LengthModeWidth))) | 53 , m_width(SVGAnimatedLength::create(this, SVGNames::widthAttr, SVGLength::cr
eate(LengthModeWidth))) |
53 , m_height(SVGAnimatedLength::create(this, SVGNames::heightAttr, SVGLength::
create(LengthModeHeight))) | 54 , m_height(SVGAnimatedLength::create(this, SVGNames::heightAttr, SVGLength::
create(LengthModeHeight))) |
54 , m_viewBox(SVGAnimatedRect::create(this, SVGNames::viewBoxAttr)) | 55 , m_viewBox(SVGAnimatedRect::create(this, SVGNames::viewBoxAttr)) |
55 , m_preserveAspectRatio(SVGAnimatedPreserveAspectRatio::create(this, SVGName
s::preserveAspectRatioAttr, SVGPreserveAspectRatio::create())) | 56 , m_preserveAspectRatio(SVGAnimatedPreserveAspectRatio::create(this, SVGName
s::preserveAspectRatioAttr, SVGPreserveAspectRatio::create())) |
56 , m_href(SVGAnimatedString::create(this, XLinkNames::hrefAttr, SVGString::cr
eate())) | |
57 , m_patternUnits(SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) | 57 , m_patternUnits(SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) |
58 , m_patternContentUnits(SVGUnitTypes::SVG_UNIT_TYPE_USERSPACEONUSE) | 58 , m_patternContentUnits(SVGUnitTypes::SVG_UNIT_TYPE_USERSPACEONUSE) |
59 { | 59 { |
60 ScriptWrappable::init(this); | 60 ScriptWrappable::init(this); |
61 | 61 |
62 addToPropertyMap(m_x); | 62 addToPropertyMap(m_x); |
63 addToPropertyMap(m_y); | 63 addToPropertyMap(m_y); |
64 addToPropertyMap(m_width); | 64 addToPropertyMap(m_width); |
65 addToPropertyMap(m_height); | 65 addToPropertyMap(m_height); |
66 addToPropertyMap(m_viewBox); | 66 addToPropertyMap(m_viewBox); |
67 addToPropertyMap(m_preserveAspectRatio); | 67 addToPropertyMap(m_preserveAspectRatio); |
68 addToPropertyMap(m_href); | |
69 registerAnimatedPropertiesForSVGPatternElement(); | 68 registerAnimatedPropertiesForSVGPatternElement(); |
70 } | 69 } |
71 | 70 |
72 PassRefPtr<SVGPatternElement> SVGPatternElement::create(Document& document) | 71 PassRefPtr<SVGPatternElement> SVGPatternElement::create(Document& document) |
73 { | 72 { |
74 return adoptRef(new SVGPatternElement(document)); | 73 return adoptRef(new SVGPatternElement(document)); |
75 } | 74 } |
76 | 75 |
77 bool SVGPatternElement::isSupportedAttribute(const QualifiedName& attrName) | 76 bool SVGPatternElement::isSupportedAttribute(const QualifiedName& attrName) |
78 { | 77 { |
(...skipping 10 matching lines...) Expand all Loading... |
89 supportedAttributes.add(SVGNames::widthAttr); | 88 supportedAttributes.add(SVGNames::widthAttr); |
90 supportedAttributes.add(SVGNames::heightAttr); | 89 supportedAttributes.add(SVGNames::heightAttr); |
91 } | 90 } |
92 return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName); | 91 return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName); |
93 } | 92 } |
94 | 93 |
95 void SVGPatternElement::parseAttribute(const QualifiedName& name, const AtomicSt
ring& value) | 94 void SVGPatternElement::parseAttribute(const QualifiedName& name, const AtomicSt
ring& value) |
96 { | 95 { |
97 SVGParsingError parseError = NoError; | 96 SVGParsingError parseError = NoError; |
98 | 97 |
99 if (!isSupportedAttribute(name)) | 98 if (!isSupportedAttribute(name)) { |
100 SVGElement::parseAttribute(name, value); | 99 SVGElement::parseAttribute(name, value); |
101 else if (name == SVGNames::patternUnitsAttr) { | 100 } else if (name == SVGNames::patternUnitsAttr) { |
102 SVGUnitTypes::SVGUnitType propertyValue = SVGPropertyTraits<SVGUnitTypes
::SVGUnitType>::fromString(value); | 101 SVGUnitTypes::SVGUnitType propertyValue = SVGPropertyTraits<SVGUnitTypes
::SVGUnitType>::fromString(value); |
103 if (propertyValue > 0) | 102 if (propertyValue > 0) |
104 setPatternUnitsBaseValue(propertyValue); | 103 setPatternUnitsBaseValue(propertyValue); |
105 return; | 104 return; |
106 } else if (name == SVGNames::patternContentUnitsAttr) { | 105 } else if (name == SVGNames::patternContentUnitsAttr) { |
107 SVGUnitTypes::SVGUnitType propertyValue = SVGPropertyTraits<SVGUnitTypes
::SVGUnitType>::fromString(value); | 106 SVGUnitTypes::SVGUnitType propertyValue = SVGPropertyTraits<SVGUnitTypes
::SVGUnitType>::fromString(value); |
108 if (propertyValue > 0) | 107 if (propertyValue > 0) |
109 setPatternContentUnitsBaseValue(propertyValue); | 108 setPatternContentUnitsBaseValue(propertyValue); |
110 return; | 109 return; |
111 } else if (name == SVGNames::patternTransformAttr) { | 110 } else if (name == SVGNames::patternTransformAttr) { |
112 SVGTransformList newList; | 111 SVGTransformList newList; |
113 newList.parse(value); | 112 newList.parse(value); |
114 detachAnimatedPatternTransformListWrappers(newList.size()); | 113 detachAnimatedPatternTransformListWrappers(newList.size()); |
115 setPatternTransformBaseValue(newList); | 114 setPatternTransformBaseValue(newList); |
116 return; | 115 return; |
117 } else if (name == SVGNames::xAttr) | 116 } else if (name == SVGNames::xAttr) { |
118 m_x->setBaseValueAsString(value, AllowNegativeLengths, parseError); | 117 m_x->setBaseValueAsString(value, AllowNegativeLengths, parseError); |
119 else if (name == SVGNames::yAttr) | 118 } else if (name == SVGNames::yAttr) { |
120 m_y->setBaseValueAsString(value, AllowNegativeLengths, parseError); | 119 m_y->setBaseValueAsString(value, AllowNegativeLengths, parseError); |
121 else if (name == SVGNames::widthAttr) | 120 } else if (name == SVGNames::widthAttr) { |
122 m_width->setBaseValueAsString(value, ForbidNegativeLengths, parseError); | 121 m_width->setBaseValueAsString(value, ForbidNegativeLengths, parseError); |
123 else if (name == SVGNames::heightAttr) | 122 } else if (name == SVGNames::heightAttr) { |
124 m_height->setBaseValueAsString(value, ForbidNegativeLengths, parseError)
; | 123 m_height->setBaseValueAsString(value, ForbidNegativeLengths, parseError)
; |
125 else if (name.matches(XLinkNames::hrefAttr)) | 124 } else if (SVGURIReference::parseAttribute(name, value, parseError)) { |
126 m_href->setBaseValueAsString(value, parseError); | 125 } else if (SVGTests::parseAttribute(name, value)) { |
127 else if (SVGTests::parseAttribute(name, value) | 126 } else if (SVGFitToViewBox::parseAttribute(this, name, value)) { |
128 || SVGFitToViewBox::parseAttribute(this, name, value)) { | 127 } else { |
129 } else | |
130 ASSERT_NOT_REACHED(); | 128 ASSERT_NOT_REACHED(); |
| 129 } |
131 | 130 |
132 reportAttributeParsingError(parseError, name, value); | 131 reportAttributeParsingError(parseError, name, value); |
133 } | 132 } |
134 | 133 |
135 void SVGPatternElement::svgAttributeChanged(const QualifiedName& attrName) | 134 void SVGPatternElement::svgAttributeChanged(const QualifiedName& attrName) |
136 { | 135 { |
137 if (!isSupportedAttribute(attrName)) { | 136 if (!isSupportedAttribute(attrName)) { |
138 SVGElement::svgAttributeChanged(attrName); | 137 SVGElement::svgAttributeChanged(attrName); |
139 return; | 138 return; |
140 } | 139 } |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 void SVGPatternElement::collectPatternAttributes(PatternAttributes& attributes)
const | 206 void SVGPatternElement::collectPatternAttributes(PatternAttributes& attributes)
const |
208 { | 207 { |
209 HashSet<const SVGPatternElement*> processedPatterns; | 208 HashSet<const SVGPatternElement*> processedPatterns; |
210 const SVGPatternElement* current = this; | 209 const SVGPatternElement* current = this; |
211 | 210 |
212 while (true) { | 211 while (true) { |
213 setPatternAttributes(current, attributes); | 212 setPatternAttributes(current, attributes); |
214 processedPatterns.add(current); | 213 processedPatterns.add(current); |
215 | 214 |
216 // Respect xlink:href, take attributes from referenced element | 215 // Respect xlink:href, take attributes from referenced element |
217 Node* refNode = SVGURIReference::targetElementFromIRIString(current->m_h
ref->currentValue()->value(), document()); | 216 Node* refNode = SVGURIReference::targetElementFromIRIString(current->hre
fString(), document()); |
218 if (refNode && refNode->hasTagName(SVGNames::patternTag)) { | 217 if (refNode && refNode->hasTagName(SVGNames::patternTag)) { |
219 current = toSVGPatternElement(const_cast<const Node*>(refNode)); | 218 current = toSVGPatternElement(const_cast<const Node*>(refNode)); |
220 | 219 |
221 // Cycle detection | 220 // Cycle detection |
222 if (processedPatterns.contains(current)) | 221 if (processedPatterns.contains(current)) |
223 return; | 222 return; |
224 } else { | 223 } else { |
225 return; | 224 return; |
226 } | 225 } |
227 } | 226 } |
(...skipping 10 matching lines...) Expand all Loading... |
238 | 237 |
239 bool SVGPatternElement::selfHasRelativeLengths() const | 238 bool SVGPatternElement::selfHasRelativeLengths() const |
240 { | 239 { |
241 return m_x->currentValue()->isRelative() | 240 return m_x->currentValue()->isRelative() |
242 || m_y->currentValue()->isRelative() | 241 || m_y->currentValue()->isRelative() |
243 || m_width->currentValue()->isRelative() | 242 || m_width->currentValue()->isRelative() |
244 || m_height->currentValue()->isRelative(); | 243 || m_height->currentValue()->isRelative(); |
245 } | 244 } |
246 | 245 |
247 } | 246 } |
OLD | NEW |