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

LibWeb: Propagate errors from parse_css_value and property_initial_value

This commit is contained in:
Sam Atkins 2023-05-02 15:09:46 +01:00 committed by Andreas Kling
parent 294f5b109f
commit f4d8a24fe4
12 changed files with 68 additions and 66 deletions

View file

@ -64,10 +64,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, attribute(Web::HTML::AttributeNames::width), CSS::PropertyID::Width))
if (auto width_value = parse_css_value(parsing_context, attribute(Web::HTML::AttributeNames::width), CSS::PropertyID::Width).release_value_but_fixme_should_propagate_errors())
style.set_property(CSS::PropertyID::Width, width_value.release_nonnull());
if (auto height_value = parse_css_value(parsing_context, attribute(Web::HTML::AttributeNames::height), CSS::PropertyID::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())
style.set_property(CSS::PropertyID::Height, height_value.release_nonnull());
}

View file

@ -111,14 +111,14 @@ void SVGGraphicsElement::apply_presentational_hints(CSS::StyleProperties& style)
for_each_attribute([&](auto& name, auto& value) {
if (name.equals_ignoring_ascii_case("fill"sv)) {
// FIXME: The `fill` attribute and CSS `fill` property are not the same! But our support is limited enough that they are equivalent for now.
if (auto fill_value = parse_css_value(parsing_context, value, CSS::PropertyID::Fill))
if (auto fill_value = parse_css_value(parsing_context, value, CSS::PropertyID::Fill).release_value_but_fixme_should_propagate_errors())
style.set_property(CSS::PropertyID::Fill, fill_value.release_nonnull());
} else if (name.equals_ignoring_ascii_case("stroke"sv)) {
// FIXME: The `stroke` attribute and CSS `stroke` property are not the same! But our support is limited enough that they are equivalent for now.
if (auto stroke_value = parse_css_value(parsing_context, value, CSS::PropertyID::Stroke))
if (auto stroke_value = parse_css_value(parsing_context, value, CSS::PropertyID::Stroke).release_value_but_fixme_should_propagate_errors())
style.set_property(CSS::PropertyID::Stroke, stroke_value.release_nonnull());
} else if (name.equals_ignoring_ascii_case("stroke-width"sv)) {
if (auto stroke_width_value = parse_css_value(parsing_context, value, CSS::PropertyID::StrokeWidth))
if (auto stroke_width_value = parse_css_value(parsing_context, value, CSS::PropertyID::StrokeWidth).release_value_but_fixme_should_propagate_errors())
style.set_property(CSS::PropertyID::StrokeWidth, stroke_width_value.release_nonnull());
}
});

View file

@ -48,7 +48,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)) {
if (auto width_value = parse_css_value(parsing_context, attribute(Web::HTML::AttributeNames::width), CSS::PropertyID::Width).release_value_but_fixme_should_propagate_errors()) {
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%.
@ -59,7 +59,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)) {
if (auto height_value = parse_css_value(parsing_context, attribute(Web::HTML::AttributeNames::height), CSS::PropertyID::Height).release_value_but_fixme_should_propagate_errors()) {
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%.

View file

@ -33,7 +33,7 @@ void SVGStopElement::apply_presentational_hints(CSS::StyleProperties& style) con
for_each_attribute([&](auto& name, auto& value) {
if (name.equals_ignoring_ascii_case("stop-color"sv)) {
CSS::Parser::ParsingContext parsing_context { document() };
if (auto stop_color = parse_css_value(parsing_context, value, CSS::PropertyID::StopColor)) {
if (auto stop_color = parse_css_value(parsing_context, value, CSS::PropertyID::StopColor).release_value_but_fixme_should_propagate_errors()) {
style.set_property(CSS::PropertyID::StopColor, stop_color.release_nonnull());
}
}