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

LibWeb: Allow focusing individual (focusable) elements with Tab key

You can now cycle through focusable elements (currently only hyperlinks
are focusable) with the Tab key.

The focus outline is rendered in a new FocusOutline paint phase.
This commit is contained in:
Andreas Kling 2020-08-14 19:40:37 +02:00
parent 5939af14d4
commit 01022eb5d6
11 changed files with 92 additions and 2 deletions

View file

@ -715,6 +715,23 @@ void LayoutBlock::paint(PaintContext& context, PaintPhase phase)
}
}
}
if (phase == PaintPhase::FocusOutline) {
if (children_are_inline()) {
for (auto& line_box : m_line_boxes) {
for (auto& fragment : line_box.fragments()) {
auto* node = fragment.layout_node().node();
if (!node)
continue;
auto* parent = node->parent_element();
if (!parent)
continue;
if (parent->is_focused())
context.painter().draw_rect(enclosing_int_rect(fragment.absolute_rect()), context.palette().focus_outline());
}
}
}
}
}
HitTestResult LayoutBlock::hit_test(const Gfx::IntPoint& position, HitTestType type) const