mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-07 19:57:45 +03:00
LibWeb: Port Element interface from DeprecatedString
This is the last IDL interface which was using DeprecatedString! :^)
This commit is contained in:
parent
274e0f4988
commit
4321606bba
Notes:
sideshowbarker
2024-07-17 02:06:40 +09:00
Author: https://github.com/shannonbooth Commit: https://github.com/SerenityOS/serenity/commit/4321606bba Pull-request: https://github.com/SerenityOS/serenity/pull/21345 Reviewed-by: https://github.com/kennethmyhra ✅
@ -14,10 +14,13 @@ namespace Web::ARIA {
|
||||
Optional<Role> ARIAMixin::role_or_default() const
|
||||
{
|
||||
// 1. Use the rules of the host language to detect that an element has a role attribute and to identify the attribute value string for it.
|
||||
auto role_string = role();
|
||||
auto maybe_role_string = role();
|
||||
if (!maybe_role_string.has_value())
|
||||
return default_role();
|
||||
|
||||
// 2. Separate the attribute value string for that attribute into a sequence of whitespace-free substrings by separating on whitespace.
|
||||
auto role_list = role_string.split_view(Infra::is_ascii_whitespace);
|
||||
auto role_string = maybe_role_string.value();
|
||||
auto role_list = role_string.bytes_as_string_view().split_view_if(Infra::is_ascii_whitespace);
|
||||
|
||||
// 3. Compare the substrings to all the names of the non-abstract WAI-ARIA roles. Case-sensitivity of the comparison inherits from the case-sensitivity of the host language.
|
||||
for (auto const& role_name : role_list) {
|
||||
@ -38,27 +41,27 @@ Optional<Role> ARIAMixin::role_or_default() const
|
||||
// https://www.w3.org/TR/wai-aria-1.2/#global_states
|
||||
bool ARIAMixin::has_global_aria_attribute() const
|
||||
{
|
||||
return !aria_atomic().is_null()
|
||||
|| !aria_busy().is_null()
|
||||
|| !aria_controls().is_null()
|
||||
|| !aria_current().is_null()
|
||||
|| !aria_described_by().is_null()
|
||||
|| !aria_details().is_null()
|
||||
|| !aria_disabled().is_null()
|
||||
|| !aria_drop_effect().is_null()
|
||||
|| !aria_error_message().is_null()
|
||||
|| !aria_flow_to().is_null()
|
||||
|| !aria_grabbed().is_null()
|
||||
|| !aria_has_popup().is_null()
|
||||
|| !aria_hidden().is_null()
|
||||
|| !aria_invalid().is_null()
|
||||
|| !aria_key_shortcuts().is_null()
|
||||
|| !aria_label().is_null()
|
||||
|| !aria_labelled_by().is_null()
|
||||
|| !aria_live().is_null()
|
||||
|| !aria_owns().is_null()
|
||||
|| !aria_relevant().is_null()
|
||||
|| !aria_role_description().is_null();
|
||||
return aria_atomic().has_value()
|
||||
|| aria_busy().has_value()
|
||||
|| aria_controls().has_value()
|
||||
|| aria_current().has_value()
|
||||
|| aria_described_by().has_value()
|
||||
|| aria_details().has_value()
|
||||
|| aria_disabled().has_value()
|
||||
|| aria_drop_effect().has_value()
|
||||
|| aria_error_message().has_value()
|
||||
|| aria_flow_to().has_value()
|
||||
|| aria_grabbed().has_value()
|
||||
|| aria_has_popup().has_value()
|
||||
|| aria_hidden().has_value()
|
||||
|| aria_invalid().has_value()
|
||||
|| aria_key_shortcuts().has_value()
|
||||
|| aria_label().has_value()
|
||||
|| aria_labelled_by().has_value()
|
||||
|| aria_live().has_value()
|
||||
|| aria_owns().has_value()
|
||||
|| aria_relevant().has_value()
|
||||
|| aria_role_description().has_value();
|
||||
}
|
||||
|
||||
Optional<DeprecatedString> ARIAMixin::parse_id_reference(DeprecatedString const& id_reference) const
|
||||
|
@ -19,152 +19,152 @@ class ARIAMixin {
|
||||
public:
|
||||
virtual ~ARIAMixin() = default;
|
||||
|
||||
virtual DeprecatedString role() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_role(DeprecatedString const&) = 0;
|
||||
virtual Optional<String> role() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_role(Optional<String> const&) = 0;
|
||||
|
||||
virtual DeprecatedString aria_active_descendant() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_active_descendant(DeprecatedString const&) = 0;
|
||||
virtual Optional<String> aria_active_descendant() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_active_descendant(Optional<String> const&) = 0;
|
||||
|
||||
virtual DeprecatedString aria_atomic() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_atomic(DeprecatedString const&) = 0;
|
||||
virtual Optional<String> aria_atomic() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_atomic(Optional<String> const&) = 0;
|
||||
|
||||
virtual DeprecatedString aria_auto_complete() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_auto_complete(DeprecatedString const&) = 0;
|
||||
virtual Optional<String> aria_auto_complete() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_auto_complete(Optional<String> const&) = 0;
|
||||
|
||||
virtual DeprecatedString aria_busy() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_busy(DeprecatedString const&) = 0;
|
||||
virtual Optional<String> aria_busy() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_busy(Optional<String> const&) = 0;
|
||||
|
||||
virtual DeprecatedString aria_checked() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_checked(DeprecatedString const&) = 0;
|
||||
virtual Optional<String> aria_checked() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_checked(Optional<String> const&) = 0;
|
||||
|
||||
virtual DeprecatedString aria_col_count() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_col_count(DeprecatedString const&) = 0;
|
||||
virtual Optional<String> aria_col_count() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_col_count(Optional<String> const&) = 0;
|
||||
|
||||
virtual DeprecatedString aria_col_index() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_col_index(DeprecatedString const&) = 0;
|
||||
virtual Optional<String> aria_col_index() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_col_index(Optional<String> const&) = 0;
|
||||
|
||||
virtual DeprecatedString aria_col_span() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_col_span(DeprecatedString const&) = 0;
|
||||
virtual Optional<String> aria_col_span() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_col_span(Optional<String> const&) = 0;
|
||||
|
||||
virtual DeprecatedString aria_controls() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_controls(DeprecatedString const&) = 0;
|
||||
virtual Optional<String> aria_controls() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_controls(Optional<String> const&) = 0;
|
||||
|
||||
virtual DeprecatedString aria_current() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_current(DeprecatedString const&) = 0;
|
||||
virtual Optional<String> aria_current() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_current(Optional<String> const&) = 0;
|
||||
|
||||
virtual DeprecatedString aria_described_by() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_described_by(DeprecatedString const&) = 0;
|
||||
virtual Optional<String> aria_described_by() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_described_by(Optional<String> const&) = 0;
|
||||
|
||||
virtual DeprecatedString aria_details() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_details(DeprecatedString const&) = 0;
|
||||
virtual Optional<String> aria_details() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_details(Optional<String> const&) = 0;
|
||||
|
||||
virtual DeprecatedString aria_disabled() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_disabled(DeprecatedString const&) = 0;
|
||||
virtual Optional<String> aria_disabled() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_disabled(Optional<String> const&) = 0;
|
||||
|
||||
virtual DeprecatedString aria_drop_effect() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_drop_effect(DeprecatedString const&) = 0;
|
||||
virtual Optional<String> aria_drop_effect() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_drop_effect(Optional<String> const&) = 0;
|
||||
|
||||
virtual DeprecatedString aria_error_message() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_error_message(DeprecatedString const&) = 0;
|
||||
virtual Optional<String> aria_error_message() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_error_message(Optional<String> const&) = 0;
|
||||
|
||||
virtual DeprecatedString aria_expanded() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_expanded(DeprecatedString const&) = 0;
|
||||
virtual Optional<String> aria_expanded() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_expanded(Optional<String> const&) = 0;
|
||||
|
||||
virtual DeprecatedString aria_flow_to() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_flow_to(DeprecatedString const&) = 0;
|
||||
virtual Optional<String> aria_flow_to() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_flow_to(Optional<String> const&) = 0;
|
||||
|
||||
virtual DeprecatedString aria_grabbed() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_grabbed(DeprecatedString const&) = 0;
|
||||
virtual Optional<String> aria_grabbed() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_grabbed(Optional<String> const&) = 0;
|
||||
|
||||
virtual DeprecatedString aria_has_popup() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_has_popup(DeprecatedString const&) = 0;
|
||||
virtual Optional<String> aria_has_popup() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_has_popup(Optional<String> const&) = 0;
|
||||
|
||||
virtual DeprecatedString aria_hidden() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_hidden(DeprecatedString const&) = 0;
|
||||
virtual Optional<String> aria_hidden() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_hidden(Optional<String> const&) = 0;
|
||||
|
||||
virtual DeprecatedString aria_invalid() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_invalid(DeprecatedString const&) = 0;
|
||||
virtual Optional<String> aria_invalid() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_invalid(Optional<String> const&) = 0;
|
||||
|
||||
virtual DeprecatedString aria_key_shortcuts() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_key_shortcuts(DeprecatedString const&) = 0;
|
||||
virtual Optional<String> aria_key_shortcuts() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_key_shortcuts(Optional<String> const&) = 0;
|
||||
|
||||
virtual DeprecatedString aria_label() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_label(DeprecatedString const&) = 0;
|
||||
virtual Optional<String> aria_label() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_label(Optional<String> const&) = 0;
|
||||
|
||||
virtual DeprecatedString aria_labelled_by() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_labelled_by(DeprecatedString const&) = 0;
|
||||
virtual Optional<String> aria_labelled_by() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_labelled_by(Optional<String> const&) = 0;
|
||||
|
||||
virtual DeprecatedString aria_level() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_level(DeprecatedString const&) = 0;
|
||||
virtual Optional<String> aria_level() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_level(Optional<String> const&) = 0;
|
||||
|
||||
virtual DeprecatedString aria_live() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_live(DeprecatedString const&) = 0;
|
||||
virtual Optional<String> aria_live() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_live(Optional<String> const&) = 0;
|
||||
|
||||
virtual DeprecatedString aria_modal() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_modal(DeprecatedString const&) = 0;
|
||||
virtual Optional<String> aria_modal() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_modal(Optional<String> const&) = 0;
|
||||
|
||||
virtual DeprecatedString aria_multi_line() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_multi_line(DeprecatedString const&) = 0;
|
||||
virtual Optional<String> aria_multi_line() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_multi_line(Optional<String> const&) = 0;
|
||||
|
||||
virtual DeprecatedString aria_multi_selectable() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_multi_selectable(DeprecatedString const&) = 0;
|
||||
virtual Optional<String> aria_multi_selectable() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_multi_selectable(Optional<String> const&) = 0;
|
||||
|
||||
virtual DeprecatedString aria_orientation() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_orientation(DeprecatedString const&) = 0;
|
||||
virtual Optional<String> aria_orientation() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_orientation(Optional<String> const&) = 0;
|
||||
|
||||
virtual DeprecatedString aria_owns() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_owns(DeprecatedString const&) = 0;
|
||||
virtual Optional<String> aria_owns() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_owns(Optional<String> const&) = 0;
|
||||
|
||||
virtual DeprecatedString aria_placeholder() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_placeholder(DeprecatedString const&) = 0;
|
||||
virtual Optional<String> aria_placeholder() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_placeholder(Optional<String> const&) = 0;
|
||||
|
||||
virtual DeprecatedString aria_pos_in_set() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_pos_in_set(DeprecatedString const&) = 0;
|
||||
virtual Optional<String> aria_pos_in_set() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_pos_in_set(Optional<String> const&) = 0;
|
||||
|
||||
virtual DeprecatedString aria_pressed() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_pressed(DeprecatedString const&) = 0;
|
||||
virtual Optional<String> aria_pressed() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_pressed(Optional<String> const&) = 0;
|
||||
|
||||
virtual DeprecatedString aria_read_only() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_read_only(DeprecatedString const&) = 0;
|
||||
virtual Optional<String> aria_read_only() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_read_only(Optional<String> const&) = 0;
|
||||
|
||||
virtual DeprecatedString aria_relevant() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_relevant(DeprecatedString const&) = 0;
|
||||
virtual Optional<String> aria_relevant() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_relevant(Optional<String> const&) = 0;
|
||||
|
||||
virtual DeprecatedString aria_required() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_required(DeprecatedString const&) = 0;
|
||||
virtual Optional<String> aria_required() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_required(Optional<String> const&) = 0;
|
||||
|
||||
virtual DeprecatedString aria_role_description() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_role_description(DeprecatedString const&) = 0;
|
||||
virtual Optional<String> aria_role_description() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_role_description(Optional<String> const&) = 0;
|
||||
|
||||
virtual DeprecatedString aria_row_count() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_row_count(DeprecatedString const&) = 0;
|
||||
virtual Optional<String> aria_row_count() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_row_count(Optional<String> const&) = 0;
|
||||
|
||||
virtual DeprecatedString aria_row_index() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_row_index(DeprecatedString const&) = 0;
|
||||
virtual Optional<String> aria_row_index() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_row_index(Optional<String> const&) = 0;
|
||||
|
||||
virtual DeprecatedString aria_row_span() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_row_span(DeprecatedString const&) = 0;
|
||||
virtual Optional<String> aria_row_span() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_row_span(Optional<String> const&) = 0;
|
||||
|
||||
virtual DeprecatedString aria_selected() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_selected(DeprecatedString const&) = 0;
|
||||
virtual Optional<String> aria_selected() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_selected(Optional<String> const&) = 0;
|
||||
|
||||
virtual DeprecatedString aria_set_size() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_set_size(DeprecatedString const&) = 0;
|
||||
virtual Optional<String> aria_set_size() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_set_size(Optional<String> const&) = 0;
|
||||
|
||||
virtual DeprecatedString aria_sort() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_sort(DeprecatedString const&) = 0;
|
||||
virtual Optional<String> aria_sort() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_sort(Optional<String> const&) = 0;
|
||||
|
||||
virtual DeprecatedString aria_value_max() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_value_max(DeprecatedString const&) = 0;
|
||||
virtual Optional<String> aria_value_max() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_value_max(Optional<String> const&) = 0;
|
||||
|
||||
virtual DeprecatedString aria_value_min() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_value_min(DeprecatedString const&) = 0;
|
||||
virtual Optional<String> aria_value_min() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_value_min(Optional<String> const&) = 0;
|
||||
|
||||
virtual DeprecatedString aria_value_now() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_value_now(DeprecatedString const&) = 0;
|
||||
virtual Optional<String> aria_value_now() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_value_now(Optional<String> const&) = 0;
|
||||
|
||||
virtual DeprecatedString aria_value_text() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_value_text(DeprecatedString const&) = 0;
|
||||
virtual Optional<String> aria_value_text() const = 0;
|
||||
virtual WebIDL::ExceptionOr<void> set_aria_value_text(Optional<String> const&) = 0;
|
||||
|
||||
// https://www.w3.org/TR/html-aria/#docconformance
|
||||
virtual Optional<Role> default_role() const { return {}; }
|
||||
|
@ -9,9 +9,16 @@
|
||||
|
||||
namespace Web::ARIA {
|
||||
|
||||
static DeprecatedString to_deprecated_string(Optional<String> const& value)
|
||||
{
|
||||
if (!value.has_value())
|
||||
return {};
|
||||
return value->to_deprecated_string();
|
||||
}
|
||||
|
||||
AriaData::AriaData(Web::ARIA::ARIAMixin const& source)
|
||||
{
|
||||
m_aria_active_descendant = source.aria_active_descendant();
|
||||
m_aria_active_descendant = to_deprecated_string(source.aria_active_descendant());
|
||||
m_aria_atomic = AriaData::parse_optional_true_false(source.aria_atomic());
|
||||
m_aria_auto_complete = AriaData::parse_aria_autocomplete(source.aria_auto_complete());
|
||||
m_aria_busy = AriaData::parse_true_false(source.aria_busy());
|
||||
@ -19,36 +26,36 @@ AriaData::AriaData(Web::ARIA::ARIAMixin const& source)
|
||||
m_aria_col_count = AriaData::parse_integer(source.aria_col_count());
|
||||
m_aria_col_index = AriaData::parse_integer(source.aria_col_index());
|
||||
m_aria_col_span = AriaData::parse_integer(source.aria_col_span());
|
||||
m_aria_controls = source.parse_id_reference_list(source.aria_controls());
|
||||
m_aria_controls = source.parse_id_reference_list(to_deprecated_string(source.aria_controls()));
|
||||
m_aria_current = AriaData::parse_aria_current(source.aria_current());
|
||||
m_aria_described_by = source.parse_id_reference_list(source.aria_described_by());
|
||||
m_aria_details = source.parse_id_reference(source.aria_details());
|
||||
m_aria_described_by = source.parse_id_reference_list(to_deprecated_string(source.aria_described_by()));
|
||||
m_aria_details = source.parse_id_reference(to_deprecated_string(source.aria_details()));
|
||||
m_aria_disabled = AriaData::parse_true_false(source.aria_disabled());
|
||||
m_aria_drop_effect = AriaData::parse_aria_drop_effect(source.aria_drop_effect());
|
||||
m_aria_error_message = source.parse_id_reference(source.aria_error_message());
|
||||
m_aria_error_message = source.parse_id_reference(to_deprecated_string(source.aria_error_message()));
|
||||
m_aria_expanded = AriaData::parse_true_false_undefined(source.aria_expanded());
|
||||
m_aria_flow_to = source.parse_id_reference_list(source.aria_flow_to());
|
||||
m_aria_flow_to = source.parse_id_reference_list(to_deprecated_string(source.aria_flow_to()));
|
||||
m_aria_grabbed = AriaData::parse_true_false_undefined(source.aria_grabbed());
|
||||
m_aria_has_popup = AriaData::parse_aria_has_popup(source.aria_has_popup());
|
||||
m_aria_hidden = AriaData::parse_true_false_undefined(source.aria_hidden());
|
||||
m_aria_invalid = AriaData::parse_aria_invalid(source.aria_invalid());
|
||||
m_aria_key_shortcuts = source.aria_key_shortcuts();
|
||||
m_aria_label = source.aria_label();
|
||||
m_aria_labelled_by = source.parse_id_reference_list(source.aria_labelled_by());
|
||||
m_aria_key_shortcuts = to_deprecated_string(source.aria_key_shortcuts());
|
||||
m_aria_label = to_deprecated_string(source.aria_label());
|
||||
m_aria_labelled_by = source.parse_id_reference_list(to_deprecated_string(source.aria_labelled_by()));
|
||||
m_aria_level = AriaData::parse_integer(source.aria_level());
|
||||
m_aria_live = AriaData::parse_aria_live(source.aria_live());
|
||||
m_aria_modal = AriaData::parse_true_false(source.aria_modal());
|
||||
m_aria_multi_line = AriaData::parse_true_false(source.aria_multi_line());
|
||||
m_aria_multi_selectable = AriaData::parse_true_false(source.aria_multi_selectable());
|
||||
m_aria_orientation = AriaData::parse_aria_orientation(source.aria_orientation());
|
||||
m_aria_owns = source.parse_id_reference_list(source.aria_owns());
|
||||
m_aria_placeholder = source.aria_placeholder();
|
||||
m_aria_owns = source.parse_id_reference_list(to_deprecated_string(source.aria_owns()));
|
||||
m_aria_placeholder = to_deprecated_string(source.aria_placeholder());
|
||||
m_aria_pos_in_set = AriaData::parse_integer(source.aria_pos_in_set());
|
||||
m_aria_pressed = AriaData::parse_tristate(source.aria_pressed());
|
||||
m_aria_read_only = AriaData::parse_true_false(source.aria_read_only());
|
||||
m_aria_relevant = AriaData::parse_aria_relevant(source.aria_relevant());
|
||||
m_aria_required = AriaData::parse_true_false(source.aria_required());
|
||||
m_aria_role_description = source.aria_role_description();
|
||||
m_aria_role_description = to_deprecated_string(source.aria_role_description());
|
||||
m_aria_row_count = AriaData::parse_integer(source.aria_row_count());
|
||||
m_aria_row_index = AriaData::parse_integer(source.aria_row_index());
|
||||
m_aria_row_span = AriaData::parse_integer(source.aria_row_span());
|
||||
@ -58,10 +65,10 @@ AriaData::AriaData(Web::ARIA::ARIAMixin const& source)
|
||||
m_aria_value_max = AriaData::parse_number(source.aria_value_max());
|
||||
m_aria_value_min = AriaData::parse_number(source.aria_value_min());
|
||||
m_aria_value_now = AriaData::parse_number(source.aria_value_now());
|
||||
m_aria_value_text = source.aria_value_text();
|
||||
m_aria_value_text = to_deprecated_string(source.aria_value_text());
|
||||
}
|
||||
|
||||
bool AriaData::parse_true_false(StringView value)
|
||||
bool AriaData::parse_true_false(Optional<String> const& value)
|
||||
{
|
||||
if (value == "true"sv)
|
||||
return true;
|
||||
@ -70,7 +77,7 @@ bool AriaData::parse_true_false(StringView value)
|
||||
return false;
|
||||
}
|
||||
|
||||
Tristate AriaData::parse_tristate(StringView value)
|
||||
Tristate AriaData::parse_tristate(Optional<String> const& value)
|
||||
{
|
||||
if (value == "true"sv)
|
||||
return Tristate::True;
|
||||
@ -83,7 +90,7 @@ Tristate AriaData::parse_tristate(StringView value)
|
||||
return Tristate::Undefined;
|
||||
}
|
||||
|
||||
Optional<bool> AriaData::parse_true_false_undefined(StringView value)
|
||||
Optional<bool> AriaData::parse_true_false_undefined(Optional<String> const& value)
|
||||
{
|
||||
if (value == "true"sv)
|
||||
return true;
|
||||
@ -94,14 +101,18 @@ Optional<bool> AriaData::parse_true_false_undefined(StringView value)
|
||||
return {};
|
||||
}
|
||||
|
||||
Optional<i32> AriaData::parse_integer(StringView value)
|
||||
Optional<i32> AriaData::parse_integer(Optional<String> const& value)
|
||||
{
|
||||
return value.to_int();
|
||||
if (!value.has_value())
|
||||
return {};
|
||||
return value->bytes_as_string_view().to_int();
|
||||
}
|
||||
|
||||
Optional<f64> AriaData::parse_number(StringView value)
|
||||
Optional<f64> AriaData::parse_number(Optional<String> const& value)
|
||||
{
|
||||
return value.to_double(TrimWhitespace::Yes);
|
||||
if (!value.has_value())
|
||||
return {};
|
||||
return value->bytes_as_string_view().to_double(TrimWhitespace::Yes);
|
||||
}
|
||||
|
||||
Optional<DeprecatedString> AriaData::aria_active_descendant_or_default() const
|
||||
@ -361,7 +372,7 @@ DeprecatedString AriaData::aria_value_text_or_default() const
|
||||
return m_aria_value_text;
|
||||
}
|
||||
|
||||
AriaAutocomplete AriaData::parse_aria_autocomplete(StringView value)
|
||||
AriaAutocomplete AriaData::parse_aria_autocomplete(Optional<String> const& value)
|
||||
{
|
||||
if (value == "inline"sv)
|
||||
return AriaAutocomplete::Inline;
|
||||
@ -374,7 +385,7 @@ AriaAutocomplete AriaData::parse_aria_autocomplete(StringView value)
|
||||
return AriaAutocomplete::None;
|
||||
}
|
||||
|
||||
AriaCurrent AriaData::parse_aria_current(StringView value)
|
||||
AriaCurrent AriaData::parse_aria_current(Optional<String> const& value)
|
||||
{
|
||||
if (value == "page"sv)
|
||||
return AriaCurrent::Page;
|
||||
@ -393,11 +404,14 @@ AriaCurrent AriaData::parse_aria_current(StringView value)
|
||||
return AriaCurrent::False;
|
||||
}
|
||||
|
||||
Vector<AriaDropEffect> AriaData::parse_aria_drop_effect(StringView value)
|
||||
Vector<AriaDropEffect> AriaData::parse_aria_drop_effect(Optional<String> const& value)
|
||||
{
|
||||
if (!value.has_value())
|
||||
return {};
|
||||
|
||||
Vector<AriaDropEffect> result;
|
||||
|
||||
for (auto token : value.split_view_if(Infra::is_ascii_whitespace)) {
|
||||
for (auto token : value->bytes_as_string_view().split_view_if(Infra::is_ascii_whitespace)) {
|
||||
if (token == "copy"sv)
|
||||
result.append(AriaDropEffect::Copy);
|
||||
else if (token == "execute"sv)
|
||||
@ -417,7 +431,7 @@ Vector<AriaDropEffect> AriaData::parse_aria_drop_effect(StringView value)
|
||||
return result;
|
||||
}
|
||||
|
||||
AriaHasPopup AriaData::parse_aria_has_popup(StringView value)
|
||||
AriaHasPopup AriaData::parse_aria_has_popup(Optional<String> const& value)
|
||||
{
|
||||
if (value == "false"sv)
|
||||
return AriaHasPopup::False;
|
||||
@ -436,7 +450,7 @@ AriaHasPopup AriaData::parse_aria_has_popup(StringView value)
|
||||
return AriaHasPopup::False;
|
||||
}
|
||||
|
||||
AriaInvalid AriaData::parse_aria_invalid(StringView value)
|
||||
AriaInvalid AriaData::parse_aria_invalid(Optional<String> const& value)
|
||||
{
|
||||
if (value == "grammar"sv)
|
||||
return AriaInvalid::Grammar;
|
||||
@ -449,7 +463,7 @@ AriaInvalid AriaData::parse_aria_invalid(StringView value)
|
||||
return AriaInvalid::False;
|
||||
}
|
||||
|
||||
Optional<AriaLive> AriaData::parse_aria_live(StringView value)
|
||||
Optional<AriaLive> AriaData::parse_aria_live(Optional<String> const& value)
|
||||
{
|
||||
if (value == "assertive"sv)
|
||||
return AriaLive::Assertive;
|
||||
@ -460,7 +474,7 @@ Optional<AriaLive> AriaData::parse_aria_live(StringView value)
|
||||
return {};
|
||||
}
|
||||
|
||||
Optional<AriaOrientation> AriaData::parse_aria_orientation(StringView value)
|
||||
Optional<AriaOrientation> AriaData::parse_aria_orientation(Optional<String> const& value)
|
||||
{
|
||||
if (value == "horizontal"sv)
|
||||
return AriaOrientation::Horizontal;
|
||||
@ -471,10 +485,13 @@ Optional<AriaOrientation> AriaData::parse_aria_orientation(StringView value)
|
||||
return {};
|
||||
}
|
||||
|
||||
Vector<AriaRelevant> AriaData::parse_aria_relevant(StringView value)
|
||||
Vector<AriaRelevant> AriaData::parse_aria_relevant(Optional<String> const& value)
|
||||
{
|
||||
if (!value.has_value())
|
||||
return {};
|
||||
|
||||
Vector<AriaRelevant> result;
|
||||
auto tokens = value.split_view_if(Infra::is_ascii_whitespace);
|
||||
auto tokens = value->bytes_as_string_view().split_view_if(Infra::is_ascii_whitespace);
|
||||
for (size_t i = 0; i < tokens.size(); i++) {
|
||||
if (tokens[i] == "additions"sv) {
|
||||
if (i + 1 < tokens.size()) {
|
||||
@ -504,7 +521,7 @@ Vector<AriaRelevant> AriaData::parse_aria_relevant(StringView value)
|
||||
return result;
|
||||
}
|
||||
|
||||
AriaSort AriaData::parse_aria_sort(StringView value)
|
||||
AriaSort AriaData::parse_aria_sort(Optional<String> const& value)
|
||||
{
|
||||
if (value == "ascending"sv)
|
||||
return AriaSort::Ascending;
|
||||
@ -517,7 +534,7 @@ AriaSort AriaData::parse_aria_sort(StringView value)
|
||||
return AriaSort::None;
|
||||
}
|
||||
|
||||
Optional<bool> AriaData::parse_optional_true_false(StringView value)
|
||||
Optional<bool> AriaData::parse_optional_true_false(Optional<String> const& value)
|
||||
{
|
||||
if (value == "true"sv)
|
||||
return true;
|
||||
|
@ -205,32 +205,32 @@ private:
|
||||
|
||||
// https://www.w3.org/TR/wai-aria-1.2/#valuetype_true-false
|
||||
// The default value for this value type is false unless otherwise specified.
|
||||
static bool parse_true_false(StringView);
|
||||
static bool parse_true_false(Optional<String> const&);
|
||||
|
||||
// https://www.w3.org/TR/wai-aria-1.2/#valuetype_tristate
|
||||
// The default value for this value type is undefined unless otherwise specified.
|
||||
static Tristate parse_tristate(StringView);
|
||||
static Tristate parse_tristate(Optional<String> const&);
|
||||
|
||||
// https://www.w3.org/TR/wai-aria-1.2/#valuetype_true-false-undefined
|
||||
// The default value for this value type is undefined unless otherwise specified.
|
||||
static Optional<bool> parse_true_false_undefined(StringView);
|
||||
static Optional<bool> parse_true_false_undefined(Optional<String> const&);
|
||||
|
||||
// https://www.w3.org/TR/wai-aria-1.2/#valuetype_integer
|
||||
static Optional<i32> parse_integer(StringView);
|
||||
static Optional<i32> parse_integer(Optional<String> const&);
|
||||
|
||||
// https://www.w3.org/TR/wai-aria-1.2/#valuetype_number
|
||||
static Optional<f64> parse_number(StringView);
|
||||
static Optional<f64> parse_number(Optional<String> const&);
|
||||
|
||||
static AriaAutocomplete parse_aria_autocomplete(StringView);
|
||||
static AriaCurrent parse_aria_current(StringView);
|
||||
static Vector<AriaDropEffect> parse_aria_drop_effect(StringView);
|
||||
static AriaHasPopup parse_aria_has_popup(StringView);
|
||||
static AriaInvalid parse_aria_invalid(StringView);
|
||||
static Optional<AriaLive> parse_aria_live(StringView);
|
||||
static Optional<AriaOrientation> parse_aria_orientation(StringView);
|
||||
static Vector<AriaRelevant> parse_aria_relevant(StringView);
|
||||
static AriaSort parse_aria_sort(StringView);
|
||||
static Optional<bool> parse_optional_true_false(StringView);
|
||||
static AriaAutocomplete parse_aria_autocomplete(Optional<String> const&);
|
||||
static AriaCurrent parse_aria_current(Optional<String> const&);
|
||||
static Vector<AriaDropEffect> parse_aria_drop_effect(Optional<String> const&);
|
||||
static AriaHasPopup parse_aria_has_popup(Optional<String> const&);
|
||||
static AriaInvalid parse_aria_invalid(Optional<String> const&);
|
||||
static Optional<AriaLive> parse_aria_live(Optional<String> const&);
|
||||
static Optional<AriaOrientation> parse_aria_orientation(Optional<String> const&);
|
||||
static Vector<AriaRelevant> parse_aria_relevant(Optional<String> const&);
|
||||
static AriaSort parse_aria_sort(Optional<String> const&);
|
||||
static Optional<bool> parse_optional_true_false(Optional<String> const&);
|
||||
|
||||
Optional<DeprecatedString> m_aria_active_descendant;
|
||||
Optional<bool> m_aria_atomic;
|
||||
|
@ -170,7 +170,7 @@ DeprecatedString Element::get_attribute_value(StringView local_name, DeprecatedF
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-element-getattributenode
|
||||
JS::GCPtr<Attr> Element::get_attribute_node(DeprecatedFlyString const& name) const
|
||||
JS::GCPtr<Attr> Element::get_attribute_node(FlyString const& name) const
|
||||
{
|
||||
// The getAttributeNode(qualifiedName) method steps are to return the result of getting an attribute given qualifiedName and this.
|
||||
return m_attributes->get_attribute(name);
|
||||
@ -258,13 +258,17 @@ WebIDL::ExceptionOr<QualifiedName> validate_and_extract(JS::Realm& realm, Deprec
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-element-setattributens
|
||||
WebIDL::ExceptionOr<void> Element::set_attribute_ns(DeprecatedFlyString const& namespace_, DeprecatedFlyString const& qualified_name, DeprecatedString const& value)
|
||||
WebIDL::ExceptionOr<void> Element::set_attribute_ns(Optional<String> const& namespace_, FlyString const& qualified_name, FlyString const& value)
|
||||
{
|
||||
DeprecatedFlyString deprecated_namespace;
|
||||
if (namespace_.has_value())
|
||||
deprecated_namespace = namespace_->to_deprecated_string();
|
||||
|
||||
// 1. Let namespace, prefix, and localName be the result of passing namespace and qualifiedName to validate and extract.
|
||||
auto extracted_qualified_name = TRY(validate_and_extract(realm(), namespace_, qualified_name));
|
||||
auto extracted_qualified_name = TRY(validate_and_extract(realm(), deprecated_namespace, qualified_name.to_deprecated_fly_string()));
|
||||
|
||||
// 2. Set an attribute value for this using localName, value, and also prefix and namespace.
|
||||
set_attribute_value(extracted_qualified_name.local_name().to_deprecated_fly_string(), value, extracted_qualified_name.deprecated_prefix(), extracted_qualified_name.deprecated_namespace_());
|
||||
set_attribute_value(extracted_qualified_name.local_name().to_deprecated_fly_string(), value.to_deprecated_fly_string(), extracted_qualified_name.deprecated_prefix(), extracted_qualified_name.deprecated_namespace_());
|
||||
|
||||
return {};
|
||||
}
|
||||
@ -319,18 +323,22 @@ bool Element::has_attribute(StringView name) const
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-element-hasattributens
|
||||
bool Element::has_attribute_ns(StringView namespace_, StringView name) const
|
||||
bool Element::has_attribute_ns(Optional<String> const& namespace_, StringView name) const
|
||||
{
|
||||
StringView namespace_view;
|
||||
if (namespace_.has_value())
|
||||
namespace_view = namespace_->bytes_as_string_view();
|
||||
|
||||
// 1. If namespace is the empty string, then set it to null.
|
||||
if (namespace_.is_empty())
|
||||
namespace_ = {};
|
||||
if (namespace_view.is_empty())
|
||||
namespace_view = {};
|
||||
|
||||
// 2. Return true if this has an attribute whose namespace is namespace and local name is localName; otherwise false.
|
||||
return m_attributes->get_attribute_ns(namespace_, name) != nullptr;
|
||||
return m_attributes->get_attribute_ns(namespace_view, name) != nullptr;
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-element-toggleattribute
|
||||
WebIDL::ExceptionOr<bool> Element::toggle_attribute(DeprecatedFlyString const& name, Optional<bool> force)
|
||||
WebIDL::ExceptionOr<bool> Element::toggle_attribute(FlyString const& name, Optional<bool> force)
|
||||
{
|
||||
// 1. If qualifiedName does not match the Name production in XML, then throw an "InvalidCharacterError" DOMException.
|
||||
// FIXME: Proper name validation
|
||||
@ -349,7 +357,7 @@ WebIDL::ExceptionOr<bool> Element::toggle_attribute(DeprecatedFlyString const& n
|
||||
// 1. If force is not given or is true, create an attribute whose local name is qualifiedName, value is the empty
|
||||
// string, and node document is this’s node document, then append this attribute to this, and then return true.
|
||||
if (!force.has_value() || force.value()) {
|
||||
auto new_attribute = Attr::create(document(), MUST(String::from_deprecated_string(insert_as_lowercase ? name.to_lowercase() : name)), String {});
|
||||
auto new_attribute = Attr::create(document(), insert_as_lowercase ? MUST(Infra::to_ascii_lowercase(name)) : name.to_string(), String {});
|
||||
m_attributes->append_attribute(new_attribute);
|
||||
|
||||
return true;
|
||||
@ -370,13 +378,13 @@ WebIDL::ExceptionOr<bool> Element::toggle_attribute(DeprecatedFlyString const& n
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-element-getattributenames
|
||||
Vector<DeprecatedString> Element::get_attribute_names() const
|
||||
Vector<String> Element::get_attribute_names() const
|
||||
{
|
||||
// The getAttributeNames() method steps are to return the qualified names of the attributes in this’s attribute list, in order; otherwise a new list.
|
||||
Vector<DeprecatedString> names;
|
||||
Vector<String> names;
|
||||
for (size_t i = 0; i < m_attributes->length(); ++i) {
|
||||
auto const* attribute = m_attributes->item(i);
|
||||
names.append(attribute->name().to_deprecated_fly_string());
|
||||
names.append(attribute->name().to_string());
|
||||
}
|
||||
return names;
|
||||
}
|
||||
@ -733,9 +741,10 @@ WebIDL::ExceptionOr<void> Element::set_inner_html(StringView markup)
|
||||
}
|
||||
|
||||
// https://w3c.github.io/DOM-Parsing/#dom-innerhtml-innerhtml
|
||||
WebIDL::ExceptionOr<DeprecatedString> Element::inner_html() const
|
||||
WebIDL::ExceptionOr<String> Element::inner_html() const
|
||||
{
|
||||
return serialize_fragment(DOMParsing::RequireWellFormed::Yes);
|
||||
auto inner_html = TRY(serialize_fragment(DOMParsing::RequireWellFormed::Yes));
|
||||
return MUST(String::from_deprecated_string(inner_html));
|
||||
}
|
||||
|
||||
bool Element::is_focused() const
|
||||
@ -805,7 +814,7 @@ void Element::make_html_uppercased_qualified_name()
|
||||
{
|
||||
// This is allowed by the spec: "User agents could optimize qualified name and HTML-uppercased qualified name by storing them in internal slots."
|
||||
if (namespace_() == Namespace::HTML && document().document_type() == Document::Type::HTML)
|
||||
m_html_uppercased_qualified_name = DeprecatedString(qualified_name()).to_uppercase();
|
||||
m_html_uppercased_qualified_name = MUST(Infra::to_ascii_uppercase(qualified_name()));
|
||||
else
|
||||
m_html_uppercased_qualified_name = qualified_name();
|
||||
}
|
||||
@ -1359,7 +1368,7 @@ bool Element::is_actually_disabled() const
|
||||
}
|
||||
|
||||
// https://w3c.github.io/DOM-Parsing/#dom-element-insertadjacenthtml
|
||||
WebIDL::ExceptionOr<void> Element::insert_adjacent_html(DeprecatedString position, DeprecatedString text)
|
||||
WebIDL::ExceptionOr<void> Element::insert_adjacent_html(String const& position, String const& text)
|
||||
{
|
||||
JS::GCPtr<Node> context;
|
||||
// 1. Use the first matching item from this list:
|
||||
@ -1475,24 +1484,24 @@ WebIDL::ExceptionOr<JS::GCPtr<Node>> Element::insert_adjacent(DeprecatedString c
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-element-insertadjacentelement
|
||||
WebIDL::ExceptionOr<JS::GCPtr<Element>> Element::insert_adjacent_element(DeprecatedString const& where, JS::NonnullGCPtr<Element> element)
|
||||
WebIDL::ExceptionOr<JS::GCPtr<Element>> Element::insert_adjacent_element(String const& where, JS::NonnullGCPtr<Element> element)
|
||||
{
|
||||
// The insertAdjacentElement(where, element) method steps are to return the result of running insert adjacent, give this, where, and element.
|
||||
auto returned_node = TRY(insert_adjacent(where, move(element)));
|
||||
auto returned_node = TRY(insert_adjacent(where.to_deprecated_string(), move(element)));
|
||||
if (!returned_node)
|
||||
return JS::GCPtr<Element> { nullptr };
|
||||
return JS::GCPtr<Element> { verify_cast<Element>(*returned_node) };
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-element-insertadjacenttext
|
||||
WebIDL::ExceptionOr<void> Element::insert_adjacent_text(DeprecatedString const& where, DeprecatedString const& data)
|
||||
WebIDL::ExceptionOr<void> Element::insert_adjacent_text(String const& where, String const& data)
|
||||
{
|
||||
// 1. Let text be a new Text node whose data is data and node document is this’s node document.
|
||||
auto text = heap().allocate<DOM::Text>(realm(), document(), MUST(String::from_deprecated_string(data)));
|
||||
auto text = heap().allocate<DOM::Text>(realm(), document(), data);
|
||||
|
||||
// 2. Run insert adjacent, given this, where, and text.
|
||||
// Spec Note: This method returns nothing because it existed before we had a chance to design it.
|
||||
(void)TRY(insert_adjacent(where, text));
|
||||
(void)TRY(insert_adjacent(where.to_deprecated_string(), text));
|
||||
return {};
|
||||
}
|
||||
|
||||
@ -1859,9 +1868,9 @@ void Element::setup_custom_element_from_constructor(HTML::CustomElementDefinitio
|
||||
m_is_value = is_value;
|
||||
}
|
||||
|
||||
void Element::set_prefix(DeprecatedFlyString const& value)
|
||||
void Element::set_prefix(Optional<FlyString> value)
|
||||
{
|
||||
m_qualified_name.set_prefix(MUST(FlyString::from_deprecated_fly_string(value)));
|
||||
m_qualified_name.set_prefix(move(value));
|
||||
}
|
||||
|
||||
void Element::for_each_attribute(Function<void(DeprecatedFlyString const&, DeprecatedString const&)> callback) const
|
||||
|
@ -74,30 +74,30 @@ class Element
|
||||
public:
|
||||
virtual ~Element() override;
|
||||
|
||||
DeprecatedFlyString qualified_name() const { return m_qualified_name.as_string().to_deprecated_fly_string(); }
|
||||
DeprecatedString const& html_uppercased_qualified_name() const { return m_html_uppercased_qualified_name; }
|
||||
FlyString const& qualified_name() const { return m_qualified_name.as_string(); }
|
||||
FlyString const& html_uppercased_qualified_name() const { return m_html_uppercased_qualified_name; }
|
||||
|
||||
virtual FlyString node_name() const final { return MUST(FlyString::from_deprecated_fly_string(html_uppercased_qualified_name())); }
|
||||
virtual FlyString node_name() const final { return html_uppercased_qualified_name(); }
|
||||
DeprecatedFlyString deprecated_local_name() const { return m_qualified_name.local_name().to_deprecated_fly_string(); }
|
||||
FlyString const& local_name() const { return m_qualified_name.local_name(); }
|
||||
|
||||
// NOTE: This is for the JS bindings
|
||||
FlyString tag_name() const { return MUST(FlyString::from_deprecated_fly_string(html_uppercased_qualified_name())); }
|
||||
DeprecatedString const& deprecated_tag_name() const { return html_uppercased_qualified_name(); }
|
||||
FlyString const& tag_name() const { return html_uppercased_qualified_name(); }
|
||||
DeprecatedString deprecated_tag_name() const { return html_uppercased_qualified_name().to_deprecated_fly_string(); }
|
||||
|
||||
Optional<FlyString> const& prefix() const { return m_qualified_name.prefix(); }
|
||||
DeprecatedFlyString deprecated_prefix() const { return m_qualified_name.deprecated_prefix(); }
|
||||
|
||||
void set_prefix(DeprecatedFlyString const& value);
|
||||
void set_prefix(Optional<FlyString> value);
|
||||
|
||||
DeprecatedFlyString namespace_() const { return m_qualified_name.deprecated_namespace_(); }
|
||||
|
||||
// NOTE: This is for the JS bindings
|
||||
DeprecatedFlyString namespace_uri() const { return namespace_(); }
|
||||
Optional<FlyString> const& namespace_uri() const { return m_qualified_name.namespace_(); }
|
||||
|
||||
// FIXME: This should be taking a 'FlyString const&'
|
||||
// FIXME: This should be taking a 'FlyString const&' / 'Optional<FlyString> const&'
|
||||
bool has_attribute(StringView name) const;
|
||||
bool has_attribute_ns(StringView namespace_, StringView name) const;
|
||||
bool has_attribute_ns(Optional<String> const& namespace_, StringView name) const;
|
||||
bool has_attributes() const;
|
||||
|
||||
// FIXME: This should be taking a 'FlyString const&'
|
||||
@ -111,7 +111,13 @@ public:
|
||||
|
||||
WebIDL::ExceptionOr<void> set_attribute(DeprecatedFlyString const& name, DeprecatedString const& value);
|
||||
WebIDL::ExceptionOr<void> set_attribute(DeprecatedFlyString const& name, Optional<String> const& value);
|
||||
WebIDL::ExceptionOr<void> set_attribute_ns(DeprecatedFlyString const& namespace_, DeprecatedFlyString const& qualified_name, DeprecatedString const& value);
|
||||
WebIDL::ExceptionOr<void> set_attribute(FlyString const& name, Optional<String> const& value)
|
||||
{
|
||||
return set_attribute(name.to_deprecated_fly_string(), value);
|
||||
}
|
||||
|
||||
// FIXME: This should be taking an Optional<FlyString>
|
||||
WebIDL::ExceptionOr<void> set_attribute_ns(Optional<String> const& namespace_, FlyString const& qualified_name, FlyString const& value);
|
||||
void set_attribute_value(DeprecatedFlyString const& local_name, DeprecatedString const& value, DeprecatedFlyString const& prefix = {}, DeprecatedFlyString const& namespace_ = {});
|
||||
WebIDL::ExceptionOr<JS::GCPtr<Attr>> set_attribute_node(Attr&);
|
||||
WebIDL::ExceptionOr<JS::GCPtr<Attr>> set_attribute_node_ns(Attr&);
|
||||
@ -119,12 +125,12 @@ public:
|
||||
// FIXME: This should take a 'FlyString cosnt&'
|
||||
void remove_attribute(StringView name);
|
||||
|
||||
WebIDL::ExceptionOr<bool> toggle_attribute(DeprecatedFlyString const& name, Optional<bool> force);
|
||||
WebIDL::ExceptionOr<bool> toggle_attribute(FlyString const& name, Optional<bool> force);
|
||||
size_t attribute_list_size() const;
|
||||
NamedNodeMap const* attributes() const { return m_attributes.ptr(); }
|
||||
Vector<DeprecatedString> get_attribute_names() const;
|
||||
Vector<String> get_attribute_names() const;
|
||||
|
||||
JS::GCPtr<Attr> get_attribute_node(DeprecatedFlyString const& name) const;
|
||||
JS::GCPtr<Attr> get_attribute_node(FlyString const& name) const;
|
||||
|
||||
DOMTokenList* class_list();
|
||||
|
||||
@ -189,10 +195,10 @@ public:
|
||||
|
||||
CSS::CSSStyleDeclaration* style_for_bindings();
|
||||
|
||||
WebIDL::ExceptionOr<DeprecatedString> inner_html() const;
|
||||
WebIDL::ExceptionOr<String> inner_html() const;
|
||||
WebIDL::ExceptionOr<void> set_inner_html(StringView);
|
||||
|
||||
WebIDL::ExceptionOr<void> insert_adjacent_html(DeprecatedString position, DeprecatedString text);
|
||||
WebIDL::ExceptionOr<void> insert_adjacent_html(String const& position, String const& text);
|
||||
|
||||
bool is_focused() const;
|
||||
bool is_active() const;
|
||||
@ -244,20 +250,20 @@ public:
|
||||
|
||||
bool is_actually_disabled() const;
|
||||
|
||||
WebIDL::ExceptionOr<JS::GCPtr<Element>> insert_adjacent_element(DeprecatedString const& where, JS::NonnullGCPtr<Element> element);
|
||||
WebIDL::ExceptionOr<void> insert_adjacent_text(DeprecatedString const& where, DeprecatedString const& data);
|
||||
WebIDL::ExceptionOr<JS::GCPtr<Element>> insert_adjacent_element(String const& where, JS::NonnullGCPtr<Element> element);
|
||||
WebIDL::ExceptionOr<void> insert_adjacent_text(String const& where, String const& data);
|
||||
|
||||
// https://w3c.github.io/csswg-drafts/cssom-view-1/#dom-element-scrollintoview
|
||||
ErrorOr<void> scroll_into_view(Optional<Variant<bool, ScrollIntoViewOptions>> = {});
|
||||
|
||||
// https://www.w3.org/TR/wai-aria-1.2/#ARIAMixin
|
||||
#define ARIA_IMPL(name, attribute) \
|
||||
DeprecatedString name() const override \
|
||||
Optional<String> name() const override \
|
||||
{ \
|
||||
return deprecated_get_attribute(attribute); \
|
||||
return get_attribute(attribute); \
|
||||
} \
|
||||
\
|
||||
WebIDL::ExceptionOr<void> set_##name(DeprecatedString const& value) override \
|
||||
WebIDL::ExceptionOr<void> set_##name(Optional<String> const& value) override \
|
||||
{ \
|
||||
TRY(set_attribute(attribute, value)); \
|
||||
return {}; \
|
||||
@ -387,7 +393,7 @@ private:
|
||||
void enqueue_an_element_on_the_appropriate_element_queue();
|
||||
|
||||
QualifiedName m_qualified_name;
|
||||
DeprecatedString m_html_uppercased_qualified_name;
|
||||
FlyString m_html_uppercased_qualified_name;
|
||||
|
||||
JS::GCPtr<NamedNodeMap> m_attributes;
|
||||
Vector<AttributeChangeSteps> m_attribute_change_steps;
|
||||
|
@ -21,14 +21,14 @@ dictionary ScrollIntoViewOptions : ScrollOptions {
|
||||
};
|
||||
|
||||
// https://dom.spec.whatwg.org/#element
|
||||
[Exposed=Window, UseDeprecatedAKString]
|
||||
[Exposed=Window]
|
||||
interface Element : Node {
|
||||
readonly attribute DOMString? namespaceURI;
|
||||
[ImplementedAs=deprecated_prefix] readonly attribute DOMString? prefix;
|
||||
[ImplementedAs=deprecated_local_name] readonly attribute DOMString localName;
|
||||
[ImplementedAs=deprecated_tag_name] readonly attribute DOMString tagName;
|
||||
readonly attribute DOMString? prefix;
|
||||
readonly attribute DOMString localName;
|
||||
readonly attribute DOMString tagName;
|
||||
|
||||
[ImplementedAs=deprecated_get_attribute] DOMString? getAttribute(DOMString qualifiedName);
|
||||
DOMString? getAttribute(DOMString qualifiedName);
|
||||
[CEReactions] undefined setAttribute(DOMString qualifiedName, DOMString value);
|
||||
[CEReactions] undefined setAttributeNS(DOMString? namespace , DOMString qualifiedName , DOMString value);
|
||||
[CEReactions] Attr? setAttributeNode(Attr attr);
|
||||
|
@ -581,7 +581,10 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Element>> create_element(Document& document
|
||||
return JS::throw_completion(WebIDL::NotSupportedError::create(realm, "Synchronously created custom element must have the same local name that element creation was invoked with"_fly_string));
|
||||
|
||||
// 10. Set result’s namespace prefix to prefix.
|
||||
element->set_prefix(prefix);
|
||||
if (prefix.is_null())
|
||||
element->set_prefix({});
|
||||
else
|
||||
element->set_prefix(MUST(FlyString::from_deprecated_fly_string(prefix)));
|
||||
|
||||
// 11. Set result’s is value to null.
|
||||
element->set_is_value(Optional<String> {});
|
||||
|
@ -1786,17 +1786,19 @@ ErrorOr<String> Node::name_or_description(NameOrDescription target, Document con
|
||||
// process its IDREFs in the order they occur:
|
||||
// - or, if computing a description, and the current node has an aria-describedby attribute that contains at least one valid IDREF, and the current node is not already part of an aria-describedby traversal,
|
||||
// process its IDREFs in the order they occur:
|
||||
if ((target == NameOrDescription::Name && Node::first_valid_id(element->aria_labelled_by(), document).has_value())
|
||||
|| (target == NameOrDescription::Description && Node::first_valid_id(element->aria_described_by(), document).has_value())) {
|
||||
auto aria_labelled_by = element->aria_labelled_by();
|
||||
auto aria_described_by = element->aria_described_by();
|
||||
if ((target == NameOrDescription::Name && aria_labelled_by.has_value() && Node::first_valid_id(aria_labelled_by->to_deprecated_string(), document).has_value())
|
||||
|| (target == NameOrDescription::Description && aria_described_by.has_value() && Node::first_valid_id(aria_described_by->to_deprecated_string(), document).has_value())) {
|
||||
|
||||
// i. Set the accumulated text to the empty string.
|
||||
total_accumulated_text.clear();
|
||||
|
||||
Vector<StringView> id_list;
|
||||
if (target == NameOrDescription::Name) {
|
||||
id_list = element->aria_labelled_by().split_view(Infra::is_ascii_whitespace);
|
||||
id_list = aria_labelled_by->bytes_as_string_view().split_view_if(Infra::is_ascii_whitespace);
|
||||
} else {
|
||||
id_list = element->aria_described_by().split_view(Infra::is_ascii_whitespace);
|
||||
id_list = aria_described_by->bytes_as_string_view().split_view_if(Infra::is_ascii_whitespace);
|
||||
}
|
||||
// ii. For each IDREF:
|
||||
for (auto const& id_ref : id_list) {
|
||||
@ -1817,10 +1819,10 @@ ErrorOr<String> Node::name_or_description(NameOrDescription target, Document con
|
||||
return total_accumulated_text.to_string();
|
||||
}
|
||||
// C. Otherwise, if computing a name, and if the current node has an aria-label attribute whose value is not the empty string, nor, when trimmed of white space, is not the empty string:
|
||||
if (target == NameOrDescription::Name && !element->aria_label().is_empty() && !element->aria_label().trim_whitespace().is_empty()) {
|
||||
if (target == NameOrDescription::Name && element->aria_label().has_value() && !element->aria_label()->is_empty() && !element->aria_label()->bytes_as_string_view().is_whitespace()) {
|
||||
// TODO: - If traversal of the current node is due to recursion and the current node is an embedded control as defined in step 2E, ignore aria-label and skip to rule 2E.
|
||||
// - Otherwise, return the value of aria-label.
|
||||
return String::from_deprecated_string(element->aria_label());
|
||||
return element->aria_label().value();
|
||||
}
|
||||
// TODO: D. Otherwise, if the current node's native markup provides an attribute (e.g. title) or element (e.g. HTML label) that defines a text alternative,
|
||||
// return that alternative in the form of a flat string as defined by the host language, unless the element is marked as presentational (role="presentation" or role="none").
|
||||
@ -1908,29 +1910,33 @@ ErrorOr<String> Node::accessible_description(Document const& document) const
|
||||
{
|
||||
// If aria-describedby is present, user agents MUST compute the accessible description by concatenating the text alternatives for elements referenced by an aria-describedby attribute on the current element.
|
||||
// The text alternatives for the referenced elements are computed using a number of methods, outlined below in the section titled Accessible Name and Description Computation.
|
||||
if (is_element()) {
|
||||
HashTable<i32> visited_nodes;
|
||||
StringBuilder builder;
|
||||
auto const* element = static_cast<Element const*>(this);
|
||||
auto id_list = element->aria_described_by().split_view(Infra::is_ascii_whitespace);
|
||||
for (auto const& id : id_list) {
|
||||
if (auto description_element = document.get_element_by_id(id)) {
|
||||
auto description = TRY(
|
||||
description_element->name_or_description(NameOrDescription::Description, document,
|
||||
visited_nodes));
|
||||
if (!description.is_empty()) {
|
||||
if (builder.is_empty()) {
|
||||
builder.append(description);
|
||||
} else {
|
||||
builder.append(" "sv);
|
||||
builder.append(description);
|
||||
}
|
||||
if (!is_element())
|
||||
return String {};
|
||||
|
||||
auto const* element = static_cast<Element const*>(this);
|
||||
auto described_by = element->aria_described_by();
|
||||
if (!described_by.has_value())
|
||||
return String {};
|
||||
|
||||
HashTable<i32> visited_nodes;
|
||||
StringBuilder builder;
|
||||
auto id_list = described_by->bytes_as_string_view().split_view_if(Infra::is_ascii_whitespace);
|
||||
for (auto const& id : id_list) {
|
||||
if (auto description_element = document.get_element_by_id(id)) {
|
||||
auto description = TRY(
|
||||
description_element->name_or_description(NameOrDescription::Description, document,
|
||||
visited_nodes));
|
||||
if (!description.is_empty()) {
|
||||
if (builder.is_empty()) {
|
||||
builder.append(description);
|
||||
} else {
|
||||
builder.append(" "sv);
|
||||
builder.append(description);
|
||||
}
|
||||
}
|
||||
}
|
||||
return builder.to_string();
|
||||
}
|
||||
return String {};
|
||||
return builder.to_string();
|
||||
}
|
||||
|
||||
Optional<StringView> Node::first_valid_id(DeprecatedString const& value, Document const& document)
|
||||
|
@ -146,20 +146,20 @@ JS::NonnullGCPtr<HTMLCollection> ParentNode::get_elements_by_tag_name(Deprecated
|
||||
|
||||
// 2. Otherwise, if root’s node document is an HTML document, return a HTMLCollection rooted at root, whose filter matches the following descendant elements:
|
||||
if (root().document().document_type() == Document::Type::HTML) {
|
||||
auto qualified_name_in_ascii_lowercase = qualified_name.to_lowercase();
|
||||
auto qualified_name_in_ascii_lowercase = MUST(FlyString::from_deprecated_fly_string(qualified_name.to_lowercase()));
|
||||
return HTMLCollection::create(*this, HTMLCollection::Scope::Descendants, [qualified_name, qualified_name_in_ascii_lowercase](Element const& element) {
|
||||
// - Whose namespace is the HTML namespace and whose qualified name is qualifiedName, in ASCII lowercase.
|
||||
if (element.namespace_() == Namespace::HTML)
|
||||
return element.qualified_name() == qualified_name_in_ascii_lowercase;
|
||||
|
||||
// - Whose namespace is not the HTML namespace and whose qualified name is qualifiedName.
|
||||
return element.qualified_name() == qualified_name;
|
||||
return element.qualified_name().to_deprecated_fly_string() == qualified_name;
|
||||
});
|
||||
}
|
||||
|
||||
// 3. Otherwise, return a HTMLCollection rooted at root, whose filter matches descendant elements whose qualified name is qualifiedName.
|
||||
return HTMLCollection::create(*this, HTMLCollection::Scope::Descendants, [qualified_name](Element const& element) {
|
||||
return element.qualified_name() == qualified_name;
|
||||
return element.qualified_name().to_deprecated_fly_string() == qualified_name;
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -22,10 +22,10 @@ public:
|
||||
// https://www.w3.org/TR/html-aria/#el-h1-h6
|
||||
virtual Optional<ARIA::Role> default_role() const override { return ARIA::Role::heading; }
|
||||
|
||||
virtual DeprecatedString aria_level() const override
|
||||
virtual Optional<String> aria_level() const override
|
||||
{
|
||||
// TODO: aria-level = the number in the element's tag name
|
||||
return deprecated_get_attribute("aria-level"sv);
|
||||
return get_attribute("aria-level"sv);
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -3895,10 +3895,10 @@ DeprecatedString HTMLParser::serialize_html_fragment(DOM::Node const& node)
|
||||
|
||||
// 1. If current node is an element in the HTML namespace, the MathML namespace, or the SVG namespace, then let tagname be current node's local name.
|
||||
// Otherwise, let tagname be current node's qualified name.
|
||||
DeprecatedString tag_name;
|
||||
FlyString tag_name;
|
||||
|
||||
if (element.namespace_().is_one_of(Namespace::HTML, Namespace::MathML, Namespace::SVG))
|
||||
tag_name = element.local_name().to_deprecated_fly_string();
|
||||
tag_name = element.local_name();
|
||||
else
|
||||
tag_name = element.qualified_name();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user