| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 PassRefPtr<SVGDashArray> AnimatableStrokeDasharrayList::toSVGDashArray(float zoo
m) const | 45 PassRefPtr<SVGDashArray> AnimatableStrokeDasharrayList::toSVGDashArray(float zoo
m) const |
| 46 { | 46 { |
| 47 RefPtr<SVGDashArray> lengths = SVGDashArray::create(); | 47 RefPtr<SVGDashArray> lengths = SVGDashArray::create(); |
| 48 for (const auto& dashLength : m_values) | 48 for (const auto& dashLength : m_values) |
| 49 lengths->append(toAnimatableLength(dashLength.get())->length(zoom, Value
RangeNonNegative)); | 49 lengths->append(toAnimatableLength(dashLength.get())->length(zoom, Value
RangeNonNegative)); |
| 50 return lengths.release(); | 50 return lengths.release(); |
| 51 } | 51 } |
| 52 | 52 |
| 53 bool AnimatableStrokeDasharrayList::usesDefaultInterpolationWith(const Animatabl
eValue* value) const | 53 bool AnimatableStrokeDasharrayList::usesDefaultInterpolationWith(const Animatabl
eValue* value) const |
| 54 { | 54 { |
| 55 WillBeHeapVector<RefPtrWillBeMember<AnimatableValue>> from = m_values; | 55 HeapVector<Member<AnimatableValue>> from = m_values; |
| 56 WillBeHeapVector<RefPtrWillBeMember<AnimatableValue>> to = toAnimatableStrok
eDasharrayList(value)->m_values; | 56 HeapVector<Member<AnimatableValue>> to = toAnimatableStrokeDasharrayList(val
ue)->m_values; |
| 57 return !from.isEmpty() && !to.isEmpty() && AnimatableRepeatable::usesDefault
InterpolationWith(value); | 57 return !from.isEmpty() && !to.isEmpty() && AnimatableRepeatable::usesDefault
InterpolationWith(value); |
| 58 } | 58 } |
| 59 | 59 |
| 60 PassRefPtrWillBeRawPtr<AnimatableValue> AnimatableStrokeDasharrayList::interpola
teTo(const AnimatableValue* value, double fraction) const | 60 AnimatableValue* AnimatableStrokeDasharrayList::interpolateTo(const AnimatableVa
lue* value, double fraction) const |
| 61 { | 61 { |
| 62 if (usesDefaultInterpolationWith(value)) | 62 if (usesDefaultInterpolationWith(value)) |
| 63 return defaultInterpolateTo(this, value, fraction); | 63 return defaultInterpolateTo(this, value, fraction); |
| 64 | 64 |
| 65 WillBeHeapVector<RefPtrWillBeMember<AnimatableValue>> from = m_values; | 65 HeapVector<Member<AnimatableValue>> from = m_values; |
| 66 WillBeHeapVector<RefPtrWillBeMember<AnimatableValue>> to = toAnimatableStrok
eDasharrayList(value)->m_values; | 66 HeapVector<Member<AnimatableValue>> to = toAnimatableStrokeDasharrayList(val
ue)->m_values; |
| 67 | 67 |
| 68 // The spec states that if the sum of all values is zero, this should be | 68 // The spec states that if the sum of all values is zero, this should be |
| 69 // treated like a value of 'none', which means that a solid line is drawn. | 69 // treated like a value of 'none', which means that a solid line is drawn. |
| 70 // Since we animate to and from values of zero, treat a value of 'none' the | 70 // Since we animate to and from values of zero, treat a value of 'none' the |
| 71 // same. If both the two and from values are 'none', we return 'none' | 71 // same. If both the two and from values are 'none', we return 'none' |
| 72 // rather than '0 0'. | 72 // rather than '0 0'. |
| 73 if (from.isEmpty() && to.isEmpty()) | 73 if (from.isEmpty() && to.isEmpty()) |
| 74 return takeConstRef(this); | 74 return takeConstRef(this); |
| 75 if (from.isEmpty() || to.isEmpty()) { | 75 if (from.isEmpty() || to.isEmpty()) { |
| 76 DEFINE_STATIC_REF_WILL_BE_PERSISTENT(AnimatableLength, zeroPixels, (Anim
atableLength::create(Length(Fixed), 1))); | 76 static AnimatableLength* zeroPixels = (new Persistent<AnimatableLength>(
AnimatableLength::create(Length(Fixed), 1)))->get(); |
| 77 if (from.isEmpty()) { | 77 if (from.isEmpty()) { |
| 78 from.append(zeroPixels); | 78 from.append(zeroPixels); |
| 79 from.append(zeroPixels); | 79 from.append(zeroPixels); |
| 80 } | 80 } |
| 81 if (to.isEmpty()) { | 81 if (to.isEmpty()) { |
| 82 to.append(zeroPixels); | 82 to.append(zeroPixels); |
| 83 to.append(zeroPixels); | 83 to.append(zeroPixels); |
| 84 } | 84 } |
| 85 } | 85 } |
| 86 | 86 |
| 87 WillBeHeapVector<RefPtrWillBeMember<AnimatableValue>> interpolatedValues; | 87 HeapVector<Member<AnimatableValue>> interpolatedValues; |
| 88 bool success = interpolateLists(from, to, fraction, interpolatedValues); | 88 bool success = interpolateLists(from, to, fraction, interpolatedValues); |
| 89 ASSERT_UNUSED(success, success); | 89 ASSERT_UNUSED(success, success); |
| 90 return adoptRefWillBeNoop(new AnimatableStrokeDasharrayList(interpolatedValu
es)); | 90 return new AnimatableStrokeDasharrayList(interpolatedValues); |
| 91 } | 91 } |
| 92 | 92 |
| 93 DEFINE_TRACE(AnimatableStrokeDasharrayList) | 93 DEFINE_TRACE(AnimatableStrokeDasharrayList) |
| 94 { | 94 { |
| 95 AnimatableRepeatable::trace(visitor); | 95 AnimatableRepeatable::trace(visitor); |
| 96 } | 96 } |
| 97 | 97 |
| 98 } // namespace blink | 98 } // namespace blink |
| OLD | NEW |