Skip to main content

HTMLCanvas

Struct HTMLCanvas 

Source
pub struct HTMLCanvas { /* private fields */ }
Expand description

Per-frame DOM builder: creates/updates cotis-{id} elements and manages clip stacks.

One instance should be created per frame via HTMLCanvas::new and consumed with HTMLCanvas::finish. Commands that share a render id reuse the same host element.

Implementations§

Source§

impl HTMLCanvas

Source

pub fn new() -> Self

Starts a new rendering frame (calls JS beginFrame).

§WASM

Requires an initialized HTML root (init_html_root in renderer.js).

Source

pub fn ensure_command_element( &mut self, command_id: u32, html_type: &str, extra_style: Option<&str>, )

Opens or reuses the host element for a render command. Multiple drawables that share the same command_id accumulate current_element_css_push on one DOM node (cotis-{id}).

Source

pub fn current_element_css_push(&mut self, value: &str) -> &mut Self

Add CSS properties to the current element. Properties are parsed from CSS syntax. If a property already exists, it will be overwritten. Example: “background-color: red; padding: 10px”

Source

pub fn set_text_content(&mut self, text: String)

Set the text content of the current element (internal use)

Source

pub fn set_inner_html(&mut self, html: String)

Set innerHTML for the current element (e.g. custom HTML hosts)

Source

pub fn new_element(&mut self, prefix: &str, html_type: &str) -> &mut Self

Create a new child element. This finalizes the current element and starts building a new one.

§Arguments
  • prefix - A prefix for the element ID (for debugging/identification)
  • html_type - The HTML tag name (e.g., “div”, “button”, “span”)
Source

pub fn finish(self)

Commits the frame and removes DOM nodes not referenced in used_element_ids.

Consumes self. Must be called once per frame after all drawables have run.

Trait Implementations§

Source§

impl Default for HTMLCanvas

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<H, TailTarget, Source, Idx> Embed<RenderTList<H, TailTarget>, There<Idx>> for Source
where TailTarget: IsRenderList, Source: Embed<TailTarget, Idx>,

Source§

fn embed(self) -> RenderTList<H, TailTarget>

Converts self into Target.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more