1
0
Fork 0
mirror of https://github.com/LadybirdBrowser/ladybird.git synced 2025-06-08 05:27:14 +09:00
ladybird/Libraries/LibWeb/IndexedDB/IDBOpenDBRequest.cpp
Andreas Kling a6dfc74e93 LibWeb: Only set prototype once for object with IDL interface
Before this change, we were going through the chain of base classes for
each IDL interface object and having them set the prototype to their
prototype.

Instead of doing that, reorder things so that we set the right prototype
immediately in Foo::initialize(), and then don't bother in all the base
class overrides.

This knocks off a ~1% profile item on Speedometer 3.
2025-04-20 18:43:11 +02:00

61 lines
1.7 KiB
C++

/*
* Copyright (c) 2024, Shannon Booth <shannon@serenityos.org>
* Copyright (c) 2024, Jamie Mansfield <jmansfield@cadixdev.org>
* Copyright (c) 2025, stelar7 <dudedbz@gmail.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibWeb/Bindings/IDBOpenDBRequestPrototype.h>
#include <LibWeb/Bindings/Intrinsics.h>
#include <LibWeb/HTML/EventNames.h>
#include <LibWeb/IndexedDB/IDBOpenDBRequest.h>
namespace Web::IndexedDB {
GC_DEFINE_ALLOCATOR(IDBOpenDBRequest);
IDBOpenDBRequest::~IDBOpenDBRequest() = default;
// NOTE: The source of an open request is always null.
IDBOpenDBRequest::IDBOpenDBRequest(JS::Realm& realm)
: IDBRequest(realm, {})
{
}
void IDBOpenDBRequest::initialize(JS::Realm& realm)
{
WEB_SET_PROTOTYPE_FOR_INTERFACE(IDBOpenDBRequest);
Base::initialize(realm);
}
GC::Ref<IDBOpenDBRequest> IDBOpenDBRequest::create(JS::Realm& realm)
{
return realm.create<IDBOpenDBRequest>(realm);
}
// https://w3c.github.io/IndexedDB/#dom-idbopendbrequest-onblocked
void IDBOpenDBRequest::set_onblocked(WebIDL::CallbackType* event_handler)
{
set_event_handler_attribute(HTML::EventNames::blocked, event_handler);
}
// https://w3c.github.io/IndexedDB/#dom-idbopendbrequest-onblocked
WebIDL::CallbackType* IDBOpenDBRequest::onblocked()
{
return event_handler_attribute(HTML::EventNames::blocked);
}
// https://w3c.github.io/IndexedDB/#dom-idbopendbrequest-onupgradeneeded
void IDBOpenDBRequest::set_onupgradeneeded(WebIDL::CallbackType* event_handler)
{
set_event_handler_attribute(HTML::EventNames::upgradeneeded, event_handler);
}
// https://w3c.github.io/IndexedDB/#dom-idbopendbrequest-onupgradeneeded
WebIDL::CallbackType* IDBOpenDBRequest::onupgradeneeded()
{
return event_handler_attribute(HTML::EventNames::upgradeneeded);
}
}