OLD | NEW |
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 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 return AnimatableColor::create(color, visitedLinkColor); | 223 return AnimatableColor::create(color, visitedLinkColor); |
224 } | 224 } |
225 | 225 |
226 inline static PassRefPtr<AnimatableValue> createFromShapeValue(ShapeValue* value
) | 226 inline static PassRefPtr<AnimatableValue> createFromShapeValue(ShapeValue* value
) |
227 { | 227 { |
228 if (value) | 228 if (value) |
229 return AnimatableShapeValue::create(value); | 229 return AnimatableShapeValue::create(value); |
230 return AnimatableUnknown::create(CSSValueAuto); | 230 return AnimatableUnknown::create(CSSValueAuto); |
231 } | 231 } |
232 | 232 |
| 233 static double fontWeightToDouble(FontWeight fontWeight) |
| 234 { |
| 235 switch (fontWeight) { |
| 236 case FontWeight100: |
| 237 return 100; |
| 238 case FontWeight200: |
| 239 return 200; |
| 240 case FontWeight300: |
| 241 return 300; |
| 242 case FontWeight400: |
| 243 return 400; |
| 244 case FontWeight500: |
| 245 return 500; |
| 246 case FontWeight600: |
| 247 return 600; |
| 248 case FontWeight700: |
| 249 return 700; |
| 250 case FontWeight800: |
| 251 return 800; |
| 252 case FontWeight900: |
| 253 return 900; |
| 254 } |
| 255 |
| 256 ASSERT_NOT_REACHED(); |
| 257 return 400; |
| 258 } |
| 259 |
| 260 static PassRefPtr<AnimatableValue> createFromFontWeight(FontWeight fontWeight) |
| 261 { |
| 262 return createFromDouble(fontWeightToDouble(fontWeight)); |
| 263 } |
| 264 |
233 // FIXME: Generate this function. | 265 // FIXME: Generate this function. |
234 PassRefPtr<AnimatableValue> CSSAnimatableValueFactory::create(CSSPropertyID prop
erty, const RenderStyle& style) | 266 PassRefPtr<AnimatableValue> CSSAnimatableValueFactory::create(CSSPropertyID prop
erty, const RenderStyle& style) |
235 { | 267 { |
236 ASSERT(CSSAnimations::isAnimatableProperty(property)); | 268 ASSERT(CSSAnimations::isAnimatableProperty(property)); |
237 switch (property) { | 269 switch (property) { |
238 case CSSPropertyBackgroundColor: | 270 case CSSPropertyBackgroundColor: |
239 return createFromColor(property, style); | 271 return createFromColor(property, style); |
240 case CSSPropertyBackgroundImage: | 272 case CSSPropertyBackgroundImage: |
241 return createFromFillLayers<CSSPropertyBackgroundImage>(style.background
Layers(), style); | 273 return createFromFillLayers<CSSPropertyBackgroundImage>(style.background
Layers(), style); |
242 case CSSPropertyBackgroundPositionX: | 274 case CSSPropertyBackgroundPositionX: |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 case CSSPropertyFloodColor: | 336 case CSSPropertyFloodColor: |
305 return createFromColor(property, style); | 337 return createFromColor(property, style); |
306 case CSSPropertyFloodOpacity: | 338 case CSSPropertyFloodOpacity: |
307 return createFromDouble(style.floodOpacity()); | 339 return createFromDouble(style.floodOpacity()); |
308 case CSSPropertyFontSize: | 340 case CSSPropertyFontSize: |
309 // Must pass a specified size to setFontSize if Text Autosizing is enabl
ed, but a computed size | 341 // Must pass a specified size to setFontSize if Text Autosizing is enabl
ed, but a computed size |
310 // if text zoom is enabled (if neither is enabled it's irrelevant as the
y're probably the same). | 342 // if text zoom is enabled (if neither is enabled it's irrelevant as the
y're probably the same). |
311 // FIXME: Should we introduce an option to pass the computed font size h
ere, allowing consumers to | 343 // FIXME: Should we introduce an option to pass the computed font size h
ere, allowing consumers to |
312 // enable text zoom rather than Text Autosizing? See http://crbug.com/22
7545. | 344 // enable text zoom rather than Text Autosizing? See http://crbug.com/22
7545. |
313 return createFromDouble(style.specifiedFontSize()); | 345 return createFromDouble(style.specifiedFontSize()); |
| 346 case CSSPropertyFontWeight: |
| 347 return createFromFontWeight(style.fontWeight()); |
314 case CSSPropertyHeight: | 348 case CSSPropertyHeight: |
315 return createFromLength(style.height(), style); | 349 return createFromLength(style.height(), style); |
316 case CSSPropertyKerning: | 350 case CSSPropertyKerning: |
317 return AnimatableSVGLength::create(style.kerning()); | 351 return AnimatableSVGLength::create(style.kerning()); |
318 case CSSPropertyLightingColor: | 352 case CSSPropertyLightingColor: |
319 return createFromColor(property, style); | 353 return createFromColor(property, style); |
320 case CSSPropertyListStyleImage: | 354 case CSSPropertyListStyleImage: |
321 return createFromStyleImage(style.listStyleImage()); | 355 return createFromStyleImage(style.listStyleImage()); |
322 case CSSPropertyLeft: | 356 case CSSPropertyLeft: |
323 return createFromLength(style.left(), style); | 357 return createFromLength(style.left(), style); |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
460 case CSSPropertyZoom: | 494 case CSSPropertyZoom: |
461 return createFromDouble(style.zoom()); | 495 return createFromDouble(style.zoom()); |
462 default: | 496 default: |
463 ASSERT_NOT_REACHED(); | 497 ASSERT_NOT_REACHED(); |
464 // This return value is to avoid a release crash if possible. | 498 // This return value is to avoid a release crash if possible. |
465 return AnimatableUnknown::create(0); | 499 return AnimatableUnknown::create(0); |
466 } | 500 } |
467 } | 501 } |
468 | 502 |
469 } // namespace WebCore | 503 } // namespace WebCore |
OLD | NEW |