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