| 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 "JSStyleMedia.h" |
| 23 | |
| 24 | #include "JSDOMAttribute.h" |
| 25 | #include "JSDOMBinding.h" |
| 26 | #include "JSDOMConvertBoolean.h" |
| 27 | #include "JSDOMConvertStrings.h" |
| 28 | #include "JSDOMExceptionHandling.h" |
| 29 | #include "JSDOMOperation.h" |
| 30 | #include "JSDOMWrapperCache.h" |
| 31 | #include "ScriptExecutionContext.h" |
| 32 | #include <JavaScriptCore/HeapSnapshotBuilder.h> |
| 33 | #include <JavaScriptCore/JSCInlines.h> |
| 34 | #include <wtf/GetPtr.h> |
| 35 | #include <wtf/PointerPreparations.h> |
| 36 | #include <wtf/URL.h> |
| 37 | |
| 38 | |
| 39 | namespace WebCore { |
| 40 | using namespace JSC; |
| 41 | |
| 42 | // Functions |
| 43 | |
| 44 | JSC::EncodedJSValue JSC_HOST_CALL jsStyleMediaPrototypeFunctionMatchMedium(JSC::ExecState*); |
| 45 | |
| 46 | // Attributes |
| 47 | |
| 48 | JSC::EncodedJSValue jsStyleMediaType(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 49 | |
| 50 | class JSStyleMediaPrototype : public JSC::JSNonFinalObject { |
| 51 | public: |
| 52 | using Base = JSC::JSNonFinalObject; |
| 53 | static JSStyleMediaPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
| 54 | { |
| 55 | JSStyleMediaPrototype* ptr = new (NotNull, JSC::allocateCell<JSStyleMediaPrototype>(vm.heap)) JSStyleMediaPrototype(vm, globalObject, structure); |
| 56 | ptr->finishCreation(vm); |
| 57 | return ptr; |
| 58 | } |
| 59 | |
| 60 | DECLARE_INFO; |
| 61 | static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) |
| 62 | { |
| 63 | return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); |
| 64 | } |
| 65 | |
| 66 | private: |
| 67 | JSStyleMediaPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
| 68 | : JSC::JSNonFinalObject(vm, structure) |
| 69 | { |
| 70 | } |
| 71 | |
| 72 | void finishCreation(JSC::VM&); |
| 73 | }; |
| 74 | |
| 75 | /* Hash table for prototype */ |
| 76 | |
| 77 | static const HashTableValue JSStyleMediaPrototypeTableValues[] = |
| 78 | { |
| 79 | { "type" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsStyleMediaType), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 80 | { "matchMedium" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsStyleMediaPrototypeFunctionMatchMedium), (intptr_t) (0) } }, |
| 81 | }; |
| 82 | |
| 83 | const ClassInfo JSStyleMediaPrototype::s_info = { "StyleMediaPrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSStyleMediaPrototype) }; |
| 84 | |
| 85 | void JSStyleMediaPrototype::finishCreation(VM& vm) |
| 86 | { |
| 87 | Base::finishCreation(vm); |
| 88 | reifyStaticProperties(vm, JSStyleMedia::info(), JSStyleMediaPrototypeTableValues, *this); |
| 89 | } |
| 90 | |
| 91 | const ClassInfo JSStyleMedia::s_info = { "StyleMedia" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSStyleMedia) }; |
| 92 | |
| 93 | JSStyleMedia::JSStyleMedia(Structure* structure, JSDOMGlobalObject& globalObject, Ref<StyleMedia>&& impl) |
| 94 | : JSDOMWrapper<StyleMedia>(structure, globalObject, WTFMove(impl)) |
| 95 | { |
| 96 | } |
| 97 | |
| 98 | void JSStyleMedia::finishCreation(VM& vm) |
| 99 | { |
| 100 | Base::finishCreation(vm); |
| 101 | ASSERT(inherits(vm, info())); |
| 102 | |
| 103 | } |
| 104 | |
| 105 | JSObject* JSStyleMedia::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
| 106 | { |
| 107 | return JSStyleMediaPrototype::create(vm, &globalObject, JSStyleMediaPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype())); |
| 108 | } |
| 109 | |
| 110 | JSObject* JSStyleMedia::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
| 111 | { |
| 112 | return getDOMPrototype<JSStyleMedia>(vm, globalObject); |
| 113 | } |
| 114 | |
| 115 | void JSStyleMedia::destroy(JSC::JSCell* cell) |
| 116 | { |
| 117 | JSStyleMedia* thisObject = static_cast<JSStyleMedia*>(cell); |
| 118 | thisObject->JSStyleMedia::~JSStyleMedia(); |
| 119 | } |
| 120 | |
| 121 | template<> inline JSStyleMedia* IDLAttribute<JSStyleMedia>::cast(ExecState& state, EncodedJSValue thisValue) |
| 122 | { |
| 123 | return jsDynamicCast<JSStyleMedia*>(state.vm(), JSValue::decode(thisValue)); |
| 124 | } |
| 125 | |
| 126 | template<> inline JSStyleMedia* IDLOperation<JSStyleMedia>::cast(ExecState& state) |
| 127 | { |
| 128 | return jsDynamicCast<JSStyleMedia*>(state.vm(), state.thisValue()); |
| 129 | } |
| 130 | |
| 131 | static inline JSValue jsStyleMediaTypeGetter(ExecState& state, JSStyleMedia& thisObject, ThrowScope& throwScope) |
| 132 | { |
| 133 | UNUSED_PARAM(throwScope); |
| 134 | UNUSED_PARAM(state); |
| 135 | auto& impl = thisObject.wrapped(); |
| 136 | JSValue result = toJS<IDLDOMString>(state, throwScope, impl.type()); |
| 137 | return result; |
| 138 | } |
| 139 | |
| 140 | EncodedJSValue jsStyleMediaType(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 141 | { |
| 142 | return IDLAttribute<JSStyleMedia>::get<jsStyleMediaTypeGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "type" ); |
| 143 | } |
| 144 | |
| 145 | static inline JSC::EncodedJSValue jsStyleMediaPrototypeFunctionMatchMediumBody(JSC::ExecState* state, typename IDLOperation<JSStyleMedia>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 146 | { |
| 147 | UNUSED_PARAM(state); |
| 148 | UNUSED_PARAM(throwScope); |
| 149 | auto& impl = castedThis->wrapped(); |
| 150 | auto mediaquery = convert<IDLDOMString>(*state, state->argument(0)); |
| 151 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 152 | return JSValue::encode(toJS<IDLBoolean>(impl.matchMedium(WTFMove(mediaquery)))); |
| 153 | } |
| 154 | |
| 155 | EncodedJSValue JSC_HOST_CALL jsStyleMediaPrototypeFunctionMatchMedium(ExecState* state) |
| 156 | { |
| 157 | return IDLOperation<JSStyleMedia>::call<jsStyleMediaPrototypeFunctionMatchMediumBody>(*state, "matchMedium" ); |
| 158 | } |
| 159 | |
| 160 | void JSStyleMedia::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) |
| 161 | { |
| 162 | auto* thisObject = jsCast<JSStyleMedia*>(cell); |
| 163 | builder.setWrappedObjectForCell(cell, &thisObject->wrapped()); |
| 164 | if (thisObject->scriptExecutionContext()) |
| 165 | builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); |
| 166 | Base::heapSnapshot(cell, builder); |
| 167 | } |
| 168 | |
| 169 | bool JSStyleMediaOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor, const char** reason) |
| 170 | { |
| 171 | auto* jsStyleMedia = jsCast<JSStyleMedia*>(handle.slot()->asCell()); |
| 172 | Frame* root = WTF::getPtr(jsStyleMedia->wrapped().frame()); |
| 173 | if (!root) |
| 174 | return false; |
| 175 | if (UNLIKELY(reason)) |
| 176 | *reason = "Reachable from Frame" ; |
| 177 | return visitor.containsOpaqueRoot(root); |
| 178 | } |
| 179 | |
| 180 | void JSStyleMediaOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context) |
| 181 | { |
| 182 | auto* jsStyleMedia = static_cast<JSStyleMedia*>(handle.slot()->asCell()); |
| 183 | auto& world = *static_cast<DOMWrapperWorld*>(context); |
| 184 | uncacheWrapper(world, &jsStyleMedia->wrapped(), jsStyleMedia); |
| 185 | } |
| 186 | |
| 187 | JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<StyleMedia>&& impl) |
| 188 | { |
| 189 | // If you hit this failure the interface definition has the ImplementationLacksVTable |
| 190 | // attribute. You should remove that attribute. If the class has subclasses |
| 191 | // that may be passed through this toJS() function you should use the SkipVTableValidation |
| 192 | // attribute to StyleMedia. |
| 193 | static_assert(!std::is_polymorphic<StyleMedia>::value, "StyleMedia is polymorphic but the IDL claims it is not" ); |
| 194 | return createWrapper<StyleMedia>(globalObject, WTFMove(impl)); |
| 195 | } |
| 196 | |
| 197 | JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, StyleMedia& impl) |
| 198 | { |
| 199 | return wrap(state, globalObject, impl); |
| 200 | } |
| 201 | |
| 202 | StyleMedia* JSStyleMedia::toWrapped(JSC::VM& vm, JSC::JSValue value) |
| 203 | { |
| 204 | if (auto* wrapper = jsDynamicCast<JSStyleMedia*>(vm, value)) |
| 205 | return &wrapper->wrapped(); |
| 206 | return nullptr; |
| 207 | } |
| 208 | |
| 209 | } |
| 210 | |