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 "JSRange.h" |
23 | |
24 | #include "CustomElementReactionQueue.h" |
25 | #include "Document.h" |
26 | #include "JSDOMAttribute.h" |
27 | #include "JSDOMBinding.h" |
28 | #include "JSDOMConstructor.h" |
29 | #include "JSDOMConvertBoolean.h" |
30 | #include "JSDOMConvertInterface.h" |
31 | #include "JSDOMConvertNumbers.h" |
32 | #include "JSDOMConvertStrings.h" |
33 | #include "JSDOMExceptionHandling.h" |
34 | #include "JSDOMGlobalObject.h" |
35 | #include "JSDOMOperation.h" |
36 | #include "JSDOMRect.h" |
37 | #include "JSDOMRectList.h" |
38 | #include "JSDOMWrapperCache.h" |
39 | #include "JSDocumentFragment.h" |
40 | #include "JSNode.h" |
41 | #include "JSRange.h" |
42 | #include "ScriptExecutionContext.h" |
43 | #include <JavaScriptCore/FunctionPrototype.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 | // Functions |
55 | |
56 | JSC::EncodedJSValue JSC_HOST_CALL jsRangePrototypeFunctionSetStart(JSC::ExecState*); |
57 | JSC::EncodedJSValue JSC_HOST_CALL jsRangePrototypeFunctionSetEnd(JSC::ExecState*); |
58 | JSC::EncodedJSValue JSC_HOST_CALL jsRangePrototypeFunctionSetStartBefore(JSC::ExecState*); |
59 | JSC::EncodedJSValue JSC_HOST_CALL jsRangePrototypeFunctionSetStartAfter(JSC::ExecState*); |
60 | JSC::EncodedJSValue JSC_HOST_CALL jsRangePrototypeFunctionSetEndBefore(JSC::ExecState*); |
61 | JSC::EncodedJSValue JSC_HOST_CALL jsRangePrototypeFunctionSetEndAfter(JSC::ExecState*); |
62 | JSC::EncodedJSValue JSC_HOST_CALL jsRangePrototypeFunctionCollapse(JSC::ExecState*); |
63 | JSC::EncodedJSValue JSC_HOST_CALL jsRangePrototypeFunctionSelectNode(JSC::ExecState*); |
64 | JSC::EncodedJSValue JSC_HOST_CALL jsRangePrototypeFunctionSelectNodeContents(JSC::ExecState*); |
65 | JSC::EncodedJSValue JSC_HOST_CALL jsRangePrototypeFunctionCompareBoundaryPoints(JSC::ExecState*); |
66 | JSC::EncodedJSValue JSC_HOST_CALL jsRangePrototypeFunctionDeleteContents(JSC::ExecState*); |
67 | JSC::EncodedJSValue JSC_HOST_CALL jsRangePrototypeFunctionExtractContents(JSC::ExecState*); |
68 | JSC::EncodedJSValue JSC_HOST_CALL jsRangePrototypeFunctionCloneContents(JSC::ExecState*); |
69 | JSC::EncodedJSValue JSC_HOST_CALL jsRangePrototypeFunctionInsertNode(JSC::ExecState*); |
70 | JSC::EncodedJSValue JSC_HOST_CALL jsRangePrototypeFunctionSurroundContents(JSC::ExecState*); |
71 | JSC::EncodedJSValue JSC_HOST_CALL jsRangePrototypeFunctionCloneRange(JSC::ExecState*); |
72 | JSC::EncodedJSValue JSC_HOST_CALL jsRangePrototypeFunctionDetach(JSC::ExecState*); |
73 | JSC::EncodedJSValue JSC_HOST_CALL jsRangePrototypeFunctionIsPointInRange(JSC::ExecState*); |
74 | JSC::EncodedJSValue JSC_HOST_CALL jsRangePrototypeFunctionComparePoint(JSC::ExecState*); |
75 | JSC::EncodedJSValue JSC_HOST_CALL jsRangePrototypeFunctionIntersectsNode(JSC::ExecState*); |
76 | JSC::EncodedJSValue JSC_HOST_CALL jsRangePrototypeFunctionGetClientRects(JSC::ExecState*); |
77 | JSC::EncodedJSValue JSC_HOST_CALL jsRangePrototypeFunctionGetBoundingClientRect(JSC::ExecState*); |
78 | JSC::EncodedJSValue JSC_HOST_CALL jsRangePrototypeFunctionCreateContextualFragment(JSC::ExecState*); |
79 | JSC::EncodedJSValue JSC_HOST_CALL jsRangePrototypeFunctionExpand(JSC::ExecState*); |
80 | JSC::EncodedJSValue JSC_HOST_CALL jsRangePrototypeFunctionCompareNode(JSC::ExecState*); |
81 | JSC::EncodedJSValue JSC_HOST_CALL jsRangePrototypeFunctionToString(JSC::ExecState*); |
82 | |
83 | // Attributes |
84 | |
85 | JSC::EncodedJSValue jsRangeConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
86 | bool setJSRangeConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
87 | JSC::EncodedJSValue jsRangeStartContainer(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
88 | JSC::EncodedJSValue jsRangeStartOffset(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
89 | JSC::EncodedJSValue jsRangeEndContainer(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
90 | JSC::EncodedJSValue jsRangeEndOffset(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
91 | JSC::EncodedJSValue jsRangeCollapsed(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
92 | JSC::EncodedJSValue jsRangeCommonAncestorContainer(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
93 | |
94 | class JSRangePrototype : public JSC::JSNonFinalObject { |
95 | public: |
96 | using Base = JSC::JSNonFinalObject; |
97 | static JSRangePrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
98 | { |
99 | JSRangePrototype* ptr = new (NotNull, JSC::allocateCell<JSRangePrototype>(vm.heap)) JSRangePrototype(vm, globalObject, structure); |
100 | ptr->finishCreation(vm); |
101 | return ptr; |
102 | } |
103 | |
104 | DECLARE_INFO; |
105 | static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) |
106 | { |
107 | return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); |
108 | } |
109 | |
110 | private: |
111 | JSRangePrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
112 | : JSC::JSNonFinalObject(vm, structure) |
113 | { |
114 | } |
115 | |
116 | void finishCreation(JSC::VM&); |
117 | }; |
118 | |
119 | using JSRangeConstructor = JSDOMConstructor<JSRange>; |
120 | |
121 | /* Hash table for constructor */ |
122 | |
123 | static const HashTableValue JSRangeConstructorTableValues[] = |
124 | { |
125 | { "START_TO_START" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(0) } }, |
126 | { "START_TO_END" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(1) } }, |
127 | { "END_TO_END" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(2) } }, |
128 | { "END_TO_START" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(3) } }, |
129 | { "NODE_BEFORE" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(0) } }, |
130 | { "NODE_AFTER" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(1) } }, |
131 | { "NODE_BEFORE_AND_AFTER" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(2) } }, |
132 | { "NODE_INSIDE" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(3) } }, |
133 | }; |
134 | |
135 | static_assert(Range::START_TO_START == 0, "START_TO_START in Range does not match value from IDL" ); |
136 | static_assert(Range::START_TO_END == 1, "START_TO_END in Range does not match value from IDL" ); |
137 | static_assert(Range::END_TO_END == 2, "END_TO_END in Range does not match value from IDL" ); |
138 | static_assert(Range::END_TO_START == 3, "END_TO_START in Range does not match value from IDL" ); |
139 | static_assert(Range::NODE_BEFORE == 0, "NODE_BEFORE in Range does not match value from IDL" ); |
140 | static_assert(Range::NODE_AFTER == 1, "NODE_AFTER in Range does not match value from IDL" ); |
141 | static_assert(Range::NODE_BEFORE_AND_AFTER == 2, "NODE_BEFORE_AND_AFTER in Range does not match value from IDL" ); |
142 | static_assert(Range::NODE_INSIDE == 3, "NODE_INSIDE in Range does not match value from IDL" ); |
143 | |
144 | template<> EncodedJSValue JSC_HOST_CALL JSRangeConstructor::construct(ExecState* state) |
145 | { |
146 | VM& vm = state->vm(); |
147 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
148 | UNUSED_PARAM(throwScope); |
149 | auto* castedThis = jsCast<JSRangeConstructor*>(state->jsCallee()); |
150 | ASSERT(castedThis); |
151 | auto* context = castedThis->scriptExecutionContext(); |
152 | if (UNLIKELY(!context)) |
153 | return throwConstructorScriptExecutionContextUnavailableError(*state, throwScope, "Range" ); |
154 | ASSERT(context->isDocument()); |
155 | auto& document = downcast<Document>(*context); |
156 | auto object = Range::create(document); |
157 | return JSValue::encode(toJSNewlyCreated<IDLInterface<Range>>(*state, *castedThis->globalObject(), WTFMove(object))); |
158 | } |
159 | |
160 | template<> JSValue JSRangeConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
161 | { |
162 | UNUSED_PARAM(vm); |
163 | return globalObject.functionPrototype(); |
164 | } |
165 | |
166 | template<> void JSRangeConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
167 | { |
168 | putDirect(vm, vm.propertyNames->prototype, JSRange::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
169 | putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("Range"_s )), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
170 | putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
171 | reifyStaticProperties(vm, JSRange::info(), JSRangeConstructorTableValues, *this); |
172 | } |
173 | |
174 | template<> const ClassInfo JSRangeConstructor::s_info = { "Range" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSRangeConstructor) }; |
175 | |
176 | /* Hash table for prototype */ |
177 | |
178 | static const HashTableValue JSRangePrototypeTableValues[] = |
179 | { |
180 | { "constructor" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRangeConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSRangeConstructor) } }, |
181 | { "startContainer" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRangeStartContainer), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
182 | { "startOffset" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRangeStartOffset), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
183 | { "endContainer" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRangeEndContainer), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
184 | { "endOffset" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRangeEndOffset), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
185 | { "collapsed" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRangeCollapsed), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
186 | { "commonAncestorContainer" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRangeCommonAncestorContainer), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
187 | { "setStart" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsRangePrototypeFunctionSetStart), (intptr_t) (2) } }, |
188 | { "setEnd" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsRangePrototypeFunctionSetEnd), (intptr_t) (2) } }, |
189 | { "setStartBefore" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsRangePrototypeFunctionSetStartBefore), (intptr_t) (1) } }, |
190 | { "setStartAfter" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsRangePrototypeFunctionSetStartAfter), (intptr_t) (1) } }, |
191 | { "setEndBefore" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsRangePrototypeFunctionSetEndBefore), (intptr_t) (1) } }, |
192 | { "setEndAfter" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsRangePrototypeFunctionSetEndAfter), (intptr_t) (1) } }, |
193 | { "collapse" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsRangePrototypeFunctionCollapse), (intptr_t) (0) } }, |
194 | { "selectNode" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsRangePrototypeFunctionSelectNode), (intptr_t) (1) } }, |
195 | { "selectNodeContents" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsRangePrototypeFunctionSelectNodeContents), (intptr_t) (1) } }, |
196 | { "compareBoundaryPoints" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsRangePrototypeFunctionCompareBoundaryPoints), (intptr_t) (2) } }, |
197 | { "deleteContents" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsRangePrototypeFunctionDeleteContents), (intptr_t) (0) } }, |
198 | { "extractContents" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsRangePrototypeFunctionExtractContents), (intptr_t) (0) } }, |
199 | { "cloneContents" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsRangePrototypeFunctionCloneContents), (intptr_t) (0) } }, |
200 | { "insertNode" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsRangePrototypeFunctionInsertNode), (intptr_t) (1) } }, |
201 | { "surroundContents" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsRangePrototypeFunctionSurroundContents), (intptr_t) (1) } }, |
202 | { "cloneRange" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsRangePrototypeFunctionCloneRange), (intptr_t) (0) } }, |
203 | { "detach" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsRangePrototypeFunctionDetach), (intptr_t) (0) } }, |
204 | { "isPointInRange" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsRangePrototypeFunctionIsPointInRange), (intptr_t) (2) } }, |
205 | { "comparePoint" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsRangePrototypeFunctionComparePoint), (intptr_t) (2) } }, |
206 | { "intersectsNode" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsRangePrototypeFunctionIntersectsNode), (intptr_t) (1) } }, |
207 | { "getClientRects" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsRangePrototypeFunctionGetClientRects), (intptr_t) (0) } }, |
208 | { "getBoundingClientRect" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsRangePrototypeFunctionGetBoundingClientRect), (intptr_t) (0) } }, |
209 | { "createContextualFragment" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsRangePrototypeFunctionCreateContextualFragment), (intptr_t) (1) } }, |
210 | { "expand" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsRangePrototypeFunctionExpand), (intptr_t) (0) } }, |
211 | { "compareNode" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsRangePrototypeFunctionCompareNode), (intptr_t) (1) } }, |
212 | { "toString" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsRangePrototypeFunctionToString), (intptr_t) (0) } }, |
213 | { "START_TO_START" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(0) } }, |
214 | { "START_TO_END" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(1) } }, |
215 | { "END_TO_END" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(2) } }, |
216 | { "END_TO_START" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(3) } }, |
217 | { "NODE_BEFORE" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(0) } }, |
218 | { "NODE_AFTER" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(1) } }, |
219 | { "NODE_BEFORE_AND_AFTER" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(2) } }, |
220 | { "NODE_INSIDE" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(3) } }, |
221 | }; |
222 | |
223 | const ClassInfo JSRangePrototype::s_info = { "RangePrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSRangePrototype) }; |
224 | |
225 | void JSRangePrototype::finishCreation(VM& vm) |
226 | { |
227 | Base::finishCreation(vm); |
228 | reifyStaticProperties(vm, JSRange::info(), JSRangePrototypeTableValues, *this); |
229 | } |
230 | |
231 | const ClassInfo JSRange::s_info = { "Range" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSRange) }; |
232 | |
233 | JSRange::JSRange(Structure* structure, JSDOMGlobalObject& globalObject, Ref<Range>&& impl) |
234 | : JSDOMWrapper<Range>(structure, globalObject, WTFMove(impl)) |
235 | { |
236 | } |
237 | |
238 | void JSRange::finishCreation(VM& vm) |
239 | { |
240 | Base::finishCreation(vm); |
241 | ASSERT(inherits(vm, info())); |
242 | |
243 | } |
244 | |
245 | JSObject* JSRange::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
246 | { |
247 | return JSRangePrototype::create(vm, &globalObject, JSRangePrototype::createStructure(vm, &globalObject, globalObject.objectPrototype())); |
248 | } |
249 | |
250 | JSObject* JSRange::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
251 | { |
252 | return getDOMPrototype<JSRange>(vm, globalObject); |
253 | } |
254 | |
255 | JSValue JSRange::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
256 | { |
257 | return getDOMConstructor<JSRangeConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
258 | } |
259 | |
260 | void JSRange::destroy(JSC::JSCell* cell) |
261 | { |
262 | JSRange* thisObject = static_cast<JSRange*>(cell); |
263 | thisObject->JSRange::~JSRange(); |
264 | } |
265 | |
266 | template<> inline JSRange* IDLAttribute<JSRange>::cast(ExecState& state, EncodedJSValue thisValue) |
267 | { |
268 | return jsDynamicCast<JSRange*>(state.vm(), JSValue::decode(thisValue)); |
269 | } |
270 | |
271 | template<> inline JSRange* IDLOperation<JSRange>::cast(ExecState& state) |
272 | { |
273 | return jsDynamicCast<JSRange*>(state.vm(), state.thisValue()); |
274 | } |
275 | |
276 | EncodedJSValue jsRangeConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
277 | { |
278 | VM& vm = state->vm(); |
279 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
280 | auto* prototype = jsDynamicCast<JSRangePrototype*>(vm, JSValue::decode(thisValue)); |
281 | if (UNLIKELY(!prototype)) |
282 | return throwVMTypeError(state, throwScope); |
283 | return JSValue::encode(JSRange::getConstructor(state->vm(), prototype->globalObject())); |
284 | } |
285 | |
286 | bool setJSRangeConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
287 | { |
288 | VM& vm = state->vm(); |
289 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
290 | auto* prototype = jsDynamicCast<JSRangePrototype*>(vm, JSValue::decode(thisValue)); |
291 | if (UNLIKELY(!prototype)) { |
292 | throwVMTypeError(state, throwScope); |
293 | return false; |
294 | } |
295 | // Shadowing a built-in constructor |
296 | return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue)); |
297 | } |
298 | |
299 | static inline JSValue jsRangeStartContainerGetter(ExecState& state, JSRange& thisObject, ThrowScope& throwScope) |
300 | { |
301 | UNUSED_PARAM(throwScope); |
302 | UNUSED_PARAM(state); |
303 | auto& impl = thisObject.wrapped(); |
304 | JSValue result = toJS<IDLInterface<Node>>(state, *thisObject.globalObject(), throwScope, impl.startContainer()); |
305 | return result; |
306 | } |
307 | |
308 | EncodedJSValue jsRangeStartContainer(ExecState* state, EncodedJSValue thisValue, PropertyName) |
309 | { |
310 | return IDLAttribute<JSRange>::get<jsRangeStartContainerGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "startContainer" ); |
311 | } |
312 | |
313 | static inline JSValue jsRangeStartOffsetGetter(ExecState& state, JSRange& thisObject, ThrowScope& throwScope) |
314 | { |
315 | UNUSED_PARAM(throwScope); |
316 | UNUSED_PARAM(state); |
317 | auto& impl = thisObject.wrapped(); |
318 | JSValue result = toJS<IDLLong>(state, throwScope, impl.startOffset()); |
319 | return result; |
320 | } |
321 | |
322 | EncodedJSValue jsRangeStartOffset(ExecState* state, EncodedJSValue thisValue, PropertyName) |
323 | { |
324 | return IDLAttribute<JSRange>::get<jsRangeStartOffsetGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "startOffset" ); |
325 | } |
326 | |
327 | static inline JSValue jsRangeEndContainerGetter(ExecState& state, JSRange& thisObject, ThrowScope& throwScope) |
328 | { |
329 | UNUSED_PARAM(throwScope); |
330 | UNUSED_PARAM(state); |
331 | auto& impl = thisObject.wrapped(); |
332 | JSValue result = toJS<IDLInterface<Node>>(state, *thisObject.globalObject(), throwScope, impl.endContainer()); |
333 | return result; |
334 | } |
335 | |
336 | EncodedJSValue jsRangeEndContainer(ExecState* state, EncodedJSValue thisValue, PropertyName) |
337 | { |
338 | return IDLAttribute<JSRange>::get<jsRangeEndContainerGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "endContainer" ); |
339 | } |
340 | |
341 | static inline JSValue jsRangeEndOffsetGetter(ExecState& state, JSRange& thisObject, ThrowScope& throwScope) |
342 | { |
343 | UNUSED_PARAM(throwScope); |
344 | UNUSED_PARAM(state); |
345 | auto& impl = thisObject.wrapped(); |
346 | JSValue result = toJS<IDLLong>(state, throwScope, impl.endOffset()); |
347 | return result; |
348 | } |
349 | |
350 | EncodedJSValue jsRangeEndOffset(ExecState* state, EncodedJSValue thisValue, PropertyName) |
351 | { |
352 | return IDLAttribute<JSRange>::get<jsRangeEndOffsetGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "endOffset" ); |
353 | } |
354 | |
355 | static inline JSValue jsRangeCollapsedGetter(ExecState& state, JSRange& thisObject, ThrowScope& throwScope) |
356 | { |
357 | UNUSED_PARAM(throwScope); |
358 | UNUSED_PARAM(state); |
359 | auto& impl = thisObject.wrapped(); |
360 | JSValue result = toJS<IDLBoolean>(state, throwScope, impl.collapsed()); |
361 | return result; |
362 | } |
363 | |
364 | EncodedJSValue jsRangeCollapsed(ExecState* state, EncodedJSValue thisValue, PropertyName) |
365 | { |
366 | return IDLAttribute<JSRange>::get<jsRangeCollapsedGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "collapsed" ); |
367 | } |
368 | |
369 | static inline JSValue jsRangeCommonAncestorContainerGetter(ExecState& state, JSRange& thisObject, ThrowScope& throwScope) |
370 | { |
371 | UNUSED_PARAM(throwScope); |
372 | UNUSED_PARAM(state); |
373 | auto& impl = thisObject.wrapped(); |
374 | JSValue result = toJS<IDLInterface<Node>>(state, *thisObject.globalObject(), throwScope, impl.commonAncestorContainer()); |
375 | return result; |
376 | } |
377 | |
378 | EncodedJSValue jsRangeCommonAncestorContainer(ExecState* state, EncodedJSValue thisValue, PropertyName) |
379 | { |
380 | return IDLAttribute<JSRange>::get<jsRangeCommonAncestorContainerGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "commonAncestorContainer" ); |
381 | } |
382 | |
383 | static inline JSC::EncodedJSValue jsRangePrototypeFunctionSetStartBody(JSC::ExecState* state, typename IDLOperation<JSRange>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
384 | { |
385 | UNUSED_PARAM(state); |
386 | UNUSED_PARAM(throwScope); |
387 | auto& impl = castedThis->wrapped(); |
388 | if (UNLIKELY(state->argumentCount() < 2)) |
389 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
390 | auto node = convert<IDLInterface<Node>>(*state, state->uncheckedArgument(0), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentTypeError(state, scope, 0, "node" , "Range" , "setStart" , "Node" ); }); |
391 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
392 | auto offset = convert<IDLUnsignedLong>(*state, state->uncheckedArgument(1)); |
393 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
394 | propagateException(*state, throwScope, impl.setStart(*node, WTFMove(offset))); |
395 | return JSValue::encode(jsUndefined()); |
396 | } |
397 | |
398 | EncodedJSValue JSC_HOST_CALL jsRangePrototypeFunctionSetStart(ExecState* state) |
399 | { |
400 | return IDLOperation<JSRange>::call<jsRangePrototypeFunctionSetStartBody>(*state, "setStart" ); |
401 | } |
402 | |
403 | static inline JSC::EncodedJSValue jsRangePrototypeFunctionSetEndBody(JSC::ExecState* state, typename IDLOperation<JSRange>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
404 | { |
405 | UNUSED_PARAM(state); |
406 | UNUSED_PARAM(throwScope); |
407 | auto& impl = castedThis->wrapped(); |
408 | if (UNLIKELY(state->argumentCount() < 2)) |
409 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
410 | auto node = convert<IDLInterface<Node>>(*state, state->uncheckedArgument(0), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentTypeError(state, scope, 0, "node" , "Range" , "setEnd" , "Node" ); }); |
411 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
412 | auto offset = convert<IDLUnsignedLong>(*state, state->uncheckedArgument(1)); |
413 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
414 | propagateException(*state, throwScope, impl.setEnd(*node, WTFMove(offset))); |
415 | return JSValue::encode(jsUndefined()); |
416 | } |
417 | |
418 | EncodedJSValue JSC_HOST_CALL jsRangePrototypeFunctionSetEnd(ExecState* state) |
419 | { |
420 | return IDLOperation<JSRange>::call<jsRangePrototypeFunctionSetEndBody>(*state, "setEnd" ); |
421 | } |
422 | |
423 | static inline JSC::EncodedJSValue jsRangePrototypeFunctionSetStartBeforeBody(JSC::ExecState* state, typename IDLOperation<JSRange>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
424 | { |
425 | UNUSED_PARAM(state); |
426 | UNUSED_PARAM(throwScope); |
427 | auto& impl = castedThis->wrapped(); |
428 | if (UNLIKELY(state->argumentCount() < 1)) |
429 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
430 | auto node = convert<IDLInterface<Node>>(*state, state->uncheckedArgument(0), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentTypeError(state, scope, 0, "node" , "Range" , "setStartBefore" , "Node" ); }); |
431 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
432 | propagateException(*state, throwScope, impl.setStartBefore(*node)); |
433 | return JSValue::encode(jsUndefined()); |
434 | } |
435 | |
436 | EncodedJSValue JSC_HOST_CALL jsRangePrototypeFunctionSetStartBefore(ExecState* state) |
437 | { |
438 | return IDLOperation<JSRange>::call<jsRangePrototypeFunctionSetStartBeforeBody>(*state, "setStartBefore" ); |
439 | } |
440 | |
441 | static inline JSC::EncodedJSValue jsRangePrototypeFunctionSetStartAfterBody(JSC::ExecState* state, typename IDLOperation<JSRange>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
442 | { |
443 | UNUSED_PARAM(state); |
444 | UNUSED_PARAM(throwScope); |
445 | auto& impl = castedThis->wrapped(); |
446 | if (UNLIKELY(state->argumentCount() < 1)) |
447 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
448 | auto node = convert<IDLInterface<Node>>(*state, state->uncheckedArgument(0), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentTypeError(state, scope, 0, "node" , "Range" , "setStartAfter" , "Node" ); }); |
449 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
450 | propagateException(*state, throwScope, impl.setStartAfter(*node)); |
451 | return JSValue::encode(jsUndefined()); |
452 | } |
453 | |
454 | EncodedJSValue JSC_HOST_CALL jsRangePrototypeFunctionSetStartAfter(ExecState* state) |
455 | { |
456 | return IDLOperation<JSRange>::call<jsRangePrototypeFunctionSetStartAfterBody>(*state, "setStartAfter" ); |
457 | } |
458 | |
459 | static inline JSC::EncodedJSValue jsRangePrototypeFunctionSetEndBeforeBody(JSC::ExecState* state, typename IDLOperation<JSRange>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
460 | { |
461 | UNUSED_PARAM(state); |
462 | UNUSED_PARAM(throwScope); |
463 | auto& impl = castedThis->wrapped(); |
464 | if (UNLIKELY(state->argumentCount() < 1)) |
465 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
466 | auto node = convert<IDLInterface<Node>>(*state, state->uncheckedArgument(0), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentTypeError(state, scope, 0, "node" , "Range" , "setEndBefore" , "Node" ); }); |
467 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
468 | propagateException(*state, throwScope, impl.setEndBefore(*node)); |
469 | return JSValue::encode(jsUndefined()); |
470 | } |
471 | |
472 | EncodedJSValue JSC_HOST_CALL jsRangePrototypeFunctionSetEndBefore(ExecState* state) |
473 | { |
474 | return IDLOperation<JSRange>::call<jsRangePrototypeFunctionSetEndBeforeBody>(*state, "setEndBefore" ); |
475 | } |
476 | |
477 | static inline JSC::EncodedJSValue jsRangePrototypeFunctionSetEndAfterBody(JSC::ExecState* state, typename IDLOperation<JSRange>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
478 | { |
479 | UNUSED_PARAM(state); |
480 | UNUSED_PARAM(throwScope); |
481 | auto& impl = castedThis->wrapped(); |
482 | if (UNLIKELY(state->argumentCount() < 1)) |
483 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
484 | auto node = convert<IDLInterface<Node>>(*state, state->uncheckedArgument(0), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentTypeError(state, scope, 0, "node" , "Range" , "setEndAfter" , "Node" ); }); |
485 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
486 | propagateException(*state, throwScope, impl.setEndAfter(*node)); |
487 | return JSValue::encode(jsUndefined()); |
488 | } |
489 | |
490 | EncodedJSValue JSC_HOST_CALL jsRangePrototypeFunctionSetEndAfter(ExecState* state) |
491 | { |
492 | return IDLOperation<JSRange>::call<jsRangePrototypeFunctionSetEndAfterBody>(*state, "setEndAfter" ); |
493 | } |
494 | |
495 | static inline JSC::EncodedJSValue jsRangePrototypeFunctionCollapseBody(JSC::ExecState* state, typename IDLOperation<JSRange>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
496 | { |
497 | UNUSED_PARAM(state); |
498 | UNUSED_PARAM(throwScope); |
499 | auto& impl = castedThis->wrapped(); |
500 | auto toStart = convert<IDLBoolean>(*state, state->argument(0)); |
501 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
502 | impl.collapse(WTFMove(toStart)); |
503 | return JSValue::encode(jsUndefined()); |
504 | } |
505 | |
506 | EncodedJSValue JSC_HOST_CALL jsRangePrototypeFunctionCollapse(ExecState* state) |
507 | { |
508 | return IDLOperation<JSRange>::call<jsRangePrototypeFunctionCollapseBody>(*state, "collapse" ); |
509 | } |
510 | |
511 | static inline JSC::EncodedJSValue jsRangePrototypeFunctionSelectNodeBody(JSC::ExecState* state, typename IDLOperation<JSRange>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
512 | { |
513 | UNUSED_PARAM(state); |
514 | UNUSED_PARAM(throwScope); |
515 | auto& impl = castedThis->wrapped(); |
516 | if (UNLIKELY(state->argumentCount() < 1)) |
517 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
518 | auto node = convert<IDLInterface<Node>>(*state, state->uncheckedArgument(0), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentTypeError(state, scope, 0, "node" , "Range" , "selectNode" , "Node" ); }); |
519 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
520 | propagateException(*state, throwScope, impl.selectNode(*node)); |
521 | return JSValue::encode(jsUndefined()); |
522 | } |
523 | |
524 | EncodedJSValue JSC_HOST_CALL jsRangePrototypeFunctionSelectNode(ExecState* state) |
525 | { |
526 | return IDLOperation<JSRange>::call<jsRangePrototypeFunctionSelectNodeBody>(*state, "selectNode" ); |
527 | } |
528 | |
529 | static inline JSC::EncodedJSValue jsRangePrototypeFunctionSelectNodeContentsBody(JSC::ExecState* state, typename IDLOperation<JSRange>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
530 | { |
531 | UNUSED_PARAM(state); |
532 | UNUSED_PARAM(throwScope); |
533 | auto& impl = castedThis->wrapped(); |
534 | if (UNLIKELY(state->argumentCount() < 1)) |
535 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
536 | auto node = convert<IDLInterface<Node>>(*state, state->uncheckedArgument(0), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentTypeError(state, scope, 0, "node" , "Range" , "selectNodeContents" , "Node" ); }); |
537 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
538 | propagateException(*state, throwScope, impl.selectNodeContents(*node)); |
539 | return JSValue::encode(jsUndefined()); |
540 | } |
541 | |
542 | EncodedJSValue JSC_HOST_CALL jsRangePrototypeFunctionSelectNodeContents(ExecState* state) |
543 | { |
544 | return IDLOperation<JSRange>::call<jsRangePrototypeFunctionSelectNodeContentsBody>(*state, "selectNodeContents" ); |
545 | } |
546 | |
547 | static inline JSC::EncodedJSValue jsRangePrototypeFunctionCompareBoundaryPointsBody(JSC::ExecState* state, typename IDLOperation<JSRange>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
548 | { |
549 | UNUSED_PARAM(state); |
550 | UNUSED_PARAM(throwScope); |
551 | auto& impl = castedThis->wrapped(); |
552 | if (UNLIKELY(state->argumentCount() < 2)) |
553 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
554 | auto how = convert<IDLUnsignedShort>(*state, state->uncheckedArgument(0)); |
555 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
556 | auto sourceRange = convert<IDLInterface<Range>>(*state, state->uncheckedArgument(1), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentTypeError(state, scope, 1, "sourceRange" , "Range" , "compareBoundaryPoints" , "Range" ); }); |
557 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
558 | return JSValue::encode(toJS<IDLShort>(*state, throwScope, impl.compareBoundaryPointsForBindings(WTFMove(how), *sourceRange))); |
559 | } |
560 | |
561 | EncodedJSValue JSC_HOST_CALL jsRangePrototypeFunctionCompareBoundaryPoints(ExecState* state) |
562 | { |
563 | return IDLOperation<JSRange>::call<jsRangePrototypeFunctionCompareBoundaryPointsBody>(*state, "compareBoundaryPoints" ); |
564 | } |
565 | |
566 | static inline JSC::EncodedJSValue jsRangePrototypeFunctionDeleteContentsBody(JSC::ExecState* state, typename IDLOperation<JSRange>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
567 | { |
568 | UNUSED_PARAM(state); |
569 | UNUSED_PARAM(throwScope); |
570 | CustomElementReactionStack customElementReactionStack(*state); |
571 | auto& impl = castedThis->wrapped(); |
572 | propagateException(*state, throwScope, impl.deleteContents()); |
573 | return JSValue::encode(jsUndefined()); |
574 | } |
575 | |
576 | EncodedJSValue JSC_HOST_CALL jsRangePrototypeFunctionDeleteContents(ExecState* state) |
577 | { |
578 | return IDLOperation<JSRange>::call<jsRangePrototypeFunctionDeleteContentsBody>(*state, "deleteContents" ); |
579 | } |
580 | |
581 | static inline JSC::EncodedJSValue jsRangePrototypeFunctionExtractContentsBody(JSC::ExecState* state, typename IDLOperation<JSRange>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
582 | { |
583 | UNUSED_PARAM(state); |
584 | UNUSED_PARAM(throwScope); |
585 | CustomElementReactionStack customElementReactionStack(*state); |
586 | auto& impl = castedThis->wrapped(); |
587 | return JSValue::encode(toJSNewlyCreated<IDLInterface<DocumentFragment>>(*state, *castedThis->globalObject(), throwScope, impl.extractContents())); |
588 | } |
589 | |
590 | EncodedJSValue JSC_HOST_CALL (ExecState* state) |
591 | { |
592 | return IDLOperation<JSRange>::call<jsRangePrototypeFunctionExtractContentsBody>(*state, "extractContents" ); |
593 | } |
594 | |
595 | static inline JSC::EncodedJSValue jsRangePrototypeFunctionCloneContentsBody(JSC::ExecState* state, typename IDLOperation<JSRange>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
596 | { |
597 | UNUSED_PARAM(state); |
598 | UNUSED_PARAM(throwScope); |
599 | CustomElementReactionStack customElementReactionStack(*state); |
600 | auto& impl = castedThis->wrapped(); |
601 | return JSValue::encode(toJSNewlyCreated<IDLInterface<DocumentFragment>>(*state, *castedThis->globalObject(), throwScope, impl.cloneContents())); |
602 | } |
603 | |
604 | EncodedJSValue JSC_HOST_CALL jsRangePrototypeFunctionCloneContents(ExecState* state) |
605 | { |
606 | return IDLOperation<JSRange>::call<jsRangePrototypeFunctionCloneContentsBody>(*state, "cloneContents" ); |
607 | } |
608 | |
609 | static inline JSC::EncodedJSValue jsRangePrototypeFunctionInsertNodeBody(JSC::ExecState* state, typename IDLOperation<JSRange>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
610 | { |
611 | UNUSED_PARAM(state); |
612 | UNUSED_PARAM(throwScope); |
613 | CustomElementReactionStack customElementReactionStack(*state); |
614 | auto& impl = castedThis->wrapped(); |
615 | if (UNLIKELY(state->argumentCount() < 1)) |
616 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
617 | auto node = convert<IDLInterface<Node>>(*state, state->uncheckedArgument(0), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentTypeError(state, scope, 0, "node" , "Range" , "insertNode" , "Node" ); }); |
618 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
619 | propagateException(*state, throwScope, impl.insertNode(*node)); |
620 | return JSValue::encode(jsUndefined()); |
621 | } |
622 | |
623 | EncodedJSValue JSC_HOST_CALL jsRangePrototypeFunctionInsertNode(ExecState* state) |
624 | { |
625 | return IDLOperation<JSRange>::call<jsRangePrototypeFunctionInsertNodeBody>(*state, "insertNode" ); |
626 | } |
627 | |
628 | static inline JSC::EncodedJSValue jsRangePrototypeFunctionSurroundContentsBody(JSC::ExecState* state, typename IDLOperation<JSRange>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
629 | { |
630 | UNUSED_PARAM(state); |
631 | UNUSED_PARAM(throwScope); |
632 | CustomElementReactionStack customElementReactionStack(*state); |
633 | auto& impl = castedThis->wrapped(); |
634 | if (UNLIKELY(state->argumentCount() < 1)) |
635 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
636 | auto newParent = convert<IDLInterface<Node>>(*state, state->uncheckedArgument(0), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentTypeError(state, scope, 0, "newParent" , "Range" , "surroundContents" , "Node" ); }); |
637 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
638 | propagateException(*state, throwScope, impl.surroundContents(*newParent)); |
639 | return JSValue::encode(jsUndefined()); |
640 | } |
641 | |
642 | EncodedJSValue JSC_HOST_CALL jsRangePrototypeFunctionSurroundContents(ExecState* state) |
643 | { |
644 | return IDLOperation<JSRange>::call<jsRangePrototypeFunctionSurroundContentsBody>(*state, "surroundContents" ); |
645 | } |
646 | |
647 | static inline JSC::EncodedJSValue jsRangePrototypeFunctionCloneRangeBody(JSC::ExecState* state, typename IDLOperation<JSRange>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
648 | { |
649 | UNUSED_PARAM(state); |
650 | UNUSED_PARAM(throwScope); |
651 | auto& impl = castedThis->wrapped(); |
652 | return JSValue::encode(toJSNewlyCreated<IDLInterface<Range>>(*state, *castedThis->globalObject(), impl.cloneRange())); |
653 | } |
654 | |
655 | EncodedJSValue JSC_HOST_CALL jsRangePrototypeFunctionCloneRange(ExecState* state) |
656 | { |
657 | return IDLOperation<JSRange>::call<jsRangePrototypeFunctionCloneRangeBody>(*state, "cloneRange" ); |
658 | } |
659 | |
660 | static inline JSC::EncodedJSValue jsRangePrototypeFunctionDetachBody(JSC::ExecState* state, typename IDLOperation<JSRange>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
661 | { |
662 | UNUSED_PARAM(state); |
663 | UNUSED_PARAM(throwScope); |
664 | auto& impl = castedThis->wrapped(); |
665 | impl.detach(); |
666 | return JSValue::encode(jsUndefined()); |
667 | } |
668 | |
669 | EncodedJSValue JSC_HOST_CALL jsRangePrototypeFunctionDetach(ExecState* state) |
670 | { |
671 | return IDLOperation<JSRange>::call<jsRangePrototypeFunctionDetachBody>(*state, "detach" ); |
672 | } |
673 | |
674 | static inline JSC::EncodedJSValue jsRangePrototypeFunctionIsPointInRangeBody(JSC::ExecState* state, typename IDLOperation<JSRange>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
675 | { |
676 | UNUSED_PARAM(state); |
677 | UNUSED_PARAM(throwScope); |
678 | auto& impl = castedThis->wrapped(); |
679 | if (UNLIKELY(state->argumentCount() < 2)) |
680 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
681 | auto node = convert<IDLInterface<Node>>(*state, state->uncheckedArgument(0), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentTypeError(state, scope, 0, "node" , "Range" , "isPointInRange" , "Node" ); }); |
682 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
683 | auto offset = convert<IDLUnsignedLong>(*state, state->uncheckedArgument(1)); |
684 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
685 | return JSValue::encode(toJS<IDLBoolean>(*state, throwScope, impl.isPointInRange(*node, WTFMove(offset)))); |
686 | } |
687 | |
688 | EncodedJSValue JSC_HOST_CALL jsRangePrototypeFunctionIsPointInRange(ExecState* state) |
689 | { |
690 | return IDLOperation<JSRange>::call<jsRangePrototypeFunctionIsPointInRangeBody>(*state, "isPointInRange" ); |
691 | } |
692 | |
693 | static inline JSC::EncodedJSValue jsRangePrototypeFunctionComparePointBody(JSC::ExecState* state, typename IDLOperation<JSRange>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
694 | { |
695 | UNUSED_PARAM(state); |
696 | UNUSED_PARAM(throwScope); |
697 | auto& impl = castedThis->wrapped(); |
698 | if (UNLIKELY(state->argumentCount() < 2)) |
699 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
700 | auto node = convert<IDLInterface<Node>>(*state, state->uncheckedArgument(0), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentTypeError(state, scope, 0, "node" , "Range" , "comparePoint" , "Node" ); }); |
701 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
702 | auto offset = convert<IDLUnsignedLong>(*state, state->uncheckedArgument(1)); |
703 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
704 | return JSValue::encode(toJS<IDLShort>(*state, throwScope, impl.comparePoint(*node, WTFMove(offset)))); |
705 | } |
706 | |
707 | EncodedJSValue JSC_HOST_CALL jsRangePrototypeFunctionComparePoint(ExecState* state) |
708 | { |
709 | return IDLOperation<JSRange>::call<jsRangePrototypeFunctionComparePointBody>(*state, "comparePoint" ); |
710 | } |
711 | |
712 | static inline JSC::EncodedJSValue jsRangePrototypeFunctionIntersectsNodeBody(JSC::ExecState* state, typename IDLOperation<JSRange>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
713 | { |
714 | UNUSED_PARAM(state); |
715 | UNUSED_PARAM(throwScope); |
716 | auto& impl = castedThis->wrapped(); |
717 | if (UNLIKELY(state->argumentCount() < 1)) |
718 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
719 | auto node = convert<IDLInterface<Node>>(*state, state->uncheckedArgument(0), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentTypeError(state, scope, 0, "node" , "Range" , "intersectsNode" , "Node" ); }); |
720 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
721 | return JSValue::encode(toJS<IDLBoolean>(*state, throwScope, impl.intersectsNode(*node))); |
722 | } |
723 | |
724 | EncodedJSValue JSC_HOST_CALL jsRangePrototypeFunctionIntersectsNode(ExecState* state) |
725 | { |
726 | return IDLOperation<JSRange>::call<jsRangePrototypeFunctionIntersectsNodeBody>(*state, "intersectsNode" ); |
727 | } |
728 | |
729 | static inline JSC::EncodedJSValue jsRangePrototypeFunctionGetClientRectsBody(JSC::ExecState* state, typename IDLOperation<JSRange>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
730 | { |
731 | UNUSED_PARAM(state); |
732 | UNUSED_PARAM(throwScope); |
733 | auto& impl = castedThis->wrapped(); |
734 | return JSValue::encode(toJS<IDLInterface<DOMRectList>>(*state, *castedThis->globalObject(), impl.getClientRects())); |
735 | } |
736 | |
737 | EncodedJSValue JSC_HOST_CALL jsRangePrototypeFunctionGetClientRects(ExecState* state) |
738 | { |
739 | return IDLOperation<JSRange>::call<jsRangePrototypeFunctionGetClientRectsBody>(*state, "getClientRects" ); |
740 | } |
741 | |
742 | static inline JSC::EncodedJSValue jsRangePrototypeFunctionGetBoundingClientRectBody(JSC::ExecState* state, typename IDLOperation<JSRange>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
743 | { |
744 | UNUSED_PARAM(state); |
745 | UNUSED_PARAM(throwScope); |
746 | auto& impl = castedThis->wrapped(); |
747 | return JSValue::encode(toJSNewlyCreated<IDLInterface<DOMRect>>(*state, *castedThis->globalObject(), impl.getBoundingClientRect())); |
748 | } |
749 | |
750 | EncodedJSValue JSC_HOST_CALL jsRangePrototypeFunctionGetBoundingClientRect(ExecState* state) |
751 | { |
752 | return IDLOperation<JSRange>::call<jsRangePrototypeFunctionGetBoundingClientRectBody>(*state, "getBoundingClientRect" ); |
753 | } |
754 | |
755 | static inline JSC::EncodedJSValue jsRangePrototypeFunctionCreateContextualFragmentBody(JSC::ExecState* state, typename IDLOperation<JSRange>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
756 | { |
757 | UNUSED_PARAM(state); |
758 | UNUSED_PARAM(throwScope); |
759 | CustomElementReactionStack customElementReactionStack(*state); |
760 | auto& impl = castedThis->wrapped(); |
761 | if (UNLIKELY(state->argumentCount() < 1)) |
762 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
763 | auto fragment = convert<IDLDOMString>(*state, state->uncheckedArgument(0)); |
764 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
765 | return JSValue::encode(toJSNewlyCreated<IDLInterface<DocumentFragment>>(*state, *castedThis->globalObject(), throwScope, impl.createContextualFragment(WTFMove(fragment)))); |
766 | } |
767 | |
768 | EncodedJSValue JSC_HOST_CALL jsRangePrototypeFunctionCreateContextualFragment(ExecState* state) |
769 | { |
770 | return IDLOperation<JSRange>::call<jsRangePrototypeFunctionCreateContextualFragmentBody>(*state, "createContextualFragment" ); |
771 | } |
772 | |
773 | static inline JSC::EncodedJSValue jsRangePrototypeFunctionExpandBody(JSC::ExecState* state, typename IDLOperation<JSRange>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
774 | { |
775 | UNUSED_PARAM(state); |
776 | UNUSED_PARAM(throwScope); |
777 | auto& impl = castedThis->wrapped(); |
778 | auto unit = state->argument(0).isUndefined() ? emptyString() : convert<IDLDOMString>(*state, state->uncheckedArgument(0)); |
779 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
780 | propagateException(*state, throwScope, impl.expand(WTFMove(unit))); |
781 | return JSValue::encode(jsUndefined()); |
782 | } |
783 | |
784 | EncodedJSValue JSC_HOST_CALL jsRangePrototypeFunctionExpand(ExecState* state) |
785 | { |
786 | return IDLOperation<JSRange>::call<jsRangePrototypeFunctionExpandBody>(*state, "expand" ); |
787 | } |
788 | |
789 | static inline JSC::EncodedJSValue jsRangePrototypeFunctionCompareNodeBody(JSC::ExecState* state, typename IDLOperation<JSRange>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
790 | { |
791 | UNUSED_PARAM(state); |
792 | UNUSED_PARAM(throwScope); |
793 | auto& impl = castedThis->wrapped(); |
794 | if (UNLIKELY(state->argumentCount() < 1)) |
795 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
796 | auto node = convert<IDLInterface<Node>>(*state, state->uncheckedArgument(0), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentTypeError(state, scope, 0, "node" , "Range" , "compareNode" , "Node" ); }); |
797 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
798 | return JSValue::encode(toJS<IDLShort>(*state, throwScope, impl.compareNode(*node))); |
799 | } |
800 | |
801 | EncodedJSValue JSC_HOST_CALL jsRangePrototypeFunctionCompareNode(ExecState* state) |
802 | { |
803 | return IDLOperation<JSRange>::call<jsRangePrototypeFunctionCompareNodeBody>(*state, "compareNode" ); |
804 | } |
805 | |
806 | static inline JSC::EncodedJSValue jsRangePrototypeFunctionToStringBody(JSC::ExecState* state, typename IDLOperation<JSRange>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
807 | { |
808 | UNUSED_PARAM(state); |
809 | UNUSED_PARAM(throwScope); |
810 | auto& impl = castedThis->wrapped(); |
811 | return JSValue::encode(toJS<IDLDOMString>(*state, impl.toString())); |
812 | } |
813 | |
814 | EncodedJSValue JSC_HOST_CALL jsRangePrototypeFunctionToString(ExecState* state) |
815 | { |
816 | return IDLOperation<JSRange>::call<jsRangePrototypeFunctionToStringBody>(*state, "toString" ); |
817 | } |
818 | |
819 | void JSRange::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) |
820 | { |
821 | auto* thisObject = jsCast<JSRange*>(cell); |
822 | builder.setWrappedObjectForCell(cell, &thisObject->wrapped()); |
823 | if (thisObject->scriptExecutionContext()) |
824 | builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); |
825 | Base::heapSnapshot(cell, builder); |
826 | } |
827 | |
828 | bool JSRangeOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor, const char** reason) |
829 | { |
830 | UNUSED_PARAM(handle); |
831 | UNUSED_PARAM(visitor); |
832 | UNUSED_PARAM(reason); |
833 | return false; |
834 | } |
835 | |
836 | void JSRangeOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context) |
837 | { |
838 | auto* jsRange = static_cast<JSRange*>(handle.slot()->asCell()); |
839 | auto& world = *static_cast<DOMWrapperWorld*>(context); |
840 | uncacheWrapper(world, &jsRange->wrapped(), jsRange); |
841 | } |
842 | |
843 | JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<Range>&& impl) |
844 | { |
845 | // If you hit this failure the interface definition has the ImplementationLacksVTable |
846 | // attribute. You should remove that attribute. If the class has subclasses |
847 | // that may be passed through this toJS() function you should use the SkipVTableValidation |
848 | // attribute to Range. |
849 | static_assert(!std::is_polymorphic<Range>::value, "Range is polymorphic but the IDL claims it is not" ); |
850 | return createWrapper<Range>(globalObject, WTFMove(impl)); |
851 | } |
852 | |
853 | JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, Range& impl) |
854 | { |
855 | return wrap(state, globalObject, impl); |
856 | } |
857 | |
858 | Range* JSRange::toWrapped(JSC::VM& vm, JSC::JSValue value) |
859 | { |
860 | if (auto* wrapper = jsDynamicCast<JSRange*>(vm, value)) |
861 | return &wrapper->wrapped(); |
862 | return nullptr; |
863 | } |
864 | |
865 | } |
866 | |