dymokomi/luce-browser-engine
Source of release 0.6.1
0.6.1 / src / web / html / html_pre_element.lucb
#==============================================================================================
#
# html_pre_element - HTML::HTMLPreElement: <pre> and its wrap presentational hint
#
# DESCRIPTION:
# Port of LibWeb/HTML/HTMLPreElement.cpp (lines 1-49) and the default_role inline of
# HTMLPreElement.h: construction (which moves the mixin tables to HTMLPreElement's, as
# C++'s vptrs move), initialize and the wrap presentational hint.
#
#==============================================================================================
## Ported from HTMLPreElement.cpp:18 Web::HTML::HTMLPreElement::HTMLPreElement.
pub func html_pre_element_construct(this: HtmlPreElement*, document: DomDocument*, qualified_name: DomQualifiedName):
html_element_construct(this.html_element(), document, qualified_name)
# The vptrs of the mixin bases move to HTMLPreElement's tables.
let element = this.html_element()
element.element.slottable_mixin.vtable = &html_pre_element_slottable_mixin_vtable
element.element.aria_mixin.vtable = &html_pre_element_aria_mixin_vtable
element.element.animatable.vtable = &html_pre_element_animatable_vtable
element.global_event_handlers.vtable = &html_pre_element_global_event_handlers_vtable
element.form_associated_element.vtable = &html_pre_element_form_associated_element_vtable
## Ported from HTMLPreElement.cpp:25 Web::HTML::HTMLPreElement::initialize (override).
pub func html_pre_element_initialize_impl(base: JsCell*, realm: Realm*):
web_set_prototype_for_interface(base, realm, BindInterfaceName.html_pre_element)
html_element_initialize_impl(base, realm)
## Ported from HTMLPreElement.cpp:31 Web::HTML::HTMLPreElement::is_presentational_hint (override).
pub func html_pre_element_is_presentational_hint_impl(base: DomElement*, name: ak.FlyString) -> bool:
if dom_element_is_presentational_hint_impl(base, name):
return true
return html_name_is(name, html_attribute_names_wrap)
## Ported from HTMLPreElement.cpp:39 Web::HTML::HTMLPreElement::apply_presentational_hints (override).
pub func html_pre_element_apply_presentational_hints_impl(base: DomElement*, properties: ak.Vector[CssStyleProperty]*):
dom_element_apply_presentational_hints_impl(base, properties)
# for_each_attribute([&](auto const& name, auto const&) { ... })
let attributes = base.m_attributes else return
for i in 0..<dom_named_node_map_length(attributes):
let attribute = dom_named_node_map_item(attributes, (u32)i) else trap("NamedNodeMap::item in range")
if html_name_is(dom_attr_name(attribute), html_attribute_names_wrap):
html_append_keyword_hint(properties, css_data.PropertyId.text_wrap_mode, css_data.Keyword.wrap)
## Ported from HTMLPreElement.h:23 Web::HTML::HTMLPreElement::default_role (override).
# https://www.w3.org/TR/html-aria/#el-pre
pub func html_pre_element_default_role_impl(base: AriaMixin*) -> AriaRole?:
return AriaRole.generic