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

Unified Diff: Source/core/animation/css/CSSAnimatableValueFactory.cpp

Issue 173953002: Make font-weight animatable. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Use clampTo<int>. 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 side-by-side diff with in-line comments
Download patch
Index: Source/core/animation/css/CSSAnimatableValueFactory.cpp
diff --git a/Source/core/animation/css/CSSAnimatableValueFactory.cpp b/Source/core/animation/css/CSSAnimatableValueFactory.cpp
index b3113f113c8a7a3d01dd86effaea2c22891f6716..6068a1b6c67bb4403473531221b8a99b46df7c40 100644
--- a/Source/core/animation/css/CSSAnimatableValueFactory.cpp
+++ b/Source/core/animation/css/CSSAnimatableValueFactory.cpp
@@ -230,6 +230,38 @@ inline static PassRefPtr<AnimatableValue> createFromShapeValue(ShapeValue* value
return AnimatableUnknown::create(CSSValueAuto);
}
+static double fontWeightToDouble(FontWeight fontWeight)
+{
+ switch (fontWeight) {
+ case FontWeight100:
+ return 100;
+ case FontWeight200:
+ return 200;
+ case FontWeight300:
+ return 300;
+ case FontWeight400:
+ return 400;
+ case FontWeight500:
+ return 500;
+ case FontWeight600:
+ return 600;
+ case FontWeight700:
+ return 700;
+ case FontWeight800:
+ return 800;
+ case FontWeight900:
+ return 900;
+ }
+
+ ASSERT_NOT_REACHED();
+ return 400;
+}
+
+static PassRefPtr<AnimatableValue> createFromFontWeight(FontWeight fontWeight)
+{
+ return createFromDouble(fontWeightToDouble(fontWeight));
+}
+
// FIXME: Generate this function.
PassRefPtr<AnimatableValue> CSSAnimatableValueFactory::create(CSSPropertyID property, const RenderStyle& style)
{
@@ -311,6 +343,8 @@ PassRefPtr<AnimatableValue> CSSAnimatableValueFactory::create(CSSPropertyID prop
// FIXME: Should we introduce an option to pass the computed font size here, allowing consumers to
// enable text zoom rather than Text Autosizing? See http://crbug.com/227545.
return createFromDouble(style.specifiedFontSize());
+ case CSSPropertyFontWeight:
+ return createFromFontWeight(style.fontWeight());
case CSSPropertyHeight:
return createFromLength(style.height(), style);
case CSSPropertyKerning:

Powered by Google App Engine
This is Rietveld 408576698