2021-04-03 22:32:16 -03:00
|
|
|
/*
|
2022-01-31 15:07:22 -03:00
|
|
|
* Copyright (c) 2021, Tim Flynn <trflynn89@serenityos.org>
|
2021-04-03 22:32:16 -03:00
|
|
|
*
|
2021-04-22 05:24:48 -03:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2021-04-03 22:32:16 -03:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2025-07-19 23:35:33 -03:00
|
|
|
#include <LibWeb/Export.h>
|
2021-04-03 22:32:16 -03:00
|
|
|
#include <LibWeb/HTML/HTMLLabelElement.h>
|
2021-10-06 15:02:41 -03:00
|
|
|
#include <LibWeb/Layout/BlockContainer.h>
|
2021-04-03 22:32:16 -03:00
|
|
|
|
|
|
|
|
namespace Web::Layout {
|
|
|
|
|
|
2025-07-19 23:35:33 -03:00
|
|
|
class WEB_API Label final : public BlockContainer {
|
2024-11-14 12:01:23 -03:00
|
|
|
GC_CELL(Label, BlockContainer);
|
|
|
|
|
GC_DECLARE_ALLOCATOR(Label);
|
2022-10-17 09:41:50 -03:00
|
|
|
|
2021-04-03 22:32:16 -03:00
|
|
|
public:
|
2024-12-20 12:35:12 -03:00
|
|
|
Label(DOM::Document&, HTML::HTMLLabelElement*, GC::Ref<CSS::ComputedProperties>);
|
2021-04-03 22:32:16 -03:00
|
|
|
virtual ~Label() override;
|
|
|
|
|
|
2022-11-02 14:35:53 -03:00
|
|
|
static bool is_inside_associated_label(LabelableNode const&, CSSPixelPoint);
|
2022-03-10 18:46:35 -03:00
|
|
|
static bool is_associated_label_hovered(LabelableNode const&);
|
2021-04-03 22:32:16 -03:00
|
|
|
|
2025-08-29 09:02:52 -03:00
|
|
|
HTML::HTMLLabelElement const& dom_node() const { return static_cast<HTML::HTMLLabelElement const&>(*BlockContainer::dom_node()); }
|
2021-10-06 15:02:41 -03:00
|
|
|
HTML::HTMLLabelElement& dom_node() { return static_cast<HTML::HTMLLabelElement&>(*BlockContainer::dom_node()); }
|
2021-04-03 22:32:16 -03:00
|
|
|
|
2022-11-02 14:35:53 -03:00
|
|
|
void handle_mousedown_on_label(Badge<Painting::TextPaintable>, CSSPixelPoint, unsigned button);
|
|
|
|
|
void handle_mouseup_on_label(Badge<Painting::TextPaintable>, CSSPixelPoint, unsigned button);
|
|
|
|
|
void handle_mousemove_on_label(Badge<Painting::TextPaintable>, CSSPixelPoint, unsigned button);
|
2021-04-03 22:32:16 -03:00
|
|
|
|
2021-04-03 22:48:05 -03:00
|
|
|
private:
|
2021-10-27 12:58:19 -03:00
|
|
|
virtual bool is_label() const override { return true; }
|
|
|
|
|
|
2022-03-10 18:46:35 -03:00
|
|
|
static Label const* label_for_control_node(LabelableNode const&);
|
2021-04-03 22:32:16 -03:00
|
|
|
|
|
|
|
|
bool m_tracking_mouse { false };
|
|
|
|
|
};
|
|
|
|
|
|
2021-10-27 12:58:19 -03:00
|
|
|
template<>
|
|
|
|
|
inline bool Node::fast_is<Label>() const { return is_label(); }
|
|
|
|
|
|
2021-04-03 22:32:16 -03:00
|
|
|
}
|