dymokomi/luce-browser-engine
Source of release 0.6.0
0.6.0 / src / web / layout / svgsvg_box.lucb
#==============================================================================================
#
# svgsvg_box - Layout::SVGSVGBox: the replaced box of an <svg> root
#
# DESCRIPTION:
# Port of LibWeb/Layout/SVGSVGBox.cpp (lines 1-34) and SVGSVGBox.h: the constructor, the
# <svg> element, the SVGSVGPaintable and the natural size the root negotiates
# (https://svgwg.org/svg2-draft/coords.html#SizingSVGInCSS).
#
# Copyright (c) 2020, Matthew Olsson <mattco@serenityos.org>
# Copyright (c) 2022-2024, Andreas Kling <andreas@ladybird.org>
# SPDX-License-Identifier: BSD-2-Clause
#
#==============================================================================================
## Ported from Libraries/LibWeb/Layout/SVGSVGBox.cpp:18 Web::Layout::SVGSVGBox::SVGSVGBox.
pub func layout_svgsvg_box_construct(this: LayoutSvgsvgBox*, document: DomDocument*, element: SvgSvgsvgElement*, style: CssComputedProperties*):
layout_replaced_box_construct(this.layout_replaced_box(), document, element.dom_element(), style)
## Ported from Libraries/LibWeb/Layout/SVGSVGBox.h:22 Web::Layout::SVGSVGBox::dom_node.
pub func layout_svgsvg_box_dom_node(this: LayoutSvgsvgBox*) -> SvgSvgsvgElement*:
return as_svg_svgsvg_element(layout_replaced_box_dom_node(this.layout_replaced_box()) else trap("VERIFY: an <svg> box has a DOM node"))
## Ported from Libraries/LibWeb/Layout/SVGSVGBox.h:23 Web::Layout::SVGSVGBox::dom_node.
pub func layout_svgsvg_box_dom_node_const(this: LayoutSvgsvgBox*) -> SvgSvgsvgElement*:
return layout_svgsvg_box_dom_node(this)
## Ported from Libraries/LibWeb/Layout/SVGSVGBox.h:25 Web::Layout::SVGSVGBox::can_have_children (override).
pub func layout_svgsvg_box_can_have_children_impl(base: LayoutNode*) -> bool:
_ = base
return true
## Ported from Libraries/LibWeb/Layout/SVGSVGBox.cpp:23 Web::Layout::SVGSVGBox::create_paintable (override).
pub func layout_svgsvg_box_create_paintable_impl(base: LayoutNode*) -> PaintPaintable*?:
return paint_svgsvg_paintable_create((LayoutSvgsvgBox*)base).paint_paintable()
## Ported from Libraries/LibWeb/Layout/SVGSVGBox.cpp:28 Web::Layout::SVGSVGBox::natural_size (override).
pub func layout_svgsvg_box_natural_size_impl(base: LayoutBox*) -> CssSizeWithAspectRatio:
let metrics = svg_svgsvg_element_negotiate_natural_metrics(layout_svgsvg_box_dom_node((LayoutSvgsvgBox*)base))
return CssSizeWithAspectRatio(width = metrics.width, height = metrics.height, aspect_ratio = metrics.aspect_ratio)
## Ported from Libraries/LibWeb/Layout/SVGSVGBox.h:31 Web::Layout::SVGSVGBox::is_svg_svg_box (override).
pub func layout_svgsvg_box_is_svg_svg_box_impl(base: LayoutNode*) -> bool:
_ = base
return true