OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org> | 2 * Copyright (C) 2004, 2005, 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 * | 4 * |
5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
9 * | 9 * |
10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 builder.append(it->valueAsString()); | 64 builder.append(it->valueAsString()); |
65 } | 65 } |
66 } | 66 } |
67 | 67 |
68 return builder.toString(); | 68 return builder.toString(); |
69 } | 69 } |
70 | 70 |
71 template <typename CharType> | 71 template <typename CharType> |
72 SVGParsingError SVGLengthList::parseInternal(const CharType*& ptr, const CharTyp
e* end) | 72 SVGParsingError SVGLengthList::parseInternal(const CharType*& ptr, const CharTyp
e* end) |
73 { | 73 { |
74 clear(); | 74 const CharType* listStart = ptr; |
75 while (ptr < end) { | 75 while (ptr < end) { |
76 const CharType* start = ptr; | 76 const CharType* start = ptr; |
77 while (ptr < end && *ptr != ',' && !isHTMLSpace<CharType>(*ptr)) | 77 while (ptr < end && *ptr != ',' && !isHTMLSpace<CharType>(*ptr)) |
78 ptr++; | 78 ptr++; |
79 if (ptr == start) | 79 if (ptr == start) |
80 break; | 80 break; |
81 String valueString(start, ptr - start); | 81 String valueString(start, ptr - start); |
82 if (valueString.isEmpty()) | 82 if (valueString.isEmpty()) |
83 break; | 83 break; |
84 | 84 |
85 RefPtrWillBeRawPtr<SVGLength> length = SVGLength::create(m_mode); | 85 RefPtrWillBeRawPtr<SVGLength> length = SVGLength::create(m_mode); |
86 SVGParsingError lengthParseStatus = length->setValueAsString(valueString
); | 86 SVGParsingError lengthParseStatus = length->setValueAsString(valueString
); |
87 if (lengthParseStatus != SVGParseStatus::NoError) | 87 if (lengthParseStatus != SVGParseStatus::NoError) |
88 return lengthParseStatus; | 88 return lengthParseStatus.offsetWith(start - listStart); |
89 append(length); | 89 append(length); |
90 skipOptionalSVGSpacesOrDelimiter(ptr, end); | 90 skipOptionalSVGSpacesOrDelimiter(ptr, end); |
91 } | 91 } |
92 return SVGParseStatus::NoError; | 92 return SVGParseStatus::NoError; |
93 } | 93 } |
94 | 94 |
95 SVGParsingError SVGLengthList::setValueAsString(const String& value) | 95 SVGParsingError SVGLengthList::setValueAsString(const String& value) |
96 { | 96 { |
97 if (value.isEmpty()) { | 97 clear(); |
98 clear(); | 98 |
| 99 if (value.isEmpty()) |
99 return SVGParseStatus::NoError; | 100 return SVGParseStatus::NoError; |
100 } | |
101 | 101 |
102 SVGParsingError parseStatus; | |
103 if (value.is8Bit()) { | 102 if (value.is8Bit()) { |
104 const LChar* ptr = value.characters8(); | 103 const LChar* ptr = value.characters8(); |
105 const LChar* end = ptr + value.length(); | 104 const LChar* end = ptr + value.length(); |
106 parseStatus = parseInternal(ptr, end); | 105 return parseInternal(ptr, end); |
107 } else { | |
108 const UChar* ptr = value.characters16(); | |
109 const UChar* end = ptr + value.length(); | |
110 parseStatus = parseInternal(ptr, end); | |
111 } | 106 } |
112 return parseStatus; | 107 const UChar* ptr = value.characters16(); |
| 108 const UChar* end = ptr + value.length(); |
| 109 return parseInternal(ptr, end); |
113 } | 110 } |
114 | 111 |
115 void SVGLengthList::add(PassRefPtrWillBeRawPtr<SVGPropertyBase> other, SVGElemen
t* contextElement) | 112 void SVGLengthList::add(PassRefPtrWillBeRawPtr<SVGPropertyBase> other, SVGElemen
t* contextElement) |
116 { | 113 { |
117 RefPtrWillBeRawPtr<SVGLengthList> otherList = toSVGLengthList(other); | 114 RefPtrWillBeRawPtr<SVGLengthList> otherList = toSVGLengthList(other); |
118 | 115 |
119 if (length() != otherList->length()) | 116 if (length() != otherList->length()) |
120 return; | 117 return; |
121 | 118 |
122 SVGLengthContext lengthContext(contextElement); | 119 SVGLengthContext lengthContext(contextElement); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 at(i)->setValue(animatedNumber, lengthContext); | 159 at(i)->setValue(animatedNumber, lengthContext); |
163 } | 160 } |
164 } | 161 } |
165 | 162 |
166 float SVGLengthList::calculateDistance(PassRefPtrWillBeRawPtr<SVGPropertyBase> t
o, SVGElement*) | 163 float SVGLengthList::calculateDistance(PassRefPtrWillBeRawPtr<SVGPropertyBase> t
o, SVGElement*) |
167 { | 164 { |
168 // FIXME: Distance calculation is not possible for SVGLengthList right now.
We need the distance for every single value. | 165 // FIXME: Distance calculation is not possible for SVGLengthList right now.
We need the distance for every single value. |
169 return -1; | 166 return -1; |
170 } | 167 } |
171 } // namespace blink | 168 } // namespace blink |
OLD | NEW |