summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/Painting/PaintableBox.cpp
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2022-03-29 15:43:28 +0200
committerAndreas Kling <kling@serenityos.org>2022-03-29 16:35:46 +0200
commit0de488749fa9648e0aa1fc654e6b8a0be490cf03 (patch)
treea77712190489cc0380fbf7a62a77a891047d10c3 /Userland/Libraries/LibWeb/Painting/PaintableBox.cpp
parente1cf51b0bd41a7c5854f8b741ee277492dfd6b6b (diff)
downloadserenity-0de488749fa9648e0aa1fc654e6b8a0be490cf03.zip
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.
Diffstat (limited to 'Userland/Libraries/LibWeb/Painting/PaintableBox.cpp')
-rw-r--r--Userland/Libraries/LibWeb/Painting/PaintableBox.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/Userland/Libraries/LibWeb/Painting/PaintableBox.cpp b/Userland/Libraries/LibWeb/Painting/PaintableBox.cpp
index 007d884869..c28958f8c7 100644
--- a/Userland/Libraries/LibWeb/Painting/PaintableBox.cpp
+++ b/Userland/Libraries/LibWeb/Painting/PaintableBox.cpp
@@ -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());
}