dymokomi/luce-browser-engine
Source of release 0.6.1
0.6.1 / src / web / html / autocomplete_element.lucb
#==============================================================================================
#
# autocomplete_element - HTML::AutocompleteElement: the autocomplete attribute and the autofill
# processing model
#
# DESCRIPTION:
# Port of LibWeb/HTML/AutocompleteElement.cpp (lines 1-368) and AutocompleteElement.h: the
# autofill mantle, the attribute's tokens, the autocomplete IDL attribute, determining a
# field's category and the autofill processing model that yields the hint set, scope,
# field name, credential type and IDL-exposed value.
#
# AutocompleteElement is a stateful mixin (input, select, textarea; regions r24 and r25);
# its element is reached through the virtual autocomplete_element_to_html_element. The two
# lambdas of parse_autocomplete_attribute (the steps labeled "default" and "done") are
# functions over the state they capture.
#
#==============================================================================================
# mark: Helpers =================================================================================
## `"text"_string`.
func html_autocomplete_string(text: str) -> ak.String:
return ak.string_from_str(text)
## `MUST(String::formatted("{} {}", first, second))`.
func html_autocomplete_join_with_space(first: ak.String, second: ak.String) -> ak.String:
var builder = ak.string_builder_new()
ak.string_builder_append_string_view(&builder, ak.string_bytes_as_string_view(&first))
ak.string_builder_append_u8(&builder, ' ')
ak.string_builder_append_string_view(&builder, ak.string_bytes_as_string_view(&second))
return ak.string_builder_to_string(&builder) else trap("MUST: String::formatted")
## `string.is_one_of(candidates...)` (String == StringView for each candidate).
func html_autocomplete_string_is_one_of(string: const ak.String*, candidates: const str[]) -> bool:
for candidate in candidates:
if ak.string_eq_string_view(string, ak.sv(candidate)):
return true
return false
## The empty AttributeDetails (`AttributeDetails attr_details {}`).
func html_autocomplete_element_attribute_details_new() -> HtmlAutocompleteElementAttributeDetails:
return HtmlAutocompleteElementAttributeDetails(field_name = ak.string_new(), credential_type = none, value = ak.string_new())
# mark: The autofill mantle and the attribute ===================================================
## Ported from AutocompleteElement.cpp:19 Web::HTML::AutocompleteElement::get_autofill_mantle.
# https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill-expectation-mantle
# https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill-anchor-mantle
pub func html_autocomplete_element_get_autofill_mantle(this: HtmlAutocompleteElement*) -> HtmlAutocompleteElementAutofillMantle:
let element = html_autocomplete_element_autocomplete_element_to_html_element_const(this)
# On an input element whose type attribute is in the Hidden state, the autocomplete attribute wears the autofill anchor mantle.
if is_html_input_element(element):
let input_element = as_html_input_element(element)
if html_input_element_type_state(input_element) == HtmlInputElementTypeAttributeState.hidden:
return HtmlAutocompleteElementAutofillMantle.anchor
# In all other cases, it wears the autofill expectation mantle.
return HtmlAutocompleteElementAutofillMantle.expectation
## Ported from AutocompleteElement.cpp:34 Web::HTML::AutocompleteElement::autocomplete_tokens.
pub func html_autocomplete_element_autocomplete_tokens(this: HtmlAutocompleteElement*) -> ak.Vector[ak.String]:
let autocomplete_value = dom_element_attribute(html_autocomplete_element_autocomplete_element_to_html_element_const(this).dom_element(), html_attribute_names_autocomplete) else ak.string_new()
var autocomplete_tokens: ak.Vector[ak.String]
let view = ak.string_bytes_as_string_view(&autocomplete_value)
let predicate = ak.CharPredicateFunction(function = web_infra.is_ascii_whitespace)
var split_tokens = ak.string_view_split_view_if(&view, &predicate)
for token in ak.vector_span(&split_tokens):
ak.vector_append_t(&autocomplete_tokens, ak.string_from_utf8(token) else trap("MUST: String::from_utf8"))
return autocomplete_tokens
## Ported from AutocompleteElement.cpp:44 Web::HTML::AutocompleteElement::autocomplete.
pub func html_autocomplete_element_autocomplete(this: HtmlAutocompleteElement*) -> ak.String:
# The autocomplete IDL attribute, on getting, must return the element's IDL-exposed autofill value.
let details = html_autocomplete_element_parse_autocomplete_attribute(this)
return details.value
## Ported from AutocompleteElement.cpp:51 Web::HTML::AutocompleteElement::set_autocomplete.
pub func html_autocomplete_element_set_autocomplete(this: HtmlAutocompleteElement*, value: ak.String):
# The autocomplete IDL attribute [...] on setting, must reflect the content attribute of the same name.
dom_element_set_attribute_value(html_autocomplete_element_autocomplete_element_to_html_element(this).dom_element(), html_attribute_names_autocomplete, value)
# mark: Determining a field's category ==========================================================
## One row of the table of determine_a_field_category (the CASE_CATEGORY macro's arguments).
struct HtmlAutocompleteFieldCategoryRow:
var token: str
var maximum_number_of_tokens: u64
var category: HtmlCategory
## The rows of determine_a_field_category, in the C++ order.
let html_autocomplete_field_categories: HtmlAutocompleteFieldCategoryRow[57] = [
HtmlAutocompleteFieldCategoryRow(token = "off", maximum_number_of_tokens = 1, category = HtmlCategory.off),
HtmlAutocompleteFieldCategoryRow(token = "on", maximum_number_of_tokens = 1, category = HtmlCategory.automatic),
HtmlAutocompleteFieldCategoryRow(token = "name", maximum_number_of_tokens = 3, category = HtmlCategory.normal),
HtmlAutocompleteFieldCategoryRow(token = "honorific-prefix", maximum_number_of_tokens = 3, category = HtmlCategory.normal),
HtmlAutocompleteFieldCategoryRow(token = "given-name", maximum_number_of_tokens = 3, category = HtmlCategory.normal),
HtmlAutocompleteFieldCategoryRow(token = "additional-name", maximum_number_of_tokens = 3, category = HtmlCategory.normal),
HtmlAutocompleteFieldCategoryRow(token = "family-name", maximum_number_of_tokens = 3, category = HtmlCategory.normal),
HtmlAutocompleteFieldCategoryRow(token = "honorific-suffix", maximum_number_of_tokens = 3, category = HtmlCategory.normal),
HtmlAutocompleteFieldCategoryRow(token = "nickname", maximum_number_of_tokens = 3, category = HtmlCategory.normal),
HtmlAutocompleteFieldCategoryRow(token = "organization-title", maximum_number_of_tokens = 3, category = HtmlCategory.normal),
HtmlAutocompleteFieldCategoryRow(token = "username", maximum_number_of_tokens = 3, category = HtmlCategory.normal),
HtmlAutocompleteFieldCategoryRow(token = "new-password", maximum_number_of_tokens = 3, category = HtmlCategory.normal),
HtmlAutocompleteFieldCategoryRow(token = "current-password", maximum_number_of_tokens = 3, category = HtmlCategory.normal),
HtmlAutocompleteFieldCategoryRow(token = "one-time-code", maximum_number_of_tokens = 3, category = HtmlCategory.normal),
HtmlAutocompleteFieldCategoryRow(token = "organization", maximum_number_of_tokens = 3, category = HtmlCategory.normal),
HtmlAutocompleteFieldCategoryRow(token = "street-address", maximum_number_of_tokens = 3, category = HtmlCategory.normal),
HtmlAutocompleteFieldCategoryRow(token = "address-line1", maximum_number_of_tokens = 3, category = HtmlCategory.normal),
HtmlAutocompleteFieldCategoryRow(token = "address-line2", maximum_number_of_tokens = 3, category = HtmlCategory.normal),
HtmlAutocompleteFieldCategoryRow(token = "address-line3", maximum_number_of_tokens = 3, category = HtmlCategory.normal),
HtmlAutocompleteFieldCategoryRow(token = "address-level4", maximum_number_of_tokens = 3, category = HtmlCategory.normal),
HtmlAutocompleteFieldCategoryRow(token = "address-level3", maximum_number_of_tokens = 3, category = HtmlCategory.normal),
HtmlAutocompleteFieldCategoryRow(token = "address-level2", maximum_number_of_tokens = 3, category = HtmlCategory.normal),
HtmlAutocompleteFieldCategoryRow(token = "address-level1", maximum_number_of_tokens = 3, category = HtmlCategory.normal),
HtmlAutocompleteFieldCategoryRow(token = "country", maximum_number_of_tokens = 3, category = HtmlCategory.normal),
HtmlAutocompleteFieldCategoryRow(token = "country-name", maximum_number_of_tokens = 3, category = HtmlCategory.normal),
HtmlAutocompleteFieldCategoryRow(token = "postal-code", maximum_number_of_tokens = 3, category = HtmlCategory.normal),
HtmlAutocompleteFieldCategoryRow(token = "cc-name", maximum_number_of_tokens = 3, category = HtmlCategory.normal),
HtmlAutocompleteFieldCategoryRow(token = "cc-given-name", maximum_number_of_tokens = 3, category = HtmlCategory.normal),
HtmlAutocompleteFieldCategoryRow(token = "cc-additional-name", maximum_number_of_tokens = 3, category = HtmlCategory.normal),
HtmlAutocompleteFieldCategoryRow(token = "cc-family-name", maximum_number_of_tokens = 3, category = HtmlCategory.normal),
HtmlAutocompleteFieldCategoryRow(token = "cc-number", maximum_number_of_tokens = 3, category = HtmlCategory.normal),
HtmlAutocompleteFieldCategoryRow(token = "cc-exp", maximum_number_of_tokens = 3, category = HtmlCategory.normal),
HtmlAutocompleteFieldCategoryRow(token = "cc-exp-month", maximum_number_of_tokens = 3, category = HtmlCategory.normal),
HtmlAutocompleteFieldCategoryRow(token = "cc-exp-year", maximum_number_of_tokens = 3, category = HtmlCategory.normal),
HtmlAutocompleteFieldCategoryRow(token = "cc-csc", maximum_number_of_tokens = 3, category = HtmlCategory.normal),
HtmlAutocompleteFieldCategoryRow(token = "cc-type", maximum_number_of_tokens = 3, category = HtmlCategory.normal),
HtmlAutocompleteFieldCategoryRow(token = "transaction-currency", maximum_number_of_tokens = 3, category = HtmlCategory.normal),
HtmlAutocompleteFieldCategoryRow(token = "transaction-amount", maximum_number_of_tokens = 3, category = HtmlCategory.normal),
HtmlAutocompleteFieldCategoryRow(token = "language", maximum_number_of_tokens = 3, category = HtmlCategory.normal),
HtmlAutocompleteFieldCategoryRow(token = "bday", maximum_number_of_tokens = 3, category = HtmlCategory.normal),
HtmlAutocompleteFieldCategoryRow(token = "bday-day", maximum_number_of_tokens = 3, category = HtmlCategory.normal),
HtmlAutocompleteFieldCategoryRow(token = "bday-month", maximum_number_of_tokens = 3, category = HtmlCategory.normal),
HtmlAutocompleteFieldCategoryRow(token = "bday-year", maximum_number_of_tokens = 3, category = HtmlCategory.normal),
HtmlAutocompleteFieldCategoryRow(token = "sex", maximum_number_of_tokens = 3, category = HtmlCategory.normal),
HtmlAutocompleteFieldCategoryRow(token = "url", maximum_number_of_tokens = 3, category = HtmlCategory.normal),
HtmlAutocompleteFieldCategoryRow(token = "photo", maximum_number_of_tokens = 3, category = HtmlCategory.normal),
HtmlAutocompleteFieldCategoryRow(token = "tel", maximum_number_of_tokens = 4, category = HtmlCategory.contact),
HtmlAutocompleteFieldCategoryRow(token = "tel-country-code", maximum_number_of_tokens = 4, category = HtmlCategory.contact),
HtmlAutocompleteFieldCategoryRow(token = "tel-national", maximum_number_of_tokens = 4, category = HtmlCategory.contact),
HtmlAutocompleteFieldCategoryRow(token = "tel-area-code", maximum_number_of_tokens = 4, category = HtmlCategory.contact),
HtmlAutocompleteFieldCategoryRow(token = "tel-local", maximum_number_of_tokens = 4, category = HtmlCategory.contact),
HtmlAutocompleteFieldCategoryRow(token = "tel-local-prefix", maximum_number_of_tokens = 4, category = HtmlCategory.contact),
HtmlAutocompleteFieldCategoryRow(token = "tel-local-suffix", maximum_number_of_tokens = 4, category = HtmlCategory.contact),
HtmlAutocompleteFieldCategoryRow(token = "tel-extension", maximum_number_of_tokens = 4, category = HtmlCategory.contact),
HtmlAutocompleteFieldCategoryRow(token = "email", maximum_number_of_tokens = 4, category = HtmlCategory.contact),
HtmlAutocompleteFieldCategoryRow(token = "impp", maximum_number_of_tokens = 4, category = HtmlCategory.contact),
HtmlAutocompleteFieldCategoryRow(token = "webauthn", maximum_number_of_tokens = 5, category = HtmlCategory.credential),
]
## Ported from AutocompleteElement.cpp:71 Web::HTML::determine_a_field_category.
# https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#determine-a-field's-category
func html_determine_a_field_category(field: ak.StringView) -> HtmlCategoryAndMaximumTokens:
# 1. If the field is not an ASCII case-insensitive match for one of the tokens given
# in the first column of the following table, return the pair (null, null).
# 2. Otherwise, let maximum tokens and category be the values of the cells in the second
# and third columns of that row respectively.
# 3. Return the pair (category, maximum tokens).
for row in html_autocomplete_field_categories:
if ak.string_view_equals_ignoring_ascii_case(&field, ak.sv(row.token)):
return HtmlCategoryAndMaximumTokens(category = row.category, maximum_tokens = row.maximum_number_of_tokens)
return HtmlCategoryAndMaximumTokens(category = none, maximum_tokens = none)
# mark: The autofill processing model ===========================================================
## The step labeled default of parse_autocomplete_attribute (the `step_default` lambda).
func html_autocomplete_element_step_default(this: HtmlAutocompleteElement*, attr_details: HtmlAutocompleteElementAttributeDetails*) -> HtmlAutocompleteElementAttributeDetails:
# 32. Default: Set the element's IDL-exposed autofill value to the empty string, and its autofill hint set and autofill scope to empty.
attr_details.value = ak.string_new()
attr_details.hint_set = ak.Vector[ak.String]()
attr_details.scope = ak.Vector[ak.String]()
# 33. If the element's autocomplete attribute is wearing the autofill anchor mantle,
# then set the element's autofill field name to the empty string and return.
if html_autocomplete_element_get_autofill_mantle(this) == HtmlAutocompleteElementAutofillMantle.anchor:
attr_details.field_name = ak.string_new()
return *attr_details
# 34. Let form be the element's form owner, if any, or null otherwise.
let form_associated_element = as_if_form_associated_element(html_autocomplete_element_autocomplete_element_to_html_element_const(this)) else trap("as<FormAssociatedElement> failed")
let form = html_form_associated_element_form_const(form_associated_element)
# 35. If form is not null and form's autocomplete attribute is in the off state, then set the element's autofill field name to "off".
# (idl_enum_to_string(Bindings::Autocomplete::Off) is "off".)
var form_autocomplete_is_off = false
if let form_element = form:
if let form_autocomplete = dom_element_attribute(form_element.dom_element(), html_attribute_names_autocomplete):
form_autocomplete_is_off = ak.string_eq_string_view(&form_autocomplete, ak.sv("off"))
if form_autocomplete_is_off:
attr_details.field_name = html_autocomplete_string("off")
# Otherwise, set the element's autofill field name to "on".
else:
attr_details.field_name = html_autocomplete_string("on")
return *attr_details
## The step labeled done of parse_autocomplete_attribute (the `step_done` lambda) over the
## state it captures.
func html_autocomplete_element_step_done(attr_details: HtmlAutocompleteElementAttributeDetails*, hint_tokens: const ak.HashTable[ak.String, ak.StringTraits]*, credential_type: ak.String?, scope_tokens: const ak.Vector[ak.String]*, field: ak.String, idl_value: ak.String) -> HtmlAutocompleteElementAttributeDetails:
# 26. Done: Set the element's autofill hint set to hint tokens.
attr_details.hint_set = ak.hash_table_values(hint_tokens)
# 27. Set the element's non-autofill credential type to credential type.
attr_details.credential_type = credential_type
# 28. Set the element's autofill scope to scope tokens.
attr_details.scope = ak.vector_clone(scope_tokens)
# 29. Set the element's autofill field name to field.
attr_details.field_name = field
# 30. Set the element's IDL-exposed autofill value to IDL value.
attr_details.value = idl_value
# 31. Return.
return *attr_details
## Ported from AutocompleteElement.cpp:146 Web::HTML::AutocompleteElement::parse_autocomplete_attribute.
# https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill-processing-model
pub func html_autocomplete_element_parse_autocomplete_attribute(this: HtmlAutocompleteElement*) -> HtmlAutocompleteElementAttributeDetails:
var attr_details = html_autocomplete_element_attribute_details_new()
# 1. If the element has no autocomplete attribute, then jump to the step labeled default.
if not dom_element_has_attribute(html_autocomplete_element_autocomplete_element_to_html_element_const(this).dom_element(), html_attribute_names_autocomplete):
return html_autocomplete_element_step_default(this, &attr_details)
# 2. Let tokens be the result of splitting the attribute's value on ASCII whitespace.
let tokens = html_autocomplete_element_autocomplete_tokens(this)
# 3. If tokens is empty, then jump to the step labeled default.
if ak.vector_is_empty(&tokens):
return html_autocomplete_element_step_default(this, &attr_details)
# 4. Let index be the index of the last token in tokens.
var index = ak.vector_size(&tokens) - 1
# 5. Let field be the indexth token in tokens.
let field = *ak.vector_at_const(&tokens, index)
# 6. Set the category, maximum tokens pair to the result of determining a field's category given field.
let category_and_maximum_tokens = html_determine_a_field_category(ak.string_bytes_as_string_view(&field))
var category = category_and_maximum_tokens.category
var maximum_tokens = category_and_maximum_tokens.maximum_tokens
# 7. If category is null, then jump to the step labeled default.
if category == none:
return html_autocomplete_element_step_default(this, &attr_details)
# 8. If the number of tokens in tokens is greater than maximum tokens, then jump to the step labeled default.
if (u64)ak.vector_size(&tokens) > (maximum_tokens else trap("maximum tokens is null")):
return html_autocomplete_element_step_default(this, &attr_details)
# 9. If category is Off or Automatic but the element's autocomplete attribute is wearing the autofill anchor mantle,
# then jump to the step labeled default.
if (category == HtmlCategory.off or category == HtmlCategory.automatic) and html_autocomplete_element_get_autofill_mantle(this) == HtmlAutocompleteElementAutofillMantle.anchor:
return html_autocomplete_element_step_default(this, &attr_details)
# 10. If category is Off, set the element's autofill field name to the string "off", set its autofill hint set to empty,
# and set its IDL-exposed autofill value to the string "off". Then, return.
if category == HtmlCategory.off:
attr_details.field_name = html_autocomplete_string("off")
attr_details.hint_set = ak.Vector[ak.String]()
attr_details.value = html_autocomplete_string("off")
return attr_details
# 11. If category is Automatic, set the element's autofill field name to the string "on", set its autofill hint set to empty,
# and set its IDL-exposed autofill value to the string "on". Then, return.
if category == HtmlCategory.automatic:
attr_details.field_name = html_autocomplete_string("on")
attr_details.hint_set = ak.Vector[ak.String]()
attr_details.value = html_autocomplete_string("on")
return attr_details
# 12. Let scope tokens be an empty list.
var scope_tokens: ak.Vector[ak.String]
# 13. Let hint tokens be an empty set.
var hint_tokens: ak.HashTable[ak.String, ak.StringTraits]
# 14. Let credential type be null.
var credential_type: ak.String? = none
# 15. Let IDL value have the same value as field.
# NOTE: lowercasing is not mentioned in the spec, but required to pass all WPT tests.
var idl_value = ak.string_to_ascii_lowercase(&field)
# 16. If category is Credential and the indexth token in tokens is an ASCII case-insensitive match for "webauthn",
# then run the substeps that follow:
if category == HtmlCategory.credential and ak.string_equals_ignoring_ascii_case_string_view(ak.vector_at_const(&tokens, index), ak.sv("webauthn")):
# 1. Set credential type to "webauthn".
credential_type = html_autocomplete_string("webauthn")
# 2. If the indexth token in tokens is the first entry, then skip to the step labeled done.
if index == 0:
return html_autocomplete_element_step_done(&attr_details, &hint_tokens, credential_type, &scope_tokens, field, idl_value)
# 3. Decrement index by one.
index -= 1
# 4. Set the category, maximum tokens pair to the result of determining a field's category given the indexth token in tokens.
let category_and_maximum_tokens_2 = html_determine_a_field_category(ak.string_bytes_as_string_view(ak.vector_at_const(&tokens, index)))
category = category_and_maximum_tokens_2.category
maximum_tokens = category_and_maximum_tokens_2.maximum_tokens
# 5. If category is not Normal and category is not Contact, then jump to the step labeled default.
if category != HtmlCategory.normal and category != HtmlCategory.contact:
return html_autocomplete_element_step_default(this, &attr_details)
# 6. If index is greater than maximum tokens minus one (i.e. if the number of remaining tokens is greater than maximum tokens),
# then jump to the step labeled default.
if (u64)index > (maximum_tokens else trap("maximum tokens is null")) - 1:
return html_autocomplete_element_step_default(this, &attr_details)
# 7. Set IDL value to the concatenation of the indexth token in tokens, a U+0020 SPACE character, and the previous value of IDL value.
idl_value = html_autocomplete_join_with_space(*ak.vector_at_const(&tokens, index), idl_value)
# 17. If the indexth token in tokens is the first entry, then skip to the step labeled done.
if index == 0:
return html_autocomplete_element_step_done(&attr_details, &hint_tokens, credential_type, &scope_tokens, field, idl_value)
# 18. Decrement index by one.
index -= 1
# 19. If category is Contact and the indexth token in tokens is an ASCII case-insensitive match for one of the strings in the following list,
# then run the substeps that follow:
let contact_names: str[5] = ["home", "work", "mobile", "fax", "pager"]
let lowercase_contact_token = ak.string_to_ascii_lowercase(ak.vector_at_const(&tokens, index))
if category == HtmlCategory.contact and html_autocomplete_string_is_one_of(&lowercase_contact_token, contact_names):
# 1. Let contact be the matching string from the list above.
let contact = ak.string_to_ascii_lowercase(ak.vector_at_const(&tokens, index))
# 2. Insert contact at the start of scope tokens.
ak.vector_prepend_u(&scope_tokens, contact)
# 3. Add contact to hint tokens.
_ = ak.hash_table_set(&hint_tokens, contact)
# 4. Let IDL value be the concatenation of contact, a U+0020 SPACE character, and the previous value of IDL value.
idl_value = html_autocomplete_join_with_space(contact, idl_value)
# 5. If the indexth entry in tokens is the first entry, then skip to the step labeled done.
if index == 0:
return html_autocomplete_element_step_done(&attr_details, &hint_tokens, credential_type, &scope_tokens, field, idl_value)
# 6. Decrement index by one.
index -= 1
# 20. If the indexth token in tokens is an ASCII case-insensitive match for one of the strings in the following list,
# then run the substeps that follow:
let mode_names: str[2] = ["shipping", "billing"]
let lowercase_mode_token = ak.string_to_ascii_lowercase(ak.vector_at_const(&tokens, index))
if html_autocomplete_string_is_one_of(&lowercase_mode_token, mode_names):
# 1. Let mode be the matching string from the list above.
let mode = ak.string_to_ascii_lowercase(ak.vector_at_const(&tokens, index))
# 2. Insert mode at the start of scope tokens.
ak.vector_prepend_u(&scope_tokens, mode)
# 3. Add mode to hint tokens.
_ = ak.hash_table_set(&hint_tokens, mode)
# 4. Let IDL value be the concatenation of mode, a U+0020 SPACE character, and the previous value of IDL value.
idl_value = html_autocomplete_join_with_space(mode, idl_value)
# 5. If the indexth entry in tokens is the first entry, then skip to the step labeled done.
if index == 0:
return html_autocomplete_element_step_done(&attr_details, &hint_tokens, credential_type, &scope_tokens, field, idl_value)
# 6. Decrement index by one.
index -= 1
# 21. If the indexth entry in tokens is not the first entry, then jump to the step labeled default.
if index != 0:
return html_autocomplete_element_step_default(this, &attr_details)
# 22. If the first eight characters of the indexth token in tokens are not an ASCII case-insensitive match for the string "section-",
# then jump to the step labeled default.
let lowercase_section_token = ak.string_to_ascii_lowercase(ak.vector_at_const(&tokens, index))
if not ak.string_starts_with_bytes(&lowercase_section_token, ak.sv("section-")):
return html_autocomplete_element_step_default(this, &attr_details)
# 23. Let section be the indexth token in tokens, converted to ASCII lowercase.
let section = ak.string_to_ascii_lowercase(ak.vector_at_const(&tokens, index))
# 24. Insert section at the start of scope tokens.
ak.vector_prepend_u(&scope_tokens, section)
# 25. Let IDL value be the concatenation of section, a U+0020 SPACE character, and the previous value of IDL value.
idl_value = html_autocomplete_join_with_space(section, idl_value)
return html_autocomplete_element_step_done(&attr_details, &hint_tokens, credential_type, &scope_tokens, field, idl_value)
# mark: The element =============================================================================
## Ported from AutocompleteElement.h:47 Web::HTML::AutocompleteElement::autocomplete_element_to_html_element (virtual).
pub func html_autocomplete_element_autocomplete_element_to_html_element_impl(this: HtmlAutocompleteElement*) -> HtmlElement*:
trap("pure virtual: Web::HTML::AutocompleteElement::autocomplete_element_to_html_element")
## Ported from AutocompleteElement.h:48 Web::HTML::AutocompleteElement::autocomplete_element_to_html_element.
pub func html_autocomplete_element_autocomplete_element_to_html_element_const(this: HtmlAutocompleteElement*) -> HtmlElement*:
return html_autocomplete_element_autocomplete_element_to_html_element(this)