dymokomi/luce-browser-engine
Source of release 0.6.0
0.6.0 / src / web / html / html_area_element.lucb
#==============================================================================================
#
# html_area_element - HTML::HTMLAreaElement: <area>
#
# DESCRIPTION:
# Port of LibWeb/HTML/HTMLAreaElement.cpp (lines 1-73) and the inlines of
# HTMLAreaElement.h: construction (which moves the mixin tables to HTMLAreaElement's, as
# C++'s vptrs move, and sets up the HTMLHyperlinkElementUtils base), initialize,
# visit_edges, attribute_changed (the URL and relList), relList, the tab index and the ARIA
# role.
#
#==============================================================================================
# mark: HTMLAreaElement.cpp ======================================================================
## Ported from HTMLAreaElement.cpp:17 Web::HTML::HTMLAreaElement::HTMLAreaElement.
pub func html_area_element_construct(this: HtmlAreaElement*, document: DomDocument*, qualified_name: DomQualifiedName):
html_element_construct(this.html_element(), document, qualified_name)
# The HTMLHyperlinkElementUtils base (its URL starts null), then the vptrs of the mixin bases
# move to HTMLAreaElement's tables.
this.html_hyperlink_element_utils.vtable = &html_area_element_html_hyperlink_element_utils_vtable
this.html_hyperlink_element_utils.class_id = this.cell().class_id
let element = this.html_element()
element.element.slottable_mixin.vtable = &html_area_element_slottable_mixin_vtable
element.element.aria_mixin.vtable = &html_area_element_aria_mixin_vtable
element.element.animatable.vtable = &html_area_element_animatable_vtable
element.global_event_handlers.vtable = &html_area_element_global_event_handlers_vtable
element.form_associated_element.vtable = &html_area_element_form_associated_element_vtable
## Ported from HTMLAreaElement.cpp:24 Web::HTML::HTMLAreaElement::initialize (override).
pub func html_area_element_initialize_impl(base: JsCell*, realm: Realm*):
web_set_prototype_for_interface(base, realm, BindInterfaceName.html_area_element)
html_element_initialize_impl(base, realm)
## Ported from HTMLAreaElement.cpp:30 Web::HTML::HTMLAreaElement::visit_edges (override).
pub func html_area_element_visit_edges_impl(base: gc.Cell*, visitor: gc.CellVisitor*):
let this = (HtmlAreaElement*)base
html_element_visit_edges_impl(base, visitor)
gc.cell_visitor_visit_t[DomTokenList](visitor, this.m_rel_list)
## Ported from HTMLAreaElement.cpp:36 Web::HTML::HTMLAreaElement::attribute_changed (override).
pub func html_area_element_attribute_changed_impl(base: DomElement*, name: ak.FlyString, old_value: ak.String?, value: ak.String?, namespace_: ak.FlyString?):
let this = (HtmlAreaElement*)base
html_element_attribute_changed_impl(base, name, old_value, value, namespace_)
if html_name_is(name, html_attribute_names_href):
html_hyperlink_element_utils_set_the_url(&this.html_hyperlink_element_utils)
elif html_name_is(name, html_attribute_names_rel):
if let rel_list = this.m_rel_list:
let value_or_empty = value else ak.string_new()
dom_token_list_associated_attribute_changed(rel_list, ak.string_bytes_as_string_view(&value_or_empty))
## Ported from HTMLAreaElement.cpp:49 Web::HTML::HTMLAreaElement::rel_list.
# https://html.spec.whatwg.org/multipage/image-maps.html#dom-area-rellist
pub func html_area_element_rel_list(this: HtmlAreaElement*) -> DomTokenList*:
# The IDL attribute relList must reflect the rel content attribute.
if this.m_rel_list == none:
this.m_rel_list = dom_token_list_create(this.dom_element(), html_attribute_names_rel)
return this.m_rel_list else trap("unreachable")
## Ported from HTMLAreaElement.cpp:58 Web::HTML::HTMLAreaElement::default_tab_index_value (override).
# https://html.spec.whatwg.org/multipage/interaction.html#dom-tabindex
pub func html_area_element_default_tab_index_value_impl(base: DomElement*) -> i32:
# See the base function for the spec comments.
return 0
## Ported from HTMLAreaElement.cpp:64 Web::HTML::HTMLAreaElement::default_role (override).
pub func html_area_element_default_role_impl(base: AriaMixin*) -> AriaRole?:
let this = (HtmlAreaElement*)dom_element_from_aria_mixin(base)
# https://www.w3.org/TR/html-aria/#el-area-no-href
let href = html_hyperlink_element_utils_href(&this.html_hyperlink_element_utils)
if not ak.string_is_empty(&href):
return AriaRole.link
# https://www.w3.org/TR/html-aria/#el-area
return AriaRole.generic
# mark: Inline members of HTMLAreaElement.h ======================================================
## Ported from HTMLAreaElement.h:28 Web::HTML::HTMLAreaElement::is_html_area_element (override).
pub func html_area_element_is_html_area_element_impl(base: DomNode*) -> bool:
return true
## Ported from HTMLAreaElement.h:33 Web::HTML::HTMLAreaElement::extract_an_origin (override).
pub func html_area_element_extract_an_origin_impl(base: BindPlatformObject*) -> web_url.Origin?:
let this = (HtmlAreaElement*)base
return html_hyperlink_element_utils_hyperlink_element_utils_extract_an_origin(&this.html_hyperlink_element_utils)
## Ported from HTMLAreaElement.h:40 Web::HTML::HTMLAreaElement::hyperlink_element_utils_element (override).
pub func html_area_element_hyperlink_element_utils_element_impl(base: HtmlHyperlinkElementUtils*) -> DomElement*:
return (DomElement*)((u8*)base - memory.offset_of(HtmlAreaElement, html_hyperlink_element_utils))
## Ported from HTMLAreaElement.h:41 Web::HTML::HTMLAreaElement::hyperlink_element_utils_element (override).
pub func html_area_element_hyperlink_element_utils_element_const_impl(base: HtmlHyperlinkElementUtils*) -> DomElement*:
return (DomElement*)((u8*)base - memory.offset_of(HtmlAreaElement, html_hyperlink_element_utils))