| 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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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<NewSVGPropertyBase> other, SVGElement* contex
tElement) |
| 120 { | 120 { |
| 121 RefPtr<SVGNumberList> otherList = toSVGNumberList(other); | 121 RefPtr<SVGNumberList> otherList = toSVGNumberList(other); |
| 122 | 122 |
| 123 if (numberOfItems() != otherList->numberOfItems()) | 123 if (length() != otherList->length()) |
| 124 return; | 124 return; |
| 125 | 125 |
| 126 for (size_t i = 0; i < numberOfItems(); ++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 |
| 130 bool SVGNumberList::adjustFromToListValues(PassRefPtr<SVGNumberList> passFromLis
t, PassRefPtr<SVGNumberList> passToList, float percentage, bool isToAnimation, b
ool resizeAnimatedListIfNeeded) | 130 bool SVGNumberList::adjustFromToListValues(PassRefPtr<SVGNumberList> passFromLis
t, PassRefPtr<SVGNumberList> passToList, float percentage, bool isToAnimation, b
ool resizeAnimatedListIfNeeded) |
| 131 { | 131 { |
| 132 RefPtr<SVGNumberList> fromList = passFromList; | 132 RefPtr<SVGNumberList> fromList = passFromList; |
| 133 RefPtr<SVGNumberList> toList = passToList; | 133 RefPtr<SVGNumberList> toList = passToList; |
| 134 | 134 |
| 135 // If no 'to' value is given, nothing to animate. | 135 // If no 'to' value is given, nothing to animate. |
| 136 size_t toListSize = toList->numberOfItems(); | 136 size_t toListSize = toList->length(); |
| 137 if (!toListSize) | 137 if (!toListSize) |
| 138 return false; | 138 return false; |
| 139 | 139 |
| 140 // If the 'from' value is given and it's length doesn't match the 'to' value
list length, fallback to a discrete animation. | 140 // If the 'from' value is given and it's length doesn't match the 'to' value
list length, fallback to a discrete animation. |
| 141 size_t fromListSize = fromList->numberOfItems(); | 141 size_t fromListSize = fromList->length(); |
| 142 if (fromListSize != toListSize && fromListSize) { | 142 if (fromListSize != toListSize && fromListSize) { |
| 143 if (percentage < 0.5) { | 143 if (percentage < 0.5) { |
| 144 if (!isToAnimation) | 144 if (!isToAnimation) |
| 145 deepCopy(fromList); | 145 deepCopy(fromList); |
| 146 } else { | 146 } else { |
| 147 deepCopy(toList); | 147 deepCopy(toList); |
| 148 } | 148 } |
| 149 | 149 |
| 150 return false; | 150 return false; |
| 151 } | 151 } |
| 152 | 152 |
| 153 ASSERT(!fromListSize || fromListSize == toListSize); | 153 ASSERT(!fromListSize || fromListSize == toListSize); |
| 154 if (resizeAnimatedListIfNeeded && numberOfItems() < toListSize) { | 154 if (resizeAnimatedListIfNeeded && length() < toListSize) { |
| 155 size_t paddingCount = toListSize - numberOfItems(); | 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<NewSVGPropertyBase> fromVal
ue, PassRefPtr<NewSVGPropertyBase> toValue, PassRefPtr<NewSVGPropertyBase> toAtE
ndOfDurationValue, 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->numberOfItems(); | 169 size_t fromListSize = fromList->length(); |
| 170 size_t toListSize = toList->numberOfItems(); | 170 size_t toListSize = toList->length(); |
| 171 size_t toAtEndOfDurationListSize = toAtEndOfDurationList->numberOfItems(); | 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<NewSVGPropertyBase> to, SVGEle
ment*) |
| 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(numberOfItems()); | 196 vec.reserveInitialCapacity(length()); |
| 197 for (size_t i = 0; i < numberOfItems(); ++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 |