mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 18:47:34 +00:00
LibWeb: Convert images to common AbstractImageStyleValue base
This commit moves both the ImageStyleValue and LinearGradientStyleValue to a common base class of AbstractImageStyleValue. This abstracts getting the natural_width/height, loading/resolving, and painting the image. Now for 'free' you get: - Linear gradients working with the various background sizing/repeat properties. - Linear gradients working as list-markers :^) -- best feature ever! P.s. This commit is a little large as it's tricky to make this change incrementally without breaking things.
This commit is contained in:
parent
264543b90a
commit
6a6475673f
13 changed files with 140 additions and 70 deletions
|
@ -248,11 +248,9 @@ void NodeWithStyle::apply_style(const CSS::StyleProperties& computed_style)
|
|||
CSS::BackgroundLayerData layer;
|
||||
|
||||
if (auto image_value = value_for_layer(images, layer_index); image_value) {
|
||||
if (image_value->is_image()) {
|
||||
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 (image_value->is_abstract_image()) {
|
||||
layer.background_image = image_value->as_abstract_image();
|
||||
layer.background_image->load_any_resources(document());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -461,9 +459,9 @@ void NodeWithStyle::apply_style(const CSS::StyleProperties& computed_style)
|
|||
computed_values.set_list_style_type(list_style_type.value());
|
||||
|
||||
auto list_style_image = computed_style.property(CSS::PropertyID::ListStyleImage);
|
||||
if (list_style_image->is_image()) {
|
||||
m_list_style_image = list_style_image->as_image();
|
||||
m_list_style_image->load_bitmap(document());
|
||||
if (list_style_image->is_abstract_image()) {
|
||||
m_list_style_image = list_style_image->as_abstract_image();
|
||||
m_list_style_image->load_any_resources(document());
|
||||
}
|
||||
|
||||
computed_values.set_color(computed_style.color_or_fallback(CSS::PropertyID::Color, *this, CSS::InitialValues::color()));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue