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 10 matching lines...) Expand all Loading... |
21 #include "config.h" | 21 #include "config.h" |
22 #include "core/svg/SVGNumberList.h" | 22 #include "core/svg/SVGNumberList.h" |
23 | 23 |
24 #include "core/svg/SVGAnimationElement.h" | 24 #include "core/svg/SVGAnimationElement.h" |
25 #include "core/svg/SVGParserUtilities.h" | 25 #include "core/svg/SVGParserUtilities.h" |
26 #include "wtf/text/StringBuilder.h" | 26 #include "wtf/text/StringBuilder.h" |
27 #include "wtf/text/WTFString.h" | 27 #include "wtf/text/WTFString.h" |
28 | 28 |
29 namespace WebCore { | 29 namespace WebCore { |
30 | 30 |
31 inline PassRefPtr<SVGNumberList> toSVGNumberList(PassRefPtr<NewSVGPropertyBase>
passBase) | 31 inline PassRefPtr<SVGNumberList> toSVGNumberList(PassRefPtr<SVGPropertyBase> pas
sBase) |
32 { | 32 { |
33 RefPtr<NewSVGPropertyBase> base = passBase; | 33 RefPtr<SVGPropertyBase> base = passBase; |
34 ASSERT(base->type() == SVGNumberList::classType()); | 34 ASSERT(base->type() == SVGNumberList::classType()); |
35 return static_pointer_cast<SVGNumberList>(base.release()); | 35 return static_pointer_cast<SVGNumberList>(base.release()); |
36 } | 36 } |
37 | 37 |
38 SVGNumberList::SVGNumberList() | 38 SVGNumberList::SVGNumberList() |
39 { | 39 { |
40 } | 40 } |
41 | 41 |
42 SVGNumberList::~SVGNumberList() | 42 SVGNumberList::~SVGNumberList() |
43 { | 43 { |
44 } | 44 } |
45 | 45 |
46 PassRefPtr<SVGNumberList> SVGNumberList::clone() | 46 PassRefPtr<SVGNumberList> SVGNumberList::clone() |
47 { | 47 { |
48 RefPtr<SVGNumberList> svgNumberList = SVGNumberList::create(); | 48 RefPtr<SVGNumberList> svgNumberList = SVGNumberList::create(); |
49 svgNumberList->deepCopy(this); | 49 svgNumberList->deepCopy(this); |
50 return svgNumberList.release(); | 50 return svgNumberList.release(); |
51 } | 51 } |
52 | 52 |
53 PassRefPtr<NewSVGPropertyBase> SVGNumberList::cloneForAnimation(const String& va
lue) const | 53 PassRefPtr<SVGPropertyBase> SVGNumberList::cloneForAnimation(const String& value
) const |
54 { | 54 { |
55 RefPtr<SVGNumberList> svgNumberList = SVGNumberList::create(); | 55 RefPtr<SVGNumberList> svgNumberList = SVGNumberList::create(); |
56 svgNumberList->setValueAsString(value, IGNORE_EXCEPTION); | 56 svgNumberList->setValueAsString(value, IGNORE_EXCEPTION); |
57 return svgNumberList.release(); | 57 return svgNumberList.release(); |
58 } | 58 } |
59 | 59 |
60 String SVGNumberList::valueAsString() const | 60 String SVGNumberList::valueAsString() const |
61 { | 61 { |
62 StringBuilder builder; | 62 StringBuilder builder; |
63 | 63 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 valid = parse(ptr, end); | 109 valid = parse(ptr, end); |
110 } | 110 } |
111 | 111 |
112 if (!valid) { | 112 if (!valid) { |
113 exceptionState.throwDOMException(SyntaxError, "Problem parsing number li
st \""+value+"\""); | 113 exceptionState.throwDOMException(SyntaxError, "Problem parsing number li
st \""+value+"\""); |
114 // No call to |clear()| here. SVG policy is to use valid items before er
ror. | 114 // No call to |clear()| here. SVG policy is to use valid items before er
ror. |
115 // Spec: http://www.w3.org/TR/SVG/single-page.html#implnote-ErrorProcess
ing | 115 // Spec: http://www.w3.org/TR/SVG/single-page.html#implnote-ErrorProcess
ing |
116 } | 116 } |
117 } | 117 } |
118 | 118 |
119 void SVGNumberList::add(PassRefPtr<NewSVGPropertyBase> other, SVGElement* contex
tElement) | 119 void SVGNumberList::add(PassRefPtr<SVGPropertyBase> other, SVGElement* contextEl
ement) |
120 { | 120 { |
121 RefPtr<SVGNumberList> otherList = toSVGNumberList(other); | 121 RefPtr<SVGNumberList> otherList = toSVGNumberList(other); |
122 | 122 |
123 if (length() != otherList->length()) | 123 if (length() != otherList->length()) |
124 return; | 124 return; |
125 | 125 |
126 for (size_t i = 0; i < length(); ++i) | 126 for (size_t i = 0; i < length(); ++i) |
127 at(i)->setValue(at(i)->value() + otherList->at(i)->value()); | 127 at(i)->setValue(at(i)->value() + otherList->at(i)->value()); |
128 } | 128 } |
129 | 129 |
(...skipping 23 matching lines...) Expand all Loading... |
153 ASSERT(!fromListSize || fromListSize == toListSize); | 153 ASSERT(!fromListSize || fromListSize == toListSize); |
154 if (resizeAnimatedListIfNeeded && length() < toListSize) { | 154 if (resizeAnimatedListIfNeeded && length() < toListSize) { |
155 size_t paddingCount = toListSize - length(); | 155 size_t paddingCount = toListSize - length(); |
156 for (size_t i = 0; i < paddingCount; ++i) | 156 for (size_t i = 0; i < paddingCount; ++i) |
157 append(SVGNumber::create()); | 157 append(SVGNumber::create()); |
158 } | 158 } |
159 | 159 |
160 return true; | 160 return true; |
161 } | 161 } |
162 | 162 |
163 void SVGNumberList::calculateAnimatedValue(SVGAnimationElement* animationElement
, float percentage, unsigned repeatCount, PassRefPtr<NewSVGPropertyBase> fromVal
ue, PassRefPtr<NewSVGPropertyBase> toValue, PassRefPtr<NewSVGPropertyBase> toAtE
ndOfDurationValue, SVGElement* contextElement) | 163 void SVGNumberList::calculateAnimatedValue(SVGAnimationElement* animationElement
, float percentage, unsigned repeatCount, PassRefPtr<SVGPropertyBase> fromValue,
PassRefPtr<SVGPropertyBase> toValue, PassRefPtr<SVGPropertyBase> toAtEndOfDurat
ionValue, SVGElement* contextElement) |
164 { | 164 { |
165 RefPtr<SVGNumberList> fromList = toSVGNumberList(fromValue); | 165 RefPtr<SVGNumberList> fromList = toSVGNumberList(fromValue); |
166 RefPtr<SVGNumberList> toList = toSVGNumberList(toValue); | 166 RefPtr<SVGNumberList> toList = toSVGNumberList(toValue); |
167 RefPtr<SVGNumberList> toAtEndOfDurationList = toSVGNumberList(toAtEndOfDurat
ionValue); | 167 RefPtr<SVGNumberList> toAtEndOfDurationList = toSVGNumberList(toAtEndOfDurat
ionValue); |
168 | 168 |
169 size_t fromListSize = fromList->length(); | 169 size_t fromListSize = fromList->length(); |
170 size_t toListSize = toList->length(); | 170 size_t toListSize = toList->length(); |
171 size_t toAtEndOfDurationListSize = toAtEndOfDurationList->length(); | 171 size_t toAtEndOfDurationListSize = toAtEndOfDurationList->length(); |
172 | 172 |
173 if (!adjustFromToListValues(fromList, toList, percentage, animationElement->
animationMode() == ToAnimation, true)) | 173 if (!adjustFromToListValues(fromList, toList, percentage, animationElement->
animationMode() == ToAnimation, true)) |
174 return; | 174 return; |
175 | 175 |
176 for (size_t i = 0; i < toListSize; ++i) { | 176 for (size_t i = 0; i < toListSize; ++i) { |
177 float effectiveFrom = fromListSize ? fromList->at(i)->value() : 0; | 177 float effectiveFrom = fromListSize ? fromList->at(i)->value() : 0; |
178 float effectiveTo = toListSize ? toList->at(i)->value() : 0; | 178 float effectiveTo = toListSize ? toList->at(i)->value() : 0; |
179 float effectiveToAtEnd = i < toAtEndOfDurationListSize ? toAtEndOfDurati
onList->at(i)->value() : 0; | 179 float effectiveToAtEnd = i < toAtEndOfDurationListSize ? toAtEndOfDurati
onList->at(i)->value() : 0; |
180 | 180 |
181 float animated = at(i)->value(); | 181 float animated = at(i)->value(); |
182 animationElement->animateAdditiveNumber(percentage, repeatCount, effecti
veFrom, effectiveTo, effectiveToAtEnd, animated); | 182 animationElement->animateAdditiveNumber(percentage, repeatCount, effecti
veFrom, effectiveTo, effectiveToAtEnd, animated); |
183 at(i)->setValue(animated); | 183 at(i)->setValue(animated); |
184 } | 184 } |
185 } | 185 } |
186 | 186 |
187 float SVGNumberList::calculateDistance(PassRefPtr<NewSVGPropertyBase> to, SVGEle
ment*) | 187 float SVGNumberList::calculateDistance(PassRefPtr<SVGPropertyBase> to, SVGElemen
t*) |
188 { | 188 { |
189 // FIXME: Distance calculation is not possible for SVGNumberList right now.
We need the distance for every single value. | 189 // FIXME: Distance calculation is not possible for SVGNumberList right now.
We need the distance for every single value. |
190 return -1; | 190 return -1; |
191 } | 191 } |
192 | 192 |
193 Vector<float> SVGNumberList::toFloatVector() const | 193 Vector<float> SVGNumberList::toFloatVector() const |
194 { | 194 { |
195 Vector<float> vec; | 195 Vector<float> vec; |
196 vec.reserveInitialCapacity(length()); | 196 vec.reserveInitialCapacity(length()); |
197 for (size_t i = 0; i < length(); ++i) | 197 for (size_t i = 0; i < length(); ++i) |
198 vec.uncheckedAppend(at(i)->value()); | 198 vec.uncheckedAppend(at(i)->value()); |
199 return vec; | 199 return vec; |
200 } | 200 } |
201 | 201 |
202 } | 202 } |
OLD | NEW |