Skip to content

Commit 0a8eb59

Browse files
committed
LibWeb: Remove Deprecated*String usage in SelectorEngine
1 parent bb43bd2 commit 0a8eb59

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

Userland/Libraries/LibWeb/CSS/SelectorEngine.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ static inline bool matches_attribute(CSS::Selector::SimpleSelector::Attribute co
129129
{
130130
// FIXME: Check the attribute's namespace, once we support that in DOM::Element!
131131

132-
auto attribute_name = attribute.qualified_name.name.name.to_deprecated_fly_string();
132+
auto const& attribute_name = attribute.qualified_name.name.name;
133133

134134
if (attribute.match_type == CSS::Selector::SimpleSelector::Attribute::MatchType::HasAttribute) {
135135
// Early way out in case of an attribute existence selector.
@@ -144,14 +144,14 @@ static inline bool matches_attribute(CSS::Selector::SimpleSelector::Attribute co
144144
switch (attribute.match_type) {
145145
case CSS::Selector::SimpleSelector::Attribute::MatchType::ExactValueMatch:
146146
return case_insensitive_match
147-
? Infra::is_ascii_case_insensitive_match(element.deprecated_attribute(attribute_name), attribute.value)
148-
: element.deprecated_attribute(attribute_name) == attribute.value.to_deprecated_string();
147+
? Infra::is_ascii_case_insensitive_match(element.attribute(attribute_name).value_or({}), attribute.value)
148+
: element.attribute(attribute_name) == attribute.value;
149149
case CSS::Selector::SimpleSelector::Attribute::MatchType::ContainsWord: {
150150
if (attribute.value.is_empty()) {
151151
// This selector is always false is match value is empty.
152152
return false;
153153
}
154-
auto const view = element.deprecated_attribute(attribute_name).split_view(' ');
154+
auto const view = element.attribute(attribute_name).value_or({}).bytes_as_string_view().split_view(' ');
155155
auto const size = view.size();
156156
for (size_t i = 0; i < size; ++i) {
157157
auto const value = view.at(i);
@@ -165,9 +165,9 @@ static inline bool matches_attribute(CSS::Selector::SimpleSelector::Attribute co
165165
}
166166
case CSS::Selector::SimpleSelector::Attribute::MatchType::ContainsString:
167167
return !attribute.value.is_empty()
168-
&& element.deprecated_attribute(attribute_name).contains(attribute.value, case_sensitivity);
168+
&& element.attribute(attribute_name).value_or({}).contains(attribute.value, case_sensitivity);
169169
case CSS::Selector::SimpleSelector::Attribute::MatchType::StartsWithSegment: {
170-
auto const element_attr_value = element.deprecated_attribute(attribute_name);
170+
auto const element_attr_value = element.attribute(attribute_name).value_or({});
171171
if (element_attr_value.is_empty()) {
172172
// If the attribute value on element is empty, the selector is true
173173
// if the match value is also empty and false otherwise.
@@ -176,17 +176,17 @@ static inline bool matches_attribute(CSS::Selector::SimpleSelector::Attribute co
176176
if (attribute.value.is_empty()) {
177177
return false;
178178
}
179-
auto segments = element_attr_value.split_view('-');
179+
auto segments = element_attr_value.bytes_as_string_view().split_view('-');
180180
return case_insensitive_match
181181
? Infra::is_ascii_case_insensitive_match(segments.first(), attribute.value)
182182
: segments.first() == attribute.value;
183183
}
184184
case CSS::Selector::SimpleSelector::Attribute::MatchType::StartsWithString:
185185
return !attribute.value.is_empty()
186-
&& element.deprecated_attribute(attribute_name).starts_with(attribute.value, case_sensitivity);
186+
&& element.attribute(attribute_name).value_or({}).bytes_as_string_view().starts_with(attribute.value, case_sensitivity);
187187
case CSS::Selector::SimpleSelector::Attribute::MatchType::EndsWithString:
188188
return !attribute.value.is_empty()
189-
&& element.deprecated_attribute(attribute_name).ends_with(attribute.value, case_sensitivity);
189+
&& element.attribute(attribute_name).value_or({}).bytes_as_string_view().ends_with(attribute.value, case_sensitivity);
190190
default:
191191
break;
192192
}
@@ -275,7 +275,7 @@ static inline bool matches_pseudo_class(CSS::Selector::SimpleSelector::PseudoCla
275275
if (!matches_link_pseudo_class(element))
276276
return false;
277277
auto document_url = element.document().url();
278-
AK::URL target_url = element.document().parse_url(element.deprecated_attribute(HTML::AttributeNames::href));
278+
AK::URL target_url = element.document().parse_url(element.attribute(HTML::AttributeNames::href).value_or({}));
279279
if (target_url.fragment().has_value())
280280
return document_url.equals(target_url, AK::URL::ExcludeFragment::No);
281281
return document_url.equals(target_url, AK::URL::ExcludeFragment::Yes);

0 commit comments

Comments
 (0)