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

Side by Side Diff: sky/engine/bindings/core/v8/custom/V8ElementCustom.cpp

Issue 922053002: Remove unused V8 integration code in Sky (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 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
OLDNEW
(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; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
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.
29 */
30
31 #include "sky/engine/config.h"
32 #include "bindings/core/v8/V8Element.h"
33
34 #include "bindings/core/v8/V8AnimationEffect.h"
35 #include "bindings/core/v8/V8AnimationPlayer.h"
36 #include "gen/sky/platform/RuntimeEnabledFeatures.h"
37 #include "sky/engine/bindings/core/v8/Dictionary.h"
38 #include "sky/engine/bindings/core/v8/ExceptionState.h"
39 #include "sky/engine/bindings/core/v8/V8Binding.h"
40 #include "sky/engine/bindings/core/v8/V8BindingMacros.h"
41 #include "sky/engine/core/animation/ElementAnimation.h"
42 #include "sky/engine/core/dom/Element.h"
43 #include "sky/engine/wtf/GetPtr.h"
44
45 namespace blink {
46
47 ////////////////////////////////////////////////////////////////////////////////
48 // Overload resolution for animate()
49 // FIXME: needs support for union types http://crbug.com/240176
50 ////////////////////////////////////////////////////////////////////////////////
51
52 // AnimationPlayer animate(AnimationEffect? effect);
53 void animate1Method(const v8::FunctionCallbackInfo<v8::Value>& info)
54 {
55 Element* impl = V8Element::toNative(info.Holder());
56 TONATIVE_VOID(AnimationEffect*, effect, V8AnimationEffect::toNativeWithTypeC heck(info.GetIsolate(), info[0]));
57 v8SetReturnValueFast(info, WTF::getPtr(ElementAnimation::animate(*impl, effe ct)), impl);
58 }
59
60 // [RaisesException] AnimationPlayer animate(sequence<Dictionary> effect);
61 void animate2Method(const v8::FunctionCallbackInfo<v8::Value>& info)
62 {
63 ExceptionState exceptionState(ExceptionState::ExecutionContext, "animate", " Element", info.Holder(), info.GetIsolate());
64 Element* impl = V8Element::toNative(info.Holder());
65 TONATIVE_VOID(Vector<Dictionary>, keyframes, toNativeArray<Dictionary>(info[ 0], 1, info.GetIsolate()));
66 RefPtr<AnimationPlayer> result = ElementAnimation::animate(*impl, keyframes, exceptionState);
67 if (exceptionState.throwIfNeeded())
68 return;
69 v8SetReturnValueFast(info, WTF::getPtr(result.release()), impl);
70 }
71
72 // AnimationPlayer animate(AnimationEffect? effect, double timing);
73 void animate3Method(const v8::FunctionCallbackInfo<v8::Value>& info)
74 {
75 Element* impl = V8Element::toNative(info.Holder());
76 TONATIVE_VOID(AnimationEffect*, effect, V8AnimationEffect::toNativeWithTypeC heck(info.GetIsolate(), info[0]));
77 TONATIVE_VOID(double, duration, static_cast<double>(info[1]->NumberValue())) ;
78 v8SetReturnValueFast(info, WTF::getPtr(ElementAnimation::animate(*impl, effe ct, duration)), impl);
79 }
80
81 // AnimationPlayer animate(AnimationEffect? effect, Dictionary timing);
82 void animate4Method(const v8::FunctionCallbackInfo<v8::Value>& info)
83 {
84 Element* impl = V8Element::toNative(info.Holder());
85 TONATIVE_VOID(AnimationEffect*, effect, V8AnimationEffect::toNativeWithTypeC heck(info.GetIsolate(), info[0]));
86 TONATIVE_VOID(Dictionary, timingInput, Dictionary(info[1], info.GetIsolate() ));
87 if (!timingInput.isUndefinedOrNull() && !timingInput.isObject()) {
88 V8ThrowException::throwTypeError(ExceptionMessages::failedToExecute("ani mate", "Element", "parameter 2 ('timingInput') is not an object."), info.GetIsol ate());
89 return;
90 }
91 v8SetReturnValueFast(info, WTF::getPtr(ElementAnimation::animate(*impl, effe ct, timingInput)), impl);
92 }
93
94 // [RaisesException] AnimationPlayer animate(sequence<Dictionary> effect, double timing);
95 void animate5Method(const v8::FunctionCallbackInfo<v8::Value>& info)
96 {
97 ExceptionState exceptionState(ExceptionState::ExecutionContext, "animate", " Element", info.Holder(), info.GetIsolate());
98 Element* impl = V8Element::toNative(info.Holder());
99 TONATIVE_VOID(Vector<Dictionary>, keyframes, toNativeArray<Dictionary>(info[ 0], 1, info.GetIsolate()));
100 TONATIVE_VOID(double, duration, static_cast<double>(info[1]->NumberValue())) ;
101 RefPtr<AnimationPlayer> result = ElementAnimation::animate(*impl, keyframes, duration, exceptionState);
102 if (exceptionState.throwIfNeeded())
103 return;
104 v8SetReturnValueFast(info, WTF::getPtr(result.release()), impl);
105 }
106
107 // [RaisesException] AnimationPlayer animate(sequence<Dictionary> effect, Dictio nary timing);
108 void animate6Method(const v8::FunctionCallbackInfo<v8::Value>& info)
109 {
110 ExceptionState exceptionState(ExceptionState::ExecutionContext, "animate", " Element", info.Holder(), info.GetIsolate());
111 Element* impl = V8Element::toNative(info.Holder());
112 TONATIVE_VOID(Vector<Dictionary>, keyframes, toNativeArray<Dictionary>(info[ 0], 1, info.GetIsolate()));
113 TONATIVE_VOID(Dictionary, timingInput, Dictionary(info[1], info.GetIsolate() ));
114 if (!timingInput.isUndefinedOrNull() && !timingInput.isObject()) {
115 exceptionState.throwTypeError("parameter 2 ('timingInput') is not an obj ect.");
116 exceptionState.throwIfNeeded();
117 return;
118 }
119 RefPtr<AnimationPlayer> result = ElementAnimation::animate(*impl, keyframes, timingInput, exceptionState);
120 if (exceptionState.throwIfNeeded())
121 return;
122 v8SetReturnValueFast(info, WTF::getPtr(result.release()), impl);
123 }
124
125 void V8Element::animateMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& i nfo)
126 {
127 v8::Isolate* isolate = info.GetIsolate();
128 ExceptionState exceptionState(ExceptionState::ExecutionContext, "animate", " Element", info.Holder(), isolate);
129 // AnimationPlayer animate(
130 // (AnimationEffect or sequence<Dictionary>)? effect,
131 // optional (double or Dictionary) timing);
132 switch (info.Length()) {
133 case 1:
134 // null resolved as to AnimationEffect, as if the member were nullable:
135 // (AnimationEffect? or sequence<Dictionary>)
136 // instead of the *union* being nullable:
137 // (AnimationEffect or sequence<Dictionary>)?
138 // AnimationPlayer animate(AnimationEffect? effect);
139 if (info[0]->IsNull()) {
140 animate1Method(info);
141 return;
142 }
143 // AnimationPlayer animate(AnimationEffect effect);
144 if (V8AnimationEffect::hasInstance(info[0], isolate)) {
145 animate1Method(info);
146 return;
147 }
148 // [MeasureAs=ElementAnimateKeyframeListEffectNoTiming]
149 // AnimationPlayer animate(sequence<Dictionary> effect);
150 if (info[0]->IsArray()) {
151 animate2Method(info);
152 return;
153 }
154 break;
155 case 2:
156 // As above, null resolved to AnimationEffect
157 // AnimationPlayer animate(AnimationEffect? effect, Dictionary timing);
158 if (info[0]->IsNull() && info[1]->IsObject()) {
159 animate4Method(info);
160 return;
161 }
162 // AnimationPlayer animate(AnimationEffect? effect, double timing);
163 if (info[0]->IsNull()) {
164 animate3Method(info);
165 return;
166 }
167 // AnimationPlayer animate(AnimationEffect effect, Dictionary timing);
168 if (V8AnimationEffect::hasInstance(info[0], isolate)
169 && info[1]->IsObject()) {
170 animate4Method(info);
171 return;
172 }
173 // AnimationPlayer animate(AnimationEffect effect, double timing);
174 if (V8AnimationEffect::hasInstance(info[0], isolate)) {
175 animate3Method(info);
176 return;
177 }
178 // [MeasureAs=ElementAnimateKeyframeListEffectObjectTiming]
179 // AnimationPlayer animate(sequence<Dictionary> effect, Dictionary timin g);
180 if (info[0]->IsArray() && info[1]->IsObject()) {
181 animate6Method(info);
182 return;
183 }
184 // [MeasureAs=ElementAnimateKeyframeListEffectDoubleTiming]
185 // AnimationPlayer animate(sequence<Dictionary> effect, double timing);
186 if (info[0]->IsArray()) {
187 animate5Method(info);
188 return;
189 }
190 break;
191 default:
192 setArityTypeError(exceptionState, "[1]", info.Length());
193 exceptionState.throwIfNeeded();
194 return;
195 break;
196 }
197 exceptionState.throwTypeError("No function was found that matched the signat ure provided.");
198 exceptionState.throwIfNeeded();
199 }
200
201 } // namespace blink
OLDNEW
« no previous file with comments | « sky/engine/bindings/core/v8/custom/V8DataViewCustom.cpp ('k') | sky/engine/bindings/core/v8/custom/V8ErrorEventCustom.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698