Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(517)

Side by Side Diff: Source/core/animation/EffectInput.cpp

Issue 182063005: Web Animations API: Refactor IDL input conversion out of Animation (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Remove templates Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "config.h"
6 #include "core/animation/EffectInput.h"
7
8 #include "bindings/v8/Dictionary.h"
9 #include "core/animation/AnimationHelpers.h"
10 #include "core/animation/css/CSSAnimations.h"
11 #include "core/css/parser/BisonCSSParser.h"
12 #include "core/css/resolver/StyleResolver.h"
13 #include "core/dom/Element.h"
14
15 namespace WebCore {
16
17 static bool checkDocumentAndRenderer(Element* element)
18 {
19 if (!element->inActiveDocument())
20 return false;
21 element->document().updateStyleIfNeeded();
22 return element->renderer();
23 }
24
25 PassRefPtrWillBeRawPtr<AnimationEffect> EffectInput::convert(Element* element, V ector<Dictionary> keyframeDictionaryVector, bool unsafe)
esprehn 2014/03/04 00:59:42 You almost certainly want to pass const Vector<Dic
alancutter (OOO until 2018) 2014/03/04 01:21:41 Done.
26 {
27 // FIXME: This test will not be neccessary once resolution of keyframe value s occurs at
28 // animation application time.
29 if (!unsafe && !checkDocumentAndRenderer(element))
30 return nullptr;
31
32 // FIXME: Move this code into KeyframeEffectModel, it will be used by the ID L constructor for that class.
33 KeyframeEffectModel::KeyframeVector keyframes;
34 Vector<RefPtr<MutableStylePropertySet> > propertySetVector;
35
36 for (size_t i = 0; i < keyframeDictionaryVector.size(); ++i) {
37 RefPtr<MutableStylePropertySet> propertySet = MutableStylePropertySet::c reate();
38 propertySetVector.append(propertySet);
39
40 RefPtrWillBeRawPtr<Keyframe> keyframe = Keyframe::create();
41 keyframes.append(keyframe);
42
43 double offset;
44 if (keyframeDictionaryVector[i].get("offset", offset)) {
esprehn 2014/03/04 00:59:42 no braces on a one line if
alancutter (OOO until 2018) 2014/03/04 01:21:41 Done.
dstockwell 2014/03/04 01:29:31 The blink style guide was relaxed about this a lon
45 keyframe->setOffset(offset);
46 }
47
48 String compositeString;
49 keyframeDictionaryVector[i].get("composite", compositeString);
50 if (compositeString == "add")
51 keyframe->setComposite(AnimationEffect::CompositeAdd);
52
53 String timingFunctionString;
54 if (keyframeDictionaryVector[i].get("easing", timingFunctionString)) {
55 RefPtrWillBeRawPtr<CSSValue> timingFunctionValue = BisonCSSParser::p arseAnimationTimingFunctionValue(timingFunctionString);
56 if (timingFunctionValue) {
esprehn 2014/03/04 00:59:42 ditto
alancutter (OOO until 2018) 2014/03/04 01:21:41 Done.
57 keyframe->setEasing(CSSToStyleMap::animationTimingFunction(timin gFunctionValue.get(), false));
58 }
59 }
60
61 Vector<String> keyframeProperties;
62 keyframeDictionaryVector[i].getOwnPropertyNames(keyframeProperties);
63
64 for (size_t j = 0; j < keyframeProperties.size(); ++j) {
65 String property = keyframeProperties[j];
66 CSSPropertyID id = camelCaseCSSPropertyNameToID(property);
67
68 // FIXME: There is no way to store invalid properties or invalid val ues
69 // in a Keyframe object, so for now I just skip over them. Eventuall y we
70 // will need to support getFrames(), which should return exactly the
71 // keyframes that were input through the API. We will add a layer to wrap
72 // KeyframeEffectModel, store input keyframes and implement getFrame s.
73 if (id == CSSPropertyInvalid || !CSSAnimations::isAnimatableProperty (id))
74 continue;
75
76 String value;
77 keyframeDictionaryVector[i].get(property, value);
78 propertySet->setProperty(id, value);
79 }
80 }
81
82 // FIXME: Replace this with code that just parses, when that code is availab le.
83 return StyleResolver::createKeyframeEffectModel(*element, propertySetVector, keyframes);
84 }
85
86 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698