1 | /* |
2 | This file is part of the WebKit open source project. |
3 | This file has been generated by generate-bindings.pl. DO NOT MODIFY! |
4 | |
5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. |
9 | |
10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. |
14 | |
15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
18 | Boston, MA 02110-1301, USA. |
19 | */ |
20 | |
21 | #include "config.h" |
22 | #include "JSEffectTiming.h" |
23 | |
24 | #include "JSDOMConvertEnumeration.h" |
25 | #include "JSDOMConvertNumbers.h" |
26 | #include "JSDOMConvertStrings.h" |
27 | #include "JSDOMConvertUnion.h" |
28 | #include "JSDOMGlobalObject.h" |
29 | #include "JSFillMode.h" |
30 | #include "JSPlaybackDirection.h" |
31 | #include <JavaScriptCore/JSCInlines.h> |
32 | #include <JavaScriptCore/ObjectConstructor.h> |
33 | #include <wtf/Variant.h> |
34 | |
35 | |
36 | namespace WebCore { |
37 | using namespace JSC; |
38 | |
39 | template<> EffectTiming convertDictionary<EffectTiming>(ExecState& state, JSValue value) |
40 | { |
41 | VM& vm = state.vm(); |
42 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
43 | bool isNullOrUndefined = value.isUndefinedOrNull(); |
44 | auto* object = isNullOrUndefined ? nullptr : value.getObject(); |
45 | if (UNLIKELY(!isNullOrUndefined && !object)) { |
46 | throwTypeError(&state, throwScope); |
47 | return { }; |
48 | } |
49 | EffectTiming result; |
50 | JSValue delayValue; |
51 | if (isNullOrUndefined) |
52 | delayValue = jsUndefined(); |
53 | else { |
54 | delayValue = object->get(&state, Identifier::fromString(&state, "delay" )); |
55 | RETURN_IF_EXCEPTION(throwScope, { }); |
56 | } |
57 | if (!delayValue.isUndefined()) { |
58 | result.delay = convert<IDLDouble>(state, delayValue); |
59 | RETURN_IF_EXCEPTION(throwScope, { }); |
60 | } else |
61 | result.delay = 0; |
62 | JSValue directionValue; |
63 | if (isNullOrUndefined) |
64 | directionValue = jsUndefined(); |
65 | else { |
66 | directionValue = object->get(&state, Identifier::fromString(&state, "direction" )); |
67 | RETURN_IF_EXCEPTION(throwScope, { }); |
68 | } |
69 | if (!directionValue.isUndefined()) { |
70 | result.direction = convert<IDLEnumeration<PlaybackDirection>>(state, directionValue); |
71 | RETURN_IF_EXCEPTION(throwScope, { }); |
72 | } else |
73 | result.direction = PlaybackDirection::Normal; |
74 | JSValue durationValue; |
75 | if (isNullOrUndefined) |
76 | durationValue = jsUndefined(); |
77 | else { |
78 | durationValue = object->get(&state, Identifier::fromString(&state, "duration" )); |
79 | RETURN_IF_EXCEPTION(throwScope, { }); |
80 | } |
81 | if (!durationValue.isUndefined()) { |
82 | result.duration = convert<IDLUnion<IDLUnrestrictedDouble, IDLDOMString>>(state, durationValue); |
83 | RETURN_IF_EXCEPTION(throwScope, { }); |
84 | } else |
85 | result.duration = "auto" ; |
86 | JSValue easingValue; |
87 | if (isNullOrUndefined) |
88 | easingValue = jsUndefined(); |
89 | else { |
90 | easingValue = object->get(&state, Identifier::fromString(&state, "easing" )); |
91 | RETURN_IF_EXCEPTION(throwScope, { }); |
92 | } |
93 | if (!easingValue.isUndefined()) { |
94 | result.easing = convert<IDLDOMString>(state, easingValue); |
95 | RETURN_IF_EXCEPTION(throwScope, { }); |
96 | } else |
97 | result.easing = "linear"_s ; |
98 | JSValue endDelayValue; |
99 | if (isNullOrUndefined) |
100 | endDelayValue = jsUndefined(); |
101 | else { |
102 | endDelayValue = object->get(&state, Identifier::fromString(&state, "endDelay" )); |
103 | RETURN_IF_EXCEPTION(throwScope, { }); |
104 | } |
105 | if (!endDelayValue.isUndefined()) { |
106 | result.endDelay = convert<IDLDouble>(state, endDelayValue); |
107 | RETURN_IF_EXCEPTION(throwScope, { }); |
108 | } else |
109 | result.endDelay = 0; |
110 | JSValue fillValue; |
111 | if (isNullOrUndefined) |
112 | fillValue = jsUndefined(); |
113 | else { |
114 | fillValue = object->get(&state, Identifier::fromString(&state, "fill" )); |
115 | RETURN_IF_EXCEPTION(throwScope, { }); |
116 | } |
117 | if (!fillValue.isUndefined()) { |
118 | result.fill = convert<IDLEnumeration<FillMode>>(state, fillValue); |
119 | RETURN_IF_EXCEPTION(throwScope, { }); |
120 | } else |
121 | result.fill = FillMode::Auto; |
122 | JSValue iterationStartValue; |
123 | if (isNullOrUndefined) |
124 | iterationStartValue = jsUndefined(); |
125 | else { |
126 | iterationStartValue = object->get(&state, Identifier::fromString(&state, "iterationStart" )); |
127 | RETURN_IF_EXCEPTION(throwScope, { }); |
128 | } |
129 | if (!iterationStartValue.isUndefined()) { |
130 | result.iterationStart = convert<IDLDouble>(state, iterationStartValue); |
131 | RETURN_IF_EXCEPTION(throwScope, { }); |
132 | } else |
133 | result.iterationStart = 0.0; |
134 | JSValue iterationsValue; |
135 | if (isNullOrUndefined) |
136 | iterationsValue = jsUndefined(); |
137 | else { |
138 | iterationsValue = object->get(&state, Identifier::fromString(&state, "iterations" )); |
139 | RETURN_IF_EXCEPTION(throwScope, { }); |
140 | } |
141 | if (!iterationsValue.isUndefined()) { |
142 | result.iterations = convert<IDLUnrestrictedDouble>(state, iterationsValue); |
143 | RETURN_IF_EXCEPTION(throwScope, { }); |
144 | } else |
145 | result.iterations = 1.0; |
146 | return result; |
147 | } |
148 | |
149 | JSC::JSObject* convertDictionaryToJS(JSC::ExecState& state, JSDOMGlobalObject& globalObject, const EffectTiming& dictionary) |
150 | { |
151 | auto& vm = state.vm(); |
152 | |
153 | auto result = constructEmptyObject(&state, globalObject.objectPrototype()); |
154 | |
155 | auto delayValue = toJS<IDLDouble>(dictionary.delay); |
156 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "delay" ), delayValue); |
157 | auto directionValue = toJS<IDLEnumeration<PlaybackDirection>>(state, dictionary.direction); |
158 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "direction" ), directionValue); |
159 | auto durationValue = toJS<IDLUnion<IDLUnrestrictedDouble, IDLDOMString>>(state, globalObject, dictionary.duration); |
160 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "duration" ), durationValue); |
161 | auto easingValue = toJS<IDLDOMString>(state, dictionary.easing); |
162 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "easing" ), easingValue); |
163 | auto endDelayValue = toJS<IDLDouble>(dictionary.endDelay); |
164 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "endDelay" ), endDelayValue); |
165 | auto fillValue = toJS<IDLEnumeration<FillMode>>(state, dictionary.fill); |
166 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "fill" ), fillValue); |
167 | auto iterationStartValue = toJS<IDLDouble>(dictionary.iterationStart); |
168 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "iterationStart" ), iterationStartValue); |
169 | auto iterationsValue = toJS<IDLUnrestrictedDouble>(dictionary.iterations); |
170 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "iterations" ), iterationsValue); |
171 | return result; |
172 | } |
173 | |
174 | } // namespace WebCore |
175 | |