Files
ladybird/Libraries/LibWeb/HTML/StorageEvent.cpp
Shannon Booth fd44da6829 LibWeb/Bindings: Emit one bindings header and cpp per IDL
Previously, the LibWeb bindings generator would output multiple per
interface files like Prototype/Constructor/Namespace/GlobalMixin
depending on the contents of that IDL file.

This complicates the build system as it means that it does not know
what files will be generated without knowledge of the contents of that
IDL file.

Instead, for each IDL file only generate a single Bindings/<IDLFile>.h
and Bindings/<IDLFile>.cpp.
2026-04-21 07:36:13 +02:00

77 lines
2.2 KiB
C++

/*
* Copyright (c) 2024, Shannon Booth <shannon@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibWeb/Bindings/Intrinsics.h>
#include <LibWeb/Bindings/StorageEvent.h>
#include <LibWeb/HTML/Storage.h>
#include <LibWeb/HTML/StorageEvent.h>
namespace Web::HTML {
GC_DEFINE_ALLOCATOR(StorageEvent);
GC::Ref<StorageEvent> StorageEvent::create(JS::Realm& realm, FlyString const& event_name, StorageEventInit const& event_init)
{
auto event = realm.create<StorageEvent>(realm, event_name, event_init);
event->set_is_trusted(true);
return event;
}
GC::Ref<StorageEvent> StorageEvent::construct_impl(JS::Realm& realm, FlyString const& event_name, StorageEventInit const& event_init)
{
return realm.create<StorageEvent>(realm, event_name, event_init);
}
StorageEvent::~StorageEvent() = default;
// https://html.spec.whatwg.org/multipage/webstorage.html#dom-storageevent-initstorageevent
void StorageEvent::init_storage_event(
String const& type,
bool bubbles,
bool cancelable,
Optional<String> const& key,
Optional<String> const& old_value,
Optional<String> const& new_value,
String const& url,
GC::Ptr<Storage> storage_area)
{
// The initStorageEvent(type, bubbles, cancelable, key, oldValue, newValue, url, storageArea) method must initialize
// the event in a manner analogous to the similarly-named initEvent() method. [DOM]
if (dispatched())
return;
initialize_event(type, bubbles, cancelable);
m_key = key;
m_old_value = old_value;
m_new_value = new_value;
m_url = url;
m_storage_area = storage_area;
}
StorageEvent::StorageEvent(JS::Realm& realm, FlyString const& event_name, StorageEventInit const& event_init)
: DOM::Event(realm, event_name, event_init)
, m_key(event_init.key)
, m_old_value(event_init.old_value)
, m_new_value(event_init.new_value)
, m_url(event_init.url)
, m_storage_area(event_init.storage_area)
{
}
void StorageEvent::initialize(JS::Realm& realm)
{
WEB_SET_PROTOTYPE_FOR_INTERFACE(StorageEvent);
Base::initialize(realm);
}
void StorageEvent::visit_edges(Visitor& visitor)
{
Base::visit_edges(visitor);
visitor.visit(m_storage_area);
}
}