From a72302342aca1ceadd919b0b0e3949f7ce928028 Mon Sep 17 00:00:00 2001 From: Sam Atkins Date: Thu, 27 Oct 2022 16:23:39 +0100 Subject: [PATCH] LibWeb: Convert marker painting to new pixel units --- .../LibWeb/Painting/MarkerPaintable.cpp | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/Userland/Libraries/LibWeb/Painting/MarkerPaintable.cpp b/Userland/Libraries/LibWeb/Painting/MarkerPaintable.cpp index 6e4422bdbd..6911166c84 100644 --- a/Userland/Libraries/LibWeb/Painting/MarkerPaintable.cpp +++ b/Userland/Libraries/LibWeb/Painting/MarkerPaintable.cpp @@ -31,24 +31,28 @@ void MarkerPaintable::paint(PaintContext& context, PaintPhase phase) const if (phase != PaintPhase::Foreground) return; - auto enclosing = enclosing_int_rect(absolute_rect()); + CSSPixelRect enclosing = absolute_rect().to_rounded().to_type(); + auto device_enclosing = context.enclosing_device_rect(enclosing); - int marker_width = (int)enclosing.height() / 2; + CSSPixels marker_width = enclosing.height() / 2.0f; if (auto const* list_style_image = layout_box().list_style_image()) { - Gfx::IntRect image_rect { + CSSPixelRect image_rect { 0, 0, - list_style_image->natural_width().value_or(marker_width), - list_style_image->natural_height().value_or(marker_width) + list_style_image->natural_width().value_or(marker_width.value()), + list_style_image->natural_height().value_or(marker_width.value()) }; image_rect.center_within(enclosing); - list_style_image->resolve_for_size(layout_box(), image_rect.size().to_type()); - list_style_image->paint(context, image_rect, computed_values().image_rendering()); + + auto device_image_rect = context.enclosing_device_rect(image_rect); + list_style_image->resolve_for_size(layout_box(), device_image_rect.size().to_type().to_type()); + list_style_image->paint(context, device_image_rect.to_type(), computed_values().image_rendering()); return; } - Gfx::IntRect marker_rect { 0, 0, marker_width, marker_width }; + CSSPixelRect marker_rect { 0, 0, marker_width, marker_width }; marker_rect.center_within(enclosing); + auto device_marker_rect = context.enclosing_device_rect(marker_rect); auto color = computed_values().color(); @@ -56,13 +60,13 @@ void MarkerPaintable::paint(PaintContext& context, PaintPhase phase) const switch (layout_box().list_style_type()) { case CSS::ListStyleType::Square: - context.painter().fill_rect(marker_rect, color); + context.painter().fill_rect(device_marker_rect.to_type(), color); break; case CSS::ListStyleType::Circle: - aa_painter.draw_ellipse(marker_rect, color, 1); + aa_painter.draw_ellipse(device_marker_rect.to_type(), color, 1); break; case CSS::ListStyleType::Disc: - aa_painter.fill_ellipse(marker_rect, color); + aa_painter.fill_ellipse(device_marker_rect.to_type(), color); break; case CSS::ListStyleType::Decimal: case CSS::ListStyleType::DecimalLeadingZero: @@ -74,7 +78,7 @@ void MarkerPaintable::paint(PaintContext& context, PaintPhase phase) const case CSS::ListStyleType::UpperRoman: if (layout_box().text().is_null()) break; - context.painter().draw_text(enclosing, layout_box().text(), Gfx::TextAlignment::Center); + context.painter().draw_text(device_enclosing.to_type(), layout_box().text(), Gfx::TextAlignment::Center); break; case CSS::ListStyleType::None: return;