dymokomi/luce-browser-engine
Source of release 0.6.0
0.6.0 / src / web / html / html_marquee_element.lucb
#==============================================================================================
#
# html_marquee_element - HTML::HTMLMarqueeElement: <marquee>
#
# DESCRIPTION:
# Port of LibWeb/HTML/HTMLMarqueeElement.cpp (lines 1-116): construction (which moves the
# mixin tables to HTMLMarqueeElement's, as C++'s vptrs move), initialize, the bgcolor /
# height / hspace / vspace / width presentational hints and the reflected scrollAmount and
# scrollDelay.
#
#==============================================================================================
## Ported from HTMLMarqueeElement.cpp:20 Web::HTML::HTMLMarqueeElement::HTMLMarqueeElement.
pub func html_marquee_element_construct(this: HtmlMarqueeElement*, document: DomDocument*, qualified_name: DomQualifiedName):
html_element_construct(this.html_element(), document, qualified_name)
# The vptrs of the mixin bases move to HTMLMarqueeElement's tables.
let element = this.html_element()
element.element.slottable_mixin.vtable = &html_marquee_element_slottable_mixin_vtable
element.element.aria_mixin.vtable = &html_marquee_element_aria_mixin_vtable
element.element.animatable.vtable = &html_marquee_element_animatable_vtable
element.global_event_handlers.vtable = &html_marquee_element_global_event_handlers_vtable
element.form_associated_element.vtable = &html_marquee_element_form_associated_element_vtable
## Ported from HTMLMarqueeElement.cpp:27 Web::HTML::HTMLMarqueeElement::initialize (override).
pub func html_marquee_element_initialize_impl(base: JsCell*, realm: Realm*):
web_set_prototype_for_interface(base, realm, BindInterfaceName.html_marquee_element)
html_element_initialize_impl(base, realm)
## Ported from HTMLMarqueeElement.cpp:33 Web::HTML::HTMLMarqueeElement::is_presentational_hint (override).
pub func html_marquee_element_is_presentational_hint_impl(base: DomElement*, name: ak.FlyString) -> bool:
if dom_element_is_presentational_hint_impl(base, name):
return true
let names: ak.FlyString[5] = [
html_attribute_names_bgcolor,
html_attribute_names_height,
html_attribute_names_hspace,
html_attribute_names_vspace,
html_attribute_names_width]
return html_name_is_one_of(name, names)
## Ported from HTMLMarqueeElement.cpp:46 Web::HTML::HTMLMarqueeElement::apply_presentational_hints (override).
pub func html_marquee_element_apply_presentational_hints_impl(base: DomElement*, properties: ak.Vector[CssStyleProperty]*):
dom_element_apply_presentational_hints_impl(base, properties)
# for_each_attribute([&](auto& name, auto& value) { ... })
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")
let name = dom_attr_name(attribute)
let value = dom_attr_value(attribute)
if html_name_is(name, html_attribute_names_bgcolor):
# https://html.spec.whatwg.org/multipage/rendering.html#the-marquee-element-2:rules-for-parsing-a-legacy-colour-value
if let color = html_parse_legacy_color_value(ak.string_bytes_as_string_view(&value)):
html_append_presentational_hint(properties, css_data.PropertyId.background_color, css_color_style_value_create_from_color(color, CssColorSyntax.legacy).css_style_value())
elif html_name_is(name, html_attribute_names_height):
# https://html.spec.whatwg.org/multipage/rendering.html#the-marquee-element-2:maps-to-the-dimension-property
if let parsed_value = html_parse_dimension_value(ak.string_bytes_as_string_view(&value)):
html_append_presentational_hint(properties, css_data.PropertyId.height, parsed_value)
elif html_name_is(name, html_attribute_names_hspace):
if let parsed_value = html_parse_dimension_value(ak.string_bytes_as_string_view(&value)):
html_append_presentational_hint(properties, css_data.PropertyId.margin_left, parsed_value)
html_append_presentational_hint(properties, css_data.PropertyId.margin_right, parsed_value)
elif html_name_is(name, html_attribute_names_vspace):
if let parsed_value = html_parse_dimension_value(ak.string_bytes_as_string_view(&value)):
html_append_presentational_hint(properties, css_data.PropertyId.margin_top, parsed_value)
html_append_presentational_hint(properties, css_data.PropertyId.margin_bottom, parsed_value)
elif html_name_is(name, html_attribute_names_width):
if let parsed_value = html_parse_dimension_value(ak.string_bytes_as_string_view(&value)):
html_append_presentational_hint(properties, css_data.PropertyId.width, parsed_value)
## Ported from HTMLMarqueeElement.cpp:79 Web::HTML::HTMLMarqueeElement::scroll_amount.
# https://html.spec.whatwg.org/multipage/obsolete.html#dom-marquee-scrollamount
pub func html_marquee_element_scroll_amount(this: HtmlMarqueeElement*) -> u32:
# The scrollAmount IDL attribute must reflect the scrollamount content attribute. The default value is 6.
if let scroll_amount_string = dom_element_get_attribute(this.dom_element(), html_attribute_names_scrollamount):
if let scroll_amount = html_parse_non_negative_integer(ak.string_bytes_as_string_view(&scroll_amount_string)):
if scroll_amount <= 2147483647:
return scroll_amount
return 6
## Ported from HTMLMarqueeElement.cpp:90 Web::HTML::HTMLMarqueeElement::set_scroll_amount.
# https://html.spec.whatwg.org/multipage/obsolete.html#dom-marquee-scrollamount
pub func html_marquee_element_set_scroll_amount(this: HtmlMarqueeElement*, value: u32):
var new_value = value
if new_value > 2147483647:
new_value = 6
dom_element_set_attribute_value(this.dom_element(), html_attribute_names_scrollamount, ak.string_number_u64((u64)new_value))
## Ported from HTMLMarqueeElement.cpp:98 Web::HTML::HTMLMarqueeElement::scroll_delay.
# https://html.spec.whatwg.org/multipage/obsolete.html#dom-marquee-scrolldelay
pub func html_marquee_element_scroll_delay(this: HtmlMarqueeElement*) -> u32:
# The scrollDelay IDL attribute must reflect the scrolldelay content attribute. The default value is 85.
if let scroll_delay_string = dom_element_get_attribute(this.dom_element(), html_attribute_names_scrolldelay):
if let scroll_delay = html_parse_non_negative_integer(ak.string_bytes_as_string_view(&scroll_delay_string)):
if scroll_delay <= 2147483647:
return scroll_delay
return 85
## Ported from HTMLMarqueeElement.cpp:109 Web::HTML::HTMLMarqueeElement::set_scroll_delay.
# https://html.spec.whatwg.org/multipage/obsolete.html#dom-marquee-scrolldelay
pub func html_marquee_element_set_scroll_delay(this: HtmlMarqueeElement*, value: u32):
var new_value = value
if new_value > 2147483647:
new_value = 85
dom_element_set_attribute_value(this.dom_element(), html_attribute_names_scrolldelay, ak.string_number_u64((u64)new_value))