mirror of
https://github.com/RGBCube/serenity
synced 2025-05-30 23:58:12 +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:
parent
5939af14d4
commit
01022eb5d6
11 changed files with 92 additions and 2 deletions
|
@ -27,9 +27,9 @@
|
|||
#include <LibGUI/Painter.h>
|
||||
#include <LibWeb/DOM/Document.h>
|
||||
#include <LibWeb/HTML/HTMLBodyElement.h>
|
||||
#include <LibWeb/Page/Frame.h>
|
||||
#include <LibWeb/Layout/LayoutBlock.h>
|
||||
#include <LibWeb/Layout/LayoutBox.h>
|
||||
#include <LibWeb/Page/Frame.h>
|
||||
|
||||
namespace Web {
|
||||
|
||||
|
@ -222,6 +222,10 @@ void LayoutBox::paint(PaintContext& context, PaintPhase phase)
|
|||
context.painter().draw_rect(enclosing_int_rect(padded_rect), Color::Cyan);
|
||||
context.painter().draw_rect(enclosing_int_rect(content_rect), Color::Magenta);
|
||||
}
|
||||
|
||||
if (phase == PaintPhase::FocusOutline && node() && node()->is_element() && downcast<DOM::Element>(*node()).is_focused()) {
|
||||
context.painter().draw_rect(enclosing_int_rect(absolute_rect()), context.palette().focus_outline());
|
||||
}
|
||||
}
|
||||
|
||||
HitTestResult LayoutBox::hit_test(const Gfx::IntPoint& position, HitTestType type) const
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue