summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibGUI/Painter.cpp
diff options
context:
space:
mode:
authorMart G <martg_@hotmail.com>2021-04-24 15:02:25 +0200
committerLinus Groh <mail@linusgroh.de>2021-04-24 15:57:20 +0200
commit157cd7c81967f56e28786f4b2f0f20cbc6aee2c0 (patch)
treefe0bbaec23623274570c99a080c3cc3cd4644220 /Userland/Libraries/LibGUI/Painter.cpp
parent0754280214084c9108b66e87160552168663091e (diff)
downloadserenity-157cd7c81967f56e28786f4b2f0f20cbc6aee2c0.zip
LibGUI: Prevent a Painter's clip_rect from being outside of its target
Previously a Painter's m_clip_origin field was initialized to a widget's window_relative_rect, which is not ensured to be within the target rect. m_clip_origin is normally not used for clipping, but after calling clear_clip_rect the clip rect that IS used for clipping gets reset to m_clip_origin (so an invalid state is entered). Now the window_relative_rect will be clipped by the target rect first, and will only then be used to initialize both the active clip_rect and m_clip_origin.
Diffstat (limited to 'Userland/Libraries/LibGUI/Painter.cpp')
-rw-r--r--Userland/Libraries/LibGUI/Painter.cpp5
1 files changed, 2 insertions, 3 deletions
diff --git a/Userland/Libraries/LibGUI/Painter.cpp b/Userland/Libraries/LibGUI/Painter.cpp
index fc96d25390..9f9688a94c 100644
--- a/Userland/Libraries/LibGUI/Painter.cpp
+++ b/Userland/Libraries/LibGUI/Painter.cpp
@@ -21,9 +21,8 @@ Painter::Painter(Widget& widget)
state().font = &widget.font();
auto origin_rect = widget.window_relative_rect();
state().translation = origin_rect.location();
- state().clip_rect = origin_rect;
- m_clip_origin = origin_rect;
- state().clip_rect.intersect(m_target->rect());
+ state().clip_rect = origin_rect.intersected(m_target->rect());
+ m_clip_origin = state().clip_rect;
}
}