⚠️ VeridianOS Kernel Documentation - This is low-level kernel code. All functions are unsafe unless explicitly marked otherwise. no_std

DomApi

Struct DomApi 

Source
pub struct DomApi {
    pub event_dispatcher: EventDispatcher,
    pub timer_queue: TimerQueue,
    pub console_output: Vec<String>,
    pub navigation_requests: Vec<String>,
    /* private fields */
}
Expand description

Bridge between JS VM and DOM tree

Fields§

§event_dispatcher: EventDispatcher

Event dispatcher

§timer_queue: TimerQueue

Timer queue

§console_output: Vec<String>

Console output

§navigation_requests: Vec<String>

Navigation requests (URLs to load)

Implementations§

Source§

impl DomApi

Source

pub fn new() -> Self

Source

pub fn get_node(&self, id: NodeId) -> Option<&DomNode>

Get a node by ID

Source

pub fn get_node_mut(&mut self, id: NodeId) -> Option<&mut DomNode>

Get a mutable node by ID

Source

pub fn node_count(&self) -> usize

Total number of nodes

Source

pub fn get_element_by_id(&self, element_id: &str) -> Option<NodeId>

document.getElementById(id) -> NodeId or None

Source

pub fn create_element(&mut self, tag: &str) -> NodeId

document.createElement(tag) -> NodeId

Source

pub fn create_text_node(&mut self, text: &str) -> NodeId

document.createTextNode(text) -> NodeId

Source

pub fn query_selector(&self, selector: &str) -> Option<NodeId>

Simple querySelector by tag name (first match)

Source

pub fn get_attribute(&self, node_id: NodeId, name: &str) -> Option<String>

element.getAttribute(name)

Source

pub fn set_attribute(&mut self, node_id: NodeId, name: &str, value: &str)

element.setAttribute(name, value)

Source

pub fn append_child(&mut self, parent_id: NodeId, child_id: NodeId) -> bool

element.appendChild(child)

Source

pub fn remove_child(&mut self, parent_id: NodeId, child_id: NodeId) -> bool

element.removeChild(child)

Source

pub fn get_text_content(&self, node_id: NodeId) -> String

element.textContent (getter)

Source

pub fn set_text_content(&mut self, node_id: NodeId, text: &str)

element.textContent = value (setter)

Source

pub fn get_inner_html(&self, node_id: NodeId) -> String

element.innerHTML (getter)

Source

pub fn set_inner_html(&mut self, node_id: NodeId, html: &str)

element.innerHTML = value (setter)

Source

pub fn set_style_property(&mut self, node_id: NodeId, name: &str, value: &str)

element.style.setProperty(name, value)

Source

pub fn get_style_property(&self, node_id: NodeId, name: &str) -> Option<String>

element.style.getPropertyValue(name)

Source

pub fn add_event_listener( &mut self, node_id: NodeId, event_type: EventType, callback_id: usize, )

addEventListener(node, type, callback_id)

Source

pub fn remove_event_listener( &mut self, node_id: NodeId, event_type: EventType, callback_id: usize, )

removeEventListener(node, type, callback_id)

Source

pub fn console_log(&mut self, message: &str)

console.log(args…)

Source

pub fn console_error(&mut self, message: &str)

console.error(args…)

Source

pub fn window_alert(&mut self, message: &str)

window.alert(message) – stub

Source

pub fn register_element_id(&mut self, node_id: NodeId, element_id: &str)

Register a node’s element ID in the lookup map

Trait Implementations§

Source§

impl Default for DomApi

Source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl Freeze for DomApi

§

impl RefUnwindSafe for DomApi

§

impl Send for DomApi

§

impl Sync for DomApi

§

impl Unpin for DomApi

§

impl UnwindSafe for DomApi

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn into(self) -> U

Calls U::from(self).

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

§

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

§

type Error = Infallible

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

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

Performs the conversion.
§

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

§

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

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

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

Performs the conversion.