mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 22:37:35 +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
|
@ -33,17 +33,25 @@ void MarkerPaintable::paint(PaintContext& context, PaintPhase phase) const
|
|||
|
||||
auto enclosing = enclosing_int_rect(absolute_rect());
|
||||
|
||||
if (auto const* list_style_image = layout_box().list_style_image_bitmap()) {
|
||||
context.painter().blit(enclosing.location(), *list_style_image, list_style_image->rect());
|
||||
int marker_width = (int)enclosing.height() / 2;
|
||||
|
||||
if (auto const* list_style_image = layout_box().list_style_image()) {
|
||||
Gfx::IntRect image_rect {
|
||||
0, 0,
|
||||
list_style_image->natural_width().value_or(marker_width),
|
||||
list_style_image->natural_height().value_or(marker_width)
|
||||
};
|
||||
image_rect.center_within(enclosing);
|
||||
list_style_image->resolve_for_size(layout_box(), image_rect.size().to_type<float>());
|
||||
list_style_image->paint(context, image_rect);
|
||||
return;
|
||||
}
|
||||
|
||||
auto color = computed_values().color();
|
||||
|
||||
int marker_width = (int)enclosing.height() / 2;
|
||||
Gfx::IntRect marker_rect { 0, 0, marker_width, marker_width };
|
||||
marker_rect.center_within(enclosing);
|
||||
|
||||
auto color = computed_values().color();
|
||||
|
||||
Gfx::AntiAliasingPainter aa_painter { context.painter() };
|
||||
|
||||
switch (layout_box().list_style_type()) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue