Skip to main content

StyledDom

Struct StyledDom 

Source
#[repr(C)]
pub struct StyledDom { pub root: NodeHierarchyItemId, pub node_hierarchy: NodeHierarchyItemVec, pub node_data: NodeDataVec, pub styled_nodes: StyledNodeVec, pub cascade_info: CascadeInfoVec, pub nodes_with_window_callbacks: NodeIdVec, pub nodes_with_not_callbacks: NodeIdVec, pub nodes_with_datasets: NodeIdVec, pub tag_ids_to_node_ids: TagIdToNodeIdMappingVec, pub non_leaf_nodes: ParentWithNodeDepthVec, pub css_property_cache: CssPropertyCachePtr, pub dom_id: DomId, }

Fields§

§root: NodeHierarchyItemId§node_hierarchy: NodeHierarchyItemVec§node_data: NodeDataVec§styled_nodes: StyledNodeVec§cascade_info: CascadeInfoVec§nodes_with_window_callbacks: NodeIdVec§nodes_with_not_callbacks: NodeIdVec§nodes_with_datasets: NodeIdVec§tag_ids_to_node_ids: TagIdToNodeIdMappingVec§non_leaf_nodes: ParentWithNodeDepthVec§css_property_cache: CssPropertyCachePtr§dom_id: DomId

The ID of this DOM in the layout tree (for multi-DOM support with IFrames)

Implementations§

Source§

impl StyledDom

Source

pub fn create(dom: &mut Dom, css: Css) -> Self

Creates a new StyledDom by applying CSS styles to a DOM tree.

NOTE: After calling this function, the DOM will be reset to an empty DOM.

Source

pub fn append_child(&mut self, other: Self)

Appends another StyledDom as a child to the self.root without re-styling the DOM itself

Source

pub fn with_child(self, other: Self) -> Self

Same as append_child(), but as a builder method

Source

pub fn set_context_menu(&mut self, context_menu: Menu)

Sets the context menu for the root node

Source

pub fn with_context_menu(self, context_menu: Menu) -> Self

Builder method for setting the context menu

Source

pub fn set_menu_bar(&mut self, menu_bar: Menu)

Sets the menu bar for the root node

Source

pub fn with_menu_bar(self, menu_bar: Menu) -> Self

Builder method for setting the menu bar

Source

pub fn restyle(&mut self, css: Css)

Re-applies CSS styles to the existing DOM structure.

Source

pub fn node_count(&self) -> usize

Returns the total number of nodes in this StyledDom.

Source

pub fn get_css_property_cache<'a>(&'a self) -> &'a CssPropertyCache

Returns an immutable reference to the CSS property cache.

Source

pub fn get_css_property_cache_mut<'a>(&'a mut self) -> &'a mut CssPropertyCache

Returns a mutable reference to the CSS property cache.

Source

pub fn get_styled_node_state(&self, node_id: &NodeId) -> StyledNodeState

Returns the current state (hover, active, focus) of a styled node.

Source

pub fn scan_for_image_keys( &self, css_image_cache: &ImageCache, ) -> FastBTreeSet<ImageRef>

Scans the display list for all image keys

Source

pub fn restyle_nodes_hover( &mut self, nodes: &[NodeId], new_hover_state: bool, ) -> BTreeMap<NodeId, Vec<ChangedCssProperty>>

Updates hover state for nodes and returns changed CSS properties.

Source

pub fn restyle_nodes_active( &mut self, nodes: &[NodeId], new_active_state: bool, ) -> BTreeMap<NodeId, Vec<ChangedCssProperty>>

Updates active state for nodes and returns changed CSS properties.

Source

pub fn restyle_nodes_focus( &mut self, nodes: &[NodeId], new_focus_state: bool, ) -> BTreeMap<NodeId, Vec<ChangedCssProperty>>

Updates focus state for nodes and returns changed CSS properties.

Source

pub fn restyle_on_state_change( &mut self, focus_changes: Option<FocusChange>, hover_changes: Option<HoverChange>, active_changes: Option<ActiveChange>, ) -> RestyleResult

Unified entry point for all CSS restyle operations.

This function synchronizes the StyledNodeState with runtime state and computes which CSS properties have changed. It determines whether layout, display list, or GPU-only updates are needed.

§Arguments
  • focus_changes - Nodes gaining/losing focus
  • hover_changes - Nodes gaining/losing hover
  • active_changes - Nodes gaining/losing active (mouse down)
§Returns
  • RestyleResult containing changed nodes and what needs updating
Source

pub fn restyle_user_property( &mut self, node_id: &NodeId, new_properties: &[CssProperty], ) -> BTreeMap<NodeId, Vec<ChangedCssProperty>>

Overrides CSS properties for a node and returns changed properties.

Source

pub fn scan_for_iframe_callbacks(&self) -> Vec<NodeId>

Scans the StyledDom for iframe callbacks

Source

pub fn scan_for_gltexture_callbacks(&self) -> Vec<NodeId>

Scans the StyledDom for OpenGL callbacks

Source

pub fn get_html_string( &self, custom_head: &str, custom_body: &str, test_mode: bool, ) -> String

Returns a HTML-formatted version of the DOM for easier debugging.

For example, a DOM with a parent div containing a child div would return:

<div id="hello">
     <div id="test" />
</div>
Source

pub fn get_subtree(&self, parent: NodeId) -> Vec<NodeId>

Returns the node ID of all sub-children of a node

Source

pub fn get_subtree_parents(&self, parent: NodeId) -> Vec<NodeId>

Returns node IDs of all parent nodes in the subtree (nodes with children).

Source

pub fn get_rects_in_rendering_order(&self) -> ContentGroup

Returns nodes grouped by their rendering order (respects z-index and position).

Source

pub fn swap_with_default(&mut self) -> Self

Replaces this StyledDom with default and returns the old value.

Trait Implementations§

Source§

impl Clone for StyledDom

Source§

fn clone(&self) -> StyledDom

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for StyledDom

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for StyledDom

Source§

fn default() -> Self

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

impl Into<StyledDom> for DomXml

Source§

fn into(self) -> StyledDom

Converts this type into the (usually inferred) input type.
Source§

impl PartialEq for StyledDom

Source§

fn eq(&self, other: &StyledDom) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for StyledDom

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<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.