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

LibWeb: Make external StyleValue-parsing methods infallible

This commit is contained in:
Sam Atkins 2023-08-19 15:01:21 +01:00 committed by Andreas Kling
parent 9e1bbfbd37
commit 28c2836c24
13 changed files with 70 additions and 70 deletions

View file

@ -43,7 +43,7 @@ void SVGSVGElement::apply_presentational_hints(CSS::StyleProperties& style) cons
auto width_attribute = attribute(SVG::AttributeNames::width);
auto parsing_context = CSS::Parser::ParsingContext { document() };
if (auto width_value = parse_css_value(parsing_context, attribute(Web::HTML::AttributeNames::width), CSS::PropertyID::Width).release_value_but_fixme_should_propagate_errors()) {
if (auto width_value = parse_css_value(parsing_context, attribute(Web::HTML::AttributeNames::width), 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%.
@ -54,7 +54,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, attribute(Web::HTML::AttributeNames::height), CSS::PropertyID::Height).release_value_but_fixme_should_propagate_errors()) {
if (auto height_value = parse_css_value(parsing_context, attribute(Web::HTML::AttributeNames::height), 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%.
@ -87,13 +87,13 @@ void SVGSVGElement::update_fallback_view_box_for_svg_as_image()
auto width_attribute = attribute(SVG::AttributeNames::width);
auto parsing_context = CSS::Parser::ParsingContext { document() };
if (auto width_value = parse_css_value(parsing_context, attribute(Web::HTML::AttributeNames::width), CSS::PropertyID::Width).release_value_but_fixme_should_propagate_errors()) {
if (auto width_value = parse_css_value(parsing_context, attribute(Web::HTML::AttributeNames::width), 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 = attribute(SVG::AttributeNames::height);
if (auto height_value = parse_css_value(parsing_context, attribute(Web::HTML::AttributeNames::height), CSS::PropertyID::Height).release_value_but_fixme_should_propagate_errors()) {
if (auto height_value = parse_css_value(parsing_context, attribute(Web::HTML::AttributeNames::height), 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();
}