| /* |
| This file is part of the WebKit open source project. |
| This file has been generated by generate-bindings.pl. DO NOT MODIFY! |
| |
| This library is free software; you can redistribute it and/or |
| modify it under the terms of the GNU Library General Public |
| License as published by the Free Software Foundation; either |
| version 2 of the License, or (at your option) any later version. |
| |
| This library is distributed in the hope that it will be useful, |
| but WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| Library General Public License for more details. |
| |
| You should have received a copy of the GNU Library General Public License |
| along with this library; see the file COPYING.LIB. If not, write to |
| the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| Boston, MA 02110-1301, USA. |
| */ |
| |
| #include "config.h" |
| #include "JSMutationEvent.h" |
| |
| #include "ExceptionCode.h" |
| #include "JSDOMBinding.h" |
| #include "JSDOMConstructor.h" |
| #include "JSDOMConvert.h" |
| #include "JSNode.h" |
| #include "URL.h" |
| #include <runtime/Error.h> |
| #include <runtime/JSString.h> |
| #include <wtf/GetPtr.h> |
| |
| using namespace JSC; |
| |
| namespace WebCore { |
| |
| // Functions |
| |
| JSC::EncodedJSValue JSC_HOST_CALL jsMutationEventPrototypeFunctionInitMutationEvent(JSC::ExecState*); |
| |
| // Attributes |
| |
| JSC::EncodedJSValue jsMutationEventRelatedNode(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| JSC::EncodedJSValue jsMutationEventPrevValue(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| JSC::EncodedJSValue jsMutationEventNewValue(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| JSC::EncodedJSValue jsMutationEventAttrName(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| JSC::EncodedJSValue jsMutationEventAttrChange(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| JSC::EncodedJSValue jsMutationEventConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| bool setJSMutationEventConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| |
| class JSMutationEventPrototype : public JSC::JSNonFinalObject { |
| public: |
| typedef JSC::JSNonFinalObject Base; |
| static JSMutationEventPrototype* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure) |
| { |
| JSMutationEventPrototype* ptr = new (NotNull, JSC::allocateCell<JSMutationEventPrototype>(vm.heap)) JSMutationEventPrototype(vm, globalObject, structure); |
| ptr->finishCreation(vm); |
| return ptr; |
| } |
| |
| DECLARE_INFO; |
| static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) |
| { |
| return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); |
| } |
| |
| private: |
| JSMutationEventPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
| : JSC::JSNonFinalObject(vm, structure) |
| { |
| } |
| |
| void finishCreation(JSC::VM&); |
| }; |
| |
| typedef JSDOMConstructorNotConstructable<JSMutationEvent> JSMutationEventConstructor; |
| |
| /* Hash table for constructor */ |
| |
| static const HashTableValue JSMutationEventConstructorTableValues[] = |
| { |
| { "MODIFICATION", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(1) } }, |
| { "ADDITION", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(2) } }, |
| { "REMOVAL", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(3) } }, |
| }; |
| |
| static_assert(MutationEvent::MODIFICATION == 1, "MODIFICATION in MutationEvent does not match value from IDL"); |
| static_assert(MutationEvent::ADDITION == 2, "ADDITION in MutationEvent does not match value from IDL"); |
| static_assert(MutationEvent::REMOVAL == 3, "REMOVAL in MutationEvent does not match value from IDL"); |
| |
| template<> JSValue JSMutationEventConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
| { |
| return JSEvent::getConstructor(vm, &globalObject); |
| } |
| |
| template<> void JSMutationEventConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
| { |
| putDirect(vm, vm.propertyNames->prototype, JSMutationEvent::prototype(vm, &globalObject), DontDelete | ReadOnly | DontEnum); |
| putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String(ASCIILiteral("MutationEvent"))), ReadOnly | DontEnum); |
| putDirect(vm, vm.propertyNames->length, jsNumber(0), ReadOnly | DontEnum); |
| reifyStaticProperties(vm, JSMutationEventConstructorTableValues, *this); |
| } |
| |
| template<> const ClassInfo JSMutationEventConstructor::s_info = { "MutationEvent", &Base::s_info, 0, CREATE_METHOD_TABLE(JSMutationEventConstructor) }; |
| |
| /* Hash table for prototype */ |
| |
| static const HashTableValue JSMutationEventPrototypeTableValues[] = |
| { |
| { "constructor", DontEnum, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMutationEventConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSMutationEventConstructor) } }, |
| { "relatedNode", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMutationEventRelatedNode), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| { "prevValue", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMutationEventPrevValue), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| { "newValue", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMutationEventNewValue), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| { "attrName", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMutationEventAttrName), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| { "attrChange", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMutationEventAttrChange), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| { "initMutationEvent", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsMutationEventPrototypeFunctionInitMutationEvent), (intptr_t) (0) } }, |
| { "MODIFICATION", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(1) } }, |
| { "ADDITION", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(2) } }, |
| { "REMOVAL", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(3) } }, |
| }; |
| |
| const ClassInfo JSMutationEventPrototype::s_info = { "MutationEventPrototype", &Base::s_info, 0, CREATE_METHOD_TABLE(JSMutationEventPrototype) }; |
| |
| void JSMutationEventPrototype::finishCreation(VM& vm) |
| { |
| Base::finishCreation(vm); |
| reifyStaticProperties(vm, JSMutationEventPrototypeTableValues, *this); |
| } |
| |
| const ClassInfo JSMutationEvent::s_info = { "MutationEvent", &Base::s_info, 0, CREATE_METHOD_TABLE(JSMutationEvent) }; |
| |
| JSMutationEvent::JSMutationEvent(Structure* structure, JSDOMGlobalObject& globalObject, Ref<MutationEvent>&& impl) |
| : JSEvent(structure, globalObject, WTFMove(impl)) |
| { |
| } |
| |
| JSObject* JSMutationEvent::createPrototype(VM& vm, JSGlobalObject* globalObject) |
| { |
| return JSMutationEventPrototype::create(vm, globalObject, JSMutationEventPrototype::createStructure(vm, globalObject, JSEvent::prototype(vm, globalObject))); |
| } |
| |
| JSObject* JSMutationEvent::prototype(VM& vm, JSGlobalObject* globalObject) |
| { |
| return getDOMPrototype<JSMutationEvent>(vm, globalObject); |
| } |
| |
| EncodedJSValue jsMutationEventRelatedNode(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| UNUSED_PARAM(throwScope); |
| UNUSED_PARAM(thisValue); |
| JSValue decodedThisValue = JSValue::decode(thisValue); |
| auto* castedThis = jsDynamicCast<JSMutationEvent*>(decodedThisValue); |
| if (UNLIKELY(!castedThis)) { |
| return throwGetterTypeError(*state, throwScope, "MutationEvent", "relatedNode"); |
| } |
| auto& impl = castedThis->wrapped(); |
| JSValue result = toJS(state, castedThis->globalObject(), impl.relatedNode()); |
| return JSValue::encode(result); |
| } |
| |
| |
| EncodedJSValue jsMutationEventPrevValue(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| UNUSED_PARAM(throwScope); |
| UNUSED_PARAM(thisValue); |
| JSValue decodedThisValue = JSValue::decode(thisValue); |
| auto* castedThis = jsDynamicCast<JSMutationEvent*>(decodedThisValue); |
| if (UNLIKELY(!castedThis)) { |
| return throwGetterTypeError(*state, throwScope, "MutationEvent", "prevValue"); |
| } |
| auto& impl = castedThis->wrapped(); |
| JSValue result = jsStringWithCache(state, impl.prevValue()); |
| return JSValue::encode(result); |
| } |
| |
| |
| EncodedJSValue jsMutationEventNewValue(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| UNUSED_PARAM(throwScope); |
| UNUSED_PARAM(thisValue); |
| JSValue decodedThisValue = JSValue::decode(thisValue); |
| auto* castedThis = jsDynamicCast<JSMutationEvent*>(decodedThisValue); |
| if (UNLIKELY(!castedThis)) { |
| return throwGetterTypeError(*state, throwScope, "MutationEvent", "newValue"); |
| } |
| auto& impl = castedThis->wrapped(); |
| JSValue result = jsStringWithCache(state, impl.newValue()); |
| return JSValue::encode(result); |
| } |
| |
| |
| EncodedJSValue jsMutationEventAttrName(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| UNUSED_PARAM(throwScope); |
| UNUSED_PARAM(thisValue); |
| JSValue decodedThisValue = JSValue::decode(thisValue); |
| auto* castedThis = jsDynamicCast<JSMutationEvent*>(decodedThisValue); |
| if (UNLIKELY(!castedThis)) { |
| return throwGetterTypeError(*state, throwScope, "MutationEvent", "attrName"); |
| } |
| auto& impl = castedThis->wrapped(); |
| JSValue result = jsStringWithCache(state, impl.attrName()); |
| return JSValue::encode(result); |
| } |
| |
| |
| EncodedJSValue jsMutationEventAttrChange(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| UNUSED_PARAM(throwScope); |
| UNUSED_PARAM(thisValue); |
| JSValue decodedThisValue = JSValue::decode(thisValue); |
| auto* castedThis = jsDynamicCast<JSMutationEvent*>(decodedThisValue); |
| if (UNLIKELY(!castedThis)) { |
| return throwGetterTypeError(*state, throwScope, "MutationEvent", "attrChange"); |
| } |
| auto& impl = castedThis->wrapped(); |
| JSValue result = jsNumber(impl.attrChange()); |
| return JSValue::encode(result); |
| } |
| |
| |
| EncodedJSValue jsMutationEventConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| JSMutationEventPrototype* domObject = jsDynamicCast<JSMutationEventPrototype*>(JSValue::decode(thisValue)); |
| if (UNLIKELY(!domObject)) |
| return throwVMTypeError(state, throwScope); |
| return JSValue::encode(JSMutationEvent::getConstructor(state->vm(), domObject->globalObject())); |
| } |
| |
| bool setJSMutationEventConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| JSValue value = JSValue::decode(encodedValue); |
| JSMutationEventPrototype* domObject = jsDynamicCast<JSMutationEventPrototype*>(JSValue::decode(thisValue)); |
| if (UNLIKELY(!domObject)) { |
| throwVMTypeError(state, throwScope); |
| return false; |
| } |
| // Shadowing a built-in constructor |
| return domObject->putDirect(state->vm(), state->propertyNames().constructor, value); |
| } |
| |
| JSValue JSMutationEvent::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
| { |
| return getDOMConstructor<JSMutationEventConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
| } |
| |
| EncodedJSValue JSC_HOST_CALL jsMutationEventPrototypeFunctionInitMutationEvent(ExecState* state) |
| { |
| VM& vm = state->vm(); |
| auto throwScope = DECLARE_THROW_SCOPE(vm); |
| UNUSED_PARAM(throwScope); |
| JSValue thisValue = state->thisValue(); |
| auto castedThis = jsDynamicCast<JSMutationEvent*>(thisValue); |
| if (UNLIKELY(!castedThis)) |
| return throwThisTypeError(*state, throwScope, "MutationEvent", "initMutationEvent"); |
| ASSERT_GC_OBJECT_INHERITS(castedThis, JSMutationEvent::info()); |
| auto& impl = castedThis->wrapped(); |
| auto type = state->argument(0).toWTFString(state); |
| RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| auto canBubble = state->argument(1).toBoolean(state); |
| RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| auto cancelable = state->argument(2).toBoolean(state); |
| RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| Node* relatedNode = nullptr; |
| if (!state->argument(3).isUndefinedOrNull()) { |
| relatedNode = JSNode::toWrapped(state->uncheckedArgument(3)); |
| if (UNLIKELY(!relatedNode)) |
| return throwArgumentTypeError(*state, throwScope, 3, "relatedNode", "MutationEvent", "initMutationEvent", "Node"); |
| } |
| auto prevValue = state->argument(4).toWTFString(state); |
| RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| auto newValue = state->argument(5).toWTFString(state); |
| RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| auto attrName = state->argument(6).toWTFString(state); |
| RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| auto attrChange = convert<uint16_t>(*state, state->argument(7), NormalConversion); |
| RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| impl.initMutationEvent(WTFMove(type), WTFMove(canBubble), WTFMove(cancelable), WTFMove(relatedNode), WTFMove(prevValue), WTFMove(newValue), WTFMove(attrName), WTFMove(attrChange)); |
| return JSValue::encode(jsUndefined()); |
| } |
| |
| |
| } |