Skip to content

Commit 12d75b1

Browse files
MichielVrinsawesomekling
authored andcommitted
LibWeb: Inspector content_size tooltip in document view
This adds a small tooltip in the browser showing the size of the element that currently selected in the inspector view. This allows for easier debugging since you dont have to dump the layout tree :^).
1 parent 7527b52 commit 12d75b1

File tree

1 file changed

+10
-0
lines changed
  • Userland/Libraries/LibWeb/Layout

1 file changed

+10
-0
lines changed

Userland/Libraries/LibWeb/Layout/Box.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,16 @@ void Box::paint(PaintContext& context, PaintPhase phase)
4646
context.painter().draw_rect(enclosing_int_rect(margin_rect), Color::Yellow);
4747
context.painter().draw_rect(enclosing_int_rect(absolute_padding_box_rect()), Color::Cyan);
4848
context.painter().draw_rect(enclosing_int_rect(content_rect), Color::Magenta);
49+
50+
auto size_text_rect = absolute_rect();
51+
auto size_text = String::formatted("{}x{}", content_rect.width(), content_rect.height());
52+
size_text_rect.set_y(content_rect.y() + content_rect.height());
53+
size_text_rect.set_top(size_text_rect.top());
54+
size_text_rect.set_width((float)context.painter().font().width(size_text));
55+
size_text_rect.set_height(context.painter().font().glyph_height());
56+
57+
context.painter().fill_rect(enclosing_int_rect(size_text_rect), Color::Cyan);
58+
context.painter().draw_text(enclosing_int_rect(size_text_rect), size_text);
4959
}
5060

5161
if (phase == PaintPhase::FocusOutline && dom_node() && dom_node()->is_element() && verify_cast<DOM::Element>(*dom_node()).is_focused()) {

0 commit comments

Comments
 (0)