OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2005, 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org> | 2 * Copyright (C) 2004, 2005, 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org> |
3 * Copyright (C) 2004, 2005, 2006 Rob Buis <buis@kde.org> | 3 * Copyright (C) 2004, 2005, 2006 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 * |
11 * This library is distributed in the hope that it will be useful, | 11 * This library is distributed in the hope that it will be useful, |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 * Library General Public License for more details. | 14 * Library General Public License for more details. |
15 * | 15 * |
16 * You should have received a copy of the GNU Library General Public License | 16 * You should have received a copy of the GNU Library General Public License |
17 * along with this library; see the file COPYING.LIB. If not, write to | 17 * along with this library; see the file COPYING.LIB. If not, write to |
18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
19 * Boston, MA 02110-1301, USA. | 19 * Boston, MA 02110-1301, USA. |
20 */ | 20 */ |
21 | 21 |
22 #include "core/svg/SVGAngle.h" | 22 #include "core/svg/SVGAngle.h" |
23 | 23 |
24 #include "bindings/core/v8/ExceptionState.h" | |
25 #include "bindings/core/v8/ExceptionStatePlaceholder.h" | |
26 #include "core/dom/ExceptionCode.h" | |
27 #include "core/svg/SVGAnimationElement.h" | 24 #include "core/svg/SVGAnimationElement.h" |
28 #include "core/svg/SVGParserUtilities.h" | 25 #include "core/svg/SVGParserUtilities.h" |
29 #include "wtf/MathExtras.h" | 26 #include "wtf/MathExtras.h" |
30 #include "wtf/text/WTFString.h" | 27 #include "wtf/text/WTFString.h" |
31 | 28 |
32 namespace blink { | 29 namespace blink { |
33 | 30 |
34 template<> const SVGEnumerationStringEntries& getStaticStringEntries<SVGMarkerOr
ientType>() | 31 template<> const SVGEnumerationStringEntries& getStaticStringEntries<SVGMarkerOr
ientType>() |
35 { | 32 { |
36 DEFINE_STATIC_LOCAL(SVGEnumerationStringEntries, entries, ()); | 33 DEFINE_STATIC_LOCAL(SVGEnumerationStringEntries, entries, ()); |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 if (!parseNumber(ptr, end, valueInSpecifiedUnits, AllowLeadingWhitespace)) | 226 if (!parseNumber(ptr, end, valueInSpecifiedUnits, AllowLeadingWhitespace)) |
230 return false; | 227 return false; |
231 | 228 |
232 unitType = stringToAngleType(ptr, end); | 229 unitType = stringToAngleType(ptr, end); |
233 if (unitType == SVGAngle::SVG_ANGLETYPE_UNKNOWN) | 230 if (unitType == SVGAngle::SVG_ANGLETYPE_UNKNOWN) |
234 return false; | 231 return false; |
235 | 232 |
236 return true; | 233 return true; |
237 } | 234 } |
238 | 235 |
239 void SVGAngle::setValueAsString(const String& value, ExceptionState& exceptionSt
ate) | 236 SVGParsingError SVGAngle::setValueAsString(const String& value) |
240 { | 237 { |
241 if (value.isEmpty()) { | 238 if (value.isEmpty()) { |
242 newValueSpecifiedUnits(SVG_ANGLETYPE_UNSPECIFIED, 0); | 239 newValueSpecifiedUnits(SVG_ANGLETYPE_UNSPECIFIED, 0); |
243 return; | 240 return NoError; |
244 } | 241 } |
245 | 242 |
246 if (value == "auto") { | 243 if (value == "auto") { |
247 newValueSpecifiedUnits(SVG_ANGLETYPE_UNSPECIFIED, 0); | 244 newValueSpecifiedUnits(SVG_ANGLETYPE_UNSPECIFIED, 0); |
248 m_orientType->setEnumValue(SVGMarkerOrientAuto); | 245 m_orientType->setEnumValue(SVGMarkerOrientAuto); |
249 return; | 246 return NoError; |
250 } | 247 } |
251 if (value == "auto-start-reverse") { | 248 if (value == "auto-start-reverse") { |
252 newValueSpecifiedUnits(SVG_ANGLETYPE_UNSPECIFIED, 0); | 249 newValueSpecifiedUnits(SVG_ANGLETYPE_UNSPECIFIED, 0); |
253 m_orientType->setEnumValue(SVGMarkerOrientAutoStartReverse); | 250 m_orientType->setEnumValue(SVGMarkerOrientAutoStartReverse); |
254 return; | 251 return NoError; |
255 } | 252 } |
256 | 253 |
257 float valueInSpecifiedUnits = 0; | 254 float valueInSpecifiedUnits = 0; |
258 SVGAngleType unitType = SVG_ANGLETYPE_UNKNOWN; | 255 SVGAngleType unitType = SVG_ANGLETYPE_UNKNOWN; |
259 | 256 |
260 bool success = value.is8Bit() ? parseValue<LChar>(value, valueInSpecifiedUni
ts, unitType) | 257 bool success = value.is8Bit() ? parseValue<LChar>(value, valueInSpecifiedUni
ts, unitType) |
261 : parseValue<UChar>(value, valueInSpecifiedUni
ts, unitType); | 258 : parseValue<UChar>(value, valueInSpecifiedUni
ts, unitType); |
262 if (!success) { | 259 if (!success) |
263 exceptionState.throwDOMException(SyntaxError, "The value provided ('" +
value + "') is invalid."); | 260 return ParsingAttributeFailedError; |
264 return; | |
265 } | |
266 | 261 |
267 m_orientType->setEnumValue(SVGMarkerOrientAngle); | 262 m_orientType->setEnumValue(SVGMarkerOrientAngle); |
268 m_unitType = unitType; | 263 m_unitType = unitType; |
269 m_valueInSpecifiedUnits = valueInSpecifiedUnits; | 264 m_valueInSpecifiedUnits = valueInSpecifiedUnits; |
| 265 return NoError; |
270 } | 266 } |
271 | 267 |
272 void SVGAngle::newValueSpecifiedUnits(SVGAngleType unitType, float valueInSpecif
iedUnits) | 268 void SVGAngle::newValueSpecifiedUnits(SVGAngleType unitType, float valueInSpecif
iedUnits) |
273 { | 269 { |
274 m_orientType->setEnumValue(SVGMarkerOrientAngle); | 270 m_orientType->setEnumValue(SVGMarkerOrientAngle); |
275 m_unitType = unitType; | 271 m_unitType = unitType; |
276 m_valueInSpecifiedUnits = valueInSpecifiedUnits; | 272 m_valueInSpecifiedUnits = valueInSpecifiedUnits; |
277 } | 273 } |
278 | 274 |
279 void SVGAngle::convertToSpecifiedUnits(SVGAngleType unitType) | 275 void SVGAngle::convertToSpecifiedUnits(SVGAngleType unitType) |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
436 | 432 |
437 void SVGAngle::orientTypeChanged() | 433 void SVGAngle::orientTypeChanged() |
438 { | 434 { |
439 if (orientType()->enumValue() == SVGMarkerOrientAuto || orientType()->enumVa
lue() == SVGMarkerOrientAutoStartReverse) { | 435 if (orientType()->enumValue() == SVGMarkerOrientAuto || orientType()->enumVa
lue() == SVGMarkerOrientAutoStartReverse) { |
440 m_unitType = SVG_ANGLETYPE_UNSPECIFIED; | 436 m_unitType = SVG_ANGLETYPE_UNSPECIFIED; |
441 m_valueInSpecifiedUnits = 0; | 437 m_valueInSpecifiedUnits = 0; |
442 } | 438 } |
443 } | 439 } |
444 | 440 |
445 } | 441 } |
OLD | NEW |