diff --git a/Libraries/LibWeb/CSS/StyleSheetIdentifier.cpp b/Libraries/LibWeb/CSS/StyleSheetIdentifier.cpp index d96f3378d0a..c821886def4 100644 --- a/Libraries/LibWeb/CSS/StyleSheetIdentifier.cpp +++ b/Libraries/LibWeb/CSS/StyleSheetIdentifier.cpp @@ -52,6 +52,7 @@ ErrorOr 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 decode(Decoder& decoder) auto type = TRY(decoder.decode()); auto dom_element_unique_id = TRY(decoder.decode>()); auto url = TRY(decoder.decode>()); + auto rule_count = TRY(decoder.decode()); 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, }; } diff --git a/Libraries/LibWeb/CSS/StyleSheetIdentifier.h b/Libraries/LibWeb/CSS/StyleSheetIdentifier.h index 567239887fe..7c2a8a780dd 100644 --- a/Libraries/LibWeb/CSS/StyleSheetIdentifier.h +++ b/Libraries/LibWeb/CSS/StyleSheetIdentifier.h @@ -19,9 +19,12 @@ struct StyleSheetIdentifier { ImportRule, UserAgent, UserStyle, - } type; + }; + + Type type; Optional dom_element_unique_id {}; Optional url {}; + size_t rule_count { 0 }; }; StringView style_sheet_identifier_type_to_string(StyleSheetIdentifier::Type); diff --git a/Services/WebContent/PageClient.cpp b/Services/WebContent/PageClient.cpp index 2e917bae179..3513357160b 100644 --- a/Services/WebContent/PageClient.cpp +++ b/Services/WebContent/PageClient.cpp @@ -896,6 +896,7 @@ static void gather_style_sheets(Vector& 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& 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(), + }); } } }