HTMLMeterElement.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. * Copyright (c) 2020, the SerenityOS developers.
  3. * Copyright (c) 2022, Luke Wilde <lukew@serenityos.org>
  4. * Copyright (c) 2023, Bastiaan van der Plaat <bastiaan.v.d.plaat@gmail.com>
  5. *
  6. * SPDX-License-Identifier: BSD-2-Clause
  7. */
  8. #pragma once
  9. #include <LibWeb/ARIA/Roles.h>
  10. #include <LibWeb/HTML/HTMLElement.h>
  11. namespace Web::HTML {
  12. class HTMLMeterElement final : public HTMLElement {
  13. WEB_PLATFORM_OBJECT(HTMLMeterElement, HTMLElement);
  14. JS_DECLARE_ALLOCATOR(HTMLMeterElement);
  15. public:
  16. virtual ~HTMLMeterElement() override;
  17. double value() const;
  18. WebIDL::ExceptionOr<void> set_value(double);
  19. double min() const;
  20. WebIDL::ExceptionOr<void> set_min(double value);
  21. double max() const;
  22. WebIDL::ExceptionOr<void> set_max(double value);
  23. double low() const;
  24. WebIDL::ExceptionOr<void> set_low(double value);
  25. double high() const;
  26. WebIDL::ExceptionOr<void> set_high(double value);
  27. double optimum() const;
  28. WebIDL::ExceptionOr<void> set_optimum(double value);
  29. // ^HTMLElement
  30. virtual void inserted() override;
  31. virtual void removed_from(DOM::Node*) override;
  32. // https://html.spec.whatwg.org/multipage/forms.html#category-label
  33. virtual bool is_labelable() const override { return true; }
  34. // https://www.w3.org/TR/html-aria/#el-meter
  35. virtual Optional<ARIA::Role> default_role() const override { return ARIA::Role::meter; }
  36. private:
  37. HTMLMeterElement(DOM::Document&, DOM::QualifiedName);
  38. virtual void initialize(JS::Realm&) override;
  39. virtual void visit_edges(Cell::Visitor&) override;
  40. void create_shadow_tree_if_needed();
  41. void update_meter_value_element();
  42. JS::GCPtr<DOM::Element> m_meter_value_element;
  43. };
  44. }