Label.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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/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&);
  15. static bool is_associated_label_hovered(LabelableNode&);
  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<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. virtual bool is_label() const override { return true; }
  23. static Label* label_for_control_node(LabelableNode&);
  24. LabelableNode* control_node();
  25. bool m_tracking_mouse { false };
  26. };
  27. template<>
  28. inline bool Node::fast_is<Label>() const { return is_label(); }
  29. }