mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 17:47:44 +00:00
LibWeb: Convert ButtonBox to be a LabelableNode
This also adds an API to Label to determine if the Label itself or its child TextNode is hovered. This allows ButtonBox to render in a hovered state when the label is hovered.
This commit is contained in:
parent
d40f3aa0d0
commit
1b2123af80
4 changed files with 65 additions and 11 deletions
|
@ -32,6 +32,7 @@
|
|||
#include <LibWeb/Layout/InitialContainingBlockBox.h>
|
||||
#include <LibWeb/Layout/Label.h>
|
||||
#include <LibWeb/Layout/LabelableNode.h>
|
||||
#include <LibWeb/Layout/TextNode.h>
|
||||
#include <LibWeb/Page/Frame.h>
|
||||
|
||||
namespace Web::Layout {
|
||||
|
@ -95,6 +96,19 @@ bool Label::is_inside_associated_label(LabelableNode& control, const Gfx::IntPoi
|
|||
return false;
|
||||
}
|
||||
|
||||
bool Label::is_associated_label_hovered(LabelableNode& control)
|
||||
{
|
||||
if (auto* label = label_for_control_node(control); label) {
|
||||
if (label->document().hovered_node() == &label->dom_node())
|
||||
return true;
|
||||
|
||||
if (auto* child = label->first_child_of_type<TextNode>(); child)
|
||||
return label->document().hovered_node() == &child->dom_node();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
Label* Label::label_for_control_node(LabelableNode& control)
|
||||
{
|
||||
Label* label = nullptr;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue