Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(218)

Side by Side Diff: Source/core/svg/SVGAnimationElement.cpp

Issue 584053002: Handle semicolons at end of keyTimes and values (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « LayoutTests/svg/custom/script-tests/keyTimes-parsing-error.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 parseKeyTimes(const String& string, Vector<float>& result, bool veri fyOrder)
56 { 56 {
57 result.clear(); 57 result.clear();
58 Vector<String> parseList; 58 Vector<String> parseList;
59 string.split(';', parseList); 59 string.split(';', true, parseList);
60 for (unsigned n = 0; n < parseList.size(); ++n) { 60 for (unsigned n = 0; n < parseList.size(); ++n) {
61 String timeString = parseList[n]; 61 String timeString = parseList[n];
62 bool ok; 62 bool ok;
63 float time = timeString.toFloat(&ok); 63 float time = timeString.toFloat(&ok);
64 if (!ok || time < 0 || time > 1) 64 if (!ok || time < 0 || time > 1)
65 goto fail; 65 goto fail;
66 if (verifyOrder) { 66 if (verifyOrder) {
67 if (!n) { 67 if (!n) {
68 if (time) 68 if (time)
69 goto fail; 69 goto fail;
70 } else if (time < result.last()) 70 } else if (time < result.last())
71 goto fail; 71 goto fail;
72 } 72 }
73 result.append(time); 73 result.append(time);
74 } 74 }
75 return; 75 return true;
76 fail: 76 fail:
77 result.clear(); 77 result.clear();
78 return false;
78 } 79 }
79 80
80 template<typename CharType> 81 template<typename CharType>
81 static void parseKeySplinesInternal(const String& string, Vector<UnitBezier>& re sult) 82 static void parseKeySplinesInternal(const String& string, Vector<UnitBezier>& re sult)
82 { 83 {
83 const CharType* ptr = string.getCharacters<CharType>(); 84 const CharType* ptr = string.getCharacters<CharType>();
84 const CharType* end = ptr + string.length(); 85 const CharType* end = ptr + string.length();
85 86
86 skipOptionalSVGSpaces(ptr, end); 87 skipOptionalSVGSpaces(ptr, end);
87 88
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 { 159 {
159 if (!isSupportedAttribute(name)) { 160 if (!isSupportedAttribute(name)) {
160 SVGSMILElement::parseAttribute(name, value); 161 SVGSMILElement::parseAttribute(name, value);
161 return; 162 return;
162 } 163 }
163 164
164 if (name == SVGNames::valuesAttr) { 165 if (name == SVGNames::valuesAttr) {
165 // Per the SMIL specification, leading and trailing white space, 166 // Per the SMIL specification, leading and trailing white space,
166 // and white space before and after semicolon separators, is allowed and will be ignored. 167 // and white space before and after semicolon separators, is allowed and will be ignored.
167 // http://www.w3.org/TR/SVG11/animate.html#ValuesAttribute 168 // http://www.w3.org/TR/SVG11/animate.html#ValuesAttribute
168 value.string().split(';', m_values); 169 Vector<String> parseList;
fs 2014/09/22 10:26:28 Maybe move this lot into a function now that it's
169 for (unsigned i = 0; i < m_values.size(); ++i) 170 value.string().split(';', true, parseList);
170 m_values[i] = m_values[i].stripWhiteSpace(); 171 unsigned last = parseList.size() - 1;
172 for (unsigned i = 0; i <= last; ++i) {
173 parseList[i] = parseList[i].stripWhiteSpace();
174 if (parseList[i].isEmpty()) {
175 // Tolerate trailing ';'
176 if (i < last) {
177 m_values.clear();
178 reportAttributeParsingError(ParsingAttributeFailedError, nam e, value);
fs 2014/09/22 10:26:28 Please add a test for a 'values' for an attribute
179 return;
180 }
181 } else {
182 m_values.append(parseList[i]);
183 }
184 }
171 185
172 updateAnimationMode(); 186 updateAnimationMode();
173 return; 187 return;
174 } 188 }
175 189
176 if (name == SVGNames::keyTimesAttr) { 190 if (name == SVGNames::keyTimesAttr) {
177 parseKeyTimes(value, m_keyTimes, true); 191 if (!parseKeyTimes(value, m_keyTimes, true))
192 reportAttributeParsingError(ParsingAttributeFailedError, name, value );
178 return; 193 return;
179 } 194 }
180 195
181 if (name == SVGNames::keyPointsAttr) { 196 if (name == SVGNames::keyPointsAttr) {
182 if (isSVGAnimateMotionElement(*this)) { 197 if (isSVGAnimateMotionElement(*this)) {
183 // This is specified to be an animateMotion attribute only but it is simpler to put it here 198 // This is specified to be an animateMotion attribute only but it is simpler to put it here
184 // where the other timing calculatations are. 199 // where the other timing calculatations are.
185 parseKeyTimes(value, m_keyPoints, false); 200 if (!parseKeyTimes(value, m_keyPoints, false))
201 reportAttributeParsingError(ParsingAttributeFailedError, name, v alue);
186 } 202 }
187 return; 203 return;
188 } 204 }
189 205
190 if (name == SVGNames::keySplinesAttr) { 206 if (name == SVGNames::keySplinesAttr) {
191 parseKeySplines(value, m_keySplines); 207 parseKeySplines(value, m_keySplines);
192 return; 208 return;
193 } 209 }
194 210
195 if (name == SVGNames::attributeTypeAttr) { 211 if (name == SVGNames::attributeTypeAttr) {
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after
687 SVGSMILElement::setAttributeName(attributeName); 703 SVGSMILElement::setAttributeName(attributeName);
688 checkInvalidCSSAttributeType(targetElement()); 704 checkInvalidCSSAttributeType(targetElement());
689 } 705 }
690 706
691 void SVGAnimationElement::checkInvalidCSSAttributeType(SVGElement* target) 707 void SVGAnimationElement::checkInvalidCSSAttributeType(SVGElement* target)
692 { 708 {
693 m_hasInvalidCSSAttributeType = target && hasValidAttributeName() && attribut eType() == AttributeTypeCSS && !isTargetAttributeCSSProperty(target, attributeNa me()); 709 m_hasInvalidCSSAttributeType = target && hasValidAttributeName() && attribut eType() == AttributeTypeCSS && !isTargetAttributeCSSProperty(target, attributeNa me());
694 } 710 }
695 711
696 } 712 }
OLDNEW
« no previous file with comments | « LayoutTests/svg/custom/script-tests/keyTimes-parsing-error.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698