/* 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 "Document.h" #include "Element.h" #include "Event.h" #include "JSDocument.h" #include "JSElement.h" #include "JSEvent.h" #include "JSNamedNodeMap.h" #include "JSNode.h" #include "JSNodeList.h" #include "KURL.h" #include "NameNodeList.h" #include "NamedNodeMap.h" #include "Node.h" #include "NodeList.h" #include "RegisteredEventListener.h" #include #include #include using namespace JSC; namespace WebCore { ASSERT_CLASS_FITS_IN_CELL(JSNode); /* Hash table */ static const HashTableValue JSNodeTableValues[19] = { { "nodeName", DontDelete|ReadOnly, (intptr_t)static_cast(jsNodeNodeName), (intptr_t)0 }, { "nodeValue", DontDelete, (intptr_t)static_cast(jsNodeNodeValue), (intptr_t)setJSNodeNodeValue }, { "nodeType", DontDelete|ReadOnly, (intptr_t)static_cast(jsNodeNodeType), (intptr_t)0 }, { "parentNode", DontDelete|ReadOnly, (intptr_t)static_cast(jsNodeParentNode), (intptr_t)0 }, { "childNodes", DontDelete|ReadOnly, (intptr_t)static_cast(jsNodeChildNodes), (intptr_t)0 }, { "firstChild", DontDelete|ReadOnly, (intptr_t)static_cast(jsNodeFirstChild), (intptr_t)0 }, { "lastChild", DontDelete|ReadOnly, (intptr_t)static_cast(jsNodeLastChild), (intptr_t)0 }, { "previousSibling", DontDelete|ReadOnly, (intptr_t)static_cast(jsNodePreviousSibling), (intptr_t)0 }, { "nextSibling", DontDelete|ReadOnly, (intptr_t)static_cast(jsNodeNextSibling), (intptr_t)0 }, { "attributes", DontDelete|ReadOnly, (intptr_t)static_cast(jsNodeAttributes), (intptr_t)0 }, { "ownerDocument", DontDelete|ReadOnly, (intptr_t)static_cast(jsNodeOwnerDocument), (intptr_t)0 }, { "namespaceURI", DontDelete|ReadOnly, (intptr_t)static_cast(jsNodeNamespaceURI), (intptr_t)0 }, { "prefix", DontDelete, (intptr_t)static_cast(jsNodePrefix), (intptr_t)setJSNodePrefix }, { "localName", DontDelete|ReadOnly, (intptr_t)static_cast(jsNodeLocalName), (intptr_t)0 }, { "baseURI", DontDelete|ReadOnly, (intptr_t)static_cast(jsNodeBaseURI), (intptr_t)0 }, { "textContent", DontDelete, (intptr_t)static_cast(jsNodeTextContent), (intptr_t)setJSNodeTextContent }, { "parentElement", DontDelete|ReadOnly, (intptr_t)static_cast(jsNodeParentElement), (intptr_t)0 }, { "constructor", DontEnum|ReadOnly, (intptr_t)static_cast(jsNodeConstructor), (intptr_t)0 }, { 0, 0, 0, 0 } }; static JSC_CONST_HASHTABLE HashTable JSNodeTable = #if ENABLE(PERFECT_HASH_SIZE) { 4095, JSNodeTableValues, 0 }; #else { 68, 63, JSNodeTableValues, 0 }; #endif /* Hash table for constructor */ static const HashTableValue JSNodeConstructorTableValues[19] = { { "ELEMENT_NODE", DontDelete|ReadOnly, (intptr_t)static_cast(jsNodeELEMENT_NODE), (intptr_t)0 }, { "ATTRIBUTE_NODE", DontDelete|ReadOnly, (intptr_t)static_cast(jsNodeATTRIBUTE_NODE), (intptr_t)0 }, { "TEXT_NODE", DontDelete|ReadOnly, (intptr_t)static_cast(jsNodeTEXT_NODE), (intptr_t)0 }, { "CDATA_SECTION_NODE", DontDelete|ReadOnly, (intptr_t)static_cast(jsNodeCDATA_SECTION_NODE), (intptr_t)0 }, { "ENTITY_REFERENCE_NODE", DontDelete|ReadOnly, (intptr_t)static_cast(jsNodeENTITY_REFERENCE_NODE), (intptr_t)0 }, { "ENTITY_NODE", DontDelete|ReadOnly, (intptr_t)static_cast(jsNodeENTITY_NODE), (intptr_t)0 }, { "PROCESSING_INSTRUCTION_NODE", DontDelete|ReadOnly, (intptr_t)static_cast(jsNodePROCESSING_INSTRUCTION_NODE), (intptr_t)0 }, { "COMMENT_NODE", DontDelete|ReadOnly, (intptr_t)static_cast(jsNodeCOMMENT_NODE), (intptr_t)0 }, { "DOCUMENT_NODE", DontDelete|ReadOnly, (intptr_t)static_cast(jsNodeDOCUMENT_NODE), (intptr_t)0 }, { "DOCUMENT_TYPE_NODE", DontDelete|ReadOnly, (intptr_t)static_cast(jsNodeDOCUMENT_TYPE_NODE), (intptr_t)0 }, { "DOCUMENT_FRAGMENT_NODE", DontDelete|ReadOnly, (intptr_t)static_cast(jsNodeDOCUMENT_FRAGMENT_NODE), (intptr_t)0 }, { "NOTATION_NODE", DontDelete|ReadOnly, (intptr_t)static_cast(jsNodeNOTATION_NODE), (intptr_t)0 }, { "DOCUMENT_POSITION_DISCONNECTED", DontDelete|ReadOnly, (intptr_t)static_cast(jsNodeDOCUMENT_POSITION_DISCONNECTED), (intptr_t)0 }, { "DOCUMENT_POSITION_PRECEDING", DontDelete|ReadOnly, (intptr_t)static_cast(jsNodeDOCUMENT_POSITION_PRECEDING), (intptr_t)0 }, { "DOCUMENT_POSITION_FOLLOWING", DontDelete|ReadOnly, (intptr_t)static_cast(jsNodeDOCUMENT_POSITION_FOLLOWING), (intptr_t)0 }, { "DOCUMENT_POSITION_CONTAINS", DontDelete|ReadOnly, (intptr_t)static_cast(jsNodeDOCUMENT_POSITION_CONTAINS), (intptr_t)0 }, { "DOCUMENT_POSITION_CONTAINED_BY", DontDelete|ReadOnly, (intptr_t)static_cast(jsNodeDOCUMENT_POSITION_CONTAINED_BY), (intptr_t)0 }, { "DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC", DontDelete|ReadOnly, (intptr_t)static_cast(jsNodeDOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC), (intptr_t)0 }, { 0, 0, 0, 0 } }; static JSC_CONST_HASHTABLE HashTable JSNodeConstructorTable = #if ENABLE(PERFECT_HASH_SIZE) { 2047, JSNodeConstructorTableValues, 0 }; #else { 67, 63, JSNodeConstructorTableValues, 0 }; #endif class JSNodeConstructor : public DOMConstructorObject { public: JSNodeConstructor(ExecState* exec, JSDOMGlobalObject* globalObject) : DOMConstructorObject(JSNodeConstructor::createStructure(globalObject->objectPrototype()), globalObject) { putDirect(exec->propertyNames().prototype, JSNodePrototype::self(exec, globalObject), None); } virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&); virtual bool getOwnPropertyDescriptor(ExecState*, const Identifier&, PropertyDescriptor&); virtual const ClassInfo* classInfo() const { return &s_info; } static const ClassInfo s_info; static PassRefPtr createStructure(JSValue proto) { return Structure::create(proto, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount); } protected: static const unsigned StructureFlags = OverridesGetOwnPropertySlot | ImplementsHasInstance | DOMConstructorObject::StructureFlags; }; const ClassInfo JSNodeConstructor::s_info = { "NodeConstructor", 0, &JSNodeConstructorTable, 0 }; bool JSNodeConstructor::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) { return getStaticValueSlot(exec, &JSNodeConstructorTable, this, propertyName, slot); } bool JSNodeConstructor::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) { return getStaticValueDescriptor(exec, &JSNodeConstructorTable, this, propertyName, descriptor); } /* Hash table for prototype */ static const HashTableValue JSNodePrototypeTableValues[37] = { { "ELEMENT_NODE", DontDelete|ReadOnly, (intptr_t)static_cast(jsNodeELEMENT_NODE), (intptr_t)0 }, { "ATTRIBUTE_NODE", DontDelete|ReadOnly, (intptr_t)static_cast(jsNodeATTRIBUTE_NODE), (intptr_t)0 }, { "TEXT_NODE", DontDelete|ReadOnly, (intptr_t)static_cast(jsNodeTEXT_NODE), (intptr_t)0 }, { "CDATA_SECTION_NODE", DontDelete|ReadOnly, (intptr_t)static_cast(jsNodeCDATA_SECTION_NODE), (intptr_t)0 }, { "ENTITY_REFERENCE_NODE", DontDelete|ReadOnly, (intptr_t)static_cast(jsNodeENTITY_REFERENCE_NODE), (intptr_t)0 }, { "ENTITY_NODE", DontDelete|ReadOnly, (intptr_t)static_cast(jsNodeENTITY_NODE), (intptr_t)0 }, { "PROCESSING_INSTRUCTION_NODE", DontDelete|ReadOnly, (intptr_t)static_cast(jsNodePROCESSING_INSTRUCTION_NODE), (intptr_t)0 }, { "COMMENT_NODE", DontDelete|ReadOnly, (intptr_t)static_cast(jsNodeCOMMENT_NODE), (intptr_t)0 }, { "DOCUMENT_NODE", DontDelete|ReadOnly, (intptr_t)static_cast(jsNodeDOCUMENT_NODE), (intptr_t)0 }, { "DOCUMENT_TYPE_NODE", DontDelete|ReadOnly, (intptr_t)static_cast(jsNodeDOCUMENT_TYPE_NODE), (intptr_t)0 }, { "DOCUMENT_FRAGMENT_NODE", DontDelete|ReadOnly, (intptr_t)static_cast(jsNodeDOCUMENT_FRAGMENT_NODE), (intptr_t)0 }, { "NOTATION_NODE", DontDelete|ReadOnly, (intptr_t)static_cast(jsNodeNOTATION_NODE), (intptr_t)0 }, { "DOCUMENT_POSITION_DISCONNECTED", DontDelete|ReadOnly, (intptr_t)static_cast(jsNodeDOCUMENT_POSITION_DISCONNECTED), (intptr_t)0 }, { "DOCUMENT_POSITION_PRECEDING", DontDelete|ReadOnly, (intptr_t)static_cast(jsNodeDOCUMENT_POSITION_PRECEDING), (intptr_t)0 }, { "DOCUMENT_POSITION_FOLLOWING", DontDelete|ReadOnly, (intptr_t)static_cast(jsNodeDOCUMENT_POSITION_FOLLOWING), (intptr_t)0 }, { "DOCUMENT_POSITION_CONTAINS", DontDelete|ReadOnly, (intptr_t)static_cast(jsNodeDOCUMENT_POSITION_CONTAINS), (intptr_t)0 }, { "DOCUMENT_POSITION_CONTAINED_BY", DontDelete|ReadOnly, (intptr_t)static_cast(jsNodeDOCUMENT_POSITION_CONTAINED_BY), (intptr_t)0 }, { "DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC", DontDelete|ReadOnly, (intptr_t)static_cast(jsNodeDOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC), (intptr_t)0 }, { "insertBefore", DontDelete|Function, (intptr_t)static_cast(jsNodePrototypeFunctionInsertBefore), (intptr_t)2 }, { "replaceChild", DontDelete|Function, (intptr_t)static_cast(jsNodePrototypeFunctionReplaceChild), (intptr_t)2 }, { "removeChild", DontDelete|Function, (intptr_t)static_cast(jsNodePrototypeFunctionRemoveChild), (intptr_t)1 }, { "appendChild", DontDelete|Function, (intptr_t)static_cast(jsNodePrototypeFunctionAppendChild), (intptr_t)1 }, { "hasChildNodes", DontDelete|Function, (intptr_t)static_cast(jsNodePrototypeFunctionHasChildNodes), (intptr_t)0 }, { "cloneNode", DontDelete|Function, (intptr_t)static_cast(jsNodePrototypeFunctionCloneNode), (intptr_t)1 }, { "normalize", DontDelete|Function, (intptr_t)static_cast(jsNodePrototypeFunctionNormalize), (intptr_t)0 }, { "isSupported", DontDelete|Function, (intptr_t)static_cast(jsNodePrototypeFunctionIsSupported), (intptr_t)2 }, { "hasAttributes", DontDelete|Function, (intptr_t)static_cast(jsNodePrototypeFunctionHasAttributes), (intptr_t)0 }, { "isSameNode", DontDelete|Function, (intptr_t)static_cast(jsNodePrototypeFunctionIsSameNode), (intptr_t)1 }, { "isEqualNode", DontDelete|Function, (intptr_t)static_cast(jsNodePrototypeFunctionIsEqualNode), (intptr_t)1 }, { "lookupPrefix", DontDelete|Function, (intptr_t)static_cast(jsNodePrototypeFunctionLookupPrefix), (intptr_t)1 }, { "isDefaultNamespace", DontDelete|Function, (intptr_t)static_cast(jsNodePrototypeFunctionIsDefaultNamespace), (intptr_t)1 }, { "lookupNamespaceURI", DontDelete|Function, (intptr_t)static_cast(jsNodePrototypeFunctionLookupNamespaceURI), (intptr_t)1 }, { "compareDocumentPosition", DontDelete|Function, (intptr_t)static_cast(jsNodePrototypeFunctionCompareDocumentPosition), (intptr_t)1 }, { "addEventListener", DontDelete|Function, (intptr_t)static_cast(jsNodePrototypeFunctionAddEventListener), (intptr_t)3 }, { "removeEventListener", DontDelete|Function, (intptr_t)static_cast(jsNodePrototypeFunctionRemoveEventListener), (intptr_t)3 }, { "dispatchEvent", DontDelete|Function, (intptr_t)static_cast(jsNodePrototypeFunctionDispatchEvent), (intptr_t)1 }, { 0, 0, 0, 0 } }; static JSC_CONST_HASHTABLE HashTable JSNodePrototypeTable = #if ENABLE(PERFECT_HASH_SIZE) { 4095, JSNodePrototypeTableValues, 0 }; #else { 134, 127, JSNodePrototypeTableValues, 0 }; #endif const ClassInfo JSNodePrototype::s_info = { "NodePrototype", 0, &JSNodePrototypeTable, 0 }; JSObject* JSNodePrototype::self(ExecState* exec, JSGlobalObject* globalObject) { return getDOMPrototype(exec, globalObject); } bool JSNodePrototype::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) { return getStaticPropertySlot(exec, &JSNodePrototypeTable, this, propertyName, slot); } bool JSNodePrototype::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) { return getStaticPropertyDescriptor(exec, &JSNodePrototypeTable, this, propertyName, descriptor); } const ClassInfo JSNode::s_info = { "Node", 0, &JSNodeTable, 0 }; JSNode::JSNode(NonNullPassRefPtr structure, JSDOMGlobalObject* globalObject, PassRefPtr impl) : DOMObjectWithGlobalPointer(structure, globalObject) , m_impl(impl) { } JSNode::~JSNode() { impl()->invalidateJSEventListeners(this); forgetDOMNode(this, impl(), impl()->document()); } JSObject* JSNode::createPrototype(ExecState* exec, JSGlobalObject* globalObject) { return new (exec) JSNodePrototype(JSNodePrototype::createStructure(globalObject->objectPrototype())); } JSValue jsNodeNodeName(ExecState* exec, JSValue slotBase, const Identifier&) { JSNode* castedThis = static_cast(asObject(slotBase)); UNUSED_PARAM(exec); Node* imp = static_cast(castedThis->impl()); JSValue result = jsStringOrNull(exec, imp->nodeName()); return result; } JSValue jsNodeNodeValue(ExecState* exec, JSValue slotBase, const Identifier&) { JSNode* castedThis = static_cast(asObject(slotBase)); UNUSED_PARAM(exec); Node* imp = static_cast(castedThis->impl()); JSValue result = jsStringOrNull(exec, imp->nodeValue()); return result; } JSValue jsNodeNodeType(ExecState* exec, JSValue slotBase, const Identifier&) { JSNode* castedThis = static_cast(asObject(slotBase)); UNUSED_PARAM(exec); Node* imp = static_cast(castedThis->impl()); JSValue result = jsNumber(exec, imp->nodeType()); return result; } JSValue jsNodeParentNode(ExecState* exec, JSValue slotBase, const Identifier&) { JSNode* castedThis = static_cast(asObject(slotBase)); UNUSED_PARAM(exec); Node* imp = static_cast(castedThis->impl()); JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->parentNode())); return result; } JSValue jsNodeChildNodes(ExecState* exec, JSValue slotBase, const Identifier&) { JSNode* castedThis = static_cast(asObject(slotBase)); UNUSED_PARAM(exec); Node* imp = static_cast(castedThis->impl()); JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->childNodes())); return result; } JSValue jsNodeFirstChild(ExecState* exec, JSValue slotBase, const Identifier&) { JSNode* castedThis = static_cast(asObject(slotBase)); UNUSED_PARAM(exec); Node* imp = static_cast(castedThis->impl()); JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->firstChild())); return result; } JSValue jsNodeLastChild(ExecState* exec, JSValue slotBase, const Identifier&) { JSNode* castedThis = static_cast(asObject(slotBase)); UNUSED_PARAM(exec); Node* imp = static_cast(castedThis->impl()); JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->lastChild())); return result; } JSValue jsNodePreviousSibling(ExecState* exec, JSValue slotBase, const Identifier&) { JSNode* castedThis = static_cast(asObject(slotBase)); UNUSED_PARAM(exec); Node* imp = static_cast(castedThis->impl()); JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->previousSibling())); return result; } JSValue jsNodeNextSibling(ExecState* exec, JSValue slotBase, const Identifier&) { JSNode* castedThis = static_cast(asObject(slotBase)); UNUSED_PARAM(exec); Node* imp = static_cast(castedThis->impl()); JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->nextSibling())); return result; } JSValue jsNodeAttributes(ExecState* exec, JSValue slotBase, const Identifier&) { JSNode* castedThis = static_cast(asObject(slotBase)); UNUSED_PARAM(exec); Node* imp = static_cast(castedThis->impl()); JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->attributes())); return result; } JSValue jsNodeOwnerDocument(ExecState* exec, JSValue slotBase, const Identifier&) { JSNode* castedThis = static_cast(asObject(slotBase)); UNUSED_PARAM(exec); Node* imp = static_cast(castedThis->impl()); JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->ownerDocument())); return result; } JSValue jsNodeNamespaceURI(ExecState* exec, JSValue slotBase, const Identifier&) { JSNode* castedThis = static_cast(asObject(slotBase)); UNUSED_PARAM(exec); Node* imp = static_cast(castedThis->impl()); JSValue result = jsStringOrNull(exec, imp->namespaceURI()); return result; } JSValue jsNodePrefix(ExecState* exec, JSValue slotBase, const Identifier&) { JSNode* castedThis = static_cast(asObject(slotBase)); UNUSED_PARAM(exec); Node* imp = static_cast(castedThis->impl()); JSValue result = jsStringOrNull(exec, imp->prefix()); return result; } JSValue jsNodeLocalName(ExecState* exec, JSValue slotBase, const Identifier&) { JSNode* castedThis = static_cast(asObject(slotBase)); UNUSED_PARAM(exec); Node* imp = static_cast(castedThis->impl()); JSValue result = jsStringOrNull(exec, imp->localName()); return result; } JSValue jsNodeBaseURI(ExecState* exec, JSValue slotBase, const Identifier&) { JSNode* castedThis = static_cast(asObject(slotBase)); UNUSED_PARAM(exec); Node* imp = static_cast(castedThis->impl()); JSValue result = jsStringOrNull(exec, imp->baseURI()); return result; } JSValue jsNodeTextContent(ExecState* exec, JSValue slotBase, const Identifier&) { JSNode* castedThis = static_cast(asObject(slotBase)); UNUSED_PARAM(exec); Node* imp = static_cast(castedThis->impl()); JSValue result = jsStringOrNull(exec, imp->textContent()); return result; } JSValue jsNodeParentElement(ExecState* exec, JSValue slotBase, const Identifier&) { JSNode* castedThis = static_cast(asObject(slotBase)); UNUSED_PARAM(exec); Node* imp = static_cast(castedThis->impl()); JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->parentElement())); return result; } JSValue jsNodeConstructor(ExecState* exec, JSValue slotBase, const Identifier&) { JSNode* domObject = static_cast(asObject(slotBase)); return JSNode::getConstructor(exec, domObject->globalObject()); } void JSNode::put(ExecState* exec, const Identifier& propertyName, JSValue value, PutPropertySlot& slot) { lookupPut(exec, propertyName, value, &JSNodeTable, this, slot); } void setJSNodeNodeValue(ExecState* exec, JSObject* thisObject, JSValue value) { static_cast(thisObject)->setNodeValue(exec, value); } void setJSNodePrefix(ExecState* exec, JSObject* thisObject, JSValue value) { JSNode* castedThisObj = static_cast(thisObject); Node* imp = static_cast(castedThisObj->impl()); ExceptionCode ec = 0; imp->setPrefix(valueToStringWithNullCheck(exec, value), ec); setDOMException(exec, ec); } void setJSNodeTextContent(ExecState* exec, JSObject* thisObject, JSValue value) { static_cast(thisObject)->setTextContent(exec, value); } JSValue JSNode::getConstructor(ExecState* exec, JSGlobalObject* globalObject) { return getDOMConstructor(exec, static_cast(globalObject)); } JSValue JSC_HOST_CALL jsNodePrototypeFunctionInsertBefore(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) { UNUSED_PARAM(args); if (!thisValue.inherits(&JSNode::s_info)) return throwError(exec, TypeError); JSNode* castedThisObj = static_cast(asObject(thisValue)); return castedThisObj->insertBefore(exec, args); } JSValue JSC_HOST_CALL jsNodePrototypeFunctionReplaceChild(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) { UNUSED_PARAM(args); if (!thisValue.inherits(&JSNode::s_info)) return throwError(exec, TypeError); JSNode* castedThisObj = static_cast(asObject(thisValue)); return castedThisObj->replaceChild(exec, args); } JSValue JSC_HOST_CALL jsNodePrototypeFunctionRemoveChild(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) { UNUSED_PARAM(args); if (!thisValue.inherits(&JSNode::s_info)) return throwError(exec, TypeError); JSNode* castedThisObj = static_cast(asObject(thisValue)); return castedThisObj->removeChild(exec, args); } JSValue JSC_HOST_CALL jsNodePrototypeFunctionAppendChild(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) { UNUSED_PARAM(args); if (!thisValue.inherits(&JSNode::s_info)) return throwError(exec, TypeError); JSNode* castedThisObj = static_cast(asObject(thisValue)); return castedThisObj->appendChild(exec, args); } JSValue JSC_HOST_CALL jsNodePrototypeFunctionHasChildNodes(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) { UNUSED_PARAM(args); if (!thisValue.inherits(&JSNode::s_info)) return throwError(exec, TypeError); JSNode* castedThisObj = static_cast(asObject(thisValue)); Node* imp = static_cast(castedThisObj->impl()); JSC::JSValue result = jsBoolean(imp->hasChildNodes()); return result; } JSValue JSC_HOST_CALL jsNodePrototypeFunctionCloneNode(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) { UNUSED_PARAM(args); if (!thisValue.inherits(&JSNode::s_info)) return throwError(exec, TypeError); JSNode* castedThisObj = static_cast(asObject(thisValue)); Node* imp = static_cast(castedThisObj->impl()); bool deep = args.at(0).toBoolean(exec); JSC::JSValue result = toJS(exec, castedThisObj->globalObject(), WTF::getPtr(imp->cloneNode(deep))); return result; } JSValue JSC_HOST_CALL jsNodePrototypeFunctionNormalize(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) { UNUSED_PARAM(args); if (!thisValue.inherits(&JSNode::s_info)) return throwError(exec, TypeError); JSNode* castedThisObj = static_cast(asObject(thisValue)); Node* imp = static_cast(castedThisObj->impl()); imp->normalize(); return jsUndefined(); } JSValue JSC_HOST_CALL jsNodePrototypeFunctionIsSupported(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) { UNUSED_PARAM(args); if (!thisValue.inherits(&JSNode::s_info)) return throwError(exec, TypeError); JSNode* castedThisObj = static_cast(asObject(thisValue)); Node* imp = static_cast(castedThisObj->impl()); const UString& feature = args.at(0).toString(exec); const UString& version = valueToStringWithNullCheck(exec, args.at(1)); JSC::JSValue result = jsBoolean(imp->isSupported(feature, version)); return result; } JSValue JSC_HOST_CALL jsNodePrototypeFunctionHasAttributes(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) { UNUSED_PARAM(args); if (!thisValue.inherits(&JSNode::s_info)) return throwError(exec, TypeError); JSNode* castedThisObj = static_cast(asObject(thisValue)); Node* imp = static_cast(castedThisObj->impl()); JSC::JSValue result = jsBoolean(imp->hasAttributes()); return result; } JSValue JSC_HOST_CALL jsNodePrototypeFunctionIsSameNode(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) { UNUSED_PARAM(args); if (!thisValue.inherits(&JSNode::s_info)) return throwError(exec, TypeError); JSNode* castedThisObj = static_cast(asObject(thisValue)); Node* imp = static_cast(castedThisObj->impl()); Node* other = toNode(args.at(0)); JSC::JSValue result = jsBoolean(imp->isSameNode(other)); return result; } JSValue JSC_HOST_CALL jsNodePrototypeFunctionIsEqualNode(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) { UNUSED_PARAM(args); if (!thisValue.inherits(&JSNode::s_info)) return throwError(exec, TypeError); JSNode* castedThisObj = static_cast(asObject(thisValue)); Node* imp = static_cast(castedThisObj->impl()); Node* other = toNode(args.at(0)); JSC::JSValue result = jsBoolean(imp->isEqualNode(other)); return result; } JSValue JSC_HOST_CALL jsNodePrototypeFunctionLookupPrefix(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) { UNUSED_PARAM(args); if (!thisValue.inherits(&JSNode::s_info)) return throwError(exec, TypeError); JSNode* castedThisObj = static_cast(asObject(thisValue)); Node* imp = static_cast(castedThisObj->impl()); const UString& namespaceURI = valueToStringWithNullCheck(exec, args.at(0)); JSC::JSValue result = jsStringOrNull(exec, imp->lookupPrefix(namespaceURI)); return result; } JSValue JSC_HOST_CALL jsNodePrototypeFunctionIsDefaultNamespace(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) { UNUSED_PARAM(args); if (!thisValue.inherits(&JSNode::s_info)) return throwError(exec, TypeError); JSNode* castedThisObj = static_cast(asObject(thisValue)); Node* imp = static_cast(castedThisObj->impl()); const UString& namespaceURI = valueToStringWithNullCheck(exec, args.at(0)); JSC::JSValue result = jsBoolean(imp->isDefaultNamespace(namespaceURI)); return result; } JSValue JSC_HOST_CALL jsNodePrototypeFunctionLookupNamespaceURI(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) { UNUSED_PARAM(args); if (!thisValue.inherits(&JSNode::s_info)) return throwError(exec, TypeError); JSNode* castedThisObj = static_cast(asObject(thisValue)); Node* imp = static_cast(castedThisObj->impl()); const UString& prefix = valueToStringWithNullCheck(exec, args.at(0)); JSC::JSValue result = jsStringOrNull(exec, imp->lookupNamespaceURI(prefix)); return result; } JSValue JSC_HOST_CALL jsNodePrototypeFunctionCompareDocumentPosition(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) { UNUSED_PARAM(args); if (!thisValue.inherits(&JSNode::s_info)) return throwError(exec, TypeError); JSNode* castedThisObj = static_cast(asObject(thisValue)); Node* imp = static_cast(castedThisObj->impl()); Node* other = toNode(args.at(0)); JSC::JSValue result = jsNumber(exec, imp->compareDocumentPosition(other)); return result; } JSValue JSC_HOST_CALL jsNodePrototypeFunctionAddEventListener(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) { UNUSED_PARAM(args); if (!thisValue.inherits(&JSNode::s_info)) return throwError(exec, TypeError); JSNode* castedThisObj = static_cast(asObject(thisValue)); return castedThisObj->addEventListener(exec, args); } JSValue JSC_HOST_CALL jsNodePrototypeFunctionRemoveEventListener(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) { UNUSED_PARAM(args); if (!thisValue.inherits(&JSNode::s_info)) return throwError(exec, TypeError); JSNode* castedThisObj = static_cast(asObject(thisValue)); return castedThisObj->removeEventListener(exec, args); } JSValue JSC_HOST_CALL jsNodePrototypeFunctionDispatchEvent(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) { UNUSED_PARAM(args); if (!thisValue.inherits(&JSNode::s_info)) return throwError(exec, TypeError); JSNode* castedThisObj = static_cast(asObject(thisValue)); Node* imp = static_cast(castedThisObj->impl()); ExceptionCode ec = 0; Event* event = toEvent(args.at(0)); JSC::JSValue result = jsBoolean(imp->dispatchEvent(event, ec)); setDOMException(exec, ec); return result; } // Constant getters JSValue jsNodeELEMENT_NODE(ExecState* exec, JSValue, const Identifier&) { return jsNumber(exec, static_cast(1)); } JSValue jsNodeATTRIBUTE_NODE(ExecState* exec, JSValue, const Identifier&) { return jsNumber(exec, static_cast(2)); } JSValue jsNodeTEXT_NODE(ExecState* exec, JSValue, const Identifier&) { return jsNumber(exec, static_cast(3)); } JSValue jsNodeCDATA_SECTION_NODE(ExecState* exec, JSValue, const Identifier&) { return jsNumber(exec, static_cast(4)); } JSValue jsNodeENTITY_REFERENCE_NODE(ExecState* exec, JSValue, const Identifier&) { return jsNumber(exec, static_cast(5)); } JSValue jsNodeENTITY_NODE(ExecState* exec, JSValue, const Identifier&) { return jsNumber(exec, static_cast(6)); } JSValue jsNodePROCESSING_INSTRUCTION_NODE(ExecState* exec, JSValue, const Identifier&) { return jsNumber(exec, static_cast(7)); } JSValue jsNodeCOMMENT_NODE(ExecState* exec, JSValue, const Identifier&) { return jsNumber(exec, static_cast(8)); } JSValue jsNodeDOCUMENT_NODE(ExecState* exec, JSValue, const Identifier&) { return jsNumber(exec, static_cast(9)); } JSValue jsNodeDOCUMENT_TYPE_NODE(ExecState* exec, JSValue, const Identifier&) { return jsNumber(exec, static_cast(10)); } JSValue jsNodeDOCUMENT_FRAGMENT_NODE(ExecState* exec, JSValue, const Identifier&) { return jsNumber(exec, static_cast(11)); } JSValue jsNodeNOTATION_NODE(ExecState* exec, JSValue, const Identifier&) { return jsNumber(exec, static_cast(12)); } JSValue jsNodeDOCUMENT_POSITION_DISCONNECTED(ExecState* exec, JSValue, const Identifier&) { return jsNumber(exec, static_cast(0x01)); } JSValue jsNodeDOCUMENT_POSITION_PRECEDING(ExecState* exec, JSValue, const Identifier&) { return jsNumber(exec, static_cast(0x02)); } JSValue jsNodeDOCUMENT_POSITION_FOLLOWING(ExecState* exec, JSValue, const Identifier&) { return jsNumber(exec, static_cast(0x04)); } JSValue jsNodeDOCUMENT_POSITION_CONTAINS(ExecState* exec, JSValue, const Identifier&) { return jsNumber(exec, static_cast(0x08)); } JSValue jsNodeDOCUMENT_POSITION_CONTAINED_BY(ExecState* exec, JSValue, const Identifier&) { return jsNumber(exec, static_cast(0x10)); } JSValue jsNodeDOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC(ExecState* exec, JSValue, const Identifier&) { return jsNumber(exec, static_cast(0x20)); } Node* toNode(JSC::JSValue value) { return value.inherits(&JSNode::s_info) ? static_cast(asObject(value))->impl() : 0; } }