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 "JSCSSStyleRule.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 jsCSSStyleRuleConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
48bool setJSCSSStyleRuleConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
49JSC::EncodedJSValue jsCSSStyleRuleSelectorText(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
50bool setJSCSSStyleRuleSelectorText(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
51JSC::EncodedJSValue jsCSSStyleRuleStyle(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
52bool setJSCSSStyleRuleStyle(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
53
54class JSCSSStyleRulePrototype : public JSC::JSNonFinalObject {
55public:
56 using Base = JSC::JSNonFinalObject;
57 static JSCSSStyleRulePrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure)
58 {
59 JSCSSStyleRulePrototype* ptr = new (NotNull, JSC::allocateCell<JSCSSStyleRulePrototype>(vm.heap)) JSCSSStyleRulePrototype(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 JSCSSStyleRulePrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
72 : JSC::JSNonFinalObject(vm, structure)
73 {
74 }
75
76 void finishCreation(JSC::VM&);
77};
78
79using JSCSSStyleRuleConstructor = JSDOMConstructorNotConstructable<JSCSSStyleRule>;
80
81template<> JSValue JSCSSStyleRuleConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
82{
83 return JSCSSRule::getConstructor(vm, &globalObject);
84}
85
86template<> void JSCSSStyleRuleConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
87{
88 putDirect(vm, vm.propertyNames->prototype, JSCSSStyleRule::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
89 putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("CSSStyleRule"_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 JSCSSStyleRuleConstructor::s_info = { "CSSStyleRule", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSCSSStyleRuleConstructor) };
94
95/* Hash table for prototype */
96
97static const HashTableValue JSCSSStyleRulePrototypeTableValues[] =
98{
99 { "constructor", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsCSSStyleRuleConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSCSSStyleRuleConstructor) } },
100 { "selectorText", static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsCSSStyleRuleSelectorText), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSCSSStyleRuleSelectorText) } },
101 { "style", static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsCSSStyleRuleStyle), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSCSSStyleRuleStyle) } },
102};
103
104const ClassInfo JSCSSStyleRulePrototype::s_info = { "CSSStyleRulePrototype", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSCSSStyleRulePrototype) };
105
106void JSCSSStyleRulePrototype::finishCreation(VM& vm)
107{
108 Base::finishCreation(vm);
109 reifyStaticProperties(vm, JSCSSStyleRule::info(), JSCSSStyleRulePrototypeTableValues, *this);
110}
111
112const ClassInfo JSCSSStyleRule::s_info = { "CSSStyleRule", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSCSSStyleRule) };
113
114JSCSSStyleRule::JSCSSStyleRule(Structure* structure, JSDOMGlobalObject& globalObject, Ref<CSSStyleRule>&& impl)
115 : JSCSSRule(structure, globalObject, WTFMove(impl))
116{
117}
118
119void JSCSSStyleRule::finishCreation(VM& vm)
120{
121 Base::finishCreation(vm);
122 ASSERT(inherits(vm, info()));
123
124}
125
126JSObject* JSCSSStyleRule::createPrototype(VM& vm, JSDOMGlobalObject& globalObject)
127{
128 return JSCSSStyleRulePrototype::create(vm, &globalObject, JSCSSStyleRulePrototype::createStructure(vm, &globalObject, JSCSSRule::prototype(vm, globalObject)));
129}
130
131JSObject* JSCSSStyleRule::prototype(VM& vm, JSDOMGlobalObject& globalObject)
132{
133 return getDOMPrototype<JSCSSStyleRule>(vm, globalObject);
134}
135
136JSValue JSCSSStyleRule::getConstructor(VM& vm, const JSGlobalObject* globalObject)
137{
138 return getDOMConstructor<JSCSSStyleRuleConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
139}
140
141template<> inline JSCSSStyleRule* IDLAttribute<JSCSSStyleRule>::cast(ExecState& state, EncodedJSValue thisValue)
142{
143 return jsDynamicCast<JSCSSStyleRule*>(state.vm(), JSValue::decode(thisValue));
144}
145
146EncodedJSValue jsCSSStyleRuleConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName)
147{
148 VM& vm = state->vm();
149 auto throwScope = DECLARE_THROW_SCOPE(vm);
150 auto* prototype = jsDynamicCast<JSCSSStyleRulePrototype*>(vm, JSValue::decode(thisValue));
151 if (UNLIKELY(!prototype))
152 return throwVMTypeError(state, throwScope);
153 return JSValue::encode(JSCSSStyleRule::getConstructor(state->vm(), prototype->globalObject()));
154}
155
156bool setJSCSSStyleRuleConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
157{
158 VM& vm = state->vm();
159 auto throwScope = DECLARE_THROW_SCOPE(vm);
160 auto* prototype = jsDynamicCast<JSCSSStyleRulePrototype*>(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 jsCSSStyleRuleSelectorTextGetter(ExecState& state, JSCSSStyleRule& 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 jsCSSStyleRuleSelectorText(ExecState* state, EncodedJSValue thisValue, PropertyName)
179{
180 return IDLAttribute<JSCSSStyleRule>::get<jsCSSStyleRuleSelectorTextGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "selectorText");
181}
182
183static inline bool setJSCSSStyleRuleSelectorTextSetter(ExecState& state, JSCSSStyleRule& 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 setJSCSSStyleRuleSelectorText(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
196{
197 return IDLAttribute<JSCSSStyleRule>::set<setJSCSSStyleRuleSelectorTextSetter>(*state, thisValue, encodedValue, "selectorText");
198}
199
200static inline JSValue jsCSSStyleRuleStyleGetter(ExecState& state, JSCSSStyleRule& 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 jsCSSStyleRuleStyle(ExecState* state, EncodedJSValue thisValue, PropertyName)
210{
211 return IDLAttribute<JSCSSStyleRule>::get<jsCSSStyleRuleStyleGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "style");
212}
213
214static inline bool setJSCSSStyleRuleStyleSetter(ExecState& state, JSCSSStyleRule& 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 setJSCSSStyleRuleStyle(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
232{
233 return IDLAttribute<JSCSSStyleRule>::set<setJSCSSStyleRuleStyleSetter>(*state, thisValue, encodedValue, "style");
234}
235
236void JSCSSStyleRule::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder)
237{
238 auto* thisObject = jsCast<JSCSSStyleRule*>(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