Sign in

    mizchi/crater/dom does not have a README file

    CoreError

    pub enum CoreError {
    NodeNotFound(NodeId)
    InvalidOperation(String)
    }

    Core error types
    impl Show for CoreError

    DomNode

    type DomNode

    Internal DOM node representation

    DomTree

    pub struct DomTree {
    next_id : Int
    nodes : Map[Int, DomNode]
    root_id : Int
    focused_node : Int?
    mutations : MutationQueue
    }

    DOM Tree - the core document structure This is the single source of truth for all DOM operations

    DomTree::append_child

    fn DomTree::append_child(self : DomTree, parent : NodeId, child : NodeId) -> Result[Unit, CoreError]

    Append child to parent

    DomTree::clear_mutations

    fn DomTree::clear_mutations(self : DomTree) -> Unit

    Clear all pending mutations without processing

    DomTree::create_comment

    fn DomTree::create_comment(self : DomTree, content : String) -> NodeId

    Create a comment node

    DomTree::create_element

    fn DomTree::create_element(self : DomTree, tag_name : String) -> NodeId

    Create an element node

    DomTree::create_text

    fn DomTree::create_text(self : DomTree, content : String) -> NodeId

    Create a text node

    DomTree::flush_mutations

    fn DomTree::flush_mutations(self : DomTree) -> (Array[MutationRecord], FlushResult)

    Flush pending mutations and return optimized records Returns (records, result) where records is the optimized mutation list and result contains statistics about the flush operation

    DomTree::flush_mutations_with

    fn[T] DomTree::flush_mutations_with(self : DomTree, handler : (MutationRecord) -> T) -> (Array[T], FlushResult)

    Flush mutations with a custom handler for each record Useful for applying mutations to other systems (e.g., LayoutTree)

    DomTree::get_attribute

    fn DomTree::get_attribute(self : DomTree, node : NodeId, name : String) -> Result[String?, CoreError]

    Get attribute from element

    DomTree::get_attributes

    fn DomTree::get_attributes(self : DomTree, node : NodeId) -> Result[Array[(String, String)], CoreError]

    Get all attributes

    DomTree::get_bbox

    fn DomTree::get_bbox(self : DomTree, node_id : NodeId, options? : GetBBoxOptions) -> SVGRect?

    Get the bounding box of an SVG element Returns the tight bounding box in user space coordinates

    DomTree::get_cached_rect

    fn DomTree::get_cached_rect(self : DomTree, node : NodeId) -> Rect?

    Get cached rect

    DomTree::get_children

    fn DomTree::get_children(self : DomTree, node : NodeId) -> Result[Array[NodeId], CoreError]

    Get child nodes

    DomTree::get_ctm

    fn DomTree::get_ctm(self : DomTree, node_id : NodeId) -> SVGMatrix?

    Get the Current Transformation Matrix (CTM) Returns the transformation from user space to viewport

    DomTree::get_document

    fn DomTree::get_document(self : DomTree) -> NodeId

    Get document root

    DomTree::get_first_child

    fn DomTree::get_first_child(self : DomTree, node : NodeId) -> Result[NodeId?, CoreError]

    Get first child

    DomTree::get_focus

    fn DomTree::get_focus(self : DomTree) -> NodeId?

    Get focused element

    DomTree::get_mutation_queue

    fn DomTree::get_mutation_queue(self : DomTree) -> MutationQueue

    Get direct access to the mutation queue (for advanced use cases)

    DomTree::get_next_sibling

    fn DomTree::get_next_sibling(self : DomTree, node : NodeId) -> Result[NodeId?, CoreError]

    Get next sibling

    DomTree::get_node_info

    fn DomTree::get_node_info(self : DomTree, node : NodeId) -> Result[NodeInfo, CoreError]

    Get node info

    DomTree::get_parent

    fn DomTree::get_parent(self : DomTree, node : NodeId) -> Result[NodeId?, CoreError]

    Get parent node

    DomTree::get_screen_ctm

    fn DomTree::get_screen_ctm(self : DomTree, node_id : NodeId) -> SVGMatrix?

    Get the Screen CTM Returns the transformation from user space to screen pixels

    DomTree::get_tag_name

    fn DomTree::get_tag_name(self : DomTree, node : NodeId) -> Result[String, CoreError]

    Get tag name

    DomTree::get_text_content

    fn DomTree::get_text_content(self : DomTree, node : NodeId) -> Result[String, CoreError]

    Get text content

    DomTree::has_pending_mutations

    fn DomTree::has_pending_mutations(self : DomTree) -> Bool

    Check if there are pending mutations

    DomTree::insert_before

    fn DomTree::insert_before(self : DomTree, parent : NodeId, child : NodeId, reference : NodeId?) -> Result[Unit, CoreError]

    Insert child before reference node

    DomTree::new

    fn DomTree::new() -> DomTree

    Create a new empty DOM tree

    DomTree::pending_mutation_count

    fn DomTree::pending_mutation_count(self : DomTree) -> Int

    Get number of pending mutations

    DomTree::query_selector

    fn DomTree::query_selector(self : DomTree, root : NodeId, selector : String) -> Result[NodeId?, CoreError]

    Query selector (simple CSS selector support) Returns first matching node

    DomTree::query_selector_all

    fn DomTree::query_selector_all(self : DomTree, root : NodeId, selector : String) -> Result[Array[NodeId], CoreError]

    Query selector all Returns all matching nodes

    DomTree::remove_attribute

    fn DomTree::remove_attribute(self : DomTree, node : NodeId, name : String) -> Result[Unit, CoreError]

    Remove attribute from element

    DomTree::remove_child

    fn DomTree::remove_child(self : DomTree, parent : NodeId, child : NodeId) -> Result[Unit, CoreError]

    Remove child from parent

    DomTree::set_attribute

    fn DomTree::set_attribute(self : DomTree, node : NodeId, name : String, value : String) -> Result[Unit, CoreError]

    Set attribute on element

    DomTree::set_cached_rect

    fn DomTree::set_cached_rect(self : DomTree, node : NodeId, rect : Rect) -> Unit

    Set cached rect (called by layout engine)

    DomTree::set_focus

    fn DomTree::set_focus(self : DomTree, node : NodeId?) -> Unit

    Set focused element

    DomTree::set_text_content

    fn DomTree::set_text_content(self : DomTree, node : NodeId, content : String) -> Result[Unit, CoreError]

    Set text content

    FlushResult

    pub struct FlushResult {
    processed : Int
    nodes_affected : Int
    needs_layout : Bool
    }

    Result of flushing the mutation queue
    impl Show for FlushResult

    GetBBoxOptions

    pub struct GetBBoxOptions {
    fill : Bool
    stroke : Bool
    markers : Bool
    clipped : Bool
    }

    Options for getBBox() method Corresponds to SVGBoundingBoxOptions in the spec

    GetBBoxOptions::all

    Create getBBox options with all geometry

    GetBBoxOptions::default

    Default getBBox options (fill only)

    MutationQueue

    pub struct MutationQueue {
    records : Array[MutationRecord]
    dirty_nodes : Map[Int, Bool]
    is_flushing : Bool
    deferred : Array[MutationRecord]
    }

    Queue for batching mutations

    MutationQueue::clear

    fn MutationQueue::clear(self : MutationQueue) -> Unit

    Clear all pending mutations without processing

    MutationQueue::flush

    Flush the queue and return optimized records for processing The caller is responsible for applying these to the layout tree

    MutationQueue::flush_with

    fn[T] MutationQueue::flush_with(self : MutationQueue, handler : (MutationRecord) -> T) -> (Array[T], FlushResult)

    Process mutations with a callback for each record Returns the flush result

    MutationQueue::has_pending

    fn MutationQueue::has_pending(self : MutationQueue, node : NodeId) -> Bool

    Check if a node has pending mutations

    MutationQueue::is_empty

    fn MutationQueue::is_empty(self : MutationQueue) -> Bool

    Check if queue is empty

    MutationQueue::length

    fn MutationQueue::length(self : MutationQueue) -> Int

    Get number of pending mutations

    MutationQueue::new

    Create a new empty mutation queue

    MutationQueue::optimize

    Optimize the queue by merging related mutations

    MutationQueue::push

    fn MutationQueue::push(self : MutationQueue, record : MutationRecord) -> Unit

    Add a mutation record to the queue

    MutationRecord

    pub struct MutationRecord {
    type_ : MutationType
    target : NodeId
    added_nodes : Array[NodeId]
    removed_nodes : Array[NodeId]
    attribute_name : String?
    old_value : String?
    new_value : String?
    changed_properties : Array[String]
    }

    Record of a single DOM mutation

    MutationRecord::affects_layout

    fn MutationRecord::affects_layout(self : MutationRecord) -> Bool

    Check if this mutation affects layout (vs paint-only)

    MutationRecord::attribute

    fn MutationRecord::attribute(target : NodeId, name : String, old_value? : String?, new_value? : String?) -> MutationRecord

    Create an Attributes mutation record

    MutationRecord::character_data

    fn MutationRecord::character_data(target : NodeId, old_value? : String?, new_value? : String?) -> MutationRecord

    Create a CharacterData mutation record

    MutationRecord::child_list

    fn MutationRecord::child_list(target : NodeId, added? : Array[NodeId], removed? : Array[NodeId]) -> MutationRecord

    Create a ChildList mutation record

    MutationRecord::style_change

    fn MutationRecord::style_change(target : NodeId, properties : Array[String]) -> MutationRecord

    Create a StyleChange mutation record

    MutationType

    pub enum MutationType {
    ChildList
    Attributes
    CharacterData
    StyleChange
    }

    Type of DOM mutation
    impl Eq for MutationType

    NodeId

    pub type NodeId Int

    Node identifier - opaque handle to a DOM node
    impl Eq for NodeId
    impl Hash for NodeId
    impl Show for NodeId

    NodeId::from_int

    fn NodeId::from_int(id : Int) -> NodeId

    Create NodeId from Int

    NodeId::inner

    #deprecated("Use `struct T(A)` to declare a newtype and use `.0` access the underlying type instead.")
    fn NodeId::inner(self : NodeId) -> Int
    Convert newtype to its underlying type, automatically derived.

    NodeId::to_int

    fn NodeId::to_int(self : NodeId) -> Int

    Get Int value from NodeId

    NodeInfo

    pub struct NodeInfo {
    node_id : NodeId
    node_type : NodeType
    node_name : String
    node_value : String
    child_count : Int
    }

    Basic node information
    impl Show for NodeInfo

    NodeType

    pub enum NodeType {
    Document
    DocumentType
    Element
    Text
    Comment
    }

    Node type enumeration
    impl Eq for NodeType
    impl Show for NodeType

    NodeType::from_dom_constant

    fn NodeType::from_dom_constant(value : Int) -> NodeType?

    Convert DOM node type constant to NodeType See: https://developer.mozilla.org/en-US/docs/Web/API/Node/nodeType

    Point

    pub struct Point {
    x : Double
    y : Double
    }

    2D Point
    impl Eq for Point
    impl Show for Point

    Rect

    pub struct Rect {
    x : Double
    y : Double
    width : Double
    height : Double
    }

    Rectangle with position and size
    impl Eq for Rect
    impl Show for Rect

    Rect::center

    fn Rect::center(self : Rect) -> Point

    Convert Rect to center point

    Rect::new

    fn Rect::new(x : Double, y : Double, width : Double, height : Double) -> Rect

    Create a new Rect

    SVGAngle

    pub struct SVGAngle {
    unit_type : SVGAngleType
    value : Double
    value_in_specified_units : Double
    }

    SVGAngle - represents an angle value with unit
    impl Eq for SVGAngle
    impl Show for SVGAngle

    SVGAngle::new

    fn SVGAngle::new(value : Double) -> SVGAngle

    Create a new SVGAngle (degrees)

    SVGAngle::to_degrees

    fn SVGAngle::to_degrees(self : SVGAngle) -> Double

    Convert SVGAngle to degrees

    SVGAngle::to_radians

    fn SVGAngle::to_radians(self : SVGAngle) -> Double

    Convert SVGAngle to radians

    SVGAngleType

    pub enum SVGAngleType {
    Unknown
    Unspecified
    Deg
    Rad
    Grad
    Turn
    }

    SVG Angle unit types
    impl Eq for SVGAngleType

    SVGLength

    pub struct SVGLength {
    unit_type : SVGLengthType
    value : Double
    value_in_specified_units : Double
    }

    SVGLength - represents a length value with unit
    impl Eq for SVGLength
    impl Show for SVGLength

    SVGLength::new

    fn SVGLength::new(value : Double) -> SVGLength

    Create a new SVGLength (unitless)

    SVGLength::to_user_units

    fn SVGLength::to_user_units(self : SVGLength, dpi? : Double, font_size? : Double) -> Double

    Convert SVGLength to user units (pixels)

    SVGLengthType

    pub enum SVGLengthType {
    Unknown
    Number
    Percentage
    Ems
    Exs
    Px
    Cm
    Mm
    In
    Pt
    Pc
    }

    SVG Length unit types
    impl Eq for SVGLengthType

    SVGMatrix

    pub struct SVGMatrix {
    a : Double
    b : Double
    c : Double
    d : Double
    e : Double
    f : Double
    }

    SVGMatrix - 2D transformation matrix for SVG Represents a 3x3 matrix: | a c e | | b d f | | 0 0 1 |
    impl Eq for SVGMatrix
    impl Show for SVGMatrix

    SVGMatrix::flip_x

    fn SVGMatrix::flip_x(self : SVGMatrix) -> SVGMatrix

    Flip on X axis

    SVGMatrix::flip_y

    fn SVGMatrix::flip_y(self : SVGMatrix) -> SVGMatrix

    Flip on Y axis

    SVGMatrix::identity

    fn SVGMatrix::identity() -> SVGMatrix

    Create an identity matrix

    SVGMatrix::inverse

    fn SVGMatrix::inverse(self : SVGMatrix) -> SVGMatrix?

    Get the inverse of this matrix

    SVGMatrix::multiply

    fn SVGMatrix::multiply(self : SVGMatrix, other : SVGMatrix) -> SVGMatrix

    Multiply this matrix by another matrix (this * other)

    SVGMatrix::new

    fn SVGMatrix::new(a : Double, b : Double, c : Double, d : Double, e : Double, f : Double) -> SVGMatrix

    Create a new SVGMatrix with specified values

    SVGMatrix::rotate

    fn SVGMatrix::rotate(angle : Double) -> SVGMatrix

    Create a rotation matrix (angle in radians)

    SVGMatrix::rotate_deg

    fn SVGMatrix::rotate_deg(angle_deg : Double) -> SVGMatrix

    Create a rotation matrix (angle in degrees)

    SVGMatrix::rotate_self

    fn SVGMatrix::rotate_self(self : SVGMatrix, angle : Double) -> SVGMatrix

    Apply rotation to this matrix (returns new matrix)

    SVGMatrix::scale

    fn SVGMatrix::scale(sx : Double, sy : Double) -> SVGMatrix

    Create a scale matrix

    SVGMatrix::scale_self

    fn SVGMatrix::scale_self(self : SVGMatrix, sx : Double, sy : Double) -> SVGMatrix

    Apply scale to this matrix (returns new matrix)

    SVGMatrix::scale_uniform

    fn SVGMatrix::scale_uniform(s : Double) -> SVGMatrix

    Create a uniform scale matrix

    SVGMatrix::skew_x

    fn SVGMatrix::skew_x(angle : Double) -> SVGMatrix

    Create a skew X matrix (angle in radians)

    SVGMatrix::skew_y

    fn SVGMatrix::skew_y(angle : Double) -> SVGMatrix

    Create a skew Y matrix (angle in radians)

    SVGMatrix::translate

    fn SVGMatrix::translate(tx : Double, ty : Double) -> SVGMatrix

    Create a translation matrix

    SVGMatrix::translate_self

    fn SVGMatrix::translate_self(self : SVGMatrix, tx : Double, ty : Double) -> SVGMatrix

    Apply translation to this matrix (returns new matrix)

    SVGNumber

    pub struct SVGNumber {
    value : Double
    }

    SVGNumber - represents an animated number value
    impl Eq for SVGNumber
    impl Show for SVGNumber

    SVGNumber::new

    fn SVGNumber::new(value : Double) -> SVGNumber

    Create a new SVGNumber

    SVGPoint

    pub struct SVGPoint {
    x : Double
    y : Double
    }

    SVGPoint - represents a point in SVG coordinate space Has matrixTransform method for coordinate transformations
    impl Eq for SVGPoint
    impl Show for SVGPoint

    SVGPoint::matrix_transform

    fn SVGPoint::matrix_transform(self : SVGPoint, matrix : SVGMatrix) -> SVGPoint

    Transform this point by a matrix

    SVGPoint::new

    fn SVGPoint::new(x : Double, y : Double) -> SVGPoint

    Create a new SVGPoint

    SVGPoint::origin

    fn SVGPoint::origin() -> SVGPoint

    Create an SVGPoint at origin (0, 0)

    SVGRect

    pub struct SVGRect {
    x : Double
    y : Double
    width : Double
    height : Double
    }

    SVGRect - represents a rectangle in SVG coordinate space Used by getBBox(), getClientRect(), and other SVG methods
    impl Eq for SVGRect
    impl Show for SVGRect

    SVGRect::empty

    fn SVGRect::empty() -> SVGRect

    Create an empty SVGRect (0, 0, 0, 0)

    SVGRect::from_rect

    fn SVGRect::from_rect(rect : Rect) -> SVGRect

    Create SVGRect from Rect

    SVGRect::new

    fn SVGRect::new(x : Double, y : Double, width : Double, height : Double) -> SVGRect

    Create a new SVGRect

    SVGRect::to_rect

    fn SVGRect::to_rect(self : SVGRect) -> Rect

    Convert SVGRect to Rect

    SVGTransform

    pub struct SVGTransform {
    transform_type : SVGTransformType
    matrix : SVGMatrix
    angle : Double
    }

    SVGTransform - represents a single transformation
    impl Eq for SVGTransform

    SVGTransform::from_matrix

    fn SVGTransform::from_matrix(matrix : SVGMatrix) -> SVGTransform

    Create an SVGTransform from a matrix

    SVGTransform::rotate

    fn SVGTransform::rotate(angle : Double, cx? : Double, cy? : Double) -> SVGTransform

    Create a rotate transform (angle in degrees)

    SVGTransform::scale

    fn SVGTransform::scale(sx : Double, sy : Double) -> SVGTransform

    Create a scale transform

    SVGTransform::skew_x

    fn SVGTransform::skew_x(angle : Double) -> SVGTransform

    Create a skewX transform (angle in degrees)

    SVGTransform::skew_y

    fn SVGTransform::skew_y(angle : Double) -> SVGTransform

    Create a skewY transform (angle in degrees)

    SVGTransform::translate

    fn SVGTransform::translate(tx : Double, ty : Double) -> SVGTransform

    Create a translate transform

    SVGTransformType

    pub enum SVGTransformType {
    Unknown
    Matrix
    Translate
    Scale
    Rotate
    SkewX
    SkewY
    }

    SVG Transform types

    ScrollState

    pub struct ScrollState {
    scroll_left : Double
    scroll_top : Double
    scroll_width : Double
    scroll_height : Double
    client_width : Double
    client_height : Double
    }

    Scroll state for a scrollable element
    impl Eq for ScrollState
    impl Show for ScrollState

    ScrollState::can_scroll_x

    fn ScrollState::can_scroll_x(self : ScrollState) -> Bool

    Check if horizontal scrolling is possible

    ScrollState::can_scroll_y

    fn ScrollState::can_scroll_y(self : ScrollState) -> Bool

    Check if vertical scrolling is possible

    ScrollState::default

    fn ScrollState::default() -> ScrollState

    Create a default ScrollState (no scrolling)

    ScrollState::max_scroll_left

    fn ScrollState::max_scroll_left(self : ScrollState) -> Double

    Get maximum scroll position (horizontal)

    ScrollState::max_scroll_top

    fn ScrollState::max_scroll_top(self : ScrollState) -> Double

    Get maximum scroll position (vertical)

    ScrollState::new

    fn ScrollState::new(scroll_width : Double, scroll_height : Double, client_width : Double, client_height : Double) -> ScrollState

    Create a new ScrollState

    ScrollState::scroll_by

    fn ScrollState::scroll_by(self : ScrollState, delta_x : Double, delta_y : Double) -> ScrollState

    Scroll by delta (relative scroll)

    ScrollState::scroll_to

    fn ScrollState::scroll_to(self : ScrollState, left : Double, top : Double) -> ScrollState

    Set scroll position (clamped to valid range)

    create_svg_angle

    fn create_svg_angle() -> SVGAngle

    Create a zero SVGAngle

    create_svg_length

    fn create_svg_length() -> SVGLength

    Create a zero SVGLength

    create_svg_matrix

    fn create_svg_matrix() -> SVGMatrix

    Create a new SVGMatrix object (identity matrix) Equivalent to SVGSVGElement.createSVGMatrix()

    create_svg_matrix_with

    fn create_svg_matrix_with(a : Double, b : Double, c : Double, d : Double, e : Double, f : Double) -> SVGMatrix

    Create a new SVGMatrix with values

    create_svg_number

    fn create_svg_number() -> SVGNumber

    Create a zero SVGNumber

    create_svg_point

    fn create_svg_point() -> SVGPoint

    Create a new SVGPoint object Equivalent to SVGSVGElement.createSVGPoint()

    create_svg_point_with

    fn create_svg_point_with(x : Double, y : Double) -> SVGPoint

    Create a new SVGPoint with values

    create_svg_rect

    fn create_svg_rect() -> SVGRect

    Create a new SVGRect object Equivalent to SVGSVGElement.createSVGRect()

    create_svg_rect_with

    fn create_svg_rect_with(x : Double, y : Double, width : Double, height : Double) -> SVGRect

    Create a new SVGRect with values

    create_svg_transform

    fn create_svg_transform() -> SVGTransform

    Create a new SVGTransform

    create_svg_transform_rotate

    fn create_svg_transform_rotate(angle : Double) -> SVGTransform

    Create a rotation SVGTransform

    create_svg_transform_scale

    fn create_svg_transform_scale(sx : Double, sy : Double) -> SVGTransform

    Create a scale SVGTransform

    create_svg_transform_translate

    fn create_svg_transform_translate(tx : Double, ty : Double) -> SVGTransform

    Create a translation SVGTransform