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

Side by Side Diff: third_party/WebKit/Source/core/svg/SVGLengthList.cpp

Issue 2097383002: Added support of calc() for SVGLength (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 4 years, 5 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
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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 const CharType* listStart = ptr; 74 const CharType* listStart = ptr;
75 while (ptr < end) { 75 while (ptr < end) {
76 const CharType* start = ptr; 76 const CharType* start = ptr;
77 // TODO(shanmuga.m): Enable calc for SVGLengthList
77 while (ptr < end && *ptr != ',' && !isHTMLSpace<CharType>(*ptr)) 78 while (ptr < end && *ptr != ',' && !isHTMLSpace<CharType>(*ptr))
78 ptr++; 79 ptr++;
79 if (ptr == start) 80 if (ptr == start)
80 break; 81 break;
81 String valueString(start, ptr - start); 82 String valueString(start, ptr - start);
82 if (valueString.isEmpty()) 83 if (valueString.isEmpty())
83 break; 84 break;
84 85
85 SVGLength* length = SVGLength::create(m_mode); 86 SVGLength* length = SVGLength::create(m_mode);
86 SVGParsingError lengthParseStatus = length->setValueAsString(valueString ); 87 SVGParsingError lengthParseStatus = length->setValueAsString(valueString );
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 ASSERT(m_mode == SVGLength::lengthModeForAnimatedLengthAttribute(animationEl ement->attributeName())); 137 ASSERT(m_mode == SVGLength::lengthModeForAnimatedLengthAttribute(animationEl ement->attributeName()));
137 138
138 size_t fromLengthListSize = fromList->length(); 139 size_t fromLengthListSize = fromList->length();
139 size_t toLengthListSize = toList->length(); 140 size_t toLengthListSize = toList->length();
140 size_t toAtEndOfDurationListSize = toAtEndOfDurationList->length(); 141 size_t toAtEndOfDurationListSize = toAtEndOfDurationList->length();
141 142
142 if (!adjustFromToListValues(fromList, toList, percentage, animationElement-> getAnimationMode())) 143 if (!adjustFromToListValues(fromList, toList, percentage, animationElement-> getAnimationMode()))
143 return; 144 return;
144 145
145 for (size_t i = 0; i < toLengthListSize; ++i) { 146 for (size_t i = 0; i < toLengthListSize; ++i) {
147 // TODO(shanmuga.m): Support calc for SVGLengthList animation
146 float animatedNumber = at(i)->value(lengthContext); 148 float animatedNumber = at(i)->value(lengthContext);
147 CSSPrimitiveValue::UnitType unitType = toList->at(i)->typeWithCalcResolv ed(); 149 CSSPrimitiveValue::UnitType unitType = toList->at(i)->typeWithCalcResolv ed();
148 float effectiveFrom = 0; 150 float effectiveFrom = 0;
149 if (fromLengthListSize) { 151 if (fromLengthListSize) {
150 if (percentage < 0.5) 152 if (percentage < 0.5)
151 unitType = fromList->at(i)->typeWithCalcResolved(); 153 unitType = fromList->at(i)->typeWithCalcResolved();
152 effectiveFrom = fromList->at(i)->value(lengthContext); 154 effectiveFrom = fromList->at(i)->value(lengthContext);
153 } 155 }
154 float effectiveTo = toList->at(i)->value(lengthContext); 156 float effectiveTo = toList->at(i)->value(lengthContext);
155 float effectiveToAtEnd = i < toAtEndOfDurationListSize ? toAtEndOfDurati onList->at(i)->value(lengthContext) : 0; 157 float effectiveToAtEnd = i < toAtEndOfDurationListSize ? toAtEndOfDurati onList->at(i)->value(lengthContext) : 0;
156 158
157 animationElement->animateAdditiveNumber(percentage, repeatCount, effecti veFrom, effectiveTo, effectiveToAtEnd, animatedNumber); 159 animationElement->animateAdditiveNumber(percentage, repeatCount, effecti veFrom, effectiveTo, effectiveToAtEnd, animatedNumber);
158 at(i)->setUnitType(unitType); 160 at(i)->setUnitType(unitType);
159 at(i)->setValue(animatedNumber, lengthContext); 161 at(i)->setValue(animatedNumber, lengthContext);
160 } 162 }
161 } 163 }
162 164
163 float SVGLengthList::calculateDistance(SVGPropertyBase* to, SVGElement*) 165 float SVGLengthList::calculateDistance(SVGPropertyBase* to, SVGElement*)
164 { 166 {
165 // FIXME: Distance calculation is not possible for SVGLengthList right now. We need the distance for every single value. 167 // FIXME: Distance calculation is not possible for SVGLengthList right now. We need the distance for every single value.
166 return -1; 168 return -1;
167 } 169 }
168 } // namespace blink 170 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/svg/SVGLengthContext.cpp ('k') | third_party/WebKit/Source/core/svg/SVGLengthTearOff.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698