mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 20:15:17 +00:00
LibWeb: Simplify IPC encoding of style sheet DOM node IDs
We were essentially reinventing Optional::map here.
This commit is contained in:
parent
2ee3985fd1
commit
576eede2b1
Notes:
github-actions[bot]
2025-03-13 20:57:37 +00:00
Author: https://github.com/trflynn89 Commit: https://github.com/LadybirdBrowser/ladybird/commit/576eede2b14 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3920
1 changed files with 3 additions and 4 deletions
|
@ -50,8 +50,7 @@ template<>
|
|||
ErrorOr<void> encode(Encoder& encoder, Web::CSS::StyleSheetIdentifier const& style_sheet_source)
|
||||
{
|
||||
TRY(encoder.encode(style_sheet_source.type));
|
||||
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.dom_element_unique_id.map([](auto value) { return value.value(); })));
|
||||
TRY(encoder.encode(style_sheet_source.url));
|
||||
|
||||
return {};
|
||||
|
@ -61,12 +60,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<i64>>());
|
||||
auto dom_element_unique_id = TRY(decoder.decode<Optional<Web::UniqueNodeID::Type>>());
|
||||
auto url = TRY(decoder.decode<Optional<String>>());
|
||||
|
||||
return Web::CSS::StyleSheetIdentifier {
|
||||
.type = type,
|
||||
.dom_element_unique_id = dom_element_unique_id.has_value() ? Web::UniqueNodeID(dom_element_unique_id.value()) : Optional<Web::UniqueNodeID> {},
|
||||
.dom_element_unique_id = dom_element_unique_id.map([](auto value) -> Web::UniqueNodeID { return value; }),
|
||||
.url = move(url),
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue