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

Side by Side Diff: Source/core/svg/SVGLengthList.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/SVGFEConvolveMatrixElement.cpp ('k') | Source/core/svg/SVGLengthList.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, 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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 const UChar* ptr = value.characters16(); 112 const UChar* ptr = value.characters16();
113 const UChar* end = ptr + value.length(); 113 const UChar* end = ptr + value.length();
114 parseInternal(ptr, end, exceptionState); 114 parseInternal(ptr, end, exceptionState);
115 } 115 }
116 } 116 }
117 117
118 void SVGLengthList::add(PassRefPtr<NewSVGPropertyBase> other, SVGElement* contex tElement) 118 void SVGLengthList::add(PassRefPtr<NewSVGPropertyBase> other, SVGElement* contex tElement)
119 { 119 {
120 RefPtr<SVGLengthList> otherList = toSVGLengthList(other); 120 RefPtr<SVGLengthList> otherList = toSVGLengthList(other);
121 121
122 if (numberOfItems() != otherList->numberOfItems()) 122 if (length() != otherList->length())
123 return; 123 return;
124 124
125 SVGLengthContext lengthContext(contextElement); 125 SVGLengthContext lengthContext(contextElement);
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(lengthContext) + otherList->at(i)->value(le ngthContext), lengthContext, ASSERT_NO_EXCEPTION); 127 at(i)->setValue(at(i)->value(lengthContext) + otherList->at(i)->value(le ngthContext), lengthContext, ASSERT_NO_EXCEPTION);
128 } 128 }
129 129
130 bool SVGLengthList::adjustFromToListValues(PassRefPtr<SVGLengthList> passFromLis t, PassRefPtr<SVGLengthList> passToList, float percentage, bool isToAnimation, b ool resizeAnimatedListIfNeeded) 130 bool SVGLengthList::adjustFromToListValues(PassRefPtr<SVGLengthList> passFromLis t, PassRefPtr<SVGLengthList> passToList, float percentage, bool isToAnimation, b ool resizeAnimatedListIfNeeded)
131 { 131 {
132 RefPtr<SVGLengthList> fromList = passFromList; 132 RefPtr<SVGLengthList> fromList = passFromList;
133 RefPtr<SVGLengthList> toList = passToList; 133 RefPtr<SVGLengthList> 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(SVGLength::create(m_mode)); 157 append(SVGLength::create(m_mode));
158 } 158 }
159 159
160 return true; 160 return true;
161 } 161 }
162 162
163 void SVGLengthList::calculateAnimatedValue(SVGAnimationElement* animationElement , float percentage, unsigned repeatCount, PassRefPtr<NewSVGPropertyBase> fromVal ue, PassRefPtr<NewSVGPropertyBase> toValue, PassRefPtr<NewSVGPropertyBase> toAtE ndOfDurationValue, SVGElement* contextElement) 163 void SVGLengthList::calculateAnimatedValue(SVGAnimationElement* animationElement , float percentage, unsigned repeatCount, PassRefPtr<NewSVGPropertyBase> fromVal ue, PassRefPtr<NewSVGPropertyBase> toValue, PassRefPtr<NewSVGPropertyBase> toAtE ndOfDurationValue, SVGElement* contextElement)
164 { 164 {
165 RefPtr<SVGLengthList> fromList = toSVGLengthList(fromValue); 165 RefPtr<SVGLengthList> fromList = toSVGLengthList(fromValue);
166 RefPtr<SVGLengthList> toList = toSVGLengthList(toValue); 166 RefPtr<SVGLengthList> toList = toSVGLengthList(toValue);
167 RefPtr<SVGLengthList> toAtEndOfDurationList = toSVGLengthList(toAtEndOfDurat ionValue); 167 RefPtr<SVGLengthList> toAtEndOfDurationList = toSVGLengthList(toAtEndOfDurat ionValue);
168 168
169 SVGLengthContext lengthContext(contextElement); 169 SVGLengthContext lengthContext(contextElement);
170 ASSERT(m_mode == SVGLength::lengthModeForAnimatedLengthAttribute(animationEl ement->attributeName())); 170 ASSERT(m_mode == SVGLength::lengthModeForAnimatedLengthAttribute(animationEl ement->attributeName()));
171 171
172 size_t fromLengthListSize = fromList->numberOfItems(); 172 size_t fromLengthListSize = fromList->length();
173 size_t toLengthListSize = toList->numberOfItems(); 173 size_t toLengthListSize = toList->length();
174 size_t toAtEndOfDurationListSize = toAtEndOfDurationList->numberOfItems(); 174 size_t toAtEndOfDurationListSize = toAtEndOfDurationList->length();
175 175
176 if (!adjustFromToListValues(fromList, toList, percentage, animationElement-> animationMode() == ToAnimation, true)) 176 if (!adjustFromToListValues(fromList, toList, percentage, animationElement-> animationMode() == ToAnimation, true))
177 return; 177 return;
178 178
179 for (size_t i = 0; i < toLengthListSize; ++i) { 179 for (size_t i = 0; i < toLengthListSize; ++i) {
180 float animatedNumber = at(i)->value(lengthContext); 180 float animatedNumber = at(i)->value(lengthContext);
181 SVGLengthType unitType = toList->at(i)->unitType(); 181 SVGLengthType unitType = toList->at(i)->unitType();
182 float effectiveFrom = 0; 182 float effectiveFrom = 0;
183 if (fromLengthListSize) { 183 if (fromLengthListSize) {
184 if (percentage < 0.5) 184 if (percentage < 0.5)
185 unitType = fromList->at(i)->unitType(); 185 unitType = fromList->at(i)->unitType();
186 effectiveFrom = fromList->at(i)->value(lengthContext); 186 effectiveFrom = fromList->at(i)->value(lengthContext);
187 } 187 }
188 float effectiveTo = toList->at(i)->value(lengthContext); 188 float effectiveTo = toList->at(i)->value(lengthContext);
189 float effectiveToAtEnd = i < toAtEndOfDurationListSize ? toAtEndOfDurati onList->at(i)->value(lengthContext) : 0; 189 float effectiveToAtEnd = i < toAtEndOfDurationListSize ? toAtEndOfDurati onList->at(i)->value(lengthContext) : 0;
190 190
191 animationElement->animateAdditiveNumber(percentage, repeatCount, effecti veFrom, effectiveTo, effectiveToAtEnd, animatedNumber); 191 animationElement->animateAdditiveNumber(percentage, repeatCount, effecti veFrom, effectiveTo, effectiveToAtEnd, animatedNumber);
192 at(i)->setUnitType(unitType); 192 at(i)->setUnitType(unitType);
193 at(i)->setValue(animatedNumber, lengthContext, ASSERT_NO_EXCEPTION); 193 at(i)->setValue(animatedNumber, lengthContext, ASSERT_NO_EXCEPTION);
194 } 194 }
195 } 195 }
196 196
197 float SVGLengthList::calculateDistance(PassRefPtr<NewSVGPropertyBase> to, SVGEle ment*) 197 float SVGLengthList::calculateDistance(PassRefPtr<NewSVGPropertyBase> to, SVGEle ment*)
198 { 198 {
199 // FIXME: Distance calculation is not possible for SVGLengthList right now. We need the distance for every single value. 199 // FIXME: Distance calculation is not possible for SVGLengthList right now. We need the distance for every single value.
200 return -1; 200 return -1;
201 } 201 }
202 } 202 }
OLDNEW
« no previous file with comments | « Source/core/svg/SVGFEConvolveMatrixElement.cpp ('k') | Source/core/svg/SVGLengthList.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698