| 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 "JSTextEvent.h" |
| 23 | |
| 24 | #include "JSDOMAttribute.h" |
| 25 | #include "JSDOMBinding.h" |
| 26 | #include "JSDOMConstructorNotConstructable.h" |
| 27 | #include "JSDOMConvertBoolean.h" |
| 28 | #include "JSDOMConvertInterface.h" |
| 29 | #include "JSDOMConvertNullable.h" |
| 30 | #include "JSDOMConvertStrings.h" |
| 31 | #include "JSDOMExceptionHandling.h" |
| 32 | #include "JSDOMOperation.h" |
| 33 | #include "JSDOMWrapperCache.h" |
| 34 | #include "JSWindowProxy.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 jsTextEventPrototypeFunctionInitTextEvent(JSC::ExecState*); |
| 49 | |
| 50 | // Attributes |
| 51 | |
| 52 | JSC::EncodedJSValue jsTextEventConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 53 | bool setJSTextEventConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| 54 | JSC::EncodedJSValue jsTextEventData(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 55 | |
| 56 | class JSTextEventPrototype : public JSC::JSNonFinalObject { |
| 57 | public: |
| 58 | using Base = JSC::JSNonFinalObject; |
| 59 | static JSTextEventPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
| 60 | { |
| 61 | JSTextEventPrototype* ptr = new (NotNull, JSC::allocateCell<JSTextEventPrototype>(vm.heap)) JSTextEventPrototype(vm, globalObject, structure); |
| 62 | ptr->finishCreation(vm); |
| 63 | return ptr; |
| 64 | } |
| 65 | |
| 66 | DECLARE_INFO; |
| 67 | static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) |
| 68 | { |
| 69 | return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); |
| 70 | } |
| 71 | |
| 72 | private: |
| 73 | JSTextEventPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
| 74 | : JSC::JSNonFinalObject(vm, structure) |
| 75 | { |
| 76 | } |
| 77 | |
| 78 | void finishCreation(JSC::VM&); |
| 79 | }; |
| 80 | |
| 81 | using JSTextEventConstructor = JSDOMConstructorNotConstructable<JSTextEvent>; |
| 82 | |
| 83 | template<> JSValue JSTextEventConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
| 84 | { |
| 85 | return JSUIEvent::getConstructor(vm, &globalObject); |
| 86 | } |
| 87 | |
| 88 | template<> void JSTextEventConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
| 89 | { |
| 90 | putDirect(vm, vm.propertyNames->prototype, JSTextEvent::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 91 | putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("TextEvent"_s )), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 92 | putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 93 | } |
| 94 | |
| 95 | template<> const ClassInfo JSTextEventConstructor::s_info = { "TextEvent" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSTextEventConstructor) }; |
| 96 | |
| 97 | /* Hash table for prototype */ |
| 98 | |
| 99 | static const HashTableValue JSTextEventPrototypeTableValues[] = |
| 100 | { |
| 101 | { "constructor" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTextEventConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTextEventConstructor) } }, |
| 102 | { "data" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTextEventData), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 103 | { "initTextEvent" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsTextEventPrototypeFunctionInitTextEvent), (intptr_t) (0) } }, |
| 104 | }; |
| 105 | |
| 106 | const ClassInfo JSTextEventPrototype::s_info = { "TextEventPrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSTextEventPrototype) }; |
| 107 | |
| 108 | void JSTextEventPrototype::finishCreation(VM& vm) |
| 109 | { |
| 110 | Base::finishCreation(vm); |
| 111 | reifyStaticProperties(vm, JSTextEvent::info(), JSTextEventPrototypeTableValues, *this); |
| 112 | } |
| 113 | |
| 114 | const ClassInfo JSTextEvent::s_info = { "TextEvent" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSTextEvent) }; |
| 115 | |
| 116 | JSTextEvent::JSTextEvent(Structure* structure, JSDOMGlobalObject& globalObject, Ref<TextEvent>&& impl) |
| 117 | : JSUIEvent(structure, globalObject, WTFMove(impl)) |
| 118 | { |
| 119 | } |
| 120 | |
| 121 | void JSTextEvent::finishCreation(VM& vm) |
| 122 | { |
| 123 | Base::finishCreation(vm); |
| 124 | ASSERT(inherits(vm, info())); |
| 125 | |
| 126 | } |
| 127 | |
| 128 | JSObject* JSTextEvent::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
| 129 | { |
| 130 | return JSTextEventPrototype::create(vm, &globalObject, JSTextEventPrototype::createStructure(vm, &globalObject, JSUIEvent::prototype(vm, globalObject))); |
| 131 | } |
| 132 | |
| 133 | JSObject* JSTextEvent::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
| 134 | { |
| 135 | return getDOMPrototype<JSTextEvent>(vm, globalObject); |
| 136 | } |
| 137 | |
| 138 | JSValue JSTextEvent::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
| 139 | { |
| 140 | return getDOMConstructor<JSTextEventConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
| 141 | } |
| 142 | |
| 143 | template<> inline JSTextEvent* IDLAttribute<JSTextEvent>::cast(ExecState& state, EncodedJSValue thisValue) |
| 144 | { |
| 145 | return jsDynamicCast<JSTextEvent*>(state.vm(), JSValue::decode(thisValue)); |
| 146 | } |
| 147 | |
| 148 | template<> inline JSTextEvent* IDLOperation<JSTextEvent>::cast(ExecState& state) |
| 149 | { |
| 150 | return jsDynamicCast<JSTextEvent*>(state.vm(), state.thisValue()); |
| 151 | } |
| 152 | |
| 153 | EncodedJSValue jsTextEventConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 154 | { |
| 155 | VM& vm = state->vm(); |
| 156 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 157 | auto* prototype = jsDynamicCast<JSTextEventPrototype*>(vm, JSValue::decode(thisValue)); |
| 158 | if (UNLIKELY(!prototype)) |
| 159 | return throwVMTypeError(state, throwScope); |
| 160 | return JSValue::encode(JSTextEvent::getConstructor(state->vm(), prototype->globalObject())); |
| 161 | } |
| 162 | |
| 163 | bool setJSTextEventConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| 164 | { |
| 165 | VM& vm = state->vm(); |
| 166 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 167 | auto* prototype = jsDynamicCast<JSTextEventPrototype*>(vm, JSValue::decode(thisValue)); |
| 168 | if (UNLIKELY(!prototype)) { |
| 169 | throwVMTypeError(state, throwScope); |
| 170 | return false; |
| 171 | } |
| 172 | // Shadowing a built-in constructor |
| 173 | return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue)); |
| 174 | } |
| 175 | |
| 176 | static inline JSValue jsTextEventDataGetter(ExecState& state, JSTextEvent& thisObject, ThrowScope& throwScope) |
| 177 | { |
| 178 | UNUSED_PARAM(throwScope); |
| 179 | UNUSED_PARAM(state); |
| 180 | auto& impl = thisObject.wrapped(); |
| 181 | JSValue result = toJS<IDLDOMString>(state, throwScope, impl.data()); |
| 182 | return result; |
| 183 | } |
| 184 | |
| 185 | EncodedJSValue jsTextEventData(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 186 | { |
| 187 | return IDLAttribute<JSTextEvent>::get<jsTextEventDataGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "data" ); |
| 188 | } |
| 189 | |
| 190 | static inline JSC::EncodedJSValue jsTextEventPrototypeFunctionInitTextEventBody(JSC::ExecState* state, typename IDLOperation<JSTextEvent>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 191 | { |
| 192 | UNUSED_PARAM(state); |
| 193 | UNUSED_PARAM(throwScope); |
| 194 | auto& impl = castedThis->wrapped(); |
| 195 | auto typeArg = convert<IDLDOMString>(*state, state->argument(0)); |
| 196 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 197 | auto canBubbleArg = convert<IDLBoolean>(*state, state->argument(1)); |
| 198 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 199 | auto cancelableArg = convert<IDLBoolean>(*state, state->argument(2)); |
| 200 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 201 | auto viewArg = convert<IDLNullable<IDLInterface<WindowProxy>>>(*state, state->argument(3), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentTypeError(state, scope, 3, "viewArg" , "TextEvent" , "initTextEvent" , "WindowProxy" ); }); |
| 202 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 203 | auto dataArg = convert<IDLDOMString>(*state, state->argument(4)); |
| 204 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 205 | impl.initTextEvent(WTFMove(typeArg), WTFMove(canBubbleArg), WTFMove(cancelableArg), WTFMove(viewArg), WTFMove(dataArg)); |
| 206 | return JSValue::encode(jsUndefined()); |
| 207 | } |
| 208 | |
| 209 | EncodedJSValue JSC_HOST_CALL jsTextEventPrototypeFunctionInitTextEvent(ExecState* state) |
| 210 | { |
| 211 | return IDLOperation<JSTextEvent>::call<jsTextEventPrototypeFunctionInitTextEventBody>(*state, "initTextEvent" ); |
| 212 | } |
| 213 | |
| 214 | void JSTextEvent::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) |
| 215 | { |
| 216 | auto* thisObject = jsCast<JSTextEvent*>(cell); |
| 217 | builder.setWrappedObjectForCell(cell, &thisObject->wrapped()); |
| 218 | if (thisObject->scriptExecutionContext()) |
| 219 | builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); |
| 220 | Base::heapSnapshot(cell, builder); |
| 221 | } |
| 222 | |
| 223 | |
| 224 | } |
| 225 | |