1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-14 13:44:58 +00:00
serenity/Userland/Libraries/LibWeb/HTML/HTMLDetailsElement.h
Timothy Flynn 8bb5652835 LibWeb: Implement HTMLDetailsElement's open attribute closer to the spec
The spec now has a "toggle task tracker" to coalesce rapid changes to
this attribute. It also now has an explicit ToggleEvent to encapsulate
the old and new state of the element.

This further handles the attribute being added/removed using a override
of Element::attribute_changed(), rather than being the only element to
instead override Element::set/remove__attribute().
2023-09-13 13:45:47 +02:00

38 lines
1 KiB
C++

/*
* Copyright (c) 2020, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/Optional.h>
#include <LibWeb/ARIA/Roles.h>
#include <LibWeb/HTML/HTMLElement.h>
#include <LibWeb/HTML/ToggleTaskTracker.h>
namespace Web::HTML {
class HTMLDetailsElement final : public HTMLElement {
WEB_PLATFORM_OBJECT(HTMLDetailsElement, HTMLElement);
public:
virtual ~HTMLDetailsElement() override;
// https://www.w3.org/TR/html-aria/#el-details
virtual Optional<ARIA::Role> default_role() const override { return ARIA::Role::group; }
private:
HTMLDetailsElement(DOM::Document&, DOM::QualifiedName);
virtual void initialize(JS::Realm&) override;
virtual void attribute_changed(DeprecatedFlyString const& name, DeprecatedString const& value) override;
void queue_a_details_toggle_event_task(String old_state, String new_state);
// https://html.spec.whatwg.org/multipage/interactive-elements.html#details-toggle-task-tracker
Optional<ToggleTaskTracker> m_details_toggle_task_tracker;
};
}