1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 06:47:34 +00:00

LibWeb: Port Element interface from DeprecatedString

This is the last IDL interface which was using DeprecatedString! :^)
This commit is contained in:
Shannon Booth 2023-10-06 07:43:52 +13:00 committed by Andreas Kling
parent 274e0f4988
commit 4321606bba
12 changed files with 295 additions and 251 deletions

View file

@ -14,10 +14,13 @@ namespace Web::ARIA {
Optional<Role> ARIAMixin::role_or_default() const 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. // 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. // 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. // 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) { 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 // https://www.w3.org/TR/wai-aria-1.2/#global_states
bool ARIAMixin::has_global_aria_attribute() const bool ARIAMixin::has_global_aria_attribute() const
{ {
return !aria_atomic().is_null() return aria_atomic().has_value()
|| !aria_busy().is_null() || aria_busy().has_value()
|| !aria_controls().is_null() || aria_controls().has_value()
|| !aria_current().is_null() || aria_current().has_value()
|| !aria_described_by().is_null() || aria_described_by().has_value()
|| !aria_details().is_null() || aria_details().has_value()
|| !aria_disabled().is_null() || aria_disabled().has_value()
|| !aria_drop_effect().is_null() || aria_drop_effect().has_value()
|| !aria_error_message().is_null() || aria_error_message().has_value()
|| !aria_flow_to().is_null() || aria_flow_to().has_value()
|| !aria_grabbed().is_null() || aria_grabbed().has_value()
|| !aria_has_popup().is_null() || aria_has_popup().has_value()
|| !aria_hidden().is_null() || aria_hidden().has_value()
|| !aria_invalid().is_null() || aria_invalid().has_value()
|| !aria_key_shortcuts().is_null() || aria_key_shortcuts().has_value()
|| !aria_label().is_null() || aria_label().has_value()
|| !aria_labelled_by().is_null() || aria_labelled_by().has_value()
|| !aria_live().is_null() || aria_live().has_value()
|| !aria_owns().is_null() || aria_owns().has_value()
|| !aria_relevant().is_null() || aria_relevant().has_value()
|| !aria_role_description().is_null(); || aria_role_description().has_value();
} }
Optional<DeprecatedString> ARIAMixin::parse_id_reference(DeprecatedString const& id_reference) const Optional<DeprecatedString> ARIAMixin::parse_id_reference(DeprecatedString const& id_reference) const

View file

@ -19,152 +19,152 @@ class ARIAMixin {
public: public:
virtual ~ARIAMixin() = default; virtual ~ARIAMixin() = default;
virtual DeprecatedString role() const = 0; virtual Optional<String> role() const = 0;
virtual WebIDL::ExceptionOr<void> set_role(DeprecatedString const&) = 0; virtual WebIDL::ExceptionOr<void> set_role(Optional<String> const&) = 0;
virtual DeprecatedString aria_active_descendant() const = 0; virtual Optional<String> aria_active_descendant() const = 0;
virtual WebIDL::ExceptionOr<void> set_aria_active_descendant(DeprecatedString const&) = 0; virtual WebIDL::ExceptionOr<void> set_aria_active_descendant(Optional<String> const&) = 0;
virtual DeprecatedString aria_atomic() const = 0; virtual Optional<String> aria_atomic() const = 0;
virtual WebIDL::ExceptionOr<void> set_aria_atomic(DeprecatedString const&) = 0; virtual WebIDL::ExceptionOr<void> set_aria_atomic(Optional<String> const&) = 0;
virtual DeprecatedString aria_auto_complete() const = 0; virtual Optional<String> aria_auto_complete() const = 0;
virtual WebIDL::ExceptionOr<void> set_aria_auto_complete(DeprecatedString const&) = 0; virtual WebIDL::ExceptionOr<void> set_aria_auto_complete(Optional<String> const&) = 0;
virtual DeprecatedString aria_busy() const = 0; virtual Optional<String> aria_busy() const = 0;
virtual WebIDL::ExceptionOr<void> set_aria_busy(DeprecatedString const&) = 0; virtual WebIDL::ExceptionOr<void> set_aria_busy(Optional<String> const&) = 0;
virtual DeprecatedString aria_checked() const = 0; virtual Optional<String> aria_checked() const = 0;
virtual WebIDL::ExceptionOr<void> set_aria_checked(DeprecatedString const&) = 0; virtual WebIDL::ExceptionOr<void> set_aria_checked(Optional<String> const&) = 0;
virtual DeprecatedString aria_col_count() const = 0; virtual Optional<String> aria_col_count() const = 0;
virtual WebIDL::ExceptionOr<void> set_aria_col_count(DeprecatedString const&) = 0; virtual WebIDL::ExceptionOr<void> set_aria_col_count(Optional<String> const&) = 0;
virtual DeprecatedString aria_col_index() const = 0; virtual Optional<String> aria_col_index() const = 0;
virtual WebIDL::ExceptionOr<void> set_aria_col_index(DeprecatedString const&) = 0; virtual WebIDL::ExceptionOr<void> set_aria_col_index(Optional<String> const&) = 0;
virtual DeprecatedString aria_col_span() const = 0; virtual Optional<String> aria_col_span() const = 0;
virtual WebIDL::ExceptionOr<void> set_aria_col_span(DeprecatedString const&) = 0; virtual WebIDL::ExceptionOr<void> set_aria_col_span(Optional<String> const&) = 0;
virtual DeprecatedString aria_controls() const = 0; virtual Optional<String> aria_controls() const = 0;
virtual WebIDL::ExceptionOr<void> set_aria_controls(DeprecatedString const&) = 0; virtual WebIDL::ExceptionOr<void> set_aria_controls(Optional<String> const&) = 0;
virtual DeprecatedString aria_current() const = 0; virtual Optional<String> aria_current() const = 0;
virtual WebIDL::ExceptionOr<void> set_aria_current(DeprecatedString const&) = 0; virtual WebIDL::ExceptionOr<void> set_aria_current(Optional<String> const&) = 0;
virtual DeprecatedString aria_described_by() const = 0; virtual Optional<String> aria_described_by() const = 0;
virtual WebIDL::ExceptionOr<void> set_aria_described_by(DeprecatedString const&) = 0; virtual WebIDL::ExceptionOr<void> set_aria_described_by(Optional<String> const&) = 0;
virtual DeprecatedString aria_details() const = 0; virtual Optional<String> aria_details() const = 0;
virtual WebIDL::ExceptionOr<void> set_aria_details(DeprecatedString const&) = 0; virtual WebIDL::ExceptionOr<void> set_aria_details(Optional<String> const&) = 0;
virtual DeprecatedString aria_disabled() const = 0; virtual Optional<String> aria_disabled() const = 0;
virtual WebIDL::ExceptionOr<void> set_aria_disabled(DeprecatedString const&) = 0; virtual WebIDL::ExceptionOr<void> set_aria_disabled(Optional<String> const&) = 0;
virtual DeprecatedString aria_drop_effect() const = 0; virtual Optional<String> aria_drop_effect() const = 0;
virtual WebIDL::ExceptionOr<void> set_aria_drop_effect(DeprecatedString const&) = 0; virtual WebIDL::ExceptionOr<void> set_aria_drop_effect(Optional<String> const&) = 0;
virtual DeprecatedString aria_error_message() const = 0; virtual Optional<String> aria_error_message() const = 0;
virtual WebIDL::ExceptionOr<void> set_aria_error_message(DeprecatedString const&) = 0; virtual WebIDL::ExceptionOr<void> set_aria_error_message(Optional<String> const&) = 0;
virtual DeprecatedString aria_expanded() const = 0; virtual Optional<String> aria_expanded() const = 0;
virtual WebIDL::ExceptionOr<void> set_aria_expanded(DeprecatedString const&) = 0; virtual WebIDL::ExceptionOr<void> set_aria_expanded(Optional<String> const&) = 0;
virtual DeprecatedString aria_flow_to() const = 0; virtual Optional<String> aria_flow_to() const = 0;
virtual WebIDL::ExceptionOr<void> set_aria_flow_to(DeprecatedString const&) = 0; virtual WebIDL::ExceptionOr<void> set_aria_flow_to(Optional<String> const&) = 0;
virtual DeprecatedString aria_grabbed() const = 0; virtual Optional<String> aria_grabbed() const = 0;
virtual WebIDL::ExceptionOr<void> set_aria_grabbed(DeprecatedString const&) = 0; virtual WebIDL::ExceptionOr<void> set_aria_grabbed(Optional<String> const&) = 0;
virtual DeprecatedString aria_has_popup() const = 0; virtual Optional<String> aria_has_popup() const = 0;
virtual WebIDL::ExceptionOr<void> set_aria_has_popup(DeprecatedString const&) = 0; virtual WebIDL::ExceptionOr<void> set_aria_has_popup(Optional<String> const&) = 0;
virtual DeprecatedString aria_hidden() const = 0; virtual Optional<String> aria_hidden() const = 0;
virtual WebIDL::ExceptionOr<void> set_aria_hidden(DeprecatedString const&) = 0; virtual WebIDL::ExceptionOr<void> set_aria_hidden(Optional<String> const&) = 0;
virtual DeprecatedString aria_invalid() const = 0; virtual Optional<String> aria_invalid() const = 0;
virtual WebIDL::ExceptionOr<void> set_aria_invalid(DeprecatedString const&) = 0; virtual WebIDL::ExceptionOr<void> set_aria_invalid(Optional<String> const&) = 0;
virtual DeprecatedString aria_key_shortcuts() const = 0; virtual Optional<String> aria_key_shortcuts() const = 0;
virtual WebIDL::ExceptionOr<void> set_aria_key_shortcuts(DeprecatedString const&) = 0; virtual WebIDL::ExceptionOr<void> set_aria_key_shortcuts(Optional<String> const&) = 0;
virtual DeprecatedString aria_label() const = 0; virtual Optional<String> aria_label() const = 0;
virtual WebIDL::ExceptionOr<void> set_aria_label(DeprecatedString const&) = 0; virtual WebIDL::ExceptionOr<void> set_aria_label(Optional<String> const&) = 0;
virtual DeprecatedString aria_labelled_by() const = 0; virtual Optional<String> aria_labelled_by() const = 0;
virtual WebIDL::ExceptionOr<void> set_aria_labelled_by(DeprecatedString const&) = 0; virtual WebIDL::ExceptionOr<void> set_aria_labelled_by(Optional<String> const&) = 0;
virtual DeprecatedString aria_level() const = 0; virtual Optional<String> aria_level() const = 0;
virtual WebIDL::ExceptionOr<void> set_aria_level(DeprecatedString const&) = 0; virtual WebIDL::ExceptionOr<void> set_aria_level(Optional<String> const&) = 0;
virtual DeprecatedString aria_live() const = 0; virtual Optional<String> aria_live() const = 0;
virtual WebIDL::ExceptionOr<void> set_aria_live(DeprecatedString const&) = 0; virtual WebIDL::ExceptionOr<void> set_aria_live(Optional<String> const&) = 0;
virtual DeprecatedString aria_modal() const = 0; virtual Optional<String> aria_modal() const = 0;
virtual WebIDL::ExceptionOr<void> set_aria_modal(DeprecatedString const&) = 0; virtual WebIDL::ExceptionOr<void> set_aria_modal(Optional<String> const&) = 0;
virtual DeprecatedString aria_multi_line() const = 0; virtual Optional<String> aria_multi_line() const = 0;
virtual WebIDL::ExceptionOr<void> set_aria_multi_line(DeprecatedString const&) = 0; virtual WebIDL::ExceptionOr<void> set_aria_multi_line(Optional<String> const&) = 0;
virtual DeprecatedString aria_multi_selectable() const = 0; virtual Optional<String> aria_multi_selectable() const = 0;
virtual WebIDL::ExceptionOr<void> set_aria_multi_selectable(DeprecatedString const&) = 0; virtual WebIDL::ExceptionOr<void> set_aria_multi_selectable(Optional<String> const&) = 0;
virtual DeprecatedString aria_orientation() const = 0; virtual Optional<String> aria_orientation() const = 0;
virtual WebIDL::ExceptionOr<void> set_aria_orientation(DeprecatedString const&) = 0; virtual WebIDL::ExceptionOr<void> set_aria_orientation(Optional<String> const&) = 0;
virtual DeprecatedString aria_owns() const = 0; virtual Optional<String> aria_owns() const = 0;
virtual WebIDL::ExceptionOr<void> set_aria_owns(DeprecatedString const&) = 0; virtual WebIDL::ExceptionOr<void> set_aria_owns(Optional<String> const&) = 0;
virtual DeprecatedString aria_placeholder() const = 0; virtual Optional<String> aria_placeholder() const = 0;
virtual WebIDL::ExceptionOr<void> set_aria_placeholder(DeprecatedString const&) = 0; virtual WebIDL::ExceptionOr<void> set_aria_placeholder(Optional<String> const&) = 0;
virtual DeprecatedString aria_pos_in_set() const = 0; virtual Optional<String> aria_pos_in_set() const = 0;
virtual WebIDL::ExceptionOr<void> set_aria_pos_in_set(DeprecatedString const&) = 0; virtual WebIDL::ExceptionOr<void> set_aria_pos_in_set(Optional<String> const&) = 0;
virtual DeprecatedString aria_pressed() const = 0; virtual Optional<String> aria_pressed() const = 0;
virtual WebIDL::ExceptionOr<void> set_aria_pressed(DeprecatedString const&) = 0; virtual WebIDL::ExceptionOr<void> set_aria_pressed(Optional<String> const&) = 0;
virtual DeprecatedString aria_read_only() const = 0; virtual Optional<String> aria_read_only() const = 0;
virtual WebIDL::ExceptionOr<void> set_aria_read_only(DeprecatedString const&) = 0; virtual WebIDL::ExceptionOr<void> set_aria_read_only(Optional<String> const&) = 0;
virtual DeprecatedString aria_relevant() const = 0; virtual Optional<String> aria_relevant() const = 0;
virtual WebIDL::ExceptionOr<void> set_aria_relevant(DeprecatedString const&) = 0; virtual WebIDL::ExceptionOr<void> set_aria_relevant(Optional<String> const&) = 0;
virtual DeprecatedString aria_required() const = 0; virtual Optional<String> aria_required() const = 0;
virtual WebIDL::ExceptionOr<void> set_aria_required(DeprecatedString const&) = 0; virtual WebIDL::ExceptionOr<void> set_aria_required(Optional<String> const&) = 0;
virtual DeprecatedString aria_role_description() const = 0; virtual Optional<String> aria_role_description() const = 0;
virtual WebIDL::ExceptionOr<void> set_aria_role_description(DeprecatedString const&) = 0; virtual WebIDL::ExceptionOr<void> set_aria_role_description(Optional<String> const&) = 0;
virtual DeprecatedString aria_row_count() const = 0; virtual Optional<String> aria_row_count() const = 0;
virtual WebIDL::ExceptionOr<void> set_aria_row_count(DeprecatedString const&) = 0; virtual WebIDL::ExceptionOr<void> set_aria_row_count(Optional<String> const&) = 0;
virtual DeprecatedString aria_row_index() const = 0; virtual Optional<String> aria_row_index() const = 0;
virtual WebIDL::ExceptionOr<void> set_aria_row_index(DeprecatedString const&) = 0; virtual WebIDL::ExceptionOr<void> set_aria_row_index(Optional<String> const&) = 0;
virtual DeprecatedString aria_row_span() const = 0; virtual Optional<String> aria_row_span() const = 0;
virtual WebIDL::ExceptionOr<void> set_aria_row_span(DeprecatedString const&) = 0; virtual WebIDL::ExceptionOr<void> set_aria_row_span(Optional<String> const&) = 0;
virtual DeprecatedString aria_selected() const = 0; virtual Optional<String> aria_selected() const = 0;
virtual WebIDL::ExceptionOr<void> set_aria_selected(DeprecatedString const&) = 0; virtual WebIDL::ExceptionOr<void> set_aria_selected(Optional<String> const&) = 0;
virtual DeprecatedString aria_set_size() const = 0; virtual Optional<String> aria_set_size() const = 0;
virtual WebIDL::ExceptionOr<void> set_aria_set_size(DeprecatedString const&) = 0; virtual WebIDL::ExceptionOr<void> set_aria_set_size(Optional<String> const&) = 0;
virtual DeprecatedString aria_sort() const = 0; virtual Optional<String> aria_sort() const = 0;
virtual WebIDL::ExceptionOr<void> set_aria_sort(DeprecatedString const&) = 0; virtual WebIDL::ExceptionOr<void> set_aria_sort(Optional<String> const&) = 0;
virtual DeprecatedString aria_value_max() const = 0; virtual Optional<String> aria_value_max() const = 0;
virtual WebIDL::ExceptionOr<void> set_aria_value_max(DeprecatedString const&) = 0; virtual WebIDL::ExceptionOr<void> set_aria_value_max(Optional<String> const&) = 0;
virtual DeprecatedString aria_value_min() const = 0; virtual Optional<String> aria_value_min() const = 0;
virtual WebIDL::ExceptionOr<void> set_aria_value_min(DeprecatedString const&) = 0; virtual WebIDL::ExceptionOr<void> set_aria_value_min(Optional<String> const&) = 0;
virtual DeprecatedString aria_value_now() const = 0; virtual Optional<String> aria_value_now() const = 0;
virtual WebIDL::ExceptionOr<void> set_aria_value_now(DeprecatedString const&) = 0; virtual WebIDL::ExceptionOr<void> set_aria_value_now(Optional<String> const&) = 0;
virtual DeprecatedString aria_value_text() const = 0; virtual Optional<String> aria_value_text() const = 0;
virtual WebIDL::ExceptionOr<void> set_aria_value_text(DeprecatedString const&) = 0; virtual WebIDL::ExceptionOr<void> set_aria_value_text(Optional<String> const&) = 0;
// https://www.w3.org/TR/html-aria/#docconformance // https://www.w3.org/TR/html-aria/#docconformance
virtual Optional<Role> default_role() const { return {}; } virtual Optional<Role> default_role() const { return {}; }

View file

@ -9,9 +9,16 @@
namespace Web::ARIA { 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) 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_atomic = AriaData::parse_optional_true_false(source.aria_atomic());
m_aria_auto_complete = AriaData::parse_aria_autocomplete(source.aria_auto_complete()); m_aria_auto_complete = AriaData::parse_aria_autocomplete(source.aria_auto_complete());
m_aria_busy = AriaData::parse_true_false(source.aria_busy()); 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_count = AriaData::parse_integer(source.aria_col_count());
m_aria_col_index = AriaData::parse_integer(source.aria_col_index()); m_aria_col_index = AriaData::parse_integer(source.aria_col_index());
m_aria_col_span = AriaData::parse_integer(source.aria_col_span()); 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_current = AriaData::parse_aria_current(source.aria_current());
m_aria_described_by = source.parse_id_reference_list(source.aria_described_by()); m_aria_described_by = source.parse_id_reference_list(to_deprecated_string(source.aria_described_by()));
m_aria_details = source.parse_id_reference(source.aria_details()); 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_disabled = AriaData::parse_true_false(source.aria_disabled());
m_aria_drop_effect = AriaData::parse_aria_drop_effect(source.aria_drop_effect()); 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_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_grabbed = AriaData::parse_true_false_undefined(source.aria_grabbed());
m_aria_has_popup = AriaData::parse_aria_has_popup(source.aria_has_popup()); 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_hidden = AriaData::parse_true_false_undefined(source.aria_hidden());
m_aria_invalid = AriaData::parse_aria_invalid(source.aria_invalid()); m_aria_invalid = AriaData::parse_aria_invalid(source.aria_invalid());
m_aria_key_shortcuts = source.aria_key_shortcuts(); m_aria_key_shortcuts = to_deprecated_string(source.aria_key_shortcuts());
m_aria_label = source.aria_label(); m_aria_label = to_deprecated_string(source.aria_label());
m_aria_labelled_by = source.parse_id_reference_list(source.aria_labelled_by()); 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_level = AriaData::parse_integer(source.aria_level());
m_aria_live = AriaData::parse_aria_live(source.aria_live()); m_aria_live = AriaData::parse_aria_live(source.aria_live());
m_aria_modal = AriaData::parse_true_false(source.aria_modal()); 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_line = AriaData::parse_true_false(source.aria_multi_line());
m_aria_multi_selectable = AriaData::parse_true_false(source.aria_multi_selectable()); m_aria_multi_selectable = AriaData::parse_true_false(source.aria_multi_selectable());
m_aria_orientation = AriaData::parse_aria_orientation(source.aria_orientation()); m_aria_orientation = AriaData::parse_aria_orientation(source.aria_orientation());
m_aria_owns = source.parse_id_reference_list(source.aria_owns()); m_aria_owns = source.parse_id_reference_list(to_deprecated_string(source.aria_owns()));
m_aria_placeholder = source.aria_placeholder(); m_aria_placeholder = to_deprecated_string(source.aria_placeholder());
m_aria_pos_in_set = AriaData::parse_integer(source.aria_pos_in_set()); m_aria_pos_in_set = AriaData::parse_integer(source.aria_pos_in_set());
m_aria_pressed = AriaData::parse_tristate(source.aria_pressed()); m_aria_pressed = AriaData::parse_tristate(source.aria_pressed());
m_aria_read_only = AriaData::parse_true_false(source.aria_read_only()); m_aria_read_only = AriaData::parse_true_false(source.aria_read_only());
m_aria_relevant = AriaData::parse_aria_relevant(source.aria_relevant()); m_aria_relevant = AriaData::parse_aria_relevant(source.aria_relevant());
m_aria_required = AriaData::parse_true_false(source.aria_required()); 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_count = AriaData::parse_integer(source.aria_row_count());
m_aria_row_index = AriaData::parse_integer(source.aria_row_index()); m_aria_row_index = AriaData::parse_integer(source.aria_row_index());
m_aria_row_span = AriaData::parse_integer(source.aria_row_span()); 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_max = AriaData::parse_number(source.aria_value_max());
m_aria_value_min = AriaData::parse_number(source.aria_value_min()); 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_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) if (value == "true"sv)
return true; return true;
@ -70,7 +77,7 @@ bool AriaData::parse_true_false(StringView value)
return false; return false;
} }
Tristate AriaData::parse_tristate(StringView value) Tristate AriaData::parse_tristate(Optional<String> const& value)
{ {
if (value == "true"sv) if (value == "true"sv)
return Tristate::True; return Tristate::True;
@ -83,7 +90,7 @@ Tristate AriaData::parse_tristate(StringView value)
return Tristate::Undefined; 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) if (value == "true"sv)
return true; return true;
@ -94,14 +101,18 @@ Optional<bool> AriaData::parse_true_false_undefined(StringView value)
return {}; 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 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; 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) if (value == "inline"sv)
return AriaAutocomplete::Inline; return AriaAutocomplete::Inline;
@ -374,7 +385,7 @@ AriaAutocomplete AriaData::parse_aria_autocomplete(StringView value)
return AriaAutocomplete::None; return AriaAutocomplete::None;
} }
AriaCurrent AriaData::parse_aria_current(StringView value) AriaCurrent AriaData::parse_aria_current(Optional<String> const& value)
{ {
if (value == "page"sv) if (value == "page"sv)
return AriaCurrent::Page; return AriaCurrent::Page;
@ -393,11 +404,14 @@ AriaCurrent AriaData::parse_aria_current(StringView value)
return AriaCurrent::False; 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; 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) if (token == "copy"sv)
result.append(AriaDropEffect::Copy); result.append(AriaDropEffect::Copy);
else if (token == "execute"sv) else if (token == "execute"sv)
@ -417,7 +431,7 @@ Vector<AriaDropEffect> AriaData::parse_aria_drop_effect(StringView value)
return result; return result;
} }
AriaHasPopup AriaData::parse_aria_has_popup(StringView value) AriaHasPopup AriaData::parse_aria_has_popup(Optional<String> const& value)
{ {
if (value == "false"sv) if (value == "false"sv)
return AriaHasPopup::False; return AriaHasPopup::False;
@ -436,7 +450,7 @@ AriaHasPopup AriaData::parse_aria_has_popup(StringView value)
return AriaHasPopup::False; return AriaHasPopup::False;
} }
AriaInvalid AriaData::parse_aria_invalid(StringView value) AriaInvalid AriaData::parse_aria_invalid(Optional<String> const& value)
{ {
if (value == "grammar"sv) if (value == "grammar"sv)
return AriaInvalid::Grammar; return AriaInvalid::Grammar;
@ -449,7 +463,7 @@ AriaInvalid AriaData::parse_aria_invalid(StringView value)
return AriaInvalid::False; 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) if (value == "assertive"sv)
return AriaLive::Assertive; return AriaLive::Assertive;
@ -460,7 +474,7 @@ Optional<AriaLive> AriaData::parse_aria_live(StringView value)
return {}; return {};
} }
Optional<AriaOrientation> AriaData::parse_aria_orientation(StringView value) Optional<AriaOrientation> AriaData::parse_aria_orientation(Optional<String> const& value)
{ {
if (value == "horizontal"sv) if (value == "horizontal"sv)
return AriaOrientation::Horizontal; return AriaOrientation::Horizontal;
@ -471,10 +485,13 @@ Optional<AriaOrientation> AriaData::parse_aria_orientation(StringView value)
return {}; 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; 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++) { for (size_t i = 0; i < tokens.size(); i++) {
if (tokens[i] == "additions"sv) { if (tokens[i] == "additions"sv) {
if (i + 1 < tokens.size()) { if (i + 1 < tokens.size()) {
@ -504,7 +521,7 @@ Vector<AriaRelevant> AriaData::parse_aria_relevant(StringView value)
return result; return result;
} }
AriaSort AriaData::parse_aria_sort(StringView value) AriaSort AriaData::parse_aria_sort(Optional<String> const& value)
{ {
if (value == "ascending"sv) if (value == "ascending"sv)
return AriaSort::Ascending; return AriaSort::Ascending;
@ -517,7 +534,7 @@ AriaSort AriaData::parse_aria_sort(StringView value)
return AriaSort::None; 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) if (value == "true"sv)
return true; return true;

View file

@ -205,32 +205,32 @@ private:
// https://www.w3.org/TR/wai-aria-1.2/#valuetype_true-false // https://www.w3.org/TR/wai-aria-1.2/#valuetype_true-false
// The default value for this value type is false unless otherwise specified. // 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 // https://www.w3.org/TR/wai-aria-1.2/#valuetype_tristate
// The default value for this value type is undefined unless otherwise specified. // 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 // 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. // 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 // 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 // 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 AriaAutocomplete parse_aria_autocomplete(Optional<String> const&);
static AriaCurrent parse_aria_current(StringView); static AriaCurrent parse_aria_current(Optional<String> const&);
static Vector<AriaDropEffect> parse_aria_drop_effect(StringView); static Vector<AriaDropEffect> parse_aria_drop_effect(Optional<String> const&);
static AriaHasPopup parse_aria_has_popup(StringView); static AriaHasPopup parse_aria_has_popup(Optional<String> const&);
static AriaInvalid parse_aria_invalid(StringView); static AriaInvalid parse_aria_invalid(Optional<String> const&);
static Optional<AriaLive> parse_aria_live(StringView); static Optional<AriaLive> parse_aria_live(Optional<String> const&);
static Optional<AriaOrientation> parse_aria_orientation(StringView); static Optional<AriaOrientation> parse_aria_orientation(Optional<String> const&);
static Vector<AriaRelevant> parse_aria_relevant(StringView); static Vector<AriaRelevant> parse_aria_relevant(Optional<String> const&);
static AriaSort parse_aria_sort(StringView); static AriaSort parse_aria_sort(Optional<String> const&);
static Optional<bool> parse_optional_true_false(StringView); static Optional<bool> parse_optional_true_false(Optional<String> const&);
Optional<DeprecatedString> m_aria_active_descendant; Optional<DeprecatedString> m_aria_active_descendant;
Optional<bool> m_aria_atomic; Optional<bool> m_aria_atomic;

View file

@ -170,7 +170,7 @@ DeprecatedString Element::get_attribute_value(StringView local_name, DeprecatedF
} }
// https://dom.spec.whatwg.org/#dom-element-getattributenode // 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. // The getAttributeNode(qualifiedName) method steps are to return the result of getting an attribute given qualifiedName and this.
return m_attributes->get_attribute(name); 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 // 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. // 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. // 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 {}; return {};
} }
@ -319,18 +323,22 @@ bool Element::has_attribute(StringView name) const
} }
// https://dom.spec.whatwg.org/#dom-element-hasattributens // 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. // 1. If namespace is the empty string, then set it to null.
if (namespace_.is_empty()) if (namespace_view.is_empty())
namespace_ = {}; namespace_view = {};
// 2. Return true if this has an attribute whose namespace is namespace and local name is localName; otherwise false. // 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 // 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. // 1. If qualifiedName does not match the Name production in XML, then throw an "InvalidCharacterError" DOMException.
// FIXME: Proper name validation // 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 // 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 thiss node document, then append this attribute to this, and then return true. // string, and node document is thiss node document, then append this attribute to this, and then return true.
if (!force.has_value() || force.value()) { 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); m_attributes->append_attribute(new_attribute);
return true; return true;
@ -370,13 +378,13 @@ WebIDL::ExceptionOr<bool> Element::toggle_attribute(DeprecatedFlyString const& n
} }
// https://dom.spec.whatwg.org/#dom-element-getattributenames // 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 thiss attribute list, in order; otherwise a new list. // The getAttributeNames() method steps are to return the qualified names of the attributes in thiss attribute list, in order; otherwise a new list.
Vector<DeprecatedString> names; Vector<String> names;
for (size_t i = 0; i < m_attributes->length(); ++i) { for (size_t i = 0; i < m_attributes->length(); ++i) {
auto const* attribute = m_attributes->item(i); auto const* attribute = m_attributes->item(i);
names.append(attribute->name().to_deprecated_fly_string()); names.append(attribute->name().to_string());
} }
return names; return names;
} }
@ -733,9 +741,10 @@ WebIDL::ExceptionOr<void> Element::set_inner_html(StringView markup)
} }
// https://w3c.github.io/DOM-Parsing/#dom-innerhtml-innerhtml // 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 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." // 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) 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 else
m_html_uppercased_qualified_name = qualified_name(); 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 // 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; JS::GCPtr<Node> context;
// 1. Use the first matching item from this list: // 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 // 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. // 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) if (!returned_node)
return JS::GCPtr<Element> { nullptr }; return JS::GCPtr<Element> { nullptr };
return JS::GCPtr<Element> { verify_cast<Element>(*returned_node) }; return JS::GCPtr<Element> { verify_cast<Element>(*returned_node) };
} }
// https://dom.spec.whatwg.org/#dom-element-insertadjacenttext // 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 thiss node document. // 1. Let text be a new Text node whose data is data and node document is thiss 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. // 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. // 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 {}; return {};
} }
@ -1859,9 +1868,9 @@ void Element::setup_custom_element_from_constructor(HTML::CustomElementDefinitio
m_is_value = is_value; 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 void Element::for_each_attribute(Function<void(DeprecatedFlyString const&, DeprecatedString const&)> callback) const

View file

@ -74,30 +74,30 @@ class Element
public: public:
virtual ~Element() override; virtual ~Element() override;
DeprecatedFlyString qualified_name() const { return m_qualified_name.as_string().to_deprecated_fly_string(); } FlyString const& qualified_name() const { return m_qualified_name.as_string(); }
DeprecatedString const& html_uppercased_qualified_name() const { return m_html_uppercased_qualified_name; } 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(); } 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(); } FlyString const& local_name() const { return m_qualified_name.local_name(); }
// NOTE: This is for the JS bindings // NOTE: This is for the JS bindings
FlyString tag_name() const { return MUST(FlyString::from_deprecated_fly_string(html_uppercased_qualified_name())); } FlyString const& tag_name() const { return html_uppercased_qualified_name(); }
DeprecatedString const& deprecated_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(); } Optional<FlyString> const& prefix() const { return m_qualified_name.prefix(); }
DeprecatedFlyString deprecated_prefix() const { return m_qualified_name.deprecated_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_(); } DeprecatedFlyString namespace_() const { return m_qualified_name.deprecated_namespace_(); }
// NOTE: This is for the JS bindings // 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(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; bool has_attributes() const;
// FIXME: This should be taking a 'FlyString 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, DeprecatedString const& value);
WebIDL::ExceptionOr<void> set_attribute(DeprecatedFlyString const& name, Optional<String> 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_ = {}); 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(Attr&);
WebIDL::ExceptionOr<JS::GCPtr<Attr>> set_attribute_node_ns(Attr&); WebIDL::ExceptionOr<JS::GCPtr<Attr>> set_attribute_node_ns(Attr&);
@ -119,12 +125,12 @@ public:
// FIXME: This should take a 'FlyString cosnt&' // FIXME: This should take a 'FlyString cosnt&'
void remove_attribute(StringView name); 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; size_t attribute_list_size() const;
NamedNodeMap const* attributes() const { return m_attributes.ptr(); } 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(); DOMTokenList* class_list();
@ -189,10 +195,10 @@ public:
CSS::CSSStyleDeclaration* style_for_bindings(); 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> 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_focused() const;
bool is_active() const; bool is_active() const;
@ -244,20 +250,20 @@ public:
bool is_actually_disabled() const; bool is_actually_disabled() const;
WebIDL::ExceptionOr<JS::GCPtr<Element>> insert_adjacent_element(DeprecatedString const& where, JS::NonnullGCPtr<Element> element); WebIDL::ExceptionOr<JS::GCPtr<Element>> insert_adjacent_element(String const& where, JS::NonnullGCPtr<Element> element);
WebIDL::ExceptionOr<void> insert_adjacent_text(DeprecatedString const& where, DeprecatedString const& data); WebIDL::ExceptionOr<void> insert_adjacent_text(String const& where, String const& data);
// https://w3c.github.io/csswg-drafts/cssom-view-1/#dom-element-scrollintoview // https://w3c.github.io/csswg-drafts/cssom-view-1/#dom-element-scrollintoview
ErrorOr<void> scroll_into_view(Optional<Variant<bool, ScrollIntoViewOptions>> = {}); ErrorOr<void> scroll_into_view(Optional<Variant<bool, ScrollIntoViewOptions>> = {});
// https://www.w3.org/TR/wai-aria-1.2/#ARIAMixin // https://www.w3.org/TR/wai-aria-1.2/#ARIAMixin
#define ARIA_IMPL(name, attribute) \ #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)); \ TRY(set_attribute(attribute, value)); \
return {}; \ return {}; \
@ -387,7 +393,7 @@ private:
void enqueue_an_element_on_the_appropriate_element_queue(); void enqueue_an_element_on_the_appropriate_element_queue();
QualifiedName m_qualified_name; QualifiedName m_qualified_name;
DeprecatedString m_html_uppercased_qualified_name; FlyString m_html_uppercased_qualified_name;
JS::GCPtr<NamedNodeMap> m_attributes; JS::GCPtr<NamedNodeMap> m_attributes;
Vector<AttributeChangeSteps> m_attribute_change_steps; Vector<AttributeChangeSteps> m_attribute_change_steps;

View file

@ -21,14 +21,14 @@ dictionary ScrollIntoViewOptions : ScrollOptions {
}; };
// https://dom.spec.whatwg.org/#element // https://dom.spec.whatwg.org/#element
[Exposed=Window, UseDeprecatedAKString] [Exposed=Window]
interface Element : Node { interface Element : Node {
readonly attribute DOMString? namespaceURI; readonly attribute DOMString? namespaceURI;
[ImplementedAs=deprecated_prefix] readonly attribute DOMString? prefix; readonly attribute DOMString? prefix;
[ImplementedAs=deprecated_local_name] readonly attribute DOMString localName; readonly attribute DOMString localName;
[ImplementedAs=deprecated_tag_name] readonly attribute DOMString tagName; 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 setAttribute(DOMString qualifiedName, DOMString value);
[CEReactions] undefined setAttributeNS(DOMString? namespace , DOMString qualifiedName , DOMString value); [CEReactions] undefined setAttributeNS(DOMString? namespace , DOMString qualifiedName , DOMString value);
[CEReactions] Attr? setAttributeNode(Attr attr); [CEReactions] Attr? setAttributeNode(Attr attr);

View file

@ -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)); 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 results namespace prefix to prefix. // 10. Set results 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 results is value to null. // 11. Set results is value to null.
element->set_is_value(Optional<String> {}); element->set_is_value(Optional<String> {});

View file

@ -1786,17 +1786,19 @@ ErrorOr<String> Node::name_or_description(NameOrDescription target, Document con
// process its IDREFs in the order they occur: // 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, // - 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: // process its IDREFs in the order they occur:
if ((target == NameOrDescription::Name && Node::first_valid_id(element->aria_labelled_by(), document).has_value()) auto aria_labelled_by = element->aria_labelled_by();
|| (target == NameOrDescription::Description && Node::first_valid_id(element->aria_described_by(), document).has_value())) { 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. // i. Set the accumulated text to the empty string.
total_accumulated_text.clear(); total_accumulated_text.clear();
Vector<StringView> id_list; Vector<StringView> id_list;
if (target == NameOrDescription::Name) { 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 { } 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: // ii. For each IDREF:
for (auto const& id_ref : id_list) { 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(); 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: // 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. // 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. // - 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, // 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"). // 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. // 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. // 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()) { if (!is_element())
HashTable<i32> visited_nodes; return String {};
StringBuilder builder;
auto const* element = static_cast<Element const*>(this); auto const* element = static_cast<Element const*>(this);
auto id_list = element->aria_described_by().split_view(Infra::is_ascii_whitespace); auto described_by = element->aria_described_by();
for (auto const& id : id_list) { if (!described_by.has_value())
if (auto description_element = document.get_element_by_id(id)) { return String {};
auto description = TRY(
description_element->name_or_description(NameOrDescription::Description, document, HashTable<i32> visited_nodes;
visited_nodes)); StringBuilder builder;
if (!description.is_empty()) { auto id_list = described_by->bytes_as_string_view().split_view_if(Infra::is_ascii_whitespace);
if (builder.is_empty()) { for (auto const& id : id_list) {
builder.append(description); if (auto description_element = document.get_element_by_id(id)) {
} else { auto description = TRY(
builder.append(" "sv); description_element->name_or_description(NameOrDescription::Description, document,
builder.append(description); 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) Optional<StringView> Node::first_valid_id(DeprecatedString const& value, Document const& document)

View file

@ -146,20 +146,20 @@ JS::NonnullGCPtr<HTMLCollection> ParentNode::get_elements_by_tag_name(Deprecated
// 2. Otherwise, if roots node document is an HTML document, return a HTMLCollection rooted at root, whose filter matches the following descendant elements: // 2. Otherwise, if roots 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) { 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) { 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. // - Whose namespace is the HTML namespace and whose qualified name is qualifiedName, in ASCII lowercase.
if (element.namespace_() == Namespace::HTML) if (element.namespace_() == Namespace::HTML)
return element.qualified_name() == qualified_name_in_ascii_lowercase; return element.qualified_name() == qualified_name_in_ascii_lowercase;
// - Whose namespace is not the HTML namespace and whose qualified name is qualifiedName. // - 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. // 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 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;
}); });
} }

View file

@ -22,10 +22,10 @@ public:
// https://www.w3.org/TR/html-aria/#el-h1-h6 // https://www.w3.org/TR/html-aria/#el-h1-h6
virtual Optional<ARIA::Role> default_role() const override { return ARIA::Role::heading; } 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 // 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: private:

View file

@ -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. // 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. // 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)) 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 else
tag_name = element.qualified_name(); tag_name = element.qualified_name();