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 "JSScreen.h"
23
24#include "JSDOMAttribute.h"
25#include "JSDOMBinding.h"
26#include "JSDOMConstructorNotConstructable.h"
27#include "JSDOMConvertNumbers.h"
28#include "JSDOMExceptionHandling.h"
29#include "JSDOMWrapperCache.h"
30#include "ScriptExecutionContext.h"
31#include <JavaScriptCore/FunctionPrototype.h>
32#include <JavaScriptCore/HeapSnapshotBuilder.h>
33#include <JavaScriptCore/JSCInlines.h>
34#include <wtf/GetPtr.h>
35#include <wtf/PointerPreparations.h>
36#include <wtf/URL.h>
37
38
39namespace WebCore {
40using namespace JSC;
41
42// Attributes
43
44JSC::EncodedJSValue jsScreenConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
45bool setJSScreenConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
46JSC::EncodedJSValue jsScreenHeight(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
47JSC::EncodedJSValue jsScreenWidth(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
48JSC::EncodedJSValue jsScreenColorDepth(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
49JSC::EncodedJSValue jsScreenPixelDepth(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
50JSC::EncodedJSValue jsScreenAvailLeft(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
51JSC::EncodedJSValue jsScreenAvailTop(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
52JSC::EncodedJSValue jsScreenAvailHeight(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
53JSC::EncodedJSValue jsScreenAvailWidth(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
54
55class JSScreenPrototype : public JSC::JSNonFinalObject {
56public:
57 using Base = JSC::JSNonFinalObject;
58 static JSScreenPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure)
59 {
60 JSScreenPrototype* ptr = new (NotNull, JSC::allocateCell<JSScreenPrototype>(vm.heap)) JSScreenPrototype(vm, globalObject, structure);
61 ptr->finishCreation(vm);
62 return ptr;
63 }
64
65 DECLARE_INFO;
66 static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
67 {
68 return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
69 }
70
71private:
72 JSScreenPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
73 : JSC::JSNonFinalObject(vm, structure)
74 {
75 }
76
77 void finishCreation(JSC::VM&);
78};
79
80using JSScreenConstructor = JSDOMConstructorNotConstructable<JSScreen>;
81
82template<> JSValue JSScreenConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
83{
84 UNUSED_PARAM(vm);
85 return globalObject.functionPrototype();
86}
87
88template<> void JSScreenConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
89{
90 putDirect(vm, vm.propertyNames->prototype, JSScreen::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
91 putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("Screen"_s)), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
92 putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
93}
94
95template<> const ClassInfo JSScreenConstructor::s_info = { "Screen", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSScreenConstructor) };
96
97/* Hash table for prototype */
98
99static const HashTableValue JSScreenPrototypeTableValues[] =
100{
101 { "constructor", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsScreenConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSScreenConstructor) } },
102 { "height", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsScreenHeight), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
103 { "width", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsScreenWidth), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
104 { "colorDepth", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsScreenColorDepth), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
105 { "pixelDepth", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsScreenPixelDepth), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
106 { "availLeft", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsScreenAvailLeft), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
107 { "availTop", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsScreenAvailTop), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
108 { "availHeight", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsScreenAvailHeight), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
109 { "availWidth", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsScreenAvailWidth), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
110};
111
112const ClassInfo JSScreenPrototype::s_info = { "ScreenPrototype", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSScreenPrototype) };
113
114void JSScreenPrototype::finishCreation(VM& vm)
115{
116 Base::finishCreation(vm);
117 reifyStaticProperties(vm, JSScreen::info(), JSScreenPrototypeTableValues, *this);
118}
119
120const ClassInfo JSScreen::s_info = { "Screen", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSScreen) };
121
122JSScreen::JSScreen(Structure* structure, JSDOMGlobalObject& globalObject, Ref<Screen>&& impl)
123 : JSDOMWrapper<Screen>(structure, globalObject, WTFMove(impl))
124{
125}
126
127void JSScreen::finishCreation(VM& vm)
128{
129 Base::finishCreation(vm);
130 ASSERT(inherits(vm, info()));
131
132}
133
134JSObject* JSScreen::createPrototype(VM& vm, JSDOMGlobalObject& globalObject)
135{
136 return JSScreenPrototype::create(vm, &globalObject, JSScreenPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype()));
137}
138
139JSObject* JSScreen::prototype(VM& vm, JSDOMGlobalObject& globalObject)
140{
141 return getDOMPrototype<JSScreen>(vm, globalObject);
142}
143
144JSValue JSScreen::getConstructor(VM& vm, const JSGlobalObject* globalObject)
145{
146 return getDOMConstructor<JSScreenConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
147}
148
149void JSScreen::destroy(JSC::JSCell* cell)
150{
151 JSScreen* thisObject = static_cast<JSScreen*>(cell);
152 thisObject->JSScreen::~JSScreen();
153}
154
155template<> inline JSScreen* IDLAttribute<JSScreen>::cast(ExecState& state, EncodedJSValue thisValue)
156{
157 return jsDynamicCast<JSScreen*>(state.vm(), JSValue::decode(thisValue));
158}
159
160EncodedJSValue jsScreenConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName)
161{
162 VM& vm = state->vm();
163 auto throwScope = DECLARE_THROW_SCOPE(vm);
164 auto* prototype = jsDynamicCast<JSScreenPrototype*>(vm, JSValue::decode(thisValue));
165 if (UNLIKELY(!prototype))
166 return throwVMTypeError(state, throwScope);
167 return JSValue::encode(JSScreen::getConstructor(state->vm(), prototype->globalObject()));
168}
169
170bool setJSScreenConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
171{
172 VM& vm = state->vm();
173 auto throwScope = DECLARE_THROW_SCOPE(vm);
174 auto* prototype = jsDynamicCast<JSScreenPrototype*>(vm, JSValue::decode(thisValue));
175 if (UNLIKELY(!prototype)) {
176 throwVMTypeError(state, throwScope);
177 return false;
178 }
179 // Shadowing a built-in constructor
180 return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue));
181}
182
183static inline JSValue jsScreenHeightGetter(ExecState& state, JSScreen& thisObject, ThrowScope& throwScope)
184{
185 UNUSED_PARAM(throwScope);
186 UNUSED_PARAM(state);
187 auto& impl = thisObject.wrapped();
188 JSValue result = toJS<IDLUnsignedLong>(state, throwScope, impl.height());
189 return result;
190}
191
192EncodedJSValue jsScreenHeight(ExecState* state, EncodedJSValue thisValue, PropertyName)
193{
194 return IDLAttribute<JSScreen>::get<jsScreenHeightGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "height");
195}
196
197static inline JSValue jsScreenWidthGetter(ExecState& state, JSScreen& thisObject, ThrowScope& throwScope)
198{
199 UNUSED_PARAM(throwScope);
200 UNUSED_PARAM(state);
201 auto& impl = thisObject.wrapped();
202 JSValue result = toJS<IDLUnsignedLong>(state, throwScope, impl.width());
203 return result;
204}
205
206EncodedJSValue jsScreenWidth(ExecState* state, EncodedJSValue thisValue, PropertyName)
207{
208 return IDLAttribute<JSScreen>::get<jsScreenWidthGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "width");
209}
210
211static inline JSValue jsScreenColorDepthGetter(ExecState& state, JSScreen& thisObject, ThrowScope& throwScope)
212{
213 UNUSED_PARAM(throwScope);
214 UNUSED_PARAM(state);
215 auto& impl = thisObject.wrapped();
216 JSValue result = toJS<IDLUnsignedLong>(state, throwScope, impl.colorDepth());
217 return result;
218}
219
220EncodedJSValue jsScreenColorDepth(ExecState* state, EncodedJSValue thisValue, PropertyName)
221{
222 return IDLAttribute<JSScreen>::get<jsScreenColorDepthGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "colorDepth");
223}
224
225static inline JSValue jsScreenPixelDepthGetter(ExecState& state, JSScreen& thisObject, ThrowScope& throwScope)
226{
227 UNUSED_PARAM(throwScope);
228 UNUSED_PARAM(state);
229 auto& impl = thisObject.wrapped();
230 JSValue result = toJS<IDLUnsignedLong>(state, throwScope, impl.pixelDepth());
231 return result;
232}
233
234EncodedJSValue jsScreenPixelDepth(ExecState* state, EncodedJSValue thisValue, PropertyName)
235{
236 return IDLAttribute<JSScreen>::get<jsScreenPixelDepthGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "pixelDepth");
237}
238
239static inline JSValue jsScreenAvailLeftGetter(ExecState& state, JSScreen& thisObject, ThrowScope& throwScope)
240{
241 UNUSED_PARAM(throwScope);
242 UNUSED_PARAM(state);
243 auto& impl = thisObject.wrapped();
244 JSValue result = toJS<IDLLong>(state, throwScope, impl.availLeft());
245 return result;
246}
247
248EncodedJSValue jsScreenAvailLeft(ExecState* state, EncodedJSValue thisValue, PropertyName)
249{
250 return IDLAttribute<JSScreen>::get<jsScreenAvailLeftGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "availLeft");
251}
252
253static inline JSValue jsScreenAvailTopGetter(ExecState& state, JSScreen& thisObject, ThrowScope& throwScope)
254{
255 UNUSED_PARAM(throwScope);
256 UNUSED_PARAM(state);
257 auto& impl = thisObject.wrapped();
258 JSValue result = toJS<IDLLong>(state, throwScope, impl.availTop());
259 return result;
260}
261
262EncodedJSValue jsScreenAvailTop(ExecState* state, EncodedJSValue thisValue, PropertyName)
263{
264 return IDLAttribute<JSScreen>::get<jsScreenAvailTopGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "availTop");
265}
266
267static inline JSValue jsScreenAvailHeightGetter(ExecState& state, JSScreen& thisObject, ThrowScope& throwScope)
268{
269 UNUSED_PARAM(throwScope);
270 UNUSED_PARAM(state);
271 auto& impl = thisObject.wrapped();
272 JSValue result = toJS<IDLUnsignedLong>(state, throwScope, impl.availHeight());
273 return result;
274}
275
276EncodedJSValue jsScreenAvailHeight(ExecState* state, EncodedJSValue thisValue, PropertyName)
277{
278 return IDLAttribute<JSScreen>::get<jsScreenAvailHeightGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "availHeight");
279}
280
281static inline JSValue jsScreenAvailWidthGetter(ExecState& state, JSScreen& thisObject, ThrowScope& throwScope)
282{
283 UNUSED_PARAM(throwScope);
284 UNUSED_PARAM(state);
285 auto& impl = thisObject.wrapped();
286 JSValue result = toJS<IDLUnsignedLong>(state, throwScope, impl.availWidth());
287 return result;
288}
289
290EncodedJSValue jsScreenAvailWidth(ExecState* state, EncodedJSValue thisValue, PropertyName)
291{
292 return IDLAttribute<JSScreen>::get<jsScreenAvailWidthGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "availWidth");
293}
294
295void JSScreen::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder)
296{
297 auto* thisObject = jsCast<JSScreen*>(cell);
298 builder.setWrappedObjectForCell(cell, &thisObject->wrapped());
299 if (thisObject->scriptExecutionContext())
300 builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string());
301 Base::heapSnapshot(cell, builder);
302}
303
304bool JSScreenOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor, const char** reason)
305{
306 auto* jsScreen = jsCast<JSScreen*>(handle.slot()->asCell());
307 Frame* root = WTF::getPtr(jsScreen->wrapped().frame());
308 if (!root)
309 return false;
310 if (UNLIKELY(reason))
311 *reason = "Reachable from Frame";
312 return visitor.containsOpaqueRoot(root);
313}
314
315void JSScreenOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
316{
317 auto* jsScreen = static_cast<JSScreen*>(handle.slot()->asCell());
318 auto& world = *static_cast<DOMWrapperWorld*>(context);
319 uncacheWrapper(world, &jsScreen->wrapped(), jsScreen);
320}
321
322JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<Screen>&& impl)
323{
324 // If you hit this failure the interface definition has the ImplementationLacksVTable
325 // attribute. You should remove that attribute. If the class has subclasses
326 // that may be passed through this toJS() function you should use the SkipVTableValidation
327 // attribute to Screen.
328 static_assert(!std::is_polymorphic<Screen>::value, "Screen is polymorphic but the IDL claims it is not");
329 return createWrapper<Screen>(globalObject, WTFMove(impl));
330}
331
332JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, Screen& impl)
333{
334 return wrap(state, globalObject, impl);
335}
336
337Screen* JSScreen::toWrapped(JSC::VM& vm, JSC::JSValue value)
338{
339 if (auto* wrapper = jsDynamicCast<JSScreen*>(vm, value))
340 return &wrapper->wrapped();
341 return nullptr;
342}
343
344}
345