| 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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 { | 83 { |
| 84 // Avoid creating a CSSValue in the common cases | 84 // Avoid creating a CSSValue in the common cases |
| 85 if (m_lengthUnitType == CSSPrimitiveValue::UnitTypePixels) | 85 if (m_lengthUnitType == CSSPrimitiveValue::UnitTypePixels) |
| 86 return Length(clampedNumber(range) * conversionData.zoom(), Fixed); | 86 return Length(clampedNumber(range) * conversionData.zoom(), Fixed); |
| 87 if (m_lengthUnitType == CSSPrimitiveValue::UnitTypePercentage) | 87 if (m_lengthUnitType == CSSPrimitiveValue::UnitTypePercentage) |
| 88 return Length(clampedNumber(range), Percent); | 88 return Length(clampedNumber(range), Percent); |
| 89 | 89 |
| 90 return toCSSPrimitiveValue(range)->convertToLength<AnyConversion>(conversion
Data); | 90 return toCSSPrimitiveValue(range)->convertToLength<AnyConversion>(conversion
Data); |
| 91 } | 91 } |
| 92 | 92 |
| 93 bool AnimatableLength::usesDefaultInterpolationWith(const AnimatableValue* value
) const | |
| 94 { | |
| 95 const AnimatableLength* length = toAnimatableLength(value); | |
| 96 CSSPrimitiveValue::LengthUnitType type = commonUnitType(length); | |
| 97 return isCalc(type) && (isViewportUnit() || length->isViewportUnit()); | |
| 98 } | |
| 99 | |
| 100 PassRefPtrWillBeRawPtr<AnimatableValue> AnimatableLength::interpolateTo(const An
imatableValue* value, double fraction) const | 93 PassRefPtrWillBeRawPtr<AnimatableValue> AnimatableLength::interpolateTo(const An
imatableValue* value, double fraction) const |
| 101 { | 94 { |
| 102 const AnimatableLength* length = toAnimatableLength(value); | 95 const AnimatableLength* length = toAnimatableLength(value); |
| 103 CSSPrimitiveValue::LengthUnitType type = commonUnitType(length); | 96 CSSPrimitiveValue::LengthUnitType type = commonUnitType(length); |
| 104 if (!isCalc(type)) | 97 if (!isCalc(type)) |
| 105 return AnimatableLength::create(blend(m_lengthValue, length->m_lengthVal
ue, fraction), type); | 98 return AnimatableLength::create(blend(m_lengthValue, length->m_lengthVal
ue, fraction), type); |
| 106 | |
| 107 // FIXME(crbug.com/168840): Support for viewport units in calc needs to be a
dded before we can blend them with other units. | |
| 108 if (isViewportUnit() || length->isViewportUnit()) | |
| 109 return defaultInterpolateTo(this, value, fraction); | |
| 110 | |
| 111 return AnimatableLength::create(scale(1 - fraction).get(), length->scale(fra
ction).get()); | 99 return AnimatableLength::create(scale(1 - fraction).get(), length->scale(fra
ction).get()); |
| 112 } | 100 } |
| 113 | 101 |
| 114 PassRefPtrWillBeRawPtr<AnimatableValue> AnimatableLength::addWith(const Animatab
leValue* value) const | 102 PassRefPtrWillBeRawPtr<AnimatableValue> AnimatableLength::addWith(const Animatab
leValue* value) const |
| 115 { | 103 { |
| 116 // Optimization for adding with 0. | 104 // Optimization for adding with 0. |
| 117 if (isUnitlessZero()) | 105 if (isUnitlessZero()) |
| 118 return takeConstRef(value); | 106 return takeConstRef(value); |
| 119 | 107 |
| 120 const AnimatableLength* length = toAnimatableLength(value); | 108 const AnimatableLength* length = toAnimatableLength(value); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 return AnimatableLength::create(m_lengthValue * factor, m_lengthUnitType); | 165 return AnimatableLength::create(m_lengthValue * factor, m_lengthUnitType); |
| 178 } | 166 } |
| 179 | 167 |
| 180 void AnimatableLength::trace(Visitor* visitor) | 168 void AnimatableLength::trace(Visitor* visitor) |
| 181 { | 169 { |
| 182 visitor->trace(m_calcExpression); | 170 visitor->trace(m_calcExpression); |
| 183 visitor->trace(m_cachedCSSPrimitiveValue); | 171 visitor->trace(m_cachedCSSPrimitiveValue); |
| 184 } | 172 } |
| 185 | 173 |
| 186 } // namespace WebCore | 174 } // namespace WebCore |
| OLD | NEW |