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 "JSCSSFontFaceRule.h" |
23 | |
24 | #include "JSCSSStyleDeclaration.h" |
25 | #include "JSDOMAttribute.h" |
26 | #include "JSDOMBinding.h" |
27 | #include "JSDOMConstructorNotConstructable.h" |
28 | #include "JSDOMConvertInterface.h" |
29 | #include "JSDOMExceptionHandling.h" |
30 | #include "JSDOMGlobalObject.h" |
31 | #include "JSDOMWrapperCache.h" |
32 | #include "ScriptExecutionContext.h" |
33 | #include <JavaScriptCore/HeapSnapshotBuilder.h> |
34 | #include <JavaScriptCore/JSCInlines.h> |
35 | #include <wtf/GetPtr.h> |
36 | #include <wtf/PointerPreparations.h> |
37 | #include <wtf/URL.h> |
38 | |
39 | |
40 | namespace WebCore { |
41 | using namespace JSC; |
42 | |
43 | // Attributes |
44 | |
45 | JSC::EncodedJSValue jsCSSFontFaceRuleConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
46 | bool setJSCSSFontFaceRuleConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
47 | JSC::EncodedJSValue jsCSSFontFaceRuleStyle(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
48 | |
49 | class JSCSSFontFaceRulePrototype : public JSC::JSNonFinalObject { |
50 | public: |
51 | using Base = JSC::JSNonFinalObject; |
52 | static JSCSSFontFaceRulePrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
53 | { |
54 | JSCSSFontFaceRulePrototype* ptr = new (NotNull, JSC::allocateCell<JSCSSFontFaceRulePrototype>(vm.heap)) JSCSSFontFaceRulePrototype(vm, globalObject, structure); |
55 | ptr->finishCreation(vm); |
56 | return ptr; |
57 | } |
58 | |
59 | DECLARE_INFO; |
60 | static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) |
61 | { |
62 | return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); |
63 | } |
64 | |
65 | private: |
66 | JSCSSFontFaceRulePrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
67 | : JSC::JSNonFinalObject(vm, structure) |
68 | { |
69 | } |
70 | |
71 | void finishCreation(JSC::VM&); |
72 | }; |
73 | |
74 | using JSCSSFontFaceRuleConstructor = JSDOMConstructorNotConstructable<JSCSSFontFaceRule>; |
75 | |
76 | template<> JSValue JSCSSFontFaceRuleConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
77 | { |
78 | return JSCSSRule::getConstructor(vm, &globalObject); |
79 | } |
80 | |
81 | template<> void JSCSSFontFaceRuleConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
82 | { |
83 | putDirect(vm, vm.propertyNames->prototype, JSCSSFontFaceRule::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
84 | putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("CSSFontFaceRule"_s )), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
85 | putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
86 | } |
87 | |
88 | template<> const ClassInfo JSCSSFontFaceRuleConstructor::s_info = { "CSSFontFaceRule" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSCSSFontFaceRuleConstructor) }; |
89 | |
90 | /* Hash table for prototype */ |
91 | |
92 | static const HashTableValue JSCSSFontFaceRulePrototypeTableValues[] = |
93 | { |
94 | { "constructor" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsCSSFontFaceRuleConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSCSSFontFaceRuleConstructor) } }, |
95 | { "style" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsCSSFontFaceRuleStyle), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
96 | }; |
97 | |
98 | const ClassInfo JSCSSFontFaceRulePrototype::s_info = { "CSSFontFaceRulePrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSCSSFontFaceRulePrototype) }; |
99 | |
100 | void JSCSSFontFaceRulePrototype::finishCreation(VM& vm) |
101 | { |
102 | Base::finishCreation(vm); |
103 | reifyStaticProperties(vm, JSCSSFontFaceRule::info(), JSCSSFontFaceRulePrototypeTableValues, *this); |
104 | } |
105 | |
106 | const ClassInfo JSCSSFontFaceRule::s_info = { "CSSFontFaceRule" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSCSSFontFaceRule) }; |
107 | |
108 | JSCSSFontFaceRule::JSCSSFontFaceRule(Structure* structure, JSDOMGlobalObject& globalObject, Ref<CSSFontFaceRule>&& impl) |
109 | : JSCSSRule(structure, globalObject, WTFMove(impl)) |
110 | { |
111 | } |
112 | |
113 | void JSCSSFontFaceRule::finishCreation(VM& vm) |
114 | { |
115 | Base::finishCreation(vm); |
116 | ASSERT(inherits(vm, info())); |
117 | |
118 | } |
119 | |
120 | JSObject* JSCSSFontFaceRule::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
121 | { |
122 | return JSCSSFontFaceRulePrototype::create(vm, &globalObject, JSCSSFontFaceRulePrototype::createStructure(vm, &globalObject, JSCSSRule::prototype(vm, globalObject))); |
123 | } |
124 | |
125 | JSObject* JSCSSFontFaceRule::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
126 | { |
127 | return getDOMPrototype<JSCSSFontFaceRule>(vm, globalObject); |
128 | } |
129 | |
130 | JSValue JSCSSFontFaceRule::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
131 | { |
132 | return getDOMConstructor<JSCSSFontFaceRuleConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
133 | } |
134 | |
135 | template<> inline JSCSSFontFaceRule* IDLAttribute<JSCSSFontFaceRule>::cast(ExecState& state, EncodedJSValue thisValue) |
136 | { |
137 | return jsDynamicCast<JSCSSFontFaceRule*>(state.vm(), JSValue::decode(thisValue)); |
138 | } |
139 | |
140 | EncodedJSValue jsCSSFontFaceRuleConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
141 | { |
142 | VM& vm = state->vm(); |
143 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
144 | auto* prototype = jsDynamicCast<JSCSSFontFaceRulePrototype*>(vm, JSValue::decode(thisValue)); |
145 | if (UNLIKELY(!prototype)) |
146 | return throwVMTypeError(state, throwScope); |
147 | return JSValue::encode(JSCSSFontFaceRule::getConstructor(state->vm(), prototype->globalObject())); |
148 | } |
149 | |
150 | bool setJSCSSFontFaceRuleConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
151 | { |
152 | VM& vm = state->vm(); |
153 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
154 | auto* prototype = jsDynamicCast<JSCSSFontFaceRulePrototype*>(vm, JSValue::decode(thisValue)); |
155 | if (UNLIKELY(!prototype)) { |
156 | throwVMTypeError(state, throwScope); |
157 | return false; |
158 | } |
159 | // Shadowing a built-in constructor |
160 | return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue)); |
161 | } |
162 | |
163 | static inline JSValue jsCSSFontFaceRuleStyleGetter(ExecState& state, JSCSSFontFaceRule& thisObject, ThrowScope& throwScope) |
164 | { |
165 | UNUSED_PARAM(throwScope); |
166 | UNUSED_PARAM(state); |
167 | auto& impl = thisObject.wrapped(); |
168 | JSValue result = toJS<IDLInterface<CSSStyleDeclaration>>(state, *thisObject.globalObject(), throwScope, impl.style()); |
169 | return result; |
170 | } |
171 | |
172 | EncodedJSValue jsCSSFontFaceRuleStyle(ExecState* state, EncodedJSValue thisValue, PropertyName) |
173 | { |
174 | return IDLAttribute<JSCSSFontFaceRule>::get<jsCSSFontFaceRuleStyleGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "style" ); |
175 | } |
176 | |
177 | void JSCSSFontFaceRule::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) |
178 | { |
179 | auto* thisObject = jsCast<JSCSSFontFaceRule*>(cell); |
180 | builder.setWrappedObjectForCell(cell, &thisObject->wrapped()); |
181 | if (thisObject->scriptExecutionContext()) |
182 | builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); |
183 | Base::heapSnapshot(cell, builder); |
184 | } |
185 | |
186 | #if ENABLE(BINDING_INTEGRITY) |
187 | #if PLATFORM(WIN) |
188 | #pragma warning(disable: 4483) |
189 | extern "C" { extern void (*const __identifier("??_7CSSFontFaceRule@WebCore@@6B@" )[])(); } |
190 | #else |
191 | extern "C" { extern void* _ZTVN7WebCore15CSSFontFaceRuleE[]; } |
192 | #endif |
193 | #endif |
194 | |
195 | JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<CSSFontFaceRule>&& impl) |
196 | { |
197 | |
198 | #if ENABLE(BINDING_INTEGRITY) |
199 | void* actualVTablePointer = *(reinterpret_cast<void**>(impl.ptr())); |
200 | #if PLATFORM(WIN) |
201 | void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(__identifier("??_7CSSFontFaceRule@WebCore@@6B@" )); |
202 | #else |
203 | void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(&_ZTVN7WebCore15CSSFontFaceRuleE[2]); |
204 | #endif |
205 | |
206 | // If this fails CSSFontFaceRule does not have a vtable, so you need to add the |
207 | // ImplementationLacksVTable attribute to the interface definition |
208 | static_assert(std::is_polymorphic<CSSFontFaceRule>::value, "CSSFontFaceRule is not polymorphic" ); |
209 | |
210 | // If you hit this assertion you either have a use after free bug, or |
211 | // CSSFontFaceRule has subclasses. If CSSFontFaceRule has subclasses that get passed |
212 | // to toJS() we currently require CSSFontFaceRule you to opt out of binding hardening |
213 | // by adding the SkipVTableValidation attribute to the interface IDL definition |
214 | RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer); |
215 | #endif |
216 | return createWrapper<CSSFontFaceRule>(globalObject, WTFMove(impl)); |
217 | } |
218 | |
219 | JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, CSSFontFaceRule& impl) |
220 | { |
221 | return wrap(state, globalObject, impl); |
222 | } |
223 | |
224 | CSSFontFaceRule* JSCSSFontFaceRule::toWrapped(JSC::VM& vm, JSC::JSValue value) |
225 | { |
226 | if (auto* wrapper = jsDynamicCast<JSCSSFontFaceRule*>(vm, value)) |
227 | return &wrapper->wrapped(); |
228 | return nullptr; |
229 | } |
230 | |
231 | } |
232 | |