OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
dstockwell
2014/03/04 01:29:31
This doesn't look like a brand new file. There was
alancutter (OOO until 2018)
2014/03/04 01:35:14
Done.
| |
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, c onst Vector<Dictionary>& keyframeDictionaryVector, bool unsafe) | |
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)) | |
45 keyframe->setOffset(offset); | |
46 | |
47 String compositeString; | |
48 keyframeDictionaryVector[i].get("composite", compositeString); | |
49 if (compositeString == "add") | |
50 keyframe->setComposite(AnimationEffect::CompositeAdd); | |
51 | |
52 String timingFunctionString; | |
53 if (keyframeDictionaryVector[i].get("easing", timingFunctionString)) { | |
54 RefPtrWillBeRawPtr<CSSValue> timingFunctionValue = BisonCSSParser::p arseAnimationTimingFunctionValue(timingFunctionString); | |
55 if (timingFunctionValue) | |
56 keyframe->setEasing(CSSToStyleMap::animationTimingFunction(timin gFunctionValue.get(), false)); | |
57 } | |
58 | |
59 Vector<String> keyframeProperties; | |
60 keyframeDictionaryVector[i].getOwnPropertyNames(keyframeProperties); | |
61 | |
62 for (size_t j = 0; j < keyframeProperties.size(); ++j) { | |
63 String property = keyframeProperties[j]; | |
64 CSSPropertyID id = camelCaseCSSPropertyNameToID(property); | |
65 | |
66 // FIXME: There is no way to store invalid properties or invalid val ues | |
67 // in a Keyframe object, so for now I just skip over them. Eventuall y we | |
68 // will need to support getFrames(), which should return exactly the | |
69 // keyframes that were input through the API. We will add a layer to wrap | |
70 // KeyframeEffectModel, store input keyframes and implement getFrame s. | |
71 if (id == CSSPropertyInvalid || !CSSAnimations::isAnimatableProperty (id)) | |
72 continue; | |
73 | |
74 String value; | |
75 keyframeDictionaryVector[i].get(property, value); | |
76 propertySet->setProperty(id, value); | |
77 } | |
78 } | |
79 | |
80 // FIXME: Replace this with code that just parses, when that code is availab le. | |
81 return StyleResolver::createKeyframeEffectModel(*element, propertySetVector, keyframes); | |
82 } | |
83 | |
84 } // namespace WebCore | |
OLD | NEW |