1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 07:27:45 +00:00

LibWeb: Convert BorderData::width to CSSPixels

The `clip_shrink` optimization in `paint_background()` now also
correctly uses DevicePixels, instead of reducing a DevicePixel rect by
a CSSPixels amount.
This commit is contained in:
Sam Atkins 2023-07-30 15:54:57 +01:00 committed by Sam Atkins
parent 072ab94889
commit 5ee1b7db7c
7 changed files with 20 additions and 20 deletions

View file

@ -83,10 +83,10 @@ void paint_background(PaintContext& context, Layout::NodeWithStyleAndBoxModelMet
return;
struct {
int top { 0 };
int bottom { 0 };
int left { 0 };
int right { 0 };
DevicePixels top { 0 };
DevicePixels bottom { 0 };
DevicePixels left { 0 };
DevicePixels right { 0 };
} clip_shrink;
auto border_top = layout_node.computed_values().border_top();
@ -96,10 +96,10 @@ void paint_background(PaintContext& context, Layout::NodeWithStyleAndBoxModelMet
if (border_top.color.alpha() == 255 && border_bottom.color.alpha() == 255
&& border_left.color.alpha() == 255 && border_right.color.alpha() == 255) {
clip_shrink.top = border_top.width;
clip_shrink.bottom = border_bottom.width;
clip_shrink.left = border_left.width;
clip_shrink.right = border_right.width;
clip_shrink.top = context.rounded_device_pixels(border_top.width);
clip_shrink.bottom = context.rounded_device_pixels(border_bottom.width);
clip_shrink.left = context.rounded_device_pixels(border_left.width);
clip_shrink.right = context.rounded_device_pixels(border_right.width);
}
// Note: Background layers are ordered front-to-back, so we paint them in reverse

View file

@ -106,7 +106,7 @@ void paint_border(PaintContext& context, BorderEdge edge, DevicePixelRect const&
auto color = border_color(edge, borders_data);
auto border_style = border_data.line_style;
auto device_pixel_width = context.enclosing_device_pixels(width);
auto device_pixel_width = context.rounded_device_pixels(width);
struct Points {
DevicePixelPoint p1;

View file

@ -278,7 +278,7 @@ void PaintableBox::paint_background(PaintContext& context) const
// HACK: If the Box has a border, use the bordered_rect to paint the background.
// This way if we have a border-radius there will be no gap between the filling and actual border.
if (computed_values().border_top().width || computed_values().border_right().width || computed_values().border_bottom().width || computed_values().border_left().width)
if (computed_values().border_top().width != 0 || computed_values().border_right().width != 0 || computed_values().border_bottom().width != 0 || computed_values().border_left().width != 0)
background_rect = absolute_border_box_rect();
Painting::paint_background(context, layout_box(), background_rect, background_color, computed_values().image_rendering(), background_layers, normalized_border_radii_data());