Skip to content

Commit 8a8cc18

Browse files
AtkinsSJawesomekling
authored andcommitted
LibWeb: Make StyleValue constructors infallible
1 parent b2b99ab commit 8a8cc18

File tree

86 files changed

+353
-353
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+353
-353
lines changed

Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp

Lines changed: 65 additions & 65 deletions
Large diffs are not rendered by default.

Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp

Lines changed: 91 additions & 91 deletions
Large diffs are not rendered by default.

Userland/Libraries/LibWeb/CSS/StyleComputer.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -688,8 +688,8 @@ static void set_property_expanding_shorthands(StyleProperties& style, CSS::Prope
688688
y_positions.unchecked_append(layer);
689689
}
690690
}
691-
set_longhand_property(CSS::PropertyID::BackgroundPositionX, StyleValueList::create(move(x_positions), values_list.separator()).release_value_but_fixme_should_propagate_errors());
692-
set_longhand_property(CSS::PropertyID::BackgroundPositionY, StyleValueList::create(move(y_positions), values_list.separator()).release_value_but_fixme_should_propagate_errors());
691+
set_longhand_property(CSS::PropertyID::BackgroundPositionX, StyleValueList::create(move(x_positions), values_list.separator()));
692+
set_longhand_property(CSS::PropertyID::BackgroundPositionY, StyleValueList::create(move(y_positions), values_list.separator()));
693693
} else {
694694
set_longhand_property(CSS::PropertyID::BackgroundPositionX, value);
695695
set_longhand_property(CSS::PropertyID::BackgroundPositionY, value);
@@ -2320,8 +2320,8 @@ void StyleComputer::compute_font(StyleProperties& style, DOM::Element const* ele
23202320

23212321
auto found_font = compute_font_for_style_values(element, pseudo_element, font_family, font_size, font_style, font_weight, font_stretch);
23222322

2323-
style.set_property(CSS::PropertyID::FontSize, LengthStyleValue::create(CSS::Length::make_px(found_font->pixel_size())).release_value_but_fixme_should_propagate_errors(), nullptr);
2324-
style.set_property(CSS::PropertyID::FontWeight, NumberStyleValue::create(font_weight->to_font_weight()).release_value_but_fixme_should_propagate_errors());
2323+
style.set_property(CSS::PropertyID::FontSize, LengthStyleValue::create(CSS::Length::make_px(found_font->pixel_size())), nullptr);
2324+
style.set_property(CSS::PropertyID::FontWeight, NumberStyleValue::create(font_weight->to_font_weight()));
23252325

23262326
style.set_computed_font(found_font.release_nonnull());
23272327

@@ -2370,16 +2370,16 @@ ErrorOr<void> StyleComputer::absolutize_values(StyleProperties& style, DOM::Elem
23702370
// because most percentages are relative to containing block metrics.
23712371
auto line_height_value_slot = style.m_property_values[to_underlying(CSS::PropertyID::LineHeight)].map([](auto& x) -> auto& { return x.style; });
23722372
if (line_height_value_slot.has_value() && (*line_height_value_slot)->is_percentage()) {
2373-
*line_height_value_slot = TRY(LengthStyleValue::create(
2374-
Length::make_px(font_size * static_cast<double>((*line_height_value_slot)->as_percentage().percentage().as_fraction()))));
2373+
*line_height_value_slot = LengthStyleValue::create(
2374+
Length::make_px(font_size * static_cast<double>((*line_height_value_slot)->as_percentage().percentage().as_fraction())));
23752375
}
23762376

23772377
auto line_height = style.line_height(viewport_rect(), font_metrics, m_root_element_font_metrics);
23782378
font_metrics.line_height = line_height;
23792379

23802380
// NOTE: line-height might be using lh which should be resolved against the parent line height (like we did here already)
23812381
if (line_height_value_slot.has_value() && (*line_height_value_slot)->is_length())
2382-
(*line_height_value_slot) = TRY(LengthStyleValue::create(Length::make_px(line_height)));
2382+
(*line_height_value_slot) = LengthStyleValue::create(Length::make_px(line_height));
23832383

23842384
for (size_t i = 0; i < style.m_property_values.size(); ++i) {
23852385
auto& value_slot = style.m_property_values[i];
@@ -2479,7 +2479,7 @@ void StyleComputer::transform_box_type_if_needed(StyleProperties& style, DOM::El
24792479
}
24802480

24812481
if (new_display != display)
2482-
style.set_property(CSS::PropertyID::Display, DisplayStyleValue::create(new_display).release_value_but_fixme_should_propagate_errors(), style.property_source_declaration(CSS::PropertyID::Display));
2482+
style.set_property(CSS::PropertyID::Display, DisplayStyleValue::create(new_display), style.property_source_declaration(CSS::PropertyID::Display));
24832483
}
24842484

24852485
NonnullRefPtr<StyleProperties> StyleComputer::create_document_style() const
@@ -2488,9 +2488,9 @@ NonnullRefPtr<StyleProperties> StyleComputer::create_document_style() const
24882488
compute_font(style, nullptr, {});
24892489
compute_defaulted_values(style, nullptr, {});
24902490
absolutize_values(style, nullptr, {}).release_value_but_fixme_should_propagate_errors();
2491-
style->set_property(CSS::PropertyID::Width, CSS::LengthStyleValue::create(CSS::Length::make_px(viewport_rect().width())).release_value_but_fixme_should_propagate_errors(), nullptr);
2492-
style->set_property(CSS::PropertyID::Height, CSS::LengthStyleValue::create(CSS::Length::make_px(viewport_rect().height())).release_value_but_fixme_should_propagate_errors(), nullptr);
2493-
style->set_property(CSS::PropertyID::Display, CSS::DisplayStyleValue::create(CSS::Display::from_short(CSS::Display::Short::Block)).release_value_but_fixme_should_propagate_errors(), nullptr);
2491+
style->set_property(CSS::PropertyID::Width, CSS::LengthStyleValue::create(CSS::Length::make_px(viewport_rect().width())), nullptr);
2492+
style->set_property(CSS::PropertyID::Height, CSS::LengthStyleValue::create(CSS::Length::make_px(viewport_rect().height())), nullptr);
2493+
style->set_property(CSS::PropertyID::Display, CSS::DisplayStyleValue::create(CSS::Display::from_short(CSS::Display::Short::Block)), nullptr);
24942494
return style;
24952495
}
24962496

Userland/Libraries/LibWeb/CSS/StyleValues/AngleStyleValue.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ namespace Web::CSS {
1616

1717
class AngleStyleValue : public StyleValueWithDefaultOperators<AngleStyleValue> {
1818
public:
19-
static ErrorOr<ValueComparingNonnullRefPtr<AngleStyleValue>> create(Angle angle)
19+
static ValueComparingNonnullRefPtr<AngleStyleValue> create(Angle angle)
2020
{
21-
return adopt_nonnull_ref_or_enomem(new (nothrow) AngleStyleValue(move(angle)));
21+
return adopt_ref(*new (nothrow) AngleStyleValue(move(angle)));
2222
}
2323
virtual ~AngleStyleValue() override;
2424

Userland/Libraries/LibWeb/CSS/StyleValues/BackgroundRepeatStyleValue.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ namespace Web::CSS {
1616

1717
class BackgroundRepeatStyleValue final : public StyleValueWithDefaultOperators<BackgroundRepeatStyleValue> {
1818
public:
19-
static ErrorOr<ValueComparingNonnullRefPtr<BackgroundRepeatStyleValue>> create(Repeat repeat_x, Repeat repeat_y)
19+
static ValueComparingNonnullRefPtr<BackgroundRepeatStyleValue> create(Repeat repeat_x, Repeat repeat_y)
2020
{
21-
return adopt_nonnull_ref_or_enomem(new (nothrow) BackgroundRepeatStyleValue(repeat_x, repeat_y));
21+
return adopt_ref(*new (nothrow) BackgroundRepeatStyleValue(repeat_x, repeat_y));
2222
}
2323
virtual ~BackgroundRepeatStyleValue() override;
2424

Userland/Libraries/LibWeb/CSS/StyleValues/BackgroundSizeStyleValue.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ namespace Web::CSS {
1818
// NOTE: This is not used for identifier sizes, like `cover` and `contain`.
1919
class BackgroundSizeStyleValue final : public StyleValueWithDefaultOperators<BackgroundSizeStyleValue> {
2020
public:
21-
static ErrorOr<ValueComparingNonnullRefPtr<BackgroundSizeStyleValue>> create(LengthPercentage size_x, LengthPercentage size_y)
21+
static ValueComparingNonnullRefPtr<BackgroundSizeStyleValue> create(LengthPercentage size_x, LengthPercentage size_y)
2222
{
23-
return adopt_nonnull_ref_or_enomem(new (nothrow) BackgroundSizeStyleValue(size_x, size_y));
23+
return adopt_ref(*new (nothrow) BackgroundSizeStyleValue(size_x, size_y));
2424
}
2525
virtual ~BackgroundSizeStyleValue() override;
2626

Userland/Libraries/LibWeb/CSS/StyleValues/BackgroundStyleValue.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ namespace Web::CSS {
1515

1616
class BackgroundStyleValue final : public StyleValueWithDefaultOperators<BackgroundStyleValue> {
1717
public:
18-
static ErrorOr<ValueComparingNonnullRefPtr<BackgroundStyleValue>> create(
18+
static ValueComparingNonnullRefPtr<BackgroundStyleValue> create(
1919
ValueComparingNonnullRefPtr<StyleValue const> color,
2020
ValueComparingNonnullRefPtr<StyleValue const> image,
2121
ValueComparingNonnullRefPtr<StyleValue const> position,
@@ -25,7 +25,7 @@ class BackgroundStyleValue final : public StyleValueWithDefaultOperators<Backgro
2525
ValueComparingNonnullRefPtr<StyleValue const> origin,
2626
ValueComparingNonnullRefPtr<StyleValue const> clip)
2727
{
28-
return adopt_nonnull_ref_or_enomem(new (nothrow) BackgroundStyleValue(move(color), move(image), move(position), move(size), move(repeat), move(attachment), move(origin), move(clip)));
28+
return adopt_ref(*new (nothrow) BackgroundStyleValue(move(color), move(image), move(position), move(size), move(repeat), move(attachment), move(origin), move(clip)));
2929
}
3030
virtual ~BackgroundStyleValue() override;
3131

Userland/Libraries/LibWeb/CSS/StyleValues/BorderRadiusShorthandStyleValue.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ namespace Web::CSS {
1616

1717
class BorderRadiusShorthandStyleValue final : public StyleValueWithDefaultOperators<BorderRadiusShorthandStyleValue> {
1818
public:
19-
static ErrorOr<ValueComparingNonnullRefPtr<BorderRadiusShorthandStyleValue>> create(
19+
static ValueComparingNonnullRefPtr<BorderRadiusShorthandStyleValue> create(
2020
ValueComparingNonnullRefPtr<BorderRadiusStyleValue const> top_left,
2121
ValueComparingNonnullRefPtr<BorderRadiusStyleValue const> top_right,
2222
ValueComparingNonnullRefPtr<BorderRadiusStyleValue const> bottom_right,
2323
ValueComparingNonnullRefPtr<BorderRadiusStyleValue const> bottom_left)
2424
{
25-
return adopt_nonnull_ref_or_enomem(new (nothrow) BorderRadiusShorthandStyleValue(move(top_left), move(top_right), move(bottom_right), move(bottom_left)));
25+
return adopt_ref(*new (nothrow) BorderRadiusShorthandStyleValue(move(top_left), move(top_right), move(bottom_right), move(bottom_left)));
2626
}
2727
virtual ~BorderRadiusShorthandStyleValue() override = default;
2828

Userland/Libraries/LibWeb/CSS/StyleValues/BorderRadiusStyleValue.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ namespace Web::CSS {
1717

1818
class BorderRadiusStyleValue final : public StyleValueWithDefaultOperators<BorderRadiusStyleValue> {
1919
public:
20-
static ErrorOr<ValueComparingNonnullRefPtr<BorderRadiusStyleValue>> create(LengthPercentage const& horizontal_radius, LengthPercentage const& vertical_radius)
20+
static ValueComparingNonnullRefPtr<BorderRadiusStyleValue> create(LengthPercentage const& horizontal_radius, LengthPercentage const& vertical_radius)
2121
{
22-
return adopt_nonnull_ref_or_enomem(new (nothrow) BorderRadiusStyleValue(horizontal_radius, vertical_radius));
22+
return adopt_ref(*new (nothrow) BorderRadiusStyleValue(horizontal_radius, vertical_radius));
2323
}
2424
virtual ~BorderRadiusStyleValue() override = default;
2525

Userland/Libraries/LibWeb/CSS/StyleValues/BorderStyleValue.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ namespace Web::CSS {
1515

1616
class BorderStyleValue final : public StyleValueWithDefaultOperators<BorderStyleValue> {
1717
public:
18-
static ErrorOr<ValueComparingNonnullRefPtr<BorderStyleValue>> create(
18+
static ValueComparingNonnullRefPtr<BorderStyleValue> create(
1919
ValueComparingNonnullRefPtr<StyleValue> border_width,
2020
ValueComparingNonnullRefPtr<StyleValue> border_style,
2121
ValueComparingNonnullRefPtr<StyleValue> border_color)
2222
{
23-
return adopt_nonnull_ref_or_enomem(new (nothrow) BorderStyleValue(move(border_width), move(border_style), move(border_color)));
23+
return adopt_ref(*new (nothrow) BorderStyleValue(move(border_width), move(border_style), move(border_color)));
2424
}
2525
virtual ~BorderStyleValue() override;
2626

0 commit comments

Comments
 (0)