summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb
diff options
context:
space:
mode:
authorTobias Christiansen <tobi@tobyase.de>2021-05-16 20:03:04 +0200
committerAndreas Kling <kling@serenityos.org>2021-05-20 22:08:02 +0200
commitadfdfd6aba58f378b00319ac5fc6cdcf78b40a84 (patch)
treeb966b88c443228fdce5754c5f10426b0354b3b53 /Userland/Libraries/LibWeb
parenta49812cb0740be90963fc6b24a3baceff7936550 (diff)
downloadserenity-adfdfd6aba58f378b00319ac5fc6cdcf78b40a84.zip
LibWeb: Deal with Boxes that have a background, border and -radius
This hack allows for Boxes that have a background to be painted and a border to accurately paint their border-radii if needed. For that the box in with the background is drawn is extended to the bordered_rect. The border is later drawn over this regardless. Previously when drawing a Box that had all three, background, border and a border-radius, there could be some white between the filling and the border.
Diffstat (limited to 'Userland/Libraries/LibWeb')
-rw-r--r--Userland/Libraries/LibWeb/Layout/Box.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/Userland/Libraries/LibWeb/Layout/Box.cpp b/Userland/Libraries/LibWeb/Layout/Box.cpp
index f4f2c680aa..de85dde8c5 100644
--- a/Userland/Libraries/LibWeb/Layout/Box.cpp
+++ b/Userland/Libraries/LibWeb/Layout/Box.cpp
@@ -179,11 +179,11 @@ void Box::paint_background(PaintContext& context)
if (is_body() && document().html_element()->should_use_body_background_properties())
return;
+ Gfx::IntRect background_rect;
Color background_color = computed_values().background_color();
const Gfx::Bitmap* background_image = this->background_image() ? this->background_image()->bitmap() : nullptr;
CSS::Repeat background_repeat_x = computed_values().background_repeat_x();
CSS::Repeat background_repeat_y = computed_values().background_repeat_y();
- auto background_rect = enclosing_int_rect(padded_rect);
if (is_root_element()) {
// CSS 2.1 Appendix E.2: If the element is a root element, paint the background over the entire canvas.
@@ -201,6 +201,11 @@ void Box::paint_background(PaintContext& context)
background_rect = enclosing_int_rect(padded_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(bordered_rect());
+
// FIXME: some values should be relative to the height() if specified, but which? For now, all relative values are relative to the width.
auto border_radius_data = normalized_border_radius_data();
auto top_left_radius = border_radius_data.top_left;