| 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 "JSNode.h" |
| 23 | |
| 24 | #include "CustomElementReactionQueue.h" |
| 25 | #include "DOMJITIDLTypeFilter.h" |
| 26 | #include "JSDOMAttribute.h" |
| 27 | #include "JSDOMBinding.h" |
| 28 | #include "JSDOMConstructorNotConstructable.h" |
| 29 | #include "JSDOMConvertBoolean.h" |
| 30 | #include "JSDOMConvertInterface.h" |
| 31 | #include "JSDOMConvertNullable.h" |
| 32 | #include "JSDOMConvertNumbers.h" |
| 33 | #include "JSDOMConvertStrings.h" |
| 34 | #include "JSDOMExceptionHandling.h" |
| 35 | #include "JSDOMGlobalObject.h" |
| 36 | #include "JSDOMOperation.h" |
| 37 | #include "JSDOMWrapperCache.h" |
| 38 | #include "JSDocument.h" |
| 39 | #include "JSElement.h" |
| 40 | #include "JSNode.h" |
| 41 | #include "JSNodeList.h" |
| 42 | #include "RuntimeEnabledFeatures.h" |
| 43 | #include "ScriptExecutionContext.h" |
| 44 | #include <JavaScriptCore/HeapSnapshotBuilder.h> |
| 45 | #include <JavaScriptCore/JSCInlines.h> |
| 46 | #include <wtf/GetPtr.h> |
| 47 | #include <wtf/PointerPreparations.h> |
| 48 | #include <wtf/URL.h> |
| 49 | |
| 50 | |
| 51 | namespace WebCore { |
| 52 | using namespace JSC; |
| 53 | |
| 54 | template<> Node::GetRootNodeOptions convertDictionary<Node::GetRootNodeOptions>(ExecState& state, JSValue value) |
| 55 | { |
| 56 | VM& vm = state.vm(); |
| 57 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 58 | bool isNullOrUndefined = value.isUndefinedOrNull(); |
| 59 | auto* object = isNullOrUndefined ? nullptr : value.getObject(); |
| 60 | if (UNLIKELY(!isNullOrUndefined && !object)) { |
| 61 | throwTypeError(&state, throwScope); |
| 62 | return { }; |
| 63 | } |
| 64 | Node::GetRootNodeOptions result; |
| 65 | JSValue composedValue; |
| 66 | if (isNullOrUndefined) |
| 67 | composedValue = jsUndefined(); |
| 68 | else { |
| 69 | composedValue = object->get(&state, Identifier::fromString(&state, "composed" )); |
| 70 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 71 | } |
| 72 | if (!composedValue.isUndefined()) { |
| 73 | result.composed = convert<IDLBoolean>(state, composedValue); |
| 74 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 75 | } else |
| 76 | result.composed = false; |
| 77 | return result; |
| 78 | } |
| 79 | |
| 80 | // Functions |
| 81 | |
| 82 | JSC::EncodedJSValue JSC_HOST_CALL jsNodePrototypeFunctionGetRootNode(JSC::ExecState*); |
| 83 | JSC::EncodedJSValue JSC_HOST_CALL jsNodePrototypeFunctionHasChildNodes(JSC::ExecState*); |
| 84 | JSC::EncodedJSValue JSC_HOST_CALL jsNodePrototypeFunctionNormalize(JSC::ExecState*); |
| 85 | JSC::EncodedJSValue JSC_HOST_CALL jsNodePrototypeFunctionCloneNode(JSC::ExecState*); |
| 86 | JSC::EncodedJSValue JSC_HOST_CALL jsNodePrototypeFunctionIsEqualNode(JSC::ExecState*); |
| 87 | JSC::EncodedJSValue JSC_HOST_CALL jsNodePrototypeFunctionIsSameNode(JSC::ExecState*); |
| 88 | JSC::EncodedJSValue JSC_HOST_CALL jsNodePrototypeFunctionCompareDocumentPosition(JSC::ExecState*); |
| 89 | JSC::EncodedJSValue JSC_HOST_CALL jsNodePrototypeFunctionContains(JSC::ExecState*); |
| 90 | JSC::EncodedJSValue JSC_HOST_CALL jsNodePrototypeFunctionLookupPrefix(JSC::ExecState*); |
| 91 | JSC::EncodedJSValue JSC_HOST_CALL jsNodePrototypeFunctionLookupNamespaceURI(JSC::ExecState*); |
| 92 | JSC::EncodedJSValue JSC_HOST_CALL jsNodePrototypeFunctionIsDefaultNamespace(JSC::ExecState*); |
| 93 | JSC::EncodedJSValue JSC_HOST_CALL jsNodePrototypeFunctionInsertBefore(JSC::ExecState*); |
| 94 | JSC::EncodedJSValue JSC_HOST_CALL jsNodePrototypeFunctionAppendChild(JSC::ExecState*); |
| 95 | JSC::EncodedJSValue JSC_HOST_CALL jsNodePrototypeFunctionReplaceChild(JSC::ExecState*); |
| 96 | JSC::EncodedJSValue JSC_HOST_CALL jsNodePrototypeFunctionRemoveChild(JSC::ExecState*); |
| 97 | |
| 98 | // Attributes |
| 99 | |
| 100 | JSC::EncodedJSValue jsNodeConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 101 | bool setJSNodeConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| 102 | JSC::EncodedJSValue jsNodeNodeType(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 103 | JSC::EncodedJSValue jsNodeNodeName(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 104 | JSC::EncodedJSValue jsNodeBaseURI(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 105 | JSC::EncodedJSValue jsNodeIsConnected(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 106 | JSC::EncodedJSValue jsNodeOwnerDocument(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 107 | JSC::EncodedJSValue jsNodeParentNode(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 108 | JSC::EncodedJSValue jsNodeParentElement(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 109 | JSC::EncodedJSValue jsNodeChildNodes(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 110 | JSC::EncodedJSValue jsNodeFirstChild(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 111 | JSC::EncodedJSValue jsNodeLastChild(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 112 | JSC::EncodedJSValue jsNodePreviousSibling(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 113 | JSC::EncodedJSValue jsNodeNextSibling(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 114 | JSC::EncodedJSValue jsNodeNodeValue(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 115 | bool setJSNodeNodeValue(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| 116 | JSC::EncodedJSValue jsNodeTextContent(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 117 | bool setJSNodeTextContent(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| 118 | |
| 119 | static const JSC::DOMJIT::GetterSetter DOMJITAttributeForNodeNodeType { |
| 120 | jsNodeNodeType, |
| 121 | #if ENABLE(JIT) |
| 122 | &compileNodeNodeTypeAttribute, |
| 123 | #else |
| 124 | nullptr, |
| 125 | #endif |
| 126 | DOMJIT::IDLResultTypeFilter<IDLUnsignedShort>::value |
| 127 | }; |
| 128 | |
| 129 | static const JSC::DOMJIT::GetterSetter DOMJITAttributeForNodeOwnerDocument { |
| 130 | jsNodeOwnerDocument, |
| 131 | #if ENABLE(JIT) |
| 132 | &compileNodeOwnerDocumentAttribute, |
| 133 | #else |
| 134 | nullptr, |
| 135 | #endif |
| 136 | DOMJIT::IDLResultTypeFilter<IDLNullable<IDLInterface<Document>>>::value |
| 137 | }; |
| 138 | |
| 139 | static const JSC::DOMJIT::GetterSetter DOMJITAttributeForNodeParentNode { |
| 140 | jsNodeParentNode, |
| 141 | #if ENABLE(JIT) |
| 142 | &compileNodeParentNodeAttribute, |
| 143 | #else |
| 144 | nullptr, |
| 145 | #endif |
| 146 | DOMJIT::IDLResultTypeFilter<IDLNullable<IDLInterface<Node>>>::value |
| 147 | }; |
| 148 | |
| 149 | static const JSC::DOMJIT::GetterSetter DOMJITAttributeForNodeFirstChild { |
| 150 | jsNodeFirstChild, |
| 151 | #if ENABLE(JIT) |
| 152 | &compileNodeFirstChildAttribute, |
| 153 | #else |
| 154 | nullptr, |
| 155 | #endif |
| 156 | DOMJIT::IDLResultTypeFilter<IDLNullable<IDLInterface<Node>>>::value |
| 157 | }; |
| 158 | |
| 159 | static const JSC::DOMJIT::GetterSetter DOMJITAttributeForNodeLastChild { |
| 160 | jsNodeLastChild, |
| 161 | #if ENABLE(JIT) |
| 162 | &compileNodeLastChildAttribute, |
| 163 | #else |
| 164 | nullptr, |
| 165 | #endif |
| 166 | DOMJIT::IDLResultTypeFilter<IDLNullable<IDLInterface<Node>>>::value |
| 167 | }; |
| 168 | |
| 169 | static const JSC::DOMJIT::GetterSetter DOMJITAttributeForNodePreviousSibling { |
| 170 | jsNodePreviousSibling, |
| 171 | #if ENABLE(JIT) |
| 172 | &compileNodePreviousSiblingAttribute, |
| 173 | #else |
| 174 | nullptr, |
| 175 | #endif |
| 176 | DOMJIT::IDLResultTypeFilter<IDLNullable<IDLInterface<Node>>>::value |
| 177 | }; |
| 178 | |
| 179 | static const JSC::DOMJIT::GetterSetter DOMJITAttributeForNodeNextSibling { |
| 180 | jsNodeNextSibling, |
| 181 | #if ENABLE(JIT) |
| 182 | &compileNodeNextSiblingAttribute, |
| 183 | #else |
| 184 | nullptr, |
| 185 | #endif |
| 186 | DOMJIT::IDLResultTypeFilter<IDLNullable<IDLInterface<Node>>>::value |
| 187 | }; |
| 188 | |
| 189 | class JSNodePrototype : public JSC::JSNonFinalObject { |
| 190 | public: |
| 191 | using Base = JSC::JSNonFinalObject; |
| 192 | static JSNodePrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
| 193 | { |
| 194 | JSNodePrototype* ptr = new (NotNull, JSC::allocateCell<JSNodePrototype>(vm.heap)) JSNodePrototype(vm, globalObject, structure); |
| 195 | ptr->finishCreation(vm); |
| 196 | return ptr; |
| 197 | } |
| 198 | |
| 199 | DECLARE_INFO; |
| 200 | static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) |
| 201 | { |
| 202 | return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); |
| 203 | } |
| 204 | |
| 205 | private: |
| 206 | JSNodePrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
| 207 | : JSC::JSNonFinalObject(vm, structure) |
| 208 | { |
| 209 | } |
| 210 | |
| 211 | void finishCreation(JSC::VM&); |
| 212 | }; |
| 213 | |
| 214 | using JSNodeConstructor = JSDOMConstructorNotConstructable<JSNode>; |
| 215 | |
| 216 | /* Hash table for constructor */ |
| 217 | |
| 218 | static const HashTableValue JSNodeConstructorTableValues[] = |
| 219 | { |
| 220 | { "ELEMENT_NODE" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(1) } }, |
| 221 | { "ATTRIBUTE_NODE" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(2) } }, |
| 222 | { "TEXT_NODE" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(3) } }, |
| 223 | { "CDATA_SECTION_NODE" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(4) } }, |
| 224 | { "ENTITY_REFERENCE_NODE" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(5) } }, |
| 225 | { "ENTITY_NODE" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(6) } }, |
| 226 | { "PROCESSING_INSTRUCTION_NODE" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(7) } }, |
| 227 | { "COMMENT_NODE" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(8) } }, |
| 228 | { "DOCUMENT_NODE" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(9) } }, |
| 229 | { "DOCUMENT_TYPE_NODE" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(10) } }, |
| 230 | { "DOCUMENT_FRAGMENT_NODE" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(11) } }, |
| 231 | { "NOTATION_NODE" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(12) } }, |
| 232 | { "DOCUMENT_POSITION_DISCONNECTED" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(0x01) } }, |
| 233 | { "DOCUMENT_POSITION_PRECEDING" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(0x02) } }, |
| 234 | { "DOCUMENT_POSITION_FOLLOWING" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(0x04) } }, |
| 235 | { "DOCUMENT_POSITION_CONTAINS" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(0x08) } }, |
| 236 | { "DOCUMENT_POSITION_CONTAINED_BY" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(0x10) } }, |
| 237 | { "DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(0x20) } }, |
| 238 | }; |
| 239 | |
| 240 | static_assert(Node::ELEMENT_NODE == 1, "ELEMENT_NODE in Node does not match value from IDL" ); |
| 241 | static_assert(Node::ATTRIBUTE_NODE == 2, "ATTRIBUTE_NODE in Node does not match value from IDL" ); |
| 242 | static_assert(Node::TEXT_NODE == 3, "TEXT_NODE in Node does not match value from IDL" ); |
| 243 | static_assert(Node::CDATA_SECTION_NODE == 4, "CDATA_SECTION_NODE in Node does not match value from IDL" ); |
| 244 | static_assert(Node::ENTITY_REFERENCE_NODE == 5, "ENTITY_REFERENCE_NODE in Node does not match value from IDL" ); |
| 245 | static_assert(Node::ENTITY_NODE == 6, "ENTITY_NODE in Node does not match value from IDL" ); |
| 246 | static_assert(Node::PROCESSING_INSTRUCTION_NODE == 7, "PROCESSING_INSTRUCTION_NODE in Node does not match value from IDL" ); |
| 247 | static_assert(Node::COMMENT_NODE == 8, "COMMENT_NODE in Node does not match value from IDL" ); |
| 248 | static_assert(Node::DOCUMENT_NODE == 9, "DOCUMENT_NODE in Node does not match value from IDL" ); |
| 249 | static_assert(Node::DOCUMENT_TYPE_NODE == 10, "DOCUMENT_TYPE_NODE in Node does not match value from IDL" ); |
| 250 | static_assert(Node::DOCUMENT_FRAGMENT_NODE == 11, "DOCUMENT_FRAGMENT_NODE in Node does not match value from IDL" ); |
| 251 | static_assert(Node::NOTATION_NODE == 12, "NOTATION_NODE in Node does not match value from IDL" ); |
| 252 | static_assert(Node::DOCUMENT_POSITION_DISCONNECTED == 0x01, "DOCUMENT_POSITION_DISCONNECTED in Node does not match value from IDL" ); |
| 253 | static_assert(Node::DOCUMENT_POSITION_PRECEDING == 0x02, "DOCUMENT_POSITION_PRECEDING in Node does not match value from IDL" ); |
| 254 | static_assert(Node::DOCUMENT_POSITION_FOLLOWING == 0x04, "DOCUMENT_POSITION_FOLLOWING in Node does not match value from IDL" ); |
| 255 | static_assert(Node::DOCUMENT_POSITION_CONTAINS == 0x08, "DOCUMENT_POSITION_CONTAINS in Node does not match value from IDL" ); |
| 256 | static_assert(Node::DOCUMENT_POSITION_CONTAINED_BY == 0x10, "DOCUMENT_POSITION_CONTAINED_BY in Node does not match value from IDL" ); |
| 257 | static_assert(Node::DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC == 0x20, "DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC in Node does not match value from IDL" ); |
| 258 | |
| 259 | template<> JSValue JSNodeConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
| 260 | { |
| 261 | return JSEventTarget::getConstructor(vm, &globalObject); |
| 262 | } |
| 263 | |
| 264 | template<> void JSNodeConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
| 265 | { |
| 266 | putDirect(vm, vm.propertyNames->prototype, JSNode::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 267 | putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("Node"_s )), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 268 | putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 269 | reifyStaticProperties(vm, JSNode::info(), JSNodeConstructorTableValues, *this); |
| 270 | } |
| 271 | |
| 272 | template<> const ClassInfo JSNodeConstructor::s_info = { "Node" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSNodeConstructor) }; |
| 273 | |
| 274 | /* Hash table for prototype */ |
| 275 | |
| 276 | static const HashTableValue JSNodePrototypeTableValues[] = |
| 277 | { |
| 278 | { "constructor" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsNodeConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSNodeConstructor) } }, |
| 279 | { "nodeType" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMJITAttribute), NoIntrinsic, { (intptr_t)static_cast<const JSC::DOMJIT::GetterSetter*>(&DOMJITAttributeForNodeNodeType), (intptr_t) (0) } }, |
| 280 | { "nodeName" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsNodeNodeName), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 281 | { "baseURI" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsNodeBaseURI), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 282 | { "isConnected" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsNodeIsConnected), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 283 | { "ownerDocument" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMJITAttribute), NoIntrinsic, { (intptr_t)static_cast<const JSC::DOMJIT::GetterSetter*>(&DOMJITAttributeForNodeOwnerDocument), (intptr_t) (0) } }, |
| 284 | { "parentNode" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMJITAttribute), NoIntrinsic, { (intptr_t)static_cast<const JSC::DOMJIT::GetterSetter*>(&DOMJITAttributeForNodeParentNode), (intptr_t) (0) } }, |
| 285 | { "parentElement" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsNodeParentElement), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 286 | { "childNodes" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsNodeChildNodes), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 287 | { "firstChild" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMJITAttribute), NoIntrinsic, { (intptr_t)static_cast<const JSC::DOMJIT::GetterSetter*>(&DOMJITAttributeForNodeFirstChild), (intptr_t) (0) } }, |
| 288 | { "lastChild" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMJITAttribute), NoIntrinsic, { (intptr_t)static_cast<const JSC::DOMJIT::GetterSetter*>(&DOMJITAttributeForNodeLastChild), (intptr_t) (0) } }, |
| 289 | { "previousSibling" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMJITAttribute), NoIntrinsic, { (intptr_t)static_cast<const JSC::DOMJIT::GetterSetter*>(&DOMJITAttributeForNodePreviousSibling), (intptr_t) (0) } }, |
| 290 | { "nextSibling" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMJITAttribute), NoIntrinsic, { (intptr_t)static_cast<const JSC::DOMJIT::GetterSetter*>(&DOMJITAttributeForNodeNextSibling), (intptr_t) (0) } }, |
| 291 | { "nodeValue" , static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsNodeNodeValue), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSNodeNodeValue) } }, |
| 292 | { "textContent" , static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsNodeTextContent), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSNodeTextContent) } }, |
| 293 | { "getRootNode" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsNodePrototypeFunctionGetRootNode), (intptr_t) (0) } }, |
| 294 | { "hasChildNodes" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsNodePrototypeFunctionHasChildNodes), (intptr_t) (0) } }, |
| 295 | { "normalize" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsNodePrototypeFunctionNormalize), (intptr_t) (0) } }, |
| 296 | { "cloneNode" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsNodePrototypeFunctionCloneNode), (intptr_t) (0) } }, |
| 297 | { "isEqualNode" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsNodePrototypeFunctionIsEqualNode), (intptr_t) (1) } }, |
| 298 | { "isSameNode" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsNodePrototypeFunctionIsSameNode), (intptr_t) (1) } }, |
| 299 | { "compareDocumentPosition" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsNodePrototypeFunctionCompareDocumentPosition), (intptr_t) (1) } }, |
| 300 | { "contains" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsNodePrototypeFunctionContains), (intptr_t) (1) } }, |
| 301 | { "lookupPrefix" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsNodePrototypeFunctionLookupPrefix), (intptr_t) (1) } }, |
| 302 | { "lookupNamespaceURI" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsNodePrototypeFunctionLookupNamespaceURI), (intptr_t) (1) } }, |
| 303 | { "isDefaultNamespace" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsNodePrototypeFunctionIsDefaultNamespace), (intptr_t) (1) } }, |
| 304 | { "insertBefore" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsNodePrototypeFunctionInsertBefore), (intptr_t) (2) } }, |
| 305 | { "appendChild" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsNodePrototypeFunctionAppendChild), (intptr_t) (1) } }, |
| 306 | { "replaceChild" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsNodePrototypeFunctionReplaceChild), (intptr_t) (2) } }, |
| 307 | { "removeChild" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsNodePrototypeFunctionRemoveChild), (intptr_t) (1) } }, |
| 308 | { "ELEMENT_NODE" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(1) } }, |
| 309 | { "ATTRIBUTE_NODE" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(2) } }, |
| 310 | { "TEXT_NODE" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(3) } }, |
| 311 | { "CDATA_SECTION_NODE" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(4) } }, |
| 312 | { "ENTITY_REFERENCE_NODE" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(5) } }, |
| 313 | { "ENTITY_NODE" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(6) } }, |
| 314 | { "PROCESSING_INSTRUCTION_NODE" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(7) } }, |
| 315 | { "COMMENT_NODE" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(8) } }, |
| 316 | { "DOCUMENT_NODE" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(9) } }, |
| 317 | { "DOCUMENT_TYPE_NODE" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(10) } }, |
| 318 | { "DOCUMENT_FRAGMENT_NODE" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(11) } }, |
| 319 | { "NOTATION_NODE" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(12) } }, |
| 320 | { "DOCUMENT_POSITION_DISCONNECTED" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(0x01) } }, |
| 321 | { "DOCUMENT_POSITION_PRECEDING" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(0x02) } }, |
| 322 | { "DOCUMENT_POSITION_FOLLOWING" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(0x04) } }, |
| 323 | { "DOCUMENT_POSITION_CONTAINS" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(0x08) } }, |
| 324 | { "DOCUMENT_POSITION_CONTAINED_BY" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(0x10) } }, |
| 325 | { "DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(0x20) } }, |
| 326 | }; |
| 327 | |
| 328 | const ClassInfo JSNodePrototype::s_info = { "NodePrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSNodePrototype) }; |
| 329 | |
| 330 | void JSNodePrototype::finishCreation(VM& vm) |
| 331 | { |
| 332 | Base::finishCreation(vm); |
| 333 | reifyStaticProperties(vm, JSNode::info(), JSNodePrototypeTableValues, *this); |
| 334 | bool hasDisabledRuntimeProperties = false; |
| 335 | if (!RuntimeEnabledFeatures::sharedFeatures().shadowDOMEnabled()) { |
| 336 | hasDisabledRuntimeProperties = true; |
| 337 | auto propertyName = Identifier::fromString(&vm, reinterpret_cast<const LChar*>("getRootNode" ), strlen("getRootNode" )); |
| 338 | VM::DeletePropertyModeScope scope(vm, VM::DeletePropertyMode::IgnoreConfigurable); |
| 339 | JSObject::deleteProperty(this, globalObject()->globalExec(), propertyName); |
| 340 | } |
| 341 | if (!RuntimeEnabledFeatures::sharedFeatures().shadowDOMEnabled()) { |
| 342 | hasDisabledRuntimeProperties = true; |
| 343 | auto propertyName = Identifier::fromString(&vm, reinterpret_cast<const LChar*>("isConnected" ), strlen("isConnected" )); |
| 344 | VM::DeletePropertyModeScope scope(vm, VM::DeletePropertyMode::IgnoreConfigurable); |
| 345 | JSObject::deleteProperty(this, globalObject()->globalExec(), propertyName); |
| 346 | } |
| 347 | if (hasDisabledRuntimeProperties && structure()->isDictionary()) |
| 348 | flattenDictionaryObject(vm); |
| 349 | } |
| 350 | |
| 351 | const ClassInfo JSNode::s_info = { "Node" , &Base::s_info, nullptr |
| 352 | #if ENABLE(JIT) |
| 353 | , &checkSubClassSnippetForJSNode |
| 354 | #else |
| 355 | , nullptr |
| 356 | #endif |
| 357 | , CREATE_METHOD_TABLE(JSNode) }; |
| 358 | |
| 359 | JSNode::JSNode(Structure* structure, JSDOMGlobalObject& globalObject, Ref<Node>&& impl) |
| 360 | : JSEventTarget(structure, globalObject, WTFMove(impl)) |
| 361 | { |
| 362 | } |
| 363 | |
| 364 | void JSNode::finishCreation(VM& vm) |
| 365 | { |
| 366 | Base::finishCreation(vm); |
| 367 | ASSERT(inherits(vm, info())); |
| 368 | |
| 369 | } |
| 370 | |
| 371 | JSObject* JSNode::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
| 372 | { |
| 373 | return JSNodePrototype::create(vm, &globalObject, JSNodePrototype::createStructure(vm, &globalObject, JSEventTarget::prototype(vm, globalObject))); |
| 374 | } |
| 375 | |
| 376 | JSObject* JSNode::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
| 377 | { |
| 378 | return getDOMPrototype<JSNode>(vm, globalObject); |
| 379 | } |
| 380 | |
| 381 | JSValue JSNode::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
| 382 | { |
| 383 | return getDOMConstructor<JSNodeConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
| 384 | } |
| 385 | |
| 386 | template<> inline JSNode* IDLAttribute<JSNode>::cast(ExecState& state, EncodedJSValue thisValue) |
| 387 | { |
| 388 | return jsDynamicCast<JSNode*>(state.vm(), JSValue::decode(thisValue)); |
| 389 | } |
| 390 | |
| 391 | template<> inline JSNode* IDLOperation<JSNode>::cast(ExecState& state) |
| 392 | { |
| 393 | return jsDynamicCast<JSNode*>(state.vm(), state.thisValue()); |
| 394 | } |
| 395 | |
| 396 | EncodedJSValue jsNodeConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 397 | { |
| 398 | VM& vm = state->vm(); |
| 399 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 400 | auto* prototype = jsDynamicCast<JSNodePrototype*>(vm, JSValue::decode(thisValue)); |
| 401 | if (UNLIKELY(!prototype)) |
| 402 | return throwVMTypeError(state, throwScope); |
| 403 | return JSValue::encode(JSNode::getConstructor(state->vm(), prototype->globalObject())); |
| 404 | } |
| 405 | |
| 406 | bool setJSNodeConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| 407 | { |
| 408 | VM& vm = state->vm(); |
| 409 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 410 | auto* prototype = jsDynamicCast<JSNodePrototype*>(vm, JSValue::decode(thisValue)); |
| 411 | if (UNLIKELY(!prototype)) { |
| 412 | throwVMTypeError(state, throwScope); |
| 413 | return false; |
| 414 | } |
| 415 | // Shadowing a built-in constructor |
| 416 | return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue)); |
| 417 | } |
| 418 | |
| 419 | static inline JSValue jsNodeNodeTypeGetter(ExecState& state, JSNode& thisObject, ThrowScope& throwScope) |
| 420 | { |
| 421 | UNUSED_PARAM(throwScope); |
| 422 | UNUSED_PARAM(state); |
| 423 | return thisObject.nodeType(state); |
| 424 | } |
| 425 | |
| 426 | EncodedJSValue jsNodeNodeType(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 427 | { |
| 428 | return IDLAttribute<JSNode>::get<jsNodeNodeTypeGetter>(*state, thisValue, "nodeType" ); |
| 429 | } |
| 430 | |
| 431 | static inline JSValue jsNodeNodeNameGetter(ExecState& state, JSNode& thisObject, ThrowScope& throwScope) |
| 432 | { |
| 433 | UNUSED_PARAM(throwScope); |
| 434 | UNUSED_PARAM(state); |
| 435 | auto& impl = thisObject.wrapped(); |
| 436 | JSValue result = toJS<IDLDOMString>(state, throwScope, impl.nodeName()); |
| 437 | return result; |
| 438 | } |
| 439 | |
| 440 | EncodedJSValue jsNodeNodeName(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 441 | { |
| 442 | return IDLAttribute<JSNode>::get<jsNodeNodeNameGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "nodeName" ); |
| 443 | } |
| 444 | |
| 445 | static inline JSValue jsNodeBaseURIGetter(ExecState& state, JSNode& thisObject, ThrowScope& throwScope) |
| 446 | { |
| 447 | UNUSED_PARAM(throwScope); |
| 448 | UNUSED_PARAM(state); |
| 449 | auto& impl = thisObject.wrapped(); |
| 450 | JSValue result = toJS<IDLUSVString>(state, throwScope, impl.baseURI()); |
| 451 | return result; |
| 452 | } |
| 453 | |
| 454 | EncodedJSValue jsNodeBaseURI(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 455 | { |
| 456 | return IDLAttribute<JSNode>::get<jsNodeBaseURIGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "baseURI" ); |
| 457 | } |
| 458 | |
| 459 | static inline JSValue jsNodeIsConnectedGetter(ExecState& state, JSNode& thisObject, ThrowScope& throwScope) |
| 460 | { |
| 461 | UNUSED_PARAM(throwScope); |
| 462 | UNUSED_PARAM(state); |
| 463 | auto& impl = thisObject.wrapped(); |
| 464 | JSValue result = toJS<IDLBoolean>(state, throwScope, impl.isConnected()); |
| 465 | return result; |
| 466 | } |
| 467 | |
| 468 | EncodedJSValue jsNodeIsConnected(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 469 | { |
| 470 | return IDLAttribute<JSNode>::get<jsNodeIsConnectedGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "isConnected" ); |
| 471 | } |
| 472 | |
| 473 | static inline JSValue jsNodeOwnerDocumentGetter(ExecState& state, JSNode& thisObject, ThrowScope& throwScope) |
| 474 | { |
| 475 | UNUSED_PARAM(throwScope); |
| 476 | UNUSED_PARAM(state); |
| 477 | auto& impl = thisObject.wrapped(); |
| 478 | JSValue result = toJS<IDLNullable<IDLInterface<Document>>>(state, *thisObject.globalObject(), throwScope, impl.ownerDocument()); |
| 479 | return result; |
| 480 | } |
| 481 | |
| 482 | EncodedJSValue jsNodeOwnerDocument(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 483 | { |
| 484 | return IDLAttribute<JSNode>::get<jsNodeOwnerDocumentGetter>(*state, thisValue, "ownerDocument" ); |
| 485 | } |
| 486 | |
| 487 | static inline JSValue jsNodeParentNodeGetter(ExecState& state, JSNode& thisObject, ThrowScope& throwScope) |
| 488 | { |
| 489 | UNUSED_PARAM(throwScope); |
| 490 | UNUSED_PARAM(state); |
| 491 | auto& impl = thisObject.wrapped(); |
| 492 | JSValue result = toJS<IDLNullable<IDLInterface<Node>>>(state, *thisObject.globalObject(), throwScope, impl.parentNode()); |
| 493 | return result; |
| 494 | } |
| 495 | |
| 496 | EncodedJSValue jsNodeParentNode(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 497 | { |
| 498 | return IDLAttribute<JSNode>::get<jsNodeParentNodeGetter>(*state, thisValue, "parentNode" ); |
| 499 | } |
| 500 | |
| 501 | static inline JSValue jsNodeParentElementGetter(ExecState& state, JSNode& thisObject, ThrowScope& throwScope) |
| 502 | { |
| 503 | UNUSED_PARAM(throwScope); |
| 504 | UNUSED_PARAM(state); |
| 505 | auto& impl = thisObject.wrapped(); |
| 506 | JSValue result = toJS<IDLNullable<IDLInterface<Element>>>(state, *thisObject.globalObject(), throwScope, impl.parentElement()); |
| 507 | return result; |
| 508 | } |
| 509 | |
| 510 | EncodedJSValue jsNodeParentElement(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 511 | { |
| 512 | return IDLAttribute<JSNode>::get<jsNodeParentElementGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "parentElement" ); |
| 513 | } |
| 514 | |
| 515 | static inline JSValue jsNodeChildNodesGetter(ExecState& state, JSNode& thisObject, ThrowScope& throwScope) |
| 516 | { |
| 517 | UNUSED_PARAM(throwScope); |
| 518 | UNUSED_PARAM(state); |
| 519 | auto& impl = thisObject.wrapped(); |
| 520 | JSValue result = toJS<IDLInterface<NodeList>>(state, *thisObject.globalObject(), throwScope, impl.childNodes()); |
| 521 | return result; |
| 522 | } |
| 523 | |
| 524 | EncodedJSValue jsNodeChildNodes(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 525 | { |
| 526 | return IDLAttribute<JSNode>::get<jsNodeChildNodesGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "childNodes" ); |
| 527 | } |
| 528 | |
| 529 | static inline JSValue jsNodeFirstChildGetter(ExecState& state, JSNode& thisObject, ThrowScope& throwScope) |
| 530 | { |
| 531 | UNUSED_PARAM(throwScope); |
| 532 | UNUSED_PARAM(state); |
| 533 | auto& impl = thisObject.wrapped(); |
| 534 | JSValue result = toJS<IDLNullable<IDLInterface<Node>>>(state, *thisObject.globalObject(), throwScope, impl.firstChild()); |
| 535 | return result; |
| 536 | } |
| 537 | |
| 538 | EncodedJSValue jsNodeFirstChild(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 539 | { |
| 540 | return IDLAttribute<JSNode>::get<jsNodeFirstChildGetter>(*state, thisValue, "firstChild" ); |
| 541 | } |
| 542 | |
| 543 | static inline JSValue jsNodeLastChildGetter(ExecState& state, JSNode& thisObject, ThrowScope& throwScope) |
| 544 | { |
| 545 | UNUSED_PARAM(throwScope); |
| 546 | UNUSED_PARAM(state); |
| 547 | auto& impl = thisObject.wrapped(); |
| 548 | JSValue result = toJS<IDLNullable<IDLInterface<Node>>>(state, *thisObject.globalObject(), throwScope, impl.lastChild()); |
| 549 | return result; |
| 550 | } |
| 551 | |
| 552 | EncodedJSValue jsNodeLastChild(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 553 | { |
| 554 | return IDLAttribute<JSNode>::get<jsNodeLastChildGetter>(*state, thisValue, "lastChild" ); |
| 555 | } |
| 556 | |
| 557 | static inline JSValue jsNodePreviousSiblingGetter(ExecState& state, JSNode& thisObject, ThrowScope& throwScope) |
| 558 | { |
| 559 | UNUSED_PARAM(throwScope); |
| 560 | UNUSED_PARAM(state); |
| 561 | auto& impl = thisObject.wrapped(); |
| 562 | JSValue result = toJS<IDLNullable<IDLInterface<Node>>>(state, *thisObject.globalObject(), throwScope, impl.previousSibling()); |
| 563 | return result; |
| 564 | } |
| 565 | |
| 566 | EncodedJSValue jsNodePreviousSibling(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 567 | { |
| 568 | return IDLAttribute<JSNode>::get<jsNodePreviousSiblingGetter>(*state, thisValue, "previousSibling" ); |
| 569 | } |
| 570 | |
| 571 | static inline JSValue jsNodeNextSiblingGetter(ExecState& state, JSNode& thisObject, ThrowScope& throwScope) |
| 572 | { |
| 573 | UNUSED_PARAM(throwScope); |
| 574 | UNUSED_PARAM(state); |
| 575 | auto& impl = thisObject.wrapped(); |
| 576 | JSValue result = toJS<IDLNullable<IDLInterface<Node>>>(state, *thisObject.globalObject(), throwScope, impl.nextSibling()); |
| 577 | return result; |
| 578 | } |
| 579 | |
| 580 | EncodedJSValue jsNodeNextSibling(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 581 | { |
| 582 | return IDLAttribute<JSNode>::get<jsNodeNextSiblingGetter>(*state, thisValue, "nextSibling" ); |
| 583 | } |
| 584 | |
| 585 | static inline JSValue jsNodeNodeValueGetter(ExecState& state, JSNode& thisObject, ThrowScope& throwScope) |
| 586 | { |
| 587 | UNUSED_PARAM(throwScope); |
| 588 | UNUSED_PARAM(state); |
| 589 | auto& impl = thisObject.wrapped(); |
| 590 | JSValue result = toJS<IDLNullable<IDLDOMString>>(state, throwScope, impl.nodeValue()); |
| 591 | return result; |
| 592 | } |
| 593 | |
| 594 | EncodedJSValue jsNodeNodeValue(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 595 | { |
| 596 | return IDLAttribute<JSNode>::get<jsNodeNodeValueGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "nodeValue" ); |
| 597 | } |
| 598 | |
| 599 | static inline bool setJSNodeNodeValueSetter(ExecState& state, JSNode& thisObject, JSValue value, ThrowScope& throwScope) |
| 600 | { |
| 601 | UNUSED_PARAM(throwScope); |
| 602 | CustomElementReactionStack customElementReactionStack(state); |
| 603 | auto& impl = thisObject.wrapped(); |
| 604 | auto nativeValue = convert<IDLNullable<IDLDOMString>>(state, value); |
| 605 | RETURN_IF_EXCEPTION(throwScope, false); |
| 606 | AttributeSetter::call(state, throwScope, [&] { |
| 607 | return impl.setNodeValue(WTFMove(nativeValue)); |
| 608 | }); |
| 609 | return true; |
| 610 | } |
| 611 | |
| 612 | bool setJSNodeNodeValue(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| 613 | { |
| 614 | return IDLAttribute<JSNode>::set<setJSNodeNodeValueSetter>(*state, thisValue, encodedValue, "nodeValue" ); |
| 615 | } |
| 616 | |
| 617 | static inline JSValue jsNodeTextContentGetter(ExecState& state, JSNode& thisObject, ThrowScope& throwScope) |
| 618 | { |
| 619 | UNUSED_PARAM(throwScope); |
| 620 | UNUSED_PARAM(state); |
| 621 | auto& impl = thisObject.wrapped(); |
| 622 | JSValue result = toJS<IDLNullable<IDLDOMString>>(state, throwScope, impl.textContent()); |
| 623 | return result; |
| 624 | } |
| 625 | |
| 626 | EncodedJSValue jsNodeTextContent(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 627 | { |
| 628 | return IDLAttribute<JSNode>::get<jsNodeTextContentGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "textContent" ); |
| 629 | } |
| 630 | |
| 631 | static inline bool setJSNodeTextContentSetter(ExecState& state, JSNode& thisObject, JSValue value, ThrowScope& throwScope) |
| 632 | { |
| 633 | UNUSED_PARAM(throwScope); |
| 634 | CustomElementReactionStack customElementReactionStack(state); |
| 635 | auto& impl = thisObject.wrapped(); |
| 636 | auto nativeValue = convert<IDLNullable<IDLDOMString>>(state, value); |
| 637 | RETURN_IF_EXCEPTION(throwScope, false); |
| 638 | AttributeSetter::call(state, throwScope, [&] { |
| 639 | return impl.setTextContent(WTFMove(nativeValue)); |
| 640 | }); |
| 641 | return true; |
| 642 | } |
| 643 | |
| 644 | bool setJSNodeTextContent(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| 645 | { |
| 646 | return IDLAttribute<JSNode>::set<setJSNodeTextContentSetter>(*state, thisValue, encodedValue, "textContent" ); |
| 647 | } |
| 648 | |
| 649 | static inline JSC::EncodedJSValue jsNodePrototypeFunctionGetRootNodeBody(JSC::ExecState* state, typename IDLOperation<JSNode>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 650 | { |
| 651 | UNUSED_PARAM(state); |
| 652 | UNUSED_PARAM(throwScope); |
| 653 | auto& impl = castedThis->wrapped(); |
| 654 | auto options = convert<IDLDictionary<Node::GetRootNodeOptions>>(*state, state->argument(0)); |
| 655 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 656 | return JSValue::encode(toJS<IDLInterface<Node>>(*state, *castedThis->globalObject(), impl.getRootNode(WTFMove(options)))); |
| 657 | } |
| 658 | |
| 659 | EncodedJSValue JSC_HOST_CALL jsNodePrototypeFunctionGetRootNode(ExecState* state) |
| 660 | { |
| 661 | return IDLOperation<JSNode>::call<jsNodePrototypeFunctionGetRootNodeBody>(*state, "getRootNode" ); |
| 662 | } |
| 663 | |
| 664 | static inline JSC::EncodedJSValue jsNodePrototypeFunctionHasChildNodesBody(JSC::ExecState* state, typename IDLOperation<JSNode>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 665 | { |
| 666 | UNUSED_PARAM(state); |
| 667 | UNUSED_PARAM(throwScope); |
| 668 | auto& impl = castedThis->wrapped(); |
| 669 | return JSValue::encode(toJS<IDLBoolean>(impl.hasChildNodes())); |
| 670 | } |
| 671 | |
| 672 | EncodedJSValue JSC_HOST_CALL jsNodePrototypeFunctionHasChildNodes(ExecState* state) |
| 673 | { |
| 674 | return IDLOperation<JSNode>::call<jsNodePrototypeFunctionHasChildNodesBody>(*state, "hasChildNodes" ); |
| 675 | } |
| 676 | |
| 677 | static inline JSC::EncodedJSValue jsNodePrototypeFunctionNormalizeBody(JSC::ExecState* state, typename IDLOperation<JSNode>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 678 | { |
| 679 | UNUSED_PARAM(state); |
| 680 | UNUSED_PARAM(throwScope); |
| 681 | CustomElementReactionStack customElementReactionStack(*state); |
| 682 | auto& impl = castedThis->wrapped(); |
| 683 | impl.normalize(); |
| 684 | return JSValue::encode(jsUndefined()); |
| 685 | } |
| 686 | |
| 687 | EncodedJSValue JSC_HOST_CALL jsNodePrototypeFunctionNormalize(ExecState* state) |
| 688 | { |
| 689 | return IDLOperation<JSNode>::call<jsNodePrototypeFunctionNormalizeBody>(*state, "normalize" ); |
| 690 | } |
| 691 | |
| 692 | static inline JSC::EncodedJSValue jsNodePrototypeFunctionCloneNodeBody(JSC::ExecState* state, typename IDLOperation<JSNode>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 693 | { |
| 694 | UNUSED_PARAM(state); |
| 695 | UNUSED_PARAM(throwScope); |
| 696 | CustomElementReactionStack customElementReactionStack(*state); |
| 697 | auto& impl = castedThis->wrapped(); |
| 698 | auto deep = convert<IDLBoolean>(*state, state->argument(0)); |
| 699 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 700 | return JSValue::encode(toJSNewlyCreated<IDLInterface<Node>>(*state, *castedThis->globalObject(), throwScope, impl.cloneNodeForBindings(WTFMove(deep)))); |
| 701 | } |
| 702 | |
| 703 | EncodedJSValue JSC_HOST_CALL jsNodePrototypeFunctionCloneNode(ExecState* state) |
| 704 | { |
| 705 | return IDLOperation<JSNode>::call<jsNodePrototypeFunctionCloneNodeBody>(*state, "cloneNode" ); |
| 706 | } |
| 707 | |
| 708 | static inline JSC::EncodedJSValue jsNodePrototypeFunctionIsEqualNodeBody(JSC::ExecState* state, typename IDLOperation<JSNode>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 709 | { |
| 710 | UNUSED_PARAM(state); |
| 711 | UNUSED_PARAM(throwScope); |
| 712 | auto& impl = castedThis->wrapped(); |
| 713 | if (UNLIKELY(state->argumentCount() < 1)) |
| 714 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| 715 | auto other = convert<IDLNullable<IDLInterface<Node>>>(*state, state->uncheckedArgument(0), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentTypeError(state, scope, 0, "other" , "Node" , "isEqualNode" , "Node" ); }); |
| 716 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 717 | return JSValue::encode(toJS<IDLBoolean>(impl.isEqualNode(WTFMove(other)))); |
| 718 | } |
| 719 | |
| 720 | EncodedJSValue JSC_HOST_CALL jsNodePrototypeFunctionIsEqualNode(ExecState* state) |
| 721 | { |
| 722 | return IDLOperation<JSNode>::call<jsNodePrototypeFunctionIsEqualNodeBody>(*state, "isEqualNode" ); |
| 723 | } |
| 724 | |
| 725 | static inline JSC::EncodedJSValue jsNodePrototypeFunctionIsSameNodeBody(JSC::ExecState* state, typename IDLOperation<JSNode>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 726 | { |
| 727 | UNUSED_PARAM(state); |
| 728 | UNUSED_PARAM(throwScope); |
| 729 | auto& impl = castedThis->wrapped(); |
| 730 | if (UNLIKELY(state->argumentCount() < 1)) |
| 731 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| 732 | auto other = convert<IDLNullable<IDLInterface<Node>>>(*state, state->uncheckedArgument(0), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentTypeError(state, scope, 0, "other" , "Node" , "isSameNode" , "Node" ); }); |
| 733 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 734 | return JSValue::encode(toJS<IDLBoolean>(impl.isSameNode(WTFMove(other)))); |
| 735 | } |
| 736 | |
| 737 | EncodedJSValue JSC_HOST_CALL jsNodePrototypeFunctionIsSameNode(ExecState* state) |
| 738 | { |
| 739 | return IDLOperation<JSNode>::call<jsNodePrototypeFunctionIsSameNodeBody>(*state, "isSameNode" ); |
| 740 | } |
| 741 | |
| 742 | static inline JSC::EncodedJSValue jsNodePrototypeFunctionCompareDocumentPositionBody(JSC::ExecState* state, typename IDLOperation<JSNode>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 743 | { |
| 744 | UNUSED_PARAM(state); |
| 745 | UNUSED_PARAM(throwScope); |
| 746 | auto& impl = castedThis->wrapped(); |
| 747 | if (UNLIKELY(state->argumentCount() < 1)) |
| 748 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| 749 | auto other = convert<IDLInterface<Node>>(*state, state->uncheckedArgument(0), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentTypeError(state, scope, 0, "other" , "Node" , "compareDocumentPosition" , "Node" ); }); |
| 750 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 751 | return JSValue::encode(toJS<IDLUnsignedShort>(impl.compareDocumentPosition(*other))); |
| 752 | } |
| 753 | |
| 754 | EncodedJSValue JSC_HOST_CALL jsNodePrototypeFunctionCompareDocumentPosition(ExecState* state) |
| 755 | { |
| 756 | return IDLOperation<JSNode>::call<jsNodePrototypeFunctionCompareDocumentPositionBody>(*state, "compareDocumentPosition" ); |
| 757 | } |
| 758 | |
| 759 | static inline JSC::EncodedJSValue jsNodePrototypeFunctionContainsBody(JSC::ExecState* state, typename IDLOperation<JSNode>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 760 | { |
| 761 | UNUSED_PARAM(state); |
| 762 | UNUSED_PARAM(throwScope); |
| 763 | auto& impl = castedThis->wrapped(); |
| 764 | if (UNLIKELY(state->argumentCount() < 1)) |
| 765 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| 766 | auto other = convert<IDLNullable<IDLInterface<Node>>>(*state, state->uncheckedArgument(0), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentTypeError(state, scope, 0, "other" , "Node" , "contains" , "Node" ); }); |
| 767 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 768 | return JSValue::encode(toJS<IDLBoolean>(impl.contains(WTFMove(other)))); |
| 769 | } |
| 770 | |
| 771 | EncodedJSValue JSC_HOST_CALL jsNodePrototypeFunctionContains(ExecState* state) |
| 772 | { |
| 773 | return IDLOperation<JSNode>::call<jsNodePrototypeFunctionContainsBody>(*state, "contains" ); |
| 774 | } |
| 775 | |
| 776 | static inline JSC::EncodedJSValue jsNodePrototypeFunctionLookupPrefixBody(JSC::ExecState* state, typename IDLOperation<JSNode>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 777 | { |
| 778 | UNUSED_PARAM(state); |
| 779 | UNUSED_PARAM(throwScope); |
| 780 | auto& impl = castedThis->wrapped(); |
| 781 | if (UNLIKELY(state->argumentCount() < 1)) |
| 782 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| 783 | auto namespaceURI = convert<IDLNullable<IDLDOMString>>(*state, state->uncheckedArgument(0)); |
| 784 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 785 | return JSValue::encode(toJS<IDLNullable<IDLDOMString>>(*state, impl.lookupPrefix(WTFMove(namespaceURI)))); |
| 786 | } |
| 787 | |
| 788 | EncodedJSValue JSC_HOST_CALL jsNodePrototypeFunctionLookupPrefix(ExecState* state) |
| 789 | { |
| 790 | return IDLOperation<JSNode>::call<jsNodePrototypeFunctionLookupPrefixBody>(*state, "lookupPrefix" ); |
| 791 | } |
| 792 | |
| 793 | static inline JSC::EncodedJSValue jsNodePrototypeFunctionLookupNamespaceURIBody(JSC::ExecState* state, typename IDLOperation<JSNode>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 794 | { |
| 795 | UNUSED_PARAM(state); |
| 796 | UNUSED_PARAM(throwScope); |
| 797 | auto& impl = castedThis->wrapped(); |
| 798 | if (UNLIKELY(state->argumentCount() < 1)) |
| 799 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| 800 | auto prefix = convert<IDLNullable<IDLDOMString>>(*state, state->uncheckedArgument(0)); |
| 801 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 802 | return JSValue::encode(toJS<IDLNullable<IDLDOMString>>(*state, impl.lookupNamespaceURI(WTFMove(prefix)))); |
| 803 | } |
| 804 | |
| 805 | EncodedJSValue JSC_HOST_CALL jsNodePrototypeFunctionLookupNamespaceURI(ExecState* state) |
| 806 | { |
| 807 | return IDLOperation<JSNode>::call<jsNodePrototypeFunctionLookupNamespaceURIBody>(*state, "lookupNamespaceURI" ); |
| 808 | } |
| 809 | |
| 810 | static inline JSC::EncodedJSValue jsNodePrototypeFunctionIsDefaultNamespaceBody(JSC::ExecState* state, typename IDLOperation<JSNode>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 811 | { |
| 812 | UNUSED_PARAM(state); |
| 813 | UNUSED_PARAM(throwScope); |
| 814 | auto& impl = castedThis->wrapped(); |
| 815 | if (UNLIKELY(state->argumentCount() < 1)) |
| 816 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| 817 | auto namespaceURI = convert<IDLNullable<IDLDOMString>>(*state, state->uncheckedArgument(0)); |
| 818 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 819 | return JSValue::encode(toJS<IDLBoolean>(impl.isDefaultNamespace(WTFMove(namespaceURI)))); |
| 820 | } |
| 821 | |
| 822 | EncodedJSValue JSC_HOST_CALL jsNodePrototypeFunctionIsDefaultNamespace(ExecState* state) |
| 823 | { |
| 824 | return IDLOperation<JSNode>::call<jsNodePrototypeFunctionIsDefaultNamespaceBody>(*state, "isDefaultNamespace" ); |
| 825 | } |
| 826 | |
| 827 | static inline JSC::EncodedJSValue jsNodePrototypeFunctionInsertBeforeBody(JSC::ExecState* state, typename IDLOperation<JSNode>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 828 | { |
| 829 | UNUSED_PARAM(state); |
| 830 | UNUSED_PARAM(throwScope); |
| 831 | CustomElementReactionStack customElementReactionStack(*state); |
| 832 | auto& impl = castedThis->wrapped(); |
| 833 | if (UNLIKELY(state->argumentCount() < 2)) |
| 834 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| 835 | auto returnValue = state->uncheckedArgument(0); |
| 836 | auto node = convert<IDLInterface<Node>>(*state, returnValue, [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentTypeError(state, scope, 0, "node" , "Node" , "insertBefore" , "Node" ); }); |
| 837 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 838 | auto child = convert<IDLNullable<IDLInterface<Node>>>(*state, state->uncheckedArgument(1), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentTypeError(state, scope, 1, "child" , "Node" , "insertBefore" , "Node" ); }); |
| 839 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 840 | propagateException(*state, throwScope, impl.insertBefore(*node, WTFMove(child))); |
| 841 | return JSValue::encode(returnValue); |
| 842 | } |
| 843 | |
| 844 | EncodedJSValue JSC_HOST_CALL jsNodePrototypeFunctionInsertBefore(ExecState* state) |
| 845 | { |
| 846 | return IDLOperation<JSNode>::call<jsNodePrototypeFunctionInsertBeforeBody>(*state, "insertBefore" ); |
| 847 | } |
| 848 | |
| 849 | static inline JSC::EncodedJSValue jsNodePrototypeFunctionAppendChildBody(JSC::ExecState* state, typename IDLOperation<JSNode>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 850 | { |
| 851 | UNUSED_PARAM(state); |
| 852 | UNUSED_PARAM(throwScope); |
| 853 | CustomElementReactionStack customElementReactionStack(*state); |
| 854 | auto& impl = castedThis->wrapped(); |
| 855 | if (UNLIKELY(state->argumentCount() < 1)) |
| 856 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| 857 | auto returnValue = state->uncheckedArgument(0); |
| 858 | auto node = convert<IDLInterface<Node>>(*state, returnValue, [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentTypeError(state, scope, 0, "node" , "Node" , "appendChild" , "Node" ); }); |
| 859 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 860 | propagateException(*state, throwScope, impl.appendChild(*node)); |
| 861 | return JSValue::encode(returnValue); |
| 862 | } |
| 863 | |
| 864 | EncodedJSValue JSC_HOST_CALL jsNodePrototypeFunctionAppendChild(ExecState* state) |
| 865 | { |
| 866 | return IDLOperation<JSNode>::call<jsNodePrototypeFunctionAppendChildBody>(*state, "appendChild" ); |
| 867 | } |
| 868 | |
| 869 | static inline JSC::EncodedJSValue jsNodePrototypeFunctionReplaceChildBody(JSC::ExecState* state, typename IDLOperation<JSNode>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 870 | { |
| 871 | UNUSED_PARAM(state); |
| 872 | UNUSED_PARAM(throwScope); |
| 873 | CustomElementReactionStack customElementReactionStack(*state); |
| 874 | auto& impl = castedThis->wrapped(); |
| 875 | if (UNLIKELY(state->argumentCount() < 2)) |
| 876 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| 877 | auto node = convert<IDLInterface<Node>>(*state, state->uncheckedArgument(0), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentTypeError(state, scope, 0, "node" , "Node" , "replaceChild" , "Node" ); }); |
| 878 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 879 | auto returnValue = state->uncheckedArgument(1); |
| 880 | auto child = convert<IDLInterface<Node>>(*state, returnValue, [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentTypeError(state, scope, 1, "child" , "Node" , "replaceChild" , "Node" ); }); |
| 881 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 882 | propagateException(*state, throwScope, impl.replaceChild(*node, *child)); |
| 883 | return JSValue::encode(returnValue); |
| 884 | } |
| 885 | |
| 886 | EncodedJSValue JSC_HOST_CALL jsNodePrototypeFunctionReplaceChild(ExecState* state) |
| 887 | { |
| 888 | return IDLOperation<JSNode>::call<jsNodePrototypeFunctionReplaceChildBody>(*state, "replaceChild" ); |
| 889 | } |
| 890 | |
| 891 | static inline JSC::EncodedJSValue jsNodePrototypeFunctionRemoveChildBody(JSC::ExecState* state, typename IDLOperation<JSNode>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 892 | { |
| 893 | UNUSED_PARAM(state); |
| 894 | UNUSED_PARAM(throwScope); |
| 895 | CustomElementReactionStack customElementReactionStack(*state); |
| 896 | auto& impl = castedThis->wrapped(); |
| 897 | if (UNLIKELY(state->argumentCount() < 1)) |
| 898 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| 899 | auto returnValue = state->uncheckedArgument(0); |
| 900 | auto child = convert<IDLInterface<Node>>(*state, returnValue, [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentTypeError(state, scope, 0, "child" , "Node" , "removeChild" , "Node" ); }); |
| 901 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 902 | propagateException(*state, throwScope, impl.removeChild(*child)); |
| 903 | return JSValue::encode(returnValue); |
| 904 | } |
| 905 | |
| 906 | EncodedJSValue JSC_HOST_CALL jsNodePrototypeFunctionRemoveChild(ExecState* state) |
| 907 | { |
| 908 | return IDLOperation<JSNode>::call<jsNodePrototypeFunctionRemoveChildBody>(*state, "removeChild" ); |
| 909 | } |
| 910 | |
| 911 | void JSNode::visitChildren(JSCell* cell, SlotVisitor& visitor) |
| 912 | { |
| 913 | auto* thisObject = jsCast<JSNode*>(cell); |
| 914 | ASSERT_GC_OBJECT_INHERITS(thisObject, info()); |
| 915 | Base::visitChildren(thisObject, visitor); |
| 916 | thisObject->visitAdditionalChildren(visitor); |
| 917 | } |
| 918 | |
| 919 | void JSNode::visitOutputConstraints(JSCell* cell, SlotVisitor& visitor) |
| 920 | { |
| 921 | auto* thisObject = jsCast<JSNode*>(cell); |
| 922 | ASSERT_GC_OBJECT_INHERITS(thisObject, info()); |
| 923 | Base::visitOutputConstraints(thisObject, visitor); |
| 924 | thisObject->visitAdditionalChildren(visitor); |
| 925 | } |
| 926 | |
| 927 | void JSNode::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) |
| 928 | { |
| 929 | auto* thisObject = jsCast<JSNode*>(cell); |
| 930 | builder.setWrappedObjectForCell(cell, &thisObject->wrapped()); |
| 931 | if (thisObject->scriptExecutionContext()) |
| 932 | builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); |
| 933 | Base::heapSnapshot(cell, builder); |
| 934 | } |
| 935 | |
| 936 | void JSNodeOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context) |
| 937 | { |
| 938 | auto* jsNode = static_cast<JSNode*>(handle.slot()->asCell()); |
| 939 | auto& world = *static_cast<DOMWrapperWorld*>(context); |
| 940 | uncacheWrapper(world, &jsNode->wrapped(), jsNode); |
| 941 | } |
| 942 | |
| 943 | Node* JSNode::toWrapped(JSC::VM& vm, JSC::JSValue value) |
| 944 | { |
| 945 | if (auto* wrapper = jsDynamicCast<JSNode*>(vm, value)) |
| 946 | return &wrapper->wrapped(); |
| 947 | return nullptr; |
| 948 | } |
| 949 | |
| 950 | } |
| 951 | |