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

Side by Side Diff: third_party/WebKit/Source/core/animation/CSSImageSliceInterpolationType.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 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/CSSImageSliceInterpolationType.h" 5 #include "core/animation/CSSImageSliceInterpolationType.h"
6 6
7 #include "core/animation/CSSLengthInterpolationType.h" 7 #include "core/animation/CSSLengthInterpolationType.h"
8 #include "core/animation/ImageSlicePropertyFunctions.h" 8 #include "core/animation/ImageSlicePropertyFunctions.h"
9 #include "core/css/CSSBorderImageSliceValue.h" 9 #include "core/css/CSSBorderImageSliceValue.h"
10 #include "core/css/resolver/StyleResolverState.h" 10 #include "core/css/resolver/StyleResolverState.h"
(...skipping 16 matching lines...) Expand all
27 explicit SliceTypes(const ImageSlice& slice) 27 explicit SliceTypes(const ImageSlice& slice)
28 { 28 {
29 isNumber[SideTop] = slice.slices.top().isFixed(); 29 isNumber[SideTop] = slice.slices.top().isFixed();
30 isNumber[SideRight] = slice.slices.right().isFixed(); 30 isNumber[SideRight] = slice.slices.right().isFixed();
31 isNumber[SideBottom] = slice.slices.bottom().isFixed(); 31 isNumber[SideBottom] = slice.slices.bottom().isFixed();
32 isNumber[SideLeft] = slice.slices.left().isFixed(); 32 isNumber[SideLeft] = slice.slices.left().isFixed();
33 fill = slice.fill; 33 fill = slice.fill;
34 } 34 }
35 explicit SliceTypes(const CSSBorderImageSliceValue& slice) 35 explicit SliceTypes(const CSSBorderImageSliceValue& slice)
36 { 36 {
37 isNumber[SideTop] = slice.slices().top()->isNumber(); 37 isNumber[SideTop] = slice.slices().top()->isPrimitiveValue() && toCSSPri mitiveValue(slice.slices().top())->isNumber();
38 isNumber[SideRight] = slice.slices().right()->isNumber(); 38 isNumber[SideRight] = slice.slices().right()->isPrimitiveValue() && toCS SPrimitiveValue(slice.slices().right())->isNumber();
39 isNumber[SideBottom] = slice.slices().bottom()->isNumber(); 39 isNumber[SideBottom] = slice.slices().bottom()->isPrimitiveValue() && to CSSPrimitiveValue(slice.slices().bottom())->isNumber();
40 isNumber[SideLeft] = slice.slices().left()->isNumber(); 40 isNumber[SideLeft] = slice.slices().left()->isPrimitiveValue() && toCSSP rimitiveValue(slice.slices().left())->isNumber();
41 fill = slice.fill(); 41 fill = slice.fill();
42 } 42 }
43 43
44 bool operator==(const SliceTypes& other) const 44 bool operator==(const SliceTypes& other) const
45 { 45 {
46 for (size_t i = 0; i < SideIndexCount; i++) { 46 for (size_t i = 0; i < SideIndexCount; i++) {
47 if (isNumber[i] != other.isNumber[i]) 47 if (isNumber[i] != other.isNumber[i])
48 return false; 48 return false;
49 } 49 }
50 return fill == other.fill; 50 return fill == other.fill;
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 return convertImageSlice(inheritedImageSlice, state.parentStyle()->effective Zoom()); 172 return convertImageSlice(inheritedImageSlice, state.parentStyle()->effective Zoom());
173 } 173 }
174 174
175 InterpolationValue CSSImageSliceInterpolationType::maybeConvertValue(const CSSVa lue& value, const StyleResolverState&, ConversionCheckers&) const 175 InterpolationValue CSSImageSliceInterpolationType::maybeConvertValue(const CSSVa lue& value, const StyleResolverState&, ConversionCheckers&) const
176 { 176 {
177 if (!value.isBorderImageSliceValue()) 177 if (!value.isBorderImageSliceValue())
178 return nullptr; 178 return nullptr;
179 179
180 const CSSBorderImageSliceValue& slice = toCSSBorderImageSliceValue(value); 180 const CSSBorderImageSliceValue& slice = toCSSBorderImageSliceValue(value);
181 std::unique_ptr<InterpolableList> list = InterpolableList::create(SideIndexC ount); 181 std::unique_ptr<InterpolableList> list = InterpolableList::create(SideIndexC ount);
182 const CSSPrimitiveValue* sides[SideIndexCount]; 182 const CSSValue* sides[SideIndexCount];
183 sides[SideTop] = slice.slices().top(); 183 sides[SideTop] = slice.slices().top();
184 sides[SideRight] = slice.slices().right(); 184 sides[SideRight] = slice.slices().right();
185 sides[SideBottom] = slice.slices().bottom(); 185 sides[SideBottom] = slice.slices().bottom();
186 sides[SideLeft] = slice.slices().left(); 186 sides[SideLeft] = slice.slices().left();
187 187
188 for (size_t i = 0; i < SideIndexCount; i++) { 188 for (size_t i = 0; i < SideIndexCount; i++) {
189 const CSSPrimitiveValue& side = *sides[i]; 189 const CSSPrimitiveValue& side = *toCSSPrimitiveValue(sides[i]);
190 DCHECK(side.isNumber() || side.isPercentage()); 190 DCHECK(side.isNumber() || side.isPercentage());
191 list->set(i, InterpolableNumber::create(side.getDoubleValue())); 191 list->set(i, InterpolableNumber::create(side.getDoubleValue()));
192 } 192 }
193 193
194 return InterpolationValue(std::move(list), CSSImageSliceNonInterpolableValue ::create(SliceTypes(slice))); 194 return InterpolationValue(std::move(list), CSSImageSliceNonInterpolableValue ::create(SliceTypes(slice)));
195 } 195 }
196 196
197 InterpolationValue CSSImageSliceInterpolationType::maybeConvertUnderlyingValue(c onst InterpolationEnvironment& environment) const 197 InterpolationValue CSSImageSliceInterpolationType::maybeConvertUnderlyingValue(c onst InterpolationEnvironment& environment) const
198 { 198 {
199 const ComputedStyle& style = *environment.state().style(); 199 const ComputedStyle& style = *environment.state().style();
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 }; 234 };
235 LengthBox box( 235 LengthBox box(
236 convertSide(SideTop), 236 convertSide(SideTop),
237 convertSide(SideRight), 237 convertSide(SideRight),
238 convertSide(SideBottom), 238 convertSide(SideBottom),
239 convertSide(SideLeft)); 239 convertSide(SideLeft));
240 ImageSlicePropertyFunctions::setImageSlice(cssProperty(), style, ImageSlice( box, types.fill)); 240 ImageSlicePropertyFunctions::setImageSlice(cssProperty(), style, ImageSlice( box, types.fill));
241 } 241 }
242 242
243 } // namespace blink 243 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698