| 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 | 61 |
| 62 namespace WebCore { | 62 namespace WebCore { |
| 63 | 63 |
| 64 static PassRefPtr<AnimatableValue> createFromLength(const Length& length, const
RenderStyle& style) | 64 static PassRefPtr<AnimatableValue> createFromLength(const Length& length, const
RenderStyle& style) |
| 65 { | 65 { |
| 66 switch (length.type()) { | 66 switch (length.type()) { |
| 67 case Fixed: | 67 case Fixed: |
| 68 return AnimatableLength::create(adjustFloatForAbsoluteZoom(length.value(
), style), AnimatableLength::UnitTypePixels); | 68 return AnimatableLength::create(adjustFloatForAbsoluteZoom(length.value(
), style), AnimatableLength::UnitTypePixels); |
| 69 case Percent: | 69 case Percent: |
| 70 return AnimatableLength::create(length.value(), AnimatableLength::UnitTy
pePercentage); | 70 return AnimatableLength::create(length.value(), AnimatableLength::UnitTy
pePercentage); |
| 71 case ViewportPercentageWidth: | |
| 72 return AnimatableLength::create(length.value(), AnimatableLength::UnitTy
peViewportWidth); | |
| 73 case ViewportPercentageHeight: | |
| 74 return AnimatableLength::create(length.value(), AnimatableLength::UnitTy
peViewportHeight); | |
| 75 case ViewportPercentageMin: | |
| 76 return AnimatableLength::create(length.value(), AnimatableLength::UnitTy
peViewportMin); | |
| 77 case ViewportPercentageMax: | |
| 78 return AnimatableLength::create(length.value(), AnimatableLength::UnitTy
peViewportMax); | |
| 79 case Calculated: | 71 case Calculated: |
| 80 return AnimatableLength::create(CSSCalcValue::createExpressionNode(lengt
h.calculationValue()->expression(), style.effectiveZoom())); | 72 return AnimatableLength::create(CSSCalcValue::createExpressionNode(lengt
h.calculationValue()->expression(), style.effectiveZoom())); |
| 81 case Auto: | 73 case Auto: |
| 82 case Intrinsic: | 74 case Intrinsic: |
| 83 case MinIntrinsic: | 75 case MinIntrinsic: |
| 84 case MinContent: | 76 case MinContent: |
| 85 case MaxContent: | 77 case MaxContent: |
| 86 case FillAvailable: | 78 case FillAvailable: |
| 87 case FitContent: | 79 case FitContent: |
| 80 // FIXME: Support for viewport units needs to be improved before we can anim
ate them as CSS values. |
| 81 case ViewportPercentageWidth: |
| 82 case ViewportPercentageHeight: |
| 83 case ViewportPercentageMin: |
| 84 case ViewportPercentageMax: |
| 88 return AnimatableUnknown::create(CSSPrimitiveValue::create(length)); | 85 return AnimatableUnknown::create(CSSPrimitiveValue::create(length)); |
| 89 case Undefined: | 86 case Undefined: |
| 90 return AnimatableUnknown::create(CSSValueNone); | 87 return AnimatableUnknown::create(CSSValueNone); |
| 91 case ExtendToZoom: // Does not apply to elements. | 88 case ExtendToZoom: // Does not apply to elements. |
| 92 ASSERT_NOT_REACHED(); | 89 ASSERT_NOT_REACHED(); |
| 93 return 0; | 90 return 0; |
| 94 } | 91 } |
| 95 ASSERT_NOT_REACHED(); | 92 ASSERT_NOT_REACHED(); |
| 96 return 0; | 93 return 0; |
| 97 } | 94 } |
| 98 | 95 |
| 99 static PassRefPtr<AnimatableValue> createFromLineHeight(const Length& length, co
nst RenderStyle& style) | 96 static PassRefPtr<AnimatableValue> createFromLineHeight(const Length& length, co
nst RenderStyle& style) |
| 100 { | 97 { |
| 101 double value = length.value(); | 98 if (length.type() == Percent) { |
| 102 switch (length.type()) { | 99 double value = length.value(); |
| 103 case Fixed: | |
| 104 return AnimatableLength::create(adjustFloatForAbsoluteZoom(value, style)
, AnimatableLength::UnitTypePixels); | |
| 105 case Percent: | |
| 106 // -100% is used to represent "normal" line height. | 100 // -100% is used to represent "normal" line height. |
| 107 if (value == -100) | 101 if (value == -100) |
| 108 return AnimatableUnknown::create(CSSValueNormal); | 102 return AnimatableUnknown::create(CSSValueNormal); |
| 109 return AnimatableDouble::create(value); | 103 return AnimatableDouble::create(value); |
| 110 default: | |
| 111 ASSERT_NOT_REACHED(); | |
| 112 return 0; | |
| 113 } | 104 } |
| 105 return createFromLength(length, style); |
| 114 } | 106 } |
| 115 | 107 |
| 116 inline static PassRefPtr<AnimatableValue> createFromDouble(double value, Animata
bleDouble::Constraint constraint = AnimatableDouble::Unconstrained) | 108 inline static PassRefPtr<AnimatableValue> createFromDouble(double value, Animata
bleDouble::Constraint constraint = AnimatableDouble::Unconstrained) |
| 117 { | 109 { |
| 118 return AnimatableDouble::create(value, constraint); | 110 return AnimatableDouble::create(value, constraint); |
| 119 } | 111 } |
| 120 | 112 |
| 121 inline static PassRefPtr<AnimatableValue> createFromLengthBox(const LengthBox& l
engthBox, const RenderStyle& style) | 113 inline static PassRefPtr<AnimatableValue> createFromLengthBox(const LengthBox& l
engthBox, const RenderStyle& style) |
| 122 { | 114 { |
| 123 return AnimatableLengthBox::create( | 115 return AnimatableLengthBox::create( |
| (...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 478 return createFromDouble(style.zoom()); | 470 return createFromDouble(style.zoom()); |
| 479 default: | 471 default: |
| 480 ASSERT_WITH_MESSAGE(!CSSAnimations::isAnimatableProperty(property), "Web
Animations not yet implemented: Create AnimatableValue from render style: %s",
getPropertyNameString(property).utf8().data()); | 472 ASSERT_WITH_MESSAGE(!CSSAnimations::isAnimatableProperty(property), "Web
Animations not yet implemented: Create AnimatableValue from render style: %s",
getPropertyNameString(property).utf8().data()); |
| 481 ASSERT_NOT_REACHED(); | 473 ASSERT_NOT_REACHED(); |
| 482 // This return value is to avoid a release crash if possible. | 474 // This return value is to avoid a release crash if possible. |
| 483 return AnimatableUnknown::create(0); | 475 return AnimatableUnknown::create(0); |
| 484 } | 476 } |
| 485 } | 477 } |
| 486 | 478 |
| 487 } // namespace WebCore | 479 } // namespace WebCore |
| OLD | NEW |