| 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 | |
| 23 | #if ENABLE(INTERSECTION_OBSERVER) |
| 24 | |
| 25 | #include "JSIntersectionObserverEntry.h" |
| 26 | |
| 27 | #include "JSDOMAttribute.h" |
| 28 | #include "JSDOMBinding.h" |
| 29 | #include "JSDOMConstructor.h" |
| 30 | #include "JSDOMConvertBoolean.h" |
| 31 | #include "JSDOMConvertInterface.h" |
| 32 | #include "JSDOMConvertNullable.h" |
| 33 | #include "JSDOMConvertNumbers.h" |
| 34 | #include "JSDOMExceptionHandling.h" |
| 35 | #include "JSDOMGlobalObject.h" |
| 36 | #include "JSDOMRectInit.h" |
| 37 | #include "JSDOMRectReadOnly.h" |
| 38 | #include "JSDOMWrapperCache.h" |
| 39 | #include "JSElement.h" |
| 40 | #include "ScriptExecutionContext.h" |
| 41 | #include <JavaScriptCore/FunctionPrototype.h> |
| 42 | #include <JavaScriptCore/HeapSnapshotBuilder.h> |
| 43 | #include <JavaScriptCore/JSCInlines.h> |
| 44 | #include <wtf/GetPtr.h> |
| 45 | #include <wtf/PointerPreparations.h> |
| 46 | #include <wtf/URL.h> |
| 47 | |
| 48 | |
| 49 | namespace WebCore { |
| 50 | using namespace JSC; |
| 51 | |
| 52 | #if ENABLE(INTERSECTION_OBSERVER) |
| 53 | |
| 54 | template<> IntersectionObserverEntry::Init convertDictionary<IntersectionObserverEntry::Init>(ExecState& state, JSValue value) |
| 55 | { |
| 56 | VM& vm = state.vm(); |
| 57 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 58 | bool isNullOrUndefined = value.isUndefinedOrNull(); |
| 59 | auto* object = isNullOrUndefined ? nullptr : value.getObject(); |
| 60 | if (UNLIKELY(!isNullOrUndefined && !object)) { |
| 61 | throwTypeError(&state, throwScope); |
| 62 | return { }; |
| 63 | } |
| 64 | IntersectionObserverEntry::Init result; |
| 65 | JSValue boundingClientRectValue; |
| 66 | if (isNullOrUndefined) |
| 67 | boundingClientRectValue = jsUndefined(); |
| 68 | else { |
| 69 | boundingClientRectValue = object->get(&state, Identifier::fromString(&state, "boundingClientRect" )); |
| 70 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 71 | } |
| 72 | if (!boundingClientRectValue.isUndefined()) { |
| 73 | result.boundingClientRect = convert<IDLDictionary<DOMRectInit>>(state, boundingClientRectValue); |
| 74 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 75 | } else { |
| 76 | throwRequiredMemberTypeError(state, throwScope, "boundingClientRect" , "IntersectionObserverEntryInit" , "DOMRectInit" ); |
| 77 | return { }; |
| 78 | } |
| 79 | JSValue intersectionRatioValue; |
| 80 | if (isNullOrUndefined) |
| 81 | intersectionRatioValue = jsUndefined(); |
| 82 | else { |
| 83 | intersectionRatioValue = object->get(&state, Identifier::fromString(&state, "intersectionRatio" )); |
| 84 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 85 | } |
| 86 | if (!intersectionRatioValue.isUndefined()) { |
| 87 | result.intersectionRatio = convert<IDLDouble>(state, intersectionRatioValue); |
| 88 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 89 | } else { |
| 90 | throwRequiredMemberTypeError(state, throwScope, "intersectionRatio" , "IntersectionObserverEntryInit" , "double" ); |
| 91 | return { }; |
| 92 | } |
| 93 | JSValue intersectionRectValue; |
| 94 | if (isNullOrUndefined) |
| 95 | intersectionRectValue = jsUndefined(); |
| 96 | else { |
| 97 | intersectionRectValue = object->get(&state, Identifier::fromString(&state, "intersectionRect" )); |
| 98 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 99 | } |
| 100 | if (!intersectionRectValue.isUndefined()) { |
| 101 | result.intersectionRect = convert<IDLDictionary<DOMRectInit>>(state, intersectionRectValue); |
| 102 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 103 | } else { |
| 104 | throwRequiredMemberTypeError(state, throwScope, "intersectionRect" , "IntersectionObserverEntryInit" , "DOMRectInit" ); |
| 105 | return { }; |
| 106 | } |
| 107 | JSValue isIntersectingValue; |
| 108 | if (isNullOrUndefined) |
| 109 | isIntersectingValue = jsUndefined(); |
| 110 | else { |
| 111 | isIntersectingValue = object->get(&state, Identifier::fromString(&state, "isIntersecting" )); |
| 112 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 113 | } |
| 114 | if (!isIntersectingValue.isUndefined()) { |
| 115 | result.isIntersecting = convert<IDLBoolean>(state, isIntersectingValue); |
| 116 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 117 | } else { |
| 118 | throwRequiredMemberTypeError(state, throwScope, "isIntersecting" , "IntersectionObserverEntryInit" , "boolean" ); |
| 119 | return { }; |
| 120 | } |
| 121 | JSValue rootBoundsValue; |
| 122 | if (isNullOrUndefined) |
| 123 | rootBoundsValue = jsUndefined(); |
| 124 | else { |
| 125 | rootBoundsValue = object->get(&state, Identifier::fromString(&state, "rootBounds" )); |
| 126 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 127 | } |
| 128 | if (!rootBoundsValue.isUndefined()) { |
| 129 | result.rootBounds = convert<IDLNullable<IDLDictionary<DOMRectInit>>>(state, rootBoundsValue); |
| 130 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 131 | } else { |
| 132 | throwRequiredMemberTypeError(state, throwScope, "rootBounds" , "IntersectionObserverEntryInit" , "DOMRectInit" ); |
| 133 | return { }; |
| 134 | } |
| 135 | JSValue targetValue; |
| 136 | if (isNullOrUndefined) |
| 137 | targetValue = jsUndefined(); |
| 138 | else { |
| 139 | targetValue = object->get(&state, Identifier::fromString(&state, "target" )); |
| 140 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 141 | } |
| 142 | if (!targetValue.isUndefined()) { |
| 143 | result.target = convert<IDLInterface<Element>>(state, targetValue); |
| 144 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 145 | } else { |
| 146 | throwRequiredMemberTypeError(state, throwScope, "target" , "IntersectionObserverEntryInit" , "Element" ); |
| 147 | return { }; |
| 148 | } |
| 149 | JSValue timeValue; |
| 150 | if (isNullOrUndefined) |
| 151 | timeValue = jsUndefined(); |
| 152 | else { |
| 153 | timeValue = object->get(&state, Identifier::fromString(&state, "time" )); |
| 154 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 155 | } |
| 156 | if (!timeValue.isUndefined()) { |
| 157 | result.time = convert<IDLDouble>(state, timeValue); |
| 158 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 159 | } else { |
| 160 | throwRequiredMemberTypeError(state, throwScope, "time" , "IntersectionObserverEntryInit" , "double" ); |
| 161 | return { }; |
| 162 | } |
| 163 | return result; |
| 164 | } |
| 165 | |
| 166 | #endif |
| 167 | |
| 168 | // Attributes |
| 169 | |
| 170 | JSC::EncodedJSValue jsIntersectionObserverEntryConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 171 | bool setJSIntersectionObserverEntryConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| 172 | JSC::EncodedJSValue jsIntersectionObserverEntryTime(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 173 | JSC::EncodedJSValue jsIntersectionObserverEntryRootBounds(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 174 | JSC::EncodedJSValue jsIntersectionObserverEntryBoundingClientRect(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 175 | JSC::EncodedJSValue jsIntersectionObserverEntryIntersectionRect(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 176 | JSC::EncodedJSValue jsIntersectionObserverEntryIsIntersecting(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 177 | JSC::EncodedJSValue jsIntersectionObserverEntryIntersectionRatio(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 178 | JSC::EncodedJSValue jsIntersectionObserverEntryTarget(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 179 | |
| 180 | class JSIntersectionObserverEntryPrototype : public JSC::JSNonFinalObject { |
| 181 | public: |
| 182 | using Base = JSC::JSNonFinalObject; |
| 183 | static JSIntersectionObserverEntryPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
| 184 | { |
| 185 | JSIntersectionObserverEntryPrototype* ptr = new (NotNull, JSC::allocateCell<JSIntersectionObserverEntryPrototype>(vm.heap)) JSIntersectionObserverEntryPrototype(vm, globalObject, structure); |
| 186 | ptr->finishCreation(vm); |
| 187 | return ptr; |
| 188 | } |
| 189 | |
| 190 | DECLARE_INFO; |
| 191 | static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) |
| 192 | { |
| 193 | return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); |
| 194 | } |
| 195 | |
| 196 | private: |
| 197 | JSIntersectionObserverEntryPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
| 198 | : JSC::JSNonFinalObject(vm, structure) |
| 199 | { |
| 200 | } |
| 201 | |
| 202 | void finishCreation(JSC::VM&); |
| 203 | }; |
| 204 | |
| 205 | using JSIntersectionObserverEntryConstructor = JSDOMConstructor<JSIntersectionObserverEntry>; |
| 206 | |
| 207 | template<> EncodedJSValue JSC_HOST_CALL JSIntersectionObserverEntryConstructor::construct(ExecState* state) |
| 208 | { |
| 209 | VM& vm = state->vm(); |
| 210 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 211 | UNUSED_PARAM(throwScope); |
| 212 | auto* castedThis = jsCast<JSIntersectionObserverEntryConstructor*>(state->jsCallee()); |
| 213 | ASSERT(castedThis); |
| 214 | if (UNLIKELY(state->argumentCount() < 1)) |
| 215 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| 216 | auto intersectionObserverEntryInit = convert<IDLDictionary<IntersectionObserverEntry::Init>>(*state, state->uncheckedArgument(0)); |
| 217 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 218 | auto object = IntersectionObserverEntry::create(WTFMove(intersectionObserverEntryInit)); |
| 219 | return JSValue::encode(toJSNewlyCreated<IDLInterface<IntersectionObserverEntry>>(*state, *castedThis->globalObject(), WTFMove(object))); |
| 220 | } |
| 221 | |
| 222 | template<> JSValue JSIntersectionObserverEntryConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
| 223 | { |
| 224 | UNUSED_PARAM(vm); |
| 225 | return globalObject.functionPrototype(); |
| 226 | } |
| 227 | |
| 228 | template<> void JSIntersectionObserverEntryConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
| 229 | { |
| 230 | putDirect(vm, vm.propertyNames->prototype, JSIntersectionObserverEntry::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 231 | putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("IntersectionObserverEntry"_s )), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 232 | putDirect(vm, vm.propertyNames->length, jsNumber(1), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 233 | } |
| 234 | |
| 235 | template<> const ClassInfo JSIntersectionObserverEntryConstructor::s_info = { "IntersectionObserverEntry" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSIntersectionObserverEntryConstructor) }; |
| 236 | |
| 237 | /* Hash table for prototype */ |
| 238 | |
| 239 | static const HashTableValue JSIntersectionObserverEntryPrototypeTableValues[] = |
| 240 | { |
| 241 | { "constructor" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsIntersectionObserverEntryConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSIntersectionObserverEntryConstructor) } }, |
| 242 | { "time" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsIntersectionObserverEntryTime), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 243 | { "rootBounds" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsIntersectionObserverEntryRootBounds), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 244 | { "boundingClientRect" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsIntersectionObserverEntryBoundingClientRect), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 245 | { "intersectionRect" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsIntersectionObserverEntryIntersectionRect), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 246 | { "isIntersecting" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsIntersectionObserverEntryIsIntersecting), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 247 | { "intersectionRatio" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsIntersectionObserverEntryIntersectionRatio), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 248 | { "target" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsIntersectionObserverEntryTarget), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 249 | }; |
| 250 | |
| 251 | const ClassInfo JSIntersectionObserverEntryPrototype::s_info = { "IntersectionObserverEntryPrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSIntersectionObserverEntryPrototype) }; |
| 252 | |
| 253 | void JSIntersectionObserverEntryPrototype::finishCreation(VM& vm) |
| 254 | { |
| 255 | Base::finishCreation(vm); |
| 256 | reifyStaticProperties(vm, JSIntersectionObserverEntry::info(), JSIntersectionObserverEntryPrototypeTableValues, *this); |
| 257 | } |
| 258 | |
| 259 | const ClassInfo JSIntersectionObserverEntry::s_info = { "IntersectionObserverEntry" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSIntersectionObserverEntry) }; |
| 260 | |
| 261 | JSIntersectionObserverEntry::JSIntersectionObserverEntry(Structure* structure, JSDOMGlobalObject& globalObject, Ref<IntersectionObserverEntry>&& impl) |
| 262 | : JSDOMWrapper<IntersectionObserverEntry>(structure, globalObject, WTFMove(impl)) |
| 263 | { |
| 264 | } |
| 265 | |
| 266 | void JSIntersectionObserverEntry::finishCreation(VM& vm) |
| 267 | { |
| 268 | Base::finishCreation(vm); |
| 269 | ASSERT(inherits(vm, info())); |
| 270 | |
| 271 | } |
| 272 | |
| 273 | JSObject* JSIntersectionObserverEntry::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
| 274 | { |
| 275 | return JSIntersectionObserverEntryPrototype::create(vm, &globalObject, JSIntersectionObserverEntryPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype())); |
| 276 | } |
| 277 | |
| 278 | JSObject* JSIntersectionObserverEntry::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
| 279 | { |
| 280 | return getDOMPrototype<JSIntersectionObserverEntry>(vm, globalObject); |
| 281 | } |
| 282 | |
| 283 | JSValue JSIntersectionObserverEntry::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
| 284 | { |
| 285 | return getDOMConstructor<JSIntersectionObserverEntryConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
| 286 | } |
| 287 | |
| 288 | void JSIntersectionObserverEntry::destroy(JSC::JSCell* cell) |
| 289 | { |
| 290 | JSIntersectionObserverEntry* thisObject = static_cast<JSIntersectionObserverEntry*>(cell); |
| 291 | thisObject->JSIntersectionObserverEntry::~JSIntersectionObserverEntry(); |
| 292 | } |
| 293 | |
| 294 | template<> inline JSIntersectionObserverEntry* IDLAttribute<JSIntersectionObserverEntry>::cast(ExecState& state, EncodedJSValue thisValue) |
| 295 | { |
| 296 | return jsDynamicCast<JSIntersectionObserverEntry*>(state.vm(), JSValue::decode(thisValue)); |
| 297 | } |
| 298 | |
| 299 | EncodedJSValue jsIntersectionObserverEntryConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 300 | { |
| 301 | VM& vm = state->vm(); |
| 302 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 303 | auto* prototype = jsDynamicCast<JSIntersectionObserverEntryPrototype*>(vm, JSValue::decode(thisValue)); |
| 304 | if (UNLIKELY(!prototype)) |
| 305 | return throwVMTypeError(state, throwScope); |
| 306 | return JSValue::encode(JSIntersectionObserverEntry::getConstructor(state->vm(), prototype->globalObject())); |
| 307 | } |
| 308 | |
| 309 | bool setJSIntersectionObserverEntryConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| 310 | { |
| 311 | VM& vm = state->vm(); |
| 312 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 313 | auto* prototype = jsDynamicCast<JSIntersectionObserverEntryPrototype*>(vm, JSValue::decode(thisValue)); |
| 314 | if (UNLIKELY(!prototype)) { |
| 315 | throwVMTypeError(state, throwScope); |
| 316 | return false; |
| 317 | } |
| 318 | // Shadowing a built-in constructor |
| 319 | return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue)); |
| 320 | } |
| 321 | |
| 322 | static inline JSValue jsIntersectionObserverEntryTimeGetter(ExecState& state, JSIntersectionObserverEntry& thisObject, ThrowScope& throwScope) |
| 323 | { |
| 324 | UNUSED_PARAM(throwScope); |
| 325 | UNUSED_PARAM(state); |
| 326 | auto& impl = thisObject.wrapped(); |
| 327 | JSValue result = toJS<IDLDouble>(state, throwScope, impl.time()); |
| 328 | return result; |
| 329 | } |
| 330 | |
| 331 | EncodedJSValue jsIntersectionObserverEntryTime(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 332 | { |
| 333 | return IDLAttribute<JSIntersectionObserverEntry>::get<jsIntersectionObserverEntryTimeGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "time" ); |
| 334 | } |
| 335 | |
| 336 | static inline JSValue jsIntersectionObserverEntryRootBoundsGetter(ExecState& state, JSIntersectionObserverEntry& thisObject, ThrowScope& throwScope) |
| 337 | { |
| 338 | UNUSED_PARAM(throwScope); |
| 339 | UNUSED_PARAM(state); |
| 340 | auto& impl = thisObject.wrapped(); |
| 341 | JSValue result = toJS<IDLNullable<IDLInterface<DOMRectReadOnly>>>(state, *thisObject.globalObject(), throwScope, impl.rootBounds()); |
| 342 | return result; |
| 343 | } |
| 344 | |
| 345 | EncodedJSValue jsIntersectionObserverEntryRootBounds(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 346 | { |
| 347 | return IDLAttribute<JSIntersectionObserverEntry>::get<jsIntersectionObserverEntryRootBoundsGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "rootBounds" ); |
| 348 | } |
| 349 | |
| 350 | static inline JSValue jsIntersectionObserverEntryBoundingClientRectGetter(ExecState& state, JSIntersectionObserverEntry& thisObject, ThrowScope& throwScope) |
| 351 | { |
| 352 | UNUSED_PARAM(throwScope); |
| 353 | UNUSED_PARAM(state); |
| 354 | auto& impl = thisObject.wrapped(); |
| 355 | JSValue result = toJS<IDLInterface<DOMRectReadOnly>>(state, *thisObject.globalObject(), throwScope, impl.boundingClientRect()); |
| 356 | return result; |
| 357 | } |
| 358 | |
| 359 | EncodedJSValue jsIntersectionObserverEntryBoundingClientRect(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 360 | { |
| 361 | return IDLAttribute<JSIntersectionObserverEntry>::get<jsIntersectionObserverEntryBoundingClientRectGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "boundingClientRect" ); |
| 362 | } |
| 363 | |
| 364 | static inline JSValue jsIntersectionObserverEntryIntersectionRectGetter(ExecState& state, JSIntersectionObserverEntry& thisObject, ThrowScope& throwScope) |
| 365 | { |
| 366 | UNUSED_PARAM(throwScope); |
| 367 | UNUSED_PARAM(state); |
| 368 | auto& impl = thisObject.wrapped(); |
| 369 | JSValue result = toJS<IDLInterface<DOMRectReadOnly>>(state, *thisObject.globalObject(), throwScope, impl.intersectionRect()); |
| 370 | return result; |
| 371 | } |
| 372 | |
| 373 | EncodedJSValue jsIntersectionObserverEntryIntersectionRect(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 374 | { |
| 375 | return IDLAttribute<JSIntersectionObserverEntry>::get<jsIntersectionObserverEntryIntersectionRectGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "intersectionRect" ); |
| 376 | } |
| 377 | |
| 378 | static inline JSValue jsIntersectionObserverEntryIsIntersectingGetter(ExecState& state, JSIntersectionObserverEntry& thisObject, ThrowScope& throwScope) |
| 379 | { |
| 380 | UNUSED_PARAM(throwScope); |
| 381 | UNUSED_PARAM(state); |
| 382 | auto& impl = thisObject.wrapped(); |
| 383 | JSValue result = toJS<IDLBoolean>(state, throwScope, impl.isIntersecting()); |
| 384 | return result; |
| 385 | } |
| 386 | |
| 387 | EncodedJSValue jsIntersectionObserverEntryIsIntersecting(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 388 | { |
| 389 | return IDLAttribute<JSIntersectionObserverEntry>::get<jsIntersectionObserverEntryIsIntersectingGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "isIntersecting" ); |
| 390 | } |
| 391 | |
| 392 | static inline JSValue jsIntersectionObserverEntryIntersectionRatioGetter(ExecState& state, JSIntersectionObserverEntry& thisObject, ThrowScope& throwScope) |
| 393 | { |
| 394 | UNUSED_PARAM(throwScope); |
| 395 | UNUSED_PARAM(state); |
| 396 | auto& impl = thisObject.wrapped(); |
| 397 | JSValue result = toJS<IDLDouble>(state, throwScope, impl.intersectionRatio()); |
| 398 | return result; |
| 399 | } |
| 400 | |
| 401 | EncodedJSValue jsIntersectionObserverEntryIntersectionRatio(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 402 | { |
| 403 | return IDLAttribute<JSIntersectionObserverEntry>::get<jsIntersectionObserverEntryIntersectionRatioGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "intersectionRatio" ); |
| 404 | } |
| 405 | |
| 406 | static inline JSValue jsIntersectionObserverEntryTargetGetter(ExecState& state, JSIntersectionObserverEntry& thisObject, ThrowScope& throwScope) |
| 407 | { |
| 408 | UNUSED_PARAM(throwScope); |
| 409 | UNUSED_PARAM(state); |
| 410 | auto& impl = thisObject.wrapped(); |
| 411 | JSValue result = toJS<IDLInterface<Element>>(state, *thisObject.globalObject(), throwScope, impl.target()); |
| 412 | return result; |
| 413 | } |
| 414 | |
| 415 | EncodedJSValue jsIntersectionObserverEntryTarget(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 416 | { |
| 417 | return IDLAttribute<JSIntersectionObserverEntry>::get<jsIntersectionObserverEntryTargetGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "target" ); |
| 418 | } |
| 419 | |
| 420 | void JSIntersectionObserverEntry::visitChildren(JSCell* cell, SlotVisitor& visitor) |
| 421 | { |
| 422 | auto* thisObject = jsCast<JSIntersectionObserverEntry*>(cell); |
| 423 | ASSERT_GC_OBJECT_INHERITS(thisObject, info()); |
| 424 | Base::visitChildren(thisObject, visitor); |
| 425 | thisObject->visitAdditionalChildren(visitor); |
| 426 | } |
| 427 | |
| 428 | void JSIntersectionObserverEntry::visitOutputConstraints(JSCell* cell, SlotVisitor& visitor) |
| 429 | { |
| 430 | auto* thisObject = jsCast<JSIntersectionObserverEntry*>(cell); |
| 431 | ASSERT_GC_OBJECT_INHERITS(thisObject, info()); |
| 432 | Base::visitOutputConstraints(thisObject, visitor); |
| 433 | thisObject->visitAdditionalChildren(visitor); |
| 434 | } |
| 435 | |
| 436 | void JSIntersectionObserverEntry::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) |
| 437 | { |
| 438 | auto* thisObject = jsCast<JSIntersectionObserverEntry*>(cell); |
| 439 | builder.setWrappedObjectForCell(cell, &thisObject->wrapped()); |
| 440 | if (thisObject->scriptExecutionContext()) |
| 441 | builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); |
| 442 | Base::heapSnapshot(cell, builder); |
| 443 | } |
| 444 | |
| 445 | bool JSIntersectionObserverEntryOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor, const char** reason) |
| 446 | { |
| 447 | UNUSED_PARAM(handle); |
| 448 | UNUSED_PARAM(visitor); |
| 449 | UNUSED_PARAM(reason); |
| 450 | return false; |
| 451 | } |
| 452 | |
| 453 | void JSIntersectionObserverEntryOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context) |
| 454 | { |
| 455 | auto* jsIntersectionObserverEntry = static_cast<JSIntersectionObserverEntry*>(handle.slot()->asCell()); |
| 456 | auto& world = *static_cast<DOMWrapperWorld*>(context); |
| 457 | uncacheWrapper(world, &jsIntersectionObserverEntry->wrapped(), jsIntersectionObserverEntry); |
| 458 | } |
| 459 | |
| 460 | JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<IntersectionObserverEntry>&& impl) |
| 461 | { |
| 462 | // If you hit this failure the interface definition has the ImplementationLacksVTable |
| 463 | // attribute. You should remove that attribute. If the class has subclasses |
| 464 | // that may be passed through this toJS() function you should use the SkipVTableValidation |
| 465 | // attribute to IntersectionObserverEntry. |
| 466 | static_assert(!std::is_polymorphic<IntersectionObserverEntry>::value, "IntersectionObserverEntry is polymorphic but the IDL claims it is not" ); |
| 467 | return createWrapper<IntersectionObserverEntry>(globalObject, WTFMove(impl)); |
| 468 | } |
| 469 | |
| 470 | JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, IntersectionObserverEntry& impl) |
| 471 | { |
| 472 | return wrap(state, globalObject, impl); |
| 473 | } |
| 474 | |
| 475 | IntersectionObserverEntry* JSIntersectionObserverEntry::toWrapped(JSC::VM& vm, JSC::JSValue value) |
| 476 | { |
| 477 | if (auto* wrapper = jsDynamicCast<JSIntersectionObserverEntry*>(vm, value)) |
| 478 | return &wrapper->wrapped(); |
| 479 | return nullptr; |
| 480 | } |
| 481 | |
| 482 | } |
| 483 | |
| 484 | #endif // ENABLE(INTERSECTION_OBSERVER) |
| 485 | |