HTMLProgressElement.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. * Copyright (c) 2020-2022, the SerenityOS developers.
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <LibWeb/ARIA/Roles.h>
  8. #include <LibWeb/HTML/HTMLElement.h>
  9. namespace Web::HTML {
  10. class HTMLProgressElement final : public HTMLElement {
  11. WEB_PLATFORM_OBJECT(HTMLProgressElement, HTMLElement);
  12. JS_DECLARE_ALLOCATOR(HTMLProgressElement);
  13. public:
  14. virtual ~HTMLProgressElement() override;
  15. virtual JS::GCPtr<Layout::Node> create_layout_node(NonnullRefPtr<CSS::StyleProperties>) 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. // https://html.spec.whatwg.org/multipage/forms.html#category-label
  23. virtual bool is_labelable() const override { return true; }
  24. bool using_system_appearance() const;
  25. // https://www.w3.org/TR/html-aria/#el-progress
  26. virtual Optional<ARIA::Role> default_role() const override { return ARIA::Role::progressbar; }
  27. private:
  28. HTMLProgressElement(DOM::Document&, DOM::QualifiedName);
  29. // ^DOM::Node
  30. virtual bool is_html_progress_element() const final { return true; }
  31. virtual void initialize(JS::Realm&) override;
  32. void progress_position_updated();
  33. bool is_determinate() const { return has_attribute(HTML::AttributeNames::value); }
  34. };
  35. }
  36. namespace Web::DOM {
  37. template<>
  38. inline bool Node::fast_is<HTML::HTMLProgressElement>() const { return is_html_progress_element(); }
  39. }