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

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

Issue 2346193002: Split CSSPrimitiveValue into CSSPrimitiveValue and CSSIdentifierValue (Closed)
Patch Set: Rebase please work 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/CSSLengthInterpolationType.h" 5 #include "core/animation/CSSLengthInterpolationType.h"
6 6
7 #include "core/animation/LengthInterpolationFunctions.h" 7 #include "core/animation/LengthInterpolationFunctions.h"
8 #include "core/animation/LengthPropertyFunctions.h" 8 #include "core/animation/LengthPropertyFunctions.h"
9 #include "core/animation/css/CSSAnimatableValueFactory.h" 9 #include "core/animation/css/CSSAnimatableValueFactory.h"
10 #include "core/css/CSSCalculationValue.h" 10 #include "core/css/CSSCalculationValue.h"
11 #include "core/css/CSSIdentifierValue.h"
11 #include "core/css/resolver/StyleBuilder.h" 12 #include "core/css/resolver/StyleBuilder.h"
12 #include "core/css/resolver/StyleResolverState.h" 13 #include "core/css/resolver/StyleResolverState.h"
13 #include "platform/LengthFunctions.h" 14 #include "platform/LengthFunctions.h"
14 #include "wtf/PtrUtil.h" 15 #include "wtf/PtrUtil.h"
15 #include <memory> 16 #include <memory>
16 17
17 namespace blink { 18 namespace blink {
18 19
19 CSSLengthInterpolationType::CSSLengthInterpolationType(PropertyHandle property) 20 CSSLengthInterpolationType::CSSLengthInterpolationType(PropertyHandle property)
20 : CSSInterpolationType(property) 21 : CSSInterpolationType(property)
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 return nullptr; 71 return nullptr;
71 Length inheritedLength; 72 Length inheritedLength;
72 if (!LengthPropertyFunctions::getLength(cssProperty(), *state.parentStyle(), inheritedLength)) 73 if (!LengthPropertyFunctions::getLength(cssProperty(), *state.parentStyle(), inheritedLength))
73 return nullptr; 74 return nullptr;
74 conversionCheckers.append(ParentLengthChecker::create(cssProperty(), inherit edLength)); 75 conversionCheckers.append(ParentLengthChecker::create(cssProperty(), inherit edLength));
75 return LengthInterpolationFunctions::maybeConvertLength(inheritedLength, eff ectiveZoom(*state.parentStyle())); 76 return LengthInterpolationFunctions::maybeConvertLength(inheritedLength, eff ectiveZoom(*state.parentStyle()));
76 } 77 }
77 78
78 InterpolationValue CSSLengthInterpolationType::maybeConvertValue(const CSSValue& value, const StyleResolverState&, ConversionCheckers& conversionCheckers) const 79 InterpolationValue CSSLengthInterpolationType::maybeConvertValue(const CSSValue& value, const StyleResolverState&, ConversionCheckers& conversionCheckers) const
79 { 80 {
80 if (value.isPrimitiveValue() && toCSSPrimitiveValue(value).isValueID()) { 81 if (value.isIdentifierValue()) {
81 CSSValueID valueID = toCSSPrimitiveValue(value).getValueID(); 82 CSSValueID valueID = toCSSIdentifierValue(value).getValueID();
82 double pixels; 83 double pixels;
83 if (!LengthPropertyFunctions::getPixelsForKeyword(cssProperty(), valueID , pixels)) 84 if (!LengthPropertyFunctions::getPixelsForKeyword(cssProperty(), valueID , pixels))
84 return nullptr; 85 return nullptr;
85 return InterpolationValue(LengthInterpolationFunctions::createInterpolab lePixels(pixels)); 86 return InterpolationValue(LengthInterpolationFunctions::createInterpolab lePixels(pixels));
86 } 87 }
87 88
88 return LengthInterpolationFunctions::maybeConvertCSSValue(value); 89 return LengthInterpolationFunctions::maybeConvertCSSValue(value);
89 } 90 }
90 91
91 PairwiseInterpolationValue CSSLengthInterpolationType::maybeMergeSingles(Interpo lationValue&& start, InterpolationValue&& end) const 92 PairwiseInterpolationValue CSSLengthInterpolationType::maybeMergeSingles(Interpo lationValue&& start, InterpolationValue&& end) const
(...skipping 22 matching lines...) Expand all
114 ComputedStyle& style = *state.style(); 115 ComputedStyle& style = *state.style();
115 float zoom = effectiveZoom(style); 116 float zoom = effectiveZoom(style);
116 Length length = LengthInterpolationFunctions::createLength(interpolableValue , nonInterpolableValue, state.cssToLengthConversionData(), m_valueRange); 117 Length length = LengthInterpolationFunctions::createLength(interpolableValue , nonInterpolableValue, state.cssToLengthConversionData(), m_valueRange);
117 if (LengthPropertyFunctions::setLength(cssProperty(), style, length)) { 118 if (LengthPropertyFunctions::setLength(cssProperty(), style, length)) {
118 #if DCHECK_IS_ON() 119 #if DCHECK_IS_ON()
119 // Assert that setting the length on ComputedStyle directly is identical to the StyleBuilder code path. 120 // Assert that setting the length on ComputedStyle directly is identical to the StyleBuilder code path.
120 // This check is useful for catching differences in clamping behaviour. 121 // This check is useful for catching differences in clamping behaviour.
121 Length before; 122 Length before;
122 Length after; 123 Length after;
123 DCHECK(LengthPropertyFunctions::getLength(cssProperty(), style, before)) ; 124 DCHECK(LengthPropertyFunctions::getLength(cssProperty(), style, before)) ;
124 StyleBuilder::applyProperty(cssProperty(), state, *CSSPrimitiveValue::cr eate(length, zoom)); 125 StyleBuilder::applyProperty(cssProperty(), state, *CSSValue::create(leng th, zoom));
125 DCHECK(LengthPropertyFunctions::getLength(cssProperty(), style, after)); 126 DCHECK(LengthPropertyFunctions::getLength(cssProperty(), style, after));
126 DCHECK_EQ(before.type(), after.type()); 127 DCHECK_EQ(before.type(), after.type());
127 if (before.isSpecified()) { 128 if (before.isSpecified()) {
128 const float kSlack = 0.1; 129 const float kSlack = 0.1;
129 float delta = floatValueForLength(after, 100) - floatValueForLength( before, 100); 130 float delta = floatValueForLength(after, 100) - floatValueForLength( before, 100);
130 DCHECK_LT(std::abs(delta), kSlack); 131 DCHECK_LT(std::abs(delta), kSlack);
131 } 132 }
132 #endif 133 #endif
133 return; 134 return;
134 } 135 }
135 StyleBuilder::applyProperty(cssProperty(), state, *CSSPrimitiveValue::create (length, zoom)); 136 StyleBuilder::applyProperty(cssProperty(), state, *CSSValue::create(length, zoom));
136 } 137 }
137 138
138 } // namespace blink 139 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698