mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-11 18:50:50 +00:00
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:
parent
eca2318390
commit
4fdb266077
Notes:
github-actions[bot]
2024-10-20 11:43:23 +00:00
Author: https://github.com/awesomekling
Commit: 4fdb266077
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1878
28 changed files with 227 additions and 189 deletions
|
@ -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),
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue