#[repr(C, align(64))]pub struct Node {Show 18 fields
pub tag: Tag,
pub flags: NodeFlags,
pub depth: u16,
pub parent: NodeId,
pub first_child: NodeId,
pub next_sibling: NodeId,
pub last_child: NodeId,
pub prev_sibling: NodeId,
pub text_offset: u32,
pub text_len: u32,
pub attr_offset: u32,
pub attr_raw_offset: u32,
pub class_hash: u64,
pub id_hash: u32,
pub attr_raw_len: u16,
pub element_index: u16,
pub attr_count: u8,
pub _padding: [u8; 7],
}Expand description
A single DOM node in the arena, exactly 64 bytes (one cache line).
The first 32 bytes contain frequently accessed fields (tree links, tag, depth). The second 32 bytes contain less-frequently accessed data (attribute metadata).
§Layout
| Offset | Bytes | Field |
|---|---|---|
| 0 | 1 | tag |
| 1 | 1 | flags |
| 2 | 2 | depth |
| 4 | 4 | parent |
| 8 | 4 | first_child |
| 12 | 4 | next_sibling |
| 16 | 4 | last_child |
| 20 | 4 | prev_sibling |
| 24 | 4 | text_offset |
| 28 | 4 | text_len |
| 32 | 4 | attr_offset |
| 36 | 4 | attr_raw_offset |
| 40 | 8 | class_hash |
| 48 | 4 | id_hash |
| 52 | 2 | attr_raw_len |
| 54 | 2 | element_index |
| 56 | 1 | attr_count |
| 57 | 7 | _padding |
Fields§
§tag: TagInterned tag type.
flags: NodeFlagsBitflags for node properties.
depth: u16Nesting depth from root (root = 0).
parent: NodeIdParent node, or NodeId::NULL for root.
first_child: NodeIdFirst child, or NodeId::NULL if no children.
next_sibling: NodeIdNext sibling, or NodeId::NULL if last.
last_child: NodeIdLast child, or NodeId::NULL if no children.
prev_sibling: NodeIdPrevious sibling, or NodeId::NULL if first.
text_offset: u32Byte offset into the text slab.
text_len: u32Length in bytes of the text content in the slab.
attr_offset: u32Byte offset into the attribute slab (after lazy parse).
attr_raw_offset: u32Byte offset into attr_str_slab for the raw attribute region.
class_hash: u6464-bit bloom filter of class attribute tokens.
Each class token is hashed via FNV-1a and a single bit is set at
hash % 64. Zero means no class attribute. Used by the selector
matcher for fast rejection. 64 bits reduces false positive rate
from ~15% (5 classes) to ~8% compared to 32-bit.
id_hash: u32FNV-1a hash of the id attribute value.
Zero means no id attribute. Used by the selector matcher for fast rejection before scanning attributes.
attr_raw_len: u16Length in bytes of the raw attribute region (max 65535).
element_index: u161-based index among element siblings (0 = not computed or text node).
attr_count: u8Number of attributes (0 with raw data present = unparsed lazy).
_padding: [u8; 7]Padding to fill the cache line.
Implementations§
Source§impl Node
impl Node
Sourcepub fn new_element(tag: Tag, depth: u16) -> Self
pub fn new_element(tag: Tag, depth: u16) -> Self
Create a new element node with all links set to NULL.
Sourcepub fn new_comment(depth: u16, text_offset: u32, text_len: u32) -> Self
pub fn new_comment(depth: u16, text_offset: u32, text_len: u32) -> Self
Create a new comment node.
Sourcepub fn new_doctype(depth: u16, text_offset: u32, text_len: u32) -> Self
pub fn new_doctype(depth: u16, text_offset: u32, text_len: u32) -> Self
Create a new doctype node.