| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "config.h" | 31 #include "config.h" |
| 32 #include "core/animation/AnimatableStrokeDasharrayList.h" | 32 #include "core/animation/AnimatableStrokeDasharrayList.h" |
| 33 | 33 |
| 34 #include "bindings/v8/ExceptionStatePlaceholder.h" | 34 #include "bindings/v8/ExceptionStatePlaceholder.h" |
| 35 #include "core/animation/AnimatableSVGLength.h" | 35 #include "core/animation/AnimatableSVGLength.h" |
| 36 | 36 |
| 37 namespace WebCore { | 37 namespace WebCore { |
| 38 | 38 |
| 39 AnimatableStrokeDasharrayList::AnimatableStrokeDasharrayList(const Vector<SVGLen
gth>& lengths) | 39 AnimatableStrokeDasharrayList::AnimatableStrokeDasharrayList(PassRefPtr<SVGLengt
hList> passLengths) |
| 40 { | 40 { |
| 41 for (size_t i = 0; i < lengths.size(); ++i) | 41 RefPtr<SVGLengthList> lengths = passLengths; |
| 42 m_values.append(AnimatableSVGLength::create(lengths[i])); | 42 SVGLengthList::ConstIterator it = lengths->begin(); |
| 43 SVGLengthList::ConstIterator itEnd = lengths->end(); |
| 44 for (; it != itEnd; ++it) |
| 45 m_values.append(AnimatableSVGLength::create(*it)); |
| 43 } | 46 } |
| 44 | 47 |
| 45 Vector<SVGLength> AnimatableStrokeDasharrayList::toSVGLengthVector() const | 48 PassRefPtr<SVGLengthList> AnimatableStrokeDasharrayList::toSVGLengthList() const |
| 46 { | 49 { |
| 47 Vector<SVGLength> lengths(m_values.size()); | 50 RefPtr<SVGLengthList> lengths = SVGLengthList::create(); |
| 48 for (size_t i = 0; i < m_values.size(); ++i) { | 51 for (size_t i = 0; i < m_values.size(); ++i) { |
| 49 lengths[i] = toAnimatableSVGLength(m_values[i].get())->toSVGLength(); | 52 RefPtr<SVGLength> length = toAnimatableSVGLength(m_values[i].get())->toS
VGLength(); |
| 50 if (lengths[i].valueInSpecifiedUnits() < 0) | 53 if (length->valueInSpecifiedUnits() < 0) |
| 51 lengths[i].setValueInSpecifiedUnits(0); | 54 length->setValueInSpecifiedUnits(0); |
| 55 lengths->append(length); |
| 52 } | 56 } |
| 53 return lengths; | 57 return lengths.release(); |
| 54 } | 58 } |
| 55 | 59 |
| 56 bool AnimatableStrokeDasharrayList::usesDefaultInterpolationWith(const Animatabl
eValue* value) const | 60 bool AnimatableStrokeDasharrayList::usesDefaultInterpolationWith(const Animatabl
eValue* value) const |
| 57 { | 61 { |
| 58 return false; | 62 return false; |
| 59 } | 63 } |
| 60 | 64 |
| 61 PassRefPtr<AnimatableValue> AnimatableStrokeDasharrayList::interpolateTo(const A
nimatableValue* value, double fraction) const | 65 PassRefPtr<AnimatableValue> AnimatableStrokeDasharrayList::interpolateTo(const A
nimatableValue* value, double fraction) const |
| 62 { | 66 { |
| 63 Vector<RefPtr<AnimatableValue> > from = m_values; | 67 Vector<RefPtr<AnimatableValue> > from = m_values; |
| 64 Vector<RefPtr<AnimatableValue> > to = toAnimatableStrokeDasharrayList(value)
->m_values; | 68 Vector<RefPtr<AnimatableValue> > to = toAnimatableStrokeDasharrayList(value)
->m_values; |
| 65 | 69 |
| 66 // The spec states that if the sum of all values is zero, this should be | 70 // The spec states that if the sum of all values is zero, this should be |
| 67 // treated like a value of 'none', which means that a solid line is drawn. | 71 // treated like a value of 'none', which means that a solid line is drawn. |
| 68 // Since we animate to and from values of zero, treat a value of 'none' the | 72 // Since we animate to and from values of zero, treat a value of 'none' the |
| 69 // same. If both the two and from values are 'none', we return 'none' | 73 // same. If both the two and from values are 'none', we return 'none' |
| 70 // rather than '0 0'. | 74 // rather than '0 0'. |
| 71 if (from.isEmpty() && to.isEmpty()) | 75 if (from.isEmpty() && to.isEmpty()) |
| 72 return takeConstRef(this); | 76 return takeConstRef(this); |
| 73 if (from.isEmpty() || to.isEmpty()) { | 77 if (from.isEmpty() || to.isEmpty()) { |
| 74 DEFINE_STATIC_REF(AnimatableSVGLength, zeroPixels, AnimatableSVGLength::
create(SVGLength()).leakRef()); | 78 DEFINE_STATIC_REF(AnimatableSVGLength, zeroPixels, AnimatableSVGLength::
create(SVGLength::create()).leakRef()); |
| 75 if (from.isEmpty()) { | 79 if (from.isEmpty()) { |
| 76 from.append(zeroPixels); | 80 from.append(zeroPixels); |
| 77 from.append(zeroPixels); | 81 from.append(zeroPixels); |
| 78 } | 82 } |
| 79 if (to.isEmpty()) { | 83 if (to.isEmpty()) { |
| 80 to.append(zeroPixels); | 84 to.append(zeroPixels); |
| 81 to.append(zeroPixels); | 85 to.append(zeroPixels); |
| 82 } | 86 } |
| 83 } | 87 } |
| 84 | 88 |
| 85 Vector<RefPtr<AnimatableValue> > interpolatedValues; | 89 Vector<RefPtr<AnimatableValue> > interpolatedValues; |
| 86 bool success = interpolateLists(from, to, fraction, interpolatedValues); | 90 bool success = interpolateLists(from, to, fraction, interpolatedValues); |
| 87 ASSERT_UNUSED(success, success); | 91 ASSERT_UNUSED(success, success); |
| 88 return adoptRef(new AnimatableStrokeDasharrayList(interpolatedValues)); | 92 return adoptRef(new AnimatableStrokeDasharrayList(interpolatedValues)); |
| 89 } | 93 } |
| 90 | 94 |
| 91 } // namespace WebCore | 95 } // namespace WebCore |
| OLD | NEW |