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