| 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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 } | 118 } |
| 119 if (keyframe->composite() != EffectModel::CompositeReplace) { | 119 if (keyframe->composite() != EffectModel::CompositeReplace) { |
| 120 exceptionState.throwDOMException(NotSupportedError, "Additiv
e animations are not supported."); | 120 exceptionState.throwDOMException(NotSupportedError, "Additiv
e animations are not supported."); |
| 121 return nullptr; | 121 return nullptr; |
| 122 } | 122 } |
| 123 } | 123 } |
| 124 } | 124 } |
| 125 } | 125 } |
| 126 keyframeEffectModel->forceConversionsToAnimatableValues(element, element.com
putedStyle()); | 126 keyframeEffectModel->forceConversionsToAnimatableValues(element, element.com
putedStyle()); |
| 127 | 127 |
| 128 ASSERT(!exceptionState.hadException()); |
| 128 return keyframeEffectModel; | 129 return keyframeEffectModel; |
| 129 } | 130 } |
| 130 | 131 |
| 131 bool exhaustDictionaryIterator(DictionaryIterator& iterator, ExecutionContext* e
xecutionContext, ExceptionState& exceptionState, Vector<Dictionary>& result) | 132 bool exhaustDictionaryIterator(DictionaryIterator& iterator, ExecutionContext* e
xecutionContext, ExceptionState& exceptionState, Vector<Dictionary>& result) |
| 132 { | 133 { |
| 133 while (iterator.next(executionContext, exceptionState)) { | 134 while (iterator.next(executionContext, exceptionState)) { |
| 134 Dictionary dictionary; | 135 Dictionary dictionary; |
| 135 if (!iterator.valueAsDictionary(dictionary, exceptionState)) { | 136 if (!iterator.valueAsDictionary(dictionary, exceptionState)) { |
| 136 exceptionState.throwTypeError("Keyframes must be objects."); | 137 exceptionState.throwTypeError("Keyframes must be objects."); |
| 137 return false; | 138 return false; |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 } | 190 } |
| 190 | 191 |
| 191 String compositeString; | 192 String compositeString; |
| 192 DictionaryHelper::get(keyframeDictionary, "composite", compositeString); | 193 DictionaryHelper::get(keyframeDictionary, "composite", compositeString); |
| 193 if (compositeString == "add") | 194 if (compositeString == "add") |
| 194 keyframe->setComposite(EffectModel::CompositeAdd); | 195 keyframe->setComposite(EffectModel::CompositeAdd); |
| 195 // TODO(alancutter): Support "accumulate" keyframe composition. | 196 // TODO(alancutter): Support "accumulate" keyframe composition. |
| 196 | 197 |
| 197 String timingFunctionString; | 198 String timingFunctionString; |
| 198 if (DictionaryHelper::get(keyframeDictionary, "easing", timingFunctionSt
ring)) { | 199 if (DictionaryHelper::get(keyframeDictionary, "easing", timingFunctionSt
ring)) { |
| 199 if (RefPtr<TimingFunction> timingFunction = AnimationInputHelpers::p
arseTimingFunction(timingFunctionString, &element.document())) | 200 RefPtr<TimingFunction> timingFunction = AnimationInputHelpers::parse
TimingFunction(timingFunctionString, &element.document(), exceptionState); |
| 200 keyframe->setEasing(timingFunction); | 201 if (!timingFunction) |
| 202 return nullptr; |
| 203 keyframe->setEasing(timingFunction); |
| 201 } | 204 } |
| 202 | 205 |
| 203 Vector<String> keyframeProperties; | 206 Vector<String> keyframeProperties; |
| 204 keyframeDictionary.getPropertyNames(keyframeProperties); | 207 keyframeDictionary.getPropertyNames(keyframeProperties); |
| 205 for (const auto& property : keyframeProperties) { | 208 for (const auto& property : keyframeProperties) { |
| 206 if (property == "offset" | 209 if (property == "offset" |
| 207 || property == "composite" | 210 || property == "composite" |
| 208 || property == "easing") { | 211 || property == "easing") { |
| 209 continue; | 212 continue; |
| 210 } | 213 } |
| 211 | 214 |
| 212 Vector<String> values; | 215 Vector<String> values; |
| 213 if (DictionaryHelper::get(keyframeDictionary, property, values)) { | 216 if (DictionaryHelper::get(keyframeDictionary, property, values)) { |
| 214 exceptionState.throwTypeError("Lists of values not permitted in
array-form list of keyframes"); | 217 exceptionState.throwTypeError("Lists of values not permitted in
array-form list of keyframes"); |
| 215 return nullptr; | 218 return nullptr; |
| 216 } | 219 } |
| 217 | 220 |
| 218 String value; | 221 String value; |
| 219 DictionaryHelper::get(keyframeDictionary, property, value); | 222 DictionaryHelper::get(keyframeDictionary, property, value); |
| 220 | 223 |
| 221 encounteredCompositableProperty |= setKeyframeValue(element, *keyfra
me.get(), property, value); | 224 encounteredCompositableProperty |= setKeyframeValue(element, *keyfra
me.get(), property, value); |
| 222 } | 225 } |
| 223 keyframes.append(keyframe); | 226 keyframes.append(keyframe); |
| 224 } | 227 } |
| 225 | 228 |
| 226 if (exceptionState.hadException()) | 229 ASSERT(!exceptionState.hadException()); |
| 227 return nullptr; | |
| 228 | 230 |
| 229 return createEffectModelFromKeyframes(element, keyframes, encounteredComposi
tableProperty, exceptionState); | 231 return createEffectModelFromKeyframes(element, keyframes, encounteredComposi
tableProperty, exceptionState); |
| 230 } | 232 } |
| 231 | 233 |
| 232 EffectModel* EffectInput::convertObjectForm(Element& element, const Dictionary&
keyframeDictionary, ExceptionState& exceptionState) | 234 EffectModel* EffectInput::convertObjectForm(Element& element, const Dictionary&
keyframeDictionary, ExceptionState& exceptionState) |
| 233 { | 235 { |
| 234 StringKeyframeVector keyframes; | 236 StringKeyframeVector keyframes; |
| 235 bool encounteredCompositableProperty = false; | 237 bool encounteredCompositableProperty = false; |
| 236 | 238 |
| 237 String timingFunctionString; | 239 String timingFunctionString; |
| 238 RefPtr<TimingFunction> timingFunction = nullptr; | 240 RefPtr<TimingFunction> timingFunction = nullptr; |
| 239 if (DictionaryHelper::get(keyframeDictionary, "easing", timingFunctionString
)) | 241 if (DictionaryHelper::get(keyframeDictionary, "easing", timingFunctionString
)) { |
| 240 timingFunction = AnimationInputHelpers::parseTimingFunction(timingFuncti
onString, &element.document()); | 242 timingFunction = AnimationInputHelpers::parseTimingFunction(timingFuncti
onString, &element.document(), exceptionState); |
| 243 if (!timingFunction) |
| 244 return nullptr; |
| 245 } |
| 241 | 246 |
| 242 ScriptValue scriptValue; | 247 ScriptValue scriptValue; |
| 243 bool frameHasOffset = DictionaryHelper::get(keyframeDictionary, "offset", sc
riptValue) && !scriptValue.isNull(); | 248 bool frameHasOffset = DictionaryHelper::get(keyframeDictionary, "offset", sc
riptValue) && !scriptValue.isNull(); |
| 244 double offset = 0.0; | 249 double offset = 0.0; |
| 245 if (frameHasOffset && !getAndCheckOffset(keyframeDictionary, offset, 0.0, ex
ceptionState)) | 250 if (frameHasOffset && !getAndCheckOffset(keyframeDictionary, offset, 0.0, ex
ceptionState)) |
| 246 return nullptr; | 251 return nullptr; |
| 247 | 252 |
| 248 String compositeString; | 253 String compositeString; |
| 249 DictionaryHelper::get(keyframeDictionary, "composite", compositeString); | 254 DictionaryHelper::get(keyframeDictionary, "composite", compositeString); |
| 250 | 255 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 keyframe->setComposite(EffectModel::CompositeAdd); | 288 keyframe->setComposite(EffectModel::CompositeAdd); |
| 284 // TODO(alancutter): Support "accumulate" keyframe composition. | 289 // TODO(alancutter): Support "accumulate" keyframe composition. |
| 285 | 290 |
| 286 encounteredCompositableProperty |= setKeyframeValue(element, *keyfra
me.get(), property, values[i]); | 291 encounteredCompositableProperty |= setKeyframeValue(element, *keyfra
me.get(), property, values[i]); |
| 287 keyframes.append(keyframe); | 292 keyframes.append(keyframe); |
| 288 } | 293 } |
| 289 } | 294 } |
| 290 | 295 |
| 291 std::sort(keyframes.begin(), keyframes.end(), compareKeyframes); | 296 std::sort(keyframes.begin(), keyframes.end(), compareKeyframes); |
| 292 | 297 |
| 298 ASSERT(!exceptionState.hadException()); |
| 299 |
| 293 return createEffectModelFromKeyframes(element, keyframes, encounteredComposi
tableProperty, exceptionState); | 300 return createEffectModelFromKeyframes(element, keyframes, encounteredComposi
tableProperty, exceptionState); |
| 294 } | 301 } |
| 295 | 302 |
| 296 } // namespace blink | 303 } // namespace blink |
| OLD | NEW |