From 28c2836c2460e4a323daafc788d477cb6cafc41c Mon Sep 17 00:00:00 2001 From: Sam Atkins Date: Sat, 19 Aug 2023 15:01:21 +0100 Subject: [PATCH] LibWeb: Make external StyleValue-parsing methods infallible --- .../LibWeb/GenerateCSSPropertyID.cpp | 6 +- Userland/Libraries/LibWeb/CSS/CSS.cpp | 2 +- .../LibWeb/CSS/CSSStyleDeclaration.cpp | 4 +- .../Libraries/LibWeb/CSS/Parser/Helpers.cpp | 4 +- .../Libraries/LibWeb/CSS/Parser/Parser.cpp | 62 +++++++++---------- Userland/Libraries/LibWeb/CSS/Parser/Parser.h | 6 +- .../Libraries/LibWeb/CSS/StyleComputer.cpp | 14 ++--- .../HTML/Canvas/CanvasTextDrawingStyles.h | 4 +- .../LibWeb/HTML/HTMLTableCellElement.cpp | 4 +- .../LibWeb/SVG/SVGForeignObjectElement.cpp | 4 +- .../LibWeb/SVG/SVGGraphicsElement.cpp | 18 +++--- .../Libraries/LibWeb/SVG/SVGSVGElement.cpp | 8 +-- .../Libraries/LibWeb/SVG/SVGStopElement.cpp | 4 +- 13 files changed, 70 insertions(+), 70 deletions(-) diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSPropertyID.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSPropertyID.cpp index e0c1b53146..29d778b8a5 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSPropertyID.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSPropertyID.cpp @@ -156,7 +156,7 @@ Optional property_id_from_camel_case_string(StringView); Optional property_id_from_string(StringView); StringView string_from_property_id(PropertyID); bool is_inherited_property(PropertyID); -ErrorOr> property_initial_value(JS::Realm&, PropertyID); +NonnullRefPtr property_initial_value(JS::Realm&, PropertyID); enum class ValueType { Angle, @@ -496,7 +496,7 @@ bool property_affects_stacking_context(PropertyID property_id) } } -ErrorOr> property_initial_value(JS::Realm& context_realm, PropertyID property_id) +NonnullRefPtr property_initial_value(JS::Realm& context_realm, PropertyID property_id) { static Array, to_underlying(last_property_id) + 1> initial_values; if (auto initial_value = initial_values[to_underlying(property_id)]) @@ -525,7 +525,7 @@ ErrorOr> property_initial_value(JS::Realm& context_rea TRY(member_generator.try_append( R"~~~( case PropertyID::@name:titlecase@: { - auto parsed_value = TRY(parse_css_value(parsing_context, "@initial_value_string@"sv, PropertyID::@name:titlecase@)); + auto parsed_value = parse_css_value(parsing_context, "@initial_value_string@"sv, PropertyID::@name:titlecase@); VERIFY(!parsed_value.is_null()); auto initial_value = parsed_value.release_nonnull(); initial_values[to_underlying(PropertyID::@name:titlecase@)] = initial_value; diff --git a/Userland/Libraries/LibWeb/CSS/CSS.cpp b/Userland/Libraries/LibWeb/CSS/CSS.cpp index 010a44e7c2..8b987121b6 100644 --- a/Userland/Libraries/LibWeb/CSS/CSS.cpp +++ b/Userland/Libraries/LibWeb/CSS/CSS.cpp @@ -28,7 +28,7 @@ bool supports(JS::VM& vm, StringView property, StringView value) // 1. If property is an ASCII case-insensitive match for any defined CSS property that the UA supports, // and value successfully parses according to that property’s grammar, return true. if (auto property_id = property_id_from_string(property); property_id.has_value()) { - if (parse_css_value(Parser::ParsingContext { realm }, value, property_id.value()).release_value_but_fixme_should_propagate_errors()) + if (parse_css_value(Parser::ParsingContext { realm }, value, property_id.value())) return true; } diff --git a/Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.cpp b/Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.cpp index 352f1fee3f..92f10d6909 100644 --- a/Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.cpp +++ b/Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.cpp @@ -100,8 +100,8 @@ WebIDL::ExceptionOr PropertyOwningCSSStyleDeclaration::set_property(Proper // 5. Let component value list be the result of parsing value for property property. auto component_value_list = is(this) - ? MUST(parse_css_value(CSS::Parser::ParsingContext { static_cast(*this).element()->document() }, value, property_id)) - : MUST(parse_css_value(CSS::Parser::ParsingContext { realm() }, value, property_id)); + ? parse_css_value(CSS::Parser::ParsingContext { static_cast(*this).element()->document() }, value, property_id) + : parse_css_value(CSS::Parser::ParsingContext { realm() }, value, property_id); // 6. If component value list is null, then return. if (!component_value_list) diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Helpers.cpp b/Userland/Libraries/LibWeb/CSS/Parser/Helpers.cpp index 362a40c385..c7c053b351 100644 --- a/Userland/Libraries/LibWeb/CSS/Parser/Helpers.cpp +++ b/Userland/Libraries/LibWeb/CSS/Parser/Helpers.cpp @@ -34,11 +34,11 @@ CSS::ElementInlineCSSStyleDeclaration* parse_css_style_attribute(CSS::Parser::Pa return parser.parse_as_style_attribute(element); } -ErrorOr> parse_css_value(CSS::Parser::ParsingContext const& context, StringView string, CSS::PropertyID property_id) +RefPtr parse_css_value(CSS::Parser::ParsingContext const& context, StringView string, CSS::PropertyID property_id) { if (string.is_empty()) return nullptr; - auto parser = TRY(CSS::Parser::Parser::create(context, string)); + auto parser = MUST(CSS::Parser::Parser::create(context, string)); return parser.parse_as_css_value(property_id); } diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp index e0cbc9233c..94f318e7a5 100644 --- a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp +++ b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp @@ -2717,14 +2717,14 @@ RefPtr Parser::parse_background_value(Vector const& StyleValueVector background_origins; RefPtr background_color; - auto initial_background_image = MUST(property_initial_value(m_context.realm(), PropertyID::BackgroundImage)); - auto initial_background_position = MUST(property_initial_value(m_context.realm(), PropertyID::BackgroundPosition)); - auto initial_background_size = MUST(property_initial_value(m_context.realm(), PropertyID::BackgroundSize)); - auto initial_background_repeat = MUST(property_initial_value(m_context.realm(), PropertyID::BackgroundRepeat)); - auto initial_background_attachment = MUST(property_initial_value(m_context.realm(), PropertyID::BackgroundAttachment)); - auto initial_background_clip = MUST(property_initial_value(m_context.realm(), PropertyID::BackgroundClip)); - auto initial_background_origin = MUST(property_initial_value(m_context.realm(), PropertyID::BackgroundOrigin)); - auto initial_background_color = MUST(property_initial_value(m_context.realm(), PropertyID::BackgroundColor)); + auto initial_background_image = property_initial_value(m_context.realm(), PropertyID::BackgroundImage); + auto initial_background_position = property_initial_value(m_context.realm(), PropertyID::BackgroundPosition); + auto initial_background_size = property_initial_value(m_context.realm(), PropertyID::BackgroundSize); + auto initial_background_repeat = property_initial_value(m_context.realm(), PropertyID::BackgroundRepeat); + auto initial_background_attachment = property_initial_value(m_context.realm(), PropertyID::BackgroundAttachment); + auto initial_background_clip = property_initial_value(m_context.realm(), PropertyID::BackgroundClip); + auto initial_background_origin = property_initial_value(m_context.realm(), PropertyID::BackgroundOrigin); + auto initial_background_color = property_initial_value(m_context.realm(), PropertyID::BackgroundColor); // Per-layer values RefPtr background_image; @@ -3297,11 +3297,11 @@ RefPtr Parser::parse_border_value(Vector const& comp } if (!border_width) - border_width = MUST(property_initial_value(m_context.realm(), PropertyID::BorderWidth)); + border_width = property_initial_value(m_context.realm(), PropertyID::BorderWidth); if (!border_style) - border_style = MUST(property_initial_value(m_context.realm(), PropertyID::BorderStyle)); + border_style = property_initial_value(m_context.realm(), PropertyID::BorderStyle); if (!border_color) - border_color = MUST(property_initial_value(m_context.realm(), PropertyID::BorderColor)); + border_color = property_initial_value(m_context.realm(), PropertyID::BorderColor); return BorderStyleValue::create(border_width.release_nonnull(), border_style.release_nonnull(), border_color.release_nonnull()); } @@ -4006,9 +4006,9 @@ RefPtr Parser::parse_flex_value(Vector const& compon } if (!flex_grow) - flex_grow = MUST(property_initial_value(m_context.realm(), PropertyID::FlexGrow)); + flex_grow = property_initial_value(m_context.realm(), PropertyID::FlexGrow); if (!flex_shrink) - flex_shrink = MUST(property_initial_value(m_context.realm(), PropertyID::FlexShrink)); + flex_shrink = property_initial_value(m_context.realm(), PropertyID::FlexShrink); if (!flex_basis) { // NOTE: The spec says that flex-basis should be 0 here, but other engines currently use 0%. // https://github.com/w3c/csswg-drafts/issues/5742 @@ -4050,9 +4050,9 @@ RefPtr Parser::parse_flex_flow_value(Vector const& c } if (!flex_direction) - flex_direction = MUST(property_initial_value(m_context.realm(), PropertyID::FlexDirection)); + flex_direction = property_initial_value(m_context.realm(), PropertyID::FlexDirection); if (!flex_wrap) - flex_wrap = MUST(property_initial_value(m_context.realm(), PropertyID::FlexWrap)); + flex_wrap = property_initial_value(m_context.realm(), PropertyID::FlexWrap); return FlexFlowStyleValue::create(flex_direction.release_nonnull(), flex_wrap.release_nonnull()); } @@ -4169,13 +4169,13 @@ RefPtr Parser::parse_font_value(Vector const& compon return nullptr; if (!font_stretch) - font_stretch = MUST(property_initial_value(m_context.realm(), PropertyID::FontStretch)); + font_stretch = property_initial_value(m_context.realm(), PropertyID::FontStretch); if (!font_style) - font_style = MUST(property_initial_value(m_context.realm(), PropertyID::FontStyle)); + font_style = property_initial_value(m_context.realm(), PropertyID::FontStyle); if (!font_weight) - font_weight = MUST(property_initial_value(m_context.realm(), PropertyID::FontWeight)); + font_weight = property_initial_value(m_context.realm(), PropertyID::FontWeight); if (!line_height) - line_height = MUST(property_initial_value(m_context.realm(), PropertyID::LineHeight)); + line_height = property_initial_value(m_context.realm(), PropertyID::LineHeight); return FontStyleValue::create(font_stretch.release_nonnull(), font_style.release_nonnull(), font_weight.release_nonnull(), font_size.release_nonnull(), line_height.release_nonnull(), font_families.release_nonnull()); } @@ -4528,11 +4528,11 @@ RefPtr Parser::parse_list_style_value(Vector const& } if (!list_position) - list_position = MUST(property_initial_value(m_context.realm(), PropertyID::ListStylePosition)); + list_position = property_initial_value(m_context.realm(), PropertyID::ListStylePosition); if (!list_image) - list_image = MUST(property_initial_value(m_context.realm(), PropertyID::ListStyleImage)); + list_image = property_initial_value(m_context.realm(), PropertyID::ListStyleImage); if (!list_type) - list_type = MUST(property_initial_value(m_context.realm(), PropertyID::ListStyleType)); + list_type = property_initial_value(m_context.realm(), PropertyID::ListStyleType); return ListStyleStyleValue::create(list_position.release_nonnull(), list_image.release_nonnull(), list_type.release_nonnull()); } @@ -4666,13 +4666,13 @@ RefPtr Parser::parse_text_decoration_value(Vector co } if (!decoration_line) - decoration_line = MUST(property_initial_value(m_context.realm(), PropertyID::TextDecorationLine)); + decoration_line = property_initial_value(m_context.realm(), PropertyID::TextDecorationLine); if (!decoration_thickness) - decoration_thickness = MUST(property_initial_value(m_context.realm(), PropertyID::TextDecorationThickness)); + decoration_thickness = property_initial_value(m_context.realm(), PropertyID::TextDecorationThickness); if (!decoration_style) - decoration_style = MUST(property_initial_value(m_context.realm(), PropertyID::TextDecorationStyle)); + decoration_style = property_initial_value(m_context.realm(), PropertyID::TextDecorationStyle); if (!decoration_color) - decoration_color = MUST(property_initial_value(m_context.realm(), PropertyID::TextDecorationColor)); + decoration_color = property_initial_value(m_context.realm(), PropertyID::TextDecorationColor); return TextDecorationStyleValue::create(decoration_line.release_nonnull(), decoration_thickness.release_nonnull(), decoration_style.release_nonnull(), decoration_color.release_nonnull()); } @@ -5923,7 +5923,7 @@ Parser::ParseErrorOr> Parser::parse_css_value(Property } for (auto& property : unassigned_properties) - assigned_values.ensure(to_underlying(property)).append(MUST(property_initial_value(m_context.realm(), property))); + assigned_values.ensure(to_underlying(property)).append(property_initial_value(m_context.realm(), property)); stream.skip_whitespace(); if (stream.has_next_token()) @@ -6486,18 +6486,18 @@ bool Parser::is_builtin(StringView name) || name.equals_ignoring_ascii_case("unset"sv); } -ErrorOr> Parser::parse_calculated_value(Badge, ParsingContext const& context, ComponentValue const& token) +RefPtr Parser::parse_calculated_value(Badge, ParsingContext const& context, ComponentValue const& token) { - auto parser = TRY(Parser::create(context, ""sv)); + auto parser = MUST(Parser::create(context, ""sv)); return parser.parse_calculated_value(token); } -ErrorOr> Parser::parse_css_value(Badge, ParsingContext const& context, PropertyID property_id, Vector const& tokens) +RefPtr Parser::parse_css_value(Badge, ParsingContext const& context, PropertyID property_id, Vector const& tokens) { if (tokens.is_empty() || property_id == CSS::PropertyID::Invalid || property_id == CSS::PropertyID::Custom) return nullptr; - auto parser = TRY(Parser::create(context, ""sv)); + auto parser = MUST(Parser::create(context, ""sv)); TokenStream token_stream { tokens }; auto result = parser.parse_css_value(property_id, token_stream); if (result.is_error()) diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Parser.h b/Userland/Libraries/LibWeb/CSS/Parser/Parser.h index 7e918c89db..81eb691a3a 100644 --- a/Userland/Libraries/LibWeb/CSS/Parser/Parser.h +++ b/Userland/Libraries/LibWeb/CSS/Parser/Parser.h @@ -66,8 +66,8 @@ public: RefPtr parse_as_css_value(PropertyID); - static ErrorOr> parse_css_value(Badge, ParsingContext const&, PropertyID, Vector const&); - static ErrorOr> parse_calculated_value(Badge, ParsingContext const&, ComponentValue const&); + static RefPtr parse_css_value(Badge, ParsingContext const&, PropertyID, Vector const&); + static RefPtr parse_calculated_value(Badge, ParsingContext const&, ComponentValue const&); [[nodiscard]] LengthOrCalculated parse_as_sizes_attribute(); @@ -306,7 +306,7 @@ namespace Web { CSS::CSSStyleSheet* parse_css_stylesheet(CSS::Parser::ParsingContext const&, StringView, Optional location = {}); CSS::ElementInlineCSSStyleDeclaration* parse_css_style_attribute(CSS::Parser::ParsingContext const&, StringView, DOM::Element&); -ErrorOr> parse_css_value(CSS::Parser::ParsingContext const&, StringView, CSS::PropertyID property_id = CSS::PropertyID::Invalid); +RefPtr parse_css_value(CSS::Parser::ParsingContext const&, StringView, CSS::PropertyID property_id = CSS::PropertyID::Invalid); Optional parse_selector(CSS::Parser::ParsingContext const&, StringView); CSS::CSSRule* parse_css_rule(CSS::Parser::ParsingContext const&, StringView); RefPtr parse_media_query(CSS::Parser::ParsingContext const&, StringView); diff --git a/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp b/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp index 2c11103789..e89805750a 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp +++ b/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp @@ -921,7 +921,7 @@ void StyleComputer::set_all_properties(DOM::Element& element, Optionalis_calculated()) { + if (auto maybe_calc_value = Parser::Parser::parse_calculated_value({}, Parser::ParsingContext { document() }, value); maybe_calc_value && maybe_calc_value->is_calculated()) { auto& calc_value = maybe_calc_value->as_calculated(); if (calc_value.resolves_to_number()) { auto resolved_value = calc_value.resolve_number(); @@ -1146,7 +1146,7 @@ RefPtr StyleComputer::resolve_unresolved_style_value(DOM::Element& e if (!expand_unresolved_values(element, string_from_property_id(property_id), unresolved_values_with_variables_expanded, expanded_values)) return {}; - if (auto parsed_value = Parser::Parser::parse_css_value({}, Parser::ParsingContext { document() }, property_id, expanded_values).release_value_but_fixme_should_propagate_errors()) + if (auto parsed_value = Parser::Parser::parse_css_value({}, Parser::ParsingContext { document() }, property_id, expanded_values)) return parsed_value.release_nonnull(); return {}; @@ -1939,7 +1939,7 @@ NonnullRefPtr get_inherit_value(JS::Realm& initial_value_conte auto* parent_element = element_to_inherit_style_from(element, pseudo_element); if (!parent_element || !parent_element->computed_css_values()) - return property_initial_value(initial_value_context_realm, property_id).release_value_but_fixme_should_propagate_errors(); + return property_initial_value(initial_value_context_realm, property_id); return parent_element->computed_css_values()->property(property_id); } @@ -1952,12 +1952,12 @@ void StyleComputer::compute_defaulted_property_value(StyleProperties& style, DOM if (is_inherited_property(property_id)) style.m_property_values[to_underlying(property_id)] = { { get_inherit_value(document().realm(), property_id, element, pseudo_element), nullptr } }; else - style.m_property_values[to_underlying(property_id)] = { { property_initial_value(document().realm(), property_id).release_value_but_fixme_should_propagate_errors(), nullptr } }; + style.m_property_values[to_underlying(property_id)] = { { property_initial_value(document().realm(), property_id), nullptr } }; return; } if (value_slot->style->is_initial()) { - value_slot->style = property_initial_value(document().realm(), property_id).release_value_but_fixme_should_propagate_errors(); + value_slot->style = property_initial_value(document().realm(), property_id); return; } @@ -1974,7 +1974,7 @@ void StyleComputer::compute_defaulted_property_value(StyleProperties& style, DOM value_slot->style = get_inherit_value(document().realm(), property_id, element, pseudo_element); } else { // and if it is not, this is treated as initial. - value_slot->style = property_initial_value(document().realm(), property_id).release_value_but_fixme_should_propagate_errors(); + value_slot->style = property_initial_value(document().realm(), property_id); } } } diff --git a/Userland/Libraries/LibWeb/HTML/Canvas/CanvasTextDrawingStyles.h b/Userland/Libraries/LibWeb/HTML/Canvas/CanvasTextDrawingStyles.h index 36836292bc..c864112bd0 100644 --- a/Userland/Libraries/LibWeb/HTML/Canvas/CanvasTextDrawingStyles.h +++ b/Userland/Libraries/LibWeb/HTML/Canvas/CanvasTextDrawingStyles.h @@ -45,10 +45,10 @@ public: auto font_style_value_result = parse_css_value(parsing_context, font, CSS::PropertyID::Font); // If the new value is syntactically incorrect (including using property-independent style sheet syntax like 'inherit' or 'initial'), then it must be ignored, without assigning a new font value. - if (font_style_value_result.is_error() || !font_style_value_result.value()) { + if (!font_style_value_result) { return; } - my_drawing_state().font_style_value = font_style_value_result.value(); + my_drawing_state().font_style_value = font_style_value_result.release_nonnull(); // Load font with font style value properties auto const& font_style_value = my_drawing_state().font_style_value->as_font(); diff --git a/Userland/Libraries/LibWeb/HTML/HTMLTableCellElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLTableCellElement.cpp index 3538b35bc6..6c448c9664 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLTableCellElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLTableCellElement.cpp @@ -40,7 +40,7 @@ void HTMLTableCellElement::apply_presentational_hints(CSS::StyleProperties& styl return; } if (name == HTML::AttributeNames::valign) { - if (auto parsed_value = parse_css_value(CSS::Parser::ParsingContext { document() }, value.view(), CSS::PropertyID::VerticalAlign).release_value_but_fixme_should_propagate_errors()) + if (auto parsed_value = parse_css_value(CSS::Parser::ParsingContext { document() }, value.view(), CSS::PropertyID::VerticalAlign)) style.set_property(CSS::PropertyID::VerticalAlign, parsed_value.release_nonnull()); return; } @@ -48,7 +48,7 @@ void HTMLTableCellElement::apply_presentational_hints(CSS::StyleProperties& styl if (value.equals_ignoring_ascii_case("center"sv) || value.equals_ignoring_ascii_case("middle"sv)) { style.set_property(CSS::PropertyID::TextAlign, CSS::IdentifierStyleValue::create(CSS::ValueID::LibwebCenter)); } else { - if (auto parsed_value = parse_css_value(CSS::Parser::ParsingContext { document() }, value.view(), CSS::PropertyID::TextAlign).release_value_but_fixme_should_propagate_errors()) + if (auto parsed_value = parse_css_value(CSS::Parser::ParsingContext { document() }, value.view(), CSS::PropertyID::TextAlign)) style.set_property(CSS::PropertyID::TextAlign, parsed_value.release_nonnull()); } return; diff --git a/Userland/Libraries/LibWeb/SVG/SVGForeignObjectElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGForeignObjectElement.cpp index af4de78c48..0b046be7e3 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGForeignObjectElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGForeignObjectElement.cpp @@ -52,10 +52,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).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()); - 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()); } diff --git a/Userland/Libraries/LibWeb/SVG/SVGGraphicsElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGGraphicsElement.cpp index 779fe10ad2..ce5e0fecb0 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGGraphicsElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGGraphicsElement.cpp @@ -125,32 +125,32 @@ 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).release_value_but_fixme_should_propagate_errors()) + if (auto fill_value = parse_css_value(parsing_context, value, CSS::PropertyID::Fill)) 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).release_value_but_fixme_should_propagate_errors()) + if (auto stroke_value = parse_css_value(parsing_context, value, CSS::PropertyID::Stroke)) 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).release_value_but_fixme_should_propagate_errors()) + if (auto stroke_width_value = parse_css_value(parsing_context, value, CSS::PropertyID::StrokeWidth)) style.set_property(CSS::PropertyID::StrokeWidth, stroke_width_value.release_nonnull()); } else if (name.equals_ignoring_ascii_case("fill-rule"sv)) { - if (auto fill_rule_value = parse_css_value(parsing_context, value, CSS::PropertyID::FillRule).release_value_but_fixme_should_propagate_errors()) + if (auto fill_rule_value = parse_css_value(parsing_context, value, CSS::PropertyID::FillRule)) style.set_property(CSS::PropertyID::FillRule, fill_rule_value.release_nonnull()); } else if (name.equals_ignoring_ascii_case("fill-opacity"sv)) { - if (auto fill_opacity_value = parse_css_value(parsing_context, value, CSS::PropertyID::FillOpacity).release_value_but_fixme_should_propagate_errors()) + if (auto fill_opacity_value = parse_css_value(parsing_context, value, CSS::PropertyID::FillOpacity)) style.set_property(CSS::PropertyID::FillOpacity, fill_opacity_value.release_nonnull()); } else if (name.equals_ignoring_ascii_case("stroke-opacity"sv)) { - if (auto stroke_opacity_value = parse_css_value(parsing_context, value, CSS::PropertyID::StrokeOpacity).release_value_but_fixme_should_propagate_errors()) + if (auto stroke_opacity_value = parse_css_value(parsing_context, value, CSS::PropertyID::StrokeOpacity)) style.set_property(CSS::PropertyID::StrokeOpacity, stroke_opacity_value.release_nonnull()); } else if (name.equals_ignoring_ascii_case(SVG::AttributeNames::opacity)) { - if (auto opacity_value = parse_css_value(parsing_context, value, CSS::PropertyID::Opacity).release_value_but_fixme_should_propagate_errors()) + if (auto opacity_value = parse_css_value(parsing_context, value, CSS::PropertyID::Opacity)) style.set_property(CSS::PropertyID::Opacity, opacity_value.release_nonnull()); } else if (name.equals_ignoring_ascii_case("text-anchor"sv)) { - if (auto text_anchor_value = parse_css_value(parsing_context, value, CSS::PropertyID::TextAnchor).release_value_but_fixme_should_propagate_errors()) + if (auto text_anchor_value = parse_css_value(parsing_context, value, CSS::PropertyID::TextAnchor)) style.set_property(CSS::PropertyID::TextAnchor, text_anchor_value.release_nonnull()); } else if (name.equals_ignoring_ascii_case("font-size"sv)) { - if (auto font_size_value = parse_css_value(parsing_context, value, CSS::PropertyID::FontSize).release_value_but_fixme_should_propagate_errors()) + if (auto font_size_value = parse_css_value(parsing_context, value, CSS::PropertyID::FontSize)) style.set_property(CSS::PropertyID::FontSize, font_size_value.release_nonnull()); } }); diff --git a/Userland/Libraries/LibWeb/SVG/SVGSVGElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGSVGElement.cpp index 4534312b3a..bca0eb17c2 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGSVGElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGSVGElement.cpp @@ -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(); } diff --git a/Userland/Libraries/LibWeb/SVG/SVGStopElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGStopElement.cpp index cda96bc0be..452d4e600f 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGStopElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGStopElement.cpp @@ -33,11 +33,11 @@ void SVGStopElement::apply_presentational_hints(CSS::StyleProperties& style) con for_each_attribute([&](auto& name, auto& value) { CSS::Parser::ParsingContext parsing_context { document() }; if (name.equals_ignoring_ascii_case("stop-color"sv)) { - if (auto stop_color = parse_css_value(parsing_context, value, CSS::PropertyID::StopColor).release_value_but_fixme_should_propagate_errors()) { + if (auto stop_color = parse_css_value(parsing_context, value, CSS::PropertyID::StopColor)) { style.set_property(CSS::PropertyID::StopColor, stop_color.release_nonnull()); } } else if (name.equals_ignoring_ascii_case("stop-opacity"sv)) { - if (auto stop_opacity = parse_css_value(parsing_context, value, CSS::PropertyID::StopOpacity).release_value_but_fixme_should_propagate_errors()) { + if (auto stop_opacity = parse_css_value(parsing_context, value, CSS::PropertyID::StopOpacity)) { style.set_property(CSS::PropertyID::StopOpacity, stop_opacity.release_nonnull()); } }