summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Atkins <atkinssj@serenityos.org>2023-05-02 15:09:46 +0100
committerAndreas Kling <kling@serenityos.org>2023-05-06 08:07:28 +0200
commitf4d8a24fe491eb75bace3b0be2b49e7d3ac165a1 (patch)
tree071a127b202ad4565f95a704c6da1c6beee66093
parent294f5b109fb98f43ce82622a61cb78e3afcab246 (diff)
downloadserenity-f4d8a24fe491eb75bace3b0be2b49e7d3ac165a1.zip
LibWeb: Propagate errors from parse_css_value and property_initial_value
-rw-r--r--Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSPropertyID.cpp6
-rw-r--r--Userland/Libraries/LibWeb/CSS/CSS.cpp2
-rw-r--r--Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.cpp4
-rw-r--r--Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp90
-rw-r--r--Userland/Libraries/LibWeb/CSS/Parser/Parser.h2
-rw-r--r--Userland/Libraries/LibWeb/CSS/StyleComputer.cpp8
-rw-r--r--Userland/Libraries/LibWeb/HTML/HTMLTableCellElement.cpp2
-rw-r--r--Userland/Libraries/LibWeb/Layout/SVGSVGBox.cpp4
-rw-r--r--Userland/Libraries/LibWeb/SVG/SVGForeignObjectElement.cpp4
-rw-r--r--Userland/Libraries/LibWeb/SVG/SVGGraphicsElement.cpp6
-rw-r--r--Userland/Libraries/LibWeb/SVG/SVGSVGElement.cpp4
-rw-r--r--Userland/Libraries/LibWeb/SVG/SVGStopElement.cpp2
12 files changed, 68 insertions, 66 deletions
diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSPropertyID.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSPropertyID.cpp
index 717167bda7..0ad0ee62e0 100644
--- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSPropertyID.cpp
+++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSPropertyID.cpp
@@ -107,7 +107,7 @@ PropertyID property_id_from_camel_case_string(StringView);
PropertyID property_id_from_string(StringView);
StringView string_from_property_id(PropertyID);
bool is_inherited_property(PropertyID);
-NonnullRefPtr<StyleValue> property_initial_value(JS::Realm&, PropertyID);
+ErrorOr<NonnullRefPtr<StyleValue>> property_initial_value(JS::Realm&, PropertyID);
bool property_accepts_value(PropertyID, StyleValue&);
size_t property_maximum_value_count(PropertyID);
@@ -310,7 +310,7 @@ bool property_affects_stacking_context(PropertyID property_id)
}
}
-NonnullRefPtr<StyleValue> property_initial_value(JS::Realm& context_realm, PropertyID property_id)
+ErrorOr<NonnullRefPtr<StyleValue>> property_initial_value(JS::Realm& context_realm, PropertyID property_id)
{
static Array<RefPtr<StyleValue>, to_underlying(last_property_id) + 1> initial_values;
if (auto initial_value = initial_values[to_underlying(property_id)])
@@ -339,7 +339,7 @@ NonnullRefPtr<StyleValue> property_initial_value(JS::Realm& context_realm, Prope
member_generator.append(
R"~~~( case PropertyID::@name:titlecase@:
{
- auto parsed_value = parse_css_value(parsing_context, "@initial_value_string@"sv, PropertyID::@name:titlecase@);
+ auto parsed_value = TRY(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 925e89a7c6..443830ff34 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 != PropertyID::Invalid) {
- if (parse_css_value(Parser::ParsingContext { realm }, value, property_id))
+ if (parse_css_value(Parser::ParsingContext { realm }, value, property_id).release_value_but_fixme_should_propagate_errors())
return true;
}
diff --git a/Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.cpp b/Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.cpp
index 03ab7bbd85..8dcbd80093 100644
--- a/Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.cpp
+++ b/Userland/Libraries/LibWeb/CSS/CSSStyleDeclaration.cpp
@@ -94,8 +94,8 @@ WebIDL::ExceptionOr<void> PropertyOwningCSSStyleDeclaration::set_property(Proper
// 5. Let component value list be the result of parsing value for property property.
auto component_value_list = is<ElementInlineCSSStyleDeclaration>(this)
- ? parse_css_value(CSS::Parser::ParsingContext { static_cast<ElementInlineCSSStyleDeclaration&>(*this).element()->document() }, value, property_id)
- : parse_css_value(CSS::Parser::ParsingContext { realm() }, value, property_id);
+ ? MUST(parse_css_value(CSS::Parser::ParsingContext { static_cast<ElementInlineCSSStyleDeclaration&>(*this).element()->document() }, value, property_id))
+ : MUST(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/Parser.cpp b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp
index 98f0b831f0..bf9c709040 100644
--- a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp
+++ b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp
@@ -4123,21 +4123,21 @@ ErrorOr<RefPtr<StyleValue>> Parser::parse_background_value(Vector<ComponentValue
return background_image || background_position || background_size || background_repeat || background_attachment || background_clip || background_origin;
};
- auto complete_background_layer = [&]() {
- background_images.append(background_image ? background_image.release_nonnull() : property_initial_value(m_context.realm(), PropertyID::BackgroundImage));
- background_positions.append(background_position ? background_position.release_nonnull() : property_initial_value(m_context.realm(), PropertyID::BackgroundPosition));
- background_sizes.append(background_size ? background_size.release_nonnull() : property_initial_value(m_context.realm(), PropertyID::BackgroundSize));
- background_repeats.append(background_repeat ? background_repeat.release_nonnull() : property_initial_value(m_context.realm(), PropertyID::BackgroundRepeat));
- background_attachments.append(background_attachment ? background_attachment.release_nonnull() : property_initial_value(m_context.realm(), PropertyID::BackgroundAttachment));
+ auto complete_background_layer = [&]() -> ErrorOr<void> {
+ TRY(background_images.try_append(background_image ? background_image.release_nonnull() : TRY(property_initial_value(m_context.realm(), PropertyID::BackgroundImage))));
+ TRY(background_positions.try_append(background_position ? background_position.release_nonnull() : TRY(property_initial_value(m_context.realm(), PropertyID::BackgroundPosition))));
+ TRY(background_sizes.try_append(background_size ? background_size.release_nonnull() : TRY(property_initial_value(m_context.realm(), PropertyID::BackgroundSize))));
+ TRY(background_repeats.try_append(background_repeat ? background_repeat.release_nonnull() : TRY(property_initial_value(m_context.realm(), PropertyID::BackgroundRepeat))));
+ TRY(background_attachments.try_append(background_attachment ? background_attachment.release_nonnull() : TRY(property_initial_value(m_context.realm(), PropertyID::BackgroundAttachment))));
if (!background_origin && !background_clip) {
- background_origin = property_initial_value(m_context.realm(), PropertyID::BackgroundOrigin);
- background_clip = property_initial_value(m_context.realm(), PropertyID::BackgroundClip);
+ background_origin = TRY(property_initial_value(m_context.realm(), PropertyID::BackgroundOrigin));
+ background_clip = TRY(property_initial_value(m_context.realm(), PropertyID::BackgroundClip));
} else if (!background_clip) {
background_clip = background_origin;
}
- background_origins.append(background_origin.release_nonnull());
- background_clips.append(background_clip.release_nonnull());
+ TRY(background_origins.try_append(background_origin.release_nonnull()));
+ TRY(background_clips.try_append(background_clip.release_nonnull()));
background_image = nullptr;
background_position = nullptr;
@@ -4146,6 +4146,8 @@ ErrorOr<RefPtr<StyleValue>> Parser::parse_background_value(Vector<ComponentValue
background_attachment = nullptr;
background_clip = nullptr;
background_origin = nullptr;
+
+ return {};
};
auto tokens = TokenStream { component_values };
@@ -4156,7 +4158,7 @@ ErrorOr<RefPtr<StyleValue>> Parser::parse_background_value(Vector<ComponentValue
has_multiple_layers = true;
if (!background_layer_is_valid(false))
return nullptr;
- complete_background_layer();
+ TRY(complete_background_layer());
continue;
}
@@ -4241,10 +4243,10 @@ ErrorOr<RefPtr<StyleValue>> Parser::parse_background_value(Vector<ComponentValue
// We only need to create StyleValueLists if there are multiple layers.
// Otherwise, we can pass the single StyleValues directly.
if (has_multiple_layers) {
- complete_background_layer();
+ TRY(complete_background_layer());
if (!background_color)
- background_color = property_initial_value(m_context.realm(), PropertyID::BackgroundColor);
+ background_color = TRY(property_initial_value(m_context.realm(), PropertyID::BackgroundColor));
return BackgroundStyleValue::create(
background_color.release_nonnull(),
TRY(StyleValueList::create(move(background_images), StyleValueList::Separator::Comma)),
@@ -4257,21 +4259,21 @@ ErrorOr<RefPtr<StyleValue>> Parser::parse_background_value(Vector<ComponentValue
}
if (!background_color)
- background_color = property_initial_value(m_context.realm(), PropertyID::BackgroundColor);
+ background_color = TRY(property_initial_value(m_context.realm(), PropertyID::BackgroundColor));
if (!background_image)
- background_image = property_initial_value(m_context.realm(), PropertyID::BackgroundImage);
+ background_image = TRY(property_initial_value(m_context.realm(), PropertyID::BackgroundImage));
if (!background_position)
- background_position = property_initial_value(m_context.realm(), PropertyID::BackgroundPosition);
+ background_position = TRY(property_initial_value(m_context.realm(), PropertyID::BackgroundPosition));
if (!background_size)
- background_size = property_initial_value(m_context.realm(), PropertyID::BackgroundSize);
+ background_size = TRY(property_initial_value(m_context.realm(), PropertyID::BackgroundSize));
if (!background_repeat)
- background_repeat = property_initial_value(m_context.realm(), PropertyID::BackgroundRepeat);
+ background_repeat = TRY(property_initial_value(m_context.realm(), PropertyID::BackgroundRepeat));
if (!background_attachment)
- background_attachment = property_initial_value(m_context.realm(), PropertyID::BackgroundAttachment);
+ background_attachment = TRY(property_initial_value(m_context.realm(), PropertyID::BackgroundAttachment));
if (!background_origin && !background_clip) {
- background_origin = property_initial_value(m_context.realm(), PropertyID::BackgroundOrigin);
- background_clip = property_initial_value(m_context.realm(), PropertyID::BackgroundClip);
+ background_origin = TRY(property_initial_value(m_context.realm(), PropertyID::BackgroundOrigin));
+ background_clip = TRY(property_initial_value(m_context.realm(), PropertyID::BackgroundClip));
} else if (!background_clip) {
background_clip = background_origin;
}
@@ -4661,11 +4663,11 @@ ErrorOr<RefPtr<StyleValue>> Parser::parse_border_value(Vector<ComponentValue> co
}
if (!border_width)
- border_width = property_initial_value(m_context.realm(), PropertyID::BorderWidth);
+ border_width = TRY(property_initial_value(m_context.realm(), PropertyID::BorderWidth));
if (!border_style)
- border_style = property_initial_value(m_context.realm(), PropertyID::BorderStyle);
+ border_style = TRY(property_initial_value(m_context.realm(), PropertyID::BorderStyle));
if (!border_color)
- border_color = property_initial_value(m_context.realm(), PropertyID::BorderColor);
+ border_color = TRY(property_initial_value(m_context.realm(), PropertyID::BorderColor));
return BorderStyleValue::create(border_width.release_nonnull(), border_style.release_nonnull(), border_color.release_nonnull());
}
@@ -5361,11 +5363,11 @@ ErrorOr<RefPtr<StyleValue>> Parser::parse_flex_value(Vector<ComponentValue> cons
}
if (!flex_grow)
- flex_grow = property_initial_value(m_context.realm(), PropertyID::FlexGrow);
+ flex_grow = TRY(property_initial_value(m_context.realm(), PropertyID::FlexGrow));
if (!flex_shrink)
- flex_shrink = property_initial_value(m_context.realm(), PropertyID::FlexShrink);
+ flex_shrink = TRY(property_initial_value(m_context.realm(), PropertyID::FlexShrink));
if (!flex_basis)
- flex_basis = property_initial_value(m_context.realm(), PropertyID::FlexBasis);
+ flex_basis = TRY(property_initial_value(m_context.realm(), PropertyID::FlexBasis));
return FlexStyleValue::create(flex_grow.release_nonnull(), flex_shrink.release_nonnull(), flex_basis.release_nonnull());
}
@@ -5397,9 +5399,9 @@ ErrorOr<RefPtr<StyleValue>> Parser::parse_flex_flow_value(Vector<ComponentValue>
}
if (!flex_direction)
- flex_direction = property_initial_value(m_context.realm(), PropertyID::FlexDirection);
+ flex_direction = TRY(property_initial_value(m_context.realm(), PropertyID::FlexDirection));
if (!flex_wrap)
- flex_wrap = property_initial_value(m_context.realm(), PropertyID::FlexWrap);
+ flex_wrap = TRY(property_initial_value(m_context.realm(), PropertyID::FlexWrap));
return FlexFlowStyleValue::create(flex_direction.release_nonnull(), flex_wrap.release_nonnull());
}
@@ -5510,13 +5512,13 @@ ErrorOr<RefPtr<StyleValue>> Parser::parse_font_value(Vector<ComponentValue> cons
return nullptr;
if (!font_stretch)
- font_stretch = property_initial_value(m_context.realm(), PropertyID::FontStretch);
+ font_stretch = TRY(property_initial_value(m_context.realm(), PropertyID::FontStretch));
if (!font_style)
- font_style = property_initial_value(m_context.realm(), PropertyID::FontStyle);
+ font_style = TRY(property_initial_value(m_context.realm(), PropertyID::FontStyle));
if (!font_weight)
- font_weight = property_initial_value(m_context.realm(), PropertyID::FontWeight);
+ font_weight = TRY(property_initial_value(m_context.realm(), PropertyID::FontWeight));
if (!line_height)
- line_height = property_initial_value(m_context.realm(), PropertyID::LineHeight);
+ line_height = TRY(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());
}
@@ -5844,11 +5846,11 @@ ErrorOr<RefPtr<StyleValue>> Parser::parse_list_style_value(Vector<ComponentValue
}
if (!list_position)
- list_position = property_initial_value(m_context.realm(), PropertyID::ListStylePosition);
+ list_position = TRY(property_initial_value(m_context.realm(), PropertyID::ListStylePosition));
if (!list_image)
- list_image = property_initial_value(m_context.realm(), PropertyID::ListStyleImage);
+ list_image = TRY(property_initial_value(m_context.realm(), PropertyID::ListStyleImage));
if (!list_type)
- list_type = property_initial_value(m_context.realm(), PropertyID::ListStyleType);
+ list_type = TRY(property_initial_value(m_context.realm(), PropertyID::ListStyleType));
return ListStyleStyleValue::create(list_position.release_nonnull(), list_image.release_nonnull(), list_type.release_nonnull());
}
@@ -5930,13 +5932,13 @@ ErrorOr<RefPtr<StyleValue>> Parser::parse_text_decoration_value(Vector<Component
}
if (!decoration_line)
- decoration_line = property_initial_value(m_context.realm(), PropertyID::TextDecorationLine);
+ decoration_line = TRY(property_initial_value(m_context.realm(), PropertyID::TextDecorationLine));
if (!decoration_thickness)
- decoration_thickness = property_initial_value(m_context.realm(), PropertyID::TextDecorationThickness);
+ decoration_thickness = TRY(property_initial_value(m_context.realm(), PropertyID::TextDecorationThickness));
if (!decoration_style)
- decoration_style = property_initial_value(m_context.realm(), PropertyID::TextDecorationStyle);
+ decoration_style = TRY(property_initial_value(m_context.realm(), PropertyID::TextDecorationStyle));
if (!decoration_color)
- decoration_color = property_initial_value(m_context.realm(), PropertyID::TextDecorationColor);
+ decoration_color = TRY(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());
}
@@ -7756,12 +7758,12 @@ CSS::ElementInlineCSSStyleDeclaration* parse_css_style_attribute(CSS::Parser::Pa
return parser.parse_as_style_attribute(element);
}
-RefPtr<CSS::StyleValue> parse_css_value(CSS::Parser::ParsingContext const& context, StringView string, CSS::PropertyID property_id)
+ErrorOr<RefPtr<CSS::StyleValue>> parse_css_value(CSS::Parser::ParsingContext const& context, StringView string, CSS::PropertyID property_id)
{
if (string.is_empty())
- return {};
- auto parser = CSS::Parser::Parser::create(context, string).release_value_but_fixme_should_propagate_errors();
- return parser.parse_as_css_value(property_id).release_value_but_fixme_should_propagate_errors();
+ return nullptr;
+ auto parser = TRY(CSS::Parser::Parser::create(context, string));
+ return parser.parse_as_css_value(property_id);
}
CSS::CSSRule* parse_css_rule(CSS::Parser::ParsingContext const& context, StringView css_text)
diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Parser.h b/Userland/Libraries/LibWeb/CSS/Parser/Parser.h
index ce59c198fe..803eabac33 100644
--- a/Userland/Libraries/LibWeb/CSS/Parser/Parser.h
+++ b/Userland/Libraries/LibWeb/CSS/Parser/Parser.h
@@ -370,7 +370,7 @@ namespace Web {
CSS::CSSStyleSheet* parse_css_stylesheet(CSS::Parser::ParsingContext const&, StringView, Optional<AK::URL> location = {});
CSS::ElementInlineCSSStyleDeclaration* parse_css_style_attribute(CSS::Parser::ParsingContext const&, StringView, DOM::Element&);
-RefPtr<CSS::StyleValue> parse_css_value(CSS::Parser::ParsingContext const&, StringView, CSS::PropertyID property_id = CSS::PropertyID::Invalid);
+ErrorOr<RefPtr<CSS::StyleValue>> parse_css_value(CSS::Parser::ParsingContext const&, StringView, CSS::PropertyID property_id = CSS::PropertyID::Invalid);
Optional<CSS::SelectorList> parse_selector(CSS::Parser::ParsingContext const&, StringView);
CSS::CSSRule* parse_css_rule(CSS::Parser::ParsingContext const&, StringView);
RefPtr<CSS::MediaQuery> 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 f2af334c82..42220c43aa 100644
--- a/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp
+++ b/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp
@@ -1000,7 +1000,7 @@ static NonnullRefPtr<StyleValue const> get_inherit_value(JS::Realm& initial_valu
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);
+ return property_initial_value(initial_value_context_realm, property_id).release_value_but_fixme_should_propagate_errors();
return parent_element->computed_css_values()->property(property_id);
};
@@ -1013,12 +1013,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);
else
- style.m_property_values[to_underlying(property_id)] = property_initial_value(document().realm(), property_id);
+ style.m_property_values[to_underlying(property_id)] = property_initial_value(document().realm(), property_id).release_value_but_fixme_should_propagate_errors();
return;
}
if (value_slot->is_initial()) {
- value_slot = property_initial_value(document().realm(), property_id);
+ value_slot = property_initial_value(document().realm(), property_id).release_value_but_fixme_should_propagate_errors();
return;
}
@@ -1035,7 +1035,7 @@ void StyleComputer::compute_defaulted_property_value(StyleProperties& style, DOM
value_slot = get_inherit_value(document().realm(), property_id, element, pseudo_element);
} else {
// and if it is not, this is treated as initial.
- value_slot = property_initial_value(document().realm(), property_id);
+ value_slot = property_initial_value(document().realm(), property_id).release_value_but_fixme_should_propagate_errors();
}
}
}
diff --git a/Userland/Libraries/LibWeb/HTML/HTMLTableCellElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLTableCellElement.cpp
index 9be2a2729b..bf7529034e 100644
--- a/Userland/Libraries/LibWeb/HTML/HTMLTableCellElement.cpp
+++ b/Userland/Libraries/LibWeb/HTML/HTMLTableCellElement.cpp
@@ -41,7 +41,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).release_value_but_fixme_should_propagate_errors());
} else {
- if (auto parsed_value = parse_css_value(CSS::Parser::ParsingContext { document() }, value.view(), CSS::PropertyID::TextAlign))
+ if (auto parsed_value = parse_css_value(CSS::Parser::ParsingContext { document() }, value.view(), CSS::PropertyID::TextAlign).release_value_but_fixme_should_propagate_errors())
style.set_property(CSS::PropertyID::TextAlign, parsed_value.release_nonnull());
}
return;
diff --git a/Userland/Libraries/LibWeb/Layout/SVGSVGBox.cpp b/Userland/Libraries/LibWeb/Layout/SVGSVGBox.cpp
index fedb8dd723..4433ac8a7c 100644
--- a/Userland/Libraries/LibWeb/Layout/SVGSVGBox.cpp
+++ b/Userland/Libraries/LibWeb/Layout/SVGSVGBox.cpp
@@ -28,11 +28,11 @@ void SVGSVGBox::prepare_for_replaced_layout()
Optional<CSSPixels> w;
Optional<CSSPixels> h;
auto parsing_context = CSS::Parser::ParsingContext { document() };
- auto width = parse_css_value(parsing_context, dom_node().attribute(Web::HTML::AttributeNames::width), CSS::PropertyID::Width);
+ auto width = parse_css_value(parsing_context, dom_node().attribute(Web::HTML::AttributeNames::width), CSS::PropertyID::Width).release_value_but_fixme_should_propagate_errors();
if (!width.is_null() && width->has_length())
w = width->to_length().to_px(*this);
- auto height = parse_css_value(parsing_context, dom_node().attribute((HTML::AttributeNames::height)), CSS::PropertyID::Height);
+ auto height = parse_css_value(parsing_context, dom_node().attribute((HTML::AttributeNames::height)), CSS::PropertyID::Height).release_value_but_fixme_should_propagate_errors();
if (!height.is_null() && height->has_length())
h = height->to_length().to_px(*this);
if (w.has_value() && h.has_value()) {
diff --git a/Userland/Libraries/LibWeb/SVG/SVGForeignObjectElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGForeignObjectElement.cpp
index ccaa0a79c5..06409cd7db 100644
--- a/Userland/Libraries/LibWeb/SVG/SVGForeignObjectElement.cpp
+++ b/Userland/Libraries/LibWeb/SVG/SVGForeignObjectElement.cpp
@@ -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());
}
diff --git a/Userland/Libraries/LibWeb/SVG/SVGGraphicsElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGGraphicsElement.cpp
index 62eab723c7..114819d451 100644
--- a/Userland/Libraries/LibWeb/SVG/SVGGraphicsElement.cpp
+++ b/Userland/Libraries/LibWeb/SVG/SVGGraphicsElement.cpp
@@ -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());
}
});
diff --git a/Userland/Libraries/LibWeb/SVG/SVGSVGElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGSVGElement.cpp
index b44a78e2f0..2bb3b5a902 100644
--- a/Userland/Libraries/LibWeb/SVG/SVGSVGElement.cpp
+++ b/Userland/Libraries/LibWeb/SVG/SVGSVGElement.cpp
@@ -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%.
diff --git a/Userland/Libraries/LibWeb/SVG/SVGStopElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGStopElement.cpp
index 235e82f707..7f7d70807c 100644
--- a/Userland/Libraries/LibWeb/SVG/SVGStopElement.cpp
+++ b/Userland/Libraries/LibWeb/SVG/SVGStopElement.cpp
@@ -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());
}
}