Coverage Report

Created: 2025-09-05 06:52

/src/serenity/Userland/Libraries/LibWeb/Layout/Label.h
Line
Count
Source (jump to first uncovered line)
1
/*
2
 * Copyright (c) 2021, Tim Flynn <trflynn89@serenityos.org>
3
 *
4
 * SPDX-License-Identifier: BSD-2-Clause
5
 */
6
7
#pragma once
8
9
#include <LibWeb/HTML/HTMLLabelElement.h>
10
#include <LibWeb/Layout/BlockContainer.h>
11
12
namespace Web::Layout {
13
14
class Label final : public BlockContainer {
15
    JS_CELL(Label, BlockContainer);
16
    JS_DECLARE_ALLOCATOR(Label);
17
18
public:
19
    Label(DOM::Document&, HTML::HTMLLabelElement*, NonnullRefPtr<CSS::StyleProperties>);
20
    virtual ~Label() override;
21
22
    static bool is_inside_associated_label(LabelableNode const&, CSSPixelPoint);
23
    static bool is_associated_label_hovered(LabelableNode const&);
24
25
0
    const HTML::HTMLLabelElement& dom_node() const { return static_cast<const HTML::HTMLLabelElement&>(*BlockContainer::dom_node()); }
26
0
    HTML::HTMLLabelElement& dom_node() { return static_cast<HTML::HTMLLabelElement&>(*BlockContainer::dom_node()); }
27
28
    void handle_mousedown_on_label(Badge<Painting::TextPaintable>, CSSPixelPoint, unsigned button);
29
    void handle_mouseup_on_label(Badge<Painting::TextPaintable>, CSSPixelPoint, unsigned button);
30
    void handle_mousemove_on_label(Badge<Painting::TextPaintable>, CSSPixelPoint, unsigned button);
31
32
private:
33
0
    virtual bool is_label() const override { return true; }
34
35
    static Label const* label_for_control_node(LabelableNode const&);
36
37
    bool m_tracking_mouse { false };
38
};
39
40
template<>
41
0
inline bool Node::fast_is<Label>() const { return is_label(); }
42
43
}