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 bool AnimatableLength::equalTo(const AnimatableValue* value) const | 102 bool AnimatableLength::equalTo(const AnimatableValue* value) const |
115 { | 103 { |
116 const AnimatableLength* length = toAnimatableLength(value); | 104 const AnimatableLength* length = toAnimatableLength(value); |
117 if (m_lengthUnitType != length->m_lengthUnitType) | 105 if (m_lengthUnitType != length->m_lengthUnitType) |
118 return false; | 106 return false; |
119 if (isCalc()) | 107 if (isCalc()) |
120 return m_calcExpression == length->m_calcExpression || m_calcExpression-
>equals(*length->m_calcExpression); | 108 return m_calcExpression == length->m_calcExpression || m_calcExpression-
>equals(*length->m_calcExpression); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 return AnimatableLength::create(m_lengthValue * factor, m_lengthUnitType); | 148 return AnimatableLength::create(m_lengthValue * factor, m_lengthUnitType); |
161 } | 149 } |
162 | 150 |
163 void AnimatableLength::trace(Visitor* visitor) | 151 void AnimatableLength::trace(Visitor* visitor) |
164 { | 152 { |
165 visitor->trace(m_calcExpression); | 153 visitor->trace(m_calcExpression); |
166 visitor->trace(m_cachedCSSPrimitiveValue); | 154 visitor->trace(m_cachedCSSPrimitiveValue); |
167 } | 155 } |
168 | 156 |
169 } // namespace WebCore | 157 } // namespace WebCore |
OLD | NEW |