LibWeb: Make DOM Node unique IDs strongly typed (and 64 bit)

This is strictly nicer than passing them around as i32 everywhere,
and by switching to i64 as the underlying type, ID allocation becomes as
simple as incrementing an integer.
This commit is contained in:
Andreas Kling 2024-10-20 10:37:44 +02:00 committed by Andreas Kling
commit 4fdb266077
Notes: github-actions[bot] 2024-10-20 11:43:23 +00:00
28 changed files with 227 additions and 189 deletions

View file

@ -50,7 +50,8 @@ template<>
ErrorOr<void> encode(Encoder& encoder, Web::CSS::StyleSheetIdentifier const& style_sheet_source)
{
TRY(encoder.encode(style_sheet_source.type));
TRY(encoder.encode(style_sheet_source.dom_element_unique_id));
Optional<i64> dom_element_unique_id = style_sheet_source.dom_element_unique_id.has_value() ? Optional<i64>(style_sheet_source.dom_element_unique_id.value()) : Optional<i64> {};
TRY(encoder.encode(dom_element_unique_id));
TRY(encoder.encode(style_sheet_source.url));
return {};
@ -60,12 +61,12 @@ template<>
ErrorOr<Web::CSS::StyleSheetIdentifier> decode(Decoder& decoder)
{
auto type = TRY(decoder.decode<Web::CSS::StyleSheetIdentifier::Type>());
auto dom_element_unique_id = TRY(decoder.decode<Optional<i32>>());
auto dom_element_unique_id = TRY(decoder.decode<Optional<i64>>());
auto url = TRY(decoder.decode<Optional<String>>());
return Web::CSS::StyleSheetIdentifier {
.type = type,
.dom_element_unique_id = move(dom_element_unique_id),
.dom_element_unique_id = dom_element_unique_id.has_value() ? Web::UniqueNodeID(dom_element_unique_id.value()) : Optional<Web::UniqueNodeID> {},
.url = move(url),
};
}