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

Unified 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: Fixed review issues 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
« no previous file with comments | « Source/core/animation/css/CSSPropertyAnimation.cpp ('k') | Source/core/rendering/style/RenderStyle.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/css/resolver/AnimatedStyleBuilder.cpp
diff --git a/Source/core/css/resolver/AnimatedStyleBuilder.cpp b/Source/core/css/resolver/AnimatedStyleBuilder.cpp
index c19384955f6f3ca4fb3c1ddd50b694c3fdb5f145..1c4263f0ec79ec1c71c385cbe23b86ceb9d32e11 100644
--- a/Source/core/css/resolver/AnimatedStyleBuilder.cpp
+++ b/Source/core/css/resolver/AnimatedStyleBuilder.cpp
@@ -225,6 +225,27 @@ void setOnFillLayers(FillLayer* fillLayer, const AnimatableValue* value, StyleRe
}
}
+FontWeight animatableValueToFontWeight(const AnimatableValue* value)
+{
+ int index = round(toAnimatableDouble(value)->toDouble() / 100) - 1;
+
+ static const FontWeight weights[] = {
+ FontWeight100,
+ FontWeight200,
+ FontWeight300,
+ FontWeight400,
+ FontWeight500,
+ FontWeight600,
+ FontWeight700,
+ FontWeight800,
+ FontWeight900
+ };
+
+ index = std::min(std::max(index, 0), static_cast<int>(WTF_ARRAY_LENGTH(weights)) - 1);
alancutter (OOO until 2018) 2014/02/24 23:01:04 clampTo<int>()
+
+ return weights[index];
+}
+
} // namespace
// FIXME: Generate this function.
@@ -351,6 +372,9 @@ void AnimatedStyleBuilder::applyProperty(CSSPropertyID property, StyleResolverSt
case CSSPropertyFontSize:
style->setFontSize(clampTo<float>(toAnimatableDouble(value)->toDouble(), 0));
return;
+ case CSSPropertyFontWeight:
+ style->setFontWeight(animatableValueToFontWeight(value));
+ return;
case CSSPropertyHeight:
style->setHeight(animatableValueToLength(value, state, NonNegativeValues));
return;
« no previous file with comments | « Source/core/animation/css/CSSPropertyAnimation.cpp ('k') | Source/core/rendering/style/RenderStyle.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698