dymokomi/luce-browser-engine
Source of release 0.6.0
0.6.0 / src / web / svg / svg_polyline_element.lucb
#==============================================================================================
#
# svg_polyline_element - SVG::SVGPolylineElement: <polyline>
#
# DESCRIPTION:
# Port of LibWeb/SVG/SVGPolylineElement.cpp: the `points` attribute and the path through
# them (https://svgwg.org/svg2-draft/shapes.html#PolylineElement).
#
#==============================================================================================
## Ported from Libraries/LibWeb/SVG/SVGPolylineElement.cpp:19 Web::SVG::SVGPolylineElement::SVGPolylineElement.
pub func svg_polyline_element_construct(this: SvgPolylineElement*, document: DomDocument*, qualified_name: DomQualifiedName):
svg_geometry_element_construct(this.svg_geometry_element(), document, qualified_name)
# The vptrs of the mixin bases move to SVGPolylineElement's tables.
let element = this.svg_element()
element.element.slottable_mixin.vtable = &svg_polyline_element_slottable_mixin_vtable
element.element.aria_mixin.vtable = &svg_polyline_element_aria_mixin_vtable
element.element.animatable.vtable = &svg_polyline_element_animatable_vtable
element.global_event_handlers.vtable = &svg_polyline_element_global_event_handlers_vtable
## Ported from Libraries/LibWeb/SVG/SVGPolylineElement.cpp:24 Web::SVG::SVGPolylineElement::initialize (override).
pub func svg_polyline_element_initialize_impl(base: JsCell*, realm: Realm*):
web_set_prototype_for_interface(base, realm, BindInterfaceName.svg_polyline_element)
svg_geometry_element_initialize_impl(base, realm)
## Ported from Libraries/LibWeb/SVG/SVGPolylineElement.cpp:30 Web::SVG::SVGPolylineElement::attribute_changed (override).
pub func svg_polyline_element_attribute_changed_impl(base: DomElement*, name: ak.FlyString, old_value: ak.String?, value: ak.String?, namespace_: ak.FlyString?):
let this = (SvgPolylineElement*)base
svg_graphics_element_attribute_changed_impl(base, name, old_value, value, namespace_)
let value_text = value else ak.String() # value.value_or(String {})
if ak.fly_string_eq_fly_string(&name, &svg_attribute_names_points):
this.m_points = svg_attribute_parser_parse_points(ak.string_bytes_as_string_view(&value_text))
dom_node_set_needs_layout_update(base.dom_node(), DomSetNeedsLayoutReason.style_change)
## Ported from Libraries/LibWeb/SVG/SVGPolylineElement.cpp:40 Web::SVG::SVGPolylineElement::get_path (override).
pub func svg_polyline_element_get_path_impl(base: SvgGeometryElement*, viewport_size: gfx.CssPixelSize) -> gfx.Path:
let this = (SvgPolylineElement*)base
var path: gfx.Path
if ak.vector_is_empty(&this.m_points):
return path
# 1. perform an absolute moveto operation to the first coordinate pair in the list of points
gfx.path_move_to(&path, *ak.vector_first(&this.m_points))
# 2. for each subsequent coordinate pair, perform an absolute lineto operation to that coordinate pair.
for point_index in 1..<ak.vector_size(&this.m_points):
gfx.path_line_to(&path, *ak.vector_at(&this.m_points, point_index))
return path