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