blob: 936f7182d159f7a68472942683d2d0fa8875dbbb [file] [log] [blame]
/*
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 "JSNode.h"
#include "CustomElementReactionQueue.h"
#include "ExceptionCode.h"
#include "JSDOMBinding.h"
#include "JSDOMConstructor.h"
#include "JSDOMConvert.h"
#include "JSDocument.h"
#include "JSElement.h"
#include "JSNode.h"
#include "JSNodeList.h"
#include "NameNodeList.h"
#include "Node.h"
#include "RuntimeEnabledFeatures.h"
#include "URL.h"
#include <runtime/Error.h>
#include <runtime/JSString.h>
#include <wtf/GetPtr.h>
using namespace JSC;
namespace WebCore {
template<> Optional<Node::GetRootNodeOptions> convertDictionary<Node::GetRootNodeOptions>(ExecState& state, JSValue value)
{
VM& vm = state.vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
if (value.isUndefinedOrNull())
return Node::GetRootNodeOptions { false };
auto* object = value.getObject();
if (UNLIKELY(!object || object->type() == RegExpObjectType)) {
throwTypeError(&state, throwScope);
return Nullopt;
}
auto composed = convertOptional<bool>(state, object->get(&state, Identifier::fromString(&state, "composed")), false);
return Node::GetRootNodeOptions { WTFMove(composed) };
}
// Functions
JSC::EncodedJSValue JSC_HOST_CALL jsNodePrototypeFunctionInsertBefore(JSC::ExecState*);
JSC::EncodedJSValue JSC_HOST_CALL jsNodePrototypeFunctionReplaceChild(JSC::ExecState*);
JSC::EncodedJSValue JSC_HOST_CALL jsNodePrototypeFunctionRemoveChild(JSC::ExecState*);
JSC::EncodedJSValue JSC_HOST_CALL jsNodePrototypeFunctionAppendChild(JSC::ExecState*);
JSC::EncodedJSValue JSC_HOST_CALL jsNodePrototypeFunctionHasChildNodes(JSC::ExecState*);
JSC::EncodedJSValue JSC_HOST_CALL jsNodePrototypeFunctionCloneNode(JSC::ExecState*);
JSC::EncodedJSValue JSC_HOST_CALL jsNodePrototypeFunctionNormalize(JSC::ExecState*);
JSC::EncodedJSValue JSC_HOST_CALL jsNodePrototypeFunctionIsSameNode(JSC::ExecState*);
JSC::EncodedJSValue JSC_HOST_CALL jsNodePrototypeFunctionIsEqualNode(JSC::ExecState*);
JSC::EncodedJSValue JSC_HOST_CALL jsNodePrototypeFunctionLookupPrefix(JSC::ExecState*);
JSC::EncodedJSValue JSC_HOST_CALL jsNodePrototypeFunctionLookupNamespaceURI(JSC::ExecState*);
JSC::EncodedJSValue JSC_HOST_CALL jsNodePrototypeFunctionIsDefaultNamespace(JSC::ExecState*);
JSC::EncodedJSValue JSC_HOST_CALL jsNodePrototypeFunctionCompareDocumentPosition(JSC::ExecState*);
JSC::EncodedJSValue JSC_HOST_CALL jsNodePrototypeFunctionContains(JSC::ExecState*);
JSC::EncodedJSValue JSC_HOST_CALL jsNodePrototypeFunctionGetRootNode(JSC::ExecState*);
// Attributes
JSC::EncodedJSValue jsNodeNodeName(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
JSC::EncodedJSValue jsNodeNodeValue(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
bool setJSNodeNodeValue(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
JSC::EncodedJSValue jsNodeNodeType(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
JSC::EncodedJSValue jsNodeParentNode(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
JSC::EncodedJSValue jsNodeChildNodes(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
JSC::EncodedJSValue jsNodeFirstChild(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
JSC::EncodedJSValue jsNodeLastChild(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
JSC::EncodedJSValue jsNodePreviousSibling(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
JSC::EncodedJSValue jsNodeNextSibling(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
JSC::EncodedJSValue jsNodeOwnerDocument(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
JSC::EncodedJSValue jsNodeBaseURI(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
JSC::EncodedJSValue jsNodeTextContent(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
bool setJSNodeTextContent(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
JSC::EncodedJSValue jsNodeIsConnected(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
JSC::EncodedJSValue jsNodeParentElement(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
JSC::EncodedJSValue jsNodeConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
bool setJSNodeConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
class JSNodePrototype : public JSC::JSNonFinalObject {
public:
typedef JSC::JSNonFinalObject Base;
static JSNodePrototype* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
{
JSNodePrototype* ptr = new (NotNull, JSC::allocateCell<JSNodePrototype>(vm.heap)) JSNodePrototype(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:
JSNodePrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
: JSC::JSNonFinalObject(vm, structure)
{
}
void finishCreation(JSC::VM&);
};
typedef JSDOMConstructorNotConstructable<JSNode> JSNodeConstructor;
/* Hash table for constructor */
static const HashTableValue JSNodeConstructorTableValues[] =
{
{ "ELEMENT_NODE", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(1) } },
{ "ATTRIBUTE_NODE", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(2) } },
{ "TEXT_NODE", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(3) } },
{ "CDATA_SECTION_NODE", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(4) } },
{ "ENTITY_REFERENCE_NODE", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(5) } },
{ "ENTITY_NODE", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(6) } },
{ "PROCESSING_INSTRUCTION_NODE", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(7) } },
{ "COMMENT_NODE", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(8) } },
{ "DOCUMENT_NODE", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(9) } },
{ "DOCUMENT_TYPE_NODE", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(10) } },
{ "DOCUMENT_FRAGMENT_NODE", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(11) } },
{ "NOTATION_NODE", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(12) } },
{ "DOCUMENT_POSITION_DISCONNECTED", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(0x01) } },
{ "DOCUMENT_POSITION_PRECEDING", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(0x02) } },
{ "DOCUMENT_POSITION_FOLLOWING", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(0x04) } },
{ "DOCUMENT_POSITION_CONTAINS", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(0x08) } },
{ "DOCUMENT_POSITION_CONTAINED_BY", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(0x10) } },
{ "DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(0x20) } },
};
static_assert(Node::ELEMENT_NODE == 1, "ELEMENT_NODE in Node does not match value from IDL");
static_assert(Node::ATTRIBUTE_NODE == 2, "ATTRIBUTE_NODE in Node does not match value from IDL");
static_assert(Node::TEXT_NODE == 3, "TEXT_NODE in Node does not match value from IDL");
static_assert(Node::CDATA_SECTION_NODE == 4, "CDATA_SECTION_NODE in Node does not match value from IDL");
static_assert(Node::ENTITY_REFERENCE_NODE == 5, "ENTITY_REFERENCE_NODE in Node does not match value from IDL");
static_assert(Node::ENTITY_NODE == 6, "ENTITY_NODE in Node does not match value from IDL");
static_assert(Node::PROCESSING_INSTRUCTION_NODE == 7, "PROCESSING_INSTRUCTION_NODE in Node does not match value from IDL");
static_assert(Node::COMMENT_NODE == 8, "COMMENT_NODE in Node does not match value from IDL");
static_assert(Node::DOCUMENT_NODE == 9, "DOCUMENT_NODE in Node does not match value from IDL");
static_assert(Node::DOCUMENT_TYPE_NODE == 10, "DOCUMENT_TYPE_NODE in Node does not match value from IDL");
static_assert(Node::DOCUMENT_FRAGMENT_NODE == 11, "DOCUMENT_FRAGMENT_NODE in Node does not match value from IDL");
static_assert(Node::NOTATION_NODE == 12, "NOTATION_NODE in Node does not match value from IDL");
static_assert(Node::DOCUMENT_POSITION_DISCONNECTED == 0x01, "DOCUMENT_POSITION_DISCONNECTED in Node does not match value from IDL");
static_assert(Node::DOCUMENT_POSITION_PRECEDING == 0x02, "DOCUMENT_POSITION_PRECEDING in Node does not match value from IDL");
static_assert(Node::DOCUMENT_POSITION_FOLLOWING == 0x04, "DOCUMENT_POSITION_FOLLOWING in Node does not match value from IDL");
static_assert(Node::DOCUMENT_POSITION_CONTAINS == 0x08, "DOCUMENT_POSITION_CONTAINS in Node does not match value from IDL");
static_assert(Node::DOCUMENT_POSITION_CONTAINED_BY == 0x10, "DOCUMENT_POSITION_CONTAINED_BY in Node does not match value from IDL");
static_assert(Node::DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC == 0x20, "DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC in Node does not match value from IDL");
template<> JSValue JSNodeConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
{
return JSEventTarget::getConstructor(vm, &globalObject);
}
template<> void JSNodeConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
{
putDirect(vm, vm.propertyNames->prototype, JSNode::prototype(vm, &globalObject), DontDelete | ReadOnly | DontEnum);
putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String(ASCIILiteral("Node"))), ReadOnly | DontEnum);
putDirect(vm, vm.propertyNames->length, jsNumber(0), ReadOnly | DontEnum);
reifyStaticProperties(vm, JSNodeConstructorTableValues, *this);
}
template<> const ClassInfo JSNodeConstructor::s_info = { "Node", &Base::s_info, 0, CREATE_METHOD_TABLE(JSNodeConstructor) };
/* Hash table for prototype */
static const HashTableValue JSNodePrototypeTableValues[] =
{
{ "constructor", DontEnum, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsNodeConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSNodeConstructor) } },
{ "nodeName", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsNodeNodeName), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
{ "nodeValue", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsNodeNodeValue), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSNodeNodeValue) } },
{ "nodeType", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsNodeNodeType), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
{ "parentNode", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsNodeParentNode), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
{ "childNodes", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsNodeChildNodes), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
{ "firstChild", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsNodeFirstChild), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
{ "lastChild", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsNodeLastChild), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
{ "previousSibling", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsNodePreviousSibling), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
{ "nextSibling", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsNodeNextSibling), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
{ "ownerDocument", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsNodeOwnerDocument), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
{ "baseURI", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsNodeBaseURI), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
{ "textContent", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsNodeTextContent), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSNodeTextContent) } },
{ "isConnected", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsNodeIsConnected), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
{ "parentElement", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsNodeParentElement), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
{ "insertBefore", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsNodePrototypeFunctionInsertBefore), (intptr_t) (2) } },
{ "replaceChild", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsNodePrototypeFunctionReplaceChild), (intptr_t) (2) } },
{ "removeChild", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsNodePrototypeFunctionRemoveChild), (intptr_t) (1) } },
{ "appendChild", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsNodePrototypeFunctionAppendChild), (intptr_t) (1) } },
{ "hasChildNodes", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsNodePrototypeFunctionHasChildNodes), (intptr_t) (0) } },
{ "cloneNode", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsNodePrototypeFunctionCloneNode), (intptr_t) (0) } },
{ "normalize", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsNodePrototypeFunctionNormalize), (intptr_t) (0) } },
{ "isSameNode", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsNodePrototypeFunctionIsSameNode), (intptr_t) (1) } },
{ "isEqualNode", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsNodePrototypeFunctionIsEqualNode), (intptr_t) (1) } },
{ "lookupPrefix", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsNodePrototypeFunctionLookupPrefix), (intptr_t) (1) } },
{ "lookupNamespaceURI", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsNodePrototypeFunctionLookupNamespaceURI), (intptr_t) (1) } },
{ "isDefaultNamespace", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsNodePrototypeFunctionIsDefaultNamespace), (intptr_t) (1) } },
{ "compareDocumentPosition", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsNodePrototypeFunctionCompareDocumentPosition), (intptr_t) (1) } },
{ "contains", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsNodePrototypeFunctionContains), (intptr_t) (1) } },
{ "getRootNode", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsNodePrototypeFunctionGetRootNode), (intptr_t) (0) } },
{ "ELEMENT_NODE", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(1) } },
{ "ATTRIBUTE_NODE", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(2) } },
{ "TEXT_NODE", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(3) } },
{ "CDATA_SECTION_NODE", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(4) } },
{ "ENTITY_REFERENCE_NODE", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(5) } },
{ "ENTITY_NODE", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(6) } },
{ "PROCESSING_INSTRUCTION_NODE", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(7) } },
{ "COMMENT_NODE", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(8) } },
{ "DOCUMENT_NODE", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(9) } },
{ "DOCUMENT_TYPE_NODE", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(10) } },
{ "DOCUMENT_FRAGMENT_NODE", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(11) } },
{ "NOTATION_NODE", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(12) } },
{ "DOCUMENT_POSITION_DISCONNECTED", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(0x01) } },
{ "DOCUMENT_POSITION_PRECEDING", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(0x02) } },
{ "DOCUMENT_POSITION_FOLLOWING", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(0x04) } },
{ "DOCUMENT_POSITION_CONTAINS", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(0x08) } },
{ "DOCUMENT_POSITION_CONTAINED_BY", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(0x10) } },
{ "DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(0x20) } },
};
const ClassInfo JSNodePrototype::s_info = { "NodePrototype", &Base::s_info, 0, CREATE_METHOD_TABLE(JSNodePrototype) };
void JSNodePrototype::finishCreation(VM& vm)
{
Base::finishCreation(vm);
reifyStaticProperties(vm, JSNodePrototypeTableValues, *this);
if (!RuntimeEnabledFeatures::sharedFeatures().shadowDOMEnabled()) {
Identifier propertyName = Identifier::fromString(&vm, reinterpret_cast<const LChar*>("getRootNode"), strlen("getRootNode"));
VM::DeletePropertyModeScope scope(vm, VM::DeletePropertyMode::IgnoreConfigurable);
JSObject::deleteProperty(this, globalObject()->globalExec(), propertyName);
}
if (!RuntimeEnabledFeatures::sharedFeatures().shadowDOMEnabled()) {
Identifier propertyName = Identifier::fromString(&vm, reinterpret_cast<const LChar*>("isConnected"), strlen("isConnected"));
VM::DeletePropertyModeScope scope(vm, VM::DeletePropertyMode::IgnoreConfigurable);
JSObject::deleteProperty(this, globalObject()->globalExec(), propertyName);
}
}
const ClassInfo JSNode::s_info = { "Node", &Base::s_info, 0, CREATE_METHOD_TABLE(JSNode) };
JSNode::JSNode(Structure* structure, JSDOMGlobalObject& globalObject, Ref<Node>&& impl)
: JSEventTarget(structure, globalObject, WTFMove(impl))
{
}
JSObject* JSNode::createPrototype(VM& vm, JSGlobalObject* globalObject)
{
return JSNodePrototype::create(vm, globalObject, JSNodePrototype::createStructure(vm, globalObject, JSEventTarget::prototype(vm, globalObject)));
}
JSObject* JSNode::prototype(VM& vm, JSGlobalObject* globalObject)
{
return getDOMPrototype<JSNode>(vm, globalObject);
}
EncodedJSValue jsNodeNodeName(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 = jsNodeCast(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "Node", "nodeName");
}
auto& impl = castedThis->wrapped();
JSValue result = jsStringWithCache(state, impl.nodeName());
return JSValue::encode(result);
}
EncodedJSValue jsNodeNodeValue(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 = jsNodeCast(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "Node", "nodeValue");
}
auto& impl = castedThis->wrapped();
JSValue result = jsStringOrNull(state, impl.nodeValue());
return JSValue::encode(result);
}
EncodedJSValue jsNodeNodeType(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 = jsNodeCast(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "Node", "nodeType");
}
auto& impl = castedThis->wrapped();
JSValue result = jsNumber(impl.nodeType());
return JSValue::encode(result);
}
EncodedJSValue jsNodeParentNode(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 = jsNodeCast(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "Node", "parentNode");
}
auto& impl = castedThis->wrapped();
JSValue result = toJS(state, castedThis->globalObject(), impl.parentNode());
return JSValue::encode(result);
}
EncodedJSValue jsNodeChildNodes(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 = jsNodeCast(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "Node", "childNodes");
}
auto& impl = castedThis->wrapped();
JSValue result = toJS(state, castedThis->globalObject(), impl.childNodes());
return JSValue::encode(result);
}
EncodedJSValue jsNodeFirstChild(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 = jsNodeCast(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "Node", "firstChild");
}
auto& impl = castedThis->wrapped();
JSValue result = toJS(state, castedThis->globalObject(), impl.firstChild());
return JSValue::encode(result);
}
EncodedJSValue jsNodeLastChild(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 = jsNodeCast(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "Node", "lastChild");
}
auto& impl = castedThis->wrapped();
JSValue result = toJS(state, castedThis->globalObject(), impl.lastChild());
return JSValue::encode(result);
}
EncodedJSValue jsNodePreviousSibling(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 = jsNodeCast(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "Node", "previousSibling");
}
auto& impl = castedThis->wrapped();
JSValue result = toJS(state, castedThis->globalObject(), impl.previousSibling());
return JSValue::encode(result);
}
EncodedJSValue jsNodeNextSibling(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 = jsNodeCast(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "Node", "nextSibling");
}
auto& impl = castedThis->wrapped();
JSValue result = toJS(state, castedThis->globalObject(), impl.nextSibling());
return JSValue::encode(result);
}
EncodedJSValue jsNodeOwnerDocument(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 = jsNodeCast(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "Node", "ownerDocument");
}
auto& impl = castedThis->wrapped();
JSValue result = toJS(state, castedThis->globalObject(), impl.ownerDocument());
return JSValue::encode(result);
}
EncodedJSValue jsNodeBaseURI(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 = jsNodeCast(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "Node", "baseURI");
}
auto& impl = castedThis->wrapped();
JSValue result = jsStringWithCache(state, impl.baseURI());
return JSValue::encode(result);
}
EncodedJSValue jsNodeTextContent(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 = jsNodeCast(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "Node", "textContent");
}
auto& impl = castedThis->wrapped();
JSValue result = jsStringOrNull(state, impl.textContent());
return JSValue::encode(result);
}
EncodedJSValue jsNodeIsConnected(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 = jsNodeCast(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "Node", "isConnected");
}
auto& impl = castedThis->wrapped();
JSValue result = jsBoolean(impl.inDocument());
return JSValue::encode(result);
}
EncodedJSValue jsNodeParentElement(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 = jsNodeCast(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "Node", "parentElement");
}
auto& impl = castedThis->wrapped();
JSValue result = toJS(state, castedThis->globalObject(), impl.parentElement());
return JSValue::encode(result);
}
EncodedJSValue jsNodeConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSNodePrototype* domObject = jsDynamicCast<JSNodePrototype*>(JSValue::decode(thisValue));
if (UNLIKELY(!domObject))
return throwVMTypeError(state, throwScope);
return JSValue::encode(JSNode::getConstructor(state->vm(), domObject->globalObject()));
}
bool setJSNodeConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSValue value = JSValue::decode(encodedValue);
JSNodePrototype* domObject = jsDynamicCast<JSNodePrototype*>(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);
}
bool setJSNodeNodeValue(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
JSValue value = JSValue::decode(encodedValue);
UNUSED_PARAM(thisValue);
JSNode* castedThis = jsNodeCast(JSValue::decode(thisValue));
if (UNLIKELY(!castedThis)) {
return throwSetterTypeError(*state, throwScope, "Node", "nodeValue");
}
auto& impl = castedThis->wrapped();
ExceptionCode ec = 0;
auto nativeValue = valueToStringWithUndefinedOrNullCheck(state, value);
RETURN_IF_EXCEPTION(throwScope, false);
impl.setNodeValue(WTFMove(nativeValue), ec);
setDOMException(state, throwScope, ec);
return true;
}
bool setJSNodeTextContent(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
JSValue value = JSValue::decode(encodedValue);
UNUSED_PARAM(thisValue);
JSNode* castedThis = jsNodeCast(JSValue::decode(thisValue));
if (UNLIKELY(!castedThis)) {
return throwSetterTypeError(*state, throwScope, "Node", "textContent");
}
auto& impl = castedThis->wrapped();
ExceptionCode ec = 0;
auto nativeValue = valueToStringWithUndefinedOrNullCheck(state, value);
RETURN_IF_EXCEPTION(throwScope, false);
impl.setTextContent(WTFMove(nativeValue), ec);
setDOMException(state, throwScope, ec);
return true;
}
JSValue JSNode::getConstructor(VM& vm, const JSGlobalObject* globalObject)
{
return getDOMConstructor<JSNodeConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
}
EncodedJSValue JSC_HOST_CALL jsNodePrototypeFunctionInsertBefore(ExecState* state)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
JSValue thisValue = state->thisValue();
auto castedThis = jsNodeCast(thisValue);
if (UNLIKELY(!castedThis))
return throwThisTypeError(*state, throwScope, "Node", "insertBefore");
ASSERT_GC_OBJECT_INHERITS(castedThis, JSNode::info());
return JSValue::encode(castedThis->insertBefore(*state));
}
EncodedJSValue JSC_HOST_CALL jsNodePrototypeFunctionReplaceChild(ExecState* state)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
JSValue thisValue = state->thisValue();
auto castedThis = jsNodeCast(thisValue);
if (UNLIKELY(!castedThis))
return throwThisTypeError(*state, throwScope, "Node", "replaceChild");
ASSERT_GC_OBJECT_INHERITS(castedThis, JSNode::info());
return JSValue::encode(castedThis->replaceChild(*state));
}
EncodedJSValue JSC_HOST_CALL jsNodePrototypeFunctionRemoveChild(ExecState* state)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
#if ENABLE(CUSTOM_ELEMENTS)
CustomElementReactionStack customElementReactionStack;
#endif
JSValue thisValue = state->thisValue();
auto castedThis = jsNodeCast(thisValue);
if (UNLIKELY(!castedThis))
return throwThisTypeError(*state, throwScope, "Node", "removeChild");
ASSERT_GC_OBJECT_INHERITS(castedThis, JSNode::info());
return JSValue::encode(castedThis->removeChild(*state));
}
EncodedJSValue JSC_HOST_CALL jsNodePrototypeFunctionAppendChild(ExecState* state)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
#if ENABLE(CUSTOM_ELEMENTS)
CustomElementReactionStack customElementReactionStack;
#endif
JSValue thisValue = state->thisValue();
auto castedThis = jsNodeCast(thisValue);
if (UNLIKELY(!castedThis))
return throwThisTypeError(*state, throwScope, "Node", "appendChild");
ASSERT_GC_OBJECT_INHERITS(castedThis, JSNode::info());
return JSValue::encode(castedThis->appendChild(*state));
}
EncodedJSValue JSC_HOST_CALL jsNodePrototypeFunctionHasChildNodes(ExecState* state)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
JSValue thisValue = state->thisValue();
auto castedThis = jsNodeCast(thisValue);
if (UNLIKELY(!castedThis))
return throwThisTypeError(*state, throwScope, "Node", "hasChildNodes");
ASSERT_GC_OBJECT_INHERITS(castedThis, JSNode::info());
auto& impl = castedThis->wrapped();
JSValue result = jsBoolean(impl.hasChildNodes());
return JSValue::encode(result);
}
EncodedJSValue JSC_HOST_CALL jsNodePrototypeFunctionCloneNode(ExecState* state)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
#if ENABLE(CUSTOM_ELEMENTS)
CustomElementReactionStack customElementReactionStack;
#endif
JSValue thisValue = state->thisValue();
auto castedThis = jsNodeCast(thisValue);
if (UNLIKELY(!castedThis))
return throwThisTypeError(*state, throwScope, "Node", "cloneNode");
ASSERT_GC_OBJECT_INHERITS(castedThis, JSNode::info());
auto& impl = castedThis->wrapped();
ExceptionCode ec = 0;
auto deep = state->argument(0).toBoolean(state);
RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
JSValue result = toJSNewlyCreated(state, castedThis->globalObject(), impl.cloneNodeForBindings(WTFMove(deep), ec));
setDOMException(state, throwScope, ec);
return JSValue::encode(result);
}
EncodedJSValue JSC_HOST_CALL jsNodePrototypeFunctionNormalize(ExecState* state)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
JSValue thisValue = state->thisValue();
auto castedThis = jsNodeCast(thisValue);
if (UNLIKELY(!castedThis))
return throwThisTypeError(*state, throwScope, "Node", "normalize");
ASSERT_GC_OBJECT_INHERITS(castedThis, JSNode::info());
auto& impl = castedThis->wrapped();
impl.normalize();
return JSValue::encode(jsUndefined());
}
EncodedJSValue JSC_HOST_CALL jsNodePrototypeFunctionIsSameNode(ExecState* state)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
JSValue thisValue = state->thisValue();
auto castedThis = jsNodeCast(thisValue);
if (UNLIKELY(!castedThis))
return throwThisTypeError(*state, throwScope, "Node", "isSameNode");
ASSERT_GC_OBJECT_INHERITS(castedThis, JSNode::info());
auto& impl = castedThis->wrapped();
if (UNLIKELY(state->argumentCount() < 1))
return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
Node* other = nullptr;
if (!state->uncheckedArgument(0).isUndefinedOrNull()) {
other = JSNode::toWrapped(state->uncheckedArgument(0));
if (UNLIKELY(!other))
return throwArgumentTypeError(*state, throwScope, 0, "other", "Node", "isSameNode", "Node");
}
JSValue result = jsBoolean(impl.isSameNode(WTFMove(other)));
return JSValue::encode(result);
}
EncodedJSValue JSC_HOST_CALL jsNodePrototypeFunctionIsEqualNode(ExecState* state)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
JSValue thisValue = state->thisValue();
auto castedThis = jsNodeCast(thisValue);
if (UNLIKELY(!castedThis))
return throwThisTypeError(*state, throwScope, "Node", "isEqualNode");
ASSERT_GC_OBJECT_INHERITS(castedThis, JSNode::info());
auto& impl = castedThis->wrapped();
if (UNLIKELY(state->argumentCount() < 1))
return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
Node* other = nullptr;
if (!state->uncheckedArgument(0).isUndefinedOrNull()) {
other = JSNode::toWrapped(state->uncheckedArgument(0));
if (UNLIKELY(!other))
return throwArgumentTypeError(*state, throwScope, 0, "other", "Node", "isEqualNode", "Node");
}
JSValue result = jsBoolean(impl.isEqualNode(WTFMove(other)));
return JSValue::encode(result);
}
EncodedJSValue JSC_HOST_CALL jsNodePrototypeFunctionLookupPrefix(ExecState* state)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
JSValue thisValue = state->thisValue();
auto castedThis = jsNodeCast(thisValue);
if (UNLIKELY(!castedThis))
return throwThisTypeError(*state, throwScope, "Node", "lookupPrefix");
ASSERT_GC_OBJECT_INHERITS(castedThis, JSNode::info());
auto& impl = castedThis->wrapped();
if (UNLIKELY(state->argumentCount() < 1))
return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
auto namespaceURI = valueToStringWithUndefinedOrNullCheck(state, state->uncheckedArgument(0));
RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
JSValue result = jsStringOrNull(state, impl.lookupPrefix(WTFMove(namespaceURI)));
return JSValue::encode(result);
}
EncodedJSValue JSC_HOST_CALL jsNodePrototypeFunctionLookupNamespaceURI(ExecState* state)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
JSValue thisValue = state->thisValue();
auto castedThis = jsNodeCast(thisValue);
if (UNLIKELY(!castedThis))
return throwThisTypeError(*state, throwScope, "Node", "lookupNamespaceURI");
ASSERT_GC_OBJECT_INHERITS(castedThis, JSNode::info());
auto& impl = castedThis->wrapped();
if (UNLIKELY(state->argumentCount() < 1))
return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
auto prefix = valueToStringWithUndefinedOrNullCheck(state, state->uncheckedArgument(0));
RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
JSValue result = jsStringOrNull(state, impl.lookupNamespaceURI(WTFMove(prefix)));
return JSValue::encode(result);
}
EncodedJSValue JSC_HOST_CALL jsNodePrototypeFunctionIsDefaultNamespace(ExecState* state)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
JSValue thisValue = state->thisValue();
auto castedThis = jsNodeCast(thisValue);
if (UNLIKELY(!castedThis))
return throwThisTypeError(*state, throwScope, "Node", "isDefaultNamespace");
ASSERT_GC_OBJECT_INHERITS(castedThis, JSNode::info());
auto& impl = castedThis->wrapped();
if (UNLIKELY(state->argumentCount() < 1))
return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
auto namespaceURI = valueToStringWithUndefinedOrNullCheck(state, state->uncheckedArgument(0));
RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
JSValue result = jsBoolean(impl.isDefaultNamespace(WTFMove(namespaceURI)));
return JSValue::encode(result);
}
EncodedJSValue JSC_HOST_CALL jsNodePrototypeFunctionCompareDocumentPosition(ExecState* state)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
JSValue thisValue = state->thisValue();
auto castedThis = jsNodeCast(thisValue);
if (UNLIKELY(!castedThis))
return throwThisTypeError(*state, throwScope, "Node", "compareDocumentPosition");
ASSERT_GC_OBJECT_INHERITS(castedThis, JSNode::info());
auto& impl = castedThis->wrapped();
if (UNLIKELY(state->argumentCount() < 1))
return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
auto other = JSNode::toWrapped(state->uncheckedArgument(0));
if (UNLIKELY(!other))
return throwArgumentTypeError(*state, throwScope, 0, "other", "Node", "compareDocumentPosition", "Node");
JSValue result = jsNumber(impl.compareDocumentPosition(*other));
return JSValue::encode(result);
}
EncodedJSValue JSC_HOST_CALL jsNodePrototypeFunctionContains(ExecState* state)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
JSValue thisValue = state->thisValue();
auto castedThis = jsNodeCast(thisValue);
if (UNLIKELY(!castedThis))
return throwThisTypeError(*state, throwScope, "Node", "contains");
ASSERT_GC_OBJECT_INHERITS(castedThis, JSNode::info());
auto& impl = castedThis->wrapped();
if (UNLIKELY(state->argumentCount() < 1))
return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
Node* other = nullptr;
if (!state->uncheckedArgument(0).isUndefinedOrNull()) {
other = JSNode::toWrapped(state->uncheckedArgument(0));
if (UNLIKELY(!other))
return throwArgumentTypeError(*state, throwScope, 0, "other", "Node", "contains", "Node");
}
JSValue result = jsBoolean(impl.contains(WTFMove(other)));
return JSValue::encode(result);
}
EncodedJSValue JSC_HOST_CALL jsNodePrototypeFunctionGetRootNode(ExecState* state)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
JSValue thisValue = state->thisValue();
auto castedThis = jsNodeCast(thisValue);
if (UNLIKELY(!castedThis))
return throwThisTypeError(*state, throwScope, "Node", "getRootNode");
ASSERT_GC_OBJECT_INHERITS(castedThis, JSNode::info());
auto& impl = castedThis->wrapped();
auto options = state->argument(0).isUndefined() ? Node::GetRootNodeOptions() : convertDictionary<Node::GetRootNodeOptions>(*state, state->uncheckedArgument(0));
RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
JSValue result = toJS(state, castedThis->globalObject(), impl.getRootNode(options.value()));
return JSValue::encode(result);
}
void JSNode::visitChildren(JSCell* cell, SlotVisitor& visitor)
{
auto* thisObject = jsCast<JSNode*>(cell);
ASSERT_GC_OBJECT_INHERITS(thisObject, info());
Base::visitChildren(thisObject, visitor);
thisObject->wrapped().visitJSEventListeners(visitor);
thisObject->visitAdditionalChildren(visitor);
}
void JSNodeOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
{
auto* jsNode = jsCast<JSNode*>(handle.slot()->asCell());
auto& world = *static_cast<DOMWrapperWorld*>(context);
uncacheWrapper(world, &jsNode->wrapped(), jsNode);
}
Node* JSNode::toWrapped(JSC::JSValue value)
{
if (auto* wrapper = jsNodeCast(value))
return &wrapper->wrapped();
return nullptr;
}
}