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

Side by Side 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 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 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 case CSSPropertyWebkitMaskSize: 201 case CSSPropertyWebkitMaskSize:
202 fillLayer->clearSize(); 202 fillLayer->clearSize();
203 break; 203 break;
204 default: 204 default:
205 ASSERT_NOT_REACHED(); 205 ASSERT_NOT_REACHED();
206 } 206 }
207 fillLayer = fillLayer->next(); 207 fillLayer = fillLayer->next();
208 } 208 }
209 } 209 }
210 210
211 FontStretch animatableValueToFontStretch(const AnimatableValue* value)
212 {
213 ASSERT(FontStretchUltraCondensed == 1 && FontStretchUltraExpanded == 9);
214 unsigned index = round(toAnimatableDouble(value)->toDouble()) - 1;
215 static const FontStretch stretchValues[] = {
216 FontStretchUltraCondensed,
217 FontStretchExtraCondensed,
218 FontStretchCondensed,
219 FontStretchSemiCondensed,
220 FontStretchNormal,
221 FontStretchSemiExpanded,
222 FontStretchExpanded,
223 FontStretchExtraExpanded,
224 FontStretchUltraExpanded
225 };
226
227 index = clampTo<unsigned>(index, 0, WTF_ARRAY_LENGTH(stretchValues) - 1);
228 return stretchValues[index];
229 }
230
211 FontWeight animatableValueToFontWeight(const AnimatableValue* value) 231 FontWeight animatableValueToFontWeight(const AnimatableValue* value)
212 { 232 {
213 int index = round(toAnimatableDouble(value)->toDouble() / 100) - 1; 233 int index = round(toAnimatableDouble(value)->toDouble() / 100) - 1;
214 234
215 static const FontWeight weights[] = { 235 static const FontWeight weights[] = {
216 FontWeight100, 236 FontWeight100,
217 FontWeight200, 237 FontWeight200,
218 FontWeight300, 238 FontWeight300,
219 FontWeight400, 239 FontWeight400,
220 FontWeight500, 240 FontWeight500,
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 return; 368 return;
349 case CSSPropertyFloodColor: 369 case CSSPropertyFloodColor:
350 style->setFloodColor(toAnimatableColor(value)->color()); 370 style->setFloodColor(toAnimatableColor(value)->color());
351 return; 371 return;
352 case CSSPropertyFloodOpacity: 372 case CSSPropertyFloodOpacity:
353 style->setFloodOpacity(clampTo<float>(toAnimatableDouble(value)->toDoubl e(), 0, 1)); 373 style->setFloodOpacity(clampTo<float>(toAnimatableDouble(value)->toDoubl e(), 0, 1));
354 return; 374 return;
355 case CSSPropertyFontSize: 375 case CSSPropertyFontSize:
356 style->setFontSize(clampTo<float>(toAnimatableDouble(value)->toDouble(), 0)); 376 style->setFontSize(clampTo<float>(toAnimatableDouble(value)->toDouble(), 0));
357 return; 377 return;
378 case CSSPropertyFontStretch:
379 style->setFontStretch(animatableValueToFontStretch(value));
380 return;
358 case CSSPropertyFontWeight: 381 case CSSPropertyFontWeight:
359 style->setFontWeight(animatableValueToFontWeight(value)); 382 style->setFontWeight(animatableValueToFontWeight(value));
360 return; 383 return;
361 case CSSPropertyHeight: 384 case CSSPropertyHeight:
362 style->setHeight(animatableValueToLength(value, state, ValueRangeNonNega tive)); 385 style->setHeight(animatableValueToLength(value, state, ValueRangeNonNega tive));
363 return; 386 return;
364 case CSSPropertyLeft: 387 case CSSPropertyLeft:
365 style->setLeft(animatableValueToLength(value, state)); 388 style->setLeft(animatableValueToLength(value, state));
366 return; 389 return;
367 case CSSPropertyLightingColor: 390 case CSSPropertyLightingColor:
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
590 return; 613 return;
591 case CSSPropertyZoom: 614 case CSSPropertyZoom:
592 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()));
593 return; 616 return;
594 default: 617 default:
595 ASSERT_NOT_REACHED(); 618 ASSERT_NOT_REACHED();
596 } 619 }
597 } 620 }
598 621
599 } // namespace blink 622 } // namespace blink
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