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 15 matching lines...) Expand all Loading... | |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 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. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #include "config.h" | 31 #include "config.h" |
32 #include "core/animation/EffectInput.h" | 32 #include "core/animation/EffectInput.h" |
33 | 33 |
34 #include "bindings/v8/Dictionary.h" | 34 #include "bindings/v8/Dictionary.h" |
35 #include "core/animation/AnimationHelpers.h" | 35 #include "core/animation/AnimationHelpers.h" |
36 #include "core/animation/css/CSSAnimations.h" | 36 #include "core/animation/KeyframeEffectModel.h" |
37 #include "core/animation/StringKeyframe.h" | |
37 #include "core/css/parser/BisonCSSParser.h" | 38 #include "core/css/parser/BisonCSSParser.h" |
38 #include "core/css/resolver/StyleResolver.h" | 39 #include "core/css/resolver/StyleResolver.h" |
39 #include "core/dom/Element.h" | 40 #include "core/dom/Element.h" |
40 | 41 |
41 namespace WebCore { | 42 namespace WebCore { |
42 | 43 |
43 static bool checkDocumentAndRenderer(Element* element) | 44 static bool checkDocumentAndRenderer(Element& element) |
44 { | 45 { |
45 if (!element->inActiveDocument()) | 46 if (!element.inActiveDocument()) |
46 return false; | 47 return false; |
47 element->document().updateRenderTreeIfNeeded(); | 48 element.document().updateRenderTreeIfNeeded(); |
esprehn
2014/04/04 22:37:12
I assume you're going to remove this eventually?
shans
2014/04/06 20:25:30
Yeah. Alan: FIXME?
alancutter (OOO until 2018)
2014/04/07 00:02:26
Added FIXME.
| |
48 return element->renderer(); | 49 return element.renderer(); |
49 } | 50 } |
50 | 51 |
51 PassRefPtrWillBeRawPtr<AnimationEffect> EffectInput::convert(Element* element, c onst Vector<Dictionary>& keyframeDictionaryVector, ExceptionState& exceptionSta te, bool unsafe) | 52 PassRefPtrWillBeRawPtr<AnimationEffect> EffectInput::convert(Element* element, c onst Vector<Dictionary>& keyframeDictionaryVector, ExceptionState& exceptionStat e, bool unsafe) |
52 { | 53 { |
53 // FIXME: This test will not be neccessary once resolution of keyframe value s occurs at | 54 // FIXME: This test will not be neccessary once resolution of keyframe value s occurs at |
54 // animation application time. | 55 // animation application time. |
55 if (!unsafe && !checkDocumentAndRenderer(element)) | 56 if (!unsafe && !checkDocumentAndRenderer(*element)) |
56 return nullptr; | 57 return nullptr; |
57 | 58 |
58 StyleSheetContents* styleSheetContents = element->document().elementSheet(). contents(); | 59 StyleSheetContents* styleSheetContents = element->document().elementSheet(). contents(); |
59 | 60 StringKeyframeVector keyframes; |
60 // FIXME: Move this code into KeyframeEffectModel, it will be used by the ID L constructor for that class. | |
61 AnimatableValueKeyframeVector keyframes; | |
62 WillBeHeapVector<RefPtrWillBeMember<MutableStylePropertySet> > propertySetVe ctor; | |
63 | 61 |
64 for (size_t i = 0; i < keyframeDictionaryVector.size(); ++i) { | 62 for (size_t i = 0; i < keyframeDictionaryVector.size(); ++i) { |
65 RefPtrWillBeRawPtr<MutableStylePropertySet> propertySet = MutableStylePr opertySet::create(); | 63 RefPtrWillBeRawPtr<StringKeyframe> keyframe = StringKeyframe::create(); |
66 propertySetVector.append(propertySet); | |
67 | |
68 RefPtrWillBeRawPtr<AnimatableValueKeyframe> keyframe = AnimatableValueKe yframe::create(); | |
69 keyframes.append(keyframe); | 64 keyframes.append(keyframe); |
70 | 65 |
71 double offset; | 66 double offset; |
72 if (keyframeDictionaryVector[i].get("offset", offset)) | 67 if (keyframeDictionaryVector[i].get("offset", offset)) |
73 keyframe->setOffset(offset); | 68 keyframe->setOffset(offset); |
74 | 69 |
75 String compositeString; | 70 String compositeString; |
76 keyframeDictionaryVector[i].get("composite", compositeString); | 71 keyframeDictionaryVector[i].get("composite", compositeString); |
77 if (compositeString == "add") | 72 if (compositeString == "add") |
78 keyframe->setComposite(AnimationEffect::CompositeAdd); | 73 keyframe->setComposite(AnimationEffect::CompositeAdd); |
79 | 74 |
80 String timingFunctionString; | 75 String timingFunctionString; |
81 if (keyframeDictionaryVector[i].get("easing", timingFunctionString)) { | 76 if (keyframeDictionaryVector[i].get("easing", timingFunctionString)) { |
82 RefPtrWillBeRawPtr<CSSValue> timingFunctionValue = BisonCSSParser::p arseAnimationTimingFunctionValue(timingFunctionString); | 77 RefPtrWillBeRawPtr<CSSValue> timingFunctionValue = BisonCSSParser::p arseAnimationTimingFunctionValue(timingFunctionString); |
83 if (timingFunctionValue) | 78 if (timingFunctionValue) |
84 keyframe->setEasing(CSSToStyleMap::animationTimingFunction(timin gFunctionValue.get(), false)); | 79 keyframe->setEasing(CSSToStyleMap::animationTimingFunction(timin gFunctionValue.get(), false)); |
85 } | 80 } |
86 | 81 |
87 Vector<String> keyframeProperties; | 82 Vector<String> keyframeProperties; |
88 keyframeDictionaryVector[i].getOwnPropertyNames(keyframeProperties); | 83 keyframeDictionaryVector[i].getOwnPropertyNames(keyframeProperties); |
89 | |
90 for (size_t j = 0; j < keyframeProperties.size(); ++j) { | 84 for (size_t j = 0; j < keyframeProperties.size(); ++j) { |
91 String property = keyframeProperties[j]; | 85 String property = keyframeProperties[j]; |
92 CSSPropertyID id = camelCaseCSSPropertyNameToID(property); | 86 CSSPropertyID id = camelCaseCSSPropertyNameToID(property); |
93 | 87 if (id == CSSPropertyInvalid) |
94 // FIXME: There is no way to store invalid properties or invalid val ues | |
95 // in a Keyframe object, so for now I just skip over them. Eventuall y we | |
96 // will need to support getFrames(), which should return exactly the | |
97 // keyframes that were input through the API. We will add a layer to wrap | |
98 // KeyframeEffectModel, store input keyframes and implement getFrame s. | |
99 if (id == CSSPropertyInvalid || !CSSAnimations::isAnimatableProperty (id)) | |
100 continue; | 88 continue; |
101 | |
102 String value; | 89 String value; |
103 keyframeDictionaryVector[i].get(property, value); | 90 keyframeDictionaryVector[i].get(property, value); |
104 propertySet->setProperty(id, value, false, styleSheetContents); | 91 keyframe->setPropertyValue(id, value, styleSheetContents); |
105 } | 92 } |
106 } | 93 } |
107 | 94 |
108 // FIXME: Replace this with code that just parses, when that code is availab le. | 95 RefPtrWillBeRawPtr<StringKeyframeEffectModel> keyframeEffectModel = StringKe yframeEffectModel::create(keyframes); |
109 RefPtrWillBeRawPtr<AnimatableValueKeyframeEffectModel> keyframeEffectModel = StyleResolver::createKeyframeEffectModel(*element, propertySetVector, keyframes ); | |
110 if (!keyframeEffectModel->isReplaceOnly()) { | 96 if (!keyframeEffectModel->isReplaceOnly()) { |
111 exceptionState.throwDOMException(NotSupportedError, "Partial keyframes a re not supported."); | 97 exceptionState.throwDOMException(NotSupportedError, "Partial keyframes a re not supported."); |
112 return nullptr; | 98 return nullptr; |
113 } | 99 } |
100 keyframeEffectModel->forceConversionsToAnimatableValues(element); | |
114 | 101 |
115 return keyframeEffectModel; | 102 return keyframeEffectModel; |
116 } | 103 } |
117 | 104 |
118 } // namespace WebCore | 105 } // namespace WebCore |
OLD | NEW |