Serenity Operating System
at master 44 lines 1.4 kB view raw
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 12namespace Web::Layout { 13 14class Label final : public BlockContainer { 15 JS_CELL(Label, BlockContainer); 16 17public: 18 Label(DOM::Document&, HTML::HTMLLabelElement*, NonnullRefPtr<CSS::StyleProperties>); 19 virtual ~Label() override; 20 21 static bool is_inside_associated_label(LabelableNode const&, CSSPixelPoint); 22 static bool is_associated_label_hovered(LabelableNode const&); 23 24 const HTML::HTMLLabelElement& dom_node() const { return static_cast<const HTML::HTMLLabelElement&>(*BlockContainer::dom_node()); } 25 HTML::HTMLLabelElement& dom_node() { return static_cast<HTML::HTMLLabelElement&>(*BlockContainer::dom_node()); } 26 27 void handle_mousedown_on_label(Badge<Painting::TextPaintable>, CSSPixelPoint, unsigned button); 28 void handle_mouseup_on_label(Badge<Painting::TextPaintable>, CSSPixelPoint, unsigned button); 29 void handle_mousemove_on_label(Badge<Painting::TextPaintable>, CSSPixelPoint, unsigned button); 30 31 LabelableNode* labeled_control(); 32 33private: 34 virtual bool is_label() const override { return true; } 35 36 static Label const* label_for_control_node(LabelableNode const&); 37 38 bool m_tracking_mouse { false }; 39}; 40 41template<> 42inline bool Node::fast_is<Label>() const { return is_label(); } 43 44}