1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 19:28:12 +00:00

LibWeb: Shift button paintable clip rectangle by scroll offset

Rectangles should be recorded using absolute coordinates, including
the scroll offset.
This commit is contained in:
Aliaksandr Kalenik 2024-02-06 11:19:55 +01:00 committed by Andreas Kling
parent d43dbe2842
commit 4a41a65ec5
4 changed files with 54 additions and 4 deletions

View file

@ -60,7 +60,9 @@ void ButtonPaintable::paint(PaintContext& context, PaintPhase phase) const
// Paint button text clipped to button rect
auto& painter = context.recording_painter();
painter.save();
painter.add_clip_rect(button_rect.to_type<int>());
auto clip_rect = absolute_rect();
clip_rect.translate_by(enclosing_scroll_frame_offset().value_or({}));
painter.add_clip_rect(context.enclosing_device_rect(clip_rect).to_type<int>());
painter.draw_text(
text_rect.to_type<int>(),
static_cast<HTML::HTMLInputElement const&>(dom_node).value(),