HTMLProgressElement.h 1.7 KB

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