| 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 "JSDOMRectReadOnly.h" |
| 23 | |
| 24 | #include "JSDOMAttribute.h" |
| 25 | #include "JSDOMBinding.h" |
| 26 | #include "JSDOMConstructor.h" |
| 27 | #include "JSDOMConvertDictionary.h" |
| 28 | #include "JSDOMConvertInterface.h" |
| 29 | #include "JSDOMConvertNumbers.h" |
| 30 | #include "JSDOMExceptionHandling.h" |
| 31 | #include "JSDOMGlobalObject.h" |
| 32 | #include "JSDOMOperation.h" |
| 33 | #include "JSDOMRectInit.h" |
| 34 | #include "JSDOMRectReadOnly.h" |
| 35 | #include "JSDOMWrapperCache.h" |
| 36 | #include "ScriptExecutionContext.h" |
| 37 | #include <JavaScriptCore/FunctionPrototype.h> |
| 38 | #include <JavaScriptCore/HeapSnapshotBuilder.h> |
| 39 | #include <JavaScriptCore/JSCInlines.h> |
| 40 | #include <JavaScriptCore/ObjectConstructor.h> |
| 41 | #include <wtf/GetPtr.h> |
| 42 | #include <wtf/PointerPreparations.h> |
| 43 | #include <wtf/URL.h> |
| 44 | |
| 45 | |
| 46 | namespace WebCore { |
| 47 | using namespace JSC; |
| 48 | |
| 49 | // Functions |
| 50 | |
| 51 | JSC::EncodedJSValue JSC_HOST_CALL jsDOMRectReadOnlyConstructorFunctionFromRect(JSC::ExecState*); |
| 52 | JSC::EncodedJSValue JSC_HOST_CALL jsDOMRectReadOnlyPrototypeFunctionToJSON(JSC::ExecState*); |
| 53 | |
| 54 | // Attributes |
| 55 | |
| 56 | JSC::EncodedJSValue jsDOMRectReadOnlyConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 57 | bool setJSDOMRectReadOnlyConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| 58 | JSC::EncodedJSValue jsDOMRectReadOnlyX(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 59 | JSC::EncodedJSValue jsDOMRectReadOnlyY(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 60 | JSC::EncodedJSValue jsDOMRectReadOnlyWidth(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 61 | JSC::EncodedJSValue jsDOMRectReadOnlyHeight(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 62 | JSC::EncodedJSValue jsDOMRectReadOnlyTop(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 63 | JSC::EncodedJSValue jsDOMRectReadOnlyRight(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 64 | JSC::EncodedJSValue jsDOMRectReadOnlyBottom(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 65 | JSC::EncodedJSValue jsDOMRectReadOnlyLeft(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 66 | |
| 67 | class JSDOMRectReadOnlyPrototype : public JSC::JSNonFinalObject { |
| 68 | public: |
| 69 | using Base = JSC::JSNonFinalObject; |
| 70 | static JSDOMRectReadOnlyPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
| 71 | { |
| 72 | JSDOMRectReadOnlyPrototype* ptr = new (NotNull, JSC::allocateCell<JSDOMRectReadOnlyPrototype>(vm.heap)) JSDOMRectReadOnlyPrototype(vm, globalObject, structure); |
| 73 | ptr->finishCreation(vm); |
| 74 | return ptr; |
| 75 | } |
| 76 | |
| 77 | DECLARE_INFO; |
| 78 | static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) |
| 79 | { |
| 80 | return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); |
| 81 | } |
| 82 | |
| 83 | private: |
| 84 | JSDOMRectReadOnlyPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
| 85 | : JSC::JSNonFinalObject(vm, structure) |
| 86 | { |
| 87 | } |
| 88 | |
| 89 | void finishCreation(JSC::VM&); |
| 90 | }; |
| 91 | |
| 92 | using JSDOMRectReadOnlyConstructor = JSDOMConstructor<JSDOMRectReadOnly>; |
| 93 | |
| 94 | /* Hash table for constructor */ |
| 95 | |
| 96 | static const HashTableValue JSDOMRectReadOnlyConstructorTableValues[] = |
| 97 | { |
| 98 | { "fromRect" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsDOMRectReadOnlyConstructorFunctionFromRect), (intptr_t) (0) } }, |
| 99 | }; |
| 100 | |
| 101 | template<> EncodedJSValue JSC_HOST_CALL JSDOMRectReadOnlyConstructor::construct(ExecState* state) |
| 102 | { |
| 103 | VM& vm = state->vm(); |
| 104 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 105 | UNUSED_PARAM(throwScope); |
| 106 | auto* castedThis = jsCast<JSDOMRectReadOnlyConstructor*>(state->jsCallee()); |
| 107 | ASSERT(castedThis); |
| 108 | auto x = state->argument(0).isUndefined() ? 0 : convert<IDLUnrestrictedDouble>(*state, state->uncheckedArgument(0)); |
| 109 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 110 | auto y = state->argument(1).isUndefined() ? 0 : convert<IDLUnrestrictedDouble>(*state, state->uncheckedArgument(1)); |
| 111 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 112 | auto width = state->argument(2).isUndefined() ? 0 : convert<IDLUnrestrictedDouble>(*state, state->uncheckedArgument(2)); |
| 113 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 114 | auto height = state->argument(3).isUndefined() ? 0 : convert<IDLUnrestrictedDouble>(*state, state->uncheckedArgument(3)); |
| 115 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 116 | auto object = DOMRectReadOnly::create(WTFMove(x), WTFMove(y), WTFMove(width), WTFMove(height)); |
| 117 | return JSValue::encode(toJSNewlyCreated<IDLInterface<DOMRectReadOnly>>(*state, *castedThis->globalObject(), WTFMove(object))); |
| 118 | } |
| 119 | |
| 120 | template<> JSValue JSDOMRectReadOnlyConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
| 121 | { |
| 122 | UNUSED_PARAM(vm); |
| 123 | return globalObject.functionPrototype(); |
| 124 | } |
| 125 | |
| 126 | template<> void JSDOMRectReadOnlyConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
| 127 | { |
| 128 | putDirect(vm, vm.propertyNames->prototype, JSDOMRectReadOnly::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 129 | putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("DOMRectReadOnly"_s )), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 130 | putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 131 | reifyStaticProperties(vm, JSDOMRectReadOnly::info(), JSDOMRectReadOnlyConstructorTableValues, *this); |
| 132 | } |
| 133 | |
| 134 | template<> const ClassInfo JSDOMRectReadOnlyConstructor::s_info = { "DOMRectReadOnly" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSDOMRectReadOnlyConstructor) }; |
| 135 | |
| 136 | /* Hash table for prototype */ |
| 137 | |
| 138 | static const HashTableValue JSDOMRectReadOnlyPrototypeTableValues[] = |
| 139 | { |
| 140 | { "constructor" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDOMRectReadOnlyConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSDOMRectReadOnlyConstructor) } }, |
| 141 | { "x" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDOMRectReadOnlyX), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 142 | { "y" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDOMRectReadOnlyY), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 143 | { "width" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDOMRectReadOnlyWidth), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 144 | { "height" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDOMRectReadOnlyHeight), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 145 | { "top" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDOMRectReadOnlyTop), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 146 | { "right" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDOMRectReadOnlyRight), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 147 | { "bottom" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDOMRectReadOnlyBottom), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 148 | { "left" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDOMRectReadOnlyLeft), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 149 | { "toJSON" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsDOMRectReadOnlyPrototypeFunctionToJSON), (intptr_t) (0) } }, |
| 150 | }; |
| 151 | |
| 152 | const ClassInfo JSDOMRectReadOnlyPrototype::s_info = { "DOMRectReadOnlyPrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSDOMRectReadOnlyPrototype) }; |
| 153 | |
| 154 | void JSDOMRectReadOnlyPrototype::finishCreation(VM& vm) |
| 155 | { |
| 156 | Base::finishCreation(vm); |
| 157 | reifyStaticProperties(vm, JSDOMRectReadOnly::info(), JSDOMRectReadOnlyPrototypeTableValues, *this); |
| 158 | } |
| 159 | |
| 160 | const ClassInfo JSDOMRectReadOnly::s_info = { "DOMRectReadOnly" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSDOMRectReadOnly) }; |
| 161 | |
| 162 | JSDOMRectReadOnly::JSDOMRectReadOnly(Structure* structure, JSDOMGlobalObject& globalObject, Ref<DOMRectReadOnly>&& impl) |
| 163 | : JSDOMWrapper<DOMRectReadOnly>(structure, globalObject, WTFMove(impl)) |
| 164 | { |
| 165 | } |
| 166 | |
| 167 | void JSDOMRectReadOnly::finishCreation(VM& vm) |
| 168 | { |
| 169 | Base::finishCreation(vm); |
| 170 | ASSERT(inherits(vm, info())); |
| 171 | |
| 172 | } |
| 173 | |
| 174 | JSObject* JSDOMRectReadOnly::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
| 175 | { |
| 176 | return JSDOMRectReadOnlyPrototype::create(vm, &globalObject, JSDOMRectReadOnlyPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype())); |
| 177 | } |
| 178 | |
| 179 | JSObject* JSDOMRectReadOnly::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
| 180 | { |
| 181 | return getDOMPrototype<JSDOMRectReadOnly>(vm, globalObject); |
| 182 | } |
| 183 | |
| 184 | JSValue JSDOMRectReadOnly::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
| 185 | { |
| 186 | return getDOMConstructor<JSDOMRectReadOnlyConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
| 187 | } |
| 188 | |
| 189 | void JSDOMRectReadOnly::destroy(JSC::JSCell* cell) |
| 190 | { |
| 191 | JSDOMRectReadOnly* thisObject = static_cast<JSDOMRectReadOnly*>(cell); |
| 192 | thisObject->JSDOMRectReadOnly::~JSDOMRectReadOnly(); |
| 193 | } |
| 194 | |
| 195 | template<> inline JSDOMRectReadOnly* IDLAttribute<JSDOMRectReadOnly>::cast(ExecState& state, EncodedJSValue thisValue) |
| 196 | { |
| 197 | return jsDynamicCast<JSDOMRectReadOnly*>(state.vm(), JSValue::decode(thisValue)); |
| 198 | } |
| 199 | |
| 200 | template<> inline JSDOMRectReadOnly* IDLOperation<JSDOMRectReadOnly>::cast(ExecState& state) |
| 201 | { |
| 202 | return jsDynamicCast<JSDOMRectReadOnly*>(state.vm(), state.thisValue()); |
| 203 | } |
| 204 | |
| 205 | EncodedJSValue jsDOMRectReadOnlyConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 206 | { |
| 207 | VM& vm = state->vm(); |
| 208 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 209 | auto* prototype = jsDynamicCast<JSDOMRectReadOnlyPrototype*>(vm, JSValue::decode(thisValue)); |
| 210 | if (UNLIKELY(!prototype)) |
| 211 | return throwVMTypeError(state, throwScope); |
| 212 | return JSValue::encode(JSDOMRectReadOnly::getConstructor(state->vm(), prototype->globalObject())); |
| 213 | } |
| 214 | |
| 215 | bool setJSDOMRectReadOnlyConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| 216 | { |
| 217 | VM& vm = state->vm(); |
| 218 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 219 | auto* prototype = jsDynamicCast<JSDOMRectReadOnlyPrototype*>(vm, JSValue::decode(thisValue)); |
| 220 | if (UNLIKELY(!prototype)) { |
| 221 | throwVMTypeError(state, throwScope); |
| 222 | return false; |
| 223 | } |
| 224 | // Shadowing a built-in constructor |
| 225 | return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue)); |
| 226 | } |
| 227 | |
| 228 | static inline JSValue jsDOMRectReadOnlyXGetter(ExecState& state, JSDOMRectReadOnly& thisObject, ThrowScope& throwScope) |
| 229 | { |
| 230 | UNUSED_PARAM(throwScope); |
| 231 | UNUSED_PARAM(state); |
| 232 | auto& impl = thisObject.wrapped(); |
| 233 | JSValue result = toJS<IDLUnrestrictedDouble>(state, throwScope, impl.x()); |
| 234 | return result; |
| 235 | } |
| 236 | |
| 237 | EncodedJSValue jsDOMRectReadOnlyX(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 238 | { |
| 239 | return IDLAttribute<JSDOMRectReadOnly>::get<jsDOMRectReadOnlyXGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "x" ); |
| 240 | } |
| 241 | |
| 242 | static inline JSValue jsDOMRectReadOnlyYGetter(ExecState& state, JSDOMRectReadOnly& thisObject, ThrowScope& throwScope) |
| 243 | { |
| 244 | UNUSED_PARAM(throwScope); |
| 245 | UNUSED_PARAM(state); |
| 246 | auto& impl = thisObject.wrapped(); |
| 247 | JSValue result = toJS<IDLUnrestrictedDouble>(state, throwScope, impl.y()); |
| 248 | return result; |
| 249 | } |
| 250 | |
| 251 | EncodedJSValue jsDOMRectReadOnlyY(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 252 | { |
| 253 | return IDLAttribute<JSDOMRectReadOnly>::get<jsDOMRectReadOnlyYGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "y" ); |
| 254 | } |
| 255 | |
| 256 | static inline JSValue jsDOMRectReadOnlyWidthGetter(ExecState& state, JSDOMRectReadOnly& thisObject, ThrowScope& throwScope) |
| 257 | { |
| 258 | UNUSED_PARAM(throwScope); |
| 259 | UNUSED_PARAM(state); |
| 260 | auto& impl = thisObject.wrapped(); |
| 261 | JSValue result = toJS<IDLUnrestrictedDouble>(state, throwScope, impl.width()); |
| 262 | return result; |
| 263 | } |
| 264 | |
| 265 | EncodedJSValue jsDOMRectReadOnlyWidth(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 266 | { |
| 267 | return IDLAttribute<JSDOMRectReadOnly>::get<jsDOMRectReadOnlyWidthGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "width" ); |
| 268 | } |
| 269 | |
| 270 | static inline JSValue jsDOMRectReadOnlyHeightGetter(ExecState& state, JSDOMRectReadOnly& thisObject, ThrowScope& throwScope) |
| 271 | { |
| 272 | UNUSED_PARAM(throwScope); |
| 273 | UNUSED_PARAM(state); |
| 274 | auto& impl = thisObject.wrapped(); |
| 275 | JSValue result = toJS<IDLUnrestrictedDouble>(state, throwScope, impl.height()); |
| 276 | return result; |
| 277 | } |
| 278 | |
| 279 | EncodedJSValue jsDOMRectReadOnlyHeight(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 280 | { |
| 281 | return IDLAttribute<JSDOMRectReadOnly>::get<jsDOMRectReadOnlyHeightGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "height" ); |
| 282 | } |
| 283 | |
| 284 | static inline JSValue jsDOMRectReadOnlyTopGetter(ExecState& state, JSDOMRectReadOnly& thisObject, ThrowScope& throwScope) |
| 285 | { |
| 286 | UNUSED_PARAM(throwScope); |
| 287 | UNUSED_PARAM(state); |
| 288 | auto& impl = thisObject.wrapped(); |
| 289 | JSValue result = toJS<IDLUnrestrictedDouble>(state, throwScope, impl.top()); |
| 290 | return result; |
| 291 | } |
| 292 | |
| 293 | EncodedJSValue jsDOMRectReadOnlyTop(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 294 | { |
| 295 | return IDLAttribute<JSDOMRectReadOnly>::get<jsDOMRectReadOnlyTopGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "top" ); |
| 296 | } |
| 297 | |
| 298 | static inline JSValue jsDOMRectReadOnlyRightGetter(ExecState& state, JSDOMRectReadOnly& thisObject, ThrowScope& throwScope) |
| 299 | { |
| 300 | UNUSED_PARAM(throwScope); |
| 301 | UNUSED_PARAM(state); |
| 302 | auto& impl = thisObject.wrapped(); |
| 303 | JSValue result = toJS<IDLUnrestrictedDouble>(state, throwScope, impl.right()); |
| 304 | return result; |
| 305 | } |
| 306 | |
| 307 | EncodedJSValue jsDOMRectReadOnlyRight(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 308 | { |
| 309 | return IDLAttribute<JSDOMRectReadOnly>::get<jsDOMRectReadOnlyRightGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "right" ); |
| 310 | } |
| 311 | |
| 312 | static inline JSValue jsDOMRectReadOnlyBottomGetter(ExecState& state, JSDOMRectReadOnly& thisObject, ThrowScope& throwScope) |
| 313 | { |
| 314 | UNUSED_PARAM(throwScope); |
| 315 | UNUSED_PARAM(state); |
| 316 | auto& impl = thisObject.wrapped(); |
| 317 | JSValue result = toJS<IDLUnrestrictedDouble>(state, throwScope, impl.bottom()); |
| 318 | return result; |
| 319 | } |
| 320 | |
| 321 | EncodedJSValue jsDOMRectReadOnlyBottom(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 322 | { |
| 323 | return IDLAttribute<JSDOMRectReadOnly>::get<jsDOMRectReadOnlyBottomGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "bottom" ); |
| 324 | } |
| 325 | |
| 326 | static inline JSValue jsDOMRectReadOnlyLeftGetter(ExecState& state, JSDOMRectReadOnly& thisObject, ThrowScope& throwScope) |
| 327 | { |
| 328 | UNUSED_PARAM(throwScope); |
| 329 | UNUSED_PARAM(state); |
| 330 | auto& impl = thisObject.wrapped(); |
| 331 | JSValue result = toJS<IDLUnrestrictedDouble>(state, throwScope, impl.left()); |
| 332 | return result; |
| 333 | } |
| 334 | |
| 335 | EncodedJSValue jsDOMRectReadOnlyLeft(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 336 | { |
| 337 | return IDLAttribute<JSDOMRectReadOnly>::get<jsDOMRectReadOnlyLeftGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "left" ); |
| 338 | } |
| 339 | |
| 340 | static inline JSC::EncodedJSValue jsDOMRectReadOnlyConstructorFunctionFromRectBody(JSC::ExecState* state, JSC::ThrowScope& throwScope) |
| 341 | { |
| 342 | UNUSED_PARAM(state); |
| 343 | UNUSED_PARAM(throwScope); |
| 344 | auto other = convert<IDLDictionary<DOMRectInit>>(*state, state->argument(0)); |
| 345 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 346 | return JSValue::encode(toJSNewlyCreated<IDLInterface<DOMRectReadOnly>>(*state, *jsCast<JSDOMGlobalObject*>(state->lexicalGlobalObject()), DOMRectReadOnly::fromRect(WTFMove(other)))); |
| 347 | } |
| 348 | |
| 349 | EncodedJSValue JSC_HOST_CALL jsDOMRectReadOnlyConstructorFunctionFromRect(ExecState* state) |
| 350 | { |
| 351 | return IDLOperation<JSDOMRectReadOnly>::callStatic<jsDOMRectReadOnlyConstructorFunctionFromRectBody>(*state, "fromRect" ); |
| 352 | } |
| 353 | |
| 354 | JSC::JSObject* JSDOMRectReadOnly::serialize(ExecState& state, JSDOMRectReadOnly& thisObject, JSDOMGlobalObject& globalObject, ThrowScope& throwScope) |
| 355 | { |
| 356 | auto& vm = state.vm(); |
| 357 | auto* result = constructEmptyObject(&state, globalObject.objectPrototype()); |
| 358 | |
| 359 | auto xValue = jsDOMRectReadOnlyXGetter(state, thisObject, throwScope); |
| 360 | throwScope.assertNoException(); |
| 361 | result->putDirect(vm, Identifier::fromString(&vm, "x" ), xValue); |
| 362 | |
| 363 | auto yValue = jsDOMRectReadOnlyYGetter(state, thisObject, throwScope); |
| 364 | throwScope.assertNoException(); |
| 365 | result->putDirect(vm, Identifier::fromString(&vm, "y" ), yValue); |
| 366 | |
| 367 | auto widthValue = jsDOMRectReadOnlyWidthGetter(state, thisObject, throwScope); |
| 368 | throwScope.assertNoException(); |
| 369 | result->putDirect(vm, Identifier::fromString(&vm, "width" ), widthValue); |
| 370 | |
| 371 | auto heightValue = jsDOMRectReadOnlyHeightGetter(state, thisObject, throwScope); |
| 372 | throwScope.assertNoException(); |
| 373 | result->putDirect(vm, Identifier::fromString(&vm, "height" ), heightValue); |
| 374 | |
| 375 | auto topValue = jsDOMRectReadOnlyTopGetter(state, thisObject, throwScope); |
| 376 | throwScope.assertNoException(); |
| 377 | result->putDirect(vm, Identifier::fromString(&vm, "top" ), topValue); |
| 378 | |
| 379 | auto rightValue = jsDOMRectReadOnlyRightGetter(state, thisObject, throwScope); |
| 380 | throwScope.assertNoException(); |
| 381 | result->putDirect(vm, Identifier::fromString(&vm, "right" ), rightValue); |
| 382 | |
| 383 | auto bottomValue = jsDOMRectReadOnlyBottomGetter(state, thisObject, throwScope); |
| 384 | throwScope.assertNoException(); |
| 385 | result->putDirect(vm, Identifier::fromString(&vm, "bottom" ), bottomValue); |
| 386 | |
| 387 | auto leftValue = jsDOMRectReadOnlyLeftGetter(state, thisObject, throwScope); |
| 388 | throwScope.assertNoException(); |
| 389 | result->putDirect(vm, Identifier::fromString(&vm, "left" ), leftValue); |
| 390 | |
| 391 | return result; |
| 392 | } |
| 393 | |
| 394 | static inline EncodedJSValue jsDOMRectReadOnlyPrototypeFunctionToJSONBody(ExecState* state, JSDOMRectReadOnly* thisObject, JSC::ThrowScope& throwScope) |
| 395 | { |
| 396 | return JSValue::encode(JSDOMRectReadOnly::serialize(*state, *thisObject, *thisObject->globalObject(), throwScope)); |
| 397 | } |
| 398 | |
| 399 | EncodedJSValue JSC_HOST_CALL jsDOMRectReadOnlyPrototypeFunctionToJSON(ExecState* state) |
| 400 | { |
| 401 | return IDLOperation<JSDOMRectReadOnly>::call<jsDOMRectReadOnlyPrototypeFunctionToJSONBody>(*state, "toJSON" ); |
| 402 | } |
| 403 | |
| 404 | void JSDOMRectReadOnly::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) |
| 405 | { |
| 406 | auto* thisObject = jsCast<JSDOMRectReadOnly*>(cell); |
| 407 | builder.setWrappedObjectForCell(cell, &thisObject->wrapped()); |
| 408 | if (thisObject->scriptExecutionContext()) |
| 409 | builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); |
| 410 | Base::heapSnapshot(cell, builder); |
| 411 | } |
| 412 | |
| 413 | bool JSDOMRectReadOnlyOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor, const char** reason) |
| 414 | { |
| 415 | auto* jsDOMRectReadOnly = jsCast<JSDOMRectReadOnly*>(handle.slot()->asCell()); |
| 416 | DOMRectReadOnly* root = &jsDOMRectReadOnly->wrapped(); |
| 417 | if (UNLIKELY(reason)) |
| 418 | *reason = "Reachable from DOMRectReadOnly" ; |
| 419 | return visitor.containsOpaqueRoot(root); |
| 420 | } |
| 421 | |
| 422 | void JSDOMRectReadOnlyOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context) |
| 423 | { |
| 424 | auto* jsDOMRectReadOnly = static_cast<JSDOMRectReadOnly*>(handle.slot()->asCell()); |
| 425 | auto& world = *static_cast<DOMWrapperWorld*>(context); |
| 426 | uncacheWrapper(world, &jsDOMRectReadOnly->wrapped(), jsDOMRectReadOnly); |
| 427 | } |
| 428 | |
| 429 | JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<DOMRectReadOnly>&& impl) |
| 430 | { |
| 431 | // If you hit this failure the interface definition has the ImplementationLacksVTable |
| 432 | // attribute. You should remove that attribute. If the class has subclasses |
| 433 | // that may be passed through this toJS() function you should use the SkipVTableValidation |
| 434 | // attribute to DOMRectReadOnly. |
| 435 | static_assert(!std::is_polymorphic<DOMRectReadOnly>::value, "DOMRectReadOnly is polymorphic but the IDL claims it is not" ); |
| 436 | return createWrapper<DOMRectReadOnly>(globalObject, WTFMove(impl)); |
| 437 | } |
| 438 | |
| 439 | JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, DOMRectReadOnly& impl) |
| 440 | { |
| 441 | return wrap(state, globalObject, impl); |
| 442 | } |
| 443 | |
| 444 | DOMRectReadOnly* JSDOMRectReadOnly::toWrapped(JSC::VM& vm, JSC::JSValue value) |
| 445 | { |
| 446 | if (auto* wrapper = jsDynamicCast<JSDOMRectReadOnly*>(vm, value)) |
| 447 | return &wrapper->wrapped(); |
| 448 | return nullptr; |
| 449 | } |
| 450 | |
| 451 | } |
| 452 | |