mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 23:07:34 +00:00
LibWeb: Allow having a linear-gradient() as a background-image
This commit is contained in:
parent
d924e9ff60
commit
ee7e9e7c86
4 changed files with 11 additions and 7 deletions
|
@ -60,7 +60,7 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
struct BackgroundLayerData {
|
struct BackgroundLayerData {
|
||||||
RefPtr<CSS::ImageStyleValue> image { nullptr };
|
RefPtr<CSS::StyleValue> background_image { nullptr };
|
||||||
CSS::BackgroundAttachment attachment { CSS::BackgroundAttachment::Scroll };
|
CSS::BackgroundAttachment attachment { CSS::BackgroundAttachment::Scroll };
|
||||||
CSS::BackgroundBox origin { CSS::BackgroundBox::PaddingBox };
|
CSS::BackgroundBox origin { CSS::BackgroundBox::PaddingBox };
|
||||||
CSS::BackgroundBox clip { CSS::BackgroundBox::BorderBox };
|
CSS::BackgroundBox clip { CSS::BackgroundBox::BorderBox };
|
||||||
|
|
|
@ -21,7 +21,7 @@ bool HTMLHtmlElement::should_use_body_background_properties() const
|
||||||
auto const& background_layers = layout_node()->background_layers();
|
auto const& background_layers = layout_node()->background_layers();
|
||||||
|
|
||||||
for (auto& layer : background_layers) {
|
for (auto& layer : background_layers) {
|
||||||
if (layer.image)
|
if (layer.background_image)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -280,9 +280,13 @@ void NodeWithStyle::apply_style(const CSS::StyleProperties& computed_style)
|
||||||
for (size_t layer_index = 0; layer_index < layer_count; layer_index++) {
|
for (size_t layer_index = 0; layer_index < layer_count; layer_index++) {
|
||||||
CSS::BackgroundLayerData layer;
|
CSS::BackgroundLayerData layer;
|
||||||
|
|
||||||
if (auto image_value = value_for_layer(images, layer_index); image_value && image_value->is_image()) {
|
if (auto image_value = value_for_layer(images, layer_index); image_value) {
|
||||||
layer.image = image_value->as_image();
|
if (image_value->is_image()) {
|
||||||
layer.image->load_bitmap(document());
|
image_value->as_image().load_bitmap(document());
|
||||||
|
layer.background_image = image_value;
|
||||||
|
} else if (image_value->is_linear_gradient()) {
|
||||||
|
layer.background_image = image_value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (auto attachment_value = value_for_layer(attachments, layer_index); attachment_value && attachment_value->has_identifier()) {
|
if (auto attachment_value = value_for_layer(attachments, layer_index); attachment_value && attachment_value->has_identifier()) {
|
||||||
|
|
|
@ -60,7 +60,7 @@ void paint_background(PaintContext& context, Layout::NodeWithStyleAndBoxModelMet
|
||||||
color_box = get_box(background_layers->last().clip);
|
color_box = get_box(background_layers->last().clip);
|
||||||
|
|
||||||
auto layer_is_paintable = [&](auto& layer) {
|
auto layer_is_paintable = [&](auto& layer) {
|
||||||
return layer.image && layer.image->bitmap();
|
return layer.background_image && layer.background_image->is_image() && layer.background_image->as_image().bitmap();
|
||||||
};
|
};
|
||||||
|
|
||||||
bool has_paintable_layers = false;
|
bool has_paintable_layers = false;
|
||||||
|
@ -86,7 +86,6 @@ void paint_background(PaintContext& context, Layout::NodeWithStyleAndBoxModelMet
|
||||||
if (!layer_is_paintable(layer))
|
if (!layer_is_paintable(layer))
|
||||||
continue;
|
continue;
|
||||||
Gfx::PainterStateSaver state { painter };
|
Gfx::PainterStateSaver state { painter };
|
||||||
auto& image = *layer.image->bitmap();
|
|
||||||
|
|
||||||
// Clip
|
// Clip
|
||||||
auto clip_box = get_box(layer.clip);
|
auto clip_box = get_box(layer.clip);
|
||||||
|
@ -94,6 +93,7 @@ void paint_background(PaintContext& context, Layout::NodeWithStyleAndBoxModelMet
|
||||||
painter.add_clip_rect(clip_rect);
|
painter.add_clip_rect(clip_rect);
|
||||||
ScopedCornerRadiusClip corner_clip { painter, clip_rect, clip_box.radii };
|
ScopedCornerRadiusClip corner_clip { painter, clip_rect, clip_box.radii };
|
||||||
|
|
||||||
|
auto& image = *layer.background_image->as_image().bitmap();
|
||||||
Gfx::FloatRect background_positioning_area;
|
Gfx::FloatRect background_positioning_area;
|
||||||
|
|
||||||
// Attachment and Origin
|
// Attachment and Origin
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue