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

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

Issue 195313003: [SVG2] Add getters and setters to SVG*List interfaces. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: s/slength/size Created 6 years, 9 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 | « Source/core/svg/SVGPathSegList.idl ('k') | Source/core/svg/SVGPointList.idl » ('j') | 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, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org> 2 * Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org>
3 * Copyright (C) 2004, 2005 Rob Buis <buis@kde.org> 3 * Copyright (C) 2004, 2005 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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 } 129 }
130 130
131 if (!valid) 131 if (!valid)
132 exceptionState.throwDOMException(SyntaxError, "Problem parsing points=\" "+value+"\""); 132 exceptionState.throwDOMException(SyntaxError, "Problem parsing points=\" "+value+"\"");
133 } 133 }
134 134
135 void SVGPointList::add(PassRefPtr<NewSVGPropertyBase> other, SVGElement* context Element) 135 void SVGPointList::add(PassRefPtr<NewSVGPropertyBase> other, SVGElement* context Element)
136 { 136 {
137 RefPtr<SVGPointList> otherList = toSVGPointList(other); 137 RefPtr<SVGPointList> otherList = toSVGPointList(other);
138 138
139 if (numberOfItems() != otherList->numberOfItems()) 139 if (length() != otherList->length())
140 return; 140 return;
141 141
142 for (size_t i = 0; i < numberOfItems(); ++i) 142 for (size_t i = 0; i < length(); ++i)
143 at(i)->setValue(at(i)->value() + otherList->at(i)->value()); 143 at(i)->setValue(at(i)->value() + otherList->at(i)->value());
144 } 144 }
145 145
146 bool SVGPointList::adjustFromToListValues(PassRefPtr<SVGPointList> passFromList, PassRefPtr<SVGPointList> passToList, float percentage, bool isToAnimation, bool resizeAnimatedListIfNeeded) 146 bool SVGPointList::adjustFromToListValues(PassRefPtr<SVGPointList> passFromList, PassRefPtr<SVGPointList> passToList, float percentage, bool isToAnimation, bool resizeAnimatedListIfNeeded)
147 { 147 {
148 RefPtr<SVGPointList> fromList = passFromList; 148 RefPtr<SVGPointList> fromList = passFromList;
149 RefPtr<SVGPointList> toList = passToList; 149 RefPtr<SVGPointList> toList = passToList;
150 150
151 // If no 'to' value is given, nothing to animate. 151 // If no 'to' value is given, nothing to animate.
152 size_t toListSize = toList->numberOfItems(); 152 size_t toListSize = toList->length();
153 if (!toListSize) 153 if (!toListSize)
154 return false; 154 return false;
155 155
156 // If the 'from' value is given and it's length doesn't match the 'to' value list length, fallback to a discrete animation. 156 // If the 'from' value is given and it's length doesn't match the 'to' value list length, fallback to a discrete animation.
157 size_t fromListSize = fromList->numberOfItems(); 157 size_t fromListSize = fromList->length();
158 if (fromListSize != toListSize && fromListSize) { 158 if (fromListSize != toListSize && fromListSize) {
159 if (percentage < 0.5) { 159 if (percentage < 0.5) {
160 if (!isToAnimation) 160 if (!isToAnimation)
161 deepCopy(fromList); 161 deepCopy(fromList);
162 } else { 162 } else {
163 deepCopy(toList); 163 deepCopy(toList);
164 } 164 }
165 165
166 return false; 166 return false;
167 } 167 }
168 168
169 ASSERT(!fromListSize || fromListSize == toListSize); 169 ASSERT(!fromListSize || fromListSize == toListSize);
170 if (resizeAnimatedListIfNeeded && numberOfItems() < toListSize) { 170 if (resizeAnimatedListIfNeeded && length() < toListSize) {
171 size_t paddingCount = toListSize - numberOfItems(); 171 size_t paddingCount = toListSize - length();
172 for (size_t i = 0; i < paddingCount; ++i) 172 for (size_t i = 0; i < paddingCount; ++i)
173 append(SVGPoint::create()); 173 append(SVGPoint::create());
174 } 174 }
175 175
176 return true; 176 return true;
177 } 177 }
178 178
179 void SVGPointList::calculateAnimatedValue(SVGAnimationElement* animationElement, float percentage, unsigned repeatCount, PassRefPtr<NewSVGPropertyBase> fromValu e, PassRefPtr<NewSVGPropertyBase> toValue, PassRefPtr<NewSVGPropertyBase> toAtEn dOfDurationValue, SVGElement* contextElement) 179 void SVGPointList::calculateAnimatedValue(SVGAnimationElement* animationElement, float percentage, unsigned repeatCount, PassRefPtr<NewSVGPropertyBase> fromValu e, PassRefPtr<NewSVGPropertyBase> toValue, PassRefPtr<NewSVGPropertyBase> toAtEn dOfDurationValue, SVGElement* contextElement)
180 { 180 {
181 RefPtr<SVGPointList> fromList = toSVGPointList(fromValue); 181 RefPtr<SVGPointList> fromList = toSVGPointList(fromValue);
182 RefPtr<SVGPointList> toList = toSVGPointList(toValue); 182 RefPtr<SVGPointList> toList = toSVGPointList(toValue);
183 RefPtr<SVGPointList> toAtEndOfDurationList = toSVGPointList(toAtEndOfDuratio nValue); 183 RefPtr<SVGPointList> toAtEndOfDurationList = toSVGPointList(toAtEndOfDuratio nValue);
184 184
185 size_t fromPointListSize = fromList->numberOfItems(); 185 size_t fromPointListSize = fromList->length();
186 size_t toPointListSize = toList->numberOfItems(); 186 size_t toPointListSize = toList->length();
187 size_t toAtEndOfDurationListSize = toAtEndOfDurationList->numberOfItems(); 187 size_t toAtEndOfDurationListSize = toAtEndOfDurationList->length();
188 188
189 if (!adjustFromToListValues(fromList, toList, percentage, animationElement-> animationMode() == ToAnimation, true)) 189 if (!adjustFromToListValues(fromList, toList, percentage, animationElement-> animationMode() == ToAnimation, true))
190 return; 190 return;
191 191
192 for (size_t i = 0; i < toPointListSize; ++i) { 192 for (size_t i = 0; i < toPointListSize; ++i) {
193 float animatedX = at(i)->x(); 193 float animatedX = at(i)->x();
194 float animatedY = at(i)->y(); 194 float animatedY = at(i)->y();
195 195
196 FloatPoint effectiveFrom; 196 FloatPoint effectiveFrom;
197 if (fromPointListSize) 197 if (fromPointListSize)
198 effectiveFrom = fromList->at(i)->value(); 198 effectiveFrom = fromList->at(i)->value();
199 FloatPoint effectiveTo = toList->at(i)->value(); 199 FloatPoint effectiveTo = toList->at(i)->value();
200 FloatPoint effectiveToAtEnd; 200 FloatPoint effectiveToAtEnd;
201 if (i < toAtEndOfDurationListSize) 201 if (i < toAtEndOfDurationListSize)
202 effectiveToAtEnd = toAtEndOfDurationList->at(i)->value(); 202 effectiveToAtEnd = toAtEndOfDurationList->at(i)->value();
203 203
204 animationElement->animateAdditiveNumber(percentage, repeatCount, effecti veFrom.x(), effectiveTo.x(), effectiveToAtEnd.x(), animatedX); 204 animationElement->animateAdditiveNumber(percentage, repeatCount, effecti veFrom.x(), effectiveTo.x(), effectiveToAtEnd.x(), animatedX);
205 animationElement->animateAdditiveNumber(percentage, repeatCount, effecti veFrom.y(), effectiveTo.y(), effectiveToAtEnd.y(), animatedY); 205 animationElement->animateAdditiveNumber(percentage, repeatCount, effecti veFrom.y(), effectiveTo.y(), effectiveToAtEnd.y(), animatedY);
206 at(i)->setValue(FloatPoint(animatedX, animatedY)); 206 at(i)->setValue(FloatPoint(animatedX, animatedY));
207 } 207 }
208 } 208 }
209 209
210 float SVGPointList::calculateDistance(PassRefPtr<NewSVGPropertyBase> to, SVGElem ent*) 210 float SVGPointList::calculateDistance(PassRefPtr<NewSVGPropertyBase> to, SVGElem ent*)
211 { 211 {
212 // FIXME: Distance calculation is not possible for SVGPointList right now. W e need the distance for every single value. 212 // FIXME: Distance calculation is not possible for SVGPointList right now. W e need the distance for every single value.
213 return -1; 213 return -1;
214 } 214 }
215 215
216 } 216 }
OLDNEW
« no previous file with comments | « Source/core/svg/SVGPathSegList.idl ('k') | Source/core/svg/SVGPointList.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698