mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-19 07:33:20 +00:00
LibWeb: Unify similar debug overlay code paths
The debug option 'Show Line Box Borders' and the inspector overlay for text nodes are conceptually similar. However they use two different code paths. This commits unifies both to use the same code.
This commit is contained in:
parent
9ace789ab4
commit
0e7749e6cd
Notes:
github-actions[bot]
2025-09-19 08:19:26 +00:00
Author: https://github.com/InvalidUsernameException
Commit: 0e7749e6cd
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6056
Reviewed-by: https://github.com/gmta ✅
2 changed files with 14 additions and 10 deletions
|
@ -976,8 +976,8 @@ void paint_text_fragment(DisplayListRecordingContext& context, TextPaintable con
|
|||
auto fragment_absolute_rect = fragment.absolute_rect();
|
||||
auto fragment_enclosing_device_rect = context.enclosing_device_rect(fragment_absolute_rect).to_type<int>();
|
||||
|
||||
if (paintable.document().highlighted_layout_node() == &paintable.layout_node())
|
||||
context.display_list_recorder().draw_rect(fragment_enclosing_device_rect, Color::Magenta);
|
||||
if (paintable.document().highlighted_layout_node() == &paintable.layout_node() || context.should_show_line_box_borders())
|
||||
paint_text_fragment_debug_highlight(context, fragment);
|
||||
|
||||
auto glyph_run = fragment.glyph_run();
|
||||
if (!glyph_run)
|
||||
|
@ -999,6 +999,17 @@ void paint_text_fragment(DisplayListRecordingContext& context, TextPaintable con
|
|||
}
|
||||
}
|
||||
|
||||
void paint_text_fragment_debug_highlight(DisplayListRecordingContext& context, PaintableFragment const& fragment)
|
||||
{
|
||||
auto fragment_absolute_rect = fragment.absolute_rect();
|
||||
auto fragment_absolute_device_rect = context.enclosing_device_rect(fragment_absolute_rect);
|
||||
context.display_list_recorder().draw_rect(fragment_absolute_device_rect.to_type<int>(), Color::Green);
|
||||
|
||||
auto baseline_start = context.rounded_device_point(fragment_absolute_rect.top_left().translated(0, fragment.baseline())).to_type<int>();
|
||||
auto baseline_end = context.rounded_device_point(fragment_absolute_rect.top_right().translated(-1, fragment.baseline())).to_type<int>();
|
||||
context.display_list_recorder().draw_line(baseline_start, baseline_end, Color::Red);
|
||||
}
|
||||
|
||||
void PaintableWithLines::paint(DisplayListRecordingContext& context, PaintPhase phase) const
|
||||
{
|
||||
if (!is_visible())
|
||||
|
@ -1016,14 +1027,6 @@ void PaintableWithLines::paint(DisplayListRecordingContext& context, PaintPhase
|
|||
}
|
||||
|
||||
for (auto const& fragment : m_fragments) {
|
||||
auto fragment_absolute_rect = fragment.absolute_rect();
|
||||
if (phase == PaintPhase::Foreground && context.should_show_line_box_borders()) {
|
||||
auto fragment_absolute_device_rect = context.enclosing_device_rect(fragment_absolute_rect);
|
||||
context.display_list_recorder().draw_rect(fragment_absolute_device_rect.to_type<int>(), Color::Green);
|
||||
context.display_list_recorder().draw_line(
|
||||
context.rounded_device_point(fragment_absolute_rect.top_left().translated(0, fragment.baseline())).to_type<int>(),
|
||||
context.rounded_device_point(fragment_absolute_rect.top_right().translated(-1, fragment.baseline())).to_type<int>(), Color::Red);
|
||||
}
|
||||
if (is<TextPaintable>(fragment.paintable()))
|
||||
paint_text_fragment(context, static_cast<TextPaintable const&>(fragment.paintable()), fragment, phase);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue