1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 22:17:44 +00:00

LibWeb+WebContent+WebWorker: Add an option to skip painting the overlay

This will allow the Inspector to take a screenshot of a DOM node without
the overlay which renders the inspected node outline / box data.
This commit is contained in:
Timothy Flynn 2023-12-06 11:49:45 -05:00 committed by Andreas Kling
parent bea11f6d99
commit a7b98a9761
8 changed files with 26 additions and 8 deletions

View file

@ -198,6 +198,15 @@ private:
bool m_pdf_viewer_supported { false };
};
struct PaintOptions {
enum class PaintOverlay {
No,
Yes,
};
PaintOverlay paint_overlay { PaintOverlay::Yes };
};
class PageClient : public JS::Cell {
JS_CELL(PageClient, JS::Cell);
@ -209,7 +218,7 @@ public:
virtual DevicePixelRect screen_rect() const = 0;
virtual double device_pixels_per_css_pixel() const = 0;
virtual CSS::PreferredColorScheme preferred_color_scheme() const = 0;
virtual void paint(DevicePixelRect const&, Gfx::Bitmap&) = 0;
virtual void paint(DevicePixelRect const&, Gfx::Bitmap&, PaintOptions = {}) = 0;
virtual void page_did_change_title(DeprecatedString const&) { }
virtual void page_did_request_navigate_back() { }
virtual void page_did_request_navigate_forward() { }

View file

@ -26,6 +26,9 @@ public:
bool should_show_line_box_borders() const { return m_should_show_line_box_borders; }
void set_should_show_line_box_borders(bool value) { m_should_show_line_box_borders = value; }
bool should_paint_overlay() const { return m_should_paint_overlay; }
void set_should_paint_overlay(bool should_paint_overlay) { m_should_paint_overlay = should_paint_overlay; }
DevicePixelRect device_viewport_rect() const { return m_device_viewport_rect; }
void set_device_viewport_rect(DevicePixelRect const& rect) { m_device_viewport_rect = rect; }
CSSPixelRect css_viewport_rect() const;
@ -62,6 +65,7 @@ public:
auto clone = PaintContext(painter, m_palette, m_device_pixels_per_css_pixel);
clone.m_device_viewport_rect = m_device_viewport_rect;
clone.m_should_show_line_box_borders = m_should_show_line_box_borders;
clone.m_should_paint_overlay = m_should_paint_overlay;
clone.m_focus = m_focus;
return clone;
}
@ -79,6 +83,7 @@ private:
double m_device_pixels_per_css_pixel { 0 };
DevicePixelRect m_device_viewport_rect;
bool m_should_show_line_box_borders { false };
bool m_should_paint_overlay { true };
bool m_focus { false };
CSSPixelPoint m_scroll_offset;
Gfx::AffineTransform m_svg_transform;

View file

@ -264,8 +264,11 @@ void StackingContext::paint_internal(PaintContext& context) const
}
paint_node(paintable_box(), context, PaintPhase::Outline);
paint_node(paintable_box(), context, PaintPhase::Overlay);
paint_descendants(context, paintable_box(), StackingContextPaintPhase::FocusAndOverlay);
if (context.should_paint_overlay()) {
paint_node(paintable_box(), context, PaintPhase::Overlay);
paint_descendants(context, paintable_box(), StackingContextPaintPhase::FocusAndOverlay);
}
}
Gfx::FloatMatrix4x4 StackingContext::combine_transformations(Vector<CSS::Transformation> const& transformations) const

View file

@ -45,7 +45,7 @@ public:
virtual double device_pixels_per_css_pixel() const override { return 1.0; }
virtual CSS::PreferredColorScheme preferred_color_scheme() const override { return m_host_page.client().preferred_color_scheme(); }
virtual void request_file(FileRequest) override { }
virtual void paint(DevicePixelRect const&, Gfx::Bitmap&) override { }
virtual void paint(DevicePixelRect const&, Gfx::Bitmap&, Web::PaintOptions = {}) override { }
private:
explicit SVGPageClient(Page& host_page)