| 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 "JSDOMSelection.h" |
| 23 | |
| 24 | #include "CustomElementReactionQueue.h" |
| 25 | #include "JSDOMAttribute.h" |
| 26 | #include "JSDOMBinding.h" |
| 27 | #include "JSDOMConstructorNotConstructable.h" |
| 28 | #include "JSDOMConvertBoolean.h" |
| 29 | #include "JSDOMConvertInterface.h" |
| 30 | #include "JSDOMConvertNullable.h" |
| 31 | #include "JSDOMConvertNumbers.h" |
| 32 | #include "JSDOMConvertStrings.h" |
| 33 | #include "JSDOMExceptionHandling.h" |
| 34 | #include "JSDOMGlobalObject.h" |
| 35 | #include "JSDOMOperation.h" |
| 36 | #include "JSDOMWrapperCache.h" |
| 37 | #include "JSNode.h" |
| 38 | #include "JSRange.h" |
| 39 | #include "ScriptExecutionContext.h" |
| 40 | #include <JavaScriptCore/FunctionPrototype.h> |
| 41 | #include <JavaScriptCore/HeapSnapshotBuilder.h> |
| 42 | #include <JavaScriptCore/JSCInlines.h> |
| 43 | #include <wtf/GetPtr.h> |
| 44 | #include <wtf/PointerPreparations.h> |
| 45 | #include <wtf/URL.h> |
| 46 | |
| 47 | |
| 48 | namespace WebCore { |
| 49 | using namespace JSC; |
| 50 | |
| 51 | // Functions |
| 52 | |
| 53 | JSC::EncodedJSValue JSC_HOST_CALL jsDOMSelectionPrototypeFunctionCollapse(JSC::ExecState*); |
| 54 | JSC::EncodedJSValue JSC_HOST_CALL jsDOMSelectionPrototypeFunctionCollapseToEnd(JSC::ExecState*); |
| 55 | JSC::EncodedJSValue JSC_HOST_CALL jsDOMSelectionPrototypeFunctionCollapseToStart(JSC::ExecState*); |
| 56 | JSC::EncodedJSValue JSC_HOST_CALL jsDOMSelectionPrototypeFunctionDeleteFromDocument(JSC::ExecState*); |
| 57 | JSC::EncodedJSValue JSC_HOST_CALL jsDOMSelectionPrototypeFunctionContainsNode(JSC::ExecState*); |
| 58 | JSC::EncodedJSValue JSC_HOST_CALL jsDOMSelectionPrototypeFunctionSelectAllChildren(JSC::ExecState*); |
| 59 | JSC::EncodedJSValue JSC_HOST_CALL jsDOMSelectionPrototypeFunctionExtend(JSC::ExecState*); |
| 60 | JSC::EncodedJSValue JSC_HOST_CALL jsDOMSelectionPrototypeFunctionGetRangeAt(JSC::ExecState*); |
| 61 | JSC::EncodedJSValue JSC_HOST_CALL jsDOMSelectionPrototypeFunctionRemoveAllRanges(JSC::ExecState*); |
| 62 | JSC::EncodedJSValue JSC_HOST_CALL jsDOMSelectionPrototypeFunctionAddRange(JSC::ExecState*); |
| 63 | JSC::EncodedJSValue JSC_HOST_CALL jsDOMSelectionPrototypeFunctionToString(JSC::ExecState*); |
| 64 | JSC::EncodedJSValue JSC_HOST_CALL jsDOMSelectionPrototypeFunctionSetBaseAndExtent(JSC::ExecState*); |
| 65 | JSC::EncodedJSValue JSC_HOST_CALL jsDOMSelectionPrototypeFunctionSetPosition(JSC::ExecState*); |
| 66 | JSC::EncodedJSValue JSC_HOST_CALL jsDOMSelectionPrototypeFunctionEmpty(JSC::ExecState*); |
| 67 | JSC::EncodedJSValue JSC_HOST_CALL jsDOMSelectionPrototypeFunctionModify(JSC::ExecState*); |
| 68 | |
| 69 | // Attributes |
| 70 | |
| 71 | JSC::EncodedJSValue jsDOMSelectionConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 72 | bool setJSDOMSelectionConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| 73 | JSC::EncodedJSValue jsDOMSelectionAnchorNode(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 74 | JSC::EncodedJSValue jsDOMSelectionAnchorOffset(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 75 | JSC::EncodedJSValue jsDOMSelectionFocusNode(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 76 | JSC::EncodedJSValue jsDOMSelectionFocusOffset(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 77 | JSC::EncodedJSValue jsDOMSelectionIsCollapsed(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 78 | JSC::EncodedJSValue jsDOMSelectionRangeCount(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 79 | JSC::EncodedJSValue jsDOMSelectionType(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 80 | JSC::EncodedJSValue jsDOMSelectionBaseNode(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 81 | JSC::EncodedJSValue jsDOMSelectionBaseOffset(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 82 | JSC::EncodedJSValue jsDOMSelectionExtentNode(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 83 | JSC::EncodedJSValue jsDOMSelectionExtentOffset(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 84 | |
| 85 | class JSDOMSelectionPrototype : public JSC::JSNonFinalObject { |
| 86 | public: |
| 87 | using Base = JSC::JSNonFinalObject; |
| 88 | static JSDOMSelectionPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
| 89 | { |
| 90 | JSDOMSelectionPrototype* ptr = new (NotNull, JSC::allocateCell<JSDOMSelectionPrototype>(vm.heap)) JSDOMSelectionPrototype(vm, globalObject, structure); |
| 91 | ptr->finishCreation(vm); |
| 92 | return ptr; |
| 93 | } |
| 94 | |
| 95 | DECLARE_INFO; |
| 96 | static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) |
| 97 | { |
| 98 | return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); |
| 99 | } |
| 100 | |
| 101 | private: |
| 102 | JSDOMSelectionPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
| 103 | : JSC::JSNonFinalObject(vm, structure) |
| 104 | { |
| 105 | } |
| 106 | |
| 107 | void finishCreation(JSC::VM&); |
| 108 | }; |
| 109 | |
| 110 | using JSDOMSelectionConstructor = JSDOMConstructorNotConstructable<JSDOMSelection>; |
| 111 | |
| 112 | template<> JSValue JSDOMSelectionConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
| 113 | { |
| 114 | UNUSED_PARAM(vm); |
| 115 | return globalObject.functionPrototype(); |
| 116 | } |
| 117 | |
| 118 | template<> void JSDOMSelectionConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
| 119 | { |
| 120 | putDirect(vm, vm.propertyNames->prototype, JSDOMSelection::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 121 | putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("Selection"_s )), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 122 | putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 123 | } |
| 124 | |
| 125 | template<> const ClassInfo JSDOMSelectionConstructor::s_info = { "Selection" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSDOMSelectionConstructor) }; |
| 126 | |
| 127 | /* Hash table for prototype */ |
| 128 | |
| 129 | static const HashTableValue JSDOMSelectionPrototypeTableValues[] = |
| 130 | { |
| 131 | { "constructor" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDOMSelectionConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSDOMSelectionConstructor) } }, |
| 132 | { "anchorNode" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDOMSelectionAnchorNode), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 133 | { "anchorOffset" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDOMSelectionAnchorOffset), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 134 | { "focusNode" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDOMSelectionFocusNode), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 135 | { "focusOffset" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDOMSelectionFocusOffset), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 136 | { "isCollapsed" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDOMSelectionIsCollapsed), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 137 | { "rangeCount" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDOMSelectionRangeCount), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 138 | { "type" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDOMSelectionType), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 139 | { "baseNode" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDOMSelectionBaseNode), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 140 | { "baseOffset" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDOMSelectionBaseOffset), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 141 | { "extentNode" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDOMSelectionExtentNode), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 142 | { "extentOffset" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDOMSelectionExtentOffset), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 143 | { "collapse" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsDOMSelectionPrototypeFunctionCollapse), (intptr_t) (1) } }, |
| 144 | { "collapseToEnd" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsDOMSelectionPrototypeFunctionCollapseToEnd), (intptr_t) (0) } }, |
| 145 | { "collapseToStart" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsDOMSelectionPrototypeFunctionCollapseToStart), (intptr_t) (0) } }, |
| 146 | { "deleteFromDocument" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsDOMSelectionPrototypeFunctionDeleteFromDocument), (intptr_t) (0) } }, |
| 147 | { "containsNode" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsDOMSelectionPrototypeFunctionContainsNode), (intptr_t) (1) } }, |
| 148 | { "selectAllChildren" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsDOMSelectionPrototypeFunctionSelectAllChildren), (intptr_t) (1) } }, |
| 149 | { "extend" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsDOMSelectionPrototypeFunctionExtend), (intptr_t) (1) } }, |
| 150 | { "getRangeAt" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsDOMSelectionPrototypeFunctionGetRangeAt), (intptr_t) (1) } }, |
| 151 | { "removeAllRanges" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsDOMSelectionPrototypeFunctionRemoveAllRanges), (intptr_t) (0) } }, |
| 152 | { "addRange" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsDOMSelectionPrototypeFunctionAddRange), (intptr_t) (1) } }, |
| 153 | { "toString" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsDOMSelectionPrototypeFunctionToString), (intptr_t) (0) } }, |
| 154 | { "setBaseAndExtent" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsDOMSelectionPrototypeFunctionSetBaseAndExtent), (intptr_t) (4) } }, |
| 155 | { "setPosition" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsDOMSelectionPrototypeFunctionSetPosition), (intptr_t) (1) } }, |
| 156 | { "empty" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsDOMSelectionPrototypeFunctionEmpty), (intptr_t) (0) } }, |
| 157 | { "modify" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsDOMSelectionPrototypeFunctionModify), (intptr_t) (0) } }, |
| 158 | }; |
| 159 | |
| 160 | const ClassInfo JSDOMSelectionPrototype::s_info = { "SelectionPrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSDOMSelectionPrototype) }; |
| 161 | |
| 162 | void JSDOMSelectionPrototype::finishCreation(VM& vm) |
| 163 | { |
| 164 | Base::finishCreation(vm); |
| 165 | reifyStaticProperties(vm, JSDOMSelection::info(), JSDOMSelectionPrototypeTableValues, *this); |
| 166 | } |
| 167 | |
| 168 | const ClassInfo JSDOMSelection::s_info = { "Selection" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSDOMSelection) }; |
| 169 | |
| 170 | JSDOMSelection::JSDOMSelection(Structure* structure, JSDOMGlobalObject& globalObject, Ref<DOMSelection>&& impl) |
| 171 | : JSDOMWrapper<DOMSelection>(structure, globalObject, WTFMove(impl)) |
| 172 | { |
| 173 | } |
| 174 | |
| 175 | void JSDOMSelection::finishCreation(VM& vm) |
| 176 | { |
| 177 | Base::finishCreation(vm); |
| 178 | ASSERT(inherits(vm, info())); |
| 179 | |
| 180 | } |
| 181 | |
| 182 | JSObject* JSDOMSelection::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
| 183 | { |
| 184 | return JSDOMSelectionPrototype::create(vm, &globalObject, JSDOMSelectionPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype())); |
| 185 | } |
| 186 | |
| 187 | JSObject* JSDOMSelection::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
| 188 | { |
| 189 | return getDOMPrototype<JSDOMSelection>(vm, globalObject); |
| 190 | } |
| 191 | |
| 192 | JSValue JSDOMSelection::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
| 193 | { |
| 194 | return getDOMConstructor<JSDOMSelectionConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
| 195 | } |
| 196 | |
| 197 | void JSDOMSelection::destroy(JSC::JSCell* cell) |
| 198 | { |
| 199 | JSDOMSelection* thisObject = static_cast<JSDOMSelection*>(cell); |
| 200 | thisObject->JSDOMSelection::~JSDOMSelection(); |
| 201 | } |
| 202 | |
| 203 | template<> inline JSDOMSelection* IDLAttribute<JSDOMSelection>::cast(ExecState& state, EncodedJSValue thisValue) |
| 204 | { |
| 205 | return jsDynamicCast<JSDOMSelection*>(state.vm(), JSValue::decode(thisValue)); |
| 206 | } |
| 207 | |
| 208 | template<> inline JSDOMSelection* IDLOperation<JSDOMSelection>::cast(ExecState& state) |
| 209 | { |
| 210 | return jsDynamicCast<JSDOMSelection*>(state.vm(), state.thisValue()); |
| 211 | } |
| 212 | |
| 213 | EncodedJSValue jsDOMSelectionConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 214 | { |
| 215 | VM& vm = state->vm(); |
| 216 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 217 | auto* prototype = jsDynamicCast<JSDOMSelectionPrototype*>(vm, JSValue::decode(thisValue)); |
| 218 | if (UNLIKELY(!prototype)) |
| 219 | return throwVMTypeError(state, throwScope); |
| 220 | return JSValue::encode(JSDOMSelection::getConstructor(state->vm(), prototype->globalObject())); |
| 221 | } |
| 222 | |
| 223 | bool setJSDOMSelectionConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| 224 | { |
| 225 | VM& vm = state->vm(); |
| 226 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 227 | auto* prototype = jsDynamicCast<JSDOMSelectionPrototype*>(vm, JSValue::decode(thisValue)); |
| 228 | if (UNLIKELY(!prototype)) { |
| 229 | throwVMTypeError(state, throwScope); |
| 230 | return false; |
| 231 | } |
| 232 | // Shadowing a built-in constructor |
| 233 | return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue)); |
| 234 | } |
| 235 | |
| 236 | static inline JSValue jsDOMSelectionAnchorNodeGetter(ExecState& state, JSDOMSelection& thisObject, ThrowScope& throwScope) |
| 237 | { |
| 238 | UNUSED_PARAM(throwScope); |
| 239 | UNUSED_PARAM(state); |
| 240 | auto& impl = thisObject.wrapped(); |
| 241 | JSValue result = toJS<IDLNullable<IDLInterface<Node>>>(state, *thisObject.globalObject(), throwScope, impl.anchorNode()); |
| 242 | return result; |
| 243 | } |
| 244 | |
| 245 | EncodedJSValue jsDOMSelectionAnchorNode(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 246 | { |
| 247 | return IDLAttribute<JSDOMSelection>::get<jsDOMSelectionAnchorNodeGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "anchorNode" ); |
| 248 | } |
| 249 | |
| 250 | static inline JSValue jsDOMSelectionAnchorOffsetGetter(ExecState& state, JSDOMSelection& thisObject, ThrowScope& throwScope) |
| 251 | { |
| 252 | UNUSED_PARAM(throwScope); |
| 253 | UNUSED_PARAM(state); |
| 254 | auto& impl = thisObject.wrapped(); |
| 255 | JSValue result = toJS<IDLUnsignedLong>(state, throwScope, impl.anchorOffset()); |
| 256 | return result; |
| 257 | } |
| 258 | |
| 259 | EncodedJSValue jsDOMSelectionAnchorOffset(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 260 | { |
| 261 | return IDLAttribute<JSDOMSelection>::get<jsDOMSelectionAnchorOffsetGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "anchorOffset" ); |
| 262 | } |
| 263 | |
| 264 | static inline JSValue jsDOMSelectionFocusNodeGetter(ExecState& state, JSDOMSelection& thisObject, ThrowScope& throwScope) |
| 265 | { |
| 266 | UNUSED_PARAM(throwScope); |
| 267 | UNUSED_PARAM(state); |
| 268 | auto& impl = thisObject.wrapped(); |
| 269 | JSValue result = toJS<IDLNullable<IDLInterface<Node>>>(state, *thisObject.globalObject(), throwScope, impl.focusNode()); |
| 270 | return result; |
| 271 | } |
| 272 | |
| 273 | EncodedJSValue jsDOMSelectionFocusNode(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 274 | { |
| 275 | return IDLAttribute<JSDOMSelection>::get<jsDOMSelectionFocusNodeGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "focusNode" ); |
| 276 | } |
| 277 | |
| 278 | static inline JSValue jsDOMSelectionFocusOffsetGetter(ExecState& state, JSDOMSelection& thisObject, ThrowScope& throwScope) |
| 279 | { |
| 280 | UNUSED_PARAM(throwScope); |
| 281 | UNUSED_PARAM(state); |
| 282 | auto& impl = thisObject.wrapped(); |
| 283 | JSValue result = toJS<IDLUnsignedLong>(state, throwScope, impl.focusOffset()); |
| 284 | return result; |
| 285 | } |
| 286 | |
| 287 | EncodedJSValue jsDOMSelectionFocusOffset(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 288 | { |
| 289 | return IDLAttribute<JSDOMSelection>::get<jsDOMSelectionFocusOffsetGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "focusOffset" ); |
| 290 | } |
| 291 | |
| 292 | static inline JSValue jsDOMSelectionIsCollapsedGetter(ExecState& state, JSDOMSelection& thisObject, ThrowScope& throwScope) |
| 293 | { |
| 294 | UNUSED_PARAM(throwScope); |
| 295 | UNUSED_PARAM(state); |
| 296 | auto& impl = thisObject.wrapped(); |
| 297 | JSValue result = toJS<IDLBoolean>(state, throwScope, impl.isCollapsed()); |
| 298 | return result; |
| 299 | } |
| 300 | |
| 301 | EncodedJSValue jsDOMSelectionIsCollapsed(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 302 | { |
| 303 | return IDLAttribute<JSDOMSelection>::get<jsDOMSelectionIsCollapsedGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "isCollapsed" ); |
| 304 | } |
| 305 | |
| 306 | static inline JSValue jsDOMSelectionRangeCountGetter(ExecState& state, JSDOMSelection& thisObject, ThrowScope& throwScope) |
| 307 | { |
| 308 | UNUSED_PARAM(throwScope); |
| 309 | UNUSED_PARAM(state); |
| 310 | auto& impl = thisObject.wrapped(); |
| 311 | JSValue result = toJS<IDLUnsignedLong>(state, throwScope, impl.rangeCount()); |
| 312 | return result; |
| 313 | } |
| 314 | |
| 315 | EncodedJSValue jsDOMSelectionRangeCount(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 316 | { |
| 317 | return IDLAttribute<JSDOMSelection>::get<jsDOMSelectionRangeCountGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "rangeCount" ); |
| 318 | } |
| 319 | |
| 320 | static inline JSValue jsDOMSelectionTypeGetter(ExecState& state, JSDOMSelection& thisObject, ThrowScope& throwScope) |
| 321 | { |
| 322 | UNUSED_PARAM(throwScope); |
| 323 | UNUSED_PARAM(state); |
| 324 | auto& impl = thisObject.wrapped(); |
| 325 | JSValue result = toJS<IDLDOMString>(state, throwScope, impl.type()); |
| 326 | return result; |
| 327 | } |
| 328 | |
| 329 | EncodedJSValue jsDOMSelectionType(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 330 | { |
| 331 | return IDLAttribute<JSDOMSelection>::get<jsDOMSelectionTypeGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "type" ); |
| 332 | } |
| 333 | |
| 334 | static inline JSValue jsDOMSelectionBaseNodeGetter(ExecState& state, JSDOMSelection& thisObject, ThrowScope& throwScope) |
| 335 | { |
| 336 | UNUSED_PARAM(throwScope); |
| 337 | UNUSED_PARAM(state); |
| 338 | auto& impl = thisObject.wrapped(); |
| 339 | JSValue result = toJS<IDLNullable<IDLInterface<Node>>>(state, *thisObject.globalObject(), throwScope, impl.baseNode()); |
| 340 | return result; |
| 341 | } |
| 342 | |
| 343 | EncodedJSValue jsDOMSelectionBaseNode(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 344 | { |
| 345 | return IDLAttribute<JSDOMSelection>::get<jsDOMSelectionBaseNodeGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "baseNode" ); |
| 346 | } |
| 347 | |
| 348 | static inline JSValue jsDOMSelectionBaseOffsetGetter(ExecState& state, JSDOMSelection& thisObject, ThrowScope& throwScope) |
| 349 | { |
| 350 | UNUSED_PARAM(throwScope); |
| 351 | UNUSED_PARAM(state); |
| 352 | auto& impl = thisObject.wrapped(); |
| 353 | JSValue result = toJS<IDLUnsignedLong>(state, throwScope, impl.baseOffset()); |
| 354 | return result; |
| 355 | } |
| 356 | |
| 357 | EncodedJSValue jsDOMSelectionBaseOffset(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 358 | { |
| 359 | return IDLAttribute<JSDOMSelection>::get<jsDOMSelectionBaseOffsetGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "baseOffset" ); |
| 360 | } |
| 361 | |
| 362 | static inline JSValue jsDOMSelectionExtentNodeGetter(ExecState& state, JSDOMSelection& thisObject, ThrowScope& throwScope) |
| 363 | { |
| 364 | UNUSED_PARAM(throwScope); |
| 365 | UNUSED_PARAM(state); |
| 366 | auto& impl = thisObject.wrapped(); |
| 367 | JSValue result = toJS<IDLNullable<IDLInterface<Node>>>(state, *thisObject.globalObject(), throwScope, impl.extentNode()); |
| 368 | return result; |
| 369 | } |
| 370 | |
| 371 | EncodedJSValue jsDOMSelectionExtentNode(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 372 | { |
| 373 | return IDLAttribute<JSDOMSelection>::get<jsDOMSelectionExtentNodeGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "extentNode" ); |
| 374 | } |
| 375 | |
| 376 | static inline JSValue jsDOMSelectionExtentOffsetGetter(ExecState& state, JSDOMSelection& thisObject, ThrowScope& throwScope) |
| 377 | { |
| 378 | UNUSED_PARAM(throwScope); |
| 379 | UNUSED_PARAM(state); |
| 380 | auto& impl = thisObject.wrapped(); |
| 381 | JSValue result = toJS<IDLUnsignedLong>(state, throwScope, impl.extentOffset()); |
| 382 | return result; |
| 383 | } |
| 384 | |
| 385 | EncodedJSValue jsDOMSelectionExtentOffset(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 386 | { |
| 387 | return IDLAttribute<JSDOMSelection>::get<jsDOMSelectionExtentOffsetGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "extentOffset" ); |
| 388 | } |
| 389 | |
| 390 | static inline JSC::EncodedJSValue jsDOMSelectionPrototypeFunctionCollapseBody(JSC::ExecState* state, typename IDLOperation<JSDOMSelection>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 391 | { |
| 392 | UNUSED_PARAM(state); |
| 393 | UNUSED_PARAM(throwScope); |
| 394 | auto& impl = castedThis->wrapped(); |
| 395 | if (UNLIKELY(state->argumentCount() < 1)) |
| 396 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| 397 | auto node = convert<IDLNullable<IDLInterface<Node>>>(*state, state->uncheckedArgument(0), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentTypeError(state, scope, 0, "node" , "Selection" , "collapse" , "Node" ); }); |
| 398 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 399 | auto offset = convert<IDLUnsignedLong>(*state, state->argument(1)); |
| 400 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 401 | impl.collapse(WTFMove(node), WTFMove(offset)); |
| 402 | return JSValue::encode(jsUndefined()); |
| 403 | } |
| 404 | |
| 405 | EncodedJSValue JSC_HOST_CALL jsDOMSelectionPrototypeFunctionCollapse(ExecState* state) |
| 406 | { |
| 407 | return IDLOperation<JSDOMSelection>::call<jsDOMSelectionPrototypeFunctionCollapseBody>(*state, "collapse" ); |
| 408 | } |
| 409 | |
| 410 | static inline JSC::EncodedJSValue jsDOMSelectionPrototypeFunctionCollapseToEndBody(JSC::ExecState* state, typename IDLOperation<JSDOMSelection>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 411 | { |
| 412 | UNUSED_PARAM(state); |
| 413 | UNUSED_PARAM(throwScope); |
| 414 | auto& impl = castedThis->wrapped(); |
| 415 | propagateException(*state, throwScope, impl.collapseToEnd()); |
| 416 | return JSValue::encode(jsUndefined()); |
| 417 | } |
| 418 | |
| 419 | EncodedJSValue JSC_HOST_CALL jsDOMSelectionPrototypeFunctionCollapseToEnd(ExecState* state) |
| 420 | { |
| 421 | return IDLOperation<JSDOMSelection>::call<jsDOMSelectionPrototypeFunctionCollapseToEndBody>(*state, "collapseToEnd" ); |
| 422 | } |
| 423 | |
| 424 | static inline JSC::EncodedJSValue jsDOMSelectionPrototypeFunctionCollapseToStartBody(JSC::ExecState* state, typename IDLOperation<JSDOMSelection>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 425 | { |
| 426 | UNUSED_PARAM(state); |
| 427 | UNUSED_PARAM(throwScope); |
| 428 | auto& impl = castedThis->wrapped(); |
| 429 | propagateException(*state, throwScope, impl.collapseToStart()); |
| 430 | return JSValue::encode(jsUndefined()); |
| 431 | } |
| 432 | |
| 433 | EncodedJSValue JSC_HOST_CALL jsDOMSelectionPrototypeFunctionCollapseToStart(ExecState* state) |
| 434 | { |
| 435 | return IDLOperation<JSDOMSelection>::call<jsDOMSelectionPrototypeFunctionCollapseToStartBody>(*state, "collapseToStart" ); |
| 436 | } |
| 437 | |
| 438 | static inline JSC::EncodedJSValue jsDOMSelectionPrototypeFunctionDeleteFromDocumentBody(JSC::ExecState* state, typename IDLOperation<JSDOMSelection>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 439 | { |
| 440 | UNUSED_PARAM(state); |
| 441 | UNUSED_PARAM(throwScope); |
| 442 | CustomElementReactionStack customElementReactionStack(*state); |
| 443 | auto& impl = castedThis->wrapped(); |
| 444 | impl.deleteFromDocument(); |
| 445 | return JSValue::encode(jsUndefined()); |
| 446 | } |
| 447 | |
| 448 | EncodedJSValue JSC_HOST_CALL jsDOMSelectionPrototypeFunctionDeleteFromDocument(ExecState* state) |
| 449 | { |
| 450 | return IDLOperation<JSDOMSelection>::call<jsDOMSelectionPrototypeFunctionDeleteFromDocumentBody>(*state, "deleteFromDocument" ); |
| 451 | } |
| 452 | |
| 453 | static inline JSC::EncodedJSValue jsDOMSelectionPrototypeFunctionContainsNodeBody(JSC::ExecState* state, typename IDLOperation<JSDOMSelection>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 454 | { |
| 455 | UNUSED_PARAM(state); |
| 456 | UNUSED_PARAM(throwScope); |
| 457 | auto& impl = castedThis->wrapped(); |
| 458 | if (UNLIKELY(state->argumentCount() < 1)) |
| 459 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| 460 | auto node = convert<IDLInterface<Node>>(*state, state->uncheckedArgument(0), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentTypeError(state, scope, 0, "node" , "Selection" , "containsNode" , "Node" ); }); |
| 461 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 462 | auto allowPartial = convert<IDLBoolean>(*state, state->argument(1)); |
| 463 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 464 | return JSValue::encode(toJS<IDLBoolean>(impl.containsNode(*node, WTFMove(allowPartial)))); |
| 465 | } |
| 466 | |
| 467 | EncodedJSValue JSC_HOST_CALL jsDOMSelectionPrototypeFunctionContainsNode(ExecState* state) |
| 468 | { |
| 469 | return IDLOperation<JSDOMSelection>::call<jsDOMSelectionPrototypeFunctionContainsNodeBody>(*state, "containsNode" ); |
| 470 | } |
| 471 | |
| 472 | static inline JSC::EncodedJSValue jsDOMSelectionPrototypeFunctionSelectAllChildrenBody(JSC::ExecState* state, typename IDLOperation<JSDOMSelection>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 473 | { |
| 474 | UNUSED_PARAM(state); |
| 475 | UNUSED_PARAM(throwScope); |
| 476 | auto& impl = castedThis->wrapped(); |
| 477 | if (UNLIKELY(state->argumentCount() < 1)) |
| 478 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| 479 | auto node = convert<IDLInterface<Node>>(*state, state->uncheckedArgument(0), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentTypeError(state, scope, 0, "node" , "Selection" , "selectAllChildren" , "Node" ); }); |
| 480 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 481 | impl.selectAllChildren(*node); |
| 482 | return JSValue::encode(jsUndefined()); |
| 483 | } |
| 484 | |
| 485 | EncodedJSValue JSC_HOST_CALL jsDOMSelectionPrototypeFunctionSelectAllChildren(ExecState* state) |
| 486 | { |
| 487 | return IDLOperation<JSDOMSelection>::call<jsDOMSelectionPrototypeFunctionSelectAllChildrenBody>(*state, "selectAllChildren" ); |
| 488 | } |
| 489 | |
| 490 | static inline JSC::EncodedJSValue jsDOMSelectionPrototypeFunctionExtendBody(JSC::ExecState* state, typename IDLOperation<JSDOMSelection>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 491 | { |
| 492 | UNUSED_PARAM(state); |
| 493 | UNUSED_PARAM(throwScope); |
| 494 | auto& impl = castedThis->wrapped(); |
| 495 | if (UNLIKELY(state->argumentCount() < 1)) |
| 496 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| 497 | auto node = convert<IDLInterface<Node>>(*state, state->uncheckedArgument(0), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentTypeError(state, scope, 0, "node" , "Selection" , "extend" , "Node" ); }); |
| 498 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 499 | auto offset = convert<IDLUnsignedLong>(*state, state->argument(1)); |
| 500 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 501 | propagateException(*state, throwScope, impl.extend(*node, WTFMove(offset))); |
| 502 | return JSValue::encode(jsUndefined()); |
| 503 | } |
| 504 | |
| 505 | EncodedJSValue JSC_HOST_CALL jsDOMSelectionPrototypeFunctionExtend(ExecState* state) |
| 506 | { |
| 507 | return IDLOperation<JSDOMSelection>::call<jsDOMSelectionPrototypeFunctionExtendBody>(*state, "extend" ); |
| 508 | } |
| 509 | |
| 510 | static inline JSC::EncodedJSValue jsDOMSelectionPrototypeFunctionGetRangeAtBody(JSC::ExecState* state, typename IDLOperation<JSDOMSelection>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 511 | { |
| 512 | UNUSED_PARAM(state); |
| 513 | UNUSED_PARAM(throwScope); |
| 514 | auto& impl = castedThis->wrapped(); |
| 515 | if (UNLIKELY(state->argumentCount() < 1)) |
| 516 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| 517 | auto index = convert<IDLUnsignedLong>(*state, state->uncheckedArgument(0)); |
| 518 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 519 | return JSValue::encode(toJS<IDLInterface<Range>>(*state, *castedThis->globalObject(), throwScope, impl.getRangeAt(WTFMove(index)))); |
| 520 | } |
| 521 | |
| 522 | EncodedJSValue JSC_HOST_CALL jsDOMSelectionPrototypeFunctionGetRangeAt(ExecState* state) |
| 523 | { |
| 524 | return IDLOperation<JSDOMSelection>::call<jsDOMSelectionPrototypeFunctionGetRangeAtBody>(*state, "getRangeAt" ); |
| 525 | } |
| 526 | |
| 527 | static inline JSC::EncodedJSValue jsDOMSelectionPrototypeFunctionRemoveAllRangesBody(JSC::ExecState* state, typename IDLOperation<JSDOMSelection>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 528 | { |
| 529 | UNUSED_PARAM(state); |
| 530 | UNUSED_PARAM(throwScope); |
| 531 | auto& impl = castedThis->wrapped(); |
| 532 | impl.removeAllRanges(); |
| 533 | return JSValue::encode(jsUndefined()); |
| 534 | } |
| 535 | |
| 536 | EncodedJSValue JSC_HOST_CALL jsDOMSelectionPrototypeFunctionRemoveAllRanges(ExecState* state) |
| 537 | { |
| 538 | return IDLOperation<JSDOMSelection>::call<jsDOMSelectionPrototypeFunctionRemoveAllRangesBody>(*state, "removeAllRanges" ); |
| 539 | } |
| 540 | |
| 541 | static inline JSC::EncodedJSValue jsDOMSelectionPrototypeFunctionAddRangeBody(JSC::ExecState* state, typename IDLOperation<JSDOMSelection>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 542 | { |
| 543 | UNUSED_PARAM(state); |
| 544 | UNUSED_PARAM(throwScope); |
| 545 | auto& impl = castedThis->wrapped(); |
| 546 | if (UNLIKELY(state->argumentCount() < 1)) |
| 547 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| 548 | auto range = convert<IDLInterface<Range>>(*state, state->uncheckedArgument(0), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentTypeError(state, scope, 0, "range" , "Selection" , "addRange" , "Range" ); }); |
| 549 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 550 | impl.addRange(*range); |
| 551 | return JSValue::encode(jsUndefined()); |
| 552 | } |
| 553 | |
| 554 | EncodedJSValue JSC_HOST_CALL jsDOMSelectionPrototypeFunctionAddRange(ExecState* state) |
| 555 | { |
| 556 | return IDLOperation<JSDOMSelection>::call<jsDOMSelectionPrototypeFunctionAddRangeBody>(*state, "addRange" ); |
| 557 | } |
| 558 | |
| 559 | static inline JSC::EncodedJSValue jsDOMSelectionPrototypeFunctionToStringBody(JSC::ExecState* state, typename IDLOperation<JSDOMSelection>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 560 | { |
| 561 | UNUSED_PARAM(state); |
| 562 | UNUSED_PARAM(throwScope); |
| 563 | auto& impl = castedThis->wrapped(); |
| 564 | return JSValue::encode(toJS<IDLDOMString>(*state, impl.toString())); |
| 565 | } |
| 566 | |
| 567 | EncodedJSValue JSC_HOST_CALL jsDOMSelectionPrototypeFunctionToString(ExecState* state) |
| 568 | { |
| 569 | return IDLOperation<JSDOMSelection>::call<jsDOMSelectionPrototypeFunctionToStringBody>(*state, "toString" ); |
| 570 | } |
| 571 | |
| 572 | static inline JSC::EncodedJSValue jsDOMSelectionPrototypeFunctionSetBaseAndExtentBody(JSC::ExecState* state, typename IDLOperation<JSDOMSelection>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 573 | { |
| 574 | UNUSED_PARAM(state); |
| 575 | UNUSED_PARAM(throwScope); |
| 576 | auto& impl = castedThis->wrapped(); |
| 577 | if (UNLIKELY(state->argumentCount() < 4)) |
| 578 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| 579 | auto baseNode = convert<IDLNullable<IDLInterface<Node>>>(*state, state->uncheckedArgument(0), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentTypeError(state, scope, 0, "baseNode" , "Selection" , "setBaseAndExtent" , "Node" ); }); |
| 580 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 581 | auto baseOffset = convert<IDLUnsignedLong>(*state, state->uncheckedArgument(1)); |
| 582 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 583 | auto extentNode = convert<IDLNullable<IDLInterface<Node>>>(*state, state->uncheckedArgument(2), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentTypeError(state, scope, 2, "extentNode" , "Selection" , "setBaseAndExtent" , "Node" ); }); |
| 584 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 585 | auto extentOffset = convert<IDLUnsignedLong>(*state, state->uncheckedArgument(3)); |
| 586 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 587 | impl.setBaseAndExtent(WTFMove(baseNode), WTFMove(baseOffset), WTFMove(extentNode), WTFMove(extentOffset)); |
| 588 | return JSValue::encode(jsUndefined()); |
| 589 | } |
| 590 | |
| 591 | EncodedJSValue JSC_HOST_CALL jsDOMSelectionPrototypeFunctionSetBaseAndExtent(ExecState* state) |
| 592 | { |
| 593 | return IDLOperation<JSDOMSelection>::call<jsDOMSelectionPrototypeFunctionSetBaseAndExtentBody>(*state, "setBaseAndExtent" ); |
| 594 | } |
| 595 | |
| 596 | static inline JSC::EncodedJSValue jsDOMSelectionPrototypeFunctionSetPositionBody(JSC::ExecState* state, typename IDLOperation<JSDOMSelection>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 597 | { |
| 598 | UNUSED_PARAM(state); |
| 599 | UNUSED_PARAM(throwScope); |
| 600 | auto& impl = castedThis->wrapped(); |
| 601 | if (UNLIKELY(state->argumentCount() < 1)) |
| 602 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| 603 | auto node = convert<IDLNullable<IDLInterface<Node>>>(*state, state->uncheckedArgument(0), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentTypeError(state, scope, 0, "node" , "Selection" , "setPosition" , "Node" ); }); |
| 604 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 605 | auto offset = convert<IDLUnsignedLong>(*state, state->argument(1)); |
| 606 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 607 | impl.setPosition(WTFMove(node), WTFMove(offset)); |
| 608 | return JSValue::encode(jsUndefined()); |
| 609 | } |
| 610 | |
| 611 | EncodedJSValue JSC_HOST_CALL jsDOMSelectionPrototypeFunctionSetPosition(ExecState* state) |
| 612 | { |
| 613 | return IDLOperation<JSDOMSelection>::call<jsDOMSelectionPrototypeFunctionSetPositionBody>(*state, "setPosition" ); |
| 614 | } |
| 615 | |
| 616 | static inline JSC::EncodedJSValue jsDOMSelectionPrototypeFunctionEmptyBody(JSC::ExecState* state, typename IDLOperation<JSDOMSelection>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 617 | { |
| 618 | UNUSED_PARAM(state); |
| 619 | UNUSED_PARAM(throwScope); |
| 620 | auto& impl = castedThis->wrapped(); |
| 621 | impl.empty(); |
| 622 | return JSValue::encode(jsUndefined()); |
| 623 | } |
| 624 | |
| 625 | EncodedJSValue JSC_HOST_CALL jsDOMSelectionPrototypeFunctionEmpty(ExecState* state) |
| 626 | { |
| 627 | return IDLOperation<JSDOMSelection>::call<jsDOMSelectionPrototypeFunctionEmptyBody>(*state, "empty" ); |
| 628 | } |
| 629 | |
| 630 | static inline JSC::EncodedJSValue jsDOMSelectionPrototypeFunctionModifyBody(JSC::ExecState* state, typename IDLOperation<JSDOMSelection>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 631 | { |
| 632 | UNUSED_PARAM(state); |
| 633 | UNUSED_PARAM(throwScope); |
| 634 | auto& impl = castedThis->wrapped(); |
| 635 | auto alter = convert<IDLDOMString>(*state, state->argument(0)); |
| 636 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 637 | auto direction = convert<IDLDOMString>(*state, state->argument(1)); |
| 638 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 639 | auto granularity = convert<IDLDOMString>(*state, state->argument(2)); |
| 640 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 641 | impl.modify(WTFMove(alter), WTFMove(direction), WTFMove(granularity)); |
| 642 | return JSValue::encode(jsUndefined()); |
| 643 | } |
| 644 | |
| 645 | EncodedJSValue JSC_HOST_CALL jsDOMSelectionPrototypeFunctionModify(ExecState* state) |
| 646 | { |
| 647 | return IDLOperation<JSDOMSelection>::call<jsDOMSelectionPrototypeFunctionModifyBody>(*state, "modify" ); |
| 648 | } |
| 649 | |
| 650 | void JSDOMSelection::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) |
| 651 | { |
| 652 | auto* thisObject = jsCast<JSDOMSelection*>(cell); |
| 653 | builder.setWrappedObjectForCell(cell, &thisObject->wrapped()); |
| 654 | if (thisObject->scriptExecutionContext()) |
| 655 | builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); |
| 656 | Base::heapSnapshot(cell, builder); |
| 657 | } |
| 658 | |
| 659 | bool JSDOMSelectionOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor, const char** reason) |
| 660 | { |
| 661 | auto* jsDOMSelection = jsCast<JSDOMSelection*>(handle.slot()->asCell()); |
| 662 | Frame* root = WTF::getPtr(jsDOMSelection->wrapped().frame()); |
| 663 | if (!root) |
| 664 | return false; |
| 665 | if (UNLIKELY(reason)) |
| 666 | *reason = "Reachable from Frame" ; |
| 667 | return visitor.containsOpaqueRoot(root); |
| 668 | } |
| 669 | |
| 670 | void JSDOMSelectionOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context) |
| 671 | { |
| 672 | auto* jsDOMSelection = static_cast<JSDOMSelection*>(handle.slot()->asCell()); |
| 673 | auto& world = *static_cast<DOMWrapperWorld*>(context); |
| 674 | uncacheWrapper(world, &jsDOMSelection->wrapped(), jsDOMSelection); |
| 675 | } |
| 676 | |
| 677 | JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<DOMSelection>&& impl) |
| 678 | { |
| 679 | // If you hit this failure the interface definition has the ImplementationLacksVTable |
| 680 | // attribute. You should remove that attribute. If the class has subclasses |
| 681 | // that may be passed through this toJS() function you should use the SkipVTableValidation |
| 682 | // attribute to DOMSelection. |
| 683 | static_assert(!std::is_polymorphic<DOMSelection>::value, "DOMSelection is polymorphic but the IDL claims it is not" ); |
| 684 | return createWrapper<DOMSelection>(globalObject, WTFMove(impl)); |
| 685 | } |
| 686 | |
| 687 | JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, DOMSelection& impl) |
| 688 | { |
| 689 | return wrap(state, globalObject, impl); |
| 690 | } |
| 691 | |
| 692 | DOMSelection* JSDOMSelection::toWrapped(JSC::VM& vm, JSC::JSValue value) |
| 693 | { |
| 694 | if (auto* wrapper = jsDynamicCast<JSDOMSelection*>(vm, value)) |
| 695 | return &wrapper->wrapped(); |
| 696 | return nullptr; |
| 697 | } |
| 698 | |
| 699 | } |
| 700 | |