1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 12:58:12 +00:00

LibWeb: Use a Variant for SimpleSelector's contents

This reduces SimpleSelector's size from 112 bytes to 80 bytes. :^)
This commit is contained in:
Sam Atkins 2022-03-21 15:43:59 +00:00 committed by Andreas Kling
parent 218a9af6b3
commit c0db19f63c
6 changed files with 96 additions and 77 deletions

View file

@ -301,15 +301,15 @@ static inline bool matches(CSS::Selector::SimpleSelector const& component, DOM::
case CSS::Selector::SimpleSelector::Type::Universal:
return true;
case CSS::Selector::SimpleSelector::Type::Id:
return component.value == element.attribute(HTML::AttributeNames::id);
return component.name() == element.attribute(HTML::AttributeNames::id);
case CSS::Selector::SimpleSelector::Type::Class:
return element.has_class(component.value);
return element.has_class(component.name());
case CSS::Selector::SimpleSelector::Type::TagName:
return component.value == element.local_name();
return component.name() == element.local_name();
case CSS::Selector::SimpleSelector::Type::Attribute:
return matches_attribute(component.attribute, element);
return matches_attribute(component.attribute(), element);
case CSS::Selector::SimpleSelector::Type::PseudoClass:
return matches_pseudo_class(component.pseudo_class, element);
return matches_pseudo_class(component.pseudo_class(), element);
case CSS::Selector::SimpleSelector::Type::PseudoElement:
// Pseudo-element matching/not-matching is handled in the top level matches().
return true;