diff --git a/Tests/LibWeb/Ref/button-inside-scroll-container.html b/Tests/LibWeb/Ref/button-inside-scroll-container.html new file mode 100644 index 0000000000..8a39ef8730 --- /dev/null +++ b/Tests/LibWeb/Ref/button-inside-scroll-container.html @@ -0,0 +1,34 @@ + + + +
+ + + + + + + + + + +
+ diff --git a/Tests/LibWeb/Ref/reference/button-inside-scroll-container-ref.html b/Tests/LibWeb/Ref/reference/button-inside-scroll-container-ref.html new file mode 100644 index 0000000000..cdd1639f8d --- /dev/null +++ b/Tests/LibWeb/Ref/reference/button-inside-scroll-container-ref.html @@ -0,0 +1,15 @@ + + + + + diff --git a/Userland/Libraries/LibWeb/Painting/ButtonPaintable.cpp b/Userland/Libraries/LibWeb/Painting/ButtonPaintable.cpp index 0d37b19f37..fd0744d1c0 100644 --- a/Userland/Libraries/LibWeb/Painting/ButtonPaintable.cpp +++ b/Userland/Libraries/LibWeb/Painting/ButtonPaintable.cpp @@ -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()); + 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()); painter.draw_text( text_rect.to_type(), static_cast(dom_node).value(), diff --git a/Userland/Libraries/LibWeb/Painting/PaintableBox.h b/Userland/Libraries/LibWeb/Painting/PaintableBox.h index a2e6b24eb5..4eeb5f95c7 100644 --- a/Userland/Libraries/LibWeb/Painting/PaintableBox.h +++ b/Userland/Libraries/LibWeb/Painting/PaintableBox.h @@ -199,6 +199,8 @@ public: void set_corner_clip_radii(BorderRadiiData const& corner_radii) { m_corner_clip_radii = corner_radii; } Optional scroll_frame_id() const { return m_scroll_frame_id; } + Optional enclosing_scroll_frame_offset() const { return m_enclosing_scroll_frame_offset; } + Optional clip_rect() const { return m_clip_rect; } protected: explicit PaintableBox(Layout::Box const&); @@ -211,9 +213,6 @@ protected: virtual CSSPixelRect compute_absolute_rect() const; virtual CSSPixelRect compute_absolute_paint_rect() const; - Optional enclosing_scroll_frame_offset() const { return m_enclosing_scroll_frame_offset; } - Optional clip_rect() const { return m_clip_rect; } - private: [[nodiscard]] virtual bool is_paintable_box() const final { return true; }