| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004, 2005 Nikolas Zimmermann <zimmermann@kde.org> | 2 * Copyright (C) 2004, 2005 Nikolas Zimmermann <zimmermann@kde.org> |
| 3 * Copyright (C) 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org> | 3 * Copyright (C) 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org> |
| 4 * Copyright (C) 2007 Eric Seidel <eric@webkit.org> | 4 * Copyright (C) 2007 Eric Seidel <eric@webkit.org> |
| 5 * Copyright (C) 2008 Apple Inc. All rights reserved. | 5 * Copyright (C) 2008 Apple Inc. All rights reserved. |
| 6 * Copyright (C) 2009 Cameron McCormack <cam@mcc.id.au> | 6 * Copyright (C) 2009 Cameron McCormack <cam@mcc.id.au> |
| 7 * Copyright (C) Research In Motion Limited 2010. All rights reserved. | 7 * Copyright (C) Research In Motion Limited 2010. All rights reserved. |
| 8 * | 8 * |
| 9 * This library is free software; you can redistribute it and/or | 9 * This library is free software; you can redistribute it and/or |
| 10 * modify it under the terms of the GNU Library General Public | 10 * modify it under the terms of the GNU Library General Public |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 Vector<String> parseList; | 53 Vector<String> parseList; |
| 54 value.split(';', true, parseList); | 54 value.split(';', true, parseList); |
| 55 unsigned last = parseList.size() - 1; | 55 unsigned last = parseList.size() - 1; |
| 56 for (unsigned i = 0; i <= last; ++i) { | 56 for (unsigned i = 0; i <= last; ++i) { |
| 57 if (parseList[i].isEmpty()) { | 57 if (parseList[i].isEmpty()) { |
| 58 // Tolerate trailing ';' | 58 // Tolerate trailing ';' |
| 59 if (i < last) | 59 if (i < last) |
| 60 goto fail; | 60 goto fail; |
| 61 } else { | 61 } else { |
| 62 parseList[i] = parseList[i].stripWhiteSpace(); | 62 parseList[i] = parseList[i].stripWhiteSpace(); |
| 63 result.append(parseList[i]); | 63 result.push_back(parseList[i]); |
| 64 } | 64 } |
| 65 } | 65 } |
| 66 | 66 |
| 67 return true; | 67 return true; |
| 68 fail: | 68 fail: |
| 69 result.clear(); | 69 result.clear(); |
| 70 return false; | 70 return false; |
| 71 } | 71 } |
| 72 | 72 |
| 73 static bool parseKeyTimes(const String& string, | 73 static bool parseKeyTimes(const String& string, |
| 74 Vector<float>& result, | 74 Vector<float>& result, |
| 75 bool verifyOrder) { | 75 bool verifyOrder) { |
| 76 result.clear(); | 76 result.clear(); |
| 77 Vector<String> parseList; | 77 Vector<String> parseList; |
| 78 string.split(';', true, parseList); | 78 string.split(';', true, parseList); |
| 79 for (unsigned n = 0; n < parseList.size(); ++n) { | 79 for (unsigned n = 0; n < parseList.size(); ++n) { |
| 80 String timeString = parseList[n].stripWhiteSpace(); | 80 String timeString = parseList[n].stripWhiteSpace(); |
| 81 bool ok; | 81 bool ok; |
| 82 float time = timeString.toFloat(&ok); | 82 float time = timeString.toFloat(&ok); |
| 83 if (!ok || time < 0 || time > 1) | 83 if (!ok || time < 0 || time > 1) |
| 84 goto fail; | 84 goto fail; |
| 85 if (verifyOrder) { | 85 if (verifyOrder) { |
| 86 if (!n) { | 86 if (!n) { |
| 87 if (time) | 87 if (time) |
| 88 goto fail; | 88 goto fail; |
| 89 } else if (time < result.back()) { | 89 } else if (time < result.back()) { |
| 90 goto fail; | 90 goto fail; |
| 91 } | 91 } |
| 92 } | 92 } |
| 93 result.append(time); | 93 result.push_back(time); |
| 94 } | 94 } |
| 95 return true; | 95 return true; |
| 96 fail: | 96 fail: |
| 97 result.clear(); | 97 result.clear(); |
| 98 return false; | 98 return false; |
| 99 } | 99 } |
| 100 | 100 |
| 101 template <typename CharType> | 101 template <typename CharType> |
| 102 static bool parseKeySplinesInternal(const String& string, | 102 static bool parseKeySplinesInternal(const String& string, |
| 103 Vector<gfx::CubicBezier>& result) { | 103 Vector<gfx::CubicBezier>& result) { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 122 float posD = 0; | 122 float posD = 0; |
| 123 if (!parseNumber(ptr, end, posD, DisallowWhitespace)) | 123 if (!parseNumber(ptr, end, posD, DisallowWhitespace)) |
| 124 return false; | 124 return false; |
| 125 | 125 |
| 126 skipOptionalSVGSpaces(ptr, end); | 126 skipOptionalSVGSpaces(ptr, end); |
| 127 | 127 |
| 128 if (ptr < end && *ptr == ';') | 128 if (ptr < end && *ptr == ';') |
| 129 ptr++; | 129 ptr++; |
| 130 skipOptionalSVGSpaces(ptr, end); | 130 skipOptionalSVGSpaces(ptr, end); |
| 131 | 131 |
| 132 result.append(gfx::CubicBezier(posA, posB, posC, posD)); | 132 result.push_back(gfx::CubicBezier(posA, posB, posC, posD)); |
| 133 } | 133 } |
| 134 | 134 |
| 135 return ptr == end; | 135 return ptr == end; |
| 136 } | 136 } |
| 137 | 137 |
| 138 static bool parseKeySplines(const String& string, | 138 static bool parseKeySplines(const String& string, |
| 139 Vector<gfx::CubicBezier>& result) { | 139 Vector<gfx::CubicBezier>& result) { |
| 140 result.clear(); | 140 result.clear(); |
| 141 if (string.isEmpty()) | 141 if (string.isEmpty()) |
| 142 return true; | 142 return true; |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 ASSERT(valuesCount >= 1); | 336 ASSERT(valuesCount >= 1); |
| 337 if (valuesCount == 1) | 337 if (valuesCount == 1) |
| 338 return; | 338 return; |
| 339 | 339 |
| 340 // FIXME, webkit.org/b/109010: m_keyTimes should not be modified in this | 340 // FIXME, webkit.org/b/109010: m_keyTimes should not be modified in this |
| 341 // function. | 341 // function. |
| 342 m_keyTimes.clear(); | 342 m_keyTimes.clear(); |
| 343 | 343 |
| 344 Vector<float> keyTimesForPaced; | 344 Vector<float> keyTimesForPaced; |
| 345 float totalDistance = 0; | 345 float totalDistance = 0; |
| 346 keyTimesForPaced.append(0); | 346 keyTimesForPaced.push_back(0); |
| 347 for (unsigned n = 0; n < valuesCount - 1; ++n) { | 347 for (unsigned n = 0; n < valuesCount - 1; ++n) { |
| 348 // Distance in any units | 348 // Distance in any units |
| 349 float distance = calculateDistance(m_values[n], m_values[n + 1]); | 349 float distance = calculateDistance(m_values[n], m_values[n + 1]); |
| 350 if (distance < 0) | 350 if (distance < 0) |
| 351 return; | 351 return; |
| 352 totalDistance += distance; | 352 totalDistance += distance; |
| 353 keyTimesForPaced.append(distance); | 353 keyTimesForPaced.push_back(distance); |
| 354 } | 354 } |
| 355 if (!totalDistance) | 355 if (!totalDistance) |
| 356 return; | 356 return; |
| 357 | 357 |
| 358 // Normalize. | 358 // Normalize. |
| 359 for (unsigned n = 1; n < keyTimesForPaced.size() - 1; ++n) | 359 for (unsigned n = 1; n < keyTimesForPaced.size() - 1; ++n) |
| 360 keyTimesForPaced[n] = | 360 keyTimesForPaced[n] = |
| 361 keyTimesForPaced[n - 1] + keyTimesForPaced[n] / totalDistance; | 361 keyTimesForPaced[n - 1] + keyTimesForPaced[n] / totalDistance; |
| 362 keyTimesForPaced[keyTimesForPaced.size() - 1] = 1; | 362 keyTimesForPaced[keyTimesForPaced.size() - 1] = 1; |
| 363 | 363 |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 614 calculatePercentForSpline(percent, calculateKeyTimesIndex(percent)); | 614 calculatePercentForSpline(percent, calculateKeyTimesIndex(percent)); |
| 615 else if (animationMode == FromToAnimation || animationMode == ToAnimation) | 615 else if (animationMode == FromToAnimation || animationMode == ToAnimation) |
| 616 effectivePercent = calculatePercentForFromTo(percent); | 616 effectivePercent = calculatePercentForFromTo(percent); |
| 617 else | 617 else |
| 618 effectivePercent = percent; | 618 effectivePercent = percent; |
| 619 | 619 |
| 620 calculateAnimatedValue(effectivePercent, repeatCount, resultElement); | 620 calculateAnimatedValue(effectivePercent, repeatCount, resultElement); |
| 621 } | 621 } |
| 622 | 622 |
| 623 } // namespace blink | 623 } // namespace blink |
| OLD | NEW |