dymokomi/luce-browser-engine
Source of release 0.6.0
0.6.0 / src / web / painting / svg_foreign_object_paintable.lucb
#==============================================================================================
#
# svg_foreign_object_paintable - Painting::SVGForeignObjectPaintable: the paintable of a
# <foreignObject>
#
# DESCRIPTION:
# Port of LibWeb/Painting/SVGForeignObjectPaintable.cpp (lines 1-42) and
# SVGForeignObjectPaintable.h: creation, the layout box, hit testing and painting (as
# its lines, when visible) and the SVGMaskable overrides.
#
# Copyright (c) 2024, Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
# SPDX-License-Identifier: BSD-2-Clause
#
#==============================================================================================
## Ported from Libraries/LibWeb/Painting/SVGForeignObjectPaintable.cpp:14 Web::Painting::SVGForeignObjectPaintable::create.
pub func paint_svg_foreign_object_paintable_create(layout_box: LayoutSvgForeignObjectBox*) -> PaintSvgForeignObjectPaintable*:
let heap = gc.cell_heap(layout_box.cell())
let this = (PaintSvgForeignObjectPaintable*)web_heap_allocate_cell(heap, &paint_svg_foreign_object_paintable_class)
gc.heap_defer_gc(heap)
paint_svg_foreign_object_paintable_construct(this, layout_box)
gc.heap_undefer_gc(heap)
return this
## Ported from Libraries/LibWeb/Painting/SVGForeignObjectPaintable.cpp:29 Web::Painting::SVGForeignObjectPaintable::hit_test (override).
pub func paint_svg_foreign_object_paintable_hit_test_impl(base: PaintPaintable*, position: gfx.CssPixelPoint, type_: PaintHitTestType, callback: ak.Function1[PaintHitTestResult, TraversalDecision]) -> TraversalDecision:
return paint_paintable_with_lines_hit_test_impl(base, position, type_, callback)
## Ported from Libraries/LibWeb/Painting/SVGForeignObjectPaintable.cpp:34 Web::Painting::SVGForeignObjectPaintable::paint (override).
pub func paint_svg_foreign_object_paintable_paint_impl(base: PaintPaintable*, context: DisplayListRecordingContext*, phase: PaintPhase):
if not paint_paintable_is_visible(base):
return
paint_paintable_with_lines_paint_impl(base, context, phase)
## Ported from Libraries/LibWeb/Painting/SVGForeignObjectPaintable.cpp:24 Web::Painting::SVGForeignObjectPaintable::layout_box.
pub func paint_svg_foreign_object_paintable_layout_box(this: PaintSvgForeignObjectPaintable*) -> LayoutSvgForeignObjectBox*:
return (LayoutSvgForeignObjectBox*)paint_paintable_layout_node(this.paint_paintable())
## The SVGForeignObjectPaintable an SVGMaskable base belongs to (the C++ `this` adjustment).
func paint_svg_foreign_object_paintable_from_svg_maskable(maskable: PaintSvgMaskable*) -> PaintSvgForeignObjectPaintable*:
return (PaintSvgForeignObjectPaintable*)((u8*)maskable - memory.offset_of(PaintSvgForeignObjectPaintable, svg_maskable))
## Ported from Libraries/LibWeb/Painting/SVGForeignObjectPaintable.h:30 Web::Painting::SVGForeignObjectPaintable::dom_node_of_svg (override).
pub func paint_svg_foreign_object_paintable_dom_node_of_svg_impl(base: PaintSvgMaskable*) -> DomNode*?:
return paint_paintable_dom_node(paint_svg_foreign_object_paintable_from_svg_maskable(base).paint_paintable())
## Ported from Libraries/LibWeb/Painting/SVGForeignObjectPaintable.h:31 Web::Painting::SVGForeignObjectPaintable::get_mask_area (override).
pub func paint_svg_foreign_object_paintable_get_mask_area_impl(base: PaintPaintableBox*) -> gfx.CssPixelRect?:
return paint_svg_maskable_get_svg_mask_area(&((PaintSvgForeignObjectPaintable*)base).svg_maskable)
## Ported from Libraries/LibWeb/Painting/SVGForeignObjectPaintable.h:32 Web::Painting::SVGForeignObjectPaintable::get_mask_type (override).
pub func paint_svg_foreign_object_paintable_get_mask_type_impl(base: PaintPaintableBox*) -> gfx.MaskKind?:
return paint_svg_maskable_get_svg_mask_type(&((PaintSvgForeignObjectPaintable*)base).svg_maskable)
## Ported from Libraries/LibWeb/Painting/SVGForeignObjectPaintable.h:33 Web::Painting::SVGForeignObjectPaintable::calculate_mask (override).
pub func paint_svg_foreign_object_paintable_calculate_mask_impl(base: PaintPaintableBox*, context: DisplayListRecordingContext*, mask_area: gfx.CssPixelRect) -> display_list.DisplayList*?:
return paint_svg_maskable_calculate_svg_mask_display_list(&((PaintSvgForeignObjectPaintable*)base).svg_maskable, context, mask_area)
## Ported from Libraries/LibWeb/Painting/SVGForeignObjectPaintable.h:34 Web::Painting::SVGForeignObjectPaintable::get_clip_area (override).
pub func paint_svg_foreign_object_paintable_get_clip_area_impl(base: PaintPaintableBox*) -> gfx.CssPixelRect?:
return paint_svg_maskable_get_svg_clip_area(&((PaintSvgForeignObjectPaintable*)base).svg_maskable)
## Ported from Libraries/LibWeb/Painting/SVGForeignObjectPaintable.h:35 Web::Painting::SVGForeignObjectPaintable::calculate_clip (override).
pub func paint_svg_foreign_object_paintable_calculate_clip_impl(base: PaintPaintableBox*, context: DisplayListRecordingContext*, clip_area: gfx.CssPixelRect) -> display_list.DisplayList*?:
return paint_svg_maskable_calculate_svg_clip_display_list(&((PaintSvgForeignObjectPaintable*)base).svg_maskable, context, clip_area)
## Ported from Libraries/LibWeb/Painting/SVGForeignObjectPaintable.cpp:19 Web::Painting::SVGForeignObjectPaintable::SVGForeignObjectPaintable.
pub func paint_svg_foreign_object_paintable_construct(this: PaintSvgForeignObjectPaintable*, layout_box: LayoutSvgForeignObjectBox*):
paint_paintable_with_lines_construct_layout_block_container(this.paint_paintable_with_lines(), layout_box.layout_block_container())
# The SVGMaskable base's vptr.
this.svg_maskable.vtable = &paint_svg_foreign_object_paintable_svg_maskable_vtable
this.svg_maskable.class_id = this.cell().class_id