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

Side by Side Diff: Source/core/css/resolver/AnimatedStyleBuilder.cpp

Issue 173953002: Make font-weight animatable. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Remove AnimatableFontWeight class. Created 6 years, 10 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 /* 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 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 case CSSPropertyWebkitMaskSize: 218 case CSSPropertyWebkitMaskSize:
219 fillLayer->clearSize(); 219 fillLayer->clearSize();
220 break; 220 break;
221 default: 221 default:
222 ASSERT_NOT_REACHED(); 222 ASSERT_NOT_REACHED();
223 } 223 }
224 fillLayer = fillLayer->next(); 224 fillLayer = fillLayer->next();
225 } 225 }
226 } 226 }
227 227
228 FontWeight animatableValueToFontWeight(const AnimatableValue* value)
229 {
230 int index = round(toAnimatableDouble(value)->toDouble() / 100) - 1;
231
232 if (index < 0 || index > 8)
alancutter (OOO until 2018) 2014/02/23 23:01:08 Better to use WTF_ARRAY_LENGTH(weights) here inste
233 return FontWeightNormal;
234
235 static const FontWeight weights[9] = {
alancutter (OOO until 2018) 2014/02/23 23:01:08 No need to declare array size.
236 FontWeight100,
237 FontWeight200,
238 FontWeight300,
239 FontWeight400,
240 FontWeight500,
241 FontWeight600,
242 FontWeight700,
243 FontWeight800,
244 FontWeight900
245 };
246
247 return weights[index];
248 }
249
228 } // namespace 250 } // namespace
229 251
230 // FIXME: Generate this function. 252 // FIXME: Generate this function.
231 void AnimatedStyleBuilder::applyProperty(CSSPropertyID property, StyleResolverSt ate& state, const AnimatableValue* value) 253 void AnimatedStyleBuilder::applyProperty(CSSPropertyID property, StyleResolverSt ate& state, const AnimatableValue* value)
232 { 254 {
233 ASSERT(CSSAnimations::isAnimatableProperty(property)); 255 ASSERT(CSSAnimations::isAnimatableProperty(property));
234 if (value->isUnknown()) { 256 if (value->isUnknown()) {
235 StyleBuilder::applyProperty(property, state, toAnimatableUnknown(value)- >toCSSValue().get()); 257 StyleBuilder::applyProperty(property, state, toAnimatableUnknown(value)- >toCSSValue().get());
236 return; 258 return;
237 } 259 }
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 return; 366 return;
345 case CSSPropertyFloodColor: 367 case CSSPropertyFloodColor:
346 style->setFloodColor(toAnimatableColor(value)->color()); 368 style->setFloodColor(toAnimatableColor(value)->color());
347 return; 369 return;
348 case CSSPropertyFloodOpacity: 370 case CSSPropertyFloodOpacity:
349 style->setFloodOpacity(clampTo<float>(toAnimatableDouble(value)->toDoubl e(), 0, 1)); 371 style->setFloodOpacity(clampTo<float>(toAnimatableDouble(value)->toDoubl e(), 0, 1));
350 return; 372 return;
351 case CSSPropertyFontSize: 373 case CSSPropertyFontSize:
352 style->setFontSize(clampTo<float>(toAnimatableDouble(value)->toDouble(), 0)); 374 style->setFontSize(clampTo<float>(toAnimatableDouble(value)->toDouble(), 0));
353 return; 375 return;
376 case CSSPropertyFontWeight:
377 style->setFontWeight(animatableValueToFontWeight(value));
378 return;
354 case CSSPropertyHeight: 379 case CSSPropertyHeight:
355 style->setHeight(animatableValueToLength(value, state, NonNegativeValues )); 380 style->setHeight(animatableValueToLength(value, state, NonNegativeValues ));
356 return; 381 return;
357 case CSSPropertyKerning: 382 case CSSPropertyKerning:
358 style->setKerning(toAnimatableSVGLength(value)->toSVGLength()); 383 style->setKerning(toAnimatableSVGLength(value)->toSVGLength());
359 return; 384 return;
360 case CSSPropertyLeft: 385 case CSSPropertyLeft:
361 style->setLeft(animatableValueToLength(value, state)); 386 style->setLeft(animatableValueToLength(value, state));
362 return; 387 return;
363 case CSSPropertyLightingColor: 388 case CSSPropertyLightingColor:
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
588 return; 613 return;
589 case CSSPropertyZoom: 614 case CSSPropertyZoom:
590 style->setZoom(clampTo<float>(toAnimatableDouble(value)->toDouble(), std ::numeric_limits<float>::denorm_min())); 615 style->setZoom(clampTo<float>(toAnimatableDouble(value)->toDouble(), std ::numeric_limits<float>::denorm_min()));
591 return; 616 return;
592 default: 617 default:
593 ASSERT_NOT_REACHED(); 618 ASSERT_NOT_REACHED();
594 } 619 }
595 } 620 }
596 621
597 } // namespace WebCore 622 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698