dymokomi/luce-browser-engine
Source of release 0.6.0
0.6.0 / src / web / painting / text_paintable.lucb
#==============================================================================================
#
# text_paintable - Painting::TextPaintable: the paintable of a text node
#
# DESCRIPTION:
# Port of LibWeb/Painting/TextPaintable.cpp (lines 1-35) and TextPaintable.h: a text
# node's paintable (its text is painted by the PaintableWithLines that holds its
# fragments) and its inspector overlay, which highlights those fragments.
#
# Copyright (c) 2022, Andreas Kling <andreas@ladybird.org>
# SPDX-License-Identifier: BSD-2-Clause
#
#==============================================================================================
## Ported from Libraries/LibWeb/Painting/TextPaintable.cpp:14 Web::Painting::TextPaintable::create.
pub func paint_text_paintable_create(layout_node: LayoutTextNode*) -> PaintTextPaintable*:
let heap = gc.cell_heap(layout_node.cell())
let this = (PaintTextPaintable*)web_heap_allocate_cell(heap, &paint_text_paintable_class)
gc.heap_defer_gc(heap)
paint_text_paintable_construct(this, layout_node)
gc.heap_undefer_gc(heap)
return this
## Ported from Libraries/LibWeb/Painting/TextPaintable.cpp:19 Web::Painting::TextPaintable::TextPaintable.
pub func paint_text_paintable_construct(this: PaintTextPaintable*, layout_node: LayoutTextNode*):
paint_paintable_construct(this.paint_paintable(), layout_node.layout_node())
## Ported from Libraries/LibWeb/Painting/TextPaintable.h:21 Web::Painting::TextPaintable::layout_node.
pub func paint_text_paintable_layout_node(this: PaintTextPaintable*) -> LayoutTextNode*:
return (LayoutTextNode*)paint_paintable_layout_node(this.paint_paintable())
## Ported from Libraries/LibWeb/Painting/TextPaintable.h:27 Web::Painting::TextPaintable::is_text_paintable (override).
pub func paint_text_paintable_is_text_paintable_impl(base: PaintPaintable*) -> bool:
_ = base
return true
## Ported from Libraries/LibWeb/Painting/TextPaintable.cpp:24 Web::Painting::TextPaintable::paint_inspector_overlay_internal (override).
pub func paint_text_paintable_paint_inspector_overlay_internal_impl(base: PaintPaintable*, context: DisplayListRecordingContext*):
let parent = tree_node_parent(base) else return
let parent_paintable = as_if_paint_paintable_with_lines(parent) else return
for fragment in &ak.vector_span(paint_paintable_with_lines_fragments(parent_paintable)):
if paint_paintable_fragment_paintable(fragment) == base:
paint_paintable_with_lines_paint_text_fragment_debug_highlight(context, fragment)