 Chromium Code Reviews
 Chromium Code Reviews Issue 19744002:
  Web Animations: Add CSSAnimatableValueFactory API (partial implementation)  (Closed) 
  Base URL: svn://svn.chromium.org/blink/trunk
    
  
    Issue 19744002:
  Web Animations: Add CSSAnimatableValueFactory API (partial implementation)  (Closed) 
  Base URL: svn://svn.chromium.org/blink/trunk| OLD | NEW | 
|---|---|
| (Empty) | |
| 1 /* | |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | |
| 3 * | |
| 4 * Redistribution and use in source and binary forms, with or without | |
| 5 * modification, are permitted provided that the following conditions are | |
| 6 * met: | |
| 7 * | |
| 8 * * Redistributions of source code must retain the above copyright | |
| 9 * notice, this list of conditions and the following disclaimer. | |
| 10 * * Redistributions in binary form must reproduce the above | |
| 11 * copyright notice, this list of conditions and the following disclaimer | |
| 12 * in the documentation and/or other materials provided with the | |
| 13 * distribution. | |
| 14 * * Neither the name of Google Inc. nor the names of its | |
| 15 * contributors may be used to endorse or promote products derived from | |
| 16 * this software without specific prior written permission. | |
| 17 * | |
| 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
| 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
| 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
| 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
| 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
| 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
| 29 */ | |
| 30 | |
| 31 #include "config.h" | |
| 32 #include "core/css/resolver/CSSAnimatableValueFactory.h" | |
| 33 | |
| 34 #include "CSSValueKeywords.h" | |
| 35 #include "core/animation/AnimatableNumber.h" | |
| 36 #include "core/animation/AnimatableUnknown.h" | |
| 37 #include "core/rendering/style/RenderStyle.h" | |
| 38 | |
| 39 | |
| 40 namespace WebCore { | |
| 41 | |
| 42 // FIXME: Handle remaining animatable properties: | |
| 
dstockwell
2013/07/30 03:35:04
Where does this list come from? It should be at le
 
alancutter (OOO until 2018)
2013/07/30 08:31:02
Updated list using CSSPropertyAnimation.
 | |
| 43 // CSSPropertyBackgroundColor | |
| 44 // CSSPropertyBackgroundPosition | |
| 45 // CSSPropertyBorderBottomColor | |
| 46 // CSSPropertyBorderBottomWidth | |
| 47 // CSSPropertyBorderLeftColor | |
| 48 // CSSPropertyBorderLeftWidth | |
| 49 // CSSPropertyBorderRightColor | |
| 50 // CSSPropertyBorderRightWidth | |
| 51 // CSSPropertyBorderSpacing | |
| 52 // CSSPropertyBorderTopColor | |
| 53 // CSSPropertyBorderTopWidth | |
| 54 // CSSPropertyBottom | |
| 55 // CSSPropertyClip | |
| 56 // CSSPropertyColor | |
| 57 // CSSPropertyFontSize | |
| 58 // CSSPropertyFontWeight | |
| 59 // CSSPropertyLetterSpacing | |
| 60 // CSSPropertyLineHeight | |
| 61 // CSSPropertyOpacity | |
| 62 // CSSPropertyOutlineColor | |
| 63 // CSSPropertyOutlineOffset | |
| 64 // CSSPropertyOutlineWidth | |
| 65 // CSSPropertyTextIndent | |
| 66 // CSSPropertyTextShadow | |
| 67 // CSSPropertyVerticalAlign | |
| 68 // CSSPropertyVisibility | |
| 69 // CSSPropertyWebkitTransform | |
| 70 // CSSPropertyWordSpacing | |
| 71 // CSSPropertyZIndex | |
| 72 | |
| 73 PassRefPtr<AnimatableValue> CSSAnimatableValueFactory::createFromCSSValue(CSSVal ue* value, CSSPropertyID property) | |
| 74 { | |
| 75 switch (property) { | |
| 76 case CSSPropertyBottom: | |
| 77 case CSSPropertyHeight: | |
| 78 case CSSPropertyLeft: | |
| 79 case CSSPropertyMarginBottom: | |
| 80 case CSSPropertyMarginLeft: | |
| 81 case CSSPropertyMarginRight: | |
| 82 case CSSPropertyMarginTop: | |
| 83 case CSSPropertyMaxHeight: | |
| 84 case CSSPropertyMaxWidth: | |
| 85 case CSSPropertyMinHeight: | |
| 86 case CSSPropertyMinWidth: | |
| 87 case CSSPropertyPaddingBottom: | |
| 88 case CSSPropertyPaddingLeft: | |
| 89 case CSSPropertyPaddingRight: | |
| 90 case CSSPropertyPaddingTop: | |
| 91 case CSSPropertyRight: | |
| 92 case CSSPropertyTop: | |
| 93 case CSSPropertyWebkitPerspectiveOriginX: | |
| 94 case CSSPropertyWebkitPerspectiveOriginY: | |
| 95 case CSSPropertyWebkitTransformOriginX: | |
| 96 case CSSPropertyWebkitTransformOriginY: | |
| 97 case CSSPropertyWidth: | |
| 98 if (AnimatableNumber::canCreateFrom(value)) | |
| 
dstockwell
2013/07/30 03:35:04
otherwise, shouldn't we create an AnimatableUnknow
 
alancutter (OOO until 2018)
2013/07/30 08:31:02
Function removed from patch.
 | |
| 99 return AnimatableNumber::create(value); | |
| 100 default: | |
| 101 return AnimatableUnknown::create(value); | |
| 102 } | |
| 103 ASSERT_NOT_REACHED(); | |
| 104 return 0; | |
| 105 } | |
| 106 | |
| 107 // FIXME: Generate this function. | |
| 108 PassRefPtr<AnimatableValue> CSSAnimatableValueFactory::createFromRenderStyle(Ren derStyle* style, CSSPropertyID property) | |
| 109 { | |
| 110 switch (property) { | |
| 111 case CSSPropertyBottom: | |
| 112 return createFromLength(style->bottom(), style); | |
| 113 case CSSPropertyHeight: | |
| 114 return createFromLength(style->height(), style); | |
| 115 case CSSPropertyLeft: | |
| 116 return createFromLength(style->left(), style); | |
| 117 case CSSPropertyMarginBottom: | |
| 118 return createFromLength(style->marginBottom(), style); | |
| 119 case CSSPropertyMarginLeft: | |
| 120 return createFromLength(style->marginLeft(), style); | |
| 121 case CSSPropertyMarginRight: | |
| 122 return createFromLength(style->marginRight(), style); | |
| 123 case CSSPropertyMarginTop: | |
| 124 return createFromLength(style->marginTop(), style); | |
| 125 case CSSPropertyMaxHeight: | |
| 126 return createFromLength(style->maxHeight(), style); | |
| 127 case CSSPropertyMaxWidth: | |
| 128 return createFromLength(style->maxWidth(), style); | |
| 129 case CSSPropertyMinHeight: | |
| 130 return createFromLength(style->minHeight(), style); | |
| 131 case CSSPropertyMinWidth: | |
| 132 return createFromLength(style->minWidth(), style); | |
| 133 case CSSPropertyPaddingBottom: | |
| 134 return createFromLength(style->paddingBottom(), style); | |
| 135 case CSSPropertyPaddingLeft: | |
| 136 return createFromLength(style->paddingLeft(), style); | |
| 137 case CSSPropertyPaddingRight: | |
| 138 return createFromLength(style->paddingRight(), style); | |
| 139 case CSSPropertyPaddingTop: | |
| 140 return createFromLength(style->paddingTop(), style); | |
| 141 case CSSPropertyRight: | |
| 142 return createFromLength(style->right(), style); | |
| 143 case CSSPropertyTop: | |
| 144 return createFromLength(style->top(), style); | |
| 145 case CSSPropertyWebkitPerspectiveOriginX: | |
| 146 return createFromLength(style->perspectiveOriginX(), style); | |
| 147 case CSSPropertyWebkitPerspectiveOriginY: | |
| 148 return createFromLength(style->perspectiveOriginY(), style); | |
| 149 case CSSPropertyWebkitTransformOriginX: | |
| 150 return createFromLength(style->transformOriginX(), style); | |
| 151 case CSSPropertyWebkitTransformOriginY: | |
| 152 return createFromLength(style->transformOriginY(), style); | |
| 153 case CSSPropertyWidth: | |
| 154 return createFromLength(style->width(), style); | |
| 155 default: | |
| 156 ASSERT_WITH_MESSAGE(false, "Unable to create property CSS value from ren der style, not yet implemented!"); | |
| 157 return 0; | |
| 158 } | |
| 159 ASSERT_NOT_REACHED(); | |
| 
dstockwell
2013/07/30 03:35:04
doesn't default: with return mean this can't ever
 
alancutter (OOO until 2018)
2013/07/30 08:31:02
Done.
 | |
| 160 return 0; | |
| 161 } | |
| 162 | |
| 163 PassRefPtr<AnimatableValue> CSSAnimatableValueFactory::createFromLength(const Le ngth& length, RenderStyle* style) | |
| 164 { | |
| 165 switch (length.type()) { | |
| 166 case Relative: | |
| 167 return AnimatableNumber::create(length.value(), AnimatableNumber::UnitTy peNumber); | |
| 168 case Fixed: | |
| 169 return AnimatableNumber::create(adjustFloatForAbsoluteZoom(length.value( ), style), AnimatableNumber::UnitTypeLength); | |
| 170 case Percent: | |
| 171 return AnimatableNumber::create(length.value(), AnimatableNumber::UnitTy pePercentage); | |
| 172 case ViewportPercentageWidth: | |
| 173 return AnimatableNumber::create(length.value(), AnimatableNumber::UnitTy peViewportWidth); | |
| 174 case ViewportPercentageHeight: | |
| 175 return AnimatableNumber::create(length.value(), AnimatableNumber::UnitTy peViewportHeight); | |
| 176 case ViewportPercentageMin: | |
| 177 return AnimatableNumber::create(length.value(), AnimatableNumber::UnitTy peViewportMin); | |
| 178 case ViewportPercentageMax: | |
| 179 return AnimatableNumber::create(length.value(), AnimatableNumber::UnitTy peViewportMax); | |
| 180 case Calculated: | |
| 181 // FIXME: Convert platform calcs to CSS calcs. | |
| 182 ASSERT_WITH_MESSAGE(false, "Unable to convert platform CalculationValue to AnimatableValue, not yet implemented!"); | |
| 
dstockwell
2013/07/30 03:35:04
I was surprised that we didn't already have this p
 
alancutter (OOO until 2018)
2013/07/30 08:31:02
It's not particularly difficult though I would pre
 | |
| 183 return 0; | |
| 184 case Auto: | |
| 185 case Intrinsic: | |
| 186 case MinIntrinsic: | |
| 187 case MinContent: | |
| 188 case MaxContent: | |
| 189 case FillAvailable: | |
| 190 case FitContent: | |
| 191 return AnimatableUnknown::create(CSSPrimitiveValue::create(length)); | |
| 192 case Undefined: | |
| 193 return AnimatableUnknown::create(CSSPrimitiveValue::create(CSSValueNone) ); | |
| 194 case ExtendToZoom: // Does not apply to elements. | |
| 195 ASSERT_NOT_REACHED(); | |
| 196 return 0; | |
| 197 } | |
| 198 ASSERT_NOT_REACHED(); | |
| 199 return 0; | |
| 200 } | |
| 201 | |
| 202 } // namespace WebCore | |
| OLD | NEW |