diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp index 325f9d111e..676bda7b5c 100644 --- a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp +++ b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp @@ -4167,6 +4167,15 @@ ErrorOr> Parser::parse_background_value(Vector background_color; + auto initial_background_image = TRY(property_initial_value(m_context.realm(), PropertyID::BackgroundImage)); + auto initial_background_position = TRY(property_initial_value(m_context.realm(), PropertyID::BackgroundPosition)); + auto initial_background_size = TRY(property_initial_value(m_context.realm(), PropertyID::BackgroundSize)); + auto initial_background_repeat = TRY(property_initial_value(m_context.realm(), PropertyID::BackgroundRepeat)); + auto initial_background_attachment = TRY(property_initial_value(m_context.realm(), PropertyID::BackgroundAttachment)); + auto initial_background_clip = TRY(property_initial_value(m_context.realm(), PropertyID::BackgroundClip)); + auto initial_background_origin = TRY(property_initial_value(m_context.realm(), PropertyID::BackgroundOrigin)); + auto initial_background_color = TRY(property_initial_value(m_context.realm(), PropertyID::BackgroundColor)); + // Per-layer values RefPtr background_image; RefPtr background_position; @@ -4190,15 +4199,15 @@ ErrorOr> Parser::parse_background_value(Vector ErrorOr { - TRY(background_images.try_append(background_image ? background_image.release_nonnull() : TRY(property_initial_value(m_context.realm(), PropertyID::BackgroundImage)))); - TRY(background_positions.try_append(background_position ? background_position.release_nonnull() : TRY(property_initial_value(m_context.realm(), PropertyID::BackgroundPosition)))); - TRY(background_sizes.try_append(background_size ? background_size.release_nonnull() : TRY(property_initial_value(m_context.realm(), PropertyID::BackgroundSize)))); - TRY(background_repeats.try_append(background_repeat ? background_repeat.release_nonnull() : TRY(property_initial_value(m_context.realm(), PropertyID::BackgroundRepeat)))); - TRY(background_attachments.try_append(background_attachment ? background_attachment.release_nonnull() : TRY(property_initial_value(m_context.realm(), PropertyID::BackgroundAttachment)))); + TRY(background_images.try_append(background_image ? background_image.release_nonnull() : initial_background_image)); + TRY(background_positions.try_append(background_position ? background_position.release_nonnull() : initial_background_position)); + TRY(background_sizes.try_append(background_size ? background_size.release_nonnull() : initial_background_size)); + TRY(background_repeats.try_append(background_repeat ? background_repeat.release_nonnull() : initial_background_repeat)); + TRY(background_attachments.try_append(background_attachment ? background_attachment.release_nonnull() : initial_background_attachment)); if (!background_origin && !background_clip) { - background_origin = TRY(property_initial_value(m_context.realm(), PropertyID::BackgroundOrigin)); - background_clip = TRY(property_initial_value(m_context.realm(), PropertyID::BackgroundClip)); + background_origin = initial_background_origin; + background_clip = initial_background_clip; } else if (!background_clip) { background_clip = background_origin; } @@ -4312,7 +4321,7 @@ ErrorOr> Parser::parse_background_value(Vector> Parser::parse_background_value(Vector