Luce packages
LuceLuce BaseLuciaOS

dymokomi/luce-browser-engine

Source of release 0.6.0

0.6.0 / src / web / svg / svg_clip_path_element.lucb

#==============================================================================================
#
#   svg_clip_path_element - SVG::SVGClipPathElement: <clipPath>
#
#   DESCRIPTION:
#       Port of LibWeb/SVG/SVGClipPathElement.cpp (lines 1-46) with the inline members of
#       SVGClipPathElement.h: the clipPathUnits attribute and its viewBox trick. Clip paths
#       have no layout node of their own; the TreeBuilder handles them as a special case.
#
#==============================================================================================

## Ported from Libraries/LibWeb/SVG/SVGClipPathElement.cpp:16 Web::SVG::SVGClipPathElement::SVGClipPathElement.
pub func svg_clip_path_element_construct(this: SvgClipPathElement*, document: DomDocument*, qualified_name: DomQualifiedName):
    svg_graphics_element_construct(this.svg_graphics_element(), document, qualified_name)
    # The vptrs of the mixin bases move to SVGClipPathElement's tables.
    let element = this.svg_element()
    element.element.slottable_mixin.vtable = &svg_clip_path_element_slottable_mixin_vtable
    element.element.aria_mixin.vtable = &svg_clip_path_element_aria_mixin_vtable
    element.element.animatable.vtable = &svg_clip_path_element_animatable_vtable
    element.global_event_handlers.vtable = &svg_clip_path_element_global_event_handlers_vtable

## Ported from Libraries/LibWeb/SVG/SVGClipPathElement.cpp:25 Web::SVG::SVGClipPathElement::initialize (override).
pub func svg_clip_path_element_initialize_impl(base: JsCell*, realm: Realm*):
    web_set_prototype_for_interface(base, realm, BindInterfaceName.svg_clip_path_element)
    svg_graphics_element_initialize_impl(base, realm)

## Ported from Libraries/LibWeb/SVG/SVGClipPathElement.cpp:31 Web::SVG::SVGClipPathElement::attribute_changed (override).
pub func svg_clip_path_element_attribute_changed_impl(base: DomElement*, name: ak.FlyString, old_value: ak.String?, value: ak.String?, namespace_: ak.FlyString?):
    let this = (SvgClipPathElement*)base
    svg_graphics_element_attribute_changed_impl(base, name, old_value, value, namespace_)

    if ak.fly_string_eq_fly_string(&name, &svg_attribute_names_clip_path_units):
        let value_text = value else ak.String()  # value.value_or(String {})
        this.m_clip_path_units = svg_attribute_parser_parse_units(ak.string_bytes_as_string_view(&value_text))

## Ported from Libraries/LibWeb/SVG/SVGClipPathElement.cpp:39 Web::SVG::SVGClipPathElement::create_layout_node (override).
pub func svg_clip_path_element_create_layout_node_impl(base: DomElement*, arg0: CssComputedProperties*) -> LayoutNode*?:
    # Clip paths are handled as a special case in the TreeBuilder.
    return none

## Ported from Libraries/LibWeb/SVG/SVGClipPathElement.h:22 Web::SVG::SVGClipPathElement::active_view_box (override).
pub func svg_clip_path_element_active_view_box_impl(base: SvgGraphicsElement*) -> SvgViewBox?:
    let this = (SvgClipPathElement*)base
    # Same trick as SVGMaskElement.
    if svg_clip_path_element_clip_path_units(this) == SvgUnits.object_bounding_box:
        return SvgViewBox(min_x = 0.0, min_y = 0.0, width = 1.0, height = 1.0)
    return none

## Ported from Libraries/LibWeb/SVG/SVGClipPathElement.h:32 Web::SVG::SVGClipPathElement::clip_path_units.
pub func svg_clip_path_element_clip_path_units(this: SvgClipPathElement*) -> SvgUnits:
    return this.m_clip_path_units else SvgUnits.user_space_on_use