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 "JSEventModifierInit.h"
23
24#include "JSDOMConvertBoolean.h"
25#include "JSDOMConvertInterface.h"
26#include "JSDOMConvertNullable.h"
27#include "JSDOMConvertNumbers.h"
28#include "JSWindowProxy.h"
29#include <JavaScriptCore/JSCInlines.h>
30
31
32namespace WebCore {
33using namespace JSC;
34
35template<> EventModifierInit convertDictionary<EventModifierInit>(ExecState& state, JSValue value)
36{
37 VM& vm = state.vm();
38 auto throwScope = DECLARE_THROW_SCOPE(vm);
39 bool isNullOrUndefined = value.isUndefinedOrNull();
40 auto* object = isNullOrUndefined ? nullptr : value.getObject();
41 if (UNLIKELY(!isNullOrUndefined && !object)) {
42 throwTypeError(&state, throwScope);
43 return { };
44 }
45 EventModifierInit result;
46 JSValue bubblesValue;
47 if (isNullOrUndefined)
48 bubblesValue = jsUndefined();
49 else {
50 bubblesValue = object->get(&state, Identifier::fromString(&state, "bubbles"));
51 RETURN_IF_EXCEPTION(throwScope, { });
52 }
53 if (!bubblesValue.isUndefined()) {
54 result.bubbles = convert<IDLBoolean>(state, bubblesValue);
55 RETURN_IF_EXCEPTION(throwScope, { });
56 } else
57 result.bubbles = false;
58 JSValue cancelableValue;
59 if (isNullOrUndefined)
60 cancelableValue = jsUndefined();
61 else {
62 cancelableValue = object->get(&state, Identifier::fromString(&state, "cancelable"));
63 RETURN_IF_EXCEPTION(throwScope, { });
64 }
65 if (!cancelableValue.isUndefined()) {
66 result.cancelable = convert<IDLBoolean>(state, cancelableValue);
67 RETURN_IF_EXCEPTION(throwScope, { });
68 } else
69 result.cancelable = false;
70 JSValue composedValue;
71 if (isNullOrUndefined)
72 composedValue = jsUndefined();
73 else {
74 composedValue = object->get(&state, Identifier::fromString(&state, "composed"));
75 RETURN_IF_EXCEPTION(throwScope, { });
76 }
77 if (!composedValue.isUndefined()) {
78 result.composed = convert<IDLBoolean>(state, composedValue);
79 RETURN_IF_EXCEPTION(throwScope, { });
80 } else
81 result.composed = false;
82 JSValue detailValue;
83 if (isNullOrUndefined)
84 detailValue = jsUndefined();
85 else {
86 detailValue = object->get(&state, Identifier::fromString(&state, "detail"));
87 RETURN_IF_EXCEPTION(throwScope, { });
88 }
89 if (!detailValue.isUndefined()) {
90 result.detail = convert<IDLLong>(state, detailValue);
91 RETURN_IF_EXCEPTION(throwScope, { });
92 } else
93 result.detail = 0;
94 JSValue viewValue;
95 if (isNullOrUndefined)
96 viewValue = jsUndefined();
97 else {
98 viewValue = object->get(&state, Identifier::fromString(&state, "view"));
99 RETURN_IF_EXCEPTION(throwScope, { });
100 }
101 if (!viewValue.isUndefined()) {
102 result.view = convert<IDLNullable<IDLInterface<WindowProxy>>>(state, viewValue);
103 RETURN_IF_EXCEPTION(throwScope, { });
104 } else
105 result.view = nullptr;
106 JSValue altKeyValue;
107 if (isNullOrUndefined)
108 altKeyValue = jsUndefined();
109 else {
110 altKeyValue = object->get(&state, Identifier::fromString(&state, "altKey"));
111 RETURN_IF_EXCEPTION(throwScope, { });
112 }
113 if (!altKeyValue.isUndefined()) {
114 result.altKey = convert<IDLBoolean>(state, altKeyValue);
115 RETURN_IF_EXCEPTION(throwScope, { });
116 } else
117 result.altKey = false;
118 JSValue ctrlKeyValue;
119 if (isNullOrUndefined)
120 ctrlKeyValue = jsUndefined();
121 else {
122 ctrlKeyValue = object->get(&state, Identifier::fromString(&state, "ctrlKey"));
123 RETURN_IF_EXCEPTION(throwScope, { });
124 }
125 if (!ctrlKeyValue.isUndefined()) {
126 result.ctrlKey = convert<IDLBoolean>(state, ctrlKeyValue);
127 RETURN_IF_EXCEPTION(throwScope, { });
128 } else
129 result.ctrlKey = false;
130 JSValue metaKeyValue;
131 if (isNullOrUndefined)
132 metaKeyValue = jsUndefined();
133 else {
134 metaKeyValue = object->get(&state, Identifier::fromString(&state, "metaKey"));
135 RETURN_IF_EXCEPTION(throwScope, { });
136 }
137 if (!metaKeyValue.isUndefined()) {
138 result.metaKey = convert<IDLBoolean>(state, metaKeyValue);
139 RETURN_IF_EXCEPTION(throwScope, { });
140 } else
141 result.metaKey = false;
142 JSValue modifierAltGraphValue;
143 if (isNullOrUndefined)
144 modifierAltGraphValue = jsUndefined();
145 else {
146 modifierAltGraphValue = object->get(&state, Identifier::fromString(&state, "modifierAltGraph"));
147 RETURN_IF_EXCEPTION(throwScope, { });
148 }
149 if (!modifierAltGraphValue.isUndefined()) {
150 result.modifierAltGraph = convert<IDLBoolean>(state, modifierAltGraphValue);
151 RETURN_IF_EXCEPTION(throwScope, { });
152 } else
153 result.modifierAltGraph = false;
154 JSValue modifierCapsLockValue;
155 if (isNullOrUndefined)
156 modifierCapsLockValue = jsUndefined();
157 else {
158 modifierCapsLockValue = object->get(&state, Identifier::fromString(&state, "modifierCapsLock"));
159 RETURN_IF_EXCEPTION(throwScope, { });
160 }
161 if (!modifierCapsLockValue.isUndefined()) {
162 result.modifierCapsLock = convert<IDLBoolean>(state, modifierCapsLockValue);
163 RETURN_IF_EXCEPTION(throwScope, { });
164 } else
165 result.modifierCapsLock = false;
166 JSValue shiftKeyValue;
167 if (isNullOrUndefined)
168 shiftKeyValue = jsUndefined();
169 else {
170 shiftKeyValue = object->get(&state, Identifier::fromString(&state, "shiftKey"));
171 RETURN_IF_EXCEPTION(throwScope, { });
172 }
173 if (!shiftKeyValue.isUndefined()) {
174 result.shiftKey = convert<IDLBoolean>(state, shiftKeyValue);
175 RETURN_IF_EXCEPTION(throwScope, { });
176 } else
177 result.shiftKey = false;
178 return result;
179}
180
181} // namespace WebCore
182