mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 22:37:35 +00:00
LibWeb: Use rounding instead of enclosing_int_rect() when painting
By using enclosing_int_rect(), borders and backgrounds of boxes were sometimes 1 pixel off, making things slightly larger than they should be. Fix this by using to_rounded() instead of enclosing_int_rect(). There's definitely more of these type of issues lurking in the code, and we'll get to them in time.
This commit is contained in:
parent
e1cf51b0bd
commit
0de488749f
5 changed files with 18 additions and 20 deletions
|
@ -184,13 +184,13 @@ void PaintableBox::paint_background(PaintContext& context) const
|
|||
if (layout_box().is_body() && document().html_element()->should_use_body_background_properties())
|
||||
return;
|
||||
|
||||
Gfx::IntRect background_rect;
|
||||
Gfx::FloatRect background_rect;
|
||||
Color background_color = computed_values().background_color();
|
||||
auto* background_layers = &computed_values().background_layers();
|
||||
|
||||
if (layout_box().is_root_element()) {
|
||||
// CSS 2.1 Appendix E.2: If the element is a root element, paint the background over the entire canvas.
|
||||
background_rect = context.viewport_rect();
|
||||
background_rect = context.viewport_rect().to_type<float>();
|
||||
|
||||
// Section 2.11.2: If the computed value of background-image on the root element is none and its background-color is transparent,
|
||||
// user agents must instead propagate the computed values of the background properties from that element’s first HTML BODY child element.
|
||||
|
@ -199,13 +199,13 @@ void PaintableBox::paint_background(PaintContext& context) const
|
|||
background_color = document().background_color(context.palette());
|
||||
}
|
||||
} else {
|
||||
background_rect = enclosing_int_rect(absolute_padding_box_rect());
|
||||
background_rect = absolute_padding_box_rect();
|
||||
}
|
||||
|
||||
// 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)
|
||||
background_rect = enclosing_int_rect(absolute_border_box_rect());
|
||||
background_rect = absolute_border_box_rect();
|
||||
|
||||
Painting::paint_background(context, layout_box(), background_rect, background_color, background_layers, normalized_border_radius_data());
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue