1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 09:27:35 +00:00

LibWeb: Remove DOM element deprecated_get_attribute()

This commit is contained in:
Bastiaan van der Plaat 2024-01-16 19:04:45 +01:00 committed by Andrew Kaster
parent c477f90df7
commit a681429dff
40 changed files with 114 additions and 122 deletions

View file

@ -54,10 +54,10 @@ void SVGForeignObjectElement::apply_presentational_hints(CSS::StyleProperties& s
{
Base::apply_presentational_hints(style);
auto parsing_context = CSS::Parser::ParsingContext { document() };
if (auto width_value = parse_css_value(parsing_context, deprecated_attribute(Web::HTML::AttributeNames::width), CSS::PropertyID::Width))
if (auto width_value = parse_css_value(parsing_context, get_attribute_value(Web::HTML::AttributeNames::width), CSS::PropertyID::Width))
style.set_property(CSS::PropertyID::Width, width_value.release_nonnull());
if (auto height_value = parse_css_value(parsing_context, deprecated_attribute(Web::HTML::AttributeNames::height), CSS::PropertyID::Height))
if (auto height_value = parse_css_value(parsing_context, get_attribute_value(Web::HTML::AttributeNames::height), CSS::PropertyID::Height))
style.set_property(CSS::PropertyID::Height, height_value.release_nonnull());
}

View file

@ -94,9 +94,9 @@ JS::GCPtr<SVGGradientElement const> SVGGradientElement::linked_gradient() const
// FIXME: This entire function is an ad-hoc hack!
// It can only resolve #<ids> in the same document.
auto link = has_attribute(AttributeNames::href) ? deprecated_get_attribute(AttributeNames::href) : deprecated_get_attribute("xlink:href"_fly_string);
if (auto href = link; !href.is_empty()) {
auto url = document().parse_url(href);
auto link = has_attribute(AttributeNames::href) ? get_attribute(AttributeNames::href) : get_attribute("xlink:href"_fly_string);
if (auto href = link; href.has_value() && !link->is_empty()) {
auto url = document().parse_url(*href);
auto id = url.fragment();
if (!id.has_value() || id->is_empty())
return {};

View file

@ -42,7 +42,7 @@ void SVGSVGElement::apply_presentational_hints(CSS::StyleProperties& style) cons
auto width_attribute = attribute(SVG::AttributeNames::width);
auto parsing_context = CSS::Parser::ParsingContext { document(), CSS::Parser::ParsingContext::Mode::SVGPresentationAttribute };
if (auto width_value = parse_css_value(parsing_context, deprecated_attribute(Web::HTML::AttributeNames::width), CSS::PropertyID::Width)) {
if (auto width_value = parse_css_value(parsing_context, width_attribute.value_or(String {}), CSS::PropertyID::Width)) {
style.set_property(CSS::PropertyID::Width, width_value.release_nonnull());
} else if (width_attribute == "") {
// If the `width` attribute is an empty string, it defaults to 100%.
@ -53,7 +53,7 @@ void SVGSVGElement::apply_presentational_hints(CSS::StyleProperties& style) cons
// Height defaults to 100%
auto height_attribute = attribute(SVG::AttributeNames::height);
if (auto height_value = parse_css_value(parsing_context, deprecated_attribute(Web::HTML::AttributeNames::height), CSS::PropertyID::Height)) {
if (auto height_value = parse_css_value(parsing_context, height_attribute.value_or(String {}), CSS::PropertyID::Height)) {
style.set_property(CSS::PropertyID::Height, height_value.release_nonnull());
} else if (height_attribute == "") {
// If the `height` attribute is an empty string, it defaults to 100%.
@ -84,15 +84,15 @@ void SVGSVGElement::update_fallback_view_box_for_svg_as_image()
Optional<double> width;
Optional<double> height;
auto width_attribute = deprecated_attribute(SVG::AttributeNames::width);
auto width_attribute = get_attribute_value(SVG::AttributeNames::width);
auto parsing_context = CSS::Parser::ParsingContext { document() };
if (auto width_value = parse_css_value(parsing_context, deprecated_attribute(Web::HTML::AttributeNames::width), CSS::PropertyID::Width)) {
if (auto width_value = parse_css_value(parsing_context, width_attribute, CSS::PropertyID::Width)) {
if (width_value->is_length() && width_value->as_length().length().is_absolute())
width = width_value->as_length().length().absolute_length_to_px().to_double();
}
auto height_attribute = deprecated_attribute(SVG::AttributeNames::height);
if (auto height_value = parse_css_value(parsing_context, deprecated_attribute(Web::HTML::AttributeNames::height), CSS::PropertyID::Height)) {
auto height_attribute = get_attribute_value(SVG::AttributeNames::height);
if (auto height_value = parse_css_value(parsing_context, height_attribute, CSS::PropertyID::Height)) {
if (height_value->is_length() && height_value->as_length().length().is_absolute())
height = height_value->as_length().length().absolute_length_to_px().to_double();
}

View file

@ -107,7 +107,7 @@ void SVGUseElement::svg_element_removed(SVGElement& svg_element)
return;
}
if (svg_element.deprecated_attribute("id"_fly_string).matches(m_referenced_id.value())) {
if (AK::StringUtils::matches(svg_element.get_attribute_value("id"_fly_string), m_referenced_id.value())) {
shadow_root()->remove_all_children();
}
}