mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 02:17:34 +00:00
LibWeb: Remove Deprecated*String usage in SelectorEngine
This commit is contained in:
parent
bb43bd2dee
commit
0a8eb59a05
1 changed files with 10 additions and 10 deletions
|
@ -129,7 +129,7 @@ static inline bool matches_attribute(CSS::Selector::SimpleSelector::Attribute co
|
||||||
{
|
{
|
||||||
// FIXME: Check the attribute's namespace, once we support that in DOM::Element!
|
// FIXME: Check the attribute's namespace, once we support that in DOM::Element!
|
||||||
|
|
||||||
auto attribute_name = attribute.qualified_name.name.name.to_deprecated_fly_string();
|
auto const& attribute_name = attribute.qualified_name.name.name;
|
||||||
|
|
||||||
if (attribute.match_type == CSS::Selector::SimpleSelector::Attribute::MatchType::HasAttribute) {
|
if (attribute.match_type == CSS::Selector::SimpleSelector::Attribute::MatchType::HasAttribute) {
|
||||||
// Early way out in case of an attribute existence selector.
|
// Early way out in case of an attribute existence selector.
|
||||||
|
@ -144,14 +144,14 @@ static inline bool matches_attribute(CSS::Selector::SimpleSelector::Attribute co
|
||||||
switch (attribute.match_type) {
|
switch (attribute.match_type) {
|
||||||
case CSS::Selector::SimpleSelector::Attribute::MatchType::ExactValueMatch:
|
case CSS::Selector::SimpleSelector::Attribute::MatchType::ExactValueMatch:
|
||||||
return case_insensitive_match
|
return case_insensitive_match
|
||||||
? Infra::is_ascii_case_insensitive_match(element.deprecated_attribute(attribute_name), attribute.value)
|
? Infra::is_ascii_case_insensitive_match(element.attribute(attribute_name).value_or({}), attribute.value)
|
||||||
: element.deprecated_attribute(attribute_name) == attribute.value.to_deprecated_string();
|
: element.attribute(attribute_name) == attribute.value;
|
||||||
case CSS::Selector::SimpleSelector::Attribute::MatchType::ContainsWord: {
|
case CSS::Selector::SimpleSelector::Attribute::MatchType::ContainsWord: {
|
||||||
if (attribute.value.is_empty()) {
|
if (attribute.value.is_empty()) {
|
||||||
// This selector is always false is match value is empty.
|
// This selector is always false is match value is empty.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
auto const view = element.deprecated_attribute(attribute_name).split_view(' ');
|
auto const view = element.attribute(attribute_name).value_or({}).bytes_as_string_view().split_view(' ');
|
||||||
auto const size = view.size();
|
auto const size = view.size();
|
||||||
for (size_t i = 0; i < size; ++i) {
|
for (size_t i = 0; i < size; ++i) {
|
||||||
auto const value = view.at(i);
|
auto const value = view.at(i);
|
||||||
|
@ -165,9 +165,9 @@ static inline bool matches_attribute(CSS::Selector::SimpleSelector::Attribute co
|
||||||
}
|
}
|
||||||
case CSS::Selector::SimpleSelector::Attribute::MatchType::ContainsString:
|
case CSS::Selector::SimpleSelector::Attribute::MatchType::ContainsString:
|
||||||
return !attribute.value.is_empty()
|
return !attribute.value.is_empty()
|
||||||
&& element.deprecated_attribute(attribute_name).contains(attribute.value, case_sensitivity);
|
&& element.attribute(attribute_name).value_or({}).contains(attribute.value, case_sensitivity);
|
||||||
case CSS::Selector::SimpleSelector::Attribute::MatchType::StartsWithSegment: {
|
case CSS::Selector::SimpleSelector::Attribute::MatchType::StartsWithSegment: {
|
||||||
auto const element_attr_value = element.deprecated_attribute(attribute_name);
|
auto const element_attr_value = element.attribute(attribute_name).value_or({});
|
||||||
if (element_attr_value.is_empty()) {
|
if (element_attr_value.is_empty()) {
|
||||||
// If the attribute value on element is empty, the selector is true
|
// If the attribute value on element is empty, the selector is true
|
||||||
// if the match value is also empty and false otherwise.
|
// if the match value is also empty and false otherwise.
|
||||||
|
@ -176,17 +176,17 @@ static inline bool matches_attribute(CSS::Selector::SimpleSelector::Attribute co
|
||||||
if (attribute.value.is_empty()) {
|
if (attribute.value.is_empty()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
auto segments = element_attr_value.split_view('-');
|
auto segments = element_attr_value.bytes_as_string_view().split_view('-');
|
||||||
return case_insensitive_match
|
return case_insensitive_match
|
||||||
? Infra::is_ascii_case_insensitive_match(segments.first(), attribute.value)
|
? Infra::is_ascii_case_insensitive_match(segments.first(), attribute.value)
|
||||||
: segments.first() == attribute.value;
|
: segments.first() == attribute.value;
|
||||||
}
|
}
|
||||||
case CSS::Selector::SimpleSelector::Attribute::MatchType::StartsWithString:
|
case CSS::Selector::SimpleSelector::Attribute::MatchType::StartsWithString:
|
||||||
return !attribute.value.is_empty()
|
return !attribute.value.is_empty()
|
||||||
&& element.deprecated_attribute(attribute_name).starts_with(attribute.value, case_sensitivity);
|
&& element.attribute(attribute_name).value_or({}).bytes_as_string_view().starts_with(attribute.value, case_sensitivity);
|
||||||
case CSS::Selector::SimpleSelector::Attribute::MatchType::EndsWithString:
|
case CSS::Selector::SimpleSelector::Attribute::MatchType::EndsWithString:
|
||||||
return !attribute.value.is_empty()
|
return !attribute.value.is_empty()
|
||||||
&& element.deprecated_attribute(attribute_name).ends_with(attribute.value, case_sensitivity);
|
&& element.attribute(attribute_name).value_or({}).bytes_as_string_view().ends_with(attribute.value, case_sensitivity);
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -275,7 +275,7 @@ static inline bool matches_pseudo_class(CSS::Selector::SimpleSelector::PseudoCla
|
||||||
if (!matches_link_pseudo_class(element))
|
if (!matches_link_pseudo_class(element))
|
||||||
return false;
|
return false;
|
||||||
auto document_url = element.document().url();
|
auto document_url = element.document().url();
|
||||||
AK::URL target_url = element.document().parse_url(element.deprecated_attribute(HTML::AttributeNames::href));
|
AK::URL target_url = element.document().parse_url(element.attribute(HTML::AttributeNames::href).value_or({}));
|
||||||
if (target_url.fragment().has_value())
|
if (target_url.fragment().has_value())
|
||||||
return document_url.equals(target_url, AK::URL::ExcludeFragment::No);
|
return document_url.equals(target_url, AK::URL::ExcludeFragment::No);
|
||||||
return document_url.equals(target_url, AK::URL::ExcludeFragment::Yes);
|
return document_url.equals(target_url, AK::URL::ExcludeFragment::Yes);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue