| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004, 2005 Nikolas Zimmermann <zimmermann@kde.org> | 2 * Copyright (C) 2004, 2005 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) 2007 Eric Seidel <eric@webkit.org> | 4 * Copyright (C) 2007 Eric Seidel <eric@webkit.org> |
| 5 * Copyright (C) 2008 Apple Inc. All rights reserved. | 5 * Copyright (C) 2008 Apple Inc. All rights reserved. |
| 6 * Copyright (C) 2009 Cameron McCormack <cam@mcc.id.au> | 6 * Copyright (C) 2009 Cameron McCormack <cam@mcc.id.au> |
| 7 * Copyright (C) Research In Motion Limited 2010. All rights reserved. | 7 * Copyright (C) Research In Motion Limited 2010. All rights reserved. |
| 8 * | 8 * |
| 9 * This library is free software; you can redistribute it and/or | 9 * This library is free software; you can redistribute it and/or |
| 10 * modify it under the terms of the GNU Library General Public | 10 * modify it under the terms of the GNU Library General Public |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 , m_toPropertyValueType(RegularPropertyValue) | 45 , m_toPropertyValueType(RegularPropertyValue) |
| 46 , m_animationValid(false) | 46 , m_animationValid(false) |
| 47 , m_attributeType(AttributeTypeAuto) | 47 , m_attributeType(AttributeTypeAuto) |
| 48 , m_hasInvalidCSSAttributeType(false) | 48 , m_hasInvalidCSSAttributeType(false) |
| 49 , m_calcMode(CalcModeLinear) | 49 , m_calcMode(CalcModeLinear) |
| 50 , m_animationMode(NoAnimation) | 50 , m_animationMode(NoAnimation) |
| 51 { | 51 { |
| 52 UseCounter::count(document, UseCounter::SVGAnimationElement); | 52 UseCounter::count(document, UseCounter::SVGAnimationElement); |
| 53 } | 53 } |
| 54 | 54 |
| 55 static void parseKeyTimes(const String& string, Vector<float>& result, bool veri
fyOrder) | 55 static bool parseValues(const String& value, Vector<String>& result) |
| 56 { |
| 57 // Per the SMIL specification, leading and trailing white space, |
| 58 // and white space before and after semicolon separators, is allowed and wil
l be ignored. |
| 59 // http://www.w3.org/TR/SVG11/animate.html#ValuesAttribute |
| 60 result.clear(); |
| 61 Vector<String> parseList; |
| 62 value.split(';', true, parseList); |
| 63 unsigned last = parseList.size() - 1; |
| 64 for (unsigned i = 0; i <= last; ++i) { |
| 65 if (parseList[i].isEmpty()) { |
| 66 // Tolerate trailing ';' |
| 67 if (i < last) |
| 68 goto fail; |
| 69 } else { |
| 70 parseList[i] = parseList[i].stripWhiteSpace(); |
| 71 result.append(parseList[i]); |
| 72 } |
| 73 } |
| 74 |
| 75 return true; |
| 76 fail: |
| 77 result.clear(); |
| 78 return false; |
| 79 } |
| 80 |
| 81 static bool parseKeyTimes(const String& string, Vector<float>& result, bool veri
fyOrder) |
| 56 { | 82 { |
| 57 result.clear(); | 83 result.clear(); |
| 58 Vector<String> parseList; | 84 Vector<String> parseList; |
| 59 string.split(';', parseList); | 85 string.split(';', true, parseList); |
| 60 for (unsigned n = 0; n < parseList.size(); ++n) { | 86 for (unsigned n = 0; n < parseList.size(); ++n) { |
| 61 String timeString = parseList[n]; | 87 String timeString = parseList[n]; |
| 62 bool ok; | 88 bool ok; |
| 63 float time = timeString.toFloat(&ok); | 89 float time = timeString.toFloat(&ok); |
| 64 if (!ok || time < 0 || time > 1) | 90 if (!ok || time < 0 || time > 1) |
| 65 goto fail; | 91 goto fail; |
| 66 if (verifyOrder) { | 92 if (verifyOrder) { |
| 67 if (!n) { | 93 if (!n) { |
| 68 if (time) | 94 if (time) |
| 69 goto fail; | 95 goto fail; |
| 70 } else if (time < result.last()) | 96 } else if (time < result.last()) |
| 71 goto fail; | 97 goto fail; |
| 72 } | 98 } |
| 73 result.append(time); | 99 result.append(time); |
| 74 } | 100 } |
| 75 return; | 101 return true; |
| 76 fail: | 102 fail: |
| 77 result.clear(); | 103 result.clear(); |
| 104 return false; |
| 78 } | 105 } |
| 79 | 106 |
| 80 template<typename CharType> | 107 template<typename CharType> |
| 81 static bool parseKeySplinesInternal(const String& string, Vector<UnitBezier>& re
sult) | 108 static bool parseKeySplinesInternal(const String& string, Vector<UnitBezier>& re
sult) |
| 82 { | 109 { |
| 83 const CharType* ptr = string.getCharacters<CharType>(); | 110 const CharType* ptr = string.getCharacters<CharType>(); |
| 84 const CharType* end = ptr + string.length(); | 111 const CharType* end = ptr + string.length(); |
| 85 | 112 |
| 86 skipOptionalSVGSpaces(ptr, end); | 113 skipOptionalSVGSpaces(ptr, end); |
| 87 | 114 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 } | 176 } |
| 150 | 177 |
| 151 void SVGAnimationElement::parseAttribute(const QualifiedName& name, const Atomic
String& value) | 178 void SVGAnimationElement::parseAttribute(const QualifiedName& name, const Atomic
String& value) |
| 152 { | 179 { |
| 153 if (!isSupportedAttribute(name)) { | 180 if (!isSupportedAttribute(name)) { |
| 154 SVGSMILElement::parseAttribute(name, value); | 181 SVGSMILElement::parseAttribute(name, value); |
| 155 return; | 182 return; |
| 156 } | 183 } |
| 157 | 184 |
| 158 if (name == SVGNames::valuesAttr) { | 185 if (name == SVGNames::valuesAttr) { |
| 159 // Per the SMIL specification, leading and trailing white space, | 186 if (!parseValues(value, m_values)) { |
| 160 // and white space before and after semicolon separators, is allowed and
will be ignored. | 187 reportAttributeParsingError(ParsingAttributeFailedError, name, value
); |
| 161 // http://www.w3.org/TR/SVG11/animate.html#ValuesAttribute | 188 return; |
| 162 value.string().split(';', m_values); | 189 } |
| 163 for (unsigned i = 0; i < m_values.size(); ++i) | |
| 164 m_values[i] = m_values[i].stripWhiteSpace(); | |
| 165 | |
| 166 updateAnimationMode(); | 190 updateAnimationMode(); |
| 167 return; | 191 return; |
| 168 } | 192 } |
| 169 | 193 |
| 170 if (name == SVGNames::keyTimesAttr) { | 194 if (name == SVGNames::keyTimesAttr) { |
| 171 parseKeyTimes(value, m_keyTimes, true); | 195 if (!parseKeyTimes(value, m_keyTimes, true)) |
| 196 reportAttributeParsingError(ParsingAttributeFailedError, name, value
); |
| 172 return; | 197 return; |
| 173 } | 198 } |
| 174 | 199 |
| 175 if (name == SVGNames::keyPointsAttr) { | 200 if (name == SVGNames::keyPointsAttr) { |
| 176 if (isSVGAnimateMotionElement(*this)) { | 201 if (isSVGAnimateMotionElement(*this)) { |
| 177 // This is specified to be an animateMotion attribute only but it is
simpler to put it here | 202 // This is specified to be an animateMotion attribute only but it is
simpler to put it here |
| 178 // where the other timing calculatations are. | 203 // where the other timing calculatations are. |
| 179 parseKeyTimes(value, m_keyPoints, false); | 204 if (!parseKeyTimes(value, m_keyPoints, false)) |
| 205 reportAttributeParsingError(ParsingAttributeFailedError, name, v
alue); |
| 180 } | 206 } |
| 181 return; | 207 return; |
| 182 } | 208 } |
| 183 | 209 |
| 184 if (name == SVGNames::keySplinesAttr) { | 210 if (name == SVGNames::keySplinesAttr) { |
| 185 if (!parseKeySplines(value, m_keySplines)) | 211 if (!parseKeySplines(value, m_keySplines)) |
| 186 reportAttributeParsingError(ParsingAttributeFailedError, name, value
); | 212 reportAttributeParsingError(ParsingAttributeFailedError, name, value
); |
| 187 return; | 213 return; |
| 188 } | 214 } |
| 189 | 215 |
| (...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 682 SVGSMILElement::setAttributeName(attributeName); | 708 SVGSMILElement::setAttributeName(attributeName); |
| 683 checkInvalidCSSAttributeType(targetElement()); | 709 checkInvalidCSSAttributeType(targetElement()); |
| 684 } | 710 } |
| 685 | 711 |
| 686 void SVGAnimationElement::checkInvalidCSSAttributeType(SVGElement* target) | 712 void SVGAnimationElement::checkInvalidCSSAttributeType(SVGElement* target) |
| 687 { | 713 { |
| 688 m_hasInvalidCSSAttributeType = target && hasValidAttributeName() && attribut
eType() == AttributeTypeCSS && !isTargetAttributeCSSProperty(target, attributeNa
me()); | 714 m_hasInvalidCSSAttributeType = target && hasValidAttributeName() && attribut
eType() == AttributeTypeCSS && !isTargetAttributeCSSProperty(target, attributeNa
me()); |
| 689 } | 715 } |
| 690 | 716 |
| 691 } | 717 } |
| OLD | NEW |