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

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

Issue 539383002: Handle semicolons at end of keySplines value (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix nits 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/keySplines-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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 goto fail; 71 goto fail;
72 } 72 }
73 result.append(time); 73 result.append(time);
74 } 74 }
75 return; 75 return;
76 fail: 76 fail:
77 result.clear(); 77 result.clear();
78 } 78 }
79 79
80 template<typename CharType> 80 template<typename CharType>
81 static void parseKeySplinesInternal(const String& string, Vector<UnitBezier>& re sult) 81 static bool parseKeySplinesInternal(const String& string, Vector<UnitBezier>& re sult)
82 { 82 {
83 const CharType* ptr = string.getCharacters<CharType>(); 83 const CharType* ptr = string.getCharacters<CharType>();
84 const CharType* end = ptr + string.length(); 84 const CharType* end = ptr + string.length();
85 85
86 skipOptionalSVGSpaces(ptr, end); 86 skipOptionalSVGSpaces(ptr, end);
87 87
88 bool delimParsed = false;
89 while (ptr < end) { 88 while (ptr < end) {
90 delimParsed = false;
91 float posA = 0; 89 float posA = 0;
92 if (!parseNumber(ptr, end, posA)) { 90 if (!parseNumber(ptr, end, posA))
93 result.clear(); 91 return false;
94 return;
95 }
96 92
97 float posB = 0; 93 float posB = 0;
98 if (!parseNumber(ptr, end, posB)) { 94 if (!parseNumber(ptr, end, posB))
99 result.clear(); 95 return false;
100 return;
101 }
102 96
103 float posC = 0; 97 float posC = 0;
104 if (!parseNumber(ptr, end, posC)) { 98 if (!parseNumber(ptr, end, posC))
105 result.clear(); 99 return false;
106 return;
107 }
108 100
109 float posD = 0; 101 float posD = 0;
110 if (!parseNumber(ptr, end, posD, DisallowWhitespace)) { 102 if (!parseNumber(ptr, end, posD, DisallowWhitespace))
111 result.clear(); 103 return false;
112 return;
113 }
114 104
115 skipOptionalSVGSpaces(ptr, end); 105 skipOptionalSVGSpaces(ptr, end);
116 106
117 if (ptr < end && *ptr == ';') { 107 if (ptr < end && *ptr == ';')
118 delimParsed = true;
119 ptr++; 108 ptr++;
120 }
121 skipOptionalSVGSpaces(ptr, end); 109 skipOptionalSVGSpaces(ptr, end);
122 110
123 result.append(UnitBezier(posA, posB, posC, posD)); 111 result.append(UnitBezier(posA, posB, posC, posD));
124 } 112 }
125 if (!(ptr == end && !delimParsed)) 113
126 result.clear(); 114 return ptr == end;
127 } 115 }
128 116
129 static void parseKeySplines(const String& string, Vector<UnitBezier>& result) 117 static bool parseKeySplines(const String& string, Vector<UnitBezier>& result)
130 { 118 {
131 result.clear(); 119 result.clear();
132 if (string.isEmpty()) 120 if (string.isEmpty())
133 return; 121 return true;
122 bool parsed = true;
134 if (string.is8Bit()) 123 if (string.is8Bit())
135 parseKeySplinesInternal<LChar>(string, result); 124 parsed = parseKeySplinesInternal<LChar>(string, result);
136 else 125 else
137 parseKeySplinesInternal<UChar>(string, result); 126 parsed = parseKeySplinesInternal<UChar>(string, result);
127 if (!parsed) {
128 result.clear();
129 return false;
130 }
131 return true;
138 } 132 }
139 133
140 bool SVGAnimationElement::isSupportedAttribute(const QualifiedName& attrName) 134 bool SVGAnimationElement::isSupportedAttribute(const QualifiedName& attrName)
141 { 135 {
142 DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, supportedAttributes, ()); 136 DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, supportedAttributes, ());
143 if (supportedAttributes.isEmpty()) { 137 if (supportedAttributes.isEmpty()) {
144 supportedAttributes.add(SVGNames::valuesAttr); 138 supportedAttributes.add(SVGNames::valuesAttr);
145 supportedAttributes.add(SVGNames::keyTimesAttr); 139 supportedAttributes.add(SVGNames::keyTimesAttr);
146 supportedAttributes.add(SVGNames::keyPointsAttr); 140 supportedAttributes.add(SVGNames::keyPointsAttr);
147 supportedAttributes.add(SVGNames::keySplinesAttr); 141 supportedAttributes.add(SVGNames::keySplinesAttr);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 if (name == SVGNames::keyPointsAttr) { 175 if (name == SVGNames::keyPointsAttr) {
182 if (isSVGAnimateMotionElement(*this)) { 176 if (isSVGAnimateMotionElement(*this)) {
183 // This is specified to be an animateMotion attribute only but it is simpler to put it here 177 // This is specified to be an animateMotion attribute only but it is simpler to put it here
184 // where the other timing calculatations are. 178 // where the other timing calculatations are.
185 parseKeyTimes(value, m_keyPoints, false); 179 parseKeyTimes(value, m_keyPoints, false);
186 } 180 }
187 return; 181 return;
188 } 182 }
189 183
190 if (name == SVGNames::keySplinesAttr) { 184 if (name == SVGNames::keySplinesAttr) {
191 parseKeySplines(value, m_keySplines); 185 if (!parseKeySplines(value, m_keySplines))
186 reportAttributeParsingError(ParsingAttributeFailedError, name, value );
192 return; 187 return;
193 } 188 }
194 189
195 if (name == SVGNames::attributeTypeAttr) { 190 if (name == SVGNames::attributeTypeAttr) {
196 setAttributeType(value); 191 setAttributeType(value);
197 return; 192 return;
198 } 193 }
199 194
200 if (name == SVGNames::calcModeAttr) { 195 if (name == SVGNames::calcModeAttr) {
201 setCalcMode(value); 196 setCalcMode(value);
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after
687 SVGSMILElement::setAttributeName(attributeName); 682 SVGSMILElement::setAttributeName(attributeName);
688 checkInvalidCSSAttributeType(targetElement()); 683 checkInvalidCSSAttributeType(targetElement());
689 } 684 }
690 685
691 void SVGAnimationElement::checkInvalidCSSAttributeType(SVGElement* target) 686 void SVGAnimationElement::checkInvalidCSSAttributeType(SVGElement* target)
692 { 687 {
693 m_hasInvalidCSSAttributeType = target && hasValidAttributeName() && attribut eType() == AttributeTypeCSS && !isTargetAttributeCSSProperty(target, attributeNa me()); 688 m_hasInvalidCSSAttributeType = target && hasValidAttributeName() && attribut eType() == AttributeTypeCSS && !isTargetAttributeCSSProperty(target, attributeNa me());
694 } 689 }
695 690
696 } 691 }
OLDNEW
« no previous file with comments | « LayoutTests/svg/custom/script-tests/keySplines-parsing-error.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698