mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-12-08 06:09:58 +00:00
LibWeb: Don't store custom name on StyleProperty
This reduces time spent in `~StyleProperty()` from 2.18% to 0.67% on https://cloudflare.com.
This commit is contained in:
parent
eb21ea890c
commit
df23b42b37
Notes:
github-actions[bot]
2025-11-12 10:20:48 +00:00
Author: https://github.com/tcl3
Commit: df23b42b37
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6796
Reviewed-by: https://github.com/gmta ✅
6 changed files with 24 additions and 18 deletions
|
|
@ -1269,8 +1269,10 @@ Optional<StyleProperty> Parser::parse_as_supports_condition()
|
|||
m_rule_context.append(RuleContext::SupportsCondition);
|
||||
auto maybe_declaration = parse_a_declaration(m_token_stream);
|
||||
m_rule_context.take_last();
|
||||
if (maybe_declaration.has_value())
|
||||
return convert_to_style_property(maybe_declaration.release_value());
|
||||
if (maybe_declaration.has_value()) {
|
||||
if (auto maybe_property_and_name = convert_to_style_property(maybe_declaration.release_value()); maybe_property_and_name.has_value())
|
||||
return maybe_property_and_name->property;
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
|
|
@ -1596,10 +1598,10 @@ bool Parser::is_valid_in_the_current_context(QualifiedRule const&) const
|
|||
|
||||
void Parser::extract_property(Declaration const& declaration, PropertiesAndCustomProperties& dest)
|
||||
{
|
||||
if (auto maybe_property = convert_to_style_property(declaration); maybe_property.has_value()) {
|
||||
auto property = maybe_property.release_value();
|
||||
if (auto maybe_property_and_name = convert_to_style_property(declaration); maybe_property_and_name.has_value()) {
|
||||
auto property = maybe_property_and_name->property;
|
||||
if (property.property_id == PropertyID::Custom) {
|
||||
dest.custom_properties.set(property.custom_name, property);
|
||||
dest.custom_properties.set(maybe_property_and_name->name, property);
|
||||
} else {
|
||||
dest.properties.append(move(property));
|
||||
}
|
||||
|
|
@ -1616,7 +1618,7 @@ GC::Ref<CSSStyleProperties> Parser::convert_to_style_declaration(Vector<Declarat
|
|||
return CSSStyleProperties::create(realm(), move(properties.properties), move(properties.custom_properties));
|
||||
}
|
||||
|
||||
Optional<StyleProperty> Parser::convert_to_style_property(Declaration const& declaration)
|
||||
Optional<StylePropertyAndName> Parser::convert_to_style_property(Declaration const& declaration)
|
||||
{
|
||||
auto property = PropertyNameAndID::from_name(declaration.name);
|
||||
|
||||
|
|
@ -1642,9 +1644,14 @@ Optional<StyleProperty> Parser::convert_to_style_property(Declaration const& dec
|
|||
}
|
||||
|
||||
if (property->is_custom_property())
|
||||
return StyleProperty { declaration.important, property->id(), value.release_value(), property->name() };
|
||||
return StylePropertyAndName {
|
||||
StyleProperty { declaration.important, property->id(), value.release_value() },
|
||||
property->name()
|
||||
};
|
||||
|
||||
return StyleProperty { declaration.important, property->id(), value.release_value(), {} };
|
||||
return StylePropertyAndName {
|
||||
StyleProperty { declaration.important, property->id(), value.release_value() }
|
||||
};
|
||||
}
|
||||
|
||||
Optional<LengthOrAutoOrCalculated> Parser::parse_source_size_value(TokenStream<ComponentValue>& tokens)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue