dymokomi/luce-browser-engine
Source of release 0.6.1
0.6.1 / src / web / svg / svg_stop_element.lucb
#==============================================================================================
#
# svg_stop_element - SVG::SVGStopElement: <stop>, a gradient's color stop
#
# DESCRIPTION:
# Port of LibWeb/SVG/SVGStopElement.cpp (lines 1-83) with the inline members of
# SVGStopElement.h: the stop-color and stop-opacity presentation attributes, the
# computed stop color and opacity, and the offset attribute (an SVGAnimatedNumber).
#
#==============================================================================================
## Ported from Libraries/LibWeb/SVG/SVGStopElement.cpp:19 Web::SVG::SVGStopElement::SVGStopElement.
pub func svg_stop_element_construct(this: SvgStopElement*, document: DomDocument*, qualified_name: DomQualifiedName):
svg_element_construct(this.svg_element(), document, qualified_name)
# The vptrs of the mixin bases move to SVGStopElement's tables.
let element = this.svg_element()
element.element.slottable_mixin.vtable = &svg_stop_element_slottable_mixin_vtable
element.element.aria_mixin.vtable = &svg_stop_element_aria_mixin_vtable
element.element.animatable.vtable = &svg_stop_element_animatable_vtable
element.global_event_handlers.vtable = &svg_stop_element_global_event_handlers_vtable
## Ported from Libraries/LibWeb/SVG/SVGStopElement.cpp:24 Web::SVG::SVGStopElement::is_presentational_hint (override).
pub func svg_stop_element_is_presentational_hint_impl(base: DomElement*, name: ak.FlyString) -> bool:
if svg_element_is_presentational_hint_impl(base, name):
return true
return ak.fly_string_eq_fly_string(&name, &svg_attribute_names_stop_color) or ak.fly_string_eq_fly_string(&name, &svg_attribute_names_stop_opacity)
## Ported from Libraries/LibWeb/SVG/SVGStopElement.cpp:32 Web::SVG::SVGStopElement::apply_presentational_hints (override).
pub func svg_stop_element_apply_presentational_hints_impl(base: DomElement*, properties: ak.Vector[CssStyleProperty]*):
svg_element_apply_presentational_hints_impl(base, properties)
var parsing_context: CssParsingParams = ---
css_parsing_params_construct_dom_document(&parsing_context, dom_node_document(base.dom_node()), CssParsingMode.svg_presentation_attribute)
# 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 ak.fly_string_eq_fly_string(&name, &svg_attribute_names_stop_color):
if let stop_color = parse_css_value(parsing_context, ak.string_bytes_as_string_view(&value), css_data.PropertyId.stop_color):
html_append_presentational_hint(properties, css_data.PropertyId.stop_color, stop_color)
elif ak.fly_string_eq_fly_string(&name, &svg_attribute_names_stop_opacity):
if let stop_opacity = parse_css_value(parsing_context, ak.string_bytes_as_string_view(&value), css_data.PropertyId.stop_opacity):
html_append_presentational_hint(properties, css_data.PropertyId.stop_opacity, stop_opacity)
## Ported from Libraries/LibWeb/SVG/SVGStopElement.cpp:49 Web::SVG::SVGStopElement::stop_color.
pub func svg_stop_element_stop_color(this: SvgStopElement*) -> gfx.Color:
if let computed_properties = dom_element_computed_properties(this.dom_element()):
var abstract_element: DomAbstractElement = ---
dom_abstract_element_construct(&abstract_element, this.dom_element())
return css_computed_properties_color(computed_properties, css_data.PropertyId.stop_color, css_color_resolution_context_for_element(abstract_element))
return css_initial_values_stop_color()
## Ported from Libraries/LibWeb/SVG/SVGStopElement.cpp:56 Web::SVG::SVGStopElement::stop_opacity.
pub func svg_stop_element_stop_opacity(this: SvgStopElement*) -> f32:
if let computed_properties = dom_element_computed_properties(this.dom_element()):
return css_computed_properties_stop_opacity(computed_properties)
return 1.0
## Ported from Libraries/LibWeb/SVG/SVGStopElement.cpp:64 Web::SVG::SVGStopElement::offset.
# https://svgwg.org/svg2-draft/pservers.html#StopElementOffsetAttribute
pub func svg_stop_element_offset(this: SvgStopElement*) -> SvgAnimatedNumber*:
if this.m_stop_offset == none:
var qualified_name: DomQualifiedName = ---
dom_qualified_name_construct(&qualified_name, svg_attribute_names_offset, none, none)
this.m_stop_offset = svg_animated_number_create(dom_element_realm(this.dom_element()), this.svg_element(), qualified_name, 0.0)
return this.m_stop_offset else trap("VERIFY: m_stop_offset")
## Ported from Libraries/LibWeb/SVG/SVGStopElement.cpp:71 Web::SVG::SVGStopElement::initialize (override).
pub func svg_stop_element_initialize_impl(base: JsCell*, realm: Realm*):
web_set_prototype_for_interface(base, realm, BindInterfaceName.svg_stop_element)
svg_element_initialize_impl(base, realm)
## Ported from Libraries/LibWeb/SVG/SVGStopElement.cpp:77 Web::SVG::SVGStopElement::visit_edges (override).
pub func svg_stop_element_visit_edges_impl(base: gc.Cell*, visitor: gc.CellVisitor*):
let this = (SvgStopElement*)base
svg_element_visit_edges_impl(base, visitor)
gc.cell_visitor_visit_t(visitor, this.m_stop_offset)
## Ported from Libraries/LibWeb/SVG/SVGStopElement.h:29 Web::SVG::SVGStopElement::stop_offset.
pub func svg_stop_element_stop_offset(this: SvgStopElement*) -> f32:
return svg_animated_number_base_val(svg_stop_element_offset(this))