Label.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /*
  2. * Copyright (c) 2021, Tim Flynn <trflynn89@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <LibWeb/HTML/HTMLLabelElement.h>
  8. #include <LibWeb/Layout/BlockContainer.h>
  9. namespace Web::Layout {
  10. class Label final : public BlockContainer {
  11. public:
  12. Label(DOM::Document&, HTML::HTMLLabelElement*, NonnullRefPtr<CSS::StyleProperties>);
  13. virtual ~Label() override;
  14. static bool is_inside_associated_label(LabelableNode const&, Gfx::IntPoint const&);
  15. static bool is_associated_label_hovered(LabelableNode const&);
  16. const HTML::HTMLLabelElement& dom_node() const { return static_cast<const HTML::HTMLLabelElement&>(*BlockContainer::dom_node()); }
  17. HTML::HTMLLabelElement& dom_node() { return static_cast<HTML::HTMLLabelElement&>(*BlockContainer::dom_node()); }
  18. void handle_mousedown_on_label(Badge<Painting::TextPaintable>, const Gfx::IntPoint&, unsigned button);
  19. void handle_mouseup_on_label(Badge<Painting::TextPaintable>, const Gfx::IntPoint&, unsigned button);
  20. void handle_mousemove_on_label(Badge<Painting::TextPaintable>, const Gfx::IntPoint&, unsigned button);
  21. LabelableNode* labeled_control();
  22. private:
  23. virtual bool is_label() const override { return true; }
  24. static Label const* label_for_control_node(LabelableNode const&);
  25. bool m_tracking_mouse { false };
  26. };
  27. template<>
  28. inline bool Node::fast_is<Label>() const { return is_label(); }
  29. }