dymokomi/luce-browser-engine
Source of release 0.6.0
0.6.0 / src / web / svg / svg_graphics_element.lucb
#==============================================================================================
#
# svg_graphics_element - SVG::SVGGraphicsElement: transforms, paint and the bounding box
#
# DESCRIPTION:
# Port of LibWeb/SVG/SVGGraphicsElement.cpp (lines 1-406) with the inline members of
# SVGGraphicsElement.h: the `transform` attribute, the painting properties read from
# the layout node's computed values (fill and stroke colors, paint servers, opacity,
# dashes, widths, line caps and joins, fill and clip rules), resolving url() references
# to masks, clip paths and patterns, getBBox(), and transform_from_transform_list.
#
# The template try_resolve_url_to<T> is resolve_url_to_element followed by the matching
# as_if_<T> at each call site (a generic body cannot ask T for its class).
#
#==============================================================================================
# mark: Construction =============================================================================
## Ported from Libraries/LibWeb/SVG/SVGGraphicsElement.cpp:34 Web::SVG::SVGGraphicsElement::SVGGraphicsElement.
pub func svg_graphics_element_construct(this: SvgGraphicsElement*, document: DomDocument*, qualified_name: DomQualifiedName):
svg_element_construct(this.svg_element(), document, qualified_name)
# Gfx::AffineTransform m_transform = {}: the identity.
gfx.affine_transform_construct(&this.m_transform)
## Ported from Libraries/LibWeb/SVG/SVGGraphicsElement.cpp:39 Web::SVG::SVGGraphicsElement::initialize (override).
pub func svg_graphics_element_initialize_impl(base: JsCell*, realm: Realm*):
web_set_prototype_for_interface(base, realm, BindInterfaceName.svg_graphics_element)
svg_element_initialize_impl(base, realm)
## Ported from Libraries/LibWeb/SVG/SVGGraphicsElement.cpp:45 Web::SVG::SVGGraphicsElement::attribute_changed (override).
pub func svg_graphics_element_attribute_changed_impl(base: DomElement*, name: ak.FlyString, old_value: ak.String?, value: ak.String?, namespace_: ak.FlyString?):
let this = (SvgGraphicsElement*)base
svg_element_attribute_changed_impl(base, name, old_value, value, namespace_)
if ak.fly_string_eq_string_view(&name, ak.sv("transform")):
let text = value else ak.String()
if let transform_list = svg_attribute_parser_parse_transform_string_view(ak.string_bytes_as_string_view(&text)):
this.m_transform = svg_transform_from_transform_list(ak.vector_span_const(&transform_list))
dom_node_set_needs_layout_update(base.dom_node(), DomSetNeedsLayoutReason.svg_graphics_element_transform_change)
# mark: Paint servers and references =============================================================
## Ported from Libraries/LibWeb/SVG/SVGGraphicsElement.cpp:57 Web::SVG::SVGGraphicsElement::svg_paint_computed_value_to_gfx_paint_style.
func svg_graphics_element_svg_paint_computed_value_to_gfx_paint_style(this: SvgGraphicsElement*, paint_context: SvgPaintContext, paint_value: CssSvgPaint?,
recording_context: DisplayListRecordingContext*? = none) -> display_list.SvgPaintServerPaintStyle*?:
# FIXME: This entire function is an ad-hoc hack:
let paint = paint_value else return none
if not css_svg_paint_is_url(&paint):
return none
let url = css_svg_paint_as_url(&paint)
if let element = svg_graphics_element_resolve_url_to_element(this, url):
if let gradient = as_if_svg_gradient_element(element):
return svg_gradient_element_to_gfx_paint_style(gradient, paint_context)
if let element = svg_graphics_element_resolve_url_to_element(this, url):
if let pattern = as_if_svg_pattern_element(element):
if let context = recording_context:
if let layout_node = dom_node_layout_node(this.dom_node()):
return svg_pattern_element_to_gfx_paint_style(pattern, paint_context, context, layout_node)
return none
## Ported from Libraries/LibWeb/SVG/SVGGraphicsElement.cpp:72 Web::SVG::SVGGraphicsElement::fill_paint_style.
# NB: SVG property accessors below are called during painting.
pub func svg_graphics_element_fill_paint_style(this: SvgGraphicsElement*, paint_context: SvgPaintContext, recording_context: DisplayListRecordingContext*? = none) -> display_list.SvgPaintServerPaintStyle*?:
let node = dom_node_unsafe_layout_node(this.dom_node()) else return none
let computed_values = layout_node_computed_values(node)
return svg_graphics_element_svg_paint_computed_value_to_gfx_paint_style(this, paint_context, css_computed_values_fill(&computed_values.computed_values), recording_context)
## Ported from Libraries/LibWeb/SVG/SVGGraphicsElement.cpp:79 Web::SVG::SVGGraphicsElement::stroke_paint_style.
pub func svg_graphics_element_stroke_paint_style(this: SvgGraphicsElement*, paint_context: SvgPaintContext, recording_context: DisplayListRecordingContext*? = none) -> display_list.SvgPaintServerPaintStyle*?:
let node = dom_node_unsafe_layout_node(this.dom_node()) else return none
let computed_values = layout_node_computed_values(node)
return svg_graphics_element_svg_paint_computed_value_to_gfx_paint_style(this, paint_context, css_computed_values_stroke(&computed_values.computed_values), recording_context)
## Ported from Libraries/LibWeb/SVG/SVGGraphicsElement.cpp:86 Web::SVG::SVGGraphicsElement::resolve_url_to_element.
func svg_graphics_element_resolve_url_to_element(this: SvgGraphicsElement*, url: CssUrl) -> DomElement*?:
# FIXME: Complete and use the entire URL, not just the fragment.
var fragment: ak.FlyString? = none
let url_string = css_url_url(&url)
if let fragment_offset = ak.string_find_byte_offset_u32(&url_string, (u32)'#'):
let substring = ak.string_substring_from_byte_offset_with_shared_superstring(&url_string, fragment_offset + 1) else trap("MUST: String::substring_from_byte_offset_with_shared_superstring")
fragment = ak.fly_string_from_string(substring)
let id = fragment else return none
let document = dom_node_document(this.dom_node())
if let element = dom_parent_node_get_element_by_id(document.dom_parent_node(), id):
return element
if let containing_shadow = dom_node_containing_shadow_root(this.dom_node()):
if let element = dom_parent_node_get_element_by_id(containing_shadow.dom_parent_node(), id):
return element
return none
## Ported from Libraries/LibWeb/SVG/SVGGraphicsElement.cpp:107 Web::SVG::SVGGraphicsElement::mask.
pub func svg_graphics_element_mask(this: SvgGraphicsElement*) -> SvgMaskElement*?:
# NB: unsafe_layout_node() because this is called during painting to resolve SVG references.
let node = dom_node_unsafe_layout_node(this.dom_node()) else trap("VERIFY: unsafe_layout_node()")
let computed_values = layout_node_computed_values(node)
let mask_reference = css_computed_values_mask(&computed_values.computed_values) else return none
let element = svg_graphics_element_resolve_url_to_element(this, css_mask_reference_url(&mask_reference)) else return none
return as_if_svg_mask_element(element)
## Ported from Libraries/LibWeb/SVG/SVGGraphicsElement.cpp:116 Web::SVG::SVGGraphicsElement::clip_path.
pub func svg_graphics_element_clip_path(this: SvgGraphicsElement*) -> SvgClipPathElement*?:
# NB: unsafe_layout_node() because this is called during painting to resolve SVG references.
let node = dom_node_unsafe_layout_node(this.dom_node()) else trap("VERIFY: unsafe_layout_node()")
let computed_values = layout_node_computed_values(node)
let clip_path_reference = css_computed_values_clip_path(&computed_values.computed_values) else return none
if not css_clip_path_reference_is_url(&clip_path_reference):
return none
let element = svg_graphics_element_resolve_url_to_element(this, css_clip_path_reference_url(&clip_path_reference)) else return none
return as_if_svg_clip_path_element(element)
## Ported from Libraries/LibWeb/SVG/SVGGraphicsElement.cpp:125 Web::SVG::SVGGraphicsElement::fill_pattern.
pub func svg_graphics_element_fill_pattern(this: SvgGraphicsElement*) -> SvgPatternElement*?:
let node = dom_node_unsafe_layout_node(this.dom_node()) else return none
let computed_values = layout_node_computed_values(node)
let fill = css_computed_values_fill(&computed_values.computed_values) else return none
if not css_svg_paint_is_url(&fill):
return none
let element = svg_graphics_element_resolve_url_to_element(this, css_svg_paint_as_url(&fill)) else return none
return as_if_svg_pattern_element(element)
## Ported from Libraries/LibWeb/SVG/SVGGraphicsElement.cpp:135 Web::SVG::SVGGraphicsElement::stroke_pattern.
pub func svg_graphics_element_stroke_pattern(this: SvgGraphicsElement*) -> SvgPatternElement*?:
let node = dom_node_unsafe_layout_node(this.dom_node()) else return none
let computed_values = layout_node_computed_values(node)
let stroke = css_computed_values_stroke(&computed_values.computed_values) else return none
if not css_svg_paint_is_url(&stroke):
return none
let element = svg_graphics_element_resolve_url_to_element(this, css_svg_paint_as_url(&stroke)) else return none
return as_if_svg_pattern_element(element)
# mark: Transforms ===============================================================================
## `Gfx::AffineTransform {}`: the identity.
func svg_identity_transform() -> gfx.AffineTransform:
var transform: gfx.AffineTransform
gfx.affine_transform_construct(&transform)
return transform
## Ported from Libraries/LibWeb/SVG/SVGGraphicsElement.cpp:145 Web::SVG::transform_from_transform_list.
pub func svg_transform_from_transform_list(transform_list: const SvgTransform[]) -> gfx.AffineTransform:
var affine_transform = svg_identity_transform()
for transform in transform_list:
match transform.operation:
.svg_transform_translate(translate):
var operation = svg_identity_transform()
_ = gfx.affine_transform_translate_float_point(&operation, gfx.FloatPoint(m_x = translate.x, m_y = translate.y))
_ = gfx.affine_transform_multiply(&affine_transform, operation)
.svg_transform_scale(scale):
var operation = svg_identity_transform()
_ = gfx.affine_transform_scale_float_point(&operation, gfx.FloatPoint(m_x = scale.x, m_y = scale.y))
_ = gfx.affine_transform_multiply(&affine_transform, operation)
.svg_transform_rotate(rotate):
var operation = svg_identity_transform()
_ = gfx.affine_transform_translate_float_point(&operation, gfx.FloatPoint(m_x = rotate.x, m_y = rotate.y))
_ = gfx.affine_transform_rotate_radians(&operation, ak.to_radians_f32(rotate.a))
_ = gfx.affine_transform_translate_float_point(&operation, gfx.FloatPoint(m_x = -rotate.x, m_y = -rotate.y))
_ = gfx.affine_transform_multiply(&affine_transform, operation)
.svg_transform_skew_x(skew_x):
var operation = svg_identity_transform()
_ = gfx.affine_transform_skew_radians(&operation, ak.to_radians_f32(skew_x.a), 0.0)
_ = gfx.affine_transform_multiply(&affine_transform, operation)
.svg_transform_skew_y(skew_y):
var operation = svg_identity_transform()
_ = gfx.affine_transform_skew_radians(&operation, 0.0, ak.to_radians_f32(skew_y.a))
_ = gfx.affine_transform_multiply(&affine_transform, operation)
.svg_transform_matrix(matrix):
var operation: gfx.AffineTransform
gfx.affine_transform_construct_f32(&operation, matrix.a, matrix.b, matrix.c, matrix.d, matrix.e, matrix.f)
_ = gfx.affine_transform_multiply(&affine_transform, operation)
return affine_transform
## Ported from Libraries/LibWeb/SVG/SVGGraphicsElement.cpp:178 Web::SVG::to_svg_fill_rule (static).
func svg_to_svg_fill_rule(fill_rule: css_data.FillRule) -> SvgFillRule:
match fill_rule:
.nonzero: return SvgFillRule.nonzero
.evenodd: return SvgFillRule.evenodd
_: trap("VERIFY_NOT_REACHED")
# mark: Painting properties ======================================================================
## Ported from Libraries/LibWeb/SVG/SVGGraphicsElement.cpp:190 Web::SVG::SVGGraphicsElement::fill_rule.
pub func svg_graphics_element_fill_rule(this: SvgGraphicsElement*) -> SvgFillRule?:
let node = dom_node_unsafe_layout_node(this.dom_node()) else return none
let computed_values = layout_node_computed_values(node)
return svg_to_svg_fill_rule(css_computed_values_fill_rule(&computed_values.computed_values))
## Ported from Libraries/LibWeb/SVG/SVGGraphicsElement.cpp:197 Web::SVG::SVGGraphicsElement::clip_rule.
pub func svg_graphics_element_clip_rule(this: SvgGraphicsElement*) -> SvgFillRule?:
let node = dom_node_unsafe_layout_node(this.dom_node()) else return none
let computed_values = layout_node_computed_values(node)
return svg_to_svg_fill_rule(css_computed_values_clip_rule(&computed_values.computed_values))
## Ported from Libraries/LibWeb/SVG/SVGGraphicsElement.cpp:204 Web::SVG::SVGGraphicsElement::fill_color.
pub func svg_graphics_element_fill_color(this: SvgGraphicsElement*) -> gfx.Color?:
let node = dom_node_unsafe_layout_node(this.dom_node()) else return none
let computed_values = layout_node_computed_values(node)
let paint = css_computed_values_fill(&computed_values.computed_values) else return none
if css_svg_paint_is_url(&paint):
if let element = svg_graphics_element_resolve_url_to_element(this, css_svg_paint_as_url(&paint)):
if let referenced_element = as_if_svg_graphics_element(element):
return svg_graphics_element_fill_color(referenced_element)
return css_svg_paint_fallback_color(&paint)
return css_svg_paint_as_color(&paint)
## Ported from Libraries/LibWeb/SVG/SVGGraphicsElement.cpp:223 Web::SVG::SVGGraphicsElement::stroke_color.
pub func svg_graphics_element_stroke_color(this: SvgGraphicsElement*) -> gfx.Color?:
let node = dom_node_unsafe_layout_node(this.dom_node()) else return none
let computed_values = layout_node_computed_values(node)
let paint = css_computed_values_stroke(&computed_values.computed_values) else return none
if css_svg_paint_is_url(&paint):
if let element = svg_graphics_element_resolve_url_to_element(this, css_svg_paint_as_url(&paint)):
if let referenced_element = as_if_svg_graphics_element(element):
return svg_graphics_element_stroke_color(referenced_element)
return css_svg_paint_fallback_color(&paint)
return css_svg_paint_as_color(&paint)
## Ported from Libraries/LibWeb/SVG/SVGGraphicsElement.cpp:242 Web::SVG::SVGGraphicsElement::fill_opacity.
pub func svg_graphics_element_fill_opacity(this: SvgGraphicsElement*) -> f32?:
let node = dom_node_unsafe_layout_node(this.dom_node()) else return none
let computed_values = layout_node_computed_values(node)
return css_computed_values_fill_opacity(&computed_values.computed_values)
## Ported from Libraries/LibWeb/SVG/SVGGraphicsElement.cpp:249 Web::SVG::SVGGraphicsElement::paint_order.
pub func svg_graphics_element_paint_order(this: SvgGraphicsElement*) -> css_data.PaintOrder[3]:
let node = dom_node_unsafe_layout_node(this.dom_node()) else return css_initial_values_paint_order()
let computed_values = layout_node_computed_values(node)
return css_computed_values_paint_order(&computed_values.computed_values)
## Ported from Libraries/LibWeb/SVG/SVGGraphicsElement.cpp:256 Web::SVG::SVGGraphicsElement::stroke_linecap.
pub func svg_graphics_element_stroke_linecap(this: SvgGraphicsElement*) -> css_data.StrokeLinecap?:
let node = dom_node_unsafe_layout_node(this.dom_node()) else return none
let computed_values = layout_node_computed_values(node)
return css_computed_values_stroke_linecap(&computed_values.computed_values)
## Ported from Libraries/LibWeb/SVG/SVGGraphicsElement.cpp:263 Web::SVG::SVGGraphicsElement::stroke_linejoin.
pub func svg_graphics_element_stroke_linejoin(this: SvgGraphicsElement*) -> css_data.StrokeLinejoin?:
let node = dom_node_unsafe_layout_node(this.dom_node()) else return none
let computed_values = layout_node_computed_values(node)
return css_computed_values_stroke_linejoin(&computed_values.computed_values)
## Ported from Libraries/LibWeb/SVG/SVGGraphicsElement.cpp:270 Web::SVG::SVGGraphicsElement::stroke_miterlimit.
pub func svg_graphics_element_stroke_miterlimit(this: SvgGraphicsElement*) -> f64?:
let node = dom_node_unsafe_layout_node(this.dom_node()) else return none
let computed_values = layout_node_computed_values(node)
return css_computed_values_stroke_miterlimit(&computed_values.computed_values)
## Ported from Libraries/LibWeb/SVG/SVGGraphicsElement.cpp:277 Web::SVG::SVGGraphicsElement::stroke_opacity.
pub func svg_graphics_element_stroke_opacity(this: SvgGraphicsElement*) -> f32?:
let node = dom_node_unsafe_layout_node(this.dom_node()) else return none
let computed_values = layout_node_computed_values(node)
return css_computed_values_stroke_opacity(&computed_values.computed_values)
## Ported from Libraries/LibWeb/SVG/SVGGraphicsElement.cpp:284 Web::SVG::SVGGraphicsElement::resolve_relative_to_viewport_size.
func svg_graphics_element_resolve_relative_to_viewport_size(this: SvgGraphicsElement*, length_percentage: CssLengthPercentage) -> f32:
# FIXME: Converting to pixels isn't really correct - values should be in "user units"
# https://svgwg.org/svg2-draft/coords.html#TermUserUnits
# Resolved relative to the "Scaled viewport size": https://www.w3.org/TR/2017/WD-fill-stroke-3-20170413/#scaled-viewport-size
# FIXME: This isn't right, but it's something.
var viewport_width = gfx.CssPixels.from_int(0)
var viewport_height = gfx.CssPixels.from_int(0)
if let svg_svg_element = dom_node_first_flat_tree_ancestor_of_type(this.dom_node(), &svg_svgsvg_element_class):
if let svg_svg_layout_node = dom_node_unsafe_layout_node(svg_svg_element):
let computed_values = layout_node_computed_values(svg_svg_layout_node)
let width = css_computed_values_width(&computed_values.computed_values)
let height = css_computed_values_height(&computed_values.computed_values)
viewport_width = css_size_to_px(&width, svg_svg_layout_node, gfx.CssPixels.from_int(0))
viewport_height = css_size_to_px(&height, svg_svg_layout_node, gfx.CssPixels.from_int(0))
let scaled_viewport_size = viewport_width.add(viewport_height).mul(gfx.CssPixels.from_f64(0.5))
let node = dom_node_unsafe_layout_node(this.dom_node()) else trap("VERIFY: unsafe_layout_node()")
return (f32)css_percentage_or_to_px(&length_percentage.percentage_or, node, scaled_viewport_size).to_double()
## Ported from Libraries/LibWeb/SVG/SVGGraphicsElement.cpp:302 Web::SVG::SVGGraphicsElement::stroke_dasharray.
pub func svg_graphics_element_stroke_dasharray(this: SvgGraphicsElement*) -> ak.Vector[f32]:
let node = dom_node_unsafe_layout_node(this.dom_node()) else return ak.Vector[f32]()
var dasharray = ak.Vector[f32]()
let computed_values = layout_node_computed_values(node)
let values = css_computed_values_stroke_dasharray(&computed_values.computed_values)
for value in ak.vector_span_const(&values):
match value:
.css_length_percentage(length_percentage):
ak.vector_append_t(&dasharray, svg_graphics_element_resolve_relative_to_viewport_size(this, length_percentage))
.f32_(number):
ak.vector_append_t(&dasharray, number)
# https://svgwg.org/svg2-draft/painting.html#StrokeDashing
# If the list has an odd number of values, then it is repeated to yield an even number of values.
if ak.vector_size(&dasharray) % 2 == 1:
let copy = ak.vector_clone(&dasharray)
ak.vector_extend_2(&dasharray, ©)
# If any value in the list is negative, the <dasharray> value is invalid. If all of the values in the list are zero, then the stroke is rendered as a solid line without any dashing.
var all_zero = true
for value in ak.vector_span_const(&dasharray):
if value < 0.0:
return ak.Vector[f32]()
if value != 0.0:
all_zero = false
if all_zero:
return ak.Vector[f32]()
return dasharray
## Ported from Libraries/LibWeb/SVG/SVGGraphicsElement.cpp:337 Web::SVG::SVGGraphicsElement::stroke_dashoffset.
pub func svg_graphics_element_stroke_dashoffset(this: SvgGraphicsElement*) -> f32?:
let node = dom_node_unsafe_layout_node(this.dom_node()) else return none
let computed_values = layout_node_computed_values(node)
return svg_graphics_element_resolve_relative_to_viewport_size(this, css_computed_values_stroke_dashoffset(&computed_values.computed_values))
## Ported from Libraries/LibWeb/SVG/SVGGraphicsElement.cpp:344 Web::SVG::SVGGraphicsElement::stroke_width.
pub func svg_graphics_element_stroke_width(this: SvgGraphicsElement*) -> f32?:
let node = dom_node_unsafe_layout_node(this.dom_node()) else return none
let computed_values = layout_node_computed_values(node)
return svg_graphics_element_resolve_relative_to_viewport_size(this, css_computed_values_stroke_width(&computed_values.computed_values))
# mark: SVG DOM ==================================================================================
## Ported from Libraries/LibWeb/SVG/SVGGraphicsElement.cpp:352 Web::SVG::SVGGraphicsElement::get_b_box.
# https://svgwg.org/svg2-draft/types.html#__svg__SVGGraphicsElement__getBBox
pub func svg_graphics_element_get_b_box(this: SvgGraphicsElement*, arg0: SvgBoundingBoxOptions?) -> GeometryDomRect*!:
let realm = dom_element_realm(this.dom_element())
# FIXME: It should be possible to compute this without layout updates. The bounding box is within the
# SVG coordinate space (before any viewbox or other transformations), so it should be possible to
# calculate this from SVG geometry without a full layout tree (at least for simple cases).
# See: https://svgwg.org/svg2-draft/coords.html#BoundingBoxes
dom_document_update_layout_if_needed_for_node(dom_node_document(this.dom_node()), this.dom_node(), DomUpdateLayoutReason.svg_graphics_element_get_b_box)
if dom_node_layout_node(this.dom_node()) == none:
return geometry_dom_rect_create_realm(realm)
# Invert the SVG -> screen space transform.
let owner_svg_element = svg_element_owner_svg_element(this.svg_element()) else return geometry_dom_rect_create_realm(realm)
let owner_paintable = dom_node_paintable_box(owner_svg_element.dom_node())
let self_paintable = dom_node_paintable_box(this.dom_node())
if owner_paintable == none or self_paintable == none:
# Throw only for non-rendered *graphics* elements where geometry isn't computable
# (e.g. elements inside <marker>, <pattern>, etc.).
if is_svg_svgsvg_element(this):
return geometry_dom_rect_create_realm(realm)
return try idl_throw(.idl_dom_exception(idl_invalid_state_error_create(realm, ak.utf16_string_from_str("Element is not rendered and geometry is not computable"))))
let owner = owner_paintable else trap("VERIFY: owner_paintable")
let self_box = self_paintable else trap("VERIFY: self_paintable")
let svg_rect = paint_paintable_box_absolute_rect(owner)
let transforms = paint_svg_graphics_paintable_computed_transforms(as_paint_svg_graphics_paintable(self_box))
let svg_to_css = paint_svg_graphics_paintable_computed_transforms_svg_to_css_pixels_transform(&transforms)
let inv = gfx.affine_transform_inverse(&svg_to_css)
let self_rect = paint_paintable_box_absolute_rect(self_box)
let float_rect = gfx.css_pixel_rect_to_type_f32(&self_rect)
let svg_location = gfx.css_pixel_rect_location(&svg_rect)
let svg_float_location = gfx.css_pixel_point_to_type_f32(&svg_location)
var rect = gfx.float_rect_translated_float_point(&float_rect, gfx.float_point_neg(&svg_float_location))
if let inverse = inv:
rect = gfx.affine_transform_map_f32_float_rect(&inverse, rect)
return geometry_dom_rect_create(realm, rect)
## Ported from Libraries/LibWeb/SVG/SVGGraphicsElement.cpp:386 Web::SVG::SVGGraphicsElement::transform.
pub func svg_graphics_element_transform(this: SvgGraphicsElement*) -> SvgAnimatedTransformList*:
let realm = dom_element_realm(this.dom_element())
svg_graphics_element_dbgln_stubbed(this, "SVGGraphicsElement::transform()")
let base_val = svg_transform_list_create_svg_read_only_list(realm, SvgReadOnlyList.yes)
let anim_val = svg_transform_list_create_svg_read_only_list(realm, SvgReadOnlyList.yes)
return svg_animated_transform_list_create(realm, base_val, anim_val)
## Ported from Libraries/LibWeb/SVG/SVGGraphicsElement.cpp:394 Web::SVG::SVGGraphicsElement::get_screen_ctm.
pub func svg_graphics_element_get_screen_ctm(this: SvgGraphicsElement*) -> GeometryDomMatrix*?:
svg_graphics_element_dbgln_stubbed(this, "SVGGraphicsElement::get_screen_ctm()")
return geometry_dom_matrix_create(dom_element_realm(this.dom_element()))
## Ported from Libraries/LibWeb/SVG/SVGGraphicsElement.cpp:400 Web::SVG::SVGGraphicsElement::get_ctm.
pub func svg_graphics_element_get_ctm(this: SvgGraphicsElement*) -> GeometryDomMatrix*?:
svg_graphics_element_dbgln_stubbed(this, "SVGGraphicsElement::get_ctm()")
return geometry_dom_matrix_create(dom_element_realm(this.dom_element()))
## `dbgln("(STUBBED) {}. Called on: {}", what, debug_description())`.
func svg_graphics_element_dbgln_stubbed(this: SvgGraphicsElement*, what: str):
let description = dom_node_debug_description(this.dom_node())
ak.dbgln(f"(STUBBED) {what}. Called on: {ak.string_view_text(ak.string_bytes_as_string_view(&description))}")
# mark: SVGGraphicsElement.h =====================================================================
## Ported from Libraries/LibWeb/SVG/SVGGraphicsElement.h:51 Web::SVG::SVGGraphicsElement::active_view_box (virtual).
pub func svg_graphics_element_active_view_box_impl(this: SvgGraphicsElement*) -> SvgViewBox?:
if let svg_fit_to_view_box = as_if_svg_fit_to_view_box(this):
return svg_fit_to_view_box_view_box(svg_fit_to_view_box)
return none
## Ported from Libraries/LibWeb/SVG/SVGGraphicsElement.h:58 Web::SVG::SVGGraphicsElement::visible_stroke_width.
pub func svg_graphics_element_visible_stroke_width(this: SvgGraphicsElement*) -> f32:
if let color = svg_graphics_element_stroke_color(this):
if gfx.color_alpha(&color) > 0:
return svg_graphics_element_stroke_width(this) else 0.0
return 0.0
## Ported from Libraries/LibWeb/SVG/SVGGraphicsElement.h:80 Web::SVG::SVGGraphicsElement::element_transform (virtual).
pub func svg_graphics_element_element_transform_impl(this: SvgGraphicsElement*) -> gfx.AffineTransform:
return this.m_transform
## Ported from Libraries/LibWeb/SVG/SVGGraphicsElement.h:103 Web::SVG::SVGGraphicsElement::is_svg_graphics_element (override).
pub func svg_graphics_element_is_svg_graphics_element_impl(base: DomNode*) -> bool:
return true