1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 03:07:43 +00:00

LibWeb: Make StyleValue constructors infallible

This commit is contained in:
Sam Atkins 2023-08-19 14:00:10 +01:00 committed by Andreas Kling
parent b2b99aba95
commit 8a8cc18cf4
86 changed files with 352 additions and 352 deletions

View file

@ -2692,9 +2692,9 @@ ErrorOr<RefPtr<StyleValue>> Parser::parse_aspect_ratio_value(Vector<ComponentVal
} }
if (auto_value && ratio_value) { if (auto_value && ratio_value) {
return TRY(StyleValueList::create( return StyleValueList::create(
StyleValueVector { auto_value.release_nonnull(), ratio_value.release_nonnull() }, StyleValueVector { auto_value.release_nonnull(), ratio_value.release_nonnull() },
StyleValueList::Separator::Space)); StyleValueList::Separator::Space);
} }
if (ratio_value) if (ratio_value)
@ -2890,13 +2890,13 @@ ErrorOr<RefPtr<StyleValue>> Parser::parse_background_value(Vector<ComponentValue
background_color = initial_background_color; background_color = initial_background_color;
return BackgroundStyleValue::create( return BackgroundStyleValue::create(
background_color.release_nonnull(), background_color.release_nonnull(),
TRY(StyleValueList::create(move(background_images), StyleValueList::Separator::Comma)), StyleValueList::create(move(background_images), StyleValueList::Separator::Comma),
TRY(StyleValueList::create(move(background_positions), StyleValueList::Separator::Comma)), StyleValueList::create(move(background_positions), StyleValueList::Separator::Comma),
TRY(StyleValueList::create(move(background_sizes), StyleValueList::Separator::Comma)), StyleValueList::create(move(background_sizes), StyleValueList::Separator::Comma),
TRY(StyleValueList::create(move(background_repeats), StyleValueList::Separator::Comma)), StyleValueList::create(move(background_repeats), StyleValueList::Separator::Comma),
TRY(StyleValueList::create(move(background_attachments), StyleValueList::Separator::Comma)), StyleValueList::create(move(background_attachments), StyleValueList::Separator::Comma),
TRY(StyleValueList::create(move(background_origins), StyleValueList::Separator::Comma)), StyleValueList::create(move(background_origins), StyleValueList::Separator::Comma),
TRY(StyleValueList::create(move(background_clips), StyleValueList::Separator::Comma))); StyleValueList::create(move(background_clips), StyleValueList::Separator::Comma));
} }
if (!background_color) if (!background_color)
@ -3096,8 +3096,8 @@ ErrorOr<RefPtr<StyleValue>> Parser::parse_single_background_position_value(Token
transaction.commit(); transaction.commit();
return PositionStyleValue::create( return PositionStyleValue::create(
TRY(EdgeStyleValue::create(horizontal->edge, horizontal->offset)), EdgeStyleValue::create(horizontal->edge, horizontal->offset),
TRY(EdgeStyleValue::create(vertical->edge, vertical->offset))); EdgeStyleValue::create(vertical->edge, vertical->offset));
} }
ErrorOr<RefPtr<StyleValue>> Parser::parse_single_background_position_x_or_y_value(TokenStream<ComponentValue>& tokens, PropertyID property) ErrorOr<RefPtr<StyleValue>> Parser::parse_single_background_position_x_or_y_value(TokenStream<ComponentValue>& tokens, PropertyID property)
@ -3398,14 +3398,14 @@ ErrorOr<RefPtr<StyleValue>> Parser::parse_border_radius_shorthand_value(Vector<C
|| (reading_vertical && vertical_radii.is_empty())) || (reading_vertical && vertical_radii.is_empty()))
return nullptr; return nullptr;
auto top_left_radius = TRY(BorderRadiusStyleValue::create(top_left(horizontal_radii), auto top_left_radius = BorderRadiusStyleValue::create(top_left(horizontal_radii),
vertical_radii.is_empty() ? top_left(horizontal_radii) : top_left(vertical_radii))); vertical_radii.is_empty() ? top_left(horizontal_radii) : top_left(vertical_radii));
auto top_right_radius = TRY(BorderRadiusStyleValue::create(top_right(horizontal_radii), auto top_right_radius = BorderRadiusStyleValue::create(top_right(horizontal_radii),
vertical_radii.is_empty() ? top_right(horizontal_radii) : top_right(vertical_radii))); vertical_radii.is_empty() ? top_right(horizontal_radii) : top_right(vertical_radii));
auto bottom_right_radius = TRY(BorderRadiusStyleValue::create(bottom_right(horizontal_radii), auto bottom_right_radius = BorderRadiusStyleValue::create(bottom_right(horizontal_radii),
vertical_radii.is_empty() ? bottom_right(horizontal_radii) : bottom_right(vertical_radii))); vertical_radii.is_empty() ? bottom_right(horizontal_radii) : bottom_right(vertical_radii));
auto bottom_left_radius = TRY(BorderRadiusStyleValue::create(bottom_left(horizontal_radii), auto bottom_left_radius = BorderRadiusStyleValue::create(bottom_left(horizontal_radii),
vertical_radii.is_empty() ? bottom_left(horizontal_radii) : bottom_left(vertical_radii))); vertical_radii.is_empty() ? bottom_left(horizontal_radii) : bottom_left(vertical_radii));
return BorderRadiusShorthandStyleValue::create(move(top_left_radius), move(top_right_radius), move(bottom_right_radius), move(bottom_left_radius)); return BorderRadiusShorthandStyleValue::create(move(top_left_radius), move(top_right_radius), move(bottom_right_radius), move(bottom_left_radius));
} }
@ -3520,9 +3520,9 @@ ErrorOr<RefPtr<StyleValue>> Parser::parse_single_shadow_value(TokenStream<Compon
// Other lengths default to 0 // Other lengths default to 0
if (!blur_radius) if (!blur_radius)
blur_radius = TRY(LengthStyleValue::create(Length::make_px(0))); blur_radius = LengthStyleValue::create(Length::make_px(0));
if (!spread_distance) if (!spread_distance)
spread_distance = TRY(LengthStyleValue::create(Length::make_px(0))); spread_distance = LengthStyleValue::create(Length::make_px(0));
// Placement is outer by default // Placement is outer by default
if (!placement.has_value()) if (!placement.has_value())
@ -3590,9 +3590,9 @@ ErrorOr<RefPtr<StyleValue>> Parser::parse_content_value(Vector<ComponentValue> c
RefPtr<StyleValueList> alt_text; RefPtr<StyleValueList> alt_text;
if (!alt_text_values.is_empty()) if (!alt_text_values.is_empty())
alt_text = TRY(StyleValueList::create(move(alt_text_values), StyleValueList::Separator::Space)); alt_text = StyleValueList::create(move(alt_text_values), StyleValueList::Separator::Space);
return ContentStyleValue::create(TRY(StyleValueList::create(move(content_values), StyleValueList::Separator::Space)), move(alt_text)); return ContentStyleValue::create(StyleValueList::create(move(content_values), StyleValueList::Separator::Space), move(alt_text));
} }
// https://www.w3.org/TR/css-display-3/#the-display-properties // https://www.w3.org/TR/css-display-3/#the-display-properties
@ -3949,18 +3949,18 @@ ErrorOr<RefPtr<StyleValue>> Parser::parse_flex_value(Vector<ComponentValue> cons
case PropertyID::FlexGrow: { case PropertyID::FlexGrow: {
// NOTE: The spec says that flex-basis should be 0 here, but other engines currently use 0%. // 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 // https://github.com/w3c/csswg-drafts/issues/5742
auto flex_basis = TRY(PercentageStyleValue::create(Percentage(0))); auto flex_basis = PercentageStyleValue::create(Percentage(0));
auto one = TRY(NumberStyleValue::create(1)); auto one = NumberStyleValue::create(1);
return FlexStyleValue::create(*value, one, flex_basis); return FlexStyleValue::create(*value, one, flex_basis);
} }
case PropertyID::FlexBasis: { case PropertyID::FlexBasis: {
auto one = TRY(NumberStyleValue::create(1)); auto one = NumberStyleValue::create(1);
return FlexStyleValue::create(one, one, *value); return FlexStyleValue::create(one, one, *value);
} }
case PropertyID::Flex: { case PropertyID::Flex: {
if (value->is_identifier() && value->to_identifier() == ValueID::None) { if (value->is_identifier() && value->to_identifier() == ValueID::None) {
auto zero = TRY(NumberStyleValue::create(0)); auto zero = NumberStyleValue::create(0);
return FlexStyleValue::create(zero, zero, TRY(IdentifierStyleValue::create(ValueID::Auto))); return FlexStyleValue::create(zero, zero, IdentifierStyleValue::create(ValueID::Auto));
} }
break; break;
} }
@ -4014,7 +4014,7 @@ ErrorOr<RefPtr<StyleValue>> Parser::parse_flex_value(Vector<ComponentValue> cons
if (!flex_basis) { if (!flex_basis) {
// NOTE: The spec says that flex-basis should be 0 here, but other engines currently use 0%. // 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 // https://github.com/w3c/csswg-drafts/issues/5742
flex_basis = TRY(PercentageStyleValue::create(Percentage(0))); flex_basis = PercentageStyleValue::create(Percentage(0));
} }
return FlexStyleValue::create(flex_grow.release_nonnull(), flex_shrink.release_nonnull(), flex_basis.release_nonnull()); return FlexStyleValue::create(flex_grow.release_nonnull(), flex_shrink.release_nonnull(), flex_basis.release_nonnull());
@ -4204,7 +4204,7 @@ ErrorOr<RefPtr<StyleValue>> Parser::parse_font_family_value(TokenStream<Componen
(void)tokens.next_token(); // String (void)tokens.next_token(); // String
if (!next_is_comma_or_eof()) if (!next_is_comma_or_eof())
return nullptr; return nullptr;
TRY(font_families.try_append(TRY(StringStyleValue::create(TRY(String::from_utf8(peek.token().string())))))); TRY(font_families.try_append(StringStyleValue::create(TRY(String::from_utf8(peek.token().string())))));
(void)tokens.next_token(); // Comma (void)tokens.next_token(); // Comma
continue; continue;
} }
@ -4224,7 +4224,7 @@ ErrorOr<RefPtr<StyleValue>> Parser::parse_font_family_value(TokenStream<Componen
(void)tokens.next_token(); // Ident (void)tokens.next_token(); // Ident
if (!next_is_comma_or_eof()) if (!next_is_comma_or_eof())
return nullptr; return nullptr;
TRY(font_families.try_append(TRY(IdentifierStyleValue::create(maybe_ident.value())))); TRY(font_families.try_append(IdentifierStyleValue::create(maybe_ident.value())));
(void)tokens.next_token(); // Comma (void)tokens.next_token(); // Comma
continue; continue;
} }
@ -4236,7 +4236,7 @@ ErrorOr<RefPtr<StyleValue>> Parser::parse_font_family_value(TokenStream<Componen
if (current_name_parts.is_empty()) if (current_name_parts.is_empty())
return nullptr; return nullptr;
(void)tokens.next_token(); // Comma (void)tokens.next_token(); // Comma
TRY(font_families.try_append(TRY(StringStyleValue::create(TRY(String::join(' ', current_name_parts)))))); TRY(font_families.try_append(StringStyleValue::create(TRY(String::join(' ', current_name_parts)))));
current_name_parts.clear(); current_name_parts.clear();
// Can't have a trailing comma // Can't have a trailing comma
if (!tokens.has_next_token()) if (!tokens.has_next_token())
@ -4248,7 +4248,7 @@ ErrorOr<RefPtr<StyleValue>> Parser::parse_font_family_value(TokenStream<Componen
} }
if (!current_name_parts.is_empty()) { if (!current_name_parts.is_empty()) {
TRY(font_families.try_append(TRY(StringStyleValue::create(TRY(String::join(' ', current_name_parts)))))); TRY(font_families.try_append(StringStyleValue::create(TRY(String::join(' ', current_name_parts)))));
current_name_parts.clear(); current_name_parts.clear();
} }
@ -4515,14 +4515,14 @@ ErrorOr<RefPtr<StyleValue>> Parser::parse_list_style_value(Vector<ComponentValue
if (found_nones == 2) { if (found_nones == 2) {
if (list_image || list_type) if (list_image || list_type)
return nullptr; return nullptr;
auto none = TRY(IdentifierStyleValue::create(ValueID::None)); auto none = IdentifierStyleValue::create(ValueID::None);
list_image = none; list_image = none;
list_type = none; list_type = none;
} else if (found_nones == 1) { } else if (found_nones == 1) {
if (list_image && list_type) if (list_image && list_type)
return nullptr; return nullptr;
auto none = TRY(IdentifierStyleValue::create(ValueID::None)); auto none = IdentifierStyleValue::create(ValueID::None);
if (!list_image) if (!list_image)
list_image = none; list_image = none;
if (!list_type) if (!list_type)
@ -4762,21 +4762,21 @@ ErrorOr<RefPtr<StyleValue>> Parser::parse_easing_value(TokenStream<ComponentValu
switch (function_metadata.parameters[argument_index].type) { switch (function_metadata.parameters[argument_index].type) {
case EasingFunctionParameterType::Number: { case EasingFunctionParameterType::Number: {
if (value.is(Token::Type::Number)) if (value.is(Token::Type::Number))
values.append(TRY(NumberStyleValue::create(value.token().number().value()))); values.append(NumberStyleValue::create(value.token().number().value()));
else else
return nullptr; return nullptr;
break; break;
} }
case EasingFunctionParameterType::NumberZeroToOne: { case EasingFunctionParameterType::NumberZeroToOne: {
if (value.is(Token::Type::Number) && value.token().number_value() >= 0 && value.token().number_value() <= 1) if (value.is(Token::Type::Number) && value.token().number_value() >= 0 && value.token().number_value() <= 1)
values.append(TRY(NumberStyleValue::create(value.token().number().value()))); values.append(NumberStyleValue::create(value.token().number().value()));
else else
return nullptr; return nullptr;
break; break;
} }
case EasingFunctionParameterType::Integer: { case EasingFunctionParameterType::Integer: {
if (value.is(Token::Type::Number) && value.token().number().is_integer()) if (value.is(Token::Type::Number) && value.token().number().is_integer())
values.append(TRY(IntegerStyleValue::create(value.token().number().integer_value()))); values.append(IntegerStyleValue::create(value.token().number().integer_value()));
else else
return nullptr; return nullptr;
break; break;
@ -4860,7 +4860,7 @@ ErrorOr<RefPtr<StyleValue>> Parser::parse_transform_value(Vector<ComponentValue>
if (maybe_calc_value && maybe_calc_value->resolves_to_angle()) { if (maybe_calc_value && maybe_calc_value->resolves_to_angle()) {
values.append(maybe_calc_value.release_nonnull()); values.append(maybe_calc_value.release_nonnull());
} else if (value.is(Token::Type::Number) && value.token().number_value() == 0) { } else if (value.is(Token::Type::Number) && value.token().number_value() == 0) {
values.append(TRY(AngleStyleValue::create(Angle::make_degrees(0)))); values.append(AngleStyleValue::create(Angle::make_degrees(0)));
} else { } else {
auto dimension_value = TRY(parse_dimension_value(value)); auto dimension_value = TRY(parse_dimension_value(value));
if (!dimension_value || !dimension_value->is_angle()) if (!dimension_value || !dimension_value->is_angle())
@ -4934,7 +4934,7 @@ ErrorOr<RefPtr<StyleValue>> Parser::parse_transform_value(Vector<ComponentValue>
return nullptr; return nullptr;
} }
transformations.append(TRY(TransformationStyleValue::create(function, move(values)))); transformations.append(TransformationStyleValue::create(function, move(values)));
} }
return StyleValueList::create(move(transformations), StyleValueList::Separator::Space); return StyleValueList::create(move(transformations), StyleValueList::Separator::Space);
} }
@ -4954,7 +4954,7 @@ ErrorOr<RefPtr<StyleValue>> Parser::parse_transform_origin_value(Vector<Componen
NonnullRefPtr<StyleValue> offset; NonnullRefPtr<StyleValue> offset;
}; };
auto to_axis_offset = [](RefPtr<StyleValue> value) -> ErrorOr<Optional<AxisOffset>> { auto to_axis_offset = [](RefPtr<StyleValue> value) -> Optional<AxisOffset> {
if (value->is_percentage()) if (value->is_percentage())
return AxisOffset { Axis::None, value->as_percentage() }; return AxisOffset { Axis::None, value->as_percentage() };
if (value->is_length()) if (value->is_length())
@ -4962,15 +4962,15 @@ ErrorOr<RefPtr<StyleValue>> Parser::parse_transform_origin_value(Vector<Componen
if (value->is_identifier()) { if (value->is_identifier()) {
switch (value->to_identifier()) { switch (value->to_identifier()) {
case ValueID::Top: case ValueID::Top:
return AxisOffset { Axis::Y, TRY(PercentageStyleValue::create(Percentage(0))) }; return AxisOffset { Axis::Y, PercentageStyleValue::create(Percentage(0)) };
case ValueID::Left: case ValueID::Left:
return AxisOffset { Axis::X, TRY(PercentageStyleValue::create(Percentage(0))) }; return AxisOffset { Axis::X, PercentageStyleValue::create(Percentage(0)) };
case ValueID::Center: case ValueID::Center:
return AxisOffset { Axis::None, TRY(PercentageStyleValue::create(Percentage(50))) }; return AxisOffset { Axis::None, PercentageStyleValue::create(Percentage(50)) };
case ValueID::Bottom: case ValueID::Bottom:
return AxisOffset { Axis::Y, TRY(PercentageStyleValue::create(Percentage(100))) }; return AxisOffset { Axis::Y, PercentageStyleValue::create(Percentage(100)) };
case ValueID::Right: case ValueID::Right:
return AxisOffset { Axis::X, TRY(PercentageStyleValue::create(Percentage(100))) }; return AxisOffset { Axis::X, PercentageStyleValue::create(Percentage(100)) };
default: default:
return OptionalNone {}; return OptionalNone {};
} }
@ -4978,7 +4978,7 @@ ErrorOr<RefPtr<StyleValue>> Parser::parse_transform_origin_value(Vector<Componen
return OptionalNone {}; return OptionalNone {};
}; };
auto make_list = [](NonnullRefPtr<StyleValue> const& x_value, NonnullRefPtr<StyleValue> const& y_value) -> ErrorOr<NonnullRefPtr<StyleValueList>> { auto make_list = [](NonnullRefPtr<StyleValue> const& x_value, NonnullRefPtr<StyleValue> const& y_value) -> NonnullRefPtr<StyleValueList> {
StyleValueVector values; StyleValueVector values;
values.append(x_value); values.append(x_value);
values.append(y_value); values.append(y_value);
@ -4988,7 +4988,7 @@ ErrorOr<RefPtr<StyleValue>> Parser::parse_transform_origin_value(Vector<Componen
auto tokens = TokenStream { component_values }; auto tokens = TokenStream { component_values };
switch (component_values.size()) { switch (component_values.size()) {
case 1: { case 1: {
auto single_value = TRY(to_axis_offset(TRY(parse_css_value_for_property(PropertyID::TransformOrigin, tokens)))); auto single_value = to_axis_offset(TRY(parse_css_value_for_property(PropertyID::TransformOrigin, tokens)));
if (!single_value.has_value()) if (!single_value.has_value())
return nullptr; return nullptr;
// If only one value is specified, the second value is assumed to be center. // If only one value is specified, the second value is assumed to be center.
@ -4996,15 +4996,15 @@ ErrorOr<RefPtr<StyleValue>> Parser::parse_transform_origin_value(Vector<Componen
switch (single_value->axis) { switch (single_value->axis) {
case Axis::None: case Axis::None:
case Axis::X: case Axis::X:
return make_list(single_value->offset, TRY(PercentageStyleValue::create(Percentage(50)))); return make_list(single_value->offset, PercentageStyleValue::create(Percentage(50)));
case Axis::Y: case Axis::Y:
return make_list(TRY(PercentageStyleValue::create(Percentage(50))), single_value->offset); return make_list(PercentageStyleValue::create(Percentage(50)), single_value->offset);
} }
VERIFY_NOT_REACHED(); VERIFY_NOT_REACHED();
} }
case 2: { case 2: {
auto first_value = TRY(to_axis_offset(TRY(parse_css_value_for_property(PropertyID::TransformOrigin, tokens)))); auto first_value = to_axis_offset(TRY(parse_css_value_for_property(PropertyID::TransformOrigin, tokens)));
auto second_value = TRY(to_axis_offset(TRY(parse_css_value_for_property(PropertyID::TransformOrigin, tokens)))); auto second_value = to_axis_offset(TRY(parse_css_value_for_property(PropertyID::TransformOrigin, tokens)));
if (!first_value.has_value() || !second_value.has_value()) if (!first_value.has_value() || !second_value.has_value())
return nullptr; return nullptr;
@ -5685,7 +5685,7 @@ Parser::ParseErrorOr<NonnullRefPtr<StyleValue>> Parser::parse_css_value(Property
} }
if (property_id == PropertyID::Custom || contains_var_or_attr) if (property_id == PropertyID::Custom || contains_var_or_attr)
return FIXME_TRY(UnresolvedStyleValue::create(move(component_values), contains_var_or_attr)); return UnresolvedStyleValue::create(move(component_values), contains_var_or_attr);
if (component_values.is_empty()) if (component_values.is_empty())
return ParseError::SyntaxError; return ParseError::SyntaxError;
@ -5904,7 +5904,7 @@ Parser::ParseErrorOr<NonnullRefPtr<StyleValue>> Parser::parse_css_value(Property
return *parsed_values.take_first(); return *parsed_values.take_first();
if (!parsed_values.is_empty() && parsed_values.size() <= property_maximum_value_count(property_id)) if (!parsed_values.is_empty() && parsed_values.size() <= property_maximum_value_count(property_id))
return FIXME_TRY(StyleValueList::create(move(parsed_values), StyleValueList::Separator::Space)); return StyleValueList::create(move(parsed_values), StyleValueList::Separator::Space);
} }
// We have multiple values, but the property claims to accept only a single one, check if it's a shorthand property. // We have multiple values, but the property claims to accept only a single one, check if it's a shorthand property.
@ -5956,10 +5956,10 @@ Parser::ParseErrorOr<NonnullRefPtr<StyleValue>> Parser::parse_css_value(Property
if (it.value.size() == 1) if (it.value.size() == 1)
longhand_values.unchecked_append(it.value.take_first()); longhand_values.unchecked_append(it.value.take_first());
else else
longhand_values.unchecked_append(FIXME_TRY(StyleValueList::create(move(it.value), StyleValueList::Separator::Space))); longhand_values.unchecked_append(StyleValueList::create(move(it.value), StyleValueList::Separator::Space));
} }
return { FIXME_TRY(CompositeStyleValue::create(move(longhand_properties), move(longhand_values))) }; return { CompositeStyleValue::create(move(longhand_properties), move(longhand_values)) };
#undef FIXME_TRY #undef FIXME_TRY
} }
@ -6009,14 +6009,14 @@ ErrorOr<Parser::PropertyAndValue> Parser::parse_css_value_for_properties(Readonl
if (ident.has_value()) { if (ident.has_value()) {
if (auto property = any_property_accepts_identifier(property_ids, ident.value()); property.has_value()) { if (auto property = any_property_accepts_identifier(property_ids, ident.value()); property.has_value()) {
(void)tokens.next_token(); (void)tokens.next_token();
return PropertyAndValue { *property, TRY(IdentifierStyleValue::create(ident.value())) }; return PropertyAndValue { *property, IdentifierStyleValue::create(ident.value()) };
} }
} }
// Custom idents // Custom idents
if (auto property = any_property_accepts_type(property_ids, ValueType::CustomIdent); property.has_value()) { if (auto property = any_property_accepts_type(property_ids, ValueType::CustomIdent); property.has_value()) {
(void)tokens.next_token(); (void)tokens.next_token();
return PropertyAndValue { *property, TRY(CustomIdentStyleValue::create(TRY(FlyString::from_utf8(peek_token.token().ident())))) }; return PropertyAndValue { *property, CustomIdentStyleValue::create(TRY(FlyString::from_utf8(peek_token.token().ident()))) };
} }
} }
@ -6064,7 +6064,7 @@ ErrorOr<Parser::PropertyAndValue> Parser::parse_css_value_for_properties(Readonl
auto percentage = Percentage(peek_token.token().percentage()); auto percentage = Percentage(peek_token.token().percentage());
if (auto property = any_property_accepts_type(property_ids, ValueType::Percentage); property.has_value() && property_accepts_percentage(*property, percentage)) { if (auto property = any_property_accepts_type(property_ids, ValueType::Percentage); property.has_value() && property_accepts_percentage(*property, percentage)) {
(void)tokens.next_token(); (void)tokens.next_token();
return PropertyAndValue { *property, TRY(PercentageStyleValue::create(percentage)) }; return PropertyAndValue { *property, PercentageStyleValue::create(percentage) };
} }
} }
@ -6077,7 +6077,7 @@ ErrorOr<Parser::PropertyAndValue> Parser::parse_css_value_for_properties(Readonl
if (peek_token.is(Token::Type::String)) { if (peek_token.is(Token::Type::String)) {
if (auto property = any_property_accepts_type(property_ids, ValueType::String); property.has_value()) if (auto property = any_property_accepts_type(property_ids, ValueType::String); property.has_value())
return PropertyAndValue { *property, TRY(StringStyleValue::create(TRY(String::from_utf8(tokens.next_token().token().string())))) }; return PropertyAndValue { *property, StringStyleValue::create(TRY(String::from_utf8(tokens.next_token().token().string()))) };
} }
if (auto property = any_property_accepts_type(property_ids, ValueType::Url); property.has_value()) { if (auto property = any_property_accepts_type(property_ids, ValueType::Url); property.has_value()) {
@ -6102,35 +6102,35 @@ ErrorOr<Parser::PropertyAndValue> Parser::parse_css_value_for_properties(Readonl
auto angle = dimension.angle(); auto angle = dimension.angle();
if (auto property = any_property_accepts_type(property_ids, ValueType::Angle); property.has_value() && property_accepts_angle(*property, angle)) { if (auto property = any_property_accepts_type(property_ids, ValueType::Angle); property.has_value() && property_accepts_angle(*property, angle)) {
transaction.commit(); transaction.commit();
return PropertyAndValue { *property, TRY(AngleStyleValue::create(angle)) }; return PropertyAndValue { *property, AngleStyleValue::create(angle) };
} }
} }
if (dimension.is_frequency()) { if (dimension.is_frequency()) {
auto frequency = dimension.frequency(); auto frequency = dimension.frequency();
if (auto property = any_property_accepts_type(property_ids, ValueType::Frequency); property.has_value() && property_accepts_frequency(*property, frequency)) { if (auto property = any_property_accepts_type(property_ids, ValueType::Frequency); property.has_value() && property_accepts_frequency(*property, frequency)) {
transaction.commit(); transaction.commit();
return PropertyAndValue { *property, TRY(FrequencyStyleValue::create(frequency)) }; return PropertyAndValue { *property, FrequencyStyleValue::create(frequency) };
} }
} }
if (dimension.is_length()) { if (dimension.is_length()) {
auto length = dimension.length(); auto length = dimension.length();
if (auto property = any_property_accepts_type(property_ids, ValueType::Length); property.has_value() && property_accepts_length(*property, length)) { if (auto property = any_property_accepts_type(property_ids, ValueType::Length); property.has_value() && property_accepts_length(*property, length)) {
transaction.commit(); transaction.commit();
return PropertyAndValue { *property, TRY(LengthStyleValue::create(length)) }; return PropertyAndValue { *property, LengthStyleValue::create(length) };
} }
} }
if (dimension.is_resolution()) { if (dimension.is_resolution()) {
auto resolution = dimension.resolution(); auto resolution = dimension.resolution();
if (auto property = any_property_accepts_type(property_ids, ValueType::Resolution); property.has_value() && property_accepts_resolution(*property, resolution)) { if (auto property = any_property_accepts_type(property_ids, ValueType::Resolution); property.has_value() && property_accepts_resolution(*property, resolution)) {
transaction.commit(); transaction.commit();
return PropertyAndValue { *property, TRY(ResolutionStyleValue::create(resolution)) }; return PropertyAndValue { *property, ResolutionStyleValue::create(resolution) };
} }
} }
if (dimension.is_time()) { if (dimension.is_time()) {
auto time = dimension.time(); auto time = dimension.time();
if (auto property = any_property_accepts_type(property_ids, ValueType::Time); property.has_value() && property_accepts_time(*property, time)) { if (auto property = any_property_accepts_type(property_ids, ValueType::Time); property.has_value() && property_accepts_time(*property, time)) {
transaction.commit(); transaction.commit();
return PropertyAndValue { *property, TRY(TimeStyleValue::create(time)) }; return PropertyAndValue { *property, TimeStyleValue::create(time) };
} }
} }
} }

View file

@ -129,33 +129,33 @@ static ErrorOr<RefPtr<StyleValue>> style_value_for_display(Display display)
StyleValueVector values; StyleValueVector values;
switch (display.outside()) { switch (display.outside()) {
case Display::Outside::Inline: case Display::Outside::Inline:
TRY(values.try_append(TRY(IdentifierStyleValue::create(ValueID::Inline)))); TRY(values.try_append(IdentifierStyleValue::create(ValueID::Inline)));
break; break;
case Display::Outside::Block: case Display::Outside::Block:
TRY(values.try_append(TRY(IdentifierStyleValue::create(ValueID::Block)))); TRY(values.try_append(IdentifierStyleValue::create(ValueID::Block)));
break; break;
case Display::Outside::RunIn: case Display::Outside::RunIn:
TRY(values.try_append(TRY(IdentifierStyleValue::create(ValueID::RunIn)))); TRY(values.try_append(IdentifierStyleValue::create(ValueID::RunIn)));
break; break;
} }
switch (display.inside()) { switch (display.inside()) {
case Display::Inside::Flow: case Display::Inside::Flow:
TRY(values.try_append(TRY(IdentifierStyleValue::create(ValueID::Flow)))); TRY(values.try_append(IdentifierStyleValue::create(ValueID::Flow)));
break; break;
case Display::Inside::FlowRoot: case Display::Inside::FlowRoot:
TRY(values.try_append(TRY(IdentifierStyleValue::create(ValueID::FlowRoot)))); TRY(values.try_append(IdentifierStyleValue::create(ValueID::FlowRoot)));
break; break;
case Display::Inside::Table: case Display::Inside::Table:
TRY(values.try_append(TRY(IdentifierStyleValue::create(ValueID::Table)))); TRY(values.try_append(IdentifierStyleValue::create(ValueID::Table)));
break; break;
case Display::Inside::Flex: case Display::Inside::Flex:
TRY(values.try_append(TRY(IdentifierStyleValue::create(ValueID::Flex)))); TRY(values.try_append(IdentifierStyleValue::create(ValueID::Flex)));
break; break;
case Display::Inside::Grid: case Display::Inside::Grid:
TRY(values.try_append(TRY(IdentifierStyleValue::create(ValueID::Grid)))); TRY(values.try_append(IdentifierStyleValue::create(ValueID::Grid)));
break; break;
case Display::Inside::Ruby: case Display::Inside::Ruby:
TRY(values.try_append(TRY(IdentifierStyleValue::create(ValueID::Ruby)))); TRY(values.try_append(IdentifierStyleValue::create(ValueID::Ruby)));
break; break;
} }
@ -201,7 +201,7 @@ static NonnullRefPtr<StyleValue const> value_or_default(Optional<StyleProperty>
return default_style; return default_style;
} }
static ErrorOr<NonnullRefPtr<StyleValue const>> style_value_for_length_percentage(LengthPercentage const& length_percentage) static NonnullRefPtr<StyleValue const> style_value_for_length_percentage(LengthPercentage const& length_percentage)
{ {
if (length_percentage.is_auto()) if (length_percentage.is_auto())
return IdentifierStyleValue::create(ValueID::Auto); return IdentifierStyleValue::create(ValueID::Auto);
@ -212,7 +212,7 @@ static ErrorOr<NonnullRefPtr<StyleValue const>> style_value_for_length_percentag
return length_percentage.calculated(); return length_percentage.calculated();
} }
static ErrorOr<NonnullRefPtr<StyleValue const>> style_value_for_size(Size const& size) static NonnullRefPtr<StyleValue const> style_value_for_size(Size const& size)
{ {
if (size.is_none()) if (size.is_none())
return IdentifierStyleValue::create(ValueID::None); return IdentifierStyleValue::create(ValueID::None);
@ -232,7 +232,7 @@ static ErrorOr<NonnullRefPtr<StyleValue const>> style_value_for_size(Size const&
TODO(); TODO();
} }
static ErrorOr<NonnullRefPtr<StyleValue const>> style_value_for_sided_shorthand(ValueComparingNonnullRefPtr<StyleValue const> top, ValueComparingNonnullRefPtr<StyleValue const> right, ValueComparingNonnullRefPtr<StyleValue const> bottom, ValueComparingNonnullRefPtr<StyleValue const> left) static NonnullRefPtr<StyleValue const> style_value_for_sided_shorthand(ValueComparingNonnullRefPtr<StyleValue const> top, ValueComparingNonnullRefPtr<StyleValue const> right, ValueComparingNonnullRefPtr<StyleValue const> bottom, ValueComparingNonnullRefPtr<StyleValue const> left)
{ {
bool top_and_bottom_same = top == bottom; bool top_and_bottom_same = top == bottom;
bool left_and_right_same = left == right; bool left_and_right_same = left == right;
@ -249,7 +249,7 @@ static ErrorOr<NonnullRefPtr<StyleValue const>> style_value_for_sided_shorthand(
return StyleValueList::create(StyleValueVector { move(top), move(right), move(bottom), move(left) }, StyleValueList::Separator::Space); return StyleValueList::create(StyleValueVector { move(top), move(right), move(bottom), move(left) }, StyleValueList::Separator::Space);
} }
static ErrorOr<NonnullRefPtr<StyleValue const>> style_value_for_svg_paint(Optional<SVGPaint> const& maybe_paint) static NonnullRefPtr<StyleValue const> style_value_for_svg_paint(Optional<SVGPaint> const& maybe_paint)
{ {
if (!maybe_paint.has_value()) if (!maybe_paint.has_value())
return IdentifierStyleValue::create(ValueID::None); return IdentifierStyleValue::create(ValueID::None);
@ -269,29 +269,29 @@ ErrorOr<RefPtr<StyleValue const>> ResolvedCSSStyleDeclaration::style_value_for_p
case PropertyID::AccentColor: { case PropertyID::AccentColor: {
auto accent_color = layout_node.computed_values().accent_color(); auto accent_color = layout_node.computed_values().accent_color();
if (accent_color.has_value()) if (accent_color.has_value())
return TRY(ColorStyleValue::create(accent_color.value())); return ColorStyleValue::create(accent_color.value());
return TRY(IdentifierStyleValue::create(ValueID::Auto)); return IdentifierStyleValue::create(ValueID::Auto);
} }
case PropertyID::AlignContent: case PropertyID::AlignContent:
return TRY(IdentifierStyleValue::create(to_value_id(layout_node.computed_values().align_content()))); return IdentifierStyleValue::create(to_value_id(layout_node.computed_values().align_content()));
case PropertyID::AlignItems: case PropertyID::AlignItems:
return TRY(IdentifierStyleValue::create(to_value_id(layout_node.computed_values().align_items()))); return IdentifierStyleValue::create(to_value_id(layout_node.computed_values().align_items()));
case PropertyID::AlignSelf: case PropertyID::AlignSelf:
return TRY(IdentifierStyleValue::create(to_value_id(layout_node.computed_values().align_self()))); return IdentifierStyleValue::create(to_value_id(layout_node.computed_values().align_self()));
case PropertyID::Appearance: case PropertyID::Appearance:
return TRY(IdentifierStyleValue::create(to_value_id(layout_node.computed_values().appearance()))); return IdentifierStyleValue::create(to_value_id(layout_node.computed_values().appearance()));
case PropertyID::AspectRatio: { case PropertyID::AspectRatio: {
auto aspect_ratio = layout_node.computed_values().aspect_ratio(); auto aspect_ratio = layout_node.computed_values().aspect_ratio();
if (aspect_ratio.use_natural_aspect_ratio_if_available && aspect_ratio.preferred_ratio.has_value()) { if (aspect_ratio.use_natural_aspect_ratio_if_available && aspect_ratio.preferred_ratio.has_value()) {
return TRY(StyleValueList::create( return StyleValueList::create(
StyleValueVector { StyleValueVector {
TRY(IdentifierStyleValue::create(ValueID::Auto)), IdentifierStyleValue::create(ValueID::Auto),
TRY(RatioStyleValue::create(aspect_ratio.preferred_ratio.value())) }, RatioStyleValue::create(aspect_ratio.preferred_ratio.value()) },
StyleValueList::Separator::Space)); StyleValueList::Separator::Space);
} }
if (aspect_ratio.preferred_ratio.has_value()) if (aspect_ratio.preferred_ratio.has_value())
return TRY(RatioStyleValue::create(aspect_ratio.preferred_ratio.value())); return RatioStyleValue::create(aspect_ratio.preferred_ratio.value());
return TRY(IdentifierStyleValue::create(ValueID::Auto)); return IdentifierStyleValue::create(ValueID::Auto);
} }
case PropertyID::Background: { case PropertyID::Background: {
auto maybe_background_color = property(PropertyID::BackgroundColor); auto maybe_background_color = property(PropertyID::BackgroundColor);
@ -304,14 +304,14 @@ ErrorOr<RefPtr<StyleValue const>> ResolvedCSSStyleDeclaration::style_value_for_p
auto maybe_background_clip = property(PropertyID::BackgroundClip); auto maybe_background_clip = property(PropertyID::BackgroundClip);
return BackgroundStyleValue::create( return BackgroundStyleValue::create(
value_or_default(maybe_background_color, TRY(InitialStyleValue::the())), value_or_default(maybe_background_color, InitialStyleValue::the()),
value_or_default(maybe_background_image, TRY(IdentifierStyleValue::create(ValueID::None))), value_or_default(maybe_background_image, IdentifierStyleValue::create(ValueID::None)),
value_or_default(maybe_background_position, TRY(PositionStyleValue::create(TRY(EdgeStyleValue::create(PositionEdge::Left, Length::make_px(0))), TRY(EdgeStyleValue::create(PositionEdge::Top, Length::make_px(0)))))), value_or_default(maybe_background_position, PositionStyleValue::create(EdgeStyleValue::create(PositionEdge::Left, Length::make_px(0)), EdgeStyleValue::create(PositionEdge::Top, Length::make_px(0)))),
value_or_default(maybe_background_size, TRY(IdentifierStyleValue::create(ValueID::Auto))), value_or_default(maybe_background_size, IdentifierStyleValue::create(ValueID::Auto)),
value_or_default(maybe_background_repeat, TRY(BackgroundRepeatStyleValue::create(Repeat::Repeat, Repeat::Repeat))), value_or_default(maybe_background_repeat, BackgroundRepeatStyleValue::create(Repeat::Repeat, Repeat::Repeat)),
value_or_default(maybe_background_attachment, TRY(IdentifierStyleValue::create(ValueID::Scroll))), value_or_default(maybe_background_attachment, IdentifierStyleValue::create(ValueID::Scroll)),
value_or_default(maybe_background_origin, TRY(IdentifierStyleValue::create(ValueID::PaddingBox))), value_or_default(maybe_background_origin, IdentifierStyleValue::create(ValueID::PaddingBox)),
value_or_default(maybe_background_clip, TRY(IdentifierStyleValue::create(ValueID::BorderBox)))); value_or_default(maybe_background_clip, IdentifierStyleValue::create(ValueID::BorderBox)));
} }
case PropertyID::BackgroundAttachment: case PropertyID::BackgroundAttachment:
return style_value_for_background_property( return style_value_for_background_property(
@ -344,13 +344,13 @@ ErrorOr<RefPtr<StyleValue const>> ResolvedCSSStyleDeclaration::style_value_for_p
layout_node, layout_node,
[](auto& layer) -> ErrorOr<NonnullRefPtr<StyleValue>> { [](auto& layer) -> ErrorOr<NonnullRefPtr<StyleValue>> {
return PositionStyleValue::create( return PositionStyleValue::create(
TRY(EdgeStyleValue::create(layer.position_edge_x, layer.position_offset_x)), EdgeStyleValue::create(layer.position_edge_x, layer.position_offset_x),
TRY(EdgeStyleValue::create(layer.position_edge_y, layer.position_offset_y))); EdgeStyleValue::create(layer.position_edge_y, layer.position_offset_y));
}, },
[]() -> ErrorOr<NonnullRefPtr<StyleValue>> { []() -> ErrorOr<NonnullRefPtr<StyleValue>> {
return PositionStyleValue::create( return PositionStyleValue::create(
TRY(EdgeStyleValue::create(PositionEdge::Left, Percentage(0))), EdgeStyleValue::create(PositionEdge::Left, Percentage(0)),
TRY(EdgeStyleValue::create(PositionEdge::Top, Percentage(0)))); EdgeStyleValue::create(PositionEdge::Top, Percentage(0)));
}); });
case PropertyID::BackgroundPositionX: case PropertyID::BackgroundPositionX:
return style_value_for_background_property( return style_value_for_background_property(
@ -367,8 +367,8 @@ ErrorOr<RefPtr<StyleValue const>> ResolvedCSSStyleDeclaration::style_value_for_p
layout_node, layout_node,
[](auto& layer) -> ErrorOr<NonnullRefPtr<StyleValue const>> { [](auto& layer) -> ErrorOr<NonnullRefPtr<StyleValue const>> {
StyleValueVector repeat { StyleValueVector repeat {
TRY(IdentifierStyleValue::create(to_value_id(layer.repeat_x))), IdentifierStyleValue::create(to_value_id(layer.repeat_x)),
TRY(IdentifierStyleValue::create(to_value_id(layer.repeat_y))), IdentifierStyleValue::create(to_value_id(layer.repeat_y)),
}; };
return StyleValueList::create(move(repeat), StyleValueList::Separator::Space); return StyleValueList::create(move(repeat), StyleValueList::Separator::Space);
}, },
@ -396,16 +396,16 @@ ErrorOr<RefPtr<StyleValue const>> ResolvedCSSStyleDeclaration::style_value_for_p
// `border` only has a reasonable value if all four sides are the same. // `border` only has a reasonable value if all four sides are the same.
if (top != right || top != bottom || top != left) if (top != right || top != bottom || top != left)
return nullptr; return nullptr;
auto width = TRY(LengthStyleValue::create(Length::make_px(top.width))); auto width = LengthStyleValue::create(Length::make_px(top.width));
auto style = TRY(IdentifierStyleValue::create(to_value_id(top.line_style))); auto style = IdentifierStyleValue::create(to_value_id(top.line_style));
auto color = TRY(ColorStyleValue::create(top.color)); auto color = ColorStyleValue::create(top.color);
return BorderStyleValue::create(width, style, color); return BorderStyleValue::create(width, style, color);
} }
case PropertyID::BorderBottom: { case PropertyID::BorderBottom: {
auto border = layout_node.computed_values().border_bottom(); auto border = layout_node.computed_values().border_bottom();
auto width = TRY(LengthStyleValue::create(Length::make_px(border.width))); auto width = LengthStyleValue::create(Length::make_px(border.width));
auto style = TRY(IdentifierStyleValue::create(to_value_id(border.line_style))); auto style = IdentifierStyleValue::create(to_value_id(border.line_style));
auto color = TRY(ColorStyleValue::create(border.color)); auto color = ColorStyleValue::create(border.color);
return BorderStyleValue::create(width, style, color); return BorderStyleValue::create(width, style, color);
} }
case PropertyID::BorderBottomColor: case PropertyID::BorderBottomColor:
@ -423,19 +423,19 @@ ErrorOr<RefPtr<StyleValue const>> ResolvedCSSStyleDeclaration::style_value_for_p
case PropertyID::BorderBottomWidth: case PropertyID::BorderBottomWidth:
return LengthStyleValue::create(Length::make_px(layout_node.computed_values().border_bottom().width)); return LengthStyleValue::create(Length::make_px(layout_node.computed_values().border_bottom().width));
case PropertyID::BorderColor: { case PropertyID::BorderColor: {
auto top = TRY(ColorStyleValue::create(layout_node.computed_values().border_top().color)); auto top = ColorStyleValue::create(layout_node.computed_values().border_top().color);
auto right = TRY(ColorStyleValue::create(layout_node.computed_values().border_right().color)); auto right = ColorStyleValue::create(layout_node.computed_values().border_right().color);
auto bottom = TRY(ColorStyleValue::create(layout_node.computed_values().border_bottom().color)); auto bottom = ColorStyleValue::create(layout_node.computed_values().border_bottom().color);
auto left = TRY(ColorStyleValue::create(layout_node.computed_values().border_left().color)); auto left = ColorStyleValue::create(layout_node.computed_values().border_left().color);
return style_value_for_sided_shorthand(top, right, bottom, left); return style_value_for_sided_shorthand(top, right, bottom, left);
} }
case PropertyID::BorderCollapse: case PropertyID::BorderCollapse:
return IdentifierStyleValue::create(to_value_id(layout_node.computed_values().border_collapse())); return IdentifierStyleValue::create(to_value_id(layout_node.computed_values().border_collapse()));
case PropertyID::BorderLeft: { case PropertyID::BorderLeft: {
auto border = layout_node.computed_values().border_left(); auto border = layout_node.computed_values().border_left();
auto width = TRY(LengthStyleValue::create(Length::make_px(border.width))); auto width = LengthStyleValue::create(Length::make_px(border.width));
auto style = TRY(IdentifierStyleValue::create(to_value_id(border.line_style))); auto style = IdentifierStyleValue::create(to_value_id(border.line_style));
auto color = TRY(ColorStyleValue::create(border.color)); auto color = ColorStyleValue::create(border.color);
return BorderStyleValue::create(width, style, color); return BorderStyleValue::create(width, style, color);
} }
case PropertyID::BorderLeftColor: case PropertyID::BorderLeftColor:
@ -471,9 +471,9 @@ ErrorOr<RefPtr<StyleValue const>> ResolvedCSSStyleDeclaration::style_value_for_p
} }
case PropertyID::BorderRight: { case PropertyID::BorderRight: {
auto border = layout_node.computed_values().border_right(); auto border = layout_node.computed_values().border_right();
auto width = TRY(LengthStyleValue::create(Length::make_px(border.width))); auto width = LengthStyleValue::create(Length::make_px(border.width));
auto style = TRY(IdentifierStyleValue::create(to_value_id(border.line_style))); auto style = IdentifierStyleValue::create(to_value_id(border.line_style));
auto color = TRY(ColorStyleValue::create(border.color)); auto color = ColorStyleValue::create(border.color);
return BorderStyleValue::create(width, style, color); return BorderStyleValue::create(width, style, color);
} }
case PropertyID::BorderRightColor: case PropertyID::BorderRightColor:
@ -489,23 +489,23 @@ ErrorOr<RefPtr<StyleValue const>> ResolvedCSSStyleDeclaration::style_value_for_p
return LengthStyleValue::create(horizontal); return LengthStyleValue::create(horizontal);
return StyleValueList::create( return StyleValueList::create(
{ {
TRY(LengthStyleValue::create(horizontal)), LengthStyleValue::create(horizontal),
TRY(LengthStyleValue::create(vertical)), LengthStyleValue::create(vertical),
}, },
StyleValueList::Separator::Space); StyleValueList::Separator::Space);
} }
case PropertyID::BorderStyle: { case PropertyID::BorderStyle: {
auto top = TRY(IdentifierStyleValue::create(to_value_id(layout_node.computed_values().border_top().line_style))); auto top = IdentifierStyleValue::create(to_value_id(layout_node.computed_values().border_top().line_style));
auto right = TRY(IdentifierStyleValue::create(to_value_id(layout_node.computed_values().border_right().line_style))); auto right = IdentifierStyleValue::create(to_value_id(layout_node.computed_values().border_right().line_style));
auto bottom = TRY(IdentifierStyleValue::create(to_value_id(layout_node.computed_values().border_bottom().line_style))); auto bottom = IdentifierStyleValue::create(to_value_id(layout_node.computed_values().border_bottom().line_style));
auto left = TRY(IdentifierStyleValue::create(to_value_id(layout_node.computed_values().border_left().line_style))); auto left = IdentifierStyleValue::create(to_value_id(layout_node.computed_values().border_left().line_style));
return style_value_for_sided_shorthand(top, right, bottom, left); return style_value_for_sided_shorthand(top, right, bottom, left);
} }
case PropertyID::BorderTop: { case PropertyID::BorderTop: {
auto border = layout_node.computed_values().border_top(); auto border = layout_node.computed_values().border_top();
auto width = TRY(LengthStyleValue::create(Length::make_px(border.width))); auto width = LengthStyleValue::create(Length::make_px(border.width));
auto style = TRY(IdentifierStyleValue::create(to_value_id(border.line_style))); auto style = IdentifierStyleValue::create(to_value_id(border.line_style));
auto color = TRY(ColorStyleValue::create(border.color)); auto color = ColorStyleValue::create(border.color);
return BorderStyleValue::create(width, style, color); return BorderStyleValue::create(width, style, color);
} }
case PropertyID::BorderTopColor: case PropertyID::BorderTopColor:
@ -523,10 +523,10 @@ ErrorOr<RefPtr<StyleValue const>> ResolvedCSSStyleDeclaration::style_value_for_p
case PropertyID::BorderTopWidth: case PropertyID::BorderTopWidth:
return LengthStyleValue::create(Length::make_px(layout_node.computed_values().border_top().width)); return LengthStyleValue::create(Length::make_px(layout_node.computed_values().border_top().width));
case PropertyID::BorderWidth: { case PropertyID::BorderWidth: {
auto top = TRY(LengthStyleValue::create(Length::make_px(layout_node.computed_values().border_top().width))); auto top = LengthStyleValue::create(Length::make_px(layout_node.computed_values().border_top().width));
auto right = TRY(LengthStyleValue::create(Length::make_px(layout_node.computed_values().border_right().width))); auto right = LengthStyleValue::create(Length::make_px(layout_node.computed_values().border_right().width));
auto bottom = TRY(LengthStyleValue::create(Length::make_px(layout_node.computed_values().border_bottom().width))); auto bottom = LengthStyleValue::create(Length::make_px(layout_node.computed_values().border_bottom().width));
auto left = TRY(LengthStyleValue::create(Length::make_px(layout_node.computed_values().border_left().width))); auto left = LengthStyleValue::create(Length::make_px(layout_node.computed_values().border_left().width));
return style_value_for_sided_shorthand(top, right, bottom, left); return style_value_for_sided_shorthand(top, right, bottom, left);
} }
case PropertyID::Bottom: case PropertyID::Bottom:
@ -537,10 +537,10 @@ ErrorOr<RefPtr<StyleValue const>> ResolvedCSSStyleDeclaration::style_value_for_p
return nullptr; return nullptr;
auto make_box_shadow_style_value = [](ShadowData const& data) -> ErrorOr<NonnullRefPtr<ShadowStyleValue>> { auto make_box_shadow_style_value = [](ShadowData const& data) -> ErrorOr<NonnullRefPtr<ShadowStyleValue>> {
auto offset_x = TRY(LengthStyleValue::create(data.offset_x)); auto offset_x = LengthStyleValue::create(data.offset_x);
auto offset_y = TRY(LengthStyleValue::create(data.offset_y)); auto offset_y = LengthStyleValue::create(data.offset_y);
auto blur_radius = TRY(LengthStyleValue::create(data.blur_radius)); auto blur_radius = LengthStyleValue::create(data.blur_radius);
auto spread_distance = TRY(LengthStyleValue::create(data.spread_distance)); auto spread_distance = LengthStyleValue::create(data.spread_distance);
return ShadowStyleValue::create(data.color, offset_x, offset_y, blur_radius, spread_distance, data.placement); return ShadowStyleValue::create(data.color, offset_x, offset_y, blur_radius, spread_distance, data.placement);
}; };
@ -705,9 +705,9 @@ ErrorOr<RefPtr<StyleValue const>> ResolvedCSSStyleDeclaration::style_value_for_p
case PropertyID::JustifyContent: case PropertyID::JustifyContent:
return IdentifierStyleValue::create(to_value_id(layout_node.computed_values().justify_content())); return IdentifierStyleValue::create(to_value_id(layout_node.computed_values().justify_content()));
case PropertyID::JustifyItems: case PropertyID::JustifyItems:
return TRY(IdentifierStyleValue::create(to_value_id(layout_node.computed_values().justify_items()))); return IdentifierStyleValue::create(to_value_id(layout_node.computed_values().justify_items()));
case PropertyID::JustifySelf: case PropertyID::JustifySelf:
return TRY(IdentifierStyleValue::create(to_value_id(layout_node.computed_values().justify_self()))); return IdentifierStyleValue::create(to_value_id(layout_node.computed_values().justify_self()));
case PropertyID::Left: case PropertyID::Left:
return style_value_for_length_percentage(layout_node.computed_values().inset().left()); return style_value_for_length_percentage(layout_node.computed_values().inset().left());
case PropertyID::LineHeight: case PropertyID::LineHeight:
@ -716,10 +716,10 @@ ErrorOr<RefPtr<StyleValue const>> ResolvedCSSStyleDeclaration::style_value_for_p
return IdentifierStyleValue::create(to_value_id(layout_node.computed_values().list_style_type())); return IdentifierStyleValue::create(to_value_id(layout_node.computed_values().list_style_type()));
case PropertyID::Margin: { case PropertyID::Margin: {
auto margin = layout_node.computed_values().margin(); auto margin = layout_node.computed_values().margin();
auto top = TRY(style_value_for_length_percentage(margin.top())); auto top = style_value_for_length_percentage(margin.top());
auto right = TRY(style_value_for_length_percentage(margin.right())); auto right = style_value_for_length_percentage(margin.right());
auto bottom = TRY(style_value_for_length_percentage(margin.bottom())); auto bottom = style_value_for_length_percentage(margin.bottom());
auto left = TRY(style_value_for_length_percentage(margin.left())); auto left = style_value_for_length_percentage(margin.left());
return style_value_for_sided_shorthand(move(top), move(right), move(bottom), move(left)); return style_value_for_sided_shorthand(move(top), move(right), move(bottom), move(left));
} }
case PropertyID::MarginBottom: case PropertyID::MarginBottom:
@ -763,10 +763,10 @@ ErrorOr<RefPtr<StyleValue const>> ResolvedCSSStyleDeclaration::style_value_for_p
return IdentifierStyleValue::create(to_value_id(layout_node.computed_values().overflow_y())); return IdentifierStyleValue::create(to_value_id(layout_node.computed_values().overflow_y()));
case PropertyID::Padding: { case PropertyID::Padding: {
auto padding = layout_node.computed_values().padding(); auto padding = layout_node.computed_values().padding();
auto top = TRY(style_value_for_length_percentage(padding.top())); auto top = style_value_for_length_percentage(padding.top());
auto right = TRY(style_value_for_length_percentage(padding.right())); auto right = style_value_for_length_percentage(padding.right());
auto bottom = TRY(style_value_for_length_percentage(padding.bottom())); auto bottom = style_value_for_length_percentage(padding.bottom());
auto left = TRY(style_value_for_length_percentage(padding.left())); auto left = style_value_for_length_percentage(padding.left());
return style_value_for_sided_shorthand(move(top), move(right), move(bottom), move(left)); return style_value_for_sided_shorthand(move(top), move(right), move(bottom), move(left));
} }
case PropertyID::PaddingBottom: case PropertyID::PaddingBottom:
@ -809,7 +809,7 @@ ErrorOr<RefPtr<StyleValue const>> ResolvedCSSStyleDeclaration::style_value_for_p
StyleValueVector style_values; StyleValueVector style_values;
TRY(style_values.try_ensure_capacity(text_decoration_lines.size())); TRY(style_values.try_ensure_capacity(text_decoration_lines.size()));
for (auto const& line : text_decoration_lines) { for (auto const& line : text_decoration_lines) {
style_values.unchecked_append(TRY(IdentifierStyleValue::create(to_value_id(line)))); style_values.unchecked_append(IdentifierStyleValue::create(to_value_id(line)));
} }
return StyleValueList::create(move(style_values), StyleValueList::Separator::Space); return StyleValueList::create(move(style_values), StyleValueList::Separator::Space);
} }
@ -848,14 +848,14 @@ ErrorOr<RefPtr<StyleValue const>> ResolvedCSSStyleDeclaration::style_value_for_p
StyleValueVector parameters; StyleValueVector parameters;
TRY(parameters.try_ensure_capacity(6)); TRY(parameters.try_ensure_capacity(6));
parameters.unchecked_append(TRY(NumberStyleValue::create(affine_matrix.a()))); parameters.unchecked_append(NumberStyleValue::create(affine_matrix.a()));
parameters.unchecked_append(TRY(NumberStyleValue::create(affine_matrix.b()))); parameters.unchecked_append(NumberStyleValue::create(affine_matrix.b()));
parameters.unchecked_append(TRY(NumberStyleValue::create(affine_matrix.c()))); parameters.unchecked_append(NumberStyleValue::create(affine_matrix.c()));
parameters.unchecked_append(TRY(NumberStyleValue::create(affine_matrix.d()))); parameters.unchecked_append(NumberStyleValue::create(affine_matrix.d()));
parameters.unchecked_append(TRY(NumberStyleValue::create(affine_matrix.e()))); parameters.unchecked_append(NumberStyleValue::create(affine_matrix.e()));
parameters.unchecked_append(TRY(NumberStyleValue::create(affine_matrix.f()))); parameters.unchecked_append(NumberStyleValue::create(affine_matrix.f()));
NonnullRefPtr<StyleValue> matrix_function = TRY(TransformationStyleValue::create(TransformFunction::Matrix, move(parameters))); NonnullRefPtr<StyleValue> matrix_function = TransformationStyleValue::create(TransformFunction::Matrix, move(parameters));
// Elsewhere we always store the transform property's value as a StyleValueList of TransformationStyleValues, // Elsewhere we always store the transform property's value as a StyleValueList of TransformationStyleValues,
// so this is just for consistency. // so this is just for consistency.
StyleValueVector matrix_functions { matrix_function }; StyleValueVector matrix_functions { matrix_function };

View file

@ -688,8 +688,8 @@ static void set_property_expanding_shorthands(StyleProperties& style, CSS::Prope
y_positions.unchecked_append(layer); y_positions.unchecked_append(layer);
} }
} }
set_longhand_property(CSS::PropertyID::BackgroundPositionX, StyleValueList::create(move(x_positions), values_list.separator()).release_value_but_fixme_should_propagate_errors()); set_longhand_property(CSS::PropertyID::BackgroundPositionX, StyleValueList::create(move(x_positions), values_list.separator()));
set_longhand_property(CSS::PropertyID::BackgroundPositionY, StyleValueList::create(move(y_positions), values_list.separator()).release_value_but_fixme_should_propagate_errors()); set_longhand_property(CSS::PropertyID::BackgroundPositionY, StyleValueList::create(move(y_positions), values_list.separator()));
} else { } else {
set_longhand_property(CSS::PropertyID::BackgroundPositionX, value); set_longhand_property(CSS::PropertyID::BackgroundPositionX, value);
set_longhand_property(CSS::PropertyID::BackgroundPositionY, value); set_longhand_property(CSS::PropertyID::BackgroundPositionY, value);
@ -2320,8 +2320,8 @@ void StyleComputer::compute_font(StyleProperties& style, DOM::Element const* ele
auto found_font = compute_font_for_style_values(element, pseudo_element, font_family, font_size, font_style, font_weight, font_stretch); auto found_font = compute_font_for_style_values(element, pseudo_element, font_family, font_size, font_style, font_weight, font_stretch);
style.set_property(CSS::PropertyID::FontSize, LengthStyleValue::create(CSS::Length::make_px(found_font->pixel_size())).release_value_but_fixme_should_propagate_errors(), nullptr); style.set_property(CSS::PropertyID::FontSize, LengthStyleValue::create(CSS::Length::make_px(found_font->pixel_size())), nullptr);
style.set_property(CSS::PropertyID::FontWeight, NumberStyleValue::create(font_weight->to_font_weight()).release_value_but_fixme_should_propagate_errors()); style.set_property(CSS::PropertyID::FontWeight, NumberStyleValue::create(font_weight->to_font_weight()));
style.set_computed_font(found_font.release_nonnull()); style.set_computed_font(found_font.release_nonnull());
@ -2370,8 +2370,8 @@ ErrorOr<void> StyleComputer::absolutize_values(StyleProperties& style, DOM::Elem
// because most percentages are relative to containing block metrics. // because most percentages are relative to containing block metrics.
auto line_height_value_slot = style.m_property_values[to_underlying(CSS::PropertyID::LineHeight)].map([](auto& x) -> auto& { return x.style; }); auto line_height_value_slot = style.m_property_values[to_underlying(CSS::PropertyID::LineHeight)].map([](auto& x) -> auto& { return x.style; });
if (line_height_value_slot.has_value() && (*line_height_value_slot)->is_percentage()) { if (line_height_value_slot.has_value() && (*line_height_value_slot)->is_percentage()) {
*line_height_value_slot = TRY(LengthStyleValue::create( *line_height_value_slot = LengthStyleValue::create(
Length::make_px(font_size * static_cast<double>((*line_height_value_slot)->as_percentage().percentage().as_fraction())))); Length::make_px(font_size * static_cast<double>((*line_height_value_slot)->as_percentage().percentage().as_fraction())));
} }
auto line_height = style.line_height(viewport_rect(), font_metrics, m_root_element_font_metrics); auto line_height = style.line_height(viewport_rect(), font_metrics, m_root_element_font_metrics);
@ -2379,7 +2379,7 @@ ErrorOr<void> StyleComputer::absolutize_values(StyleProperties& style, DOM::Elem
// NOTE: line-height might be using lh which should be resolved against the parent line height (like we did here already) // NOTE: line-height might be using lh which should be resolved against the parent line height (like we did here already)
if (line_height_value_slot.has_value() && (*line_height_value_slot)->is_length()) if (line_height_value_slot.has_value() && (*line_height_value_slot)->is_length())
(*line_height_value_slot) = TRY(LengthStyleValue::create(Length::make_px(line_height))); (*line_height_value_slot) = LengthStyleValue::create(Length::make_px(line_height));
for (size_t i = 0; i < style.m_property_values.size(); ++i) { for (size_t i = 0; i < style.m_property_values.size(); ++i) {
auto& value_slot = style.m_property_values[i]; auto& value_slot = style.m_property_values[i];
@ -2479,7 +2479,7 @@ void StyleComputer::transform_box_type_if_needed(StyleProperties& style, DOM::El
} }
if (new_display != display) if (new_display != display)
style.set_property(CSS::PropertyID::Display, DisplayStyleValue::create(new_display).release_value_but_fixme_should_propagate_errors(), style.property_source_declaration(CSS::PropertyID::Display)); style.set_property(CSS::PropertyID::Display, DisplayStyleValue::create(new_display), style.property_source_declaration(CSS::PropertyID::Display));
} }
NonnullRefPtr<StyleProperties> StyleComputer::create_document_style() const NonnullRefPtr<StyleProperties> StyleComputer::create_document_style() const
@ -2488,9 +2488,9 @@ NonnullRefPtr<StyleProperties> StyleComputer::create_document_style() const
compute_font(style, nullptr, {}); compute_font(style, nullptr, {});
compute_defaulted_values(style, nullptr, {}); compute_defaulted_values(style, nullptr, {});
absolutize_values(style, nullptr, {}).release_value_but_fixme_should_propagate_errors(); absolutize_values(style, nullptr, {}).release_value_but_fixme_should_propagate_errors();
style->set_property(CSS::PropertyID::Width, CSS::LengthStyleValue::create(CSS::Length::make_px(viewport_rect().width())).release_value_but_fixme_should_propagate_errors(), nullptr); style->set_property(CSS::PropertyID::Width, CSS::LengthStyleValue::create(CSS::Length::make_px(viewport_rect().width())), nullptr);
style->set_property(CSS::PropertyID::Height, CSS::LengthStyleValue::create(CSS::Length::make_px(viewport_rect().height())).release_value_but_fixme_should_propagate_errors(), nullptr); style->set_property(CSS::PropertyID::Height, CSS::LengthStyleValue::create(CSS::Length::make_px(viewport_rect().height())), nullptr);
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); style->set_property(CSS::PropertyID::Display, CSS::DisplayStyleValue::create(CSS::Display::from_short(CSS::Display::Short::Block)), nullptr);
return style; return style;
} }

View file

@ -16,9 +16,9 @@ namespace Web::CSS {
class AngleStyleValue : public StyleValueWithDefaultOperators<AngleStyleValue> { class AngleStyleValue : public StyleValueWithDefaultOperators<AngleStyleValue> {
public: public:
static ErrorOr<ValueComparingNonnullRefPtr<AngleStyleValue>> create(Angle angle) static ValueComparingNonnullRefPtr<AngleStyleValue> create(Angle angle)
{ {
return adopt_nonnull_ref_or_enomem(new (nothrow) AngleStyleValue(move(angle))); return adopt_ref(*new (nothrow) AngleStyleValue(move(angle)));
} }
virtual ~AngleStyleValue() override; virtual ~AngleStyleValue() override;

View file

@ -16,9 +16,9 @@ namespace Web::CSS {
class BackgroundRepeatStyleValue final : public StyleValueWithDefaultOperators<BackgroundRepeatStyleValue> { class BackgroundRepeatStyleValue final : public StyleValueWithDefaultOperators<BackgroundRepeatStyleValue> {
public: public:
static ErrorOr<ValueComparingNonnullRefPtr<BackgroundRepeatStyleValue>> create(Repeat repeat_x, Repeat repeat_y) static ValueComparingNonnullRefPtr<BackgroundRepeatStyleValue> create(Repeat repeat_x, Repeat repeat_y)
{ {
return adopt_nonnull_ref_or_enomem(new (nothrow) BackgroundRepeatStyleValue(repeat_x, repeat_y)); return adopt_ref(*new (nothrow) BackgroundRepeatStyleValue(repeat_x, repeat_y));
} }
virtual ~BackgroundRepeatStyleValue() override; virtual ~BackgroundRepeatStyleValue() override;

View file

@ -18,9 +18,9 @@ namespace Web::CSS {
// NOTE: This is not used for identifier sizes, like `cover` and `contain`. // NOTE: This is not used for identifier sizes, like `cover` and `contain`.
class BackgroundSizeStyleValue final : public StyleValueWithDefaultOperators<BackgroundSizeStyleValue> { class BackgroundSizeStyleValue final : public StyleValueWithDefaultOperators<BackgroundSizeStyleValue> {
public: public:
static ErrorOr<ValueComparingNonnullRefPtr<BackgroundSizeStyleValue>> create(LengthPercentage size_x, LengthPercentage size_y) static ValueComparingNonnullRefPtr<BackgroundSizeStyleValue> create(LengthPercentage size_x, LengthPercentage size_y)
{ {
return adopt_nonnull_ref_or_enomem(new (nothrow) BackgroundSizeStyleValue(size_x, size_y)); return adopt_ref(*new (nothrow) BackgroundSizeStyleValue(size_x, size_y));
} }
virtual ~BackgroundSizeStyleValue() override; virtual ~BackgroundSizeStyleValue() override;

View file

@ -15,7 +15,7 @@ namespace Web::CSS {
class BackgroundStyleValue final : public StyleValueWithDefaultOperators<BackgroundStyleValue> { class BackgroundStyleValue final : public StyleValueWithDefaultOperators<BackgroundStyleValue> {
public: public:
static ErrorOr<ValueComparingNonnullRefPtr<BackgroundStyleValue>> create( static ValueComparingNonnullRefPtr<BackgroundStyleValue> create(
ValueComparingNonnullRefPtr<StyleValue const> color, ValueComparingNonnullRefPtr<StyleValue const> color,
ValueComparingNonnullRefPtr<StyleValue const> image, ValueComparingNonnullRefPtr<StyleValue const> image,
ValueComparingNonnullRefPtr<StyleValue const> position, ValueComparingNonnullRefPtr<StyleValue const> position,
@ -25,7 +25,7 @@ public:
ValueComparingNonnullRefPtr<StyleValue const> origin, ValueComparingNonnullRefPtr<StyleValue const> origin,
ValueComparingNonnullRefPtr<StyleValue const> clip) ValueComparingNonnullRefPtr<StyleValue const> clip)
{ {
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))); return adopt_ref(*new (nothrow) BackgroundStyleValue(move(color), move(image), move(position), move(size), move(repeat), move(attachment), move(origin), move(clip)));
} }
virtual ~BackgroundStyleValue() override; virtual ~BackgroundStyleValue() override;

View file

@ -16,13 +16,13 @@ namespace Web::CSS {
class BorderRadiusShorthandStyleValue final : public StyleValueWithDefaultOperators<BorderRadiusShorthandStyleValue> { class BorderRadiusShorthandStyleValue final : public StyleValueWithDefaultOperators<BorderRadiusShorthandStyleValue> {
public: public:
static ErrorOr<ValueComparingNonnullRefPtr<BorderRadiusShorthandStyleValue>> create( static ValueComparingNonnullRefPtr<BorderRadiusShorthandStyleValue> create(
ValueComparingNonnullRefPtr<BorderRadiusStyleValue const> top_left, ValueComparingNonnullRefPtr<BorderRadiusStyleValue const> top_left,
ValueComparingNonnullRefPtr<BorderRadiusStyleValue const> top_right, ValueComparingNonnullRefPtr<BorderRadiusStyleValue const> top_right,
ValueComparingNonnullRefPtr<BorderRadiusStyleValue const> bottom_right, ValueComparingNonnullRefPtr<BorderRadiusStyleValue const> bottom_right,
ValueComparingNonnullRefPtr<BorderRadiusStyleValue const> bottom_left) ValueComparingNonnullRefPtr<BorderRadiusStyleValue const> bottom_left)
{ {
return adopt_nonnull_ref_or_enomem(new (nothrow) BorderRadiusShorthandStyleValue(move(top_left), move(top_right), move(bottom_right), move(bottom_left))); return adopt_ref(*new (nothrow) BorderRadiusShorthandStyleValue(move(top_left), move(top_right), move(bottom_right), move(bottom_left)));
} }
virtual ~BorderRadiusShorthandStyleValue() override = default; virtual ~BorderRadiusShorthandStyleValue() override = default;

View file

@ -17,9 +17,9 @@ namespace Web::CSS {
class BorderRadiusStyleValue final : public StyleValueWithDefaultOperators<BorderRadiusStyleValue> { class BorderRadiusStyleValue final : public StyleValueWithDefaultOperators<BorderRadiusStyleValue> {
public: public:
static ErrorOr<ValueComparingNonnullRefPtr<BorderRadiusStyleValue>> create(LengthPercentage const& horizontal_radius, LengthPercentage const& vertical_radius) static ValueComparingNonnullRefPtr<BorderRadiusStyleValue> create(LengthPercentage const& horizontal_radius, LengthPercentage const& vertical_radius)
{ {
return adopt_nonnull_ref_or_enomem(new (nothrow) BorderRadiusStyleValue(horizontal_radius, vertical_radius)); return adopt_ref(*new (nothrow) BorderRadiusStyleValue(horizontal_radius, vertical_radius));
} }
virtual ~BorderRadiusStyleValue() override = default; virtual ~BorderRadiusStyleValue() override = default;

View file

@ -15,12 +15,12 @@ namespace Web::CSS {
class BorderStyleValue final : public StyleValueWithDefaultOperators<BorderStyleValue> { class BorderStyleValue final : public StyleValueWithDefaultOperators<BorderStyleValue> {
public: public:
static ErrorOr<ValueComparingNonnullRefPtr<BorderStyleValue>> create( static ValueComparingNonnullRefPtr<BorderStyleValue> create(
ValueComparingNonnullRefPtr<StyleValue> border_width, ValueComparingNonnullRefPtr<StyleValue> border_width,
ValueComparingNonnullRefPtr<StyleValue> border_style, ValueComparingNonnullRefPtr<StyleValue> border_style,
ValueComparingNonnullRefPtr<StyleValue> border_color) ValueComparingNonnullRefPtr<StyleValue> border_color)
{ {
return adopt_nonnull_ref_or_enomem(new (nothrow) BorderStyleValue(move(border_width), move(border_style), move(border_color))); return adopt_ref(*new (nothrow) BorderStyleValue(move(border_width), move(border_style), move(border_color)));
} }
virtual ~BorderStyleValue() override; virtual ~BorderStyleValue() override;

View file

@ -66,9 +66,9 @@ public:
Value m_value; Value m_value;
}; };
static ErrorOr<ValueComparingNonnullRefPtr<CalculatedStyleValue>> create(NonnullOwnPtr<CalculationNode> calculation, CSSNumericType resolved_type) static ValueComparingNonnullRefPtr<CalculatedStyleValue> create(NonnullOwnPtr<CalculationNode> calculation, CSSNumericType resolved_type)
{ {
return adopt_nonnull_ref_or_enomem(new (nothrow) CalculatedStyleValue(move(calculation), resolved_type)); return adopt_ref(*new (nothrow) CalculatedStyleValue(move(calculation), resolved_type));
} }
ErrorOr<String> to_string() const override; ErrorOr<String> to_string() const override;

View file

@ -12,24 +12,24 @@
namespace Web::CSS { namespace Web::CSS {
ErrorOr<ValueComparingNonnullRefPtr<ColorStyleValue>> ColorStyleValue::create(Color color) ValueComparingNonnullRefPtr<ColorStyleValue> ColorStyleValue::create(Color color)
{ {
if (color.value() == 0) { if (color.value() == 0) {
static auto transparent = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) ColorStyleValue(color))); static auto transparent = adopt_ref(*new (nothrow) ColorStyleValue(color));
return transparent; return transparent;
} }
if (color == Color::from_rgb(0x000000)) { if (color == Color::from_rgb(0x000000)) {
static auto black = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) ColorStyleValue(color))); static auto black = adopt_ref(*new (nothrow) ColorStyleValue(color));
return black; return black;
} }
if (color == Color::from_rgb(0xffffff)) { if (color == Color::from_rgb(0xffffff)) {
static auto white = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) ColorStyleValue(color))); static auto white = adopt_ref(*new (nothrow) ColorStyleValue(color));
return white; return white;
} }
return adopt_nonnull_ref_or_enomem(new (nothrow) ColorStyleValue(color)); return adopt_ref(*new (nothrow) ColorStyleValue(color));
} }
ErrorOr<String> ColorStyleValue::to_string() const ErrorOr<String> ColorStyleValue::to_string() const

View file

@ -16,7 +16,7 @@ namespace Web::CSS {
class ColorStyleValue : public StyleValueWithDefaultOperators<ColorStyleValue> { class ColorStyleValue : public StyleValueWithDefaultOperators<ColorStyleValue> {
public: public:
static ErrorOr<ValueComparingNonnullRefPtr<ColorStyleValue>> create(Color color); static ValueComparingNonnullRefPtr<ColorStyleValue> create(Color color);
virtual ~ColorStyleValue() override = default; virtual ~ColorStyleValue() override = default;
Color color() const { return m_color; } Color color() const { return m_color; }

View file

@ -12,9 +12,9 @@ namespace Web::CSS {
class CompositeStyleValue final : public StyleValueWithDefaultOperators<CompositeStyleValue> { class CompositeStyleValue final : public StyleValueWithDefaultOperators<CompositeStyleValue> {
public: public:
static ErrorOr<ValueComparingNonnullRefPtr<CompositeStyleValue>> create(Vector<PropertyID> sub_properties, Vector<ValueComparingNonnullRefPtr<StyleValue const>> values) static ValueComparingNonnullRefPtr<CompositeStyleValue> create(Vector<PropertyID> sub_properties, Vector<ValueComparingNonnullRefPtr<StyleValue const>> values)
{ {
return adopt_nonnull_ref_or_enomem(new CompositeStyleValue(move(sub_properties), move(values))); return adopt_ref(*new CompositeStyleValue(move(sub_properties), move(values)));
} }
virtual ~CompositeStyleValue() override; virtual ~CompositeStyleValue() override;

View file

@ -18,10 +18,10 @@ namespace Web::CSS {
class ConicGradientStyleValue final : public AbstractImageStyleValue { class ConicGradientStyleValue final : public AbstractImageStyleValue {
public: public:
static ErrorOr<ValueComparingNonnullRefPtr<ConicGradientStyleValue>> create(Angle from_angle, PositionValue position, Vector<AngularColorStopListElement> color_stop_list, GradientRepeating repeating) static ValueComparingNonnullRefPtr<ConicGradientStyleValue> create(Angle from_angle, PositionValue position, Vector<AngularColorStopListElement> color_stop_list, GradientRepeating repeating)
{ {
VERIFY(color_stop_list.size() >= 2); VERIFY(color_stop_list.size() >= 2);
return adopt_nonnull_ref_or_enomem(new (nothrow) ConicGradientStyleValue(from_angle, position, move(color_stop_list), repeating)); return adopt_ref(*new (nothrow) ConicGradientStyleValue(from_angle, position, move(color_stop_list), repeating));
} }
virtual ErrorOr<String> to_string() const override; virtual ErrorOr<String> to_string() const override;

View file

@ -15,9 +15,9 @@ namespace Web::CSS {
class ContentStyleValue final : public StyleValueWithDefaultOperators<ContentStyleValue> { class ContentStyleValue final : public StyleValueWithDefaultOperators<ContentStyleValue> {
public: public:
static ErrorOr<ValueComparingNonnullRefPtr<ContentStyleValue>> create(ValueComparingNonnullRefPtr<StyleValueList> content, ValueComparingRefPtr<StyleValueList> alt_text) static ValueComparingNonnullRefPtr<ContentStyleValue> create(ValueComparingNonnullRefPtr<StyleValueList> content, ValueComparingRefPtr<StyleValueList> alt_text)
{ {
return adopt_nonnull_ref_or_enomem(new (nothrow) ContentStyleValue(move(content), move(alt_text))); return adopt_ref(*new (nothrow) ContentStyleValue(move(content), move(alt_text)));
} }
virtual ~ContentStyleValue() override = default; virtual ~ContentStyleValue() override = default;

View file

@ -14,9 +14,9 @@ namespace Web::CSS {
// https://www.w3.org/TR/css-values-4/#custom-idents // https://www.w3.org/TR/css-values-4/#custom-idents
class CustomIdentStyleValue final : public StyleValueWithDefaultOperators<CustomIdentStyleValue> { class CustomIdentStyleValue final : public StyleValueWithDefaultOperators<CustomIdentStyleValue> {
public: public:
static ErrorOr<ValueComparingNonnullRefPtr<CustomIdentStyleValue>> create(FlyString custom_ident) static ValueComparingNonnullRefPtr<CustomIdentStyleValue> create(FlyString custom_ident)
{ {
return adopt_nonnull_ref_or_enomem(new (nothrow) CustomIdentStyleValue(move(custom_ident))); return adopt_ref(*new (nothrow) CustomIdentStyleValue(move(custom_ident)));
} }
virtual ~CustomIdentStyleValue() override = default; virtual ~CustomIdentStyleValue() override = default;

View file

@ -8,9 +8,9 @@
namespace Web::CSS { namespace Web::CSS {
ErrorOr<ValueComparingNonnullRefPtr<DisplayStyleValue>> DisplayStyleValue::create(Display const& display) ValueComparingNonnullRefPtr<DisplayStyleValue> DisplayStyleValue::create(Display const& display)
{ {
return adopt_nonnull_ref_or_enomem(new (nothrow) DisplayStyleValue(display)); return adopt_ref(*new (nothrow) DisplayStyleValue(display));
} }
} }

View file

@ -13,7 +13,7 @@ namespace Web::CSS {
class DisplayStyleValue : public StyleValueWithDefaultOperators<DisplayStyleValue> { class DisplayStyleValue : public StyleValueWithDefaultOperators<DisplayStyleValue> {
public: public:
static ErrorOr<ValueComparingNonnullRefPtr<DisplayStyleValue>> create(Display const&); static ValueComparingNonnullRefPtr<DisplayStyleValue> create(Display const&);
virtual ~DisplayStyleValue() override = default; virtual ~DisplayStyleValue() override = default;
virtual ErrorOr<String> to_string() const override { return m_display.to_string(); } virtual ErrorOr<String> to_string() const override { return m_display.to_string(); }

View file

@ -17,9 +17,9 @@ namespace Web::CSS {
class EasingStyleValue final : public StyleValueWithDefaultOperators<EasingStyleValue> { class EasingStyleValue final : public StyleValueWithDefaultOperators<EasingStyleValue> {
public: public:
static ErrorOr<ValueComparingNonnullRefPtr<EasingStyleValue>> create(CSS::EasingFunction easing_function, StyleValueVector&& values) static ValueComparingNonnullRefPtr<EasingStyleValue> create(CSS::EasingFunction easing_function, StyleValueVector&& values)
{ {
return adopt_nonnull_ref_or_enomem(new (nothrow) EasingStyleValue(easing_function, move(values))); return adopt_ref(*new (nothrow) EasingStyleValue(easing_function, move(values)));
} }
virtual ~EasingStyleValue() override = default; virtual ~EasingStyleValue() override = default;

View file

@ -14,9 +14,9 @@ namespace Web::CSS {
class EdgeStyleValue final : public StyleValueWithDefaultOperators<EdgeStyleValue> { class EdgeStyleValue final : public StyleValueWithDefaultOperators<EdgeStyleValue> {
public: public:
static ErrorOr<ValueComparingNonnullRefPtr<EdgeStyleValue>> create(PositionEdge edge, LengthPercentage const& offset) static ValueComparingNonnullRefPtr<EdgeStyleValue> create(PositionEdge edge, LengthPercentage const& offset)
{ {
return adopt_nonnull_ref_or_enomem(new (nothrow) EdgeStyleValue(edge, offset)); return adopt_ref(*new (nothrow) EdgeStyleValue(edge, offset));
} }
virtual ~EdgeStyleValue() override = default; virtual ~EdgeStyleValue() override = default;

View file

@ -70,11 +70,11 @@ using FilterFunction = Variant<Filter::Blur, Filter::DropShadow, Filter::HueRota
class FilterValueListStyleValue final : public StyleValueWithDefaultOperators<FilterValueListStyleValue> { class FilterValueListStyleValue final : public StyleValueWithDefaultOperators<FilterValueListStyleValue> {
public: public:
static ErrorOr<ValueComparingNonnullRefPtr<FilterValueListStyleValue>> create( static ValueComparingNonnullRefPtr<FilterValueListStyleValue> create(
Vector<FilterFunction> filter_value_list) Vector<FilterFunction> filter_value_list)
{ {
VERIFY(filter_value_list.size() >= 1); VERIFY(filter_value_list.size() >= 1);
return adopt_nonnull_ref_or_enomem(new (nothrow) FilterValueListStyleValue(move(filter_value_list))); return adopt_ref(*new (nothrow) FilterValueListStyleValue(move(filter_value_list)));
} }
Vector<FilterFunction> const& filter_value_list() const { return m_filter_value_list; } Vector<FilterFunction> const& filter_value_list() const { return m_filter_value_list; }

View file

@ -15,9 +15,9 @@ namespace Web::CSS {
class FlexFlowStyleValue final : public StyleValueWithDefaultOperators<FlexFlowStyleValue> { class FlexFlowStyleValue final : public StyleValueWithDefaultOperators<FlexFlowStyleValue> {
public: public:
static ErrorOr<ValueComparingNonnullRefPtr<FlexFlowStyleValue>> create(ValueComparingNonnullRefPtr<StyleValue> flex_direction, ValueComparingNonnullRefPtr<StyleValue> flex_wrap) static ValueComparingNonnullRefPtr<FlexFlowStyleValue> create(ValueComparingNonnullRefPtr<StyleValue> flex_direction, ValueComparingNonnullRefPtr<StyleValue> flex_wrap)
{ {
return adopt_nonnull_ref_or_enomem(new (nothrow) FlexFlowStyleValue(move(flex_direction), move(flex_wrap))); return adopt_ref(*new (nothrow) FlexFlowStyleValue(move(flex_direction), move(flex_wrap)));
} }
virtual ~FlexFlowStyleValue() override = default; virtual ~FlexFlowStyleValue() override = default;

View file

@ -15,12 +15,12 @@ namespace Web::CSS {
class FlexStyleValue final : public StyleValueWithDefaultOperators<FlexStyleValue> { class FlexStyleValue final : public StyleValueWithDefaultOperators<FlexStyleValue> {
public: public:
static ErrorOr<ValueComparingNonnullRefPtr<FlexStyleValue>> create( static ValueComparingNonnullRefPtr<FlexStyleValue> create(
ValueComparingNonnullRefPtr<StyleValue> grow, ValueComparingNonnullRefPtr<StyleValue> grow,
ValueComparingNonnullRefPtr<StyleValue> shrink, ValueComparingNonnullRefPtr<StyleValue> shrink,
ValueComparingNonnullRefPtr<StyleValue> basis) ValueComparingNonnullRefPtr<StyleValue> basis)
{ {
return adopt_nonnull_ref_or_enomem(new (nothrow) FlexStyleValue(move(grow), move(shrink), move(basis))); return adopt_ref(*new (nothrow) FlexStyleValue(move(grow), move(shrink), move(basis)));
} }
virtual ~FlexStyleValue() override = default; virtual ~FlexStyleValue() override = default;

View file

@ -15,7 +15,7 @@ namespace Web::CSS {
class FontStyleValue final : public StyleValueWithDefaultOperators<FontStyleValue> { class FontStyleValue final : public StyleValueWithDefaultOperators<FontStyleValue> {
public: public:
static ErrorOr<ValueComparingNonnullRefPtr<FontStyleValue>> create( static ValueComparingNonnullRefPtr<FontStyleValue> create(
ValueComparingNonnullRefPtr<StyleValue> font_stretch, ValueComparingNonnullRefPtr<StyleValue> font_stretch,
ValueComparingNonnullRefPtr<StyleValue> font_style, ValueComparingNonnullRefPtr<StyleValue> font_style,
ValueComparingNonnullRefPtr<StyleValue> font_weight, ValueComparingNonnullRefPtr<StyleValue> font_weight,
@ -23,7 +23,7 @@ public:
ValueComparingNonnullRefPtr<StyleValue> line_height, ValueComparingNonnullRefPtr<StyleValue> line_height,
ValueComparingNonnullRefPtr<StyleValue> font_families) ValueComparingNonnullRefPtr<StyleValue> font_families)
{ {
return adopt_nonnull_ref_or_enomem(new (nothrow) FontStyleValue(move(font_stretch), move(font_style), move(font_weight), move(font_size), move(line_height), move(font_families))); return adopt_ref(*new (nothrow) FontStyleValue(move(font_stretch), move(font_style), move(font_weight), move(font_size), move(line_height), move(font_families)));
} }
virtual ~FontStyleValue() override = default; virtual ~FontStyleValue() override = default;

View file

@ -16,9 +16,9 @@ namespace Web::CSS {
class FrequencyStyleValue : public StyleValueWithDefaultOperators<FrequencyStyleValue> { class FrequencyStyleValue : public StyleValueWithDefaultOperators<FrequencyStyleValue> {
public: public:
static ErrorOr<ValueComparingNonnullRefPtr<FrequencyStyleValue>> create(Frequency frequency) static ValueComparingNonnullRefPtr<FrequencyStyleValue> create(Frequency frequency)
{ {
return adopt_nonnull_ref_or_enomem(new (nothrow) FrequencyStyleValue(move(frequency))); return adopt_ref(*new (nothrow) FrequencyStyleValue(move(frequency)));
} }
virtual ~FrequencyStyleValue() override = default; virtual ~FrequencyStyleValue() override = default;

View file

@ -12,22 +12,22 @@
namespace Web::CSS { namespace Web::CSS {
ErrorOr<ValueComparingNonnullRefPtr<GridAreaShorthandStyleValue>> GridAreaShorthandStyleValue::create( ValueComparingNonnullRefPtr<GridAreaShorthandStyleValue> GridAreaShorthandStyleValue::create(
ValueComparingNonnullRefPtr<GridTrackPlacementStyleValue const> row_start, ValueComparingNonnullRefPtr<GridTrackPlacementStyleValue const> row_start,
ValueComparingNonnullRefPtr<GridTrackPlacementStyleValue const> column_start, ValueComparingNonnullRefPtr<GridTrackPlacementStyleValue const> column_start,
ValueComparingNonnullRefPtr<GridTrackPlacementStyleValue const> row_end, ValueComparingNonnullRefPtr<GridTrackPlacementStyleValue const> row_end,
ValueComparingNonnullRefPtr<GridTrackPlacementStyleValue const> column_end) ValueComparingNonnullRefPtr<GridTrackPlacementStyleValue const> column_end)
{ {
return adopt_nonnull_ref_or_enomem(new (nothrow) GridAreaShorthandStyleValue(row_start, column_start, row_end, column_end)); return adopt_ref(*new (nothrow) GridAreaShorthandStyleValue(row_start, column_start, row_end, column_end));
} }
ErrorOr<ValueComparingNonnullRefPtr<GridAreaShorthandStyleValue>> GridAreaShorthandStyleValue::create(GridTrackPlacement row_start, GridTrackPlacement column_start, GridTrackPlacement row_end, GridTrackPlacement column_end) ValueComparingNonnullRefPtr<GridAreaShorthandStyleValue> GridAreaShorthandStyleValue::create(GridTrackPlacement row_start, GridTrackPlacement column_start, GridTrackPlacement row_end, GridTrackPlacement column_end)
{ {
return adopt_nonnull_ref_or_enomem(new (nothrow) GridAreaShorthandStyleValue( return adopt_ref(*new (nothrow) GridAreaShorthandStyleValue(
TRY(GridTrackPlacementStyleValue::create(row_start)), GridTrackPlacementStyleValue::create(row_start),
TRY(GridTrackPlacementStyleValue::create(column_start)), GridTrackPlacementStyleValue::create(column_start),
TRY(GridTrackPlacementStyleValue::create(row_end)), GridTrackPlacementStyleValue::create(row_end),
TRY(GridTrackPlacementStyleValue::create(column_end)))); GridTrackPlacementStyleValue::create(column_end)));
} }
ErrorOr<String> GridAreaShorthandStyleValue::to_string() const ErrorOr<String> GridAreaShorthandStyleValue::to_string() const

View file

@ -15,12 +15,12 @@ namespace Web::CSS {
class GridAreaShorthandStyleValue final : public StyleValueWithDefaultOperators<GridAreaShorthandStyleValue> { class GridAreaShorthandStyleValue final : public StyleValueWithDefaultOperators<GridAreaShorthandStyleValue> {
public: public:
static ErrorOr<ValueComparingNonnullRefPtr<GridAreaShorthandStyleValue>> create( static ValueComparingNonnullRefPtr<GridAreaShorthandStyleValue> create(
ValueComparingNonnullRefPtr<GridTrackPlacementStyleValue const> row_start, ValueComparingNonnullRefPtr<GridTrackPlacementStyleValue const> row_start,
ValueComparingNonnullRefPtr<GridTrackPlacementStyleValue const> column_start, ValueComparingNonnullRefPtr<GridTrackPlacementStyleValue const> column_start,
ValueComparingNonnullRefPtr<GridTrackPlacementStyleValue const> row_end, ValueComparingNonnullRefPtr<GridTrackPlacementStyleValue const> row_end,
ValueComparingNonnullRefPtr<GridTrackPlacementStyleValue const> column_end); ValueComparingNonnullRefPtr<GridTrackPlacementStyleValue const> column_end);
static ErrorOr<ValueComparingNonnullRefPtr<GridAreaShorthandStyleValue>> create(GridTrackPlacement row_start, GridTrackPlacement column_start, GridTrackPlacement row_end, GridTrackPlacement column_end); static ValueComparingNonnullRefPtr<GridAreaShorthandStyleValue> create(GridTrackPlacement row_start, GridTrackPlacement column_start, GridTrackPlacement row_end, GridTrackPlacement column_end);
virtual ~GridAreaShorthandStyleValue() override = default; virtual ~GridAreaShorthandStyleValue() override = default;
auto row_start() const { return m_properties.row_start; } auto row_start() const { return m_properties.row_start; }

View file

@ -11,9 +11,9 @@
namespace Web::CSS { namespace Web::CSS {
ErrorOr<ValueComparingNonnullRefPtr<GridTemplateAreaStyleValue>> GridTemplateAreaStyleValue::create(Vector<Vector<String>> grid_template_area) ValueComparingNonnullRefPtr<GridTemplateAreaStyleValue> GridTemplateAreaStyleValue::create(Vector<Vector<String>> grid_template_area)
{ {
return adopt_nonnull_ref_or_enomem(new (nothrow) GridTemplateAreaStyleValue(grid_template_area)); return adopt_ref(*new (nothrow) GridTemplateAreaStyleValue(grid_template_area));
} }
ErrorOr<String> GridTemplateAreaStyleValue::to_string() const ErrorOr<String> GridTemplateAreaStyleValue::to_string() const

View file

@ -15,7 +15,7 @@ namespace Web::CSS {
class GridTemplateAreaStyleValue final : public StyleValueWithDefaultOperators<GridTemplateAreaStyleValue> { class GridTemplateAreaStyleValue final : public StyleValueWithDefaultOperators<GridTemplateAreaStyleValue> {
public: public:
static ErrorOr<ValueComparingNonnullRefPtr<GridTemplateAreaStyleValue>> create(Vector<Vector<String>> grid_template_area); static ValueComparingNonnullRefPtr<GridTemplateAreaStyleValue> create(Vector<Vector<String>> grid_template_area);
virtual ~GridTemplateAreaStyleValue() override = default; virtual ~GridTemplateAreaStyleValue() override = default;
Vector<Vector<String>> const& grid_template_area() const { return m_grid_template_area; } Vector<Vector<String>> const& grid_template_area() const { return m_grid_template_area; }

View file

@ -12,16 +12,16 @@
namespace Web::CSS { namespace Web::CSS {
ErrorOr<ValueComparingNonnullRefPtr<GridTrackPlacementShorthandStyleValue>> GridTrackPlacementShorthandStyleValue::create(ValueComparingNonnullRefPtr<GridTrackPlacementStyleValue const> start, ValueComparingNonnullRefPtr<GridTrackPlacementStyleValue const> end) ValueComparingNonnullRefPtr<GridTrackPlacementShorthandStyleValue> GridTrackPlacementShorthandStyleValue::create(ValueComparingNonnullRefPtr<GridTrackPlacementStyleValue const> start, ValueComparingNonnullRefPtr<GridTrackPlacementStyleValue const> end)
{ {
return adopt_nonnull_ref_or_enomem(new (nothrow) GridTrackPlacementShorthandStyleValue(move(start), move(end))); return adopt_ref(*new (nothrow) GridTrackPlacementShorthandStyleValue(move(start), move(end)));
} }
ErrorOr<ValueComparingNonnullRefPtr<GridTrackPlacementShorthandStyleValue>> GridTrackPlacementShorthandStyleValue::create(GridTrackPlacement start) ValueComparingNonnullRefPtr<GridTrackPlacementShorthandStyleValue> GridTrackPlacementShorthandStyleValue::create(GridTrackPlacement start)
{ {
return adopt_nonnull_ref_or_enomem(new (nothrow) GridTrackPlacementShorthandStyleValue( return adopt_ref(*new (nothrow) GridTrackPlacementShorthandStyleValue(
TRY(GridTrackPlacementStyleValue::create(start)), GridTrackPlacementStyleValue::create(start),
TRY(GridTrackPlacementStyleValue::create(GridTrackPlacement::make_auto())))); GridTrackPlacementStyleValue::create(GridTrackPlacement::make_auto())));
} }
ErrorOr<String> GridTrackPlacementShorthandStyleValue::to_string() const ErrorOr<String> GridTrackPlacementShorthandStyleValue::to_string() const

View file

@ -15,8 +15,8 @@ namespace Web::CSS {
class GridTrackPlacementShorthandStyleValue final : public StyleValueWithDefaultOperators<GridTrackPlacementShorthandStyleValue> { class GridTrackPlacementShorthandStyleValue final : public StyleValueWithDefaultOperators<GridTrackPlacementShorthandStyleValue> {
public: public:
static ErrorOr<ValueComparingNonnullRefPtr<GridTrackPlacementShorthandStyleValue>> create(ValueComparingNonnullRefPtr<GridTrackPlacementStyleValue const> start, ValueComparingNonnullRefPtr<GridTrackPlacementStyleValue const> end); static ValueComparingNonnullRefPtr<GridTrackPlacementShorthandStyleValue> create(ValueComparingNonnullRefPtr<GridTrackPlacementStyleValue const> start, ValueComparingNonnullRefPtr<GridTrackPlacementStyleValue const> end);
static ErrorOr<ValueComparingNonnullRefPtr<GridTrackPlacementShorthandStyleValue>> create(GridTrackPlacement start); static ValueComparingNonnullRefPtr<GridTrackPlacementShorthandStyleValue> create(GridTrackPlacement start);
virtual ~GridTrackPlacementShorthandStyleValue() override = default; virtual ~GridTrackPlacementShorthandStyleValue() override = default;
auto start() const { return m_properties.start; } auto start() const { return m_properties.start; }

View file

@ -11,9 +11,9 @@
namespace Web::CSS { namespace Web::CSS {
ErrorOr<ValueComparingNonnullRefPtr<GridTrackPlacementStyleValue>> GridTrackPlacementStyleValue::create(CSS::GridTrackPlacement grid_track_placement) ValueComparingNonnullRefPtr<GridTrackPlacementStyleValue> GridTrackPlacementStyleValue::create(CSS::GridTrackPlacement grid_track_placement)
{ {
return adopt_nonnull_ref_or_enomem(new (nothrow) GridTrackPlacementStyleValue(grid_track_placement)); return adopt_ref(*new (nothrow) GridTrackPlacementStyleValue(grid_track_placement));
} }
ErrorOr<String> GridTrackPlacementStyleValue::to_string() const ErrorOr<String> GridTrackPlacementStyleValue::to_string() const

View file

@ -16,7 +16,7 @@ namespace Web::CSS {
class GridTrackPlacementStyleValue final : public StyleValueWithDefaultOperators<GridTrackPlacementStyleValue> { class GridTrackPlacementStyleValue final : public StyleValueWithDefaultOperators<GridTrackPlacementStyleValue> {
public: public:
static ErrorOr<ValueComparingNonnullRefPtr<GridTrackPlacementStyleValue>> create(GridTrackPlacement grid_track_placement); static ValueComparingNonnullRefPtr<GridTrackPlacementStyleValue> create(GridTrackPlacement grid_track_placement);
virtual ~GridTrackPlacementStyleValue() override = default; virtual ~GridTrackPlacementStyleValue() override = default;
GridTrackPlacement const& grid_track_placement() const { return m_grid_track_placement; } GridTrackPlacement const& grid_track_placement() const { return m_grid_track_placement; }

View file

@ -9,12 +9,12 @@
namespace Web::CSS { namespace Web::CSS {
ErrorOr<ValueComparingNonnullRefPtr<GridTrackSizeListShorthandStyleValue>> GridTrackSizeListShorthandStyleValue::create( ValueComparingNonnullRefPtr<GridTrackSizeListShorthandStyleValue> GridTrackSizeListShorthandStyleValue::create(
ValueComparingNonnullRefPtr<GridTemplateAreaStyleValue const> areas, ValueComparingNonnullRefPtr<GridTemplateAreaStyleValue const> areas,
ValueComparingNonnullRefPtr<GridTrackSizeListStyleValue const> rows, ValueComparingNonnullRefPtr<GridTrackSizeListStyleValue const> rows,
ValueComparingNonnullRefPtr<GridTrackSizeListStyleValue const> columns) ValueComparingNonnullRefPtr<GridTrackSizeListStyleValue const> columns)
{ {
return adopt_nonnull_ref_or_enomem(new (nothrow) GridTrackSizeListShorthandStyleValue(move(areas), move(rows), move(columns))); return adopt_ref(*new (nothrow) GridTrackSizeListShorthandStyleValue(move(areas), move(rows), move(columns)));
} }
ErrorOr<String> GridTrackSizeListShorthandStyleValue::to_string() const ErrorOr<String> GridTrackSizeListShorthandStyleValue::to_string() const

View file

@ -13,7 +13,7 @@ namespace Web::CSS {
class GridTrackSizeListShorthandStyleValue final : public StyleValueWithDefaultOperators<GridTrackSizeListShorthandStyleValue> { class GridTrackSizeListShorthandStyleValue final : public StyleValueWithDefaultOperators<GridTrackSizeListShorthandStyleValue> {
public: public:
static ErrorOr<ValueComparingNonnullRefPtr<GridTrackSizeListShorthandStyleValue>> create( static ValueComparingNonnullRefPtr<GridTrackSizeListShorthandStyleValue> create(
ValueComparingNonnullRefPtr<GridTemplateAreaStyleValue const> areas, ValueComparingNonnullRefPtr<GridTemplateAreaStyleValue const> areas,
ValueComparingNonnullRefPtr<GridTrackSizeListStyleValue const> rows, ValueComparingNonnullRefPtr<GridTrackSizeListStyleValue const> rows,
ValueComparingNonnullRefPtr<GridTrackSizeListStyleValue const> columns); ValueComparingNonnullRefPtr<GridTrackSizeListStyleValue const> columns);

View file

@ -16,19 +16,19 @@ ErrorOr<String> GridTrackSizeListStyleValue::to_string() const
return m_grid_track_size_list.to_string(); return m_grid_track_size_list.to_string();
} }
ErrorOr<ValueComparingNonnullRefPtr<GridTrackSizeListStyleValue>> GridTrackSizeListStyleValue::create(CSS::GridTrackSizeList grid_track_size_list) ValueComparingNonnullRefPtr<GridTrackSizeListStyleValue> GridTrackSizeListStyleValue::create(CSS::GridTrackSizeList grid_track_size_list)
{ {
return adopt_nonnull_ref_or_enomem(new (nothrow) GridTrackSizeListStyleValue(grid_track_size_list)); return adopt_ref(*new (nothrow) GridTrackSizeListStyleValue(grid_track_size_list));
} }
ErrorOr<ValueComparingNonnullRefPtr<GridTrackSizeListStyleValue>> GridTrackSizeListStyleValue::make_auto() ValueComparingNonnullRefPtr<GridTrackSizeListStyleValue> GridTrackSizeListStyleValue::make_auto()
{ {
return adopt_nonnull_ref_or_enomem(new (nothrow) GridTrackSizeListStyleValue(CSS::GridTrackSizeList())); return adopt_ref(*new (nothrow) GridTrackSizeListStyleValue(CSS::GridTrackSizeList()));
} }
ErrorOr<ValueComparingNonnullRefPtr<GridTrackSizeListStyleValue>> GridTrackSizeListStyleValue::make_none() ValueComparingNonnullRefPtr<GridTrackSizeListStyleValue> GridTrackSizeListStyleValue::make_none()
{ {
return adopt_nonnull_ref_or_enomem(new (nothrow) GridTrackSizeListStyleValue(CSS::GridTrackSizeList())); return adopt_ref(*new (nothrow) GridTrackSizeListStyleValue(CSS::GridTrackSizeList()));
} }
} }

View file

@ -16,11 +16,11 @@ namespace Web::CSS {
class GridTrackSizeListStyleValue final : public StyleValueWithDefaultOperators<GridTrackSizeListStyleValue> { class GridTrackSizeListStyleValue final : public StyleValueWithDefaultOperators<GridTrackSizeListStyleValue> {
public: public:
static ErrorOr<ValueComparingNonnullRefPtr<GridTrackSizeListStyleValue>> create(CSS::GridTrackSizeList grid_track_size_list); static ValueComparingNonnullRefPtr<GridTrackSizeListStyleValue> create(CSS::GridTrackSizeList grid_track_size_list);
virtual ~GridTrackSizeListStyleValue() override = default; virtual ~GridTrackSizeListStyleValue() override = default;
static ErrorOr<ValueComparingNonnullRefPtr<GridTrackSizeListStyleValue>> make_auto(); static ValueComparingNonnullRefPtr<GridTrackSizeListStyleValue> make_auto();
static ErrorOr<ValueComparingNonnullRefPtr<GridTrackSizeListStyleValue>> make_none(); static ValueComparingNonnullRefPtr<GridTrackSizeListStyleValue> make_none();
CSS::GridTrackSizeList grid_track_size_list() const { return m_grid_track_size_list; } CSS::GridTrackSizeList grid_track_size_list() const { return m_grid_track_size_list; }

View file

@ -16,9 +16,9 @@ namespace Web::CSS {
class IdentifierStyleValue final : public StyleValueWithDefaultOperators<IdentifierStyleValue> { class IdentifierStyleValue final : public StyleValueWithDefaultOperators<IdentifierStyleValue> {
public: public:
static ErrorOr<ValueComparingNonnullRefPtr<IdentifierStyleValue>> create(ValueID id) static ValueComparingNonnullRefPtr<IdentifierStyleValue> create(ValueID id)
{ {
return adopt_nonnull_ref_or_enomem(new (nothrow) IdentifierStyleValue(id)); return adopt_ref(*new (nothrow) IdentifierStyleValue(id));
} }
virtual ~IdentifierStyleValue() override = default; virtual ~IdentifierStyleValue() override = default;

View file

@ -20,9 +20,9 @@ class ImageStyleValue final
: public AbstractImageStyleValue : public AbstractImageStyleValue
, public Weakable<ImageStyleValue> { , public Weakable<ImageStyleValue> {
public: public:
static ErrorOr<ValueComparingNonnullRefPtr<ImageStyleValue>> create(AK::URL const& url) static ValueComparingNonnullRefPtr<ImageStyleValue> create(AK::URL const& url)
{ {
return adopt_nonnull_ref_or_enomem(new (nothrow) ImageStyleValue(url)); return adopt_ref(*new (nothrow) ImageStyleValue(url));
} }
virtual ~ImageStyleValue() override = default; virtual ~ImageStyleValue() override = default;

View file

@ -12,9 +12,9 @@ namespace Web::CSS {
class InheritStyleValue final : public StyleValueWithDefaultOperators<InheritStyleValue> { class InheritStyleValue final : public StyleValueWithDefaultOperators<InheritStyleValue> {
public: public:
static ErrorOr<ValueComparingNonnullRefPtr<InheritStyleValue>> the() static ValueComparingNonnullRefPtr<InheritStyleValue> the()
{ {
static ValueComparingNonnullRefPtr<InheritStyleValue> instance = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) InheritStyleValue)); static ValueComparingNonnullRefPtr<InheritStyleValue> instance = adopt_ref(*new (nothrow) InheritStyleValue);
return instance; return instance;
} }
virtual ~InheritStyleValue() override = default; virtual ~InheritStyleValue() override = default;

View file

@ -12,9 +12,9 @@ namespace Web::CSS {
class InitialStyleValue final : public StyleValueWithDefaultOperators<InitialStyleValue> { class InitialStyleValue final : public StyleValueWithDefaultOperators<InitialStyleValue> {
public: public:
static ErrorOr<ValueComparingNonnullRefPtr<InitialStyleValue>> the() static ValueComparingNonnullRefPtr<InitialStyleValue> the()
{ {
static ValueComparingNonnullRefPtr<InitialStyleValue> instance = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) InitialStyleValue)); static ValueComparingNonnullRefPtr<InitialStyleValue> instance = adopt_ref(*new (nothrow) InitialStyleValue);
return instance; return instance;
} }
virtual ~InitialStyleValue() override = default; virtual ~InitialStyleValue() override = default;

View file

@ -12,9 +12,9 @@ namespace Web::CSS {
class IntegerStyleValue : public StyleValueWithDefaultOperators<IntegerStyleValue> { class IntegerStyleValue : public StyleValueWithDefaultOperators<IntegerStyleValue> {
public: public:
static ErrorOr<ValueComparingNonnullRefPtr<IntegerStyleValue>> create(i64 value) static ValueComparingNonnullRefPtr<IntegerStyleValue> create(i64 value)
{ {
return adopt_nonnull_ref_or_enomem(new (nothrow) IntegerStyleValue(value)); return adopt_ref(*new (nothrow) IntegerStyleValue(value));
} }
i64 integer() const { return m_value; } i64 integer() const { return m_value; }

View file

@ -11,20 +11,20 @@
namespace Web::CSS { namespace Web::CSS {
ErrorOr<ValueComparingNonnullRefPtr<LengthStyleValue>> LengthStyleValue::create(Length const& length) ValueComparingNonnullRefPtr<LengthStyleValue> LengthStyleValue::create(Length const& length)
{ {
VERIFY(!length.is_auto()); VERIFY(!length.is_auto());
if (length.is_px()) { if (length.is_px()) {
if (length.raw_value() == 0) { if (length.raw_value() == 0) {
static auto value = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) LengthStyleValue(CSS::Length::make_px(0)))); static auto value = adopt_ref(*new (nothrow) LengthStyleValue(CSS::Length::make_px(0)));
return value; return value;
} }
if (length.raw_value() == 1) { if (length.raw_value() == 1) {
static auto value = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) LengthStyleValue(CSS::Length::make_px(1)))); static auto value = adopt_ref(*new (nothrow) LengthStyleValue(CSS::Length::make_px(1)));
return value; return value;
} }
} }
return adopt_nonnull_ref_or_enomem(new (nothrow) LengthStyleValue(length)); return adopt_ref(*new (nothrow) LengthStyleValue(length));
} }
ErrorOr<ValueComparingNonnullRefPtr<StyleValue const>> LengthStyleValue::absolutized(CSSPixelRect const& viewport_rect, Length::FontMetrics const& font_metrics, Length::FontMetrics const& root_font_metrics) const ErrorOr<ValueComparingNonnullRefPtr<StyleValue const>> LengthStyleValue::absolutized(CSSPixelRect const& viewport_rect, Length::FontMetrics const& font_metrics, Length::FontMetrics const& root_font_metrics) const

View file

@ -15,7 +15,7 @@ namespace Web::CSS {
class LengthStyleValue : public StyleValueWithDefaultOperators<LengthStyleValue> { class LengthStyleValue : public StyleValueWithDefaultOperators<LengthStyleValue> {
public: public:
static ErrorOr<ValueComparingNonnullRefPtr<LengthStyleValue>> create(Length const&); static ValueComparingNonnullRefPtr<LengthStyleValue> create(Length const&);
virtual ~LengthStyleValue() override = default; virtual ~LengthStyleValue() override = default;
Length const& length() const { return m_length; } Length const& length() const { return m_length; }

View file

@ -38,10 +38,10 @@ public:
WebKit WebKit
}; };
static ErrorOr<ValueComparingNonnullRefPtr<LinearGradientStyleValue>> create(GradientDirection direction, Vector<LinearColorStopListElement> color_stop_list, GradientType type, GradientRepeating repeating) static ValueComparingNonnullRefPtr<LinearGradientStyleValue> create(GradientDirection direction, Vector<LinearColorStopListElement> color_stop_list, GradientType type, GradientRepeating repeating)
{ {
VERIFY(color_stop_list.size() >= 2); VERIFY(color_stop_list.size() >= 2);
return adopt_nonnull_ref_or_enomem(new (nothrow) LinearGradientStyleValue(direction, move(color_stop_list), type, repeating)); return adopt_ref(*new (nothrow) LinearGradientStyleValue(direction, move(color_stop_list), type, repeating));
} }
virtual ErrorOr<String> to_string() const override; virtual ErrorOr<String> to_string() const override;

View file

@ -15,12 +15,12 @@ namespace Web::CSS {
class ListStyleStyleValue final : public StyleValueWithDefaultOperators<ListStyleStyleValue> { class ListStyleStyleValue final : public StyleValueWithDefaultOperators<ListStyleStyleValue> {
public: public:
static ErrorOr<ValueComparingNonnullRefPtr<ListStyleStyleValue>> create( static ValueComparingNonnullRefPtr<ListStyleStyleValue> create(
ValueComparingNonnullRefPtr<StyleValue> position, ValueComparingNonnullRefPtr<StyleValue> position,
ValueComparingNonnullRefPtr<StyleValue> image, ValueComparingNonnullRefPtr<StyleValue> image,
ValueComparingNonnullRefPtr<StyleValue> style_type) ValueComparingNonnullRefPtr<StyleValue> style_type)
{ {
return adopt_nonnull_ref_or_enomem(new (nothrow) ListStyleStyleValue(move(position), move(image), move(style_type))); return adopt_ref(*new (nothrow) ListStyleStyleValue(move(position), move(image), move(style_type)));
} }
virtual ~ListStyleStyleValue() override = default; virtual ~ListStyleStyleValue() override = default;

View file

@ -15,9 +15,9 @@ namespace Web::CSS {
class NumberStyleValue : public StyleValueWithDefaultOperators<NumberStyleValue> { class NumberStyleValue : public StyleValueWithDefaultOperators<NumberStyleValue> {
public: public:
static ErrorOr<ValueComparingNonnullRefPtr<NumberStyleValue>> create(double value) static ValueComparingNonnullRefPtr<NumberStyleValue> create(double value)
{ {
return adopt_nonnull_ref_or_enomem(new (nothrow) NumberStyleValue(value)); return adopt_ref(*new (nothrow) NumberStyleValue(value));
} }
double number() const { return m_value; } double number() const { return m_value; }

View file

@ -15,9 +15,9 @@ namespace Web::CSS {
class OverflowStyleValue final : public StyleValueWithDefaultOperators<OverflowStyleValue> { class OverflowStyleValue final : public StyleValueWithDefaultOperators<OverflowStyleValue> {
public: public:
static ErrorOr<ValueComparingNonnullRefPtr<OverflowStyleValue>> create(ValueComparingNonnullRefPtr<StyleValue> overflow_x, ValueComparingNonnullRefPtr<StyleValue> overflow_y) static ValueComparingNonnullRefPtr<OverflowStyleValue> create(ValueComparingNonnullRefPtr<StyleValue> overflow_x, ValueComparingNonnullRefPtr<StyleValue> overflow_y)
{ {
return adopt_nonnull_ref_or_enomem(new (nothrow) OverflowStyleValue(move(overflow_x), move(overflow_y))); return adopt_ref(*new (nothrow) OverflowStyleValue(move(overflow_x), move(overflow_y)));
} }
virtual ~OverflowStyleValue() override = default; virtual ~OverflowStyleValue() override = default;

View file

@ -16,9 +16,9 @@ namespace Web::CSS {
class PercentageStyleValue final : public StyleValueWithDefaultOperators<PercentageStyleValue> { class PercentageStyleValue final : public StyleValueWithDefaultOperators<PercentageStyleValue> {
public: public:
static ErrorOr<ValueComparingNonnullRefPtr<PercentageStyleValue>> create(Percentage percentage) static ValueComparingNonnullRefPtr<PercentageStyleValue> create(Percentage percentage)
{ {
return adopt_nonnull_ref_or_enomem(new (nothrow) PercentageStyleValue(move(percentage))); return adopt_ref(*new (nothrow) PercentageStyleValue(move(percentage)));
} }
virtual ~PercentageStyleValue() override = default; virtual ~PercentageStyleValue() override = default;

View file

@ -12,9 +12,9 @@ namespace Web::CSS {
class PlaceContentStyleValue final : public StyleValueWithDefaultOperators<PlaceContentStyleValue> { class PlaceContentStyleValue final : public StyleValueWithDefaultOperators<PlaceContentStyleValue> {
public: public:
static ErrorOr<ValueComparingNonnullRefPtr<PlaceContentStyleValue>> create(ValueComparingNonnullRefPtr<StyleValue> align_content, ValueComparingNonnullRefPtr<StyleValue> justify_content) static ValueComparingNonnullRefPtr<PlaceContentStyleValue> create(ValueComparingNonnullRefPtr<StyleValue> align_content, ValueComparingNonnullRefPtr<StyleValue> justify_content)
{ {
return adopt_nonnull_ref_or_enomem(new (nothrow) PlaceContentStyleValue(move(align_content), move(justify_content))); return adopt_ref(*new (nothrow) PlaceContentStyleValue(move(align_content), move(justify_content)));
} }
virtual ~PlaceContentStyleValue() override = default; virtual ~PlaceContentStyleValue() override = default;

View file

@ -12,9 +12,9 @@ namespace Web::CSS {
class PlaceItemsStyleValue final : public StyleValueWithDefaultOperators<PlaceItemsStyleValue> { class PlaceItemsStyleValue final : public StyleValueWithDefaultOperators<PlaceItemsStyleValue> {
public: public:
static ErrorOr<ValueComparingNonnullRefPtr<PlaceItemsStyleValue>> create(ValueComparingNonnullRefPtr<StyleValue> align_items, ValueComparingNonnullRefPtr<StyleValue> justify_items) static ValueComparingNonnullRefPtr<PlaceItemsStyleValue> create(ValueComparingNonnullRefPtr<StyleValue> align_items, ValueComparingNonnullRefPtr<StyleValue> justify_items)
{ {
return adopt_nonnull_ref_or_enomem(new (nothrow) PlaceItemsStyleValue(move(align_items), move(justify_items))); return adopt_ref(*new (nothrow) PlaceItemsStyleValue(move(align_items), move(justify_items)));
} }
virtual ~PlaceItemsStyleValue() override = default; virtual ~PlaceItemsStyleValue() override = default;

View file

@ -12,9 +12,9 @@ namespace Web::CSS {
class PlaceSelfStyleValue final : public StyleValueWithDefaultOperators<PlaceSelfStyleValue> { class PlaceSelfStyleValue final : public StyleValueWithDefaultOperators<PlaceSelfStyleValue> {
public: public:
static ErrorOr<ValueComparingNonnullRefPtr<PlaceSelfStyleValue>> create(ValueComparingNonnullRefPtr<StyleValue> align_self, ValueComparingNonnullRefPtr<StyleValue> justify_self) static ValueComparingNonnullRefPtr<PlaceSelfStyleValue> create(ValueComparingNonnullRefPtr<StyleValue> align_self, ValueComparingNonnullRefPtr<StyleValue> justify_self)
{ {
return adopt_nonnull_ref_or_enomem(new (nothrow) PlaceSelfStyleValue(move(align_self), move(justify_self))); return adopt_ref(*new (nothrow) PlaceSelfStyleValue(move(align_self), move(justify_self)));
} }
virtual ~PlaceSelfStyleValue() override = default; virtual ~PlaceSelfStyleValue() override = default;

View file

@ -17,9 +17,9 @@ namespace Web::CSS {
class PositionStyleValue final : public StyleValueWithDefaultOperators<PositionStyleValue> { class PositionStyleValue final : public StyleValueWithDefaultOperators<PositionStyleValue> {
public: public:
static ErrorOr<ValueComparingNonnullRefPtr<PositionStyleValue>> create(ValueComparingNonnullRefPtr<StyleValue> egde_x, ValueComparingNonnullRefPtr<StyleValue> edge_y) static ValueComparingNonnullRefPtr<PositionStyleValue> create(ValueComparingNonnullRefPtr<StyleValue> egde_x, ValueComparingNonnullRefPtr<StyleValue> edge_y)
{ {
return adopt_nonnull_ref_or_enomem(new (nothrow) PositionStyleValue(move(egde_x), move(edge_y))); return adopt_ref(*new (nothrow) PositionStyleValue(move(egde_x), move(edge_y)));
} }
virtual ~PositionStyleValue() override = default; virtual ~PositionStyleValue() override = default;

View file

@ -44,10 +44,10 @@ public:
using Size = Variant<Extent, CircleSize, EllipseSize>; using Size = Variant<Extent, CircleSize, EllipseSize>;
static ErrorOr<ValueComparingNonnullRefPtr<RadialGradientStyleValue>> create(EndingShape ending_shape, Size size, PositionValue position, Vector<LinearColorStopListElement> color_stop_list, GradientRepeating repeating) static ValueComparingNonnullRefPtr<RadialGradientStyleValue> create(EndingShape ending_shape, Size size, PositionValue position, Vector<LinearColorStopListElement> color_stop_list, GradientRepeating repeating)
{ {
VERIFY(color_stop_list.size() >= 2); VERIFY(color_stop_list.size() >= 2);
return adopt_nonnull_ref_or_enomem(new (nothrow) RadialGradientStyleValue(ending_shape, size, position, move(color_stop_list), repeating)); return adopt_ref(*new (nothrow) RadialGradientStyleValue(ending_shape, size, position, move(color_stop_list), repeating));
} }
virtual ErrorOr<String> to_string() const override; virtual ErrorOr<String> to_string() const override;

View file

@ -13,9 +13,9 @@ namespace Web::CSS {
class RatioStyleValue final : public StyleValueWithDefaultOperators<RatioStyleValue> { class RatioStyleValue final : public StyleValueWithDefaultOperators<RatioStyleValue> {
public: public:
static ErrorOr<ValueComparingNonnullRefPtr<RatioStyleValue>> create(Ratio ratio) static ValueComparingNonnullRefPtr<RatioStyleValue> create(Ratio ratio)
{ {
return adopt_nonnull_ref_or_enomem(new (nothrow) RatioStyleValue(move(ratio))); return adopt_ref(*new (nothrow) RatioStyleValue(move(ratio)));
} }
virtual ~RatioStyleValue() override = default; virtual ~RatioStyleValue() override = default;

View file

@ -11,9 +11,9 @@
namespace Web::CSS { namespace Web::CSS {
ErrorOr<ValueComparingNonnullRefPtr<RectStyleValue>> RectStyleValue::create(EdgeRect rect) ValueComparingNonnullRefPtr<RectStyleValue> RectStyleValue::create(EdgeRect rect)
{ {
return adopt_nonnull_ref_or_enomem(new (nothrow) RectStyleValue(move(rect))); return adopt_ref(*new (nothrow) RectStyleValue(move(rect)));
} }
ErrorOr<String> RectStyleValue::to_string() const ErrorOr<String> RectStyleValue::to_string() const

View file

@ -16,7 +16,7 @@ namespace Web::CSS {
class RectStyleValue : public StyleValueWithDefaultOperators<RectStyleValue> { class RectStyleValue : public StyleValueWithDefaultOperators<RectStyleValue> {
public: public:
static ErrorOr<ValueComparingNonnullRefPtr<RectStyleValue>> create(EdgeRect rect); static ValueComparingNonnullRefPtr<RectStyleValue> create(EdgeRect rect);
virtual ~RectStyleValue() override = default; virtual ~RectStyleValue() override = default;
EdgeRect rect() const { return m_rect; } EdgeRect rect() const { return m_rect; }

View file

@ -13,9 +13,9 @@ namespace Web::CSS {
class ResolutionStyleValue : public StyleValueWithDefaultOperators<ResolutionStyleValue> { class ResolutionStyleValue : public StyleValueWithDefaultOperators<ResolutionStyleValue> {
public: public:
static ErrorOr<ValueComparingNonnullRefPtr<ResolutionStyleValue>> create(Resolution resolution) static ValueComparingNonnullRefPtr<ResolutionStyleValue> create(Resolution resolution)
{ {
return adopt_nonnull_ref_or_enomem(new (nothrow) ResolutionStyleValue(move(resolution))); return adopt_ref(*new (nothrow) ResolutionStyleValue(move(resolution)));
} }
virtual ~ResolutionStyleValue() override = default; virtual ~ResolutionStyleValue() override = default;

View file

@ -12,9 +12,9 @@ namespace Web::CSS {
class RevertStyleValue final : public StyleValueWithDefaultOperators<RevertStyleValue> { class RevertStyleValue final : public StyleValueWithDefaultOperators<RevertStyleValue> {
public: public:
static ErrorOr<ValueComparingNonnullRefPtr<RevertStyleValue>> the() static ValueComparingNonnullRefPtr<RevertStyleValue> the()
{ {
static ValueComparingNonnullRefPtr<RevertStyleValue> instance = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) RevertStyleValue)); static ValueComparingNonnullRefPtr<RevertStyleValue> instance = adopt_ref(*new (nothrow) RevertStyleValue);
return instance; return instance;
} }
virtual ~RevertStyleValue() override = default; virtual ~RevertStyleValue() override = default;

View file

@ -22,7 +22,7 @@ enum class ShadowPlacement {
class ShadowStyleValue final : public StyleValueWithDefaultOperators<ShadowStyleValue> { class ShadowStyleValue final : public StyleValueWithDefaultOperators<ShadowStyleValue> {
public: public:
static ErrorOr<ValueComparingNonnullRefPtr<ShadowStyleValue>> create( static ValueComparingNonnullRefPtr<ShadowStyleValue> create(
Color color, Color color,
ValueComparingNonnullRefPtr<StyleValue const> offset_x, ValueComparingNonnullRefPtr<StyleValue const> offset_x,
ValueComparingNonnullRefPtr<StyleValue const> offset_y, ValueComparingNonnullRefPtr<StyleValue const> offset_y,
@ -30,7 +30,7 @@ public:
ValueComparingNonnullRefPtr<StyleValue const> spread_distance, ValueComparingNonnullRefPtr<StyleValue const> spread_distance,
ShadowPlacement placement) ShadowPlacement placement)
{ {
return adopt_nonnull_ref_or_enomem(new (nothrow) ShadowStyleValue(color, move(offset_x), move(offset_y), move(blur_radius), move(spread_distance), placement)); return adopt_ref(*new (nothrow) ShadowStyleValue(color, move(offset_x), move(offset_y), move(blur_radius), move(spread_distance), placement));
} }
virtual ~ShadowStyleValue() override = default; virtual ~ShadowStyleValue() override = default;

View file

@ -13,9 +13,9 @@ namespace Web::CSS {
class StringStyleValue : public StyleValueWithDefaultOperators<StringStyleValue> { class StringStyleValue : public StyleValueWithDefaultOperators<StringStyleValue> {
public: public:
static ErrorOr<ValueComparingNonnullRefPtr<StringStyleValue>> create(String const& string) static ValueComparingNonnullRefPtr<StringStyleValue> create(String const& string)
{ {
return adopt_nonnull_ref_or_enomem(new (nothrow) StringStyleValue(string)); return adopt_ref(*new (nothrow) StringStyleValue(string));
} }
virtual ~StringStyleValue() override = default; virtual ~StringStyleValue() override = default;

View file

@ -19,9 +19,9 @@ public:
Space, Space,
Comma, Comma,
}; };
static ErrorOr<ValueComparingNonnullRefPtr<StyleValueList>> create(StyleValueVector&& values, Separator separator) static ValueComparingNonnullRefPtr<StyleValueList> create(StyleValueVector&& values, Separator separator)
{ {
return adopt_nonnull_ref_or_enomem(new (nothrow) StyleValueList(move(values), separator)); return adopt_ref(*new (nothrow) StyleValueList(move(values), separator));
} }
size_t size() const { return m_properties.values.size(); } size_t size() const { return m_properties.values.size(); }

View file

@ -15,13 +15,13 @@ namespace Web::CSS {
class TextDecorationStyleValue final : public StyleValueWithDefaultOperators<TextDecorationStyleValue> { class TextDecorationStyleValue final : public StyleValueWithDefaultOperators<TextDecorationStyleValue> {
public: public:
static ErrorOr<ValueComparingNonnullRefPtr<TextDecorationStyleValue>> create( static ValueComparingNonnullRefPtr<TextDecorationStyleValue> create(
ValueComparingNonnullRefPtr<StyleValue> line, ValueComparingNonnullRefPtr<StyleValue> line,
ValueComparingNonnullRefPtr<StyleValue> thickness, ValueComparingNonnullRefPtr<StyleValue> thickness,
ValueComparingNonnullRefPtr<StyleValue> style, ValueComparingNonnullRefPtr<StyleValue> style,
ValueComparingNonnullRefPtr<StyleValue> color) ValueComparingNonnullRefPtr<StyleValue> color)
{ {
return adopt_nonnull_ref_or_enomem(new (nothrow) TextDecorationStyleValue(move(line), move(thickness), move(style), move(color))); return adopt_ref(*new (nothrow) TextDecorationStyleValue(move(line), move(thickness), move(style), move(color)));
} }
virtual ~TextDecorationStyleValue() override = default; virtual ~TextDecorationStyleValue() override = default;

View file

@ -16,9 +16,9 @@ namespace Web::CSS {
class TimeStyleValue : public StyleValueWithDefaultOperators<TimeStyleValue> { class TimeStyleValue : public StyleValueWithDefaultOperators<TimeStyleValue> {
public: public:
static ErrorOr<ValueComparingNonnullRefPtr<TimeStyleValue>> create(Time time) static ValueComparingNonnullRefPtr<TimeStyleValue> create(Time time)
{ {
return adopt_nonnull_ref_or_enomem(new (nothrow) TimeStyleValue(move(time))); return adopt_ref(*new (nothrow) TimeStyleValue(move(time)));
} }
virtual ~TimeStyleValue() override = default; virtual ~TimeStyleValue() override = default;

View file

@ -16,9 +16,9 @@ namespace Web::CSS {
class TransformationStyleValue final : public StyleValueWithDefaultOperators<TransformationStyleValue> { class TransformationStyleValue final : public StyleValueWithDefaultOperators<TransformationStyleValue> {
public: public:
static ErrorOr<ValueComparingNonnullRefPtr<TransformationStyleValue>> create(CSS::TransformFunction transform_function, StyleValueVector&& values) static ValueComparingNonnullRefPtr<TransformationStyleValue> create(CSS::TransformFunction transform_function, StyleValueVector&& values)
{ {
return adopt_nonnull_ref_or_enomem(new (nothrow) TransformationStyleValue(transform_function, move(values))); return adopt_ref(*new (nothrow) TransformationStyleValue(transform_function, move(values)));
} }
virtual ~TransformationStyleValue() override = default; virtual ~TransformationStyleValue() override = default;

View file

@ -14,9 +14,9 @@ namespace Web::CSS {
class URLStyleValue final : public StyleValueWithDefaultOperators<URLStyleValue> { class URLStyleValue final : public StyleValueWithDefaultOperators<URLStyleValue> {
public: public:
static ErrorOr<ValueComparingNonnullRefPtr<URLStyleValue>> create(AK::URL const& url) static ValueComparingNonnullRefPtr<URLStyleValue> create(AK::URL const& url)
{ {
return adopt_nonnull_ref_or_enomem(new (nothrow) URLStyleValue(url)); return adopt_ref(*new (nothrow) URLStyleValue(url));
} }
virtual ~URLStyleValue() override = default; virtual ~URLStyleValue() override = default;

View file

@ -17,9 +17,9 @@ namespace Web::CSS {
class UnresolvedStyleValue final : public StyleValue { class UnresolvedStyleValue final : public StyleValue {
public: public:
static ErrorOr<ValueComparingNonnullRefPtr<UnresolvedStyleValue>> create(Vector<Parser::ComponentValue>&& values, bool contains_var_or_attr) static ValueComparingNonnullRefPtr<UnresolvedStyleValue> create(Vector<Parser::ComponentValue>&& values, bool contains_var_or_attr)
{ {
return adopt_nonnull_ref_or_enomem(new (nothrow) UnresolvedStyleValue(move(values), contains_var_or_attr)); return adopt_ref(*new (nothrow) UnresolvedStyleValue(move(values), contains_var_or_attr));
} }
virtual ~UnresolvedStyleValue() override = default; virtual ~UnresolvedStyleValue() override = default;

View file

@ -15,9 +15,9 @@ namespace Web::CSS {
class UnsetStyleValue final : public StyleValueWithDefaultOperators<UnsetStyleValue> { class UnsetStyleValue final : public StyleValueWithDefaultOperators<UnsetStyleValue> {
public: public:
static ErrorOr<ValueComparingNonnullRefPtr<UnsetStyleValue>> the() static ValueComparingNonnullRefPtr<UnsetStyleValue> the()
{ {
static ValueComparingNonnullRefPtr<UnsetStyleValue> instance = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) UnsetStyleValue)); static ValueComparingNonnullRefPtr<UnsetStyleValue> instance = adopt_ref(*new (nothrow) UnsetStyleValue);
return instance; return instance;
} }
virtual ~UnsetStyleValue() override = default; virtual ~UnsetStyleValue() override = default;

View file

@ -35,12 +35,12 @@ void HTMLBodyElement::apply_presentational_hints(CSS::StyleProperties& style) co
// https://html.spec.whatwg.org/multipage/rendering.html#the-page:rules-for-parsing-a-legacy-colour-value // https://html.spec.whatwg.org/multipage/rendering.html#the-page:rules-for-parsing-a-legacy-colour-value
auto color = parse_legacy_color_value(value); auto color = parse_legacy_color_value(value);
if (color.has_value()) if (color.has_value())
style.set_property(CSS::PropertyID::BackgroundColor, CSS::ColorStyleValue::create(color.value()).release_value_but_fixme_should_propagate_errors(), nullptr); style.set_property(CSS::PropertyID::BackgroundColor, CSS::ColorStyleValue::create(color.value()), nullptr);
} else if (name.equals_ignoring_ascii_case("text"sv)) { } else if (name.equals_ignoring_ascii_case("text"sv)) {
// https://html.spec.whatwg.org/multipage/rendering.html#the-page:rules-for-parsing-a-legacy-colour-value-2 // https://html.spec.whatwg.org/multipage/rendering.html#the-page:rules-for-parsing-a-legacy-colour-value-2
auto color = parse_legacy_color_value(value); auto color = parse_legacy_color_value(value);
if (color.has_value()) if (color.has_value())
style.set_property(CSS::PropertyID::Color, CSS::ColorStyleValue::create(color.value()).release_value_but_fixme_should_propagate_errors(), nullptr); style.set_property(CSS::PropertyID::Color, CSS::ColorStyleValue::create(color.value()), nullptr);
} else if (name.equals_ignoring_ascii_case("background"sv)) { } else if (name.equals_ignoring_ascii_case("background"sv)) {
VERIFY(m_background_style_value); VERIFY(m_background_style_value);
style.set_property(CSS::PropertyID::BackgroundImage, *m_background_style_value, nullptr); style.set_property(CSS::PropertyID::BackgroundImage, *m_background_style_value, nullptr);
@ -67,7 +67,7 @@ void HTMLBodyElement::attribute_changed(DeprecatedFlyString const& name, Depreca
if (color.has_value()) if (color.has_value())
document().set_visited_link_color(color.value()); document().set_visited_link_color(color.value());
} else if (name.equals_ignoring_ascii_case("background"sv)) { } else if (name.equals_ignoring_ascii_case("background"sv)) {
m_background_style_value = CSS::ImageStyleValue::create(document().parse_url(value)).release_value_but_fixme_should_propagate_errors(); m_background_style_value = CSS::ImageStyleValue::create(document().parse_url(value));
m_background_style_value->on_animate = [this] { m_background_style_value->on_animate = [this] {
if (layout_node()) { if (layout_node()) {
layout_node()->set_needs_display(); layout_node()->set_needs_display();

View file

@ -24,13 +24,13 @@ void HTMLDivElement::apply_presentational_hints(CSS::StyleProperties& style) con
for_each_attribute([&](auto& name, auto& value) { for_each_attribute([&](auto& name, auto& value) {
if (name.equals_ignoring_ascii_case("align"sv)) { if (name.equals_ignoring_ascii_case("align"sv)) {
if (value.equals_ignoring_ascii_case("left"sv)) if (value.equals_ignoring_ascii_case("left"sv))
style.set_property(CSS::PropertyID::TextAlign, CSS::IdentifierStyleValue::create(CSS::ValueID::LibwebLeft).release_value_but_fixme_should_propagate_errors()); style.set_property(CSS::PropertyID::TextAlign, CSS::IdentifierStyleValue::create(CSS::ValueID::LibwebLeft));
else if (value.equals_ignoring_ascii_case("right"sv)) else if (value.equals_ignoring_ascii_case("right"sv))
style.set_property(CSS::PropertyID::TextAlign, CSS::IdentifierStyleValue::create(CSS::ValueID::LibwebRight).release_value_but_fixme_should_propagate_errors()); style.set_property(CSS::PropertyID::TextAlign, CSS::IdentifierStyleValue::create(CSS::ValueID::LibwebRight));
else if (value.equals_ignoring_ascii_case("center"sv)) else if (value.equals_ignoring_ascii_case("center"sv))
style.set_property(CSS::PropertyID::TextAlign, CSS::IdentifierStyleValue::create(CSS::ValueID::LibwebCenter).release_value_but_fixme_should_propagate_errors()); style.set_property(CSS::PropertyID::TextAlign, CSS::IdentifierStyleValue::create(CSS::ValueID::LibwebCenter));
else if (value.equals_ignoring_ascii_case("justify"sv)) else if (value.equals_ignoring_ascii_case("justify"sv))
style.set_property(CSS::PropertyID::TextAlign, CSS::IdentifierStyleValue::create(CSS::ValueID::Justify).release_value_but_fixme_should_propagate_errors()); style.set_property(CSS::PropertyID::TextAlign, CSS::IdentifierStyleValue::create(CSS::ValueID::Justify));
} }
}); });
} }

View file

@ -32,7 +32,7 @@ void HTMLFontElement::apply_presentational_hints(CSS::StyleProperties& style) co
// https://html.spec.whatwg.org/multipage/rendering.html#phrasing-content-3:rules-for-parsing-a-legacy-colour-value // https://html.spec.whatwg.org/multipage/rendering.html#phrasing-content-3:rules-for-parsing-a-legacy-colour-value
auto color = parse_legacy_color_value(value); auto color = parse_legacy_color_value(value);
if (color.has_value()) if (color.has_value())
style.set_property(CSS::PropertyID::Color, CSS::ColorStyleValue::create(color.value()).release_value_but_fixme_should_propagate_errors()); style.set_property(CSS::PropertyID::Color, CSS::ColorStyleValue::create(color.value()));
} }
}); });
} }

View file

@ -31,13 +31,13 @@ void HTMLHeadingElement::apply_presentational_hints(CSS::StyleProperties& style)
for_each_attribute([&](auto& name, auto& value) { for_each_attribute([&](auto& name, auto& value) {
if (name.equals_ignoring_ascii_case("align"sv)) { if (name.equals_ignoring_ascii_case("align"sv)) {
if (value == "left"sv) if (value == "left"sv)
style.set_property(CSS::PropertyID::TextAlign, CSS::IdentifierStyleValue::create(CSS::ValueID::Left).release_value_but_fixme_should_propagate_errors()); style.set_property(CSS::PropertyID::TextAlign, CSS::IdentifierStyleValue::create(CSS::ValueID::Left));
else if (value == "right"sv) else if (value == "right"sv)
style.set_property(CSS::PropertyID::TextAlign, CSS::IdentifierStyleValue::create(CSS::ValueID::Right).release_value_but_fixme_should_propagate_errors()); style.set_property(CSS::PropertyID::TextAlign, CSS::IdentifierStyleValue::create(CSS::ValueID::Right));
else if (value == "center"sv) else if (value == "center"sv)
style.set_property(CSS::PropertyID::TextAlign, CSS::IdentifierStyleValue::create(CSS::ValueID::Center).release_value_but_fixme_should_propagate_errors()); style.set_property(CSS::PropertyID::TextAlign, CSS::IdentifierStyleValue::create(CSS::ValueID::Center));
else if (value == "justify"sv) else if (value == "justify"sv)
style.set_property(CSS::PropertyID::TextAlign, CSS::IdentifierStyleValue::create(CSS::ValueID::Justify).release_value_but_fixme_should_propagate_errors()); style.set_property(CSS::PropertyID::TextAlign, CSS::IdentifierStyleValue::create(CSS::ValueID::Justify));
} }
}); });
} }

View file

@ -80,7 +80,7 @@ JS::GCPtr<Layout::Node> HTMLInputElement::create_layout_node(NonnullRefPtr<CSS::
// AD-HOC: We rewrite `display: inline` to `display: inline-block`. // AD-HOC: We rewrite `display: inline` to `display: inline-block`.
// This is required for the internal shadow tree to work correctly in layout. // This is required for the internal shadow tree to work correctly in layout.
if (style->display().is_inline_outside() && style->display().is_flow_inside()) if (style->display().is_inline_outside() && style->display().is_flow_inside())
style->set_property(CSS::PropertyID::Display, CSS::DisplayStyleValue::create(CSS::Display::from_short(CSS::Display::Short::InlineBlock)).release_value_but_fixme_should_propagate_errors()); style->set_property(CSS::PropertyID::Display, CSS::DisplayStyleValue::create(CSS::Display::from_short(CSS::Display::Short::InlineBlock)));
return Element::create_layout_node_for_display_type(document(), style->display(), style, this); return Element::create_layout_node_for_display_type(document(), style->display(), style, this);
} }

View file

@ -33,7 +33,7 @@ void HTMLMarqueeElement::apply_presentational_hints(CSS::StyleProperties& style)
// https://html.spec.whatwg.org/multipage/rendering.html#the-marquee-element-2:rules-for-parsing-a-legacy-colour-value // https://html.spec.whatwg.org/multipage/rendering.html#the-marquee-element-2:rules-for-parsing-a-legacy-colour-value
auto color = parse_legacy_color_value(value); auto color = parse_legacy_color_value(value);
if (color.has_value()) if (color.has_value())
style.set_property(CSS::PropertyID::BackgroundColor, CSS::ColorStyleValue::create(color.value()).release_value_but_fixme_should_propagate_errors()); style.set_property(CSS::PropertyID::BackgroundColor, CSS::ColorStyleValue::create(color.value()));
} }
}); });
} }

View file

@ -31,13 +31,13 @@ void HTMLParagraphElement::apply_presentational_hints(CSS::StyleProperties& styl
for_each_attribute([&](auto& name, auto& value) { for_each_attribute([&](auto& name, auto& value) {
if (name.equals_ignoring_ascii_case("align"sv)) { if (name.equals_ignoring_ascii_case("align"sv)) {
if (value == "left"sv) if (value == "left"sv)
style.set_property(CSS::PropertyID::TextAlign, CSS::IdentifierStyleValue::create(CSS::ValueID::Left).release_value_but_fixme_should_propagate_errors()); style.set_property(CSS::PropertyID::TextAlign, CSS::IdentifierStyleValue::create(CSS::ValueID::Left));
else if (value == "right"sv) else if (value == "right"sv)
style.set_property(CSS::PropertyID::TextAlign, CSS::IdentifierStyleValue::create(CSS::ValueID::Right).release_value_but_fixme_should_propagate_errors()); style.set_property(CSS::PropertyID::TextAlign, CSS::IdentifierStyleValue::create(CSS::ValueID::Right));
else if (value == "center"sv) else if (value == "center"sv)
style.set_property(CSS::PropertyID::TextAlign, CSS::IdentifierStyleValue::create(CSS::ValueID::Center).release_value_but_fixme_should_propagate_errors()); style.set_property(CSS::PropertyID::TextAlign, CSS::IdentifierStyleValue::create(CSS::ValueID::Center));
else if (value == "justify"sv) else if (value == "justify"sv)
style.set_property(CSS::PropertyID::TextAlign, CSS::IdentifierStyleValue::create(CSS::ValueID::Justify).release_value_but_fixme_should_propagate_errors()); style.set_property(CSS::PropertyID::TextAlign, CSS::IdentifierStyleValue::create(CSS::ValueID::Justify));
} }
}); });
} }

View file

@ -30,7 +30,7 @@ void HTMLPreElement::apply_presentational_hints(CSS::StyleProperties& style) con
for_each_attribute([&](auto const& name, auto const&) { for_each_attribute([&](auto const& name, auto const&) {
if (name.equals_ignoring_ascii_case(HTML::AttributeNames::wrap)) if (name.equals_ignoring_ascii_case(HTML::AttributeNames::wrap))
style.set_property(CSS::PropertyID::WhiteSpace, CSS::IdentifierStyleValue::create(CSS::ValueID::PreWrap).release_value_but_fixme_should_propagate_errors()); style.set_property(CSS::PropertyID::WhiteSpace, CSS::IdentifierStyleValue::create(CSS::ValueID::PreWrap));
}); });
} }

View file

@ -31,7 +31,7 @@ void HTMLTableCaptionElement::apply_presentational_hints(CSS::StyleProperties& s
for_each_attribute([&](auto& name, auto& value) { for_each_attribute([&](auto& name, auto& value) {
if (name.equals_ignoring_ascii_case("align"sv)) { if (name.equals_ignoring_ascii_case("align"sv)) {
if (value == "bottom"sv) if (value == "bottom"sv)
style.set_property(CSS::PropertyID::CaptionSide, CSS::IdentifierStyleValue::create(CSS::ValueID::Bottom).release_value_but_fixme_should_propagate_errors()); style.set_property(CSS::PropertyID::CaptionSide, CSS::IdentifierStyleValue::create(CSS::ValueID::Bottom));
} }
}); });
} }

View file

@ -36,7 +36,7 @@ void HTMLTableCellElement::apply_presentational_hints(CSS::StyleProperties& styl
// https://html.spec.whatwg.org/multipage/rendering.html#tables-2:rules-for-parsing-a-legacy-colour-value // https://html.spec.whatwg.org/multipage/rendering.html#tables-2:rules-for-parsing-a-legacy-colour-value
auto color = parse_legacy_color_value(value); auto color = parse_legacy_color_value(value);
if (color.has_value()) if (color.has_value())
style.set_property(CSS::PropertyID::BackgroundColor, CSS::ColorStyleValue::create(color.value()).release_value_but_fixme_should_propagate_errors()); style.set_property(CSS::PropertyID::BackgroundColor, CSS::ColorStyleValue::create(color.value()));
return; return;
} }
if (name == HTML::AttributeNames::valign) { if (name == HTML::AttributeNames::valign) {
@ -46,7 +46,7 @@ void HTMLTableCellElement::apply_presentational_hints(CSS::StyleProperties& styl
} }
if (name == HTML::AttributeNames::align) { if (name == HTML::AttributeNames::align) {
if (value.equals_ignoring_ascii_case("center"sv) || value.equals_ignoring_ascii_case("middle"sv)) { 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()); style.set_property(CSS::PropertyID::TextAlign, CSS::IdentifierStyleValue::create(CSS::ValueID::LibwebCenter));
} else { } 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).release_value_but_fixme_should_propagate_errors())
style.set_property(CSS::PropertyID::TextAlign, parsed_value.release_nonnull()); style.set_property(CSS::PropertyID::TextAlign, parsed_value.release_nonnull());
@ -63,7 +63,7 @@ void HTMLTableCellElement::apply_presentational_hints(CSS::StyleProperties& styl
return; return;
} else if (name == HTML::AttributeNames::background) { } else if (name == HTML::AttributeNames::background) {
if (auto parsed_value = document().parse_url(value); parsed_value.is_valid()) if (auto parsed_value = document().parse_url(value); parsed_value.is_valid())
style.set_property(CSS::PropertyID::BackgroundImage, CSS::ImageStyleValue::create(parsed_value).release_value_but_fixme_should_propagate_errors()); style.set_property(CSS::PropertyID::BackgroundImage, CSS::ImageStyleValue::create(parsed_value));
return; return;
} }
}); });

View file

@ -56,7 +56,7 @@ void HTMLTableElement::apply_presentational_hints(CSS::StyleProperties& style) c
// https://html.spec.whatwg.org/multipage/rendering.html#tables-2:rules-for-parsing-a-legacy-colour-value // https://html.spec.whatwg.org/multipage/rendering.html#tables-2:rules-for-parsing-a-legacy-colour-value
auto color = parse_legacy_color_value(value); auto color = parse_legacy_color_value(value);
if (color.has_value()) if (color.has_value())
style.set_property(CSS::PropertyID::BackgroundColor, CSS::ColorStyleValue::create(color.value()).release_value_but_fixme_should_propagate_errors()); style.set_property(CSS::PropertyID::BackgroundColor, CSS::ColorStyleValue::create(color.value()));
return; return;
} }
if (name == HTML::AttributeNames::cellspacing) { if (name == HTML::AttributeNames::cellspacing) {

View file

@ -41,11 +41,11 @@ void HTMLTableRowElement::apply_presentational_hints(CSS::StyleProperties& style
// https://html.spec.whatwg.org/multipage/rendering.html#tables-2:rules-for-parsing-a-legacy-colour-value // https://html.spec.whatwg.org/multipage/rendering.html#tables-2:rules-for-parsing-a-legacy-colour-value
auto color = parse_legacy_color_value(value); auto color = parse_legacy_color_value(value);
if (color.has_value()) if (color.has_value())
style.set_property(CSS::PropertyID::BackgroundColor, CSS::ColorStyleValue::create(color.value()).release_value_but_fixme_should_propagate_errors()); style.set_property(CSS::PropertyID::BackgroundColor, CSS::ColorStyleValue::create(color.value()));
return; return;
} else if (name == HTML::AttributeNames::background) { } else if (name == HTML::AttributeNames::background) {
if (auto parsed_value = document().parse_url(value); parsed_value.is_valid()) if (auto parsed_value = document().parse_url(value); parsed_value.is_valid())
style.set_property(CSS::PropertyID::BackgroundImage, CSS::ImageStyleValue::create(parsed_value).release_value_but_fixme_should_propagate_errors()); style.set_property(CSS::PropertyID::BackgroundImage, CSS::ImageStyleValue::create(parsed_value));
return; return;
} }
}); });

View file

@ -3993,14 +3993,14 @@ static RefPtr<CSS::StyleValue> parse_current_dimension_value(float value, Utf8Vi
{ {
// 1. If position is past the end of input, then return value as a length. // 1. If position is past the end of input, then return value as a length.
if (position == input.end()) if (position == input.end())
return CSS::LengthStyleValue::create(CSS::Length::make_px(value)).release_value_but_fixme_should_propagate_errors(); return CSS::LengthStyleValue::create(CSS::Length::make_px(value));
// 2. If the code point at position within input is U+0025 (%), then return value as a percentage. // 2. If the code point at position within input is U+0025 (%), then return value as a percentage.
if (*position == '%') if (*position == '%')
return CSS::PercentageStyleValue::create(CSS::Percentage(value)).release_value_but_fixme_should_propagate_errors(); return CSS::PercentageStyleValue::create(CSS::Percentage(value));
// 3. Return value as a length. // 3. Return value as a length.
return CSS::LengthStyleValue::create(CSS::Length::make_px(value)).release_value_but_fixme_should_propagate_errors(); return CSS::LengthStyleValue::create(CSS::Length::make_px(value));
} }
// https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#rules-for-parsing-dimension-values // https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#rules-for-parsing-dimension-values
@ -4034,7 +4034,7 @@ RefPtr<CSS::StyleValue> parse_dimension_value(StringView string)
// 6. If position is past the end of input, then return value as a length. // 6. If position is past the end of input, then return value as a length.
if (position == input.end()) if (position == input.end())
return CSS::LengthStyleValue::create(CSS::Length::make_px(*integer_value)).release_value_but_fixme_should_propagate_errors(); return CSS::LengthStyleValue::create(CSS::Length::make_px(*integer_value));
float value = *integer_value; float value = *integer_value;
@ -4065,7 +4065,7 @@ RefPtr<CSS::StyleValue> parse_dimension_value(StringView string)
// 4. If position is past the end of input, then return value as a length. // 4. If position is past the end of input, then return value as a length.
if (position == input.end()) if (position == input.end())
return CSS::LengthStyleValue::create(CSS::Length::make_px(value)).release_value_but_fixme_should_propagate_errors(); return CSS::LengthStyleValue::create(CSS::Length::make_px(value));
// 5. If the code point at position within input is not an ASCII digit, then break. // 5. If the code point at position within input is not an ASCII digit, then break.
if (!is_ascii_digit(*position)) if (!is_ascii_digit(*position))

View file

@ -352,11 +352,11 @@ ErrorOr<void> TreeBuilder::create_layout_tree(DOM::Node& dom_node, TreeBuilder::
auto& progress = static_cast<HTML::HTMLProgressElement&>(dom_node); auto& progress = static_cast<HTML::HTMLProgressElement&>(dom_node);
if (!progress.using_system_appearance()) { if (!progress.using_system_appearance()) {
auto bar_style = TRY(style_computer.compute_style(progress, CSS::Selector::PseudoElement::ProgressBar)); auto bar_style = TRY(style_computer.compute_style(progress, CSS::Selector::PseudoElement::ProgressBar));
bar_style->set_property(CSS::PropertyID::Display, CSS::DisplayStyleValue::create(CSS::Display::from_short(CSS::Display::Short::FlowRoot)).release_value_but_fixme_should_propagate_errors()); bar_style->set_property(CSS::PropertyID::Display, CSS::DisplayStyleValue::create(CSS::Display::from_short(CSS::Display::Short::FlowRoot)));
auto value_style = TRY(style_computer.compute_style(progress, CSS::Selector::PseudoElement::ProgressValue)); auto value_style = TRY(style_computer.compute_style(progress, CSS::Selector::PseudoElement::ProgressValue));
value_style->set_property(CSS::PropertyID::Display, CSS::DisplayStyleValue::create(CSS::Display::from_short(CSS::Display::Short::Block)).release_value_but_fixme_should_propagate_errors()); value_style->set_property(CSS::PropertyID::Display, CSS::DisplayStyleValue::create(CSS::Display::from_short(CSS::Display::Short::Block)));
auto position = progress.position(); auto position = progress.position();
value_style->set_property(CSS::PropertyID::Width, CSS::PercentageStyleValue::create(CSS::Percentage(position >= 0 ? round_to<int>(100 * position) : 0)).release_value_but_fixme_should_propagate_errors()); value_style->set_property(CSS::PropertyID::Width, CSS::PercentageStyleValue::create(CSS::Percentage(position >= 0 ? round_to<int>(100 * position) : 0)));
auto bar_display = bar_style->display(); auto bar_display = bar_style->display();
auto value_display = value_style->display(); auto value_display = value_style->display();
auto progress_bar = DOM::Element::create_layout_node_for_display_type(document, bar_display, bar_style, nullptr); auto progress_bar = DOM::Element::create_layout_node_for_display_type(document, bar_display, bar_style, nullptr);

View file

@ -396,7 +396,7 @@ Gfx::FloatMatrix4x4 StackingContext::get_transformation_matrix(CSS::Transformati
0, 0, 0, 1); 0, 0, 0, 1);
break; break;
default: default:
dbgln_if(LIBWEB_CSS_DEBUG, "FIXME: Unhandled transformation function {}", MUST(CSS::TransformationStyleValue::create(transformation.function, {}))->to_string()); dbgln_if(LIBWEB_CSS_DEBUG, "FIXME: Unhandled transformation function {}", CSS::TransformationStyleValue::create(transformation.function, {})->to_string());
} }
return Gfx::FloatMatrix4x4::identity(); return Gfx::FloatMatrix4x4::identity();
} }

View file

@ -49,7 +49,7 @@ void SVGSVGElement::apply_presentational_hints(CSS::StyleProperties& style) cons
// If the `width` attribute is an empty string, it defaults to 100%. // If the `width` attribute is an empty string, it defaults to 100%.
// This matches WebKit and Blink, but not Firefox. The spec is unclear. // This matches WebKit and Blink, but not Firefox. The spec is unclear.
// FIXME: Figure out what to do here. // FIXME: Figure out what to do here.
style.set_property(CSS::PropertyID::Width, CSS::PercentageStyleValue::create(CSS::Percentage { 100 }).release_value_but_fixme_should_propagate_errors()); style.set_property(CSS::PropertyID::Width, CSS::PercentageStyleValue::create(CSS::Percentage { 100 }));
} }
// Height defaults to 100% // Height defaults to 100%
@ -60,7 +60,7 @@ void SVGSVGElement::apply_presentational_hints(CSS::StyleProperties& style) cons
// If the `height` attribute is an empty string, it defaults to 100%. // If the `height` attribute is an empty string, it defaults to 100%.
// This matches WebKit and Blink, but not Firefox. The spec is unclear. // This matches WebKit and Blink, but not Firefox. The spec is unclear.
// FIXME: Figure out what to do here. // FIXME: Figure out what to do here.
style.set_property(CSS::PropertyID::Height, CSS::PercentageStyleValue::create(CSS::Percentage { 100 }).release_value_but_fixme_should_propagate_errors()); style.set_property(CSS::PropertyID::Height, CSS::PercentageStyleValue::create(CSS::Percentage { 100 }));
} }
} }

View file

@ -31,17 +31,17 @@ void SVGSymbolElement::initialize(JS::Realm& realm)
void SVGSymbolElement::apply_presentational_hints(CSS::StyleProperties& style) const void SVGSymbolElement::apply_presentational_hints(CSS::StyleProperties& style) const
{ {
// The user agent style sheet sets the overflow property for symbol elements to hidden. // The user agent style sheet sets the overflow property for symbol elements to hidden.
auto hidden = CSS::IdentifierStyleValue::create(CSS::ValueID::Hidden).release_value_but_fixme_should_propagate_errors(); auto hidden = CSS::IdentifierStyleValue::create(CSS::ValueID::Hidden);
style.set_property(CSS::PropertyID::Overflow, CSS::OverflowStyleValue::create(hidden, hidden).release_value_but_fixme_should_propagate_errors()); style.set_property(CSS::PropertyID::Overflow, CSS::OverflowStyleValue::create(hidden, hidden));
if (is_direct_child_of_use_shadow_tree()) { if (is_direct_child_of_use_shadow_tree()) {
// The generated instance of a symbol that is the direct referenced element of a use element must always have a computed value of inline for the display property. // The generated instance of a symbol that is the direct referenced element of a use element must always have a computed value of inline for the display property.
style.set_property(CSS::PropertyID::Display, CSS::DisplayStyleValue::create(CSS::Display::from_short(CSS::Display::Short::Inline)).release_value_but_fixme_should_propagate_errors()); style.set_property(CSS::PropertyID::Display, CSS::DisplayStyleValue::create(CSS::Display::from_short(CSS::Display::Short::Inline)));
} else { } else {
// FIXME: When we have a DefaultSVG.css then use https://svgwg.org/svg2-draft/styling.html#UAStyleSheet instead. // FIXME: When we have a DefaultSVG.css then use https://svgwg.org/svg2-draft/styling.html#UAStyleSheet instead.
// The user agent must set the display property on the symbol element to none, as part of the user agent style sheet, // The user agent must set the display property on the symbol element to none, as part of the user agent style sheet,
// and this declaration must have importance over any other CSS rule or presentation attribute. // and this declaration must have importance over any other CSS rule or presentation attribute.
style.set_property(CSS::PropertyID::Display, CSS::DisplayStyleValue::create(CSS::Display::from_short(CSS::Display::Short::None)).release_value_but_fixme_should_propagate_errors()); style.set_property(CSS::PropertyID::Display, CSS::DisplayStyleValue::create(CSS::Display::from_short(CSS::Display::Short::None)));
} }
} }