ladybird/Libraries/LibWeb/IndexedDB/TransactionChanges.h
Sam Atkins e667aaaab1 LibDevTools+LibWeb: Send IndexedDB change updates
The Storage panel expects storesUpdate messages after watched storage
changes. Summarize committed IndexedDB mutation logs into DevTools paths
and forward them through WebContent so Firefox can refresh database,
object-store, and record rows without polling.

Firefox's behaviour is less than ideal here. A lot of things don't
update automatically even inspecting a page in Firefox. Some
things (like new databases) won't show up until you fully refresh the
page. So that makes it a bit hard to know that we're doing things
correctly. As far as I can tell, we are at least behaving as well as
Firefox requires.

We do have one workaround: Firefox doesn't display record updates
without a manual refresh, and in fact any change messages for them show
up as rows in the host's database table. So for now, we filter them out
to avoid visual weirdness in the inspector.
2026-06-19 14:25:39 +02:00

33 lines
621 B
C++

/*
* Copyright (c) 2026, Ladybird contributors
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/JsonValue.h>
#include <AK/Optional.h>
#include <AK/String.h>
#include <AK/Vector.h>
namespace Web::IndexedDB {
struct TransactionChange {
String database_name;
String object_store_name;
Optional<JsonValue> key {};
};
struct TransactionChanges {
Vector<TransactionChange> added;
Vector<TransactionChange> changed;
Vector<TransactionChange> deleted;
bool is_empty() const
{
return added.is_empty() && changed.is_empty() && deleted.is_empty();
}
};
}