OLD | NEW |
---|---|
(Empty) | |
1 /* | |
2 * Copyright (C) 2014 Google Inc. All rights reserved. | |
3 * | |
4 * Redistribution and use in source and binary forms, with or without | |
5 * modification, are permitted provided that the following conditions are | |
6 * met: | |
7 * | |
8 * * Redistributions of source code must retain the above copyright | |
9 * notice, this list of conditions and the following disclaimer. | |
10 * * Redistributions in binary form must reproduce the above | |
11 * copyright notice, this list of conditions and the following disclaimer | |
12 * in the documentation and/or other materials provided with the | |
13 * distribution. | |
14 * * Neither the name of Google Inc. nor the names of its | |
15 * contributors may be used to endorse or promote products derived from | |
16 * this software without specific prior written permission. | |
17 * | |
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES{ | |
25 | |
26 } LOSS OF USE, | |
27 * DATA, OR PROFITS{ | |
28 | |
29 } OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
33 */ | |
34 | |
35 #include "config.h" | |
36 #include "core/wawwa/AnimatableElement.h" | |
37 | |
38 namespace blink { | |
39 | |
40 AnimatableElement::AnimatableElement(String inputID) | |
41 : m_id(inputID) | |
42 { | |
43 } | |
44 | |
45 PassRefPtrWillBeRawPtr<AnimatableElement> AnimatableElement::create(String input ID) | |
46 { | |
47 return adoptRef(new AnimatableElement(inputID)); | |
48 } | |
49 | |
50 AnimatableElement * AnimatableElement::clone() | |
51 { | |
52 return new AnimatableElement(m_id); | |
53 } | |
54 | |
55 PassRefPtrWillBeRawPtr<RemotePlayer> AnimatableElement::animate(const Vector<Dic tionary>& keyframeDictionaryVector, const Dictionary& timingInputDictionary, Pas sRefPtr<DedicatedWorkerGlobalScope> workerGlobalScope, ExceptionState& es) | |
56 { | |
57 String temp = m_id.isolatedCopy(); | |
58 ASSERT(temp.isSafeToSendToAnotherThread()); | |
59 Document* doc = static_cast<Document*>(workerGlobalScope->thread()->workerOb jectProxy().context()); | |
60 Page* page = doc->page(); | |
61 | |
62 Timing ti = TimingInput::convert(timingInputDictionary); | |
dstockwell
2014/08/29 01:05:43
Don't use acronyms for local variable names.
| |
63 | |
64 Vector<ProxyKeyframe> holdVector; | |
dstockwell
2014/08/29 01:05:43
Try to avoid using types in variable names. 'holds
| |
65 | |
66 ProxyKeyframe keyframe; | |
67 double lastOffset = 0; | |
68 for (size_t i = 0; i < keyframeDictionaryVector.size(); i++) { | |
dstockwell
2014/08/29 01:05:43
This logic should be shared with EffectInput.
nainar1
2014/08/29 06:01:39
Acknowledged.
| |
69 ScriptValue scriptValue; | |
70 bool frameHasOffset = DictionaryHelper::get(keyframeDictionaryVector[i], "offset", scriptValue) && !scriptValue.isNull(); | |
71 if (frameHasOffset) { | |
72 double offset; | |
73 DictionaryHelper::get(keyframeDictionaryVector[i], "offset", offset) ; | |
74 if (std::isnan(offset)) { | |
75 es.throwDOMException(InvalidModificationError, "Non numeric offs et provided"); | |
76 } | |
77 if (offset < 0 || offset > 1) { | |
78 es.throwDOMException(InvalidModificationError, "Offsets provided outside the range [0, 1]"); | |
79 return nullptr; | |
80 } | |
81 if (offset < lastOffset) { | |
82 es.throwDOMException(InvalidModificationError, "Keyframes with s pecified offsets are not sorted"); | |
83 return nullptr; | |
84 } | |
85 lastOffset = offset; | |
86 keyframe.offset = offset; | |
87 } | |
88 keyframe.offset = 2; | |
89 String compositeString; | |
90 DictionaryHelper::get(keyframeDictionaryVector[i], "composite", composit eString); | |
91 if (compositeString == "add") | |
92 keyframe.composite = compositeString; | |
93 String timingFunctionString; | |
94 if (DictionaryHelper::get(keyframeDictionaryVector[i], "easing", timingF unctionString)) { | |
95 if (RefPtrWillBeRawPtr<CSSValue> timingFunctionValue = BisonCSSParse r::parseAnimationTimingFunctionValue(timingFunctionString)) | |
96 keyframe.easing = timingFunctionString; | |
97 } | |
98 | |
99 Vector<String> holdProperties; | |
100 holdProperties.clear(); | |
101 keyframe.pairs.clear(); | |
102 keyframeDictionaryVector[i].getOwnPropertyNames(holdProperties); | |
103 for (size_t j = 0; j < holdProperties.size(); j++) { | |
104 String property = holdProperties[j]; | |
105 String value; | |
106 DictionaryHelper::get(keyframeDictionaryVector[i], property, value); | |
107 ProxyPairs pair1 = {property, value}; | |
108 keyframe.pairs.append(pair1); | |
109 } | |
110 holdVector.append(keyframe); | |
111 } | |
112 WorkerObjectProxy wop = workerGlobalScope->thread()->workerObjectProxy(); | |
113 wop.postTaskToMainExecutionContext(createCrossThreadTask(&ProxyMap::execute, AllowCrossThreadAccess(page->m_ProxyMap.get()), Animate, temp, holdVector, ti)) ; | |
114 return adoptRef(new RemotePlayer(m_id, workerGlobalScope, holdVector, ti)); | |
115 } | |
116 | |
117 } // namespace blink | |
OLD | NEW |