| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) Research In Motion Limited 2010. All rights reserved. | 2 * Copyright (C) Research In Motion Limited 2010. All rights reserved. |
| 3 * | 3 * |
| 4 * This library is free software; you can redistribute it and/or | 4 * This library is free software; you can redistribute it and/or |
| 5 * modify it under the terms of the GNU Library General Public | 5 * modify it under the terms of the GNU Library General Public |
| 6 * License as published by the Free Software Foundation; either | 6 * License as published by the Free Software Foundation; either |
| 7 * version 2 of the License, or (at your option) any later version. | 7 * version 2 of the License, or (at your option) any later version. |
| 8 * | 8 * |
| 9 * This library is distributed in the hope that it will be useful, | 9 * This library is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 animVal->setValuesAndWrappers(newAnimVal, &m_animatedWrappers, shouldOwn
Values); | 102 animVal->setValuesAndWrappers(newAnimVal, &m_animatedWrappers, shouldOwn
Values); |
| 103 ASSERT(animVal->values().size() == animVal->wrappers().size()); | 103 ASSERT(animVal->values().size() == animVal->wrappers().size()); |
| 104 ASSERT(animVal->wrappers().size() == m_animatedWrappers.size()); | 104 ASSERT(animVal->wrappers().size() == m_animatedWrappers.size()); |
| 105 m_isAnimating = true; | 105 m_isAnimating = true; |
| 106 } | 106 } |
| 107 | 107 |
| 108 void animationEnded() | 108 void animationEnded() |
| 109 { | 109 { |
| 110 ASSERT(m_isAnimating); | 110 ASSERT(m_isAnimating); |
| 111 ASSERT(m_animVal); | 111 ASSERT(m_animVal); |
| 112 ASSERT(contextElement()); | 112 ASSERT(m_values.size() == m_wrappers.size()); |
| 113 | 113 |
| 114 ListProperty* animVal = static_cast<ListProperty*>(m_animVal.get()); | 114 ListProperty* animVal = static_cast<ListProperty*>(m_animVal.get()); |
| 115 if (animVal->wrappers().size()) { | 115 ASSERT(animVal->values().size() == animVal->wrappers().size()); |
| 116 ASSERT(m_values.size() == m_wrappers.size()); | 116 ASSERT(animVal->wrappers().size() == m_animatedWrappers.size()); |
| 117 ASSERT(animVal->values().size() == animVal->wrappers().size()); | |
| 118 ASSERT(animVal->wrappers().size() == m_animatedWrappers.size()); | |
| 119 | 117 |
| 120 animVal->setValuesAndWrappers(&m_values, &m_wrappers, false); | 118 animVal->setValuesAndWrappers(&m_values, &m_wrappers, false); |
| 121 ASSERT(animVal->values().size() == animVal->wrappers().size()); | 119 ASSERT(animVal->values().size() == animVal->wrappers().size()); |
| 122 ASSERT(animVal->wrappers().size() == m_wrappers.size()); | 120 ASSERT(animVal->wrappers().size() == m_wrappers.size()); |
| 123 } | 121 |
| 124 m_animatedWrappers.clear(); | 122 m_animatedWrappers.clear(); |
| 125 m_isAnimating = false; | 123 m_isAnimating = false; |
| 126 } | 124 } |
| 127 | 125 |
| 128 void synchronizeWrappersIfNeeded() | 126 void synchronizeWrappersIfNeeded() |
| 129 { | 127 { |
| 130 // Eventually the wrapper list needs synchronization because any SVGAnim
ateLengthList::calculateAnimatedValue() call may | 128 // Eventually the wrapper list needs synchronization because any SVGAnim
ateLengthList::calculateAnimatedValue() call may |
| 131 // mutate the length of our values() list, and thus the wrapper() cache
needs synchronization, to have the same size. | 129 // mutate the length of our values() list, and thus the wrapper() cache
needs synchronization, to have the same size. |
| 132 // Also existing wrappers which point directly at elements in the existi
ng SVGLengthList have to be detached (so a copy | 130 // Also existing wrappers which point directly at elements in the existi
ng SVGLengthList have to be detached (so a copy |
| 133 // of them is created, so existing animVal variables in JS are kept-aliv
e). If we'd detach them later the underlying | 131 // of them is created, so existing animVal variables in JS are kept-aliv
e). If we'd detach them later the underlying |
| (...skipping 14 matching lines...) Expand all Loading... |
| 148 } | 146 } |
| 149 | 147 |
| 150 void animValDidChange() | 148 void animValDidChange() |
| 151 { | 149 { |
| 152 ASSERT(m_isAnimating); | 150 ASSERT(m_isAnimating); |
| 153 ASSERT(m_animVal); | 151 ASSERT(m_animVal); |
| 154 ASSERT(m_values.size() == m_wrappers.size()); | 152 ASSERT(m_values.size() == m_wrappers.size()); |
| 155 synchronizeWrappersIfNeeded(); | 153 synchronizeWrappersIfNeeded(); |
| 156 } | 154 } |
| 157 | 155 |
| 158 virtual void detachWrappers() OVERRIDE | |
| 159 { | |
| 160 if (m_animVal) { | |
| 161 ListProperty* animVal = static_cast<ListProperty*>(m_animVal.get()); | |
| 162 animVal->detachListWrappers(0); | |
| 163 } | |
| 164 } | |
| 165 | |
| 166 static PassRefPtr<SVGAnimatedListPropertyTearOff<PropertyType> > create(SVGE
lement* contextElement, const QualifiedName& attributeName, AnimatedPropertyType
animatedPropertyType, PropertyType& values) | 156 static PassRefPtr<SVGAnimatedListPropertyTearOff<PropertyType> > create(SVGE
lement* contextElement, const QualifiedName& attributeName, AnimatedPropertyType
animatedPropertyType, PropertyType& values) |
| 167 { | 157 { |
| 168 ASSERT(contextElement); | 158 ASSERT(contextElement); |
| 169 return adoptRef(new SVGAnimatedListPropertyTearOff<PropertyType>(context
Element, attributeName, animatedPropertyType, values)); | 159 return adoptRef(new SVGAnimatedListPropertyTearOff<PropertyType>(context
Element, attributeName, animatedPropertyType, values)); |
| 170 } | 160 } |
| 171 | 161 |
| 172 protected: | 162 protected: |
| 173 SVGAnimatedListPropertyTearOff(SVGElement* contextElement, const QualifiedNa
me& attributeName, AnimatedPropertyType animatedPropertyType, PropertyType& valu
es) | 163 SVGAnimatedListPropertyTearOff(SVGElement* contextElement, const QualifiedNa
me& attributeName, AnimatedPropertyType animatedPropertyType, PropertyType& valu
es) |
| 174 : SVGAnimatedProperty(contextElement, attributeName, animatedPropertyTyp
e) | 164 : SVGAnimatedProperty(contextElement, attributeName, animatedPropertyTyp
e) |
| 175 , m_values(values) | 165 , m_values(values) |
| 176 { | 166 { |
| 177 if (!values.isEmpty()) | 167 if (!values.isEmpty()) |
| 178 m_wrappers.fill(0, values.size()); | 168 m_wrappers.fill(0, values.size()); |
| 179 } | 169 } |
| 180 | 170 |
| 181 ~SVGAnimatedListPropertyTearOff() | |
| 182 { | |
| 183 if (m_baseVal) | |
| 184 static_cast<ListPropertyTearOff*>(m_baseVal.get())->clearAnimatedPro
perty(); | |
| 185 if (m_animVal) | |
| 186 static_cast<ListPropertyTearOff*>(m_animVal.get())->clearAnimatedPro
perty(); | |
| 187 } | |
| 188 | |
| 189 PropertyType& m_values; | 171 PropertyType& m_values; |
| 190 | 172 |
| 191 ListWrapperCache m_wrappers; | 173 ListWrapperCache m_wrappers; |
| 192 ListWrapperCache m_animatedWrappers; | 174 ListWrapperCache m_animatedWrappers; |
| 193 | 175 |
| 194 RefPtr<SVGProperty> m_baseVal; | 176 RefPtr<SVGProperty> m_baseVal; |
| 195 RefPtr<SVGProperty> m_animVal; | 177 RefPtr<SVGProperty> m_animVal; |
| 196 }; | 178 }; |
| 197 | 179 |
| 198 } | 180 } |
| 199 | 181 |
| 200 #endif // SVGAnimatedListPropertyTearOff_h | 182 #endif // SVGAnimatedListPropertyTearOff_h |
| OLD | NEW |