mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-26 01:35:08 +02:00
LibWeb: Add HTMLSelectedContentElement for customizable select
Introduce the HTMLSelectedContentElement and integrate it into <select>, <option> and HTMLParser. See whatwg/html#10548. There are two bugs with WPT tests which causes the third subtest in selectedcontent.html and selectedcontent-mutations.html fail. See whatwg/html#11882, web-platform-tests/wpt#55849.
This commit is contained in:
Notes:
github-actions[bot]
2025-12-12 12:07:51 +00:00
Author: https://github.com/F3n67u Commit: https://github.com/LadybirdBrowser/ladybird/commit/b58fcaeecf8 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/7024 Reviewed-by: https://github.com/AtkinsSJ ✅
43
Libraries/LibWeb/HTML/HTMLSelectedContentElement.h
Normal file
43
Libraries/LibWeb/HTML/HTMLSelectedContentElement.h
Normal file
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright (c) 2025, Feng Yu <f3n67u@outlook.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LibWeb/ARIA/Roles.h>
|
||||
#include <LibWeb/HTML/HTMLElement.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/form-elements.html#the-selectedcontent-element
|
||||
class HTMLSelectedContentElement final : public HTMLElement {
|
||||
WEB_PLATFORM_OBJECT(HTMLSelectedContentElement, HTMLElement);
|
||||
GC_DECLARE_ALLOCATOR(HTMLSelectedContentElement);
|
||||
|
||||
public:
|
||||
virtual ~HTMLSelectedContentElement() override;
|
||||
|
||||
// https://www.w3.org/TR/html-aria/#el-selectedcontent
|
||||
virtual Optional<ARIA::Role> default_role() const override { return ARIA::Role::generic; }
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/form-elements.html#clear-a-selectedcontent
|
||||
void clear_selectedcontent();
|
||||
|
||||
bool disabled() const { return m_disabled; }
|
||||
void set_disabled(bool disabled) { m_disabled = disabled; }
|
||||
|
||||
private:
|
||||
HTMLSelectedContentElement(DOM::Document&, DOM::QualifiedName);
|
||||
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
|
||||
virtual void post_connection() override;
|
||||
virtual void removed_from(DOM::Node* old_parent, DOM::Node& old_root) override;
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/form-elements.html#selectedcontent-disabled
|
||||
bool m_disabled { false };
|
||||
};
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user