dymokomi/luce-browser-engine
Source of release 0.6.0
0.6.0 / src / web / html / html_output_element.lucb
#==============================================================================================
#
# html_output_element - HTML::HTMLOutputElement: <output>
#
# DESCRIPTION:
# Port of LibWeb/HTML/HTMLOutputElement.cpp (lines 1-113) and the inline functions of
# HTMLOutputElement.h: construction (which moves the mixin tables to HTMLOutputElement's,
# as C++'s vptrs move), htmlFor, the default value override, value, the reset and clear
# algorithms and the FormAssociatedElement and HTMLElement overrides.
#
#==============================================================================================
# mark: Construction ============================================================================
## Ported from HTMLOutputElement.cpp:16 Web::HTML::HTMLOutputElement::HTMLOutputElement.
pub func html_output_element_construct(this: HtmlOutputElement*, document: DomDocument*, qualified_name: DomQualifiedName):
html_element_construct(this.html_element(), document, qualified_name)
# The vptrs of the mixin bases move to HTMLOutputElement's tables.
let element = this.html_element()
element.element.slottable_mixin.vtable = &html_output_element_slottable_mixin_vtable
element.element.aria_mixin.vtable = &html_output_element_aria_mixin_vtable
element.element.animatable.vtable = &html_output_element_animatable_vtable
element.global_event_handlers.vtable = &html_output_element_global_event_handlers_vtable
element.form_associated_element.vtable = &html_output_element_form_associated_element_vtable
## Ported from HTMLOutputElement.cpp:23 Web::HTML::HTMLOutputElement::initialize (override).
pub func html_output_element_initialize_impl(base: JsCell*, realm: Realm*):
web_set_prototype_for_interface(base, realm, BindInterfaceName.html_output_element)
html_element_initialize_impl(base, realm)
## Ported from HTMLOutputElement.cpp:29 Web::HTML::HTMLOutputElement::visit_edges (override).
pub func html_output_element_visit_edges_impl(base: gc.Cell*, visitor: gc.CellVisitor*):
let this = (HtmlOutputElement*)base
html_element_visit_edges_impl(base, visitor)
gc.cell_visitor_visit_t[DomTokenList](visitor, this.m_html_for)
## The output element of its FormAssociatedElement mixin.
func html_output_element_from_form_associated_element(base: HtmlFormAssociatedElement*) -> HtmlOutputElement*:
return (HtmlOutputElement*)html_form_associated_element_form_associated_element_to_html_element(base)
## Ported from HTMLOutputElement.cpp:35 Web::HTML::HTMLOutputElement::form_associated_element_attribute_changed (override).
pub func html_output_element_form_associated_element_attribute_changed_impl(base: HtmlFormAssociatedElement*, name: ak.FlyString, old_value: ak.String?, value: ak.String?, namespace_: ak.FlyString?):
let this = html_output_element_from_form_associated_element(base)
if ak.fly_string_eq_fly_string(&name, &html_attribute_names_for):
if let html_for = this.m_html_for:
let new_value = value else ak.string_new()
dom_token_list_associated_attribute_changed(html_for, ak.string_bytes_as_string_view(&new_value))
# mark: htmlFor, defaultValue and value =========================================================
## Ported from HTMLOutputElement.cpp:44 Web::HTML::HTMLOutputElement::html_for.
# https://html.spec.whatwg.org/multipage/form-elements.html#dom-output-htmlfor
pub func html_output_element_html_for(this: HtmlOutputElement*) -> DomTokenList*:
# The htmlFor IDL attribute must reflect the for content attribute.
if this.m_html_for == none:
this.m_html_for = dom_token_list_create(this.dom_element(), html_attribute_names_for)
return this.m_html_for else trap("unreachable")
## Ported from HTMLOutputElement.cpp:53 Web::HTML::HTMLOutputElement::default_value.
# https://html.spec.whatwg.org/multipage/form-elements.html#dom-output-defaultvalue
pub func html_output_element_default_value(this: HtmlOutputElement*) -> ak.Utf16String:
# 1. If this element's default value override is non-null, then return it.
if let default_value_override = this.m_default_value_override:
return default_value_override
# 2. Return this element's descendant text content.
return dom_node_descendant_text_content(this.dom_node())
## Ported from HTMLOutputElement.cpp:64 Web::HTML::HTMLOutputElement::set_default_value.
# https://html.spec.whatwg.org/multipage/form-elements.html#dom-output-defaultvalue
pub func html_output_element_set_default_value(this: HtmlOutputElement*, default_value: ak.Utf16String):
# 1. If this's default value override is null, then string replace all with the given value within this and return.
if this.m_default_value_override == none:
dom_node_string_replace_all(this.dom_node(), default_value)
return
# 2. Set this's default value override to the given value.
this.m_default_value_override = default_value
## Ported from HTMLOutputElement.cpp:77 Web::HTML::HTMLOutputElement::value.
# https://html.spec.whatwg.org/multipage/form-elements.html#dom-output-value
pub func html_output_element_value(this: HtmlOutputElement*) -> ak.Utf16String:
# The value getter steps are to return this's descendant text content.
return dom_node_descendant_text_content(this.dom_node())
## Ported from HTMLOutputElement.cpp:84 Web::HTML::HTMLOutputElement::set_value.
# https://html.spec.whatwg.org/multipage/form-elements.html#dom-output-value
pub func html_output_element_set_value(this: HtmlOutputElement*, value: ak.Utf16String):
# 1. Set this's default value override to its default value.
this.m_default_value_override = html_output_element_default_value(this)
# 2. String replace all with the given value within this.
dom_node_string_replace_all(this.dom_node(), value)
## Ported from HTMLOutputElement.cpp:94 Web::HTML::HTMLOutputElement::reset_algorithm (override).
# https://html.spec.whatwg.org/multipage/form-elements.html#the-output-element:concept-form-reset-control
pub func html_output_element_reset_algorithm_impl(base: HtmlFormAssociatedElement*):
let this = html_output_element_from_form_associated_element(base)
# 1. String replace all with this element's default value within this element.
dom_node_string_replace_all(this.dom_node(), html_output_element_default_value(this))
# 2. Set this element's default value override to null.
this.m_default_value_override = none
## Ported from HTMLOutputElement.cpp:104 Web::HTML::HTMLOutputElement::clear_algorithm (override).
# https://w3c.github.io/webdriver/#dfn-clear-algorithm
pub func html_output_element_clear_algorithm_impl(base: HtmlFormAssociatedElement*):
let this = html_output_element_from_form_associated_element(base)
# The clear algorithm for output elements is set the element's value mode flag to default
this.m_default_value_override = html_output_element_default_value(this)
# and then to set the element's textContent IDL attribute to an empty string (thus clearing the element's child nodes).
dom_node_string_replace_all(this.dom_node(), ak.utf16_string_new())
# mark: Inline functions of HTMLOutputElement.h =================================================
## Ported from HTMLOutputElement.h:25 Web::HTML::HTMLOutputElement::type.
## (C++ caches the string in a function-local static; a module global is not scanned by the
## collector, so the port makes the same value each time.)
pub func html_output_element_type(this: HtmlOutputElement*) -> ak.String:
return ak.string_from_str("output")
## Ported from HTMLOutputElement.h:35 Web::HTML::HTMLOutputElement::form_value (override).
pub func html_output_element_form_value_impl(base: HtmlFormAssociatedElement*) -> ak.Utf16String:
return html_output_element_value(html_output_element_from_form_associated_element(base))
## Ported from HTMLOutputElement.h:39 Web::HTML::HTMLOutputElement::is_form_associated_element (override).
pub func html_output_element_is_form_associated_element_impl(base: HtmlFormAssociatedElement*) -> bool:
return true
## Ported from HTMLOutputElement.h:43 Web::HTML::HTMLOutputElement::is_listed (override).
# https://html.spec.whatwg.org/multipage/forms.html#category-listed
pub func html_output_element_is_listed_impl(base: HtmlFormAssociatedElement*) -> bool:
return true
## Ported from HTMLOutputElement.h:46 Web::HTML::HTMLOutputElement::is_resettable (override).
# https://html.spec.whatwg.org/multipage/forms.html#category-autocapitalize
pub func html_output_element_is_resettable_impl(base: HtmlFormAssociatedElement*) -> bool:
return true
## Ported from HTMLOutputElement.h:49 Web::HTML::HTMLOutputElement::is_autocapitalize_and_autocorrect_inheriting (override).
# https://html.spec.whatwg.org/multipage/forms.html#category-autocapitalize
pub func html_output_element_is_autocapitalize_and_autocorrect_inheriting_impl(base: HtmlFormAssociatedElement*) -> bool:
return true
## Ported from HTMLOutputElement.h:53 Web::HTML::HTMLOutputElement::is_labelable (override).
# https://html.spec.whatwg.org/multipage/forms.html#category-label
pub func html_output_element_is_labelable_impl(base: HtmlElement*) -> bool:
return true
## Ported from HTMLOutputElement.h:59 Web::HTML::HTMLOutputElement::default_role (override).
# https://www.w3.org/TR/html-aria/#el-output
pub func html_output_element_default_role_impl(base: AriaMixin*) -> AriaRole?:
return AriaRole.status