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

Unified Diff: Source/core/css/resolver/AnimatedStyleBuilder.cpp

Issue 203523002: Reland "Add plumbing for font-stretch" (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: w/fix for ASSERT Created 6 years, 5 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/css/parser/CSSPropertyParser.cpp ('k') | Source/core/css/resolver/FontBuilder.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 42f6f2de0b35b235b5954dd85e8841a7d1b6659d..ff6f44735206e37aba162abd1ae8567df48a3b92 100644
--- a/Source/core/css/resolver/AnimatedStyleBuilder.cpp
+++ b/Source/core/css/resolver/AnimatedStyleBuilder.cpp
@@ -208,6 +208,26 @@ void setOnFillLayers(FillLayer& fillLayers, const AnimatableValue* value, StyleR
}
}
+FontStretch animatableValueToFontStretch(const AnimatableValue* value)
+{
+ ASSERT(FontStretchUltraCondensed == 1 && FontStretchUltraExpanded == 9);
+ unsigned index = round(toAnimatableDouble(value)->toDouble()) - 1;
+ static const FontStretch stretchValues[] = {
+ FontStretchUltraCondensed,
+ FontStretchExtraCondensed,
+ FontStretchCondensed,
+ FontStretchSemiCondensed,
+ FontStretchNormal,
+ FontStretchSemiExpanded,
+ FontStretchExpanded,
+ FontStretchExtraExpanded,
+ FontStretchUltraExpanded
+ };
+
+ index = clampTo<unsigned>(index, 0, WTF_ARRAY_LENGTH(stretchValues) - 1);
+ return stretchValues[index];
+}
+
FontWeight animatableValueToFontWeight(const AnimatableValue* value)
{
int index = round(toAnimatableDouble(value)->toDouble() / 100) - 1;
@@ -355,6 +375,9 @@ void AnimatedStyleBuilder::applyProperty(CSSPropertyID property, StyleResolverSt
case CSSPropertyFontSize:
style->setFontSize(clampTo<float>(toAnimatableDouble(value)->toDouble(), 0));
return;
+ case CSSPropertyFontStretch:
+ style->setFontStretch(animatableValueToFontStretch(value));
+ return;
case CSSPropertyFontWeight:
style->setFontWeight(animatableValueToFontWeight(value));
return;
« no previous file with comments | « Source/core/css/parser/CSSPropertyParser.cpp ('k') | Source/core/css/resolver/FontBuilder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698