2021-04-03 21:32:16 -04:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2021, Tim Flynn <trflynn89@pm.me>
|
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2021-04-03 21:32:16 -04:00
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <LibWeb/HTML/HTMLLabelElement.h>
|
2021-10-06 20:02:41 +02:00
|
|
|
#include <LibWeb/Layout/BlockContainer.h>
|
2021-04-03 21:32:16 -04:00
|
|
|
|
|
|
|
namespace Web::Layout {
|
|
|
|
|
2021-10-06 20:02:41 +02:00
|
|
|
class Label : public BlockContainer {
|
2021-04-03 21:32:16 -04:00
|
|
|
public:
|
|
|
|
Label(DOM::Document&, HTML::HTMLLabelElement*, NonnullRefPtr<CSS::StyleProperties>);
|
|
|
|
virtual ~Label() override;
|
|
|
|
|
|
|
|
static bool is_inside_associated_label(LabelableNode&, const Gfx::IntPoint&);
|
2021-04-04 12:17:24 -04:00
|
|
|
static bool is_associated_label_hovered(LabelableNode&);
|
2021-04-03 21:32:16 -04:00
|
|
|
|
2021-10-06 20:02:41 +02:00
|
|
|
const HTML::HTMLLabelElement& dom_node() const { return static_cast<const HTML::HTMLLabelElement&>(*BlockContainer::dom_node()); }
|
|
|
|
HTML::HTMLLabelElement& dom_node() { return static_cast<HTML::HTMLLabelElement&>(*BlockContainer::dom_node()); }
|
2021-04-03 21:32:16 -04:00
|
|
|
|
2021-04-03 21:48:05 -04:00
|
|
|
void handle_mousedown_on_label(Badge<TextNode>, const Gfx::IntPoint&, unsigned button);
|
|
|
|
void handle_mouseup_on_label(Badge<TextNode>, const Gfx::IntPoint&, unsigned button);
|
|
|
|
void handle_mousemove_on_label(Badge<TextNode>, const Gfx::IntPoint&, unsigned button);
|
2021-04-03 21:32:16 -04:00
|
|
|
|
2021-04-03 21:48:05 -04:00
|
|
|
private:
|
2021-04-03 21:32:16 -04:00
|
|
|
static Label* label_for_control_node(LabelableNode&);
|
|
|
|
LabelableNode* control_node();
|
|
|
|
|
|
|
|
bool m_tracking_mouse { false };
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|