| 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 "JSComputedEffectTiming.h" |
| 23 | |
| 24 | #include "JSDOMConvertEnumeration.h" |
| 25 | #include "JSDOMConvertNullable.h" |
| 26 | #include "JSDOMConvertNumbers.h" |
| 27 | #include "JSDOMConvertStrings.h" |
| 28 | #include "JSDOMConvertUnion.h" |
| 29 | #include "JSDOMGlobalObject.h" |
| 30 | #include "JSFillMode.h" |
| 31 | #include "JSPlaybackDirection.h" |
| 32 | #include <JavaScriptCore/JSCInlines.h> |
| 33 | #include <JavaScriptCore/ObjectConstructor.h> |
| 34 | #include <wtf/Variant.h> |
| 35 | |
| 36 | |
| 37 | namespace WebCore { |
| 38 | using namespace JSC; |
| 39 | |
| 40 | template<> ComputedEffectTiming convertDictionary<ComputedEffectTiming>(ExecState& state, JSValue value) |
| 41 | { |
| 42 | VM& vm = state.vm(); |
| 43 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 44 | bool isNullOrUndefined = value.isUndefinedOrNull(); |
| 45 | auto* object = isNullOrUndefined ? nullptr : value.getObject(); |
| 46 | if (UNLIKELY(!isNullOrUndefined && !object)) { |
| 47 | throwTypeError(&state, throwScope); |
| 48 | return { }; |
| 49 | } |
| 50 | ComputedEffectTiming result; |
| 51 | JSValue delayValue; |
| 52 | if (isNullOrUndefined) |
| 53 | delayValue = jsUndefined(); |
| 54 | else { |
| 55 | delayValue = object->get(&state, Identifier::fromString(&state, "delay" )); |
| 56 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 57 | } |
| 58 | if (!delayValue.isUndefined()) { |
| 59 | result.delay = convert<IDLDouble>(state, delayValue); |
| 60 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 61 | } else |
| 62 | result.delay = 0; |
| 63 | JSValue directionValue; |
| 64 | if (isNullOrUndefined) |
| 65 | directionValue = jsUndefined(); |
| 66 | else { |
| 67 | directionValue = object->get(&state, Identifier::fromString(&state, "direction" )); |
| 68 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 69 | } |
| 70 | if (!directionValue.isUndefined()) { |
| 71 | result.direction = convert<IDLEnumeration<PlaybackDirection>>(state, directionValue); |
| 72 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 73 | } else |
| 74 | result.direction = PlaybackDirection::Normal; |
| 75 | JSValue durationValue; |
| 76 | if (isNullOrUndefined) |
| 77 | durationValue = jsUndefined(); |
| 78 | else { |
| 79 | durationValue = object->get(&state, Identifier::fromString(&state, "duration" )); |
| 80 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 81 | } |
| 82 | if (!durationValue.isUndefined()) { |
| 83 | result.duration = convert<IDLUnion<IDLUnrestrictedDouble, IDLDOMString>>(state, durationValue); |
| 84 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 85 | } else |
| 86 | result.duration = "auto" ; |
| 87 | JSValue easingValue; |
| 88 | if (isNullOrUndefined) |
| 89 | easingValue = jsUndefined(); |
| 90 | else { |
| 91 | easingValue = object->get(&state, Identifier::fromString(&state, "easing" )); |
| 92 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 93 | } |
| 94 | if (!easingValue.isUndefined()) { |
| 95 | result.easing = convert<IDLDOMString>(state, easingValue); |
| 96 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 97 | } else |
| 98 | result.easing = "linear"_s ; |
| 99 | JSValue endDelayValue; |
| 100 | if (isNullOrUndefined) |
| 101 | endDelayValue = jsUndefined(); |
| 102 | else { |
| 103 | endDelayValue = object->get(&state, Identifier::fromString(&state, "endDelay" )); |
| 104 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 105 | } |
| 106 | if (!endDelayValue.isUndefined()) { |
| 107 | result.endDelay = convert<IDLDouble>(state, endDelayValue); |
| 108 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 109 | } else |
| 110 | result.endDelay = 0; |
| 111 | JSValue fillValue; |
| 112 | if (isNullOrUndefined) |
| 113 | fillValue = jsUndefined(); |
| 114 | else { |
| 115 | fillValue = object->get(&state, Identifier::fromString(&state, "fill" )); |
| 116 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 117 | } |
| 118 | if (!fillValue.isUndefined()) { |
| 119 | result.fill = convert<IDLEnumeration<FillMode>>(state, fillValue); |
| 120 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 121 | } else |
| 122 | result.fill = FillMode::Auto; |
| 123 | JSValue iterationStartValue; |
| 124 | if (isNullOrUndefined) |
| 125 | iterationStartValue = jsUndefined(); |
| 126 | else { |
| 127 | iterationStartValue = object->get(&state, Identifier::fromString(&state, "iterationStart" )); |
| 128 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 129 | } |
| 130 | if (!iterationStartValue.isUndefined()) { |
| 131 | result.iterationStart = convert<IDLDouble>(state, iterationStartValue); |
| 132 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 133 | } else |
| 134 | result.iterationStart = 0.0; |
| 135 | JSValue iterationsValue; |
| 136 | if (isNullOrUndefined) |
| 137 | iterationsValue = jsUndefined(); |
| 138 | else { |
| 139 | iterationsValue = object->get(&state, Identifier::fromString(&state, "iterations" )); |
| 140 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 141 | } |
| 142 | if (!iterationsValue.isUndefined()) { |
| 143 | result.iterations = convert<IDLUnrestrictedDouble>(state, iterationsValue); |
| 144 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 145 | } else |
| 146 | result.iterations = 1.0; |
| 147 | JSValue activeDurationValue; |
| 148 | if (isNullOrUndefined) |
| 149 | activeDurationValue = jsUndefined(); |
| 150 | else { |
| 151 | activeDurationValue = object->get(&state, Identifier::fromString(&state, "activeDuration" )); |
| 152 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 153 | } |
| 154 | if (!activeDurationValue.isUndefined()) { |
| 155 | result.activeDuration = convert<IDLUnrestrictedDouble>(state, activeDurationValue); |
| 156 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 157 | } |
| 158 | JSValue currentIterationValue; |
| 159 | if (isNullOrUndefined) |
| 160 | currentIterationValue = jsUndefined(); |
| 161 | else { |
| 162 | currentIterationValue = object->get(&state, Identifier::fromString(&state, "currentIteration" )); |
| 163 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 164 | } |
| 165 | if (!currentIterationValue.isUndefined()) { |
| 166 | result.currentIteration = convert<IDLNullable<IDLUnrestrictedDouble>>(state, currentIterationValue); |
| 167 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 168 | } else |
| 169 | result.currentIteration = WTF::nullopt; |
| 170 | JSValue endTimeValue; |
| 171 | if (isNullOrUndefined) |
| 172 | endTimeValue = jsUndefined(); |
| 173 | else { |
| 174 | endTimeValue = object->get(&state, Identifier::fromString(&state, "endTime" )); |
| 175 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 176 | } |
| 177 | if (!endTimeValue.isUndefined()) { |
| 178 | result.endTime = convert<IDLUnrestrictedDouble>(state, endTimeValue); |
| 179 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 180 | } |
| 181 | JSValue localTimeValue; |
| 182 | if (isNullOrUndefined) |
| 183 | localTimeValue = jsUndefined(); |
| 184 | else { |
| 185 | localTimeValue = object->get(&state, Identifier::fromString(&state, "localTime" )); |
| 186 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 187 | } |
| 188 | if (!localTimeValue.isUndefined()) { |
| 189 | result.localTime = convert<IDLNullable<IDLDouble>>(state, localTimeValue); |
| 190 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 191 | } else |
| 192 | result.localTime = WTF::nullopt; |
| 193 | JSValue progressValue; |
| 194 | if (isNullOrUndefined) |
| 195 | progressValue = jsUndefined(); |
| 196 | else { |
| 197 | progressValue = object->get(&state, Identifier::fromString(&state, "progress" )); |
| 198 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 199 | } |
| 200 | if (!progressValue.isUndefined()) { |
| 201 | result.progress = convert<IDLNullable<IDLDouble>>(state, progressValue); |
| 202 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 203 | } else |
| 204 | result.progress = WTF::nullopt; |
| 205 | return result; |
| 206 | } |
| 207 | |
| 208 | JSC::JSObject* convertDictionaryToJS(JSC::ExecState& state, JSDOMGlobalObject& globalObject, const ComputedEffectTiming& dictionary) |
| 209 | { |
| 210 | auto& vm = state.vm(); |
| 211 | |
| 212 | auto result = constructEmptyObject(&state, globalObject.objectPrototype()); |
| 213 | |
| 214 | auto delayValue = toJS<IDLDouble>(dictionary.delay); |
| 215 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "delay" ), delayValue); |
| 216 | auto directionValue = toJS<IDLEnumeration<PlaybackDirection>>(state, dictionary.direction); |
| 217 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "direction" ), directionValue); |
| 218 | auto durationValue = toJS<IDLUnion<IDLUnrestrictedDouble, IDLDOMString>>(state, globalObject, dictionary.duration); |
| 219 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "duration" ), durationValue); |
| 220 | auto easingValue = toJS<IDLDOMString>(state, dictionary.easing); |
| 221 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "easing" ), easingValue); |
| 222 | auto endDelayValue = toJS<IDLDouble>(dictionary.endDelay); |
| 223 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "endDelay" ), endDelayValue); |
| 224 | auto fillValue = toJS<IDLEnumeration<FillMode>>(state, dictionary.fill); |
| 225 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "fill" ), fillValue); |
| 226 | auto iterationStartValue = toJS<IDLDouble>(dictionary.iterationStart); |
| 227 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "iterationStart" ), iterationStartValue); |
| 228 | auto iterationsValue = toJS<IDLUnrestrictedDouble>(dictionary.iterations); |
| 229 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "iterations" ), iterationsValue); |
| 230 | if (!IDLUnrestrictedDouble::isNullValue(dictionary.activeDuration)) { |
| 231 | auto activeDurationValue = toJS<IDLUnrestrictedDouble>(IDLUnrestrictedDouble::extractValueFromNullable(dictionary.activeDuration)); |
| 232 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "activeDuration" ), activeDurationValue); |
| 233 | } |
| 234 | auto currentIterationValue = toJS<IDLNullable<IDLUnrestrictedDouble>>(dictionary.currentIteration); |
| 235 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "currentIteration" ), currentIterationValue); |
| 236 | if (!IDLUnrestrictedDouble::isNullValue(dictionary.endTime)) { |
| 237 | auto endTimeValue = toJS<IDLUnrestrictedDouble>(IDLUnrestrictedDouble::extractValueFromNullable(dictionary.endTime)); |
| 238 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "endTime" ), endTimeValue); |
| 239 | } |
| 240 | auto localTimeValue = toJS<IDLNullable<IDLDouble>>(dictionary.localTime); |
| 241 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "localTime" ), localTimeValue); |
| 242 | auto progressValue = toJS<IDLNullable<IDLDouble>>(dictionary.progress); |
| 243 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "progress" ), progressValue); |
| 244 | return result; |
| 245 | } |
| 246 | |
| 247 | } // namespace WebCore |
| 248 | |