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 "JSCSSPageRule.h"
23
24#include "JSCSSStyleDeclaration.h"
25#include "JSDOMAttribute.h"
26#include "JSDOMBinding.h"
27#include "JSDOMConstructorNotConstructable.h"
28#include "JSDOMConvertInterface.h"
29#include "JSDOMConvertNullable.h"
30#include "JSDOMConvertStrings.h"
31#include "JSDOMExceptionHandling.h"
32#include "JSDOMGlobalObject.h"
33#include "JSDOMWrapperCache.h"
34#include "ScriptExecutionContext.h"
35#include <JavaScriptCore/HeapSnapshotBuilder.h>
36#include <JavaScriptCore/JSCInlines.h>
37#include <wtf/GetPtr.h>
38#include <wtf/PointerPreparations.h>
39#include <wtf/URL.h>
40
41
42namespace WebCore {
43using namespace JSC;
44
45// Attributes
46
47JSC::EncodedJSValue jsCSSPageRuleConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
48bool setJSCSSPageRuleConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
49JSC::EncodedJSValue jsCSSPageRuleSelectorText(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
50bool setJSCSSPageRuleSelectorText(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
51JSC::EncodedJSValue jsCSSPageRuleStyle(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
52bool setJSCSSPageRuleStyle(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
53
54class JSCSSPageRulePrototype : public JSC::JSNonFinalObject {
55public:
56 using Base = JSC::JSNonFinalObject;
57 static JSCSSPageRulePrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure)
58 {
59 JSCSSPageRulePrototype* ptr = new (NotNull, JSC::allocateCell<JSCSSPageRulePrototype>(vm.heap)) JSCSSPageRulePrototype(vm, globalObject, structure);
60 ptr->finishCreation(vm);
61 return ptr;
62 }
63
64 DECLARE_INFO;
65 static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
66 {
67 return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
68 }
69
70private:
71 JSCSSPageRulePrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
72 : JSC::JSNonFinalObject(vm, structure)
73 {
74 }
75
76 void finishCreation(JSC::VM&);
77};
78
79using JSCSSPageRuleConstructor = JSDOMConstructorNotConstructable<JSCSSPageRule>;
80
81template<> JSValue JSCSSPageRuleConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
82{
83 return JSCSSRule::getConstructor(vm, &globalObject);
84}
85
86template<> void JSCSSPageRuleConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
87{
88 putDirect(vm, vm.propertyNames->prototype, JSCSSPageRule::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
89 putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("CSSPageRule"_s)), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
90 putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
91}
92
93template<> const ClassInfo JSCSSPageRuleConstructor::s_info = { "CSSPageRule", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSCSSPageRuleConstructor) };
94
95/* Hash table for prototype */
96
97static const HashTableValue JSCSSPageRulePrototypeTableValues[] =
98{
99 { "constructor", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsCSSPageRuleConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSCSSPageRuleConstructor) } },
100 { "selectorText", static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsCSSPageRuleSelectorText), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSCSSPageRuleSelectorText) } },
101 { "style", static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsCSSPageRuleStyle), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSCSSPageRuleStyle) } },
102};
103
104const ClassInfo JSCSSPageRulePrototype::s_info = { "CSSPageRulePrototype", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSCSSPageRulePrototype) };
105
106void JSCSSPageRulePrototype::finishCreation(VM& vm)
107{
108 Base::finishCreation(vm);
109 reifyStaticProperties(vm, JSCSSPageRule::info(), JSCSSPageRulePrototypeTableValues, *this);
110}
111
112const ClassInfo JSCSSPageRule::s_info = { "CSSPageRule", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSCSSPageRule) };
113
114JSCSSPageRule::JSCSSPageRule(Structure* structure, JSDOMGlobalObject& globalObject, Ref<CSSPageRule>&& impl)
115 : JSCSSRule(structure, globalObject, WTFMove(impl))
116{
117}
118
119void JSCSSPageRule::finishCreation(VM& vm)
120{
121 Base::finishCreation(vm);
122 ASSERT(inherits(vm, info()));
123
124}
125
126JSObject* JSCSSPageRule::createPrototype(VM& vm, JSDOMGlobalObject& globalObject)
127{
128 return JSCSSPageRulePrototype::create(vm, &globalObject, JSCSSPageRulePrototype::createStructure(vm, &globalObject, JSCSSRule::prototype(vm, globalObject)));
129}
130
131JSObject* JSCSSPageRule::prototype(VM& vm, JSDOMGlobalObject& globalObject)
132{
133 return getDOMPrototype<JSCSSPageRule>(vm, globalObject);
134}
135
136JSValue JSCSSPageRule::getConstructor(VM& vm, const JSGlobalObject* globalObject)
137{
138 return getDOMConstructor<JSCSSPageRuleConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
139}
140
141template<> inline JSCSSPageRule* IDLAttribute<JSCSSPageRule>::cast(ExecState& state, EncodedJSValue thisValue)
142{
143 return jsDynamicCast<JSCSSPageRule*>(state.vm(), JSValue::decode(thisValue));
144}
145
146EncodedJSValue jsCSSPageRuleConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName)
147{
148 VM& vm = state->vm();
149 auto throwScope = DECLARE_THROW_SCOPE(vm);
150 auto* prototype = jsDynamicCast<JSCSSPageRulePrototype*>(vm, JSValue::decode(thisValue));
151 if (UNLIKELY(!prototype))
152 return throwVMTypeError(state, throwScope);
153 return JSValue::encode(JSCSSPageRule::getConstructor(state->vm(), prototype->globalObject()));
154}
155
156bool setJSCSSPageRuleConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
157{
158 VM& vm = state->vm();
159 auto throwScope = DECLARE_THROW_SCOPE(vm);
160 auto* prototype = jsDynamicCast<JSCSSPageRulePrototype*>(vm, JSValue::decode(thisValue));
161 if (UNLIKELY(!prototype)) {
162 throwVMTypeError(state, throwScope);
163 return false;
164 }
165 // Shadowing a built-in constructor
166 return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue));
167}
168
169static inline JSValue jsCSSPageRuleSelectorTextGetter(ExecState& state, JSCSSPageRule& thisObject, ThrowScope& throwScope)
170{
171 UNUSED_PARAM(throwScope);
172 UNUSED_PARAM(state);
173 auto& impl = thisObject.wrapped();
174 JSValue result = toJS<IDLNullable<IDLDOMString>>(state, throwScope, impl.selectorText());
175 return result;
176}
177
178EncodedJSValue jsCSSPageRuleSelectorText(ExecState* state, EncodedJSValue thisValue, PropertyName)
179{
180 return IDLAttribute<JSCSSPageRule>::get<jsCSSPageRuleSelectorTextGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "selectorText");
181}
182
183static inline bool setJSCSSPageRuleSelectorTextSetter(ExecState& state, JSCSSPageRule& thisObject, JSValue value, ThrowScope& throwScope)
184{
185 UNUSED_PARAM(throwScope);
186 auto& impl = thisObject.wrapped();
187 auto nativeValue = convert<IDLNullable<IDLDOMString>>(state, value);
188 RETURN_IF_EXCEPTION(throwScope, false);
189 AttributeSetter::call(state, throwScope, [&] {
190 return impl.setSelectorText(WTFMove(nativeValue));
191 });
192 return true;
193}
194
195bool setJSCSSPageRuleSelectorText(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
196{
197 return IDLAttribute<JSCSSPageRule>::set<setJSCSSPageRuleSelectorTextSetter>(*state, thisValue, encodedValue, "selectorText");
198}
199
200static inline JSValue jsCSSPageRuleStyleGetter(ExecState& state, JSCSSPageRule& thisObject, ThrowScope& throwScope)
201{
202 UNUSED_PARAM(throwScope);
203 UNUSED_PARAM(state);
204 auto& impl = thisObject.wrapped();
205 JSValue result = toJS<IDLInterface<CSSStyleDeclaration>>(state, *thisObject.globalObject(), throwScope, impl.style());
206 return result;
207}
208
209EncodedJSValue jsCSSPageRuleStyle(ExecState* state, EncodedJSValue thisValue, PropertyName)
210{
211 return IDLAttribute<JSCSSPageRule>::get<jsCSSPageRuleStyleGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "style");
212}
213
214static inline bool setJSCSSPageRuleStyleSetter(ExecState& state, JSCSSPageRule& thisObject, JSValue value, ThrowScope& throwScope)
215{
216 UNUSED_PARAM(throwScope);
217 auto id = Identifier::fromString(&state.vm(), reinterpret_cast<const LChar*>("style"), strlen("style"));
218 auto valueToForwardTo = thisObject.get(&state, id);
219 RETURN_IF_EXCEPTION(throwScope, false);
220 if (UNLIKELY(!valueToForwardTo.isObject())) {
221 throwTypeError(&state, throwScope);
222 return false;
223 }
224 auto forwardId = Identifier::fromString(&state.vm(), reinterpret_cast<const LChar*>("cssText"), strlen("cssText"));
225 PutPropertySlot slot(valueToForwardTo, false);
226 asObject(valueToForwardTo)->methodTable(state.vm())->put(asObject(valueToForwardTo), &state, forwardId, value, slot);
227 RETURN_IF_EXCEPTION(throwScope, false);
228 return true;
229}
230
231bool setJSCSSPageRuleStyle(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
232{
233 return IDLAttribute<JSCSSPageRule>::set<setJSCSSPageRuleStyleSetter>(*state, thisValue, encodedValue, "style");
234}
235
236void JSCSSPageRule::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder)
237{
238 auto* thisObject = jsCast<JSCSSPageRule*>(cell);
239 builder.setWrappedObjectForCell(cell, &thisObject->wrapped());
240 if (thisObject->scriptExecutionContext())
241 builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string());
242 Base::heapSnapshot(cell, builder);
243}
244
245
246}
247