mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-20 03:25:13 +00:00
LibWeb+WebContent: Include rule count in listed CSS style sheets
This commit is contained in:
parent
576eede2b1
commit
cf601a49bb
Notes:
github-actions[bot]
2025-03-13 20:57:30 +00:00
Author: https://github.com/trflynn89 Commit: https://github.com/LadybirdBrowser/ladybird/commit/cf601a49bb4 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3920
3 changed files with 12 additions and 3 deletions
|
@ -52,6 +52,7 @@ ErrorOr<void> encode(Encoder& encoder, Web::CSS::StyleSheetIdentifier const& sty
|
|||
TRY(encoder.encode(style_sheet_source.type));
|
||||
TRY(encoder.encode(style_sheet_source.dom_element_unique_id.map([](auto value) { return value.value(); })));
|
||||
TRY(encoder.encode(style_sheet_source.url));
|
||||
TRY(encoder.encode(style_sheet_source.rule_count));
|
||||
|
||||
return {};
|
||||
}
|
||||
|
@ -62,11 +63,13 @@ 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<Web::UniqueNodeID::Type>>());
|
||||
auto url = TRY(decoder.decode<Optional<String>>());
|
||||
auto rule_count = TRY(decoder.decode<size_t>());
|
||||
|
||||
return Web::CSS::StyleSheetIdentifier {
|
||||
.type = type,
|
||||
.dom_element_unique_id = dom_element_unique_id.map([](auto value) -> Web::UniqueNodeID { return value; }),
|
||||
.url = move(url),
|
||||
.rule_count = rule_count,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -19,9 +19,12 @@ struct StyleSheetIdentifier {
|
|||
ImportRule,
|
||||
UserAgent,
|
||||
UserStyle,
|
||||
} type;
|
||||
};
|
||||
|
||||
Type type;
|
||||
Optional<UniqueNodeID> dom_element_unique_id {};
|
||||
Optional<String> url {};
|
||||
size_t rule_count { 0 };
|
||||
};
|
||||
|
||||
StringView style_sheet_identifier_type_to_string(StyleSheetIdentifier::Type);
|
||||
|
|
|
@ -896,6 +896,7 @@ static void gather_style_sheets(Vector<Web::CSS::StyleSheetIdentifier>& results,
|
|||
if (auto location = sheet.location(); location.has_value())
|
||||
identifier.url = location.release_value();
|
||||
|
||||
identifier.rule_count = sheet.rules().length();
|
||||
results.append(move(identifier));
|
||||
}
|
||||
|
||||
|
@ -904,8 +905,10 @@ static void gather_style_sheets(Vector<Web::CSS::StyleSheetIdentifier>& results,
|
|||
gather_style_sheets(results, *import_rule->loaded_style_sheet());
|
||||
} else {
|
||||
// We can gather this anyway, and hope it loads later
|
||||
results.append({ .type = Web::CSS::StyleSheetIdentifier::Type::ImportRule,
|
||||
.url = import_rule->url().to_string() });
|
||||
results.append({
|
||||
.type = Web::CSS::StyleSheetIdentifier::Type::ImportRule,
|
||||
.url = import_rule->url().to_string(),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue