Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(221)

Side by Side Diff: third_party/WebKit/Source/core/animation/LengthInterpolationFunctions.cpp

Issue 2370783003: Avoid SVG viewport bug for CSS length animations that don't use viewport units (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/WebKit/LayoutTests/svg/animations/img-tag-css-length-animation-crash.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/animation/LengthInterpolationFunctions.h" 5 #include "core/animation/LengthInterpolationFunctions.h"
6 6
7 #include "core/css/CSSPrimitiveValue.h" 7 #include "core/css/CSSPrimitiveValue.h"
8 #include "core/css/CSSToLengthConversionData.h" 8 #include "core/css/CSSToLengthConversionData.h"
9 #include "platform/CalculationValue.h" 9 #include "platform/CalculationValue.h"
10 10
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 } 142 }
143 143
144 Length LengthInterpolationFunctions::createLength(const InterpolableValue& inter polableValue, const NonInterpolableValue* nonInterpolableValue, const CSSToLengt hConversionData& conversionData, ValueRange range) 144 Length LengthInterpolationFunctions::createLength(const InterpolableValue& inter polableValue, const NonInterpolableValue* nonInterpolableValue, const CSSToLengt hConversionData& conversionData, ValueRange range)
145 { 145 {
146 const InterpolableList& interpolableList = toInterpolableList(interpolableVa lue); 146 const InterpolableList& interpolableList = toInterpolableList(interpolableVa lue);
147 bool hasPercentage = CSSLengthNonInterpolableValue::hasPercentage(nonInterpo lableValue); 147 bool hasPercentage = CSSLengthNonInterpolableValue::hasPercentage(nonInterpo lableValue);
148 double pixels = 0; 148 double pixels = 0;
149 double percentage = 0; 149 double percentage = 0;
150 for (size_t i = 0; i < CSSPrimitiveValue::LengthUnitTypeCount; i++) { 150 for (size_t i = 0; i < CSSPrimitiveValue::LengthUnitTypeCount; i++) {
151 double value = toInterpolableNumber(*interpolableList.get(i)).value(); 151 double value = toInterpolableNumber(*interpolableList.get(i)).value();
152 if (value == 0)
153 continue;
152 if (i == CSSPrimitiveValue::UnitTypePercentage) { 154 if (i == CSSPrimitiveValue::UnitTypePercentage) {
153 percentage = value; 155 percentage = value;
154 } else { 156 } else {
155 CSSPrimitiveValue::UnitType type = CSSPrimitiveValue::lengthUnitType ToUnitType(static_cast<CSSPrimitiveValue::LengthUnitType>(i)); 157 CSSPrimitiveValue::UnitType type = CSSPrimitiveValue::lengthUnitType ToUnitType(static_cast<CSSPrimitiveValue::LengthUnitType>(i));
156 pixels += conversionData.zoomedComputedPixels(value, type); 158 pixels += conversionData.zoomedComputedPixels(value, type);
157 } 159 }
158 } 160 }
159 161
160 if (percentage != 0) 162 if (percentage != 0)
161 hasPercentage = true; 163 hasPercentage = true;
162 if (pixels != 0 && hasPercentage) 164 if (pixels != 0 && hasPercentage)
163 return Length(CalculationValue::create(PixelsAndPercent(pixels, percenta ge), range)); 165 return Length(CalculationValue::create(PixelsAndPercent(pixels, percenta ge), range));
164 if (hasPercentage) 166 if (hasPercentage)
165 return Length(clampToRange(percentage, range), Percent); 167 return Length(clampToRange(percentage, range), Percent);
166 return Length(CSSPrimitiveValue::clampToCSSLengthRange(clampToRange(pixels, range)), Fixed); 168 return Length(CSSPrimitiveValue::clampToCSSLengthRange(clampToRange(pixels, range)), Fixed);
167 } 169 }
168 170
169 } // namespace blink 171 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/svg/animations/img-tag-css-length-animation-crash.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698