mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-05-21 10:38:24 +00:00
LibWeb: Make Element::has_class() an inline function
This is extremely hot when running CSS selectors, so let's make it easier for it to be inlined.
This commit is contained in:
@@ -374,19 +374,6 @@ Vector<String> Element::get_attribute_names() const
|
||||
return names;
|
||||
}
|
||||
|
||||
bool Element::has_class(FlyString const& class_name, CaseSensitivity case_sensitivity) const
|
||||
{
|
||||
if (case_sensitivity == CaseSensitivity::CaseSensitive) {
|
||||
return any_of(m_classes, [&](auto& it) {
|
||||
return it == class_name;
|
||||
});
|
||||
} else {
|
||||
return any_of(m_classes, [&](auto& it) {
|
||||
return it.equals_ignoring_ascii_case(class_name);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
JS::GCPtr<Layout::Node> Element::create_layout_node(NonnullRefPtr<CSS::StyleProperties> style)
|
||||
{
|
||||
if (local_name() == "noscript" && document().is_scripting_enabled())
|
||||
|
||||
@@ -470,6 +470,18 @@ inline Element const* Node::parent_element() const
|
||||
return static_cast<Element const*>(parent);
|
||||
}
|
||||
|
||||
inline bool Element::has_class(FlyString const& class_name, CaseSensitivity case_sensitivity) const
|
||||
{
|
||||
if (case_sensitivity == CaseSensitivity::CaseSensitive) {
|
||||
return any_of(m_classes, [&](auto& it) {
|
||||
return it == class_name;
|
||||
});
|
||||
}
|
||||
return any_of(m_classes, [&](auto& it) {
|
||||
return it.equals_ignoring_ascii_case(class_name);
|
||||
});
|
||||
}
|
||||
|
||||
WebIDL::ExceptionOr<QualifiedName> validate_and_extract(JS::Realm&, Optional<FlyString> namespace_, FlyString const& qualified_name);
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user