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

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

Issue 199423003: Add plumbing for font-stretch (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/css/parser/CSSPropertyParser.cpp ('k') | Source/core/css/resolver/FontBuilder.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 FontStretch animatableValueToFontStretch(const AnimatableValue* value)
229 {
230 ASSERT(FontStretchUltraCondensed == 1 && FontStretchUltraExpanded == 9);
231 unsigned index = round(toAnimatableDouble(value)->toDouble()) - 1;
232 static const FontStretch stretchValues[] = {
233 FontStretchUltraCondensed,
234 FontStretchExtraCondensed,
235 FontStretchCondensed,
236 FontStretchSemiCondensed,
237 FontStretchNormal,
238 FontStretchSemiExpanded,
239 FontStretchExpanded,
240 FontStretchExtraExpanded,
241 FontStretchUltraExpanded
242 };
243
244 index = clampTo<unsigned>(index, 0, WTF_ARRAY_LENGTH(stretchValues) - 1);
245 return stretchValues[index];
246 }
247
228 FontWeight animatableValueToFontWeight(const AnimatableValue* value) 248 FontWeight animatableValueToFontWeight(const AnimatableValue* value)
229 { 249 {
230 int index = round(toAnimatableDouble(value)->toDouble() / 100) - 1; 250 int index = round(toAnimatableDouble(value)->toDouble() / 100) - 1;
231 251
232 static const FontWeight weights[] = { 252 static const FontWeight weights[] = {
233 FontWeight100, 253 FontWeight100,
234 FontWeight200, 254 FontWeight200,
235 FontWeight300, 255 FontWeight300,
236 FontWeight400, 256 FontWeight400,
237 FontWeight500, 257 FontWeight500,
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 return; 385 return;
366 case CSSPropertyFloodColor: 386 case CSSPropertyFloodColor:
367 style->setFloodColor(toAnimatableColor(value)->color()); 387 style->setFloodColor(toAnimatableColor(value)->color());
368 return; 388 return;
369 case CSSPropertyFloodOpacity: 389 case CSSPropertyFloodOpacity:
370 style->setFloodOpacity(clampTo<float>(toAnimatableDouble(value)->toDoubl e(), 0, 1)); 390 style->setFloodOpacity(clampTo<float>(toAnimatableDouble(value)->toDoubl e(), 0, 1));
371 return; 391 return;
372 case CSSPropertyFontSize: 392 case CSSPropertyFontSize:
373 style->setFontSize(clampTo<float>(toAnimatableDouble(value)->toDouble(), 0)); 393 style->setFontSize(clampTo<float>(toAnimatableDouble(value)->toDouble(), 0));
374 return; 394 return;
395 case CSSPropertyFontStretch:
396 style->setFontStretch(animatableValueToFontStretch(value));
397 return;
375 case CSSPropertyFontWeight: 398 case CSSPropertyFontWeight:
376 style->setFontWeight(animatableValueToFontWeight(value)); 399 style->setFontWeight(animatableValueToFontWeight(value));
377 return; 400 return;
378 case CSSPropertyHeight: 401 case CSSPropertyHeight:
379 style->setHeight(animatableValueToLength(value, state, NonNegativeValues )); 402 style->setHeight(animatableValueToLength(value, state, NonNegativeValues ));
380 return; 403 return;
381 case CSSPropertyKerning: 404 case CSSPropertyKerning:
382 style->setKerning(toAnimatableSVGLength(value)->toSVGLength()); 405 style->setKerning(toAnimatableSVGLength(value)->toSVGLength());
383 return; 406 return;
384 case CSSPropertyLeft: 407 case CSSPropertyLeft:
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
612 return; 635 return;
613 case CSSPropertyZoom: 636 case CSSPropertyZoom:
614 style->setZoom(clampTo<float>(toAnimatableDouble(value)->toDouble(), std ::numeric_limits<float>::denorm_min())); 637 style->setZoom(clampTo<float>(toAnimatableDouble(value)->toDouble(), std ::numeric_limits<float>::denorm_min()));
615 return; 638 return;
616 default: 639 default:
617 ASSERT_NOT_REACHED(); 640 ASSERT_NOT_REACHED();
618 } 641 }
619 } 642 }
620 643
621 } // namespace WebCore 644 } // namespace WebCore
OLDNEW
« 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