From e60253d64c4c3eb339d8a69bbccfb888ea9c0bd6 Mon Sep 17 00:00:00 2001 From: Tobias Christiansen Date: Mon, 30 Oct 2023 16:15:29 +0100 Subject: [PATCH] LibWeb: Respect offsets always when painting with object-position Previously we didn't always set the bitmap_intersect correctly when applying an object-position. This lead to images not correctly being centered when the axis that it should move along was not the specified axis. --- Userland/Libraries/LibWeb/Painting/ImagePaintable.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/Userland/Libraries/LibWeb/Painting/ImagePaintable.cpp b/Userland/Libraries/LibWeb/Painting/ImagePaintable.cpp index a58d4a5a71..07ff2c4173 100644 --- a/Userland/Libraries/LibWeb/Painting/ImagePaintable.cpp +++ b/Userland/Libraries/LibWeb/Painting/ImagePaintable.cpp @@ -141,10 +141,9 @@ void ImagePaintable::paint(PaintContext& context, PaintPhase phase) const offset_x = (double)residual_horizontal - (double)(residual_horizontal)*offset.percentage().as_fraction(); else offset_x = residual_horizontal - offset.length().to_px(layout_node()).to_int(); - - if (image_int_rect.width() < scaled_bitmap_width) - bitmap_intersect.set_x(-(offset_x / scale_x)); } + if (image_int_rect.width() < scaled_bitmap_width) + bitmap_intersect.set_x(-(offset_x / scale_x)); } auto offset_y = 0; @@ -164,10 +163,9 @@ void ImagePaintable::paint(PaintContext& context, PaintPhase phase) const offset_y = (double)residual_vertical - (double)(residual_vertical)*offset.percentage().as_fraction(); else offset_y = residual_vertical - offset.length().to_px(layout_node()).to_int(); - - if (image_int_rect.height() < scaled_bitmap_height) - bitmap_intersect.set_y(-(offset_y / scale_y)); } + if (image_int_rect.height() < scaled_bitmap_height) + bitmap_intersect.set_y(-(offset_y / scale_y)); } Gfx::IntRect draw_rect = {