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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 bool exhaustDictionaryIterator(DictionaryIterator& iterator, | 158 bool exhaustDictionaryIterator(DictionaryIterator& iterator, |
159 ExecutionContext* executionContext, | 159 ExecutionContext* executionContext, |
160 ExceptionState& exceptionState, | 160 ExceptionState& exceptionState, |
161 Vector<Dictionary>& result) { | 161 Vector<Dictionary>& result) { |
162 while (iterator.next(executionContext, exceptionState)) { | 162 while (iterator.next(executionContext, exceptionState)) { |
163 Dictionary dictionary; | 163 Dictionary dictionary; |
164 if (!iterator.valueAsDictionary(dictionary, exceptionState)) { | 164 if (!iterator.valueAsDictionary(dictionary, exceptionState)) { |
165 exceptionState.throwTypeError("Keyframes must be objects."); | 165 exceptionState.throwTypeError("Keyframes must be objects."); |
166 return false; | 166 return false; |
167 } | 167 } |
168 result.append(dictionary); | 168 result.push_back(dictionary); |
169 } | 169 } |
170 return !exceptionState.hadException(); | 170 return !exceptionState.hadException(); |
171 } | 171 } |
172 | 172 |
173 } // namespace | 173 } // namespace |
174 | 174 |
175 // Spec: http://w3c.github.io/web-animations/#processing-a-keyframes-argument | 175 // Spec: http://w3c.github.io/web-animations/#processing-a-keyframes-argument |
176 EffectModel* EffectInput::convert( | 176 EffectModel* EffectInput::convert( |
177 Element* element, | 177 Element* element, |
178 const DictionarySequenceOrDictionary& effectInput, | 178 const DictionarySequenceOrDictionary& effectInput, |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 "Lists of values not permitted in array-form list of keyframes"); | 258 "Lists of values not permitted in array-form list of keyframes"); |
259 return nullptr; | 259 return nullptr; |
260 } | 260 } |
261 | 261 |
262 String value; | 262 String value; |
263 DictionaryHelper::get(keyframeDictionary, property, value); | 263 DictionaryHelper::get(keyframeDictionary, property, value); |
264 | 264 |
265 setKeyframeValue(element, *keyframe.get(), property, value, | 265 setKeyframeValue(element, *keyframe.get(), property, value, |
266 executionContext); | 266 executionContext); |
267 } | 267 } |
268 keyframes.append(keyframe); | 268 keyframes.push_back(keyframe); |
269 } | 269 } |
270 | 270 |
271 DCHECK(!exceptionState.hadException()); | 271 DCHECK(!exceptionState.hadException()); |
272 | 272 |
273 return createEffectModelFromKeyframes(element, keyframes, exceptionState); | 273 return createEffectModelFromKeyframes(element, keyframes, exceptionState); |
274 } | 274 } |
275 | 275 |
276 static bool getPropertyIndexedKeyframeValues( | 276 static bool getPropertyIndexedKeyframeValues( |
277 const Dictionary& keyframeDictionary, | 277 const Dictionary& keyframeDictionary, |
278 const String& property, | 278 const String& property, |
279 ExecutionContext* executionContext, | 279 ExecutionContext* executionContext, |
280 ExceptionState& exceptionState, | 280 ExceptionState& exceptionState, |
281 Vector<String>& result) { | 281 Vector<String>& result) { |
282 DCHECK(result.isEmpty()); | 282 DCHECK(result.isEmpty()); |
283 | 283 |
284 // Array of strings. | 284 // Array of strings. |
285 if (DictionaryHelper::get(keyframeDictionary, property, result)) | 285 if (DictionaryHelper::get(keyframeDictionary, property, result)) |
286 return true; | 286 return true; |
287 | 287 |
288 Dictionary valuesDictionary; | 288 Dictionary valuesDictionary; |
289 if (!keyframeDictionary.get(property, valuesDictionary) || | 289 if (!keyframeDictionary.get(property, valuesDictionary) || |
290 valuesDictionary.isUndefinedOrNull()) { | 290 valuesDictionary.isUndefinedOrNull()) { |
291 // Non-object. | 291 // Non-object. |
292 String value; | 292 String value; |
293 DictionaryHelper::get(keyframeDictionary, property, value); | 293 DictionaryHelper::get(keyframeDictionary, property, value); |
294 result.append(value); | 294 result.push_back(value); |
295 return true; | 295 return true; |
296 } | 296 } |
297 | 297 |
298 DictionaryIterator iterator = valuesDictionary.getIterator(executionContext); | 298 DictionaryIterator iterator = valuesDictionary.getIterator(executionContext); |
299 if (iterator.isNull()) { | 299 if (iterator.isNull()) { |
300 // Non-iterable object. | 300 // Non-iterable object. |
301 String value; | 301 String value; |
302 DictionaryHelper::get(keyframeDictionary, property, value); | 302 DictionaryHelper::get(keyframeDictionary, property, value); |
303 result.append(value); | 303 result.push_back(value); |
304 return true; | 304 return true; |
305 } | 305 } |
306 | 306 |
307 // Iterable object. | 307 // Iterable object. |
308 while (iterator.next(executionContext, exceptionState)) { | 308 while (iterator.next(executionContext, exceptionState)) { |
309 String value; | 309 String value; |
310 if (!iterator.valueAsString(value)) { | 310 if (!iterator.valueAsString(value)) { |
311 exceptionState.throwTypeError("Unable to read keyframe value as string."); | 311 exceptionState.throwTypeError("Unable to read keyframe value as string."); |
312 return false; | 312 return false; |
313 } | 313 } |
314 result.append(value); | 314 result.push_back(value); |
315 } | 315 } |
316 return !exceptionState.hadException(); | 316 return !exceptionState.hadException(); |
317 } | 317 } |
318 | 318 |
319 EffectModel* EffectInput::convertObjectForm( | 319 EffectModel* EffectInput::convertObjectForm( |
320 Element& element, | 320 Element& element, |
321 const Dictionary& keyframeDictionary, | 321 const Dictionary& keyframeDictionary, |
322 ExecutionContext* executionContext, | 322 ExecutionContext* executionContext, |
323 ExceptionState& exceptionState) { | 323 ExceptionState& exceptionState) { |
324 StringKeyframeVector keyframes; | 324 StringKeyframeVector keyframes; |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
372 | 372 |
373 if (timingFunction) | 373 if (timingFunction) |
374 keyframe->setEasing(timingFunction); | 374 keyframe->setEasing(timingFunction); |
375 | 375 |
376 if (compositeString == "add") | 376 if (compositeString == "add") |
377 keyframe->setComposite(EffectModel::CompositeAdd); | 377 keyframe->setComposite(EffectModel::CompositeAdd); |
378 // TODO(alancutter): Support "accumulate" keyframe composition. | 378 // TODO(alancutter): Support "accumulate" keyframe composition. |
379 | 379 |
380 setKeyframeValue(element, *keyframe.get(), property, values[i], | 380 setKeyframeValue(element, *keyframe.get(), property, values[i], |
381 executionContext); | 381 executionContext); |
382 keyframes.append(keyframe); | 382 keyframes.push_back(keyframe); |
383 } | 383 } |
384 } | 384 } |
385 | 385 |
386 std::sort(keyframes.begin(), keyframes.end(), compareKeyframes); | 386 std::sort(keyframes.begin(), keyframes.end(), compareKeyframes); |
387 | 387 |
388 DCHECK(!exceptionState.hadException()); | 388 DCHECK(!exceptionState.hadException()); |
389 | 389 |
390 return createEffectModelFromKeyframes(element, keyframes, exceptionState); | 390 return createEffectModelFromKeyframes(element, keyframes, exceptionState); |
391 } | 391 } |
392 | 392 |
393 } // namespace blink | 393 } // namespace blink |
OLD | NEW |