2020-08-01 03:05:43 +01:00
|
|
|
/*
|
2022-02-16 19:12:54 +01:00
|
|
|
* Copyright (c) 2020-2022, the SerenityOS developers.
|
2023-12-05 21:18:15 +01:00
|
|
|
* Copyright (c) 2023, Bastiaan van der Plaat <bastiaan.v.d.plaat@gmail.com>
|
2020-08-01 03:05:43 +01:00
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-08-01 03:05:43 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2023-01-28 22:23:16 +00:00
|
|
|
#include <LibWeb/ARIA/Roles.h>
|
2020-08-01 03:05:43 +01:00
|
|
|
#include <LibWeb/HTML/HTMLElement.h>
|
|
|
|
|
|
|
|
namespace Web::HTML {
|
|
|
|
|
|
|
|
class HTMLProgressElement final : public HTMLElement {
|
2022-08-28 13:42:07 +02:00
|
|
|
WEB_PLATFORM_OBJECT(HTMLProgressElement, HTMLElement);
|
2024-11-15 04:01:23 +13:00
|
|
|
GC_DECLARE_ALLOCATOR(HTMLProgressElement);
|
2020-08-01 03:05:43 +01:00
|
|
|
|
2022-08-28 13:42:07 +02:00
|
|
|
public:
|
2020-08-01 03:05:43 +01:00
|
|
|
virtual ~HTMLProgressElement() override;
|
2022-02-16 19:12:54 +01:00
|
|
|
|
|
|
|
double value() const;
|
2023-05-25 20:37:57 +01:00
|
|
|
WebIDL::ExceptionOr<void> set_value(double);
|
2022-02-16 19:12:54 +01:00
|
|
|
|
2024-11-29 12:25:22 +00:00
|
|
|
WebIDL::Double max() const;
|
|
|
|
WebIDL::ExceptionOr<void> set_max(WebIDL::Double value);
|
2022-02-16 19:12:54 +01:00
|
|
|
|
|
|
|
double position() const;
|
|
|
|
|
2022-03-01 21:03:30 +00:00
|
|
|
// ^HTMLElement
|
2023-12-05 21:18:15 +01:00
|
|
|
virtual void inserted() override;
|
|
|
|
virtual void removed_from(DOM::Node*) override;
|
|
|
|
|
2024-12-20 11:32:17 +01:00
|
|
|
virtual void adjust_computed_style(CSS::ComputedProperties&) override;
|
2024-11-08 20:14:37 +08:00
|
|
|
|
2022-03-01 21:03:30 +00:00
|
|
|
// https://html.spec.whatwg.org/multipage/forms.html#category-label
|
|
|
|
virtual bool is_labelable() const override { return true; }
|
|
|
|
|
2022-11-28 17:58:13 -06:00
|
|
|
// https://www.w3.org/TR/html-aria/#el-progress
|
2023-01-28 22:23:16 +00:00
|
|
|
virtual Optional<ARIA::Role> default_role() const override { return ARIA::Role::progressbar; }
|
2022-11-28 17:58:13 -06:00
|
|
|
|
2022-02-16 19:12:54 +01:00
|
|
|
private:
|
2022-08-28 13:42:07 +02:00
|
|
|
HTMLProgressElement(DOM::Document&, DOM::QualifiedName);
|
|
|
|
|
2023-03-10 21:16:18 +01:00
|
|
|
// ^DOM::Node
|
2023-03-16 23:50:11 +00:00
|
|
|
virtual bool is_html_progress_element() const final { return true; }
|
2024-12-20 16:35:12 +01:00
|
|
|
virtual void computed_properties_changed() override;
|
2023-03-10 21:16:18 +01:00
|
|
|
|
2023-08-07 08:41:28 +02:00
|
|
|
virtual void initialize(JS::Realm&) override;
|
2023-12-05 21:18:15 +01:00
|
|
|
virtual void visit_edges(Cell::Visitor&) override;
|
|
|
|
|
|
|
|
void create_shadow_tree_if_needed();
|
2023-01-10 06:28:20 -05:00
|
|
|
|
2023-12-05 21:18:15 +01:00
|
|
|
void update_progress_value_element();
|
2022-07-22 16:08:03 +01:00
|
|
|
|
2022-02-16 19:12:54 +01:00
|
|
|
bool is_determinate() const { return has_attribute(HTML::AttributeNames::value); }
|
2023-12-05 21:18:15 +01:00
|
|
|
|
2024-11-15 04:01:23 +13:00
|
|
|
GC::Ptr<DOM::Element> m_progress_value_element;
|
2020-08-01 03:05:43 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
2023-03-10 21:16:18 +01:00
|
|
|
|
|
|
|
namespace Web::DOM {
|
|
|
|
template<>
|
|
|
|
inline bool Node::fast_is<HTML::HTMLProgressElement>() const { return is_html_progress_element(); }
|
|
|
|
}
|