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

Side by Side Diff: Source/core/animation/interpolation/LengthStyleInterpolation.cpp

Issue 273903002: Web Animations API: Length properties responsive to style changes (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase Created 6 years, 7 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "config.h" 5 #include "config.h"
6 #include "core/animation/interpolation/LengthStyleInterpolation.h" 6 #include "core/animation/interpolation/LengthStyleInterpolation.h"
7 7
8 #include "core/css/CSSCalculationValue.h" 8 #include "core/css/CSSCalculationValue.h"
9 #include "core/css/resolver/StyleBuilder.h" 9 #include "core/css/resolver/StyleBuilder.h"
10 10
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 next = CSSCalcValue::createExpressionNode(CSSPrimitiveValue::cre ate(subValue->value(), toUnitType(position))); 59 next = CSSCalcValue::createExpressionNode(CSSPrimitiveValue::cre ate(subValue->value(), toUnitType(position)));
60 return constructCalcExpression(next, list, position + 1); 60 return constructCalcExpression(next, list, position + 1);
61 } 61 }
62 position++; 62 position++;
63 } 63 }
64 return previous; 64 return previous;
65 } 65 }
66 66
67 } 67 }
68 68
69 PassRefPtrWillBeRawPtr<CSSValue> LengthStyleInterpolation::interpolableValueToLe ngth(InterpolableValue* value) 69 PassRefPtrWillBeRawPtr<CSSValue> LengthStyleInterpolation::interpolableValueToLe ngth(InterpolableValue* value, ValueRange range)
70 { 70 {
71 InterpolableList* listValue = toInterpolableList(value); 71 InterpolableList* listValue = toInterpolableList(value);
72 unsigned unitCount = 0; 72 unsigned unitCount = 0;
73 for (size_t i = 0; i < CSSPrimitiveValue::LengthUnitTypeCount; i++) { 73 for (size_t i = 0; i < CSSPrimitiveValue::LengthUnitTypeCount; i++) {
74 const InterpolableNumber* subValue = toInterpolableNumber(listValue->get (i)); 74 const InterpolableNumber* subValue = toInterpolableNumber(listValue->get (i));
75 if (subValue->value()) { 75 if (subValue->value()) {
76 unitCount++; 76 unitCount++;
77 } 77 }
78 } 78 }
79 79
80 switch (unitCount) { 80 switch (unitCount) {
81 case 0: 81 case 0:
82 return CSSPrimitiveValue::create(0, CSSPrimitiveValue::CSS_PX); 82 return CSSPrimitiveValue::create(0, CSSPrimitiveValue::CSS_PX);
83 case 1: 83 case 1:
84 for (size_t i = 0; i < CSSPrimitiveValue::LengthUnitTypeCount; i++) { 84 for (size_t i = 0; i < CSSPrimitiveValue::LengthUnitTypeCount; i++) {
85 const InterpolableNumber* subValue = toInterpolableNumber(listValue- >get(i)); 85 const InterpolableNumber* subValue = toInterpolableNumber(listValue- >get(i));
86 if (subValue->value()) { 86 double value = subValue->value();
87 return CSSPrimitiveValue::create(subValue->value(), toUnitType(i )); 87 if (value) {
88 if (range == ValueRangeNonNegative && value < 0)
89 value = 0;
90 return CSSPrimitiveValue::create(value, toUnitType(i));
88 } 91 }
89 } 92 }
93 ASSERT_NOT_REACHED();
90 default: 94 default:
91 return CSSPrimitiveValue::create(CSSCalcValue::create(constructCalcExpre ssion(nullptr, listValue, 0))); 95 return CSSPrimitiveValue::create(CSSCalcValue::create(constructCalcExpre ssion(nullptr, listValue, 0), range));
92 } 96 }
93 } 97 }
94 98
95 void LengthStyleInterpolation::apply(StyleResolverState& state) const 99 void LengthStyleInterpolation::apply(StyleResolverState& state) const
96 { 100 {
97 StyleBuilder::applyProperty(m_id, state, interpolableValueToLength(m_cachedV alue.get()).get()); 101 StyleBuilder::applyProperty(m_id, state, interpolableValueToLength(m_cachedV alue.get(), m_range).get());
98 } 102 }
99 103
100 void LengthStyleInterpolation::trace(Visitor* visitor) 104 void LengthStyleInterpolation::trace(Visitor* visitor)
101 { 105 {
102 StyleInterpolation::trace(visitor); 106 StyleInterpolation::trace(visitor);
103 } 107 }
104 108
105 } 109 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698