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 "JSMouseEventInit.h"
23
24#include "JSDOMConvertBoolean.h"
25#include "JSDOMConvertInterface.h"
26#include "JSDOMConvertNullable.h"
27#include "JSDOMConvertNumbers.h"
28#include "JSEventTarget.h"
29#include "JSWindowProxy.h"
30#include <JavaScriptCore/JSCInlines.h>
31
32
33namespace WebCore {
34using namespace JSC;
35
36template<> MouseEventInit convertDictionary<MouseEventInit>(ExecState& state, JSValue value)
37{
38 VM& vm = state.vm();
39 auto throwScope = DECLARE_THROW_SCOPE(vm);
40 bool isNullOrUndefined = value.isUndefinedOrNull();
41 auto* object = isNullOrUndefined ? nullptr : value.getObject();
42 if (UNLIKELY(!isNullOrUndefined && !object)) {
43 throwTypeError(&state, throwScope);
44 return { };
45 }
46 MouseEventInit result;
47 JSValue bubblesValue;
48 if (isNullOrUndefined)
49 bubblesValue = jsUndefined();
50 else {
51 bubblesValue = object->get(&state, Identifier::fromString(&state, "bubbles"));
52 RETURN_IF_EXCEPTION(throwScope, { });
53 }
54 if (!bubblesValue.isUndefined()) {
55 result.bubbles = convert<IDLBoolean>(state, bubblesValue);
56 RETURN_IF_EXCEPTION(throwScope, { });
57 } else
58 result.bubbles = false;
59 JSValue cancelableValue;
60 if (isNullOrUndefined)
61 cancelableValue = jsUndefined();
62 else {
63 cancelableValue = object->get(&state, Identifier::fromString(&state, "cancelable"));
64 RETURN_IF_EXCEPTION(throwScope, { });
65 }
66 if (!cancelableValue.isUndefined()) {
67 result.cancelable = convert<IDLBoolean>(state, cancelableValue);
68 RETURN_IF_EXCEPTION(throwScope, { });
69 } else
70 result.cancelable = false;
71 JSValue composedValue;
72 if (isNullOrUndefined)
73 composedValue = jsUndefined();
74 else {
75 composedValue = object->get(&state, Identifier::fromString(&state, "composed"));
76 RETURN_IF_EXCEPTION(throwScope, { });
77 }
78 if (!composedValue.isUndefined()) {
79 result.composed = convert<IDLBoolean>(state, composedValue);
80 RETURN_IF_EXCEPTION(throwScope, { });
81 } else
82 result.composed = false;
83 JSValue detailValue;
84 if (isNullOrUndefined)
85 detailValue = jsUndefined();
86 else {
87 detailValue = object->get(&state, Identifier::fromString(&state, "detail"));
88 RETURN_IF_EXCEPTION(throwScope, { });
89 }
90 if (!detailValue.isUndefined()) {
91 result.detail = convert<IDLLong>(state, detailValue);
92 RETURN_IF_EXCEPTION(throwScope, { });
93 } else
94 result.detail = 0;
95 JSValue viewValue;
96 if (isNullOrUndefined)
97 viewValue = jsUndefined();
98 else {
99 viewValue = object->get(&state, Identifier::fromString(&state, "view"));
100 RETURN_IF_EXCEPTION(throwScope, { });
101 }
102 if (!viewValue.isUndefined()) {
103 result.view = convert<IDLNullable<IDLInterface<WindowProxy>>>(state, viewValue);
104 RETURN_IF_EXCEPTION(throwScope, { });
105 } else
106 result.view = nullptr;
107 JSValue altKeyValue;
108 if (isNullOrUndefined)
109 altKeyValue = jsUndefined();
110 else {
111 altKeyValue = object->get(&state, Identifier::fromString(&state, "altKey"));
112 RETURN_IF_EXCEPTION(throwScope, { });
113 }
114 if (!altKeyValue.isUndefined()) {
115 result.altKey = convert<IDLBoolean>(state, altKeyValue);
116 RETURN_IF_EXCEPTION(throwScope, { });
117 } else
118 result.altKey = false;
119 JSValue ctrlKeyValue;
120 if (isNullOrUndefined)
121 ctrlKeyValue = jsUndefined();
122 else {
123 ctrlKeyValue = object->get(&state, Identifier::fromString(&state, "ctrlKey"));
124 RETURN_IF_EXCEPTION(throwScope, { });
125 }
126 if (!ctrlKeyValue.isUndefined()) {
127 result.ctrlKey = convert<IDLBoolean>(state, ctrlKeyValue);
128 RETURN_IF_EXCEPTION(throwScope, { });
129 } else
130 result.ctrlKey = false;
131 JSValue metaKeyValue;
132 if (isNullOrUndefined)
133 metaKeyValue = jsUndefined();
134 else {
135 metaKeyValue = object->get(&state, Identifier::fromString(&state, "metaKey"));
136 RETURN_IF_EXCEPTION(throwScope, { });
137 }
138 if (!metaKeyValue.isUndefined()) {
139 result.metaKey = convert<IDLBoolean>(state, metaKeyValue);
140 RETURN_IF_EXCEPTION(throwScope, { });
141 } else
142 result.metaKey = false;
143 JSValue modifierAltGraphValue;
144 if (isNullOrUndefined)
145 modifierAltGraphValue = jsUndefined();
146 else {
147 modifierAltGraphValue = object->get(&state, Identifier::fromString(&state, "modifierAltGraph"));
148 RETURN_IF_EXCEPTION(throwScope, { });
149 }
150 if (!modifierAltGraphValue.isUndefined()) {
151 result.modifierAltGraph = convert<IDLBoolean>(state, modifierAltGraphValue);
152 RETURN_IF_EXCEPTION(throwScope, { });
153 } else
154 result.modifierAltGraph = false;
155 JSValue modifierCapsLockValue;
156 if (isNullOrUndefined)
157 modifierCapsLockValue = jsUndefined();
158 else {
159 modifierCapsLockValue = object->get(&state, Identifier::fromString(&state, "modifierCapsLock"));
160 RETURN_IF_EXCEPTION(throwScope, { });
161 }
162 if (!modifierCapsLockValue.isUndefined()) {
163 result.modifierCapsLock = convert<IDLBoolean>(state, modifierCapsLockValue);
164 RETURN_IF_EXCEPTION(throwScope, { });
165 } else
166 result.modifierCapsLock = false;
167 JSValue shiftKeyValue;
168 if (isNullOrUndefined)
169 shiftKeyValue = jsUndefined();
170 else {
171 shiftKeyValue = object->get(&state, Identifier::fromString(&state, "shiftKey"));
172 RETURN_IF_EXCEPTION(throwScope, { });
173 }
174 if (!shiftKeyValue.isUndefined()) {
175 result.shiftKey = convert<IDLBoolean>(state, shiftKeyValue);
176 RETURN_IF_EXCEPTION(throwScope, { });
177 } else
178 result.shiftKey = false;
179 JSValue buttonValue;
180 if (isNullOrUndefined)
181 buttonValue = jsUndefined();
182 else {
183 buttonValue = object->get(&state, Identifier::fromString(&state, "button"));
184 RETURN_IF_EXCEPTION(throwScope, { });
185 }
186 if (!buttonValue.isUndefined()) {
187 result.button = convert<IDLUnsignedShort>(state, buttonValue);
188 RETURN_IF_EXCEPTION(throwScope, { });
189 } else
190 result.button = 0;
191 JSValue buttonsValue;
192 if (isNullOrUndefined)
193 buttonsValue = jsUndefined();
194 else {
195 buttonsValue = object->get(&state, Identifier::fromString(&state, "buttons"));
196 RETURN_IF_EXCEPTION(throwScope, { });
197 }
198 if (!buttonsValue.isUndefined()) {
199 result.buttons = convert<IDLUnsignedShort>(state, buttonsValue);
200 RETURN_IF_EXCEPTION(throwScope, { });
201 } else
202 result.buttons = 0;
203 JSValue clientXValue;
204 if (isNullOrUndefined)
205 clientXValue = jsUndefined();
206 else {
207 clientXValue = object->get(&state, Identifier::fromString(&state, "clientX"));
208 RETURN_IF_EXCEPTION(throwScope, { });
209 }
210 if (!clientXValue.isUndefined()) {
211 result.clientX = convert<IDLLong>(state, clientXValue);
212 RETURN_IF_EXCEPTION(throwScope, { });
213 } else
214 result.clientX = 0;
215 JSValue clientYValue;
216 if (isNullOrUndefined)
217 clientYValue = jsUndefined();
218 else {
219 clientYValue = object->get(&state, Identifier::fromString(&state, "clientY"));
220 RETURN_IF_EXCEPTION(throwScope, { });
221 }
222 if (!clientYValue.isUndefined()) {
223 result.clientY = convert<IDLLong>(state, clientYValue);
224 RETURN_IF_EXCEPTION(throwScope, { });
225 } else
226 result.clientY = 0;
227 JSValue relatedTargetValue;
228 if (isNullOrUndefined)
229 relatedTargetValue = jsUndefined();
230 else {
231 relatedTargetValue = object->get(&state, Identifier::fromString(&state, "relatedTarget"));
232 RETURN_IF_EXCEPTION(throwScope, { });
233 }
234 if (!relatedTargetValue.isUndefined()) {
235 result.relatedTarget = convert<IDLNullable<IDLInterface<EventTarget>>>(state, relatedTargetValue);
236 RETURN_IF_EXCEPTION(throwScope, { });
237 } else
238 result.relatedTarget = nullptr;
239 JSValue screenXValue;
240 if (isNullOrUndefined)
241 screenXValue = jsUndefined();
242 else {
243 screenXValue = object->get(&state, Identifier::fromString(&state, "screenX"));
244 RETURN_IF_EXCEPTION(throwScope, { });
245 }
246 if (!screenXValue.isUndefined()) {
247 result.screenX = convert<IDLLong>(state, screenXValue);
248 RETURN_IF_EXCEPTION(throwScope, { });
249 } else
250 result.screenX = 0;
251 JSValue screenYValue;
252 if (isNullOrUndefined)
253 screenYValue = jsUndefined();
254 else {
255 screenYValue = object->get(&state, Identifier::fromString(&state, "screenY"));
256 RETURN_IF_EXCEPTION(throwScope, { });
257 }
258 if (!screenYValue.isUndefined()) {
259 result.screenY = convert<IDLLong>(state, screenYValue);
260 RETURN_IF_EXCEPTION(throwScope, { });
261 } else
262 result.screenY = 0;
263 return result;
264}
265
266} // namespace WebCore
267