Label.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. /*
  2. * Copyright (c) 2021, Tim Flynn <trflynn89@pm.me>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <LibWeb/HTML/HTMLLabelElement.h>
  8. #include <LibWeb/Layout/BlockBox.h>
  9. namespace Web::Layout {
  10. class Label : public BlockBox {
  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&);
  15. static bool is_associated_label_hovered(LabelableNode&);
  16. const HTML::HTMLLabelElement& dom_node() const { return static_cast<const HTML::HTMLLabelElement&>(*BlockBox::dom_node()); }
  17. HTML::HTMLLabelElement& dom_node() { return static_cast<HTML::HTMLLabelElement&>(*BlockBox::dom_node()); }
  18. void handle_mousedown_on_label(Badge<TextNode>, const Gfx::IntPoint&, unsigned button);
  19. void handle_mouseup_on_label(Badge<TextNode>, const Gfx::IntPoint&, unsigned button);
  20. void handle_mousemove_on_label(Badge<TextNode>, const Gfx::IntPoint&, unsigned button);
  21. private:
  22. static Label* label_for_control_node(LabelableNode&);
  23. LabelableNode* control_node();
  24. bool m_tracking_mouse { false };
  25. };
  26. }