1
//! Defines the core Document Object Model (DOM) structures.
2
//!
3
//! This module is responsible for representing the UI as a tree of nodes,
4
//! similar to the HTML DOM. It includes definitions for node types, event handling
5
//! and the main `Dom` and `CompactDom` structures.
6

            
7
#[cfg(not(feature = "std"))]
8
use alloc::string::ToString;
9
use alloc::{boxed::Box, collections::btree_map::BTreeMap, string::String, vec::Vec};
10
use core::{
11
    fmt,
12
    hash::{Hash, Hasher},
13
    iter::FromIterator,
14
    mem,
15
    sync::atomic::{AtomicUsize, Ordering},
16
};
17

            
18
pub use azul_css::dynamic_selector::{CssPropertyWithConditions, CssPropertyWithConditionsVec};
19
use azul_css::{
20
    codegen::format::GetHash,
21
    css::{BoxOrStatic, Css, NodeTypeTag},
22
    props::{
23
        basic::{FloatValue, FontRef},
24
        layout::{LayoutDisplay, LayoutFloat, LayoutPosition},
25
        property::CssProperty,
26
    },
27
    AzString, OptionString,
28
};
29

            
30
// Re-exported from a11y.rs and events.rs
31
pub use crate::a11y::*;
32
use crate::{
33
    callbacks::{
34
        CoreCallback, CoreCallbackData, CoreCallbackDataVec, CoreCallbackType, VirtualViewCallback,
35
        VirtualViewCallbackType,
36
    },
37
    geom::LogicalPosition,
38
    id::{NodeDataContainer, NodeDataContainerRef, NodeDataContainerRefMut},
39
    menu::Menu,
40
    prop_cache::{CssPropertyCache, CssPropertyCachePtr},
41
    refany::{OptionRefAny, RefAny},
42
    resources::{
43
        image_ref_get_hash, CoreImageCallback, ImageMask, ImageRef, ImageRefHash, RendererResources,
44
    },
45
    styled_dom::{
46
        CompactDom, NodeHierarchyItemId, StyleFontFamilyHash, StyledDom, StyledNode,
47
        StyledNodeState,
48
    },
49
    window::OptionVirtualKeyCodeCombo,
50
};
51
pub use crate::{
52
    events::{
53
        ApplicationEventFilter, ComponentEventFilter, EventFilter, ExternalEventFilter,
54
        FocusEventFilter, HoverEventFilter, WindowEventFilter,
55
    },
56
    id::{Node, NodeHierarchy, NodeId},
57
};
58

            
59
static TAG_ID: AtomicUsize = AtomicUsize::new(1);
60

            
61
/// Strongly-typed input element types for HTML `<input>` elements.
62
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
63
#[repr(C)]
64
pub enum InputType {
65
    /// Text input (default)
66
    Text,
67
    /// Button
68
    Button,
69
    /// Checkbox
70
    Checkbox,
71
    /// Color picker
72
    Color,
73
    /// Date picker
74
    Date,
75
    /// Date and time picker
76
    Datetime,
77
    /// Date and time picker (local)
78
    DatetimeLocal,
79
    /// Email address input
80
    Email,
81
    /// File upload
82
    File,
83
    /// Hidden input
84
    Hidden,
85
    /// Image button
86
    Image,
87
    /// Month picker
88
    Month,
89
    /// Number input
90
    Number,
91
    /// Password input
92
    Password,
93
    /// Radio button
94
    Radio,
95
    /// Range slider
96
    Range,
97
    /// Reset button
98
    Reset,
99
    /// Search input
100
    Search,
101
    /// Submit button
102
    Submit,
103
    /// Telephone number input
104
    Tel,
105
    /// Time picker
106
    Time,
107
    /// URL input
108
    Url,
109
    /// Week picker
110
    Week,
111
}
112

            
113
impl InputType {
114
    /// Returns the HTML attribute value for this input type
115
    #[must_use]
116
25
    pub const fn as_str(&self) -> &'static str {
117
25
        match self {
118
2
            Self::Text => "text",
119
1
            Self::Button => "button",
120
1
            Self::Checkbox => "checkbox",
121
1
            Self::Color => "color",
122
1
            Self::Date => "date",
123
1
            Self::Datetime => "datetime",
124
2
            Self::DatetimeLocal => "datetime-local",
125
1
            Self::Email => "email",
126
1
            Self::File => "file",
127
1
            Self::Hidden => "hidden",
128
1
            Self::Image => "image",
129
1
            Self::Month => "month",
130
1
            Self::Number => "number",
131
1
            Self::Password => "password",
132
1
            Self::Radio => "radio",
133
1
            Self::Range => "range",
134
1
            Self::Reset => "reset",
135
1
            Self::Search => "search",
136
1
            Self::Submit => "submit",
137
1
            Self::Tel => "tel",
138
1
            Self::Time => "time",
139
1
            Self::Url => "url",
140
1
            Self::Week => "week",
141
        }
142
25
    }
143
}
144

            
145
#[derive(Debug, Copy, Clone, PartialEq, Eq, Ord, PartialOrd, Hash)]
146
#[repr(C)]
147
pub struct TagId {
148
    pub inner: u64,
149
}
150

            
151
impl ::core::fmt::Display for TagId {
152
3
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
153
3
        f.debug_struct("TagId").field("inner", &self.inner).finish()
154
3
    }
155
}
156

            
157
impl_option!(
158
    TagId,
159
    OptionTagId,
160
    [Debug, Copy, Clone, PartialEq, Eq, Ord, PartialOrd, Hash]
161
);
162

            
163
impl TagId {
164
    #[must_use]
165
8
    pub const fn into_crate_internal(&self) -> Self {
166
8
        Self { inner: self.inner }
167
8
    }
168
    #[must_use]
169
828917
    pub const fn from_crate_internal(t: Self) -> Self {
170
828917
        t
171
828917
    }
172

            
173
    /// Creates a new, unique hit-testing tag ID.
174
    /// Wraps around to 1 on overflow (0 is reserved for "no tag").
175
    ///
176
    /// AUDIT: the wrap is only reachable after 2^64 - 1 allocations (a process
177
    /// running long enough to exhaust the counter is not realistic), but note
178
    /// that on wrap the freshly-issued id could theoretically collide with a
179
    /// still-live tag from very early in the process. This is left as a
180
    /// documented, non-triggerable limitation rather than adding a live-tag
181
    /// registry to detect collisions on every allocation. AUDIT-TODO: revisit
182
    /// if `TagId` is ever narrowed below 64 bits.
183
514
    pub fn unique() -> Self {
184
        loop {
185
514
            let current = TAG_ID.load(Ordering::SeqCst);
186
514
            let next = if current == usize::MAX {
187
                1
188
            } else {
189
514
                current + 1
190
            };
191
514
            if TAG_ID
192
514
                .compare_exchange(current, next, Ordering::SeqCst, Ordering::SeqCst)
193
514
                .is_ok()
194
            {
195
514
                return Self {
196
514
                    inner: current as u64,
197
514
                };
198
            }
199
        }
200
514
    }
201
}
202

            
203
/// Same as the `TagId`, but only for scrollable nodes.
204
/// This provides a typed distinction for tags associated with scrolling containers.
205
#[derive(Copy, Clone, PartialEq, Eq, Hash, Ord, PartialOrd)]
206
#[repr(C)]
207
pub struct ScrollTagId {
208
    pub inner: TagId,
209
}
210

            
211
impl ::core::fmt::Display for ScrollTagId {
212
3
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
213
3
        f.debug_struct("ScrollTagId")
214
3
            .field("inner", &self.inner)
215
3
            .finish()
216
3
    }
217
}
218

            
219
impl ::core::fmt::Debug for ScrollTagId {
220
1
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
221
1
        write!(f, "{self}")
222
1
    }
223
}
224

            
225
impl ScrollTagId {
226
    /// Creates a new, unique scroll tag ID. Note that this should not
227
    /// be used for identifying nodes, use the `DomNodeHash` instead.
228
    #[must_use]
229
2
    pub fn unique() -> Self {
230
2
        Self {
231
2
            inner: TagId::unique(),
232
2
        }
233
2
    }
234
}
235

            
236
/// Orientation of a scrollbar.
237
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
238
#[repr(C)]
239
pub enum ScrollbarOrientation {
240
    Horizontal,
241
    Vertical,
242
}
243

            
244
/// Calculated hash of a DOM node, used for identifying identical DOM
245
/// nodes across frames for efficient diffing and state preservation.
246
#[derive(Copy, Clone, Hash, PartialEq, Eq, Ord, PartialOrd)]
247
#[repr(C)]
248
pub struct DomNodeHash {
249
    pub inner: u64,
250
}
251

            
252
impl ::core::fmt::Debug for DomNodeHash {
253
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
254
        write!(f, "DomNodeHash({})", self.inner)
255
    }
256
}
257

            
258
/// List of core DOM node types built into `azul`.
259
/// This enum defines the building blocks of the UI, similar to HTML tags.
260
#[derive(Debug, Clone, PartialEq, Hash, Eq, PartialOrd, Ord)]
261
#[repr(C, u8)]
262
pub enum NodeType {
263
    // Root and container elements
264
    /// Root HTML element.
265
    Html,
266
    /// Document head (metadata container).
267
    Head,
268
    /// Root element of the document body.
269
    Body,
270
    /// Generic block-level container.
271
    Div,
272
    /// Paragraph.
273
    P,
274
    /// Article content.
275
    Article,
276
    /// Section of a document.
277
    Section,
278
    /// Navigation links.
279
    Nav,
280
    /// Sidebar/tangential content.
281
    Aside,
282
    /// Header section.
283
    Header,
284
    /// Footer section.
285
    Footer,
286
    /// Main content.
287
    Main,
288
    /// Figure with optional caption.
289
    Figure,
290
    /// Caption for figure element.
291
    FigCaption,
292
    /// Headings.
293
    H1,
294
    H2,
295
    H3,
296
    H4,
297
    H5,
298
    H6,
299
    /// Line break.
300
    Br,
301
    /// Horizontal rule.
302
    Hr,
303
    /// Preformatted text.
304
    Pre,
305
    /// Block quote.
306
    BlockQuote,
307
    /// Address.
308
    Address,
309
    /// Details disclosure widget.
310
    Details,
311
    /// Summary for details element.
312
    Summary,
313
    /// Dialog box or window.
314
    Dialog,
315

            
316
    // List elements
317
    /// Unordered list.
318
    Ul,
319
    /// Ordered list.
320
    Ol,
321
    /// List item.
322
    Li,
323
    /// Definition list.
324
    Dl,
325
    /// Definition term.
326
    Dt,
327
    /// Definition description.
328
    Dd,
329
    /// Menu list.
330
    Menu,
331
    /// Menu item.
332
    MenuItem,
333
    /// Directory list (deprecated).
334
    Dir,
335

            
336
    // Table elements
337
    /// Table container.
338
    Table,
339
    /// Table caption.
340
    Caption,
341
    /// Table header.
342
    THead,
343
    /// Table body.
344
    TBody,
345
    /// Table footer.
346
    TFoot,
347
    /// Table row.
348
    Tr,
349
    /// Table header cell.
350
    Th,
351
    /// Table data cell.
352
    Td,
353
    /// Table column group.
354
    ColGroup,
355
    /// Table column.
356
    Col,
357

            
358
    // Form elements
359
    /// Form container.
360
    Form,
361
    /// Form fieldset.
362
    FieldSet,
363
    /// Fieldset legend.
364
    Legend,
365
    /// Label for form controls.
366
    Label,
367
    /// Input control.
368
    Input,
369
    /// Button control.
370
    Button,
371
    /// Select dropdown.
372
    Select,
373
    /// Option group.
374
    OptGroup,
375
    /// Select option.
376
    SelectOption,
377
    /// Multiline text input.
378
    TextArea,
379
    /// Form output element.
380
    Output,
381
    /// Progress indicator.
382
    Progress,
383
    /// Scalar measurement within a known range.
384
    Meter,
385
    /// List of predefined options for input.
386
    DataList,
387

            
388
    // Inline elements
389
    /// Generic inline container.
390
    Span,
391
    /// Anchor/hyperlink.
392
    A,
393
    /// Emphasized text.
394
    Em,
395
    /// Strongly emphasized text.
396
    Strong,
397
    /// Bold text (deprecated - use `Dom::create_strong()` for semantic importance).
398
    B,
399
    /// Italic text (deprecated - use `Dom::create_em()` for emphasis or `Dom::create_cite()` for
400
    /// citations).
401
    I,
402
    /// Underline text.
403
    U,
404
    /// Strikethrough text.
405
    S,
406
    /// Marked/highlighted text.
407
    Mark,
408
    /// Deleted text.
409
    Del,
410
    /// Inserted text.
411
    Ins,
412
    /// Code.
413
    Code,
414
    /// Sample output.
415
    Samp,
416
    /// Keyboard input.
417
    Kbd,
418
    /// Variable.
419
    Var,
420
    /// Citation.
421
    Cite,
422
    /// Defining instance of a term.
423
    Dfn,
424
    /// Abbreviation.
425
    Abbr,
426
    /// Acronym.
427
    Acronym,
428
    /// Inline quotation.
429
    Q,
430
    /// Date/time.
431
    Time,
432
    /// Subscript.
433
    Sub,
434
    /// Superscript.
435
    Sup,
436
    /// Small text (deprecated - use CSS `font-size` instead).
437
    Small,
438
    /// Big text (deprecated - use CSS `font-size` instead).
439
    Big,
440
    /// Bi-directional override.
441
    Bdo,
442
    /// Bi-directional isolate.
443
    Bdi,
444
    /// Word break opportunity.
445
    Wbr,
446
    /// Ruby annotation.
447
    Ruby,
448
    /// Ruby text.
449
    Rt,
450
    /// Ruby text container.
451
    Rtc,
452
    /// Ruby parenthesis.
453
    Rp,
454
    /// Machine-readable data.
455
    Data,
456

            
457
    // Embedded content
458
    /// Canvas for graphics.
459
    Canvas,
460
    /// Embedded object.
461
    Object,
462
    /// Embedded object parameter.
463
    Param,
464
    /// External resource embed.
465
    Embed,
466
    /// Audio content.
467
    Audio,
468
    /// Video content.
469
    Video,
470
    /// Media source.
471
    Source,
472
    /// Text track for media.
473
    Track,
474
    /// Image map.
475
    Map,
476
    /// Image map area.
477
    Area,
478
    // SVG elements — container
479
    /// SVG `<svg>` root graphics container.
480
    Svg,
481
    /// SVG `<g>` group element.
482
    SvgG,
483
    /// SVG `<defs>` — reusable definitions (not rendered directly).
484
    SvgDefs,
485
    /// SVG `<symbol>` — like defs but with its own viewBox.
486
    SvgSymbol,
487
    /// SVG `<use>` — references and instantiates a defs element.
488
    SvgUse,
489
    /// SVG `<switch>` — conditional processing.
490
    SvgSwitch,
491

            
492
    // SVG elements — shape
493
    /// SVG `<path>` element.
494
    SvgPath,
495
    /// SVG `<circle>` element.
496
    SvgCircle,
497
    /// SVG `<rect>` element.
498
    SvgRect,
499
    /// SVG `<ellipse>` element.
500
    SvgEllipse,
501
    /// SVG `<line>` element.
502
    SvgLine,
503
    /// SVG `<polygon>` element.
504
    SvgPolygon,
505
    /// SVG `<polyline>` element.
506
    SvgPolyline,
507

            
508
    // SVG elements — text
509
    /// SVG `<text>` element.
510
    SvgText(AzString),
511
    /// SVG `<tspan>` element.
512
    SvgTspan,
513
    /// SVG `<textPath>` element.
514
    SvgTextPath,
515

            
516
    // SVG elements — paint servers
517
    /// SVG `<linearGradient>` element.
518
    SvgLinearGradient,
519
    /// SVG `<radialGradient>` element.
520
    SvgRadialGradient,
521
    /// SVG `<stop>` gradient stop element.
522
    SvgStop,
523
    /// SVG `<pattern>` element.
524
    SvgPattern,
525

            
526
    // SVG elements — clipping / masking
527
    /// SVG `<clipPath>` element.
528
    SvgClipPathElement,
529
    /// SVG `<mask>` element.
530
    SvgMask,
531

            
532
    // SVG elements — filter
533
    /// SVG `<filter>` container element.
534
    SvgFilter,
535
    /// SVG `<feBlend>`.
536
    SvgFeBlend,
537
    /// SVG `<feColorMatrix>`.
538
    SvgFeColorMatrix,
539
    /// SVG `<feComponentTransfer>`.
540
    SvgFeComponentTransfer,
541
    /// SVG `<feComposite>`.
542
    SvgFeComposite,
543
    /// SVG `<feConvolveMatrix>`.
544
    SvgFeConvolveMatrix,
545
    /// SVG `<feDiffuseLighting>`.
546
    SvgFeDiffuseLighting,
547
    /// SVG `<feDisplacementMap>`.
548
    SvgFeDisplacementMap,
549
    /// SVG `<feDistantLight>`.
550
    SvgFeDistantLight,
551
    /// SVG `<feDropShadow>`.
552
    SvgFeDropShadow,
553
    /// SVG `<feFlood>`.
554
    SvgFeFlood,
555
    /// SVG `<feFuncR>`.
556
    SvgFeFuncR,
557
    /// SVG `<feFuncG>`.
558
    SvgFeFuncG,
559
    /// SVG `<feFuncB>`.
560
    SvgFeFuncB,
561
    /// SVG `<feFuncA>`.
562
    SvgFeFuncA,
563
    /// SVG `<feGaussianBlur>`.
564
    SvgFeGaussianBlur,
565
    /// SVG `<feImage>`.
566
    SvgFeImage,
567
    /// SVG `<feMerge>`.
568
    SvgFeMerge,
569
    /// SVG `<feMergeNode>`.
570
    SvgFeMergeNode,
571
    /// SVG `<feMorphology>`.
572
    SvgFeMorphology,
573
    /// SVG `<feOffset>`.
574
    SvgFeOffset,
575
    /// SVG `<fePointLight>`.
576
    SvgFePointLight,
577
    /// SVG `<feSpecularLighting>`.
578
    SvgFeSpecularLighting,
579
    /// SVG `<feSpotLight>`.
580
    SvgFeSpotLight,
581
    /// SVG `<feTile>`.
582
    SvgFeTile,
583
    /// SVG `<feTurbulence>`.
584
    SvgFeTurbulence,
585

            
586
    // SVG elements — marker / image / foreign
587
    /// SVG `<marker>` element (not the CSS `::marker` pseudo-element).
588
    SvgMarker,
589
    /// SVG `<image>` element (embedded raster image in SVG).
590
    SvgImage(ImageRef),
591
    /// SVG `<foreignObject>` element.
592
    SvgForeignObject,
593

            
594
    // SVG elements — descriptive / structural
595
    /// SVG `<title>` element (distinct from HTML `<title>`).
596
    SvgTitle,
597
    /// SVG `<desc>` element.
598
    SvgDesc,
599
    /// SVG `<metadata>` element.
600
    SvgMetadata,
601
    /// SVG `<a>` hyperlink element (distinct from HTML `<a>`).
602
    SvgA,
603
    /// SVG `<view>` element.
604
    SvgView,
605
    /// SVG `<style>` element (distinct from HTML `<style>`).
606
    SvgStyle,
607
    /// SVG `<script>` element (distinct from HTML `<script>`).
608
    SvgScript,
609

            
610
    // SVG elements — animation
611
    /// SVG `<animate>` element.
612
    SvgAnimate,
613
    /// SVG `<animateMotion>` element.
614
    SvgAnimateMotion,
615
    /// SVG `<animateTransform>` element.
616
    SvgAnimateTransform,
617
    /// SVG `<set>` element.
618
    SvgSet,
619
    /// SVG `<mpath>` element.
620
    SvgMpath,
621

            
622
    // Metadata elements
623
    /// Document title.
624
    Title,
625
    /// Metadata.
626
    Meta,
627
    /// External resource link.
628
    Link,
629
    /// Embedded or referenced script.
630
    Script,
631
    /// Style information.
632
    Style,
633
    /// Base URL for relative URLs.
634
    Base,
635

            
636
    // Pseudo-elements (transformed into real elements)
637
    /// `::before` pseudo-element.
638
    Before,
639
    /// `::after` pseudo-element.
640
    After,
641
    /// `::marker` pseudo-element.
642
    Marker,
643
    /// `::placeholder` pseudo-element.
644
    Placeholder,
645

            
646
    // Special content types
647
    /// Text content, `::text`.
648
    /// Uses `BoxOrStatic` to keep `NodeType` small (~16B vs ~72B with inline `AzString`)
649
    /// and to allow static text references in the future.
650
    Text(BoxOrStatic<AzString>),
651
    /// Image element, `::image`.
652
    /// Uses `BoxOrStatic` to keep `NodeType` small.
653
    Image(BoxOrStatic<ImageRef>),
654
    /// `VirtualView` (embedded content) - payload stored in `NodeDataExt.virtual_view`
655
    VirtualView,
656
    /// `<transient-window>` — a popup that is a real OS window drawn from this
657
    /// node's subtree. Contributes nothing to layout while closed; when `open`
658
    /// the engine materialises the children as a window anchored to the PARENT.
659
    /// See `crate::transient`.
660
    TransientWindow(crate::transient::TransientWindowConfig),
661
    /// Icon element - resolved to actual content by `IconProvider`.
662
    /// The string is the icon name (e.g., "home", "settings", "search").
663
    /// Uses `BoxOrStatic` to keep `NodeType` small.
664
    Icon(BoxOrStatic<AzString>),
665
    /// Invisible probe node that signals "this subtree needs the user's
666
    /// GPS / network location". Zero-size in layout, skipped in the
667
    /// display list. The `GeolocationManager` walks the styled DOM for
668
    /// these at end-of-layout and starts / stops the matching native
669
    /// subscription.
670
    GeolocationProbe(crate::geolocation::GeolocationProbeConfig),
671
    /// THE canonical page-break element: an empty block the UA styles with
672
    /// `break-before: page`. The pagination estimator and a screen DOM
673
    /// treat it identically; sibling margins collapse through it, so
674
    /// materializing an estimated break does not move content. XML tag:
675
    /// `<pagebreak/>`; constructor: [`Dom::create_page_break`].
676
    PageBreak,
677
}
678

            
679
/// Type alias: `BoxOrStatic<ImageRef>` — used by `NodeType::Image` for FFI monomorphization.
680
pub type BoxOrStaticImageRef = BoxOrStatic<ImageRef>;
681

            
682
impl_option!(
683
    NodeType,
684
    OptionNodeType,
685
    copy = false,
686
    [Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash]
687
);
688

            
689
impl NodeType {
690
    #[allow(clippy::too_many_lines)] // large but cohesive: single-purpose parser/builder/dispatch
691
                                     // (one branch per input variant)
692
1756624
    fn to_library_owned_nodetype(&self) -> Self {
693
        use self::NodeType::{
694
            Abbr, Acronym, Address, After, Area, Article, Aside, Audio, Base, Bdi, Bdo, Before,
695
            Big, BlockQuote, Body, Br, Button, Canvas, Caption, Cite, Code, Col, ColGroup, Data,
696
            DataList, Dd, Del, Details, Dfn, Dialog, Dir, Div, Dl, Dt, Em, Embed, FieldSet,
697
            FigCaption, Figure, Footer, Form, GeolocationProbe, Head, Header, Hr, Html, Icon,
698
            Image, Input, Ins, Kbd, Label, Legend, Li, Link, Main, Map, Mark, Marker, Menu,
699
            MenuItem, Meta, Meter, Nav, Object, Ol, OptGroup, Output, Param, Placeholder, Pre,
700
            Progress, Rp, Rt, Rtc, Ruby, Samp, Script, Section, Select, SelectOption, Small,
701
            Source, Span, Strong, Style, Sub, Summary, Sup, Svg, SvgA, SvgAnimate,
702
            SvgAnimateMotion, SvgAnimateTransform, SvgCircle, SvgClipPathElement, SvgDefs, SvgDesc,
703
            SvgEllipse, SvgFeBlend, SvgFeColorMatrix, SvgFeComponentTransfer, SvgFeComposite,
704
            SvgFeConvolveMatrix, SvgFeDiffuseLighting, SvgFeDisplacementMap, SvgFeDistantLight,
705
            SvgFeDropShadow, SvgFeFlood, SvgFeFuncA, SvgFeFuncB, SvgFeFuncG, SvgFeFuncR,
706
            SvgFeGaussianBlur, SvgFeImage, SvgFeMerge, SvgFeMergeNode, SvgFeMorphology,
707
            SvgFeOffset, SvgFePointLight, SvgFeSpecularLighting, SvgFeSpotLight, SvgFeTile,
708
            SvgFeTurbulence, SvgFilter, SvgForeignObject, SvgG, SvgImage, SvgLine,
709
            SvgLinearGradient, SvgMarker, SvgMask, SvgMetadata, SvgMpath, SvgPath, SvgPattern,
710
            SvgPolygon, SvgPolyline, SvgRadialGradient, SvgRect, SvgScript, SvgSet, SvgStop,
711
            SvgStyle, SvgSwitch, SvgSymbol, SvgText, SvgTextPath, SvgTitle, SvgTspan, SvgUse,
712
            SvgView, TBody, TFoot, THead, Table, Td, Text, TextArea, Th, Time, Title, Tr, Track,
713
            Ul, Var, Video, VirtualView, Wbr, A, B, H1, H2, H3, H4, H5, H6, I, P, Q, S, U,
714
        };
715
1756624
        match self {
716
171
            Html => Html,
717
            Head => Head,
718
366
            Body => Body,
719
1587121
            Div => Div,
720
20881
            P => P,
721
            Article => Article,
722
24
            Section => Section,
723
            Nav => Nav,
724
            Aside => Aside,
725
            Header => Header,
726
            Footer => Footer,
727
            Main => Main,
728
            Figure => Figure,
729
            FigCaption => FigCaption,
730
49
            H1 => H1,
731
96
            H2 => H2,
732
24
            H3 => H3,
733
            H4 => H4,
734
            H5 => H5,
735
1
            H6 => H6,
736
1
            Br => Br,
737
            Hr => Hr,
738
            Pre => Pre,
739
36
            BlockQuote => BlockQuote,
740
            Address => Address,
741
            Details => Details,
742
            Summary => Summary,
743
            Dialog => Dialog,
744
168
            Ul => Ul,
745
            Ol => Ol,
746
324
            Li => Li,
747
            Dl => Dl,
748
            Dt => Dt,
749
            Dd => Dd,
750
            Menu => Menu,
751
            MenuItem => MenuItem,
752
            Dir => Dir,
753
1
            Table => Table,
754
            Caption => Caption,
755
            THead => THead,
756
            TBody => TBody,
757
            TFoot => TFoot,
758
            Tr => Tr,
759
            Th => Th,
760
1
            Td => Td,
761
            ColGroup => ColGroup,
762
            Col => Col,
763
            Form => Form,
764
            FieldSet => FieldSet,
765
            Legend => Legend,
766
            Label => Label,
767
1
            Input => Input,
768
1513
            Button => Button,
769
1
            Select => Select,
770
            OptGroup => OptGroup,
771
            SelectOption => SelectOption,
772
1
            TextArea => TextArea,
773
            Output => Output,
774
            Progress => Progress,
775
            Meter => Meter,
776
            DataList => DataList,
777
432
            Span => Span,
778
1
            A => A,
779
24
            Em => Em,
780
24
            Strong => Strong,
781
36
            B => B,
782
            I => I,
783
            U => U,
784
            S => S,
785
            Mark => Mark,
786
            Del => Del,
787
            Ins => Ins,
788
24
            Code => Code,
789
            Samp => Samp,
790
            Kbd => Kbd,
791
            Var => Var,
792
            Cite => Cite,
793
            Dfn => Dfn,
794
            Abbr => Abbr,
795
            Acronym => Acronym,
796
            Q => Q,
797
            Time => Time,
798
            Sub => Sub,
799
            Sup => Sup,
800
            Small => Small,
801
            Big => Big,
802
            Bdo => Bdo,
803
            Bdi => Bdi,
804
            Wbr => Wbr,
805
            Ruby => Ruby,
806
            Rt => Rt,
807
            Rtc => Rtc,
808
            Rp => Rp,
809
            Data => Data,
810
            Canvas => Canvas,
811
            Object => Object,
812
            Param => Param,
813
            Embed => Embed,
814
            Audio => Audio,
815
            Video => Video,
816
            Source => Source,
817
            Track => Track,
818
            Map => Map,
819
            Area => Area,
820
            // SVG container
821
1
            Svg => Svg,
822
            SvgG => SvgG,
823
            SvgDefs => SvgDefs,
824
            SvgSymbol => SvgSymbol,
825
            SvgUse => SvgUse,
826
            SvgSwitch => SvgSwitch,
827
            // SVG shape
828
1
            SvgPath => SvgPath,
829
            SvgCircle => SvgCircle,
830
            SvgRect => SvgRect,
831
            SvgEllipse => SvgEllipse,
832
            SvgLine => SvgLine,
833
            SvgPolygon => SvgPolygon,
834
            SvgPolyline => SvgPolyline,
835
            // SVG text
836
1
            SvgText(s) => SvgText(s.clone_self()),
837
            SvgTspan => SvgTspan,
838
            SvgTextPath => SvgTextPath,
839
            // SVG paint
840
            SvgLinearGradient => SvgLinearGradient,
841
            SvgRadialGradient => SvgRadialGradient,
842
            SvgStop => SvgStop,
843
            SvgPattern => SvgPattern,
844
            // SVG clip/mask
845
            SvgClipPathElement => SvgClipPathElement,
846
            SvgMask => SvgMask,
847
            // SVG filter
848
            SvgFilter => SvgFilter,
849
            SvgFeBlend => SvgFeBlend,
850
            SvgFeColorMatrix => SvgFeColorMatrix,
851
            SvgFeComponentTransfer => SvgFeComponentTransfer,
852
            SvgFeComposite => SvgFeComposite,
853
            SvgFeConvolveMatrix => SvgFeConvolveMatrix,
854
            SvgFeDiffuseLighting => SvgFeDiffuseLighting,
855
            SvgFeDisplacementMap => SvgFeDisplacementMap,
856
            SvgFeDistantLight => SvgFeDistantLight,
857
            SvgFeDropShadow => SvgFeDropShadow,
858
            SvgFeFlood => SvgFeFlood,
859
            SvgFeFuncR => SvgFeFuncR,
860
            SvgFeFuncG => SvgFeFuncG,
861
            SvgFeFuncB => SvgFeFuncB,
862
            SvgFeFuncA => SvgFeFuncA,
863
            SvgFeGaussianBlur => SvgFeGaussianBlur,
864
            SvgFeImage => SvgFeImage,
865
            SvgFeMerge => SvgFeMerge,
866
            SvgFeMergeNode => SvgFeMergeNode,
867
            SvgFeMorphology => SvgFeMorphology,
868
            SvgFeOffset => SvgFeOffset,
869
            SvgFePointLight => SvgFePointLight,
870
            SvgFeSpecularLighting => SvgFeSpecularLighting,
871
            SvgFeSpotLight => SvgFeSpotLight,
872
            SvgFeTile => SvgFeTile,
873
            SvgFeTurbulence => SvgFeTurbulence,
874
            // SVG marker/image/foreign
875
            SvgMarker => SvgMarker,
876
1
            SvgImage(i) => SvgImage(i.clone()),
877
            SvgForeignObject => SvgForeignObject,
878
            // SVG descriptive/structural
879
            SvgTitle => SvgTitle,
880
            SvgDesc => SvgDesc,
881
            SvgMetadata => SvgMetadata,
882
            SvgA => SvgA,
883
            SvgView => SvgView,
884
            SvgStyle => SvgStyle,
885
            SvgScript => SvgScript,
886
            // SVG animation
887
            SvgAnimate => SvgAnimate,
888
            SvgAnimateMotion => SvgAnimateMotion,
889
            SvgAnimateTransform => SvgAnimateTransform,
890
            SvgSet => SvgSet,
891
            SvgMpath => SvgMpath,
892
            // HTML metadata
893
            Title => Title,
894
            Meta => Meta,
895
            Link => Link,
896
            Script => Script,
897
            Style => Style,
898
            Base => Base,
899
1
            Before => Before,
900
1
            After => After,
901
1
            Marker => Marker,
902
1
            Placeholder => Placeholder,
903

            
904
140681
            Text(s) => Text(BoxOrStatic::heap(s.clone_self())),
905
422
            Image(i) => Image(i.clone()),
906
181
            VirtualView => VirtualView,
907
506
            Self::TransientWindow(c) => Self::TransientWindow(*c),
908
3504
            Icon(s) => Icon(BoxOrStatic::heap(s.clone_self())),
909
1
            GeolocationProbe(cfg) => GeolocationProbe(*cfg),
910
            Self::PageBreak => Self::PageBreak,
911
        }
912
1756624
    }
913

            
914
    #[must_use]
915
38950
    pub fn format(&self) -> Option<String> {
916
        use self::NodeType::{GeolocationProbe, Icon, Image, Text, TransientWindow, VirtualView};
917
38950
        match self {
918
29396
            Text(s) => Some(format!("{s}")),
919
1
            Image(id) => Some(format!("image({id:?})")),
920
2
            VirtualView => Some("virtualized-view".to_string()),
921
            TransientWindow(c) => Some(format!("transient-window(open={})", c.open)),
922
2
            Icon(s) => Some(format!("icon({s})")),
923
6
            GeolocationProbe(cfg) => Some(format!(
924
6
                "geolocation-probe(hi={}, bg={}, max={}m, every={}ms)",
925
6
                cfg.high_accuracy, cfg.background, cfg.max_accuracy_m, cfg.min_interval_ms
926
6
            )),
927
9543
            _ => None,
928
        }
929
38950
    }
930

            
931
    /// Returns the `NodeTypeTag` for CSS selector matching.
932
    #[allow(clippy::too_many_lines)] // large but cohesive: single-purpose parser/builder/dispatch (one branch per input variant)
933
    #[must_use]
934
696842
    pub const fn get_path(&self) -> NodeTypeTag {
935
696842
        match self {
936
5462
            Self::Html => NodeTypeTag::Html,
937
            Self::Head => NodeTypeTag::Head,
938
21083
            Self::Body => NodeTypeTag::Body,
939
120901
            Self::Div => NodeTypeTag::Div,
940
149183
            Self::P => NodeTypeTag::P,
941
            Self::Article => NodeTypeTag::Article,
942
            Self::Section => NodeTypeTag::Section,
943
            Self::Nav => NodeTypeTag::Nav,
944
            Self::Aside => NodeTypeTag::Aside,
945
            Self::Header => NodeTypeTag::Header,
946
            Self::Footer => NodeTypeTag::Footer,
947
            Self::Main => NodeTypeTag::Main,
948
            Self::Figure => NodeTypeTag::Figure,
949
            Self::FigCaption => NodeTypeTag::FigCaption,
950
3639
            Self::H1 => NodeTypeTag::H1,
951
2076
            Self::H2 => NodeTypeTag::H2,
952
348
            Self::H3 => NodeTypeTag::H3,
953
12
            Self::H4 => NodeTypeTag::H4,
954
12
            Self::H5 => NodeTypeTag::H5,
955
15
            Self::H6 => NodeTypeTag::H6,
956
15
            Self::Br => NodeTypeTag::Br,
957
            Self::Hr => NodeTypeTag::Hr,
958
48
            Self::Pre => NodeTypeTag::Pre,
959
336
            Self::BlockQuote => NodeTypeTag::BlockQuote,
960
            Self::Address => NodeTypeTag::Address,
961
            Self::Details => NodeTypeTag::Details,
962
            Self::Summary => NodeTypeTag::Summary,
963
            Self::Dialog => NodeTypeTag::Dialog,
964
3720
            Self::Ul => NodeTypeTag::Ul,
965
            Self::Ol => NodeTypeTag::Ol,
966
11424
            Self::Li => NodeTypeTag::Li,
967
            Self::Dl => NodeTypeTag::Dl,
968
            Self::Dt => NodeTypeTag::Dt,
969
            Self::Dd => NodeTypeTag::Dd,
970
            Self::Menu => NodeTypeTag::Menu,
971
            Self::MenuItem => NodeTypeTag::MenuItem,
972
            Self::Dir => NodeTypeTag::Dir,
973
483
            Self::Table => NodeTypeTag::Table,
974
            Self::Caption => NodeTypeTag::Caption,
975
48
            Self::THead => NodeTypeTag::THead,
976
            Self::TBody => NodeTypeTag::TBody,
977
            Self::TFoot => NodeTypeTag::TFoot,
978
504
            Self::Tr => NodeTypeTag::Tr,
979
96
            Self::Th => NodeTypeTag::Th,
980
1107
            Self::Td => NodeTypeTag::Td,
981
            Self::ColGroup => NodeTypeTag::ColGroup,
982
            Self::Col => NodeTypeTag::Col,
983
            Self::Form => NodeTypeTag::Form,
984
            Self::FieldSet => NodeTypeTag::FieldSet,
985
            Self::Legend => NodeTypeTag::Legend,
986
            Self::Label => NodeTypeTag::Label,
987
27
            Self::Input => NodeTypeTag::Input,
988
19827
            Self::Button => NodeTypeTag::Button,
989
3
            Self::Select => NodeTypeTag::Select,
990
            Self::OptGroup => NodeTypeTag::OptGroup,
991
            Self::SelectOption => NodeTypeTag::SelectOption,
992
3
            Self::TextArea => NodeTypeTag::TextArea,
993
            Self::Output => NodeTypeTag::Output,
994
            Self::Progress => NodeTypeTag::Progress,
995
            Self::Meter => NodeTypeTag::Meter,
996
            Self::DataList => NodeTypeTag::DataList,
997
1848
            Self::Span => NodeTypeTag::Span,
998
603
            Self::A => NodeTypeTag::A,
999
336
            Self::Em => NodeTypeTag::Em,
336
            Self::Strong => NodeTypeTag::Strong,
            Self::B => NodeTypeTag::B,
            Self::I => NodeTypeTag::I,
            Self::U => NodeTypeTag::U,
            Self::S => NodeTypeTag::S,
            Self::Mark => NodeTypeTag::Mark,
            Self::Del => NodeTypeTag::Del,
            Self::Ins => NodeTypeTag::Ins,
336
            Self::Code => NodeTypeTag::Code,
            Self::Samp => NodeTypeTag::Samp,
            Self::Kbd => NodeTypeTag::Kbd,
            Self::Var => NodeTypeTag::Var,
            Self::Cite => NodeTypeTag::Cite,
            Self::Dfn => NodeTypeTag::Dfn,
            Self::Abbr => NodeTypeTag::Abbr,
            Self::Acronym => NodeTypeTag::Acronym,
            Self::Q => NodeTypeTag::Q,
            Self::Time => NodeTypeTag::Time,
            Self::Sub => NodeTypeTag::Sub,
            Self::Sup => NodeTypeTag::Sup,
            Self::Small => NodeTypeTag::Small,
            Self::Big => NodeTypeTag::Big,
            Self::Bdo => NodeTypeTag::Bdo,
            Self::Bdi => NodeTypeTag::Bdi,
            Self::Wbr => NodeTypeTag::Wbr,
            Self::Ruby => NodeTypeTag::Ruby,
            Self::Rt => NodeTypeTag::Rt,
            Self::Rtc => NodeTypeTag::Rtc,
            Self::Rp => NodeTypeTag::Rp,
            Self::Data => NodeTypeTag::Data,
            Self::Canvas => NodeTypeTag::Canvas,
            Self::Object => NodeTypeTag::Object,
            Self::Param => NodeTypeTag::Param,
            Self::Embed => NodeTypeTag::Embed,
            Self::Audio => NodeTypeTag::Audio,
            Self::Video => NodeTypeTag::Video,
            Self::Source => NodeTypeTag::Source,
            Self::Track => NodeTypeTag::Track,
            Self::Map => NodeTypeTag::Map,
            Self::Area => NodeTypeTag::Area,
            // SVG — all variants map 1:1 to NodeTypeTag
183
            Self::Svg => NodeTypeTag::Svg,
            Self::SvgG => NodeTypeTag::SvgG,
24
            Self::SvgDefs => NodeTypeTag::SvgDefs,
            Self::SvgSymbol => NodeTypeTag::SvgSymbol,
            Self::SvgUse => NodeTypeTag::SvgUse,
            Self::SvgSwitch => NodeTypeTag::SvgSwitch,
99
            Self::SvgPath => NodeTypeTag::SvgPath,
            Self::SvgCircle => NodeTypeTag::SvgCircle,
84
            Self::SvgRect => NodeTypeTag::SvgRect,
            Self::SvgEllipse => NodeTypeTag::SvgEllipse,
            Self::SvgLine => NodeTypeTag::SvgLine,
            Self::SvgPolygon => NodeTypeTag::SvgPolygon,
            Self::SvgPolyline => NodeTypeTag::SvgPolyline,
3
            Self::SvgText(_) => NodeTypeTag::SvgText,
            Self::SvgTspan => NodeTypeTag::SvgTspan,
            Self::SvgTextPath => NodeTypeTag::SvgTextPath,
            Self::SvgLinearGradient => NodeTypeTag::SvgLinearGradient,
            Self::SvgRadialGradient => NodeTypeTag::SvgRadialGradient,
            Self::SvgStop => NodeTypeTag::SvgStop,
            Self::SvgPattern => NodeTypeTag::SvgPattern,
            Self::SvgClipPathElement => NodeTypeTag::SvgClipPathElement,
            Self::SvgMask => NodeTypeTag::SvgMask,
            Self::SvgFilter => NodeTypeTag::SvgFilter,
            Self::SvgFeBlend => NodeTypeTag::SvgFeBlend,
            Self::SvgFeColorMatrix => NodeTypeTag::SvgFeColorMatrix,
            Self::SvgFeComponentTransfer => NodeTypeTag::SvgFeComponentTransfer,
            Self::SvgFeComposite => NodeTypeTag::SvgFeComposite,
            Self::SvgFeConvolveMatrix => NodeTypeTag::SvgFeConvolveMatrix,
            Self::SvgFeDiffuseLighting => NodeTypeTag::SvgFeDiffuseLighting,
            Self::SvgFeDisplacementMap => NodeTypeTag::SvgFeDisplacementMap,
            Self::SvgFeDistantLight => NodeTypeTag::SvgFeDistantLight,
            Self::SvgFeDropShadow => NodeTypeTag::SvgFeDropShadow,
            Self::SvgFeFlood => NodeTypeTag::SvgFeFlood,
            Self::SvgFeFuncR => NodeTypeTag::SvgFeFuncR,
            Self::SvgFeFuncG => NodeTypeTag::SvgFeFuncG,
            Self::SvgFeFuncB => NodeTypeTag::SvgFeFuncB,
            Self::SvgFeFuncA => NodeTypeTag::SvgFeFuncA,
            Self::SvgFeGaussianBlur => NodeTypeTag::SvgFeGaussianBlur,
            Self::SvgFeImage => NodeTypeTag::SvgFeImage,
            Self::SvgFeMerge => NodeTypeTag::SvgFeMerge,
            Self::SvgFeMergeNode => NodeTypeTag::SvgFeMergeNode,
            Self::SvgFeMorphology => NodeTypeTag::SvgFeMorphology,
            Self::SvgFeOffset => NodeTypeTag::SvgFeOffset,
            Self::SvgFePointLight => NodeTypeTag::SvgFePointLight,
            Self::SvgFeSpecularLighting => NodeTypeTag::SvgFeSpecularLighting,
            Self::SvgFeSpotLight => NodeTypeTag::SvgFeSpotLight,
            Self::SvgFeTile => NodeTypeTag::SvgFeTile,
            Self::SvgFeTurbulence => NodeTypeTag::SvgFeTurbulence,
            Self::SvgMarker => NodeTypeTag::SvgMarker,
3
            Self::SvgImage(_) => NodeTypeTag::SvgImage,
            Self::SvgForeignObject => NodeTypeTag::SvgForeignObject,
            Self::SvgTitle => NodeTypeTag::SvgTitle,
            Self::SvgDesc => NodeTypeTag::SvgDesc,
            Self::SvgMetadata => NodeTypeTag::SvgMetadata,
            Self::SvgA => NodeTypeTag::SvgA,
            Self::SvgView => NodeTypeTag::SvgView,
            Self::SvgStyle => NodeTypeTag::SvgStyle,
            Self::SvgScript => NodeTypeTag::SvgScript,
            Self::SvgAnimate => NodeTypeTag::SvgAnimate,
            Self::SvgAnimateMotion => NodeTypeTag::SvgAnimateMotion,
            Self::SvgAnimateTransform => NodeTypeTag::SvgAnimateTransform,
            Self::SvgSet => NodeTypeTag::SvgSet,
            Self::SvgMpath => NodeTypeTag::SvgMpath,
            // HTML metadata
            Self::Title => NodeTypeTag::Title,
            Self::Meta => NodeTypeTag::Meta,
            Self::Link => NodeTypeTag::Link,
            Self::Script => NodeTypeTag::Script,
            Self::Style => NodeTypeTag::Style,
            Self::Base => NodeTypeTag::Base,
332030
            Self::Text(_) => NodeTypeTag::Text,
416
            Self::Image(_) => NodeTypeTag::Img,
339
            Self::VirtualView => NodeTypeTag::VirtualView,
            Self::TransientWindow(_) => NodeTypeTag::TransientWindow,
19791
            Self::Icon(_) => NodeTypeTag::Icon,
3
            Self::GeolocationProbe(_) => NodeTypeTag::GeolocationProbe,
24
            Self::PageBreak => NodeTypeTag::PageBreak,
3
            Self::Before => NodeTypeTag::Before,
3
            Self::After => NodeTypeTag::After,
3
            Self::Marker => NodeTypeTag::Marker,
3
            Self::Placeholder => NodeTypeTag::Placeholder,
        }
696842
    }
    /// Returns whether this node type is a semantic HTML element that should
    /// automatically generate an accessibility tree node.
    ///
    /// These are elements with inherent semantic meaning that assistive
    /// technologies should be aware of, even without explicit ARIA attributes.
    #[must_use]
41
    pub const fn is_semantic_for_accessibility(&self) -> bool {
24
        matches!(
41
            self,
            Self::Button
                | Self::Input
                | Self::TextArea
                | Self::Select
                | Self::A
                | Self::H1
                | Self::H2
                | Self::H3
                | Self::H4
                | Self::H5
                | Self::H6
                | Self::Article
                | Self::Section
                | Self::Nav
                | Self::Main
                | Self::Header
                | Self::Footer
                | Self::Aside
        )
41
    }
}
/// Represents the CSS formatting context for an element
#[derive(Clone, Copy, PartialEq, Eq)]
// [g147f az-web-lift] `#[repr(C, u8)]` forces an explicit u8 discriminant at offset 0 instead of
// letting Rust niche-pack the other variants' discriminants into the payload variants'
// (Block{bool}/Float/OutOfFlow) invalid byte values. The remill lift mis-decodes that niche
// encoding: `Block` (byte 0/1) reads correctly but `Inline` (a niche value) reads as garbage →
// `match` falls to `_` → nested <div>text</div> dispatches to layout_bfc instead of layout_ifc and
// its text never lays out (g147 root cause). Same fix pattern as the text3 enums
// (InlineContent/LogicalItem/ShapedItem/FontStack/LayoutError). Harmless + correct for native.
#[repr(C, u8)]
// +spec:display-property:844893 - block-level box establishing a new formatting context (BFC)
// modeled here
pub enum FormattingContext {
    /// Block-level formatting context
    Block {
        /// Whether this element establishes a new block formatting context
        establishes_new_context: bool,
    },
    /// Inline-level formatting context
    Inline,
    /// Inline-block (participates in an IFC but creates a BFC)
    InlineBlock,
    /// Flex formatting context
    Flex,
    /// Float (left or right)
    Float(LayoutFloat),
    /// Absolutely positioned (out of flow)
    OutOfFlow(LayoutPosition),
    /// Table formatting context (container)
    Table,
    /// Table row group formatting context (thead, tbody, tfoot)
    TableRowGroup,
    /// Table row formatting context
    TableRow,
    /// Table cell formatting context (td, th)
    TableCell,
    /// Table column group formatting context
    TableColumnGroup,
    /// Table caption formatting context
    TableCaption,
    /// Grid formatting context
    Grid,
    /// display:contents - element generates no box, children promoted to parent
    Contents,
    /// No formatting context (display: none)
    None,
}
impl fmt::Debug for FormattingContext {
541318
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
541318
        match self {
            Self::Block {
41640
                establishes_new_context,
41640
            } => write!(
41640
                f,
41640
                "Block {{ establishes_new_context: {establishes_new_context:?} }}"
            ),
462164
            Self::Inline => write!(f, "Inline"),
1116
            Self::InlineBlock => write!(f, "InlineBlock"),
31442
            Self::Flex => write!(f, "Flex"),
            Self::Float(layout_float) => write!(f, "Float({layout_float:?})"),
            Self::OutOfFlow(layout_position) => {
                write!(f, "OutOfFlow({layout_position:?})")
            }
84
            Self::Grid => write!(f, "Grid"),
            Self::None => write!(f, "None"),
552
            Self::Table => write!(f, "Table"),
            Self::TableRowGroup => write!(f, "TableRowGroup"),
60
            Self::TableRow => write!(f, "TableRow"),
4260
            Self::TableCell => write!(f, "TableCell"),
            Self::TableColumnGroup => write!(f, "TableColumnGroup"),
            Self::TableCaption => write!(f, "TableCaption"),
            Self::Contents => write!(f, "Contents"),
        }
541318
    }
}
impl Default for FormattingContext {
836
    fn default() -> Self {
836
        Self::Block {
836
            establishes_new_context: false,
836
        }
836
    }
}
/// Defines the type of event that can trigger a callback action.
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
#[repr(C)]
pub enum On {
    /// Mouse cursor is hovering over the element.
    MouseOver,
    /// Mouse cursor is over the element and a button is pressed.
    ///
    /// NOT a click: a press is not an activation (the user can still release
    /// elsewhere, and it never fires for keyboard or assistive-technology
    /// activation). Use [`On::Click`] for "the user activated this".
    MouseDown,
    /// (Specialization of `MouseDown`). Fires only if the left mouse button
    /// has been pressed while cursor was over the element.
    LeftMouseDown,
    /// (Specialization of `MouseDown`). Fires only if the middle mouse button
    /// has been pressed while cursor was over the element.
    MiddleMouseDown,
    /// (Specialization of `MouseDown`). Fires only if the right mouse button
    /// has been pressed while cursor was over the element.
    RightMouseDown,
    /// The element was ACTIVATED: pressed and released on the same node (W3C
    /// `click`), or activated from the keyboard (Enter / Space on a focused
    /// element) or by an assistive technology's default action.
    ///
    /// THIS is what a "click handler" wants. `MouseUp` is the raw pointer
    /// release: it fires for any button, it fires when the press began
    /// elsewhere, and it never fires for a keyboard or screen-reader
    /// activation - which is why activation handlers written against it were
    /// unreachable from the keyboard (2026-09-01).
    Click,
    /// Mouse button has been released while cursor was over the element.
    MouseUp,
    /// (Specialization of `MouseUp`). Fires only if the left mouse button has
    /// been released while cursor was over the element.
    LeftMouseUp,
    /// (Specialization of `MouseUp`). Fires only if the middle mouse button has
    /// been released while cursor was over the element.
    MiddleMouseUp,
    /// (Specialization of `MouseUp`). Fires only if the right mouse button has
    /// been released while cursor was over the element.
    RightMouseUp,
    /// Mouse cursor has entered the element.
    MouseEnter,
    /// Mouse cursor has left the element.
    MouseLeave,
    /// Mousewheel / touchpad scrolling.
    Scroll,
    /// The window received a unicode character (also respects the system locale).
    /// Check `keyboard_state.current_char` to get the current pressed character.
    TextInput,
    /// A **virtual keycode** was pressed. Note: This is only the virtual keycode,
    /// not the actual char. If you want to get the character, use `TextInput` instead.
    /// A virtual key does not have to map to a printable character.
    ///
    /// You can get all currently pressed virtual keycodes in the
    /// `keyboard_state.current_virtual_keycodes` and / or just the last keycode in the
    /// `keyboard_state.latest_virtual_keycode`.
    VirtualKeyDown,
    /// A **virtual keycode** was release. See `VirtualKeyDown` for more info.
    VirtualKeyUp,
    /// A file has been dropped on the element.
    HoveredFile,
    /// A file is being hovered on the element.
    DroppedFile,
    /// A file was hovered, but has exited the window.
    HoveredFileCancelled,
    /// Equivalent to `onfocus`.
    FocusReceived,
    /// Equivalent to `onblur`.
    FocusLost,
    // Accessibility-specific events
    /// Default action triggered by screen reader (usually same as click/activate)
    Default,
    /// Element should collapse (e.g., accordion panel, tree node)
    Collapse,
    /// Element should expand (e.g., accordion panel, tree node)
    Expand,
    /// Increment value (e.g., number input, slider)
    Increment,
    /// Decrement value (e.g., number input, slider)
    Decrement,
    /// A structural document edit (split / merge / wrap / replace…) was
    /// recorded on (or under) this element and awaits the app's
    /// apply-and-ack (fires once per changeset; focus-scoped, bubbles to
    /// the contenteditable root). APPENDED at the enum tail for ABI
    /// stability.
    DocumentEdit,
    /// The focused editable's text was COMMITTED (typing, IME, deletion,
    /// paste, undo/redo) - the post-commit counterpart of `TextInput`, which
    /// fires before the pending insertion is applied. Read the committed
    /// text through `get_unsynced_text_edits`. APPENDED at the enum tail for
    /// ABI stability.
    TextChanged,
    /// Mouse cursor MOVED while over the element. APPENDED at the end.
    ///
    /// W3C `mousemove`. [`On::MouseOver`] is the ENTRY event; this is the
    /// one that fires continuously while the pointer travels across the
    /// element.
    MouseMove,
}
/// Contains the necessary information to render an embedded `VirtualView` node.
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[repr(C)]
pub struct VirtualViewNode {
    /// The callback function that returns the DOM for the virtualized view's content.
    pub callback: VirtualViewCallback,
    /// The application data passed to the virtualized view's layout callback.
    pub refany: RefAny,
}
/// An enum that holds either a CSS ID or a class name as a string.
#[repr(C, u8)]
#[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub enum IdOrClass {
    Id(AzString),
    Class(AzString),
}
impl_option!(
    IdOrClass,
    OptionIdOrClass,
    copy = false,
    [Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord]
);
impl_vec!(
    IdOrClass,
    IdOrClassVec,
    IdOrClassVecDestructor,
    IdOrClassVecDestructorType,
    IdOrClassVecSlice,
    OptionIdOrClass
);
impl_vec_debug!(IdOrClass, IdOrClassVec);
impl_vec_partialord!(IdOrClass, IdOrClassVec);
impl_vec_ord!(IdOrClass, IdOrClassVec);
impl_vec_clone!(IdOrClass, IdOrClassVec, IdOrClassVecDestructor);
impl_vec_partialeq!(IdOrClass, IdOrClassVec);
impl_vec_eq!(IdOrClass, IdOrClassVec);
impl_vec_hash!(IdOrClass, IdOrClassVec);
impl IdOrClass {
    #[must_use]
3
    pub fn as_id(&self) -> Option<&str> {
3
        match self {
2
            Self::Id(s) => Some(s.as_str()),
1
            Self::Class(_) => None,
        }
3
    }
    #[must_use]
35
    pub fn as_class(&self) -> Option<&str> {
35
        match self {
34
            Self::Class(s) => Some(s.as_str()),
1
            Self::Id(_) => None,
        }
35
    }
}
/// Name-value pair for custom attributes (data-*, aria-*, etc.)
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[repr(C)]
pub struct AttributeNameValue {
    pub attr_name: AzString,
    pub value: AzString,
}
/// Strongly-typed HTML attribute with type-safe values.
///
/// This enum provides a type-safe way to represent HTML attributes, ensuring that
/// values are validated at compile-time and properly converted to their string
/// representations at runtime.
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[repr(C, u8)]
pub enum AttributeType {
    /// Element ID attribute (`id="..."`)
    Id(AzString),
    /// CSS class attribute (`class="..."`)
    Class(AzString),
    /// Accessible name/label (`aria-label="..."`)
    AriaLabel(AzString),
    /// Element that labels this one (`aria-labelledby="..."`)
    AriaLabelledBy(AzString),
    /// Element that describes this one (`aria-describedby="..."`)
    AriaDescribedBy(AzString),
    /// Role for accessibility (`role="..."`)
    AriaRole(AzString),
    /// Current state of an element (`aria-checked`, `aria-selected`, etc.)
    AriaState(AttributeNameValue),
    /// ARIA property (`aria-*`)
    AriaProperty(AttributeNameValue),
    /// Hyperlink target URL (`href="..."`)
    Href(AzString),
    /// Link relationship (`rel="..."`)
    Rel(AzString),
    /// Link target frame (`target="..."`)
    Target(AzString),
    /// Image source URL (`src="..."`)
    Src(AzString),
    /// Alternative text for images (`alt="..."`)
    Alt(AzString),
    /// Image title (tooltip) (`title="..."`)
    Title(AzString),
    /// Form input name (`name="..."`)
    Name(AzString),
    /// Form input value (`value="..."`)
    Value(AzString),
    /// Input type (`type="text|password|email|..."`)
    InputType(AzString),
    /// Placeholder text (`placeholder="..."`)
    Placeholder(AzString),
    /// Input is required (`required`)
    Required,
    /// Input is disabled (`disabled`)
    Disabled,
    /// Input is readonly (`readonly`)
    Readonly,
    /// Input is checked (checkbox/radio) (`checked`)
    CheckedTrue,
    /// Input is unchecked (checkbox/radio)
    CheckedFalse,
    /// Input is selected (option) (`selected`)
    Selected,
    /// Maximum value for number inputs (`max="..."`)
    Max(AzString),
    /// Minimum value for number inputs (`min="..."`)
    Min(AzString),
    /// Step value for number inputs (`step="..."`)
    Step(AzString),
    /// Input pattern for validation (`pattern="..."`)
    Pattern(AzString),
    /// Minimum length (`minlength="..."`)
    MinLength(i32),
    /// Maximum length (`maxlength="..."`)
    MaxLength(i32),
    /// Autocomplete behavior (`autocomplete="on|off|..."`)
    Autocomplete(AzString),
    /// Table header scope (`scope="row|col|rowgroup|colgroup"`)
    Scope(AzString),
    /// Number of columns to span (`colspan="..."`)
    ColSpan(i32),
    /// Number of rows to span (`rowspan="..."`)
    RowSpan(i32),
    /// Tab index for keyboard navigation (`tabindex="..."`)
    TabIndex(i32),
    /// Element can receive focus (`tabindex="0"` equivalent)
    Focusable,
    /// Take focus when the window first shows this element (`autofocus`).
    ///
    /// HTML semantics: the FIRST autofocus element in the document wins, and
    /// it is focused WITHOUT showing a focus ring - the ring is for keyboard
    /// navigation (`:focus-visible`), and a form that opens with its first
    /// field ringed looks like the user pressed Tab when they did not.
    Autofocus,
    /// Language code (`lang="..."`)
    Lang(AzString),
    /// Text direction (`dir="ltr|rtl|auto"`)
    Dir(AzString),
    /// Content is editable (`contenteditable="true|false"`)
    ContentEditable(bool),
    /// Element is draggable (`draggable="true|false"`)
    Draggable(bool),
    /// Element is hidden (`hidden`)
    Hidden,
    /// Generic data attribute (`data-*="..."`)
    Data(AttributeNameValue),
    /// Generic custom attribute (for future extensibility)
    Custom(AttributeNameValue),
}
impl_option!(
    AttributeType,
    OptionAttributeType,
    copy = false,
    [Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash]
);
impl_vec!(
    AttributeType,
    AttributeTypeVec,
    AttributeTypeVecDestructor,
    AttributeTypeVecDestructorType,
    AttributeTypeVecSlice,
    OptionAttributeType
);
impl_vec_debug!(AttributeType, AttributeTypeVec);
impl_vec_partialord!(AttributeType, AttributeTypeVec);
impl_vec_ord!(AttributeType, AttributeTypeVec);
impl_vec_clone!(AttributeType, AttributeTypeVec, AttributeTypeVecDestructor);
impl_vec_partialeq!(AttributeType, AttributeTypeVec);
impl_vec_eq!(AttributeType, AttributeTypeVec);
impl_vec_hash!(AttributeType, AttributeTypeVec);
impl AttributeType {
    /// Returns the id string if this is an `Id` attribute, `None` otherwise.
    #[must_use]
71340
    pub fn as_id(&self) -> Option<&str> {
71340
        match self {
62142
            Self::Id(s) => Some(s.as_str()),
9198
            _ => None,
        }
71340
    }
    /// Returns the class string if this is a `Class` attribute, `None` otherwise.
    #[must_use]
230965
    pub fn as_class(&self) -> Option<&str> {
230965
        match self {
228955
            Self::Class(s) => Some(s.as_str()),
2010
            _ => None,
        }
230965
    }
    /// Get the attribute name (e.g., "href", "aria-label", "data-foo")
    #[must_use]
420
    pub fn name(&self) -> &str {
420
        match self {
20
            Self::Id(_) => "id",
69
            Self::Class(_) => "class",
1
            Self::AriaLabel(_) => "aria-label",
1
            Self::AriaLabelledBy(_) => "aria-labelledby",
1
            Self::AriaDescribedBy(_) => "aria-describedby",
1
            Self::AriaRole(_) => "role",
52
            Self::AriaState(nv) | Self::AriaProperty(nv) | Self::Data(nv) | Self::Custom(nv) => {
55
                nv.attr_name.as_str()
            }
134
            Self::Href(_) => "href",
1
            Self::Rel(_) => "rel",
1
            Self::Target(_) => "target",
1
            Self::Src(_) => "src",
1
            Self::Alt(_) => "alt",
1
            Self::Title(_) => "title",
1
            Self::Name(_) => "name",
2
            Self::Value(_) => "value",
39
            Self::InputType(_) => "type",
1
            Self::Placeholder(_) => "placeholder",
1
            Self::Required => "required",
1
            Self::Disabled => "disabled",
1
            Self::Readonly => "readonly",
4
            Self::CheckedTrue | Self::CheckedFalse => "checked",
1
            Self::Selected => "selected",
1
            Self::Max(_) => "max",
1
            Self::Min(_) => "min",
1
            Self::Step(_) => "step",
1
            Self::Pattern(_) => "pattern",
1
            Self::MinLength(_) => "minlength",
1
            Self::MaxLength(_) => "maxlength",
1
            Self::Autocomplete(_) => "autocomplete",
1
            Self::Scope(_) => "scope",
1
            Self::ColSpan(_) => "colspan",
1
            Self::RowSpan(_) => "rowspan",
4
            Self::TabIndex(_) | Self::Focusable => "tabindex",
1
            Self::Autofocus => "autofocus",
63
            Self::Lang(_) => "lang",
1
            Self::Dir(_) => "dir",
1
            Self::ContentEditable(_) => "contenteditable",
1
            Self::Draggable(_) => "draggable",
1
            Self::Hidden => "hidden",
        }
420
    }
    /// Get the attribute value as a string
    #[must_use]
429
    pub fn value(&self) -> AzString {
429
        match self {
20
            Self::Id(v)
69
            | Self::Class(v)
1
            | Self::AriaLabel(v)
1
            | Self::AriaLabelledBy(v)
1
            | Self::AriaDescribedBy(v)
1
            | Self::AriaRole(v)
134
            | Self::Href(v)
1
            | Self::Rel(v)
1
            | Self::Target(v)
1
            | Self::Src(v)
1
            | Self::Alt(v)
1
            | Self::Title(v)
1
            | Self::Name(v)
2
            | Self::Value(v)
39
            | Self::InputType(v)
1
            | Self::Placeholder(v)
1
            | Self::Max(v)
1
            | Self::Min(v)
1
            | Self::Step(v)
1
            | Self::Pattern(v)
1
            | Self::Autocomplete(v)
1
            | Self::Scope(v)
63
            | Self::Lang(v)
345
            | Self::Dir(v) => v.clone(),
47
            Self::AriaState(nv) | Self::AriaProperty(nv) | Self::Data(nv) | Self::Custom(nv) => {
50
                nv.value.clone()
            }
2
            Self::MinLength(n)
2
            | Self::MaxLength(n)
2
            | Self::ColSpan(n)
2
            | Self::RowSpan(n)
10
            | Self::TabIndex(n) => n.to_string().into(),
2
            Self::Focusable => "0".into(),
            // Boolean attribute: present means true, as in HTML.
1
            Self::Autofocus => "true".into(),
3
            Self::ContentEditable(b) | Self::Draggable(b) => {
6
                if *b {
3
                    "true".into()
                } else {
3
                    "false".into()
                }
            }
            Self::Required
            | Self::Disabled
            | Self::Readonly
            | Self::CheckedTrue
            | Self::CheckedFalse
            | Self::Selected
15
            | Self::Hidden => "".into(), // Boolean attributes
        }
429
    }
    /// Check if this is a boolean attribute (present = true, absent = false)
    #[must_use]
48
    pub const fn is_boolean(&self) -> bool {
39
        matches!(
48
            self,
            Self::Required
                | Self::Disabled
                | Self::Readonly
                | Self::CheckedTrue
                | Self::CheckedFalse
                | Self::Selected
                | Self::Hidden
        )
48
    }
}
/// Represents all data associated with a single DOM node, such as its type,
/// classes, IDs, callbacks, and inline styles.
#[repr(C)]
#[derive(Debug)]
pub struct NodeData {
    /// `div`, `p`, `img`, etc.
    pub node_type: NodeType,
    /// Callbacks attached to this node:
    ///
    /// `On::Click` -> `Callback(my_button_click_handler)`
    pub callbacks: CoreCallbackDataVec,
    /// Inline style: a `Css` value that applies only to this node (implicit `:scope`).
    /// Each rule carries conditions (@media/@os/:hover/...) and declarations; rules
    /// produced by parsing inline strings are tagged `rule_priority::INLINE`, while
    /// widget defaults pushed via `with_css_props` keep the same INLINE priority so
    /// they override author CSS — preserving the cascade priority that the previous
    /// per-property `css_props` field had.
    pub style: azul_css::css::Css,
    /// Packed flags: `tab_index` + contenteditable + `is_anonymous`.
    pub flags: NodeFlags,
    /// Optional extra accessibility information about this DOM node (MSAA, AT-SPI, UA).
    /// 8 bytes (Option<Box<T>> is pointer-sized).
    pub accessibility: Option<Box<AccessibilityInfo>>,
    /// Stores "extra", not commonly used data of the node: clip-mask, menus, etc.
    ///
    /// SHOULD NOT EXPOSED IN THE API - necessary to retroactively add functionality
    /// to the node without breaking the ABI.
    extra: Option<Box<NodeDataExt>>,
}
impl_option!(
    NodeData,
    OptionNodeData,
    copy = false,
    [Debug, PartialEq, Eq, PartialOrd, Ord]
);
// Manual equality/ordering (was derived) for ONE reason: an `extra` that is
// identity-empty - it exists only to carry a MARKER - must compare equal to
// no `extra` at all. Markers are minted fresh (UUID strings) every `layout()`
// and are excluded from node identity wholesale (USER ruling 2026-08-29); the
// `NodeDataExt` impls already skip the field, and this normalization covers
// the marked-vs-never-extended pair.
impl NodeData {
    /// `extra` as it counts toward IDENTITY: `None` when absent or when the
    /// ext carries nothing but a marker.
92336
    fn identity_extra(&self) -> Option<&NodeDataExt> {
92336
        self.extra.as_deref().filter(|e| !e.is_identity_empty())
92336
    }
}
/// The double-drop guard. `NodeData` owns two `Box`es (`accessibility`,
/// `extra`); the codegen FFI mirror (`AzNodeData`) is dropped by
/// `drop_in_place` of this type FIRST and then by Rust's drop glue for its
/// own fields when it is embedded by value in another wrapper — the same
/// bytes twice. Taking each `Box` out before freeing it leaves `None`
/// behind, so the second drop finds nothing; the `Vec` / `String` fields
/// already gate themselves (`destructor == AlreadyDestroyed`).
impl Drop for NodeData {
4652354
    fn drop(&mut self) {
4652354
        drop(self.accessibility.take());
4652354
        drop(self.extra.take());
4652354
    }
}
impl PartialEq for NodeData {
46193
    fn eq(&self, other: &Self) -> bool {
46193
        self.node_type == other.node_type
46193
            && self.callbacks == other.callbacks
46181
            && self.style == other.style
46167
            && self.flags == other.flags
46167
            && self.accessibility == other.accessibility
46167
            && self.identity_extra() == other.identity_extra()
46193
    }
}
impl Eq for NodeData {}
impl PartialOrd for NodeData {
1
    fn partial_cmp(&self, other: &Self) -> Option<core::cmp::Ordering> {
1
        Some(self.cmp(other))
1
    }
}
impl Ord for NodeData {
1
    fn cmp(&self, other: &Self) -> core::cmp::Ordering {
1
        (
1
            &self.node_type,
1
            &self.callbacks,
1
            &self.style,
1
            &self.flags,
1
            &self.accessibility,
1
            self.identity_extra(),
1
        )
1
            .cmp(&(
1
                &other.node_type,
1
                &other.callbacks,
1
                &other.style,
1
                &other.flags,
1
                &other.accessibility,
1
                other.identity_extra(),
1
            ))
1
    }
}
impl Hash for NodeData {
140447
    fn hash<H: Hasher>(&self, state: &mut H) {
140447
        self.node_type.hash(state);
140447
        self.attributes().as_ref().hash(state);
140447
        self.flags.hash(state);
        // NOTE: callbacks are NOT hashed regularly, otherwise
        // they'd cause inconsistencies because of the scroll callback
140447
        for callback in self.callbacks.as_ref() {
2327
            callback.event.hash(state);
2327
            callback.callback.hash(state);
2327
            callback.refany.get_type_id().hash(state);
2327
        }
        // Hash inline CSS properties (Static declarations only — same set the
        // legacy `css_props` field hashed). Conditions are intentionally
        // skipped to match the previous behaviour.
140447
        for (prop, _conds) in self.style.iter_inline_properties() {
1678
            mem::discriminant(prop).hash(state);
1678
        }
140447
        if let Some(ext) = self.extra.as_ref() {
104359
            if let Some(ds) = ext.dataset.as_ref() {
159
                ds.hash(state);
104224
            }
104359
            if let Some(c) = ext.svg_data.as_ref() {
4
                c.hash(state);
104355
            }
104359
            if let Some(c) = ext.menu_bar.as_ref() {
                c.hash(state);
104359
            }
104359
            if let Some(c) = ext.context_menu.as_ref() {
4
                c.hash(state);
104355
            }
104359
            if let Some(vv) = ext.virtual_view.as_ref() {
                vv.hash(state);
104359
            }
36088
        }
140447
    }
}
/// Tracks which component rendered a DOM subtree.
///
/// When a component's `render_fn` returns a `StyledDom`, the framework stamps the
/// root node(s) of the output with a `ComponentOrigin`. This enables:
/// - The debugger to show a "Component Tree" alongside the DOM tree
/// - Code generation roundtrips (rendered DOM → component invocations → code)
/// - Clicking a DOM node to navigate to the component that produced it
#[derive(Debug, Clone, PartialEq)]
pub struct ComponentOrigin {
    /// Qualified component name, e.g. "shadcn:card", "builtin:div"
    pub component_id: AzString,
    /// Snapshot of the data model at render time, stored as a JSON value.
    /// The debug server can inspect typed values; the frontend serializes
    /// them back to JSON for display and editing.
    pub data_model_json: crate::json::Json,
}
// Manual impls because Json contains f64 (no Eq/Ord/Hash derive),
// but we need them for NodeDataExt. We compare on the Display string.
impl Eq for ComponentOrigin {}
impl PartialOrd for ComponentOrigin {
    fn partial_cmp(&self, other: &Self) -> Option<core::cmp::Ordering> {
        Some(self.cmp(other))
    }
}
impl Ord for ComponentOrigin {
    fn cmp(&self, other: &Self) -> core::cmp::Ordering {
        self.component_id.cmp(&other.component_id).then_with(|| {
            let a = alloc::format!("{}", self.data_model_json);
            let b = alloc::format!("{}", other.data_model_json);
            a.cmp(&b)
        })
    }
}
impl Hash for ComponentOrigin {
2
    fn hash<H: Hasher>(&self, state: &mut H) {
2
        self.component_id.hash(state);
2
        alloc::format!("{}", self.data_model_json).hash(state);
2
    }
}
impl Default for ComponentOrigin {
2
    fn default() -> Self {
2
        Self {
2
            component_id: AzString::from_const_str(""),
2
            data_model_json: crate::json::Json::null(),
2
        }
2
    }
}
/// SVG-specific data stored on a DOM node.
///
/// Each SVG element type stores its parsed attribute data here.
/// Also used for raster image clip masks (legacy C API).
#[derive(Debug, Clone, PartialOrd)]
pub enum SvgNodeData {
    /// Raster R8 image clip mask (legacy C API for chart.c style manual masks).
    ImageClipMask(ImageMask),
    /// `<path d="...">` — resolved path geometry.
    Path(crate::svg::SvgMultiPolygon),
    /// `<circle cx="" cy="" r="">`.
    Circle { cx: f32, cy: f32, r: f32 },
    /// `<rect x="" y="" width="" height="" rx="" ry="">`.
    Rect {
        x: f32,
        y: f32,
        width: f32,
        height: f32,
        rx: f32,
        ry: f32,
    },
    /// `<ellipse cx="" cy="" rx="" ry="">`.
    Ellipse { cx: f32, cy: f32, rx: f32, ry: f32 },
    /// `<line x1="" y1="" x2="" y2="">`.
    Line { x1: f32, y1: f32, x2: f32, y2: f32 },
    /// `<polygon points="">` / `<polyline points="">` — parsed point list.
    PointsList {
        points: alloc::vec::Vec<azul_css::props::basic::SvgPoint>,
        closed: bool,
    },
    /// `<svg viewBox="" width="" height="">` — viewport attributes.
    ViewBox {
        min_x: f32,
        min_y: f32,
        width: f32,
        height: f32,
    },
    /// `<linearGradient>` attributes.
    LinearGradient { x1: f32, y1: f32, x2: f32, y2: f32 },
    /// `<radialGradient>` attributes.
    RadialGradient {
        cx: f32,
        cy: f32,
        r: f32,
        fx: f32,
        fy: f32,
    },
    /// `<stop offset="" stop-color="" stop-opacity="">`.
    GradientStop { offset: f32 },
    /// `<use href="" x="" y="">`.
    Use { href: AzString, x: f32, y: f32 },
    /// `<image href="" x="" y="" width="" height="">`.
    SvgImageData {
        href: AzString,
        x: f32,
        y: f32,
        width: f32,
        height: f32,
    },
}
// PartialEq compares f32 fields by BIT PATTERN (to_bits), mirroring the Hash impl
// below, so a NaN coordinate is equal to itself and Eq/Hash agree. A derived PartialEq
// used raw float `==` (NaN != NaN), breaking Eq's reflexivity for e.g. a NaN Rect —
// and NodeType embeds this type, so the break propagated.
impl PartialEq for SvgNodeData {
    #[allow(clippy::match_same_arms, clippy::similar_names, clippy::too_many_lines)] // SVG coord names (cx/cy/fx/fy, min_x/min_y) are domain-standard; one arm per variant
16
    fn eq(&self, other: &Self) -> bool {
        // f32 bit-equality (matches Hash's to_bits).
56
        const fn fb(a: f32, b: f32) -> bool {
56
            a.to_bits() == b.to_bits()
56
        }
        use self::SvgNodeData::{
            Circle, Ellipse, GradientStop, ImageClipMask, Line, LinearGradient, Path, PointsList,
            RadialGradient, Rect, SvgImageData, Use, ViewBox,
        };
16
        match (self, other) {
            (ImageClipMask(a), ImageClipMask(b)) => a == b,
            (Path(a), Path(b)) => {
                let ra = a.rings.as_ref();
                let rb = b.rings.as_ref();
                ra.len() == rb.len()
                    && ra.iter().zip(rb.iter()).all(|(x, y)| {
                        let ia = x.items.as_ref();
                        let ib = y.items.as_ref();
                        ia.len() == ib.len()
                            && ia
                                .iter()
                                .zip(ib.iter())
                                .all(|(p, q)| svg_path_element_bits_eq(p, q))
                    })
            }
            (
                Circle { cx, cy, r },
                Circle {
                    cx: cx2,
                    cy: cy2,
                    r: r2,
                },
            ) => fb(*cx, *cx2) && fb(*cy, *cy2) && fb(*r, *r2),
            (
                Rect {
1
                    x,
1
                    y,
1
                    width,
1
                    height,
1
                    rx,
1
                    ry,
                },
                Rect {
1
                    x: x2,
1
                    y: y2,
1
                    width: w2,
1
                    height: h2,
1
                    rx: rx2,
1
                    ry: ry2,
                },
            ) => {
1
                fb(*x, *x2)
1
                    && fb(*y, *y2)
1
                    && fb(*width, *w2)
1
                    && fb(*height, *h2)
1
                    && fb(*rx, *rx2)
1
                    && fb(*ry, *ry2)
            }
            (
                Ellipse { cx, cy, rx, ry },
                Ellipse {
                    cx: cx2,
                    cy: cy2,
                    rx: rx2,
                    ry: ry2,
                },
            ) => fb(*cx, *cx2) && fb(*cy, *cy2) && fb(*rx, *rx2) && fb(*ry, *ry2),
            (
                Line { x1, y1, x2, y2 },
                Line {
                    x1: a1,
                    y1: b1,
                    x2: a2,
                    y2: b2,
                },
            )
            | (
                LinearGradient { x1, y1, x2, y2 },
                LinearGradient {
                    x1: a1,
                    y1: b1,
                    x2: a2,
                    y2: b2,
                },
            ) => fb(*x1, *a1) && fb(*y1, *b1) && fb(*x2, *a2) && fb(*y2, *b2),
            (
                PointsList {
                    points: pa,
                    closed: ca,
                },
                PointsList {
                    points: pb,
                    closed: cb,
                },
            ) => {
                ca == cb
                    && pa.len() == pb.len()
                    && pa
                        .iter()
                        .zip(pb.iter())
                        .all(|(p, q)| fb(p.x, q.x) && fb(p.y, q.y))
            }
            (
                ViewBox {
12
                    min_x,
12
                    min_y,
12
                    width,
12
                    height,
                },
                ViewBox {
12
                    min_x: a,
12
                    min_y: b,
12
                    width: w,
12
                    height: h,
                },
12
            ) => fb(*min_x, *a) && fb(*min_y, *b) && fb(*width, *w) && fb(*height, *h),
            (
                RadialGradient { cx, cy, r, fx, fy },
                RadialGradient {
                    cx: cx2,
                    cy: cy2,
                    r: r2,
                    fx: fx2,
                    fy: fy2,
                },
            ) => fb(*cx, *cx2) && fb(*cy, *cy2) && fb(*r, *r2) && fb(*fx, *fx2) && fb(*fy, *fy2),
2
            (GradientStop { offset: a }, GradientStop { offset: b }) => fb(*a, *b),
            (
                Use { href, x, y },
                Use {
                    href: h2,
                    x: x2,
                    y: y2,
                },
            ) => href == h2 && fb(*x, *x2) && fb(*y, *y2),
            (
                SvgImageData {
                    href,
                    x,
                    y,
                    width,
                    height,
                },
                SvgImageData {
                    href: h2,
                    x: x2,
                    y: y2,
                    width: w2,
                    height: hh2,
                },
            ) => href == h2 && fb(*x, *x2) && fb(*y, *y2) && fb(*width, *w2) && fb(*height, *hh2),
            // Different variants are never equal.
1
            _ => false,
        }
16
    }
}
/// Bit-equality for two `SvgPathElement`s (matches the Hash impl's per-coordinate
/// `to_bits`), so NaN path coordinates are self-equal.
const fn svg_path_element_bits_eq(
    a: &crate::svg::SvgPathElement,
    b: &crate::svg::SvgPathElement,
) -> bool {
    use crate::svg::SvgPathElement::{CubicCurve, Line, QuadraticCurve};
    const fn pb(a: azul_css::props::basic::SvgPoint, b: azul_css::props::basic::SvgPoint) -> bool {
        a.x.to_bits() == b.x.to_bits() && a.y.to_bits() == b.y.to_bits()
    }
    match (a, b) {
        (Line(a), Line(b)) => pb(a.start, b.start) && pb(a.end, b.end),
        (QuadraticCurve(a), QuadraticCurve(b)) => {
            pb(a.start, b.start) && pb(a.ctrl, b.ctrl) && pb(a.end, b.end)
        }
        (CubicCurve(a), CubicCurve(b)) => {
            pb(a.start, b.start)
                && pb(a.ctrl_1, b.ctrl_1)
                && pb(a.ctrl_2, b.ctrl_2)
                && pb(a.end, b.end)
        }
        _ => false,
    }
}
impl Eq for SvgNodeData {}
// SvgNodeData contains f32 (svg coords) so Ord can't be derived; this Ord is
// defined *in terms of* the derived field-wise PartialOrd (unwrap_or Equal), so
// the two cannot disagree — the derive_ord_xor_partial_ord concern doesn't apply.
#[allow(clippy::derive_ord_xor_partial_ord)]
impl Ord for SvgNodeData {
1
    fn cmp(&self, other: &Self) -> core::cmp::Ordering {
1
        self.partial_cmp(other)
1
            .unwrap_or(core::cmp::Ordering::Equal)
1
    }
}
impl Hash for SvgNodeData {
    #[allow(clippy::too_many_lines)] // large but cohesive: one arm per variant
6
    fn hash<H: Hasher>(&self, state: &mut H) {
6
        mem::discriminant(self).hash(state);
6
        match self {
            Self::ImageClipMask(m) => m.hash(state),
            Self::Path(mp) => {
                for ring in mp.rings.as_ref() {
                    for item in ring.items.as_ref() {
                        match item {
                            crate::svg::SvgPathElement::Line(l) => {
                                0u8.hash(state);
                                l.start.x.to_bits().hash(state);
                                l.start.y.to_bits().hash(state);
                                l.end.x.to_bits().hash(state);
                                l.end.y.to_bits().hash(state);
                            }
                            crate::svg::SvgPathElement::QuadraticCurve(q) => {
                                1u8.hash(state);
                                q.start.x.to_bits().hash(state);
                                q.start.y.to_bits().hash(state);
                                q.ctrl.x.to_bits().hash(state);
                                q.ctrl.y.to_bits().hash(state);
                                q.end.x.to_bits().hash(state);
                                q.end.y.to_bits().hash(state);
                            }
                            crate::svg::SvgPathElement::CubicCurve(c) => {
                                2u8.hash(state);
                                c.start.x.to_bits().hash(state);
                                c.start.y.to_bits().hash(state);
                                c.ctrl_1.x.to_bits().hash(state);
                                c.ctrl_1.y.to_bits().hash(state);
                                c.ctrl_2.x.to_bits().hash(state);
                                c.ctrl_2.y.to_bits().hash(state);
                                c.end.x.to_bits().hash(state);
                                c.end.y.to_bits().hash(state);
                            }
                        }
                    }
                }
            }
            Self::Circle { cx, cy, r } => {
                cx.to_bits().hash(state);
                cy.to_bits().hash(state);
                r.to_bits().hash(state);
            }
            Self::Rect {
2
                x,
2
                y,
2
                width,
2
                height,
2
                rx,
2
                ry,
2
            } => {
2
                x.to_bits().hash(state);
2
                y.to_bits().hash(state);
2
                width.to_bits().hash(state);
2
                height.to_bits().hash(state);
2
                rx.to_bits().hash(state);
2
                ry.to_bits().hash(state);
2
            }
            Self::Ellipse { cx, cy, rx, ry } => {
                cx.to_bits().hash(state);
                cy.to_bits().hash(state);
                rx.to_bits().hash(state);
                ry.to_bits().hash(state);
            }
            // Line and LinearGradient share a { x1, y1, x2, y2 } shape and hash
            // identically (Eq still distinguishes the variants); fold the duplicate bodies.
            Self::Line { x1, y1, x2, y2 } | Self::LinearGradient { x1, y1, x2, y2 } => {
                x1.to_bits().hash(state);
                y1.to_bits().hash(state);
                x2.to_bits().hash(state);
                y2.to_bits().hash(state);
            }
            Self::PointsList { points, closed } => {
                for p in points {
                    p.x.to_bits().hash(state);
                    p.y.to_bits().hash(state);
                }
                closed.hash(state);
            }
            Self::ViewBox {
                min_x,
                min_y,
                width,
                height,
            } => {
                min_x.to_bits().hash(state);
                min_y.to_bits().hash(state);
                width.to_bits().hash(state);
                height.to_bits().hash(state);
            }
            Self::RadialGradient { cx, cy, r, fx, fy } => {
                cx.to_bits().hash(state);
                cy.to_bits().hash(state);
                r.to_bits().hash(state);
                fx.to_bits().hash(state);
                fy.to_bits().hash(state);
            }
4
            Self::GradientStop { offset } => {
4
                offset.to_bits().hash(state);
4
            }
            Self::Use { href, x, y } => {
                href.hash(state);
                x.to_bits().hash(state);
                y.to_bits().hash(state);
            }
            Self::SvgImageData {
                href,
                x,
                y,
                width,
                height,
            } => {
                href.hash(state);
                x.to_bits().hash(state);
                y.to_bits().hash(state);
                width.to_bits().hash(state);
                height.to_bits().hash(state);
            }
        }
6
    }
}
/// NOTE: NOT EXPOSED IN THE API! Stores extra,
/// not commonly used information for the `NodeData`.
/// This helps keep the primary `NodeData` struct smaller for common cases.
#[repr(C)]
#[derive(Debug, Default, Clone)]
pub struct NodeDataExt {
    /// Strongly-typed HTML attributes (aria-*, href, alt, etc.)
    /// IDs and classes are stored as `AttributeType::Id` and `AttributeType::Class` entries.
    /// Moved from `NodeData` to save 48B for the ~95% of nodes with no attributes.
    pub attributes: AttributeTypeVec,
    /// `VirtualView` callback data, only set when `node_type` == `NodeType::VirtualView`.
    pub virtual_view: Option<VirtualViewNode>,
    /// `data-*` attributes for this node, useful to store UI-related data on the node itself.
    pub dataset: Option<RefAny>,
    /// SVG-specific data or raster clip mask for this DOM node.
    pub svg_data: Option<SvgNodeData>,
    /// Menu bar that should be displayed at the top of this nodes rect.
    pub menu_bar: Option<Box<Menu>>,
    /// Context menu that should be opened when the item is left-clicked.
    pub context_menu: Option<Box<Menu>>,
    /// Stable key for reconciliation. If provided, allows the framework to track
    /// this node across frames even if its position in the array changes.
    /// This is crucial for correct lifecycle events when lists are reordered.
    pub key: Option<u64>,
    /// App-chosen marker string, resolvable to this node's `(DomId, NodeId)`
    /// via `CallbackInfo::get_node_id_by_marker` - the clean way for one
    /// widget's callback to find another widget without knowing its
    /// internals. Unlike an `Id` attribute, a marker is invisible to CSS
    /// matching.
    pub marker: Option<AzString>,
    /// Callback to merge dataset state from a previous frame's node into the current node.
    /// This enables heavy resource preservation (video decoders, GL textures) across frames.
    pub dataset_merge_callback: Option<DatasetMergeCallback>,
    /// Tracks which component rendered this DOM subtree.
    /// Set by the framework during component rendering — the root node(s) of a
    /// component's output DOM get stamped with the component's qualified name.
    /// Enables the debugger to reconstruct the component invocation tree from the
    /// flat rendered DOM, and enables code generation roundtrips.
    pub component_origin: Option<ComponentOrigin>,
    /// COMPONENT-ATTACHED presence-animation functions, resolvable by NAME
    /// from this node's `-azul-animation-in` / `-azul-animation-out` (after
    /// stylesheet `@keyframes` — the web mechanism stays the only default
    /// name source). This replaced the global `AppConfig` registry (USER
    /// ruling 2026-08-17): a sidebar widget ships its fly-out next to its
    /// own DOM, not in app-global state.
    pub animation_callbacks: Vec<crate::resources::AnimationFunction>,
}
// The MARKER is EXCLUDED from equality, ordering and hashing (USER ruling
// 2026-08-29): markers are minted fresh - UUID strings - at every `layout()`
// and exist only to be RESOLVED back to a node, never to describe it. Two
// otherwise identical nodes must compare equal across rebuilds, or every
// marked node would look "changed" to the DOM diff on every frame, defeating
// reconciliation for exactly the widgets the fast path is for.
impl NodeDataExt {
    /// Every field EXCEPT `marker`, as one comparable/hashable tuple - the
    /// single place that decides what "same ext" means.
    #[allow(clippy::type_complexity)]
11552
    const fn cmp_key(
11552
        &self,
11552
    ) -> (
11552
        &AttributeTypeVec,
11552
        &Option<VirtualViewNode>,
11552
        &Option<RefAny>,
11552
        &Option<SvgNodeData>,
11552
        &Option<Box<Menu>>,
11552
        &Option<Box<Menu>>,
11552
        &Option<u64>,
11552
        &Option<DatasetMergeCallback>,
11552
        &Option<ComponentOrigin>,
11552
        &Vec<crate::resources::AnimationFunction>,
11552
    ) {
11552
        (
11552
            &self.attributes,
11552
            &self.virtual_view,
11552
            &self.dataset,
11552
            &self.svg_data,
11552
            &self.menu_bar,
11552
            &self.context_menu,
11552
            &self.key,
11552
            &self.dataset_merge_callback,
11552
            &self.component_origin,
11552
            &self.animation_callbacks,
11552
        )
11552
    }
}
impl NodeDataExt {
    /// `true` when every identity-relevant field (everything [`cmp_key`]
    /// (`Self::cmp_key`) compares, i.e. everything but the marker) is at its
    /// default - such an ext exists only to carry a marker, and
    /// `NodeData::identity_extra` treats it as absent.
11557
    fn is_identity_empty(&self) -> bool {
11557
        self.attributes.as_ref().is_empty()
7
            && self.virtual_view.is_none()
7
            && self.dataset.is_none()
7
            && self.svg_data.is_none()
7
            && self.menu_bar.is_none()
7
            && self.context_menu.is_none()
7
            && self.key.is_none()
5
            && self.dataset_merge_callback.is_none()
5
            && self.component_origin.is_none()
5
            && self.animation_callbacks.is_empty()
11557
    }
}
impl PartialEq for NodeDataExt {
5776
    fn eq(&self, other: &Self) -> bool {
5776
        self.cmp_key() == other.cmp_key()
5776
    }
}
impl Eq for NodeDataExt {}
impl PartialOrd for NodeDataExt {
    fn partial_cmp(&self, other: &Self) -> Option<core::cmp::Ordering> {
        Some(self.cmp(other))
    }
}
impl Ord for NodeDataExt {
    fn cmp(&self, other: &Self) -> core::cmp::Ordering {
        self.cmp_key().cmp(&other.cmp_key())
    }
}
impl Hash for NodeDataExt {
    fn hash<H: Hasher>(&self, state: &mut H) {
        self.cmp_key().hash(state);
    }
}
/// A callback function used to merge the state of an old dataset into a new one.
///
/// This enables components with heavy internal state (video players, WebGL contexts)
/// to preserve their resources across frames, while the DOM tree is recreated.
///
/// The callback receives both the old and new datasets as `RefAny` (cheap shallow clones)
/// and returns the dataset that should be used for the new node.
///
/// # Example
///
/// ```rust,ignore
/// fn merge_video_state(new_data: RefAny, old_data: RefAny) -> RefAny {
///     // Transfer heavy resources from old to new
///     if let (Some(mut new), Some(old)) = (
///         new_data.downcast_mut::<VideoState>(),
///         old_data.downcast_ref::<VideoState>()
///     ) {
///         new.decoder = old.decoder.take();
///         new.gl_texture = old.gl_texture.take();
///     }
///     new_data // Return the merged state
/// }
/// ```
#[derive(Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
#[repr(C)]
pub struct DatasetMergeCallback {
    /// The function pointer that performs the merge.
    /// Signature: `fn(new_data: RefAny, old_data: RefAny) -> RefAny`
    pub cb: DatasetMergeCallbackType,
    /// Optional callable for FFI language bindings (Python, etc.)
    /// When set, the FFI layer can invoke this instead of `cb`.
    pub callable: OptionRefAny,
}
impl fmt::Debug for DatasetMergeCallback {
1
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1
        f.debug_struct("DatasetMergeCallback")
1
            .field("cb", &(self.cb as usize))
1
            .field("callable", &self.callable)
1
            .finish()
1
    }
}
/// Allow creating `DatasetMergeCallback` from a raw function pointer.
/// This enables the `Into<DatasetMergeCallback>` pattern for Python bindings.
impl From<DatasetMergeCallbackType> for DatasetMergeCallback {
6324
    fn from(cb: DatasetMergeCallbackType) -> Self {
6324
        Self {
6324
            cb,
6324
            callable: OptionRefAny::None,
6324
        }
6324
    }
}
impl DatasetMergeCallback {
    /// Build from a raw `DatasetMergeCallbackType` function pointer (callable =
    /// None). The concrete parameter is a coercion site, so callers can pass a
    /// bare `extern "C" fn` item without an `as DatasetMergeCallbackType` cast.
    #[must_use]
4427
    pub fn from_ptr(cb: DatasetMergeCallbackType) -> Self {
4427
        Self::from(cb)
4427
    }
}
impl_option!(
    DatasetMergeCallback,
    OptionDatasetMergeCallback,
    copy = false,
    [Debug, Clone]
);
/// Function pointer type for dataset merge callbacks.
///
/// Arguments:
/// - `new_data`: The new node's dataset (shallow clone, cheap)
/// - `old_data`: The old node's dataset (shallow clone, cheap)
///
/// Returns:
/// - The `RefAny` that should be used as the dataset for the new node
pub type DatasetMergeCallbackType = extern "C" fn(RefAny, RefAny) -> RefAny;
impl Clone for NodeData {
    #[inline]
998912
    fn clone(&self) -> Self {
998912
        Self {
998912
            node_type: self.node_type.to_library_owned_nodetype(),
998912
            style: self.style.clone(),
998912
            callbacks: self.callbacks.clone(),
998912
            flags: self.flags,
998912
            accessibility: self.accessibility.clone(),
998912
            extra: self.extra.clone(),
998912
        }
998912
    }
}
// Clone, PartialEq, Eq, Hash, PartialOrd, Ord
impl_vec!(
    NodeData,
    NodeDataVec,
    NodeDataVecDestructor,
    NodeDataVecDestructorType,
    NodeDataVecSlice,
    OptionNodeData
);
impl_vec_clone!(NodeData, NodeDataVec, NodeDataVecDestructor);
impl_vec_mut!(NodeData, NodeDataVec);
impl_vec_debug!(NodeData, NodeDataVec);
impl_vec_partialord!(NodeData, NodeDataVec);
impl_vec_ord!(NodeData, NodeDataVec);
impl_vec_partialeq!(NodeData, NodeDataVec);
impl_vec_eq!(NodeData, NodeDataVec);
impl_vec_hash!(NodeData, NodeDataVec);
impl NodeDataVec {
    #[inline]
    #[must_use]
47125402
    pub fn as_container(&self) -> NodeDataContainerRef<'_, NodeData> {
47125402
        NodeDataContainerRef {
47125402
            internal: self.as_ref(),
47125402
        }
47125402
    }
    #[inline]
155
    pub fn as_container_mut(&mut self) -> NodeDataContainerRefMut<'_, NodeData> {
155
        NodeDataContainerRefMut {
155
            internal: self.as_mut(),
155
        }
155
    }
}
// SAFETY: All fields in NodeData are either Send (NodeType, NodeFlags,
// CssPropertyWithConditionsVec), Arc-wrapped (RefAny), or plain data (Box<AccessibilityInfo>,
// Box<NodeDataExt>). Function pointers (callbacks) are inherently Send. The RefAny uses atomic
// reference counting.
unsafe impl Send for NodeData {}
/// Determines the behavior of an element in sequential focus navigation
// (e.g., using the Tab key).
#[derive(Debug, Copy, Clone, PartialEq, Eq, Ord, PartialOrd, Hash)]
#[repr(C, u8)]
#[derive(Default)]
pub enum TabIndex {
    /// Automatic tab index, similar to simply setting `focusable = "true"` or `tabindex = 0`
    /// (both have the effect of making the element focusable).
    ///
    /// Sidenote: See <https://www.w3.org/TR/html5/editing.html#sequential-focus-navigation-and-the-tabindex-attribute>
    /// for interesting notes on tabindex and accessibility
    #[default]
    Auto,
    /// Set the tab index in relation to its parent element. I.e. if you have a list of elements,
    /// the focusing order is restricted to the current parent.
    ///
    /// When pressing tab repeatedly, the focusing order will be
    /// determined by `OverrideInParent` elements taking precedence among global order.
    OverrideInParent(u32),
    /// Elements can be focused in callbacks, but are not accessible via
    /// keyboard / tab navigation (-1).
    NoKeyboardFocus,
}
impl_option!(
    TabIndex,
    OptionTabIndex,
    [Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash]
);
impl TabIndex {
    /// Returns the HTML-compatible number of the `tabindex` element.
    // const fn: TryFrom isn't const, and u32 -> isize is lossless on every
    // supported (>= 32-bit) target, so the `as` cast cannot actually wrap here.
    #[allow(clippy::cast_possible_wrap)]
    #[must_use]
6
    pub const fn get_index(&self) -> isize {
        use self::TabIndex::{Auto, NoKeyboardFocus, OverrideInParent};
6
        match self {
2
            Auto => 0,
2
            OverrideInParent(x) => *x as isize,
2
            NoKeyboardFocus => -1,
        }
6
    }
}
/// Packed representation of tab index + contenteditable flag.
///
/// Bit layout (32 bits):
///   [31]     contenteditable flag (1 = true)
///   [30:29]  `tab_index` variant:
///              00 = None (no tab index set)
///              01 = Auto
///              10 = `OverrideInParent` (value in bits [28:0])
///              11 = `NoKeyboardFocus`
///   [28]     `is_anonymous` (1 = anonymous box for table layout)
///   [27:0]   `OverrideInParent` value (max ~268 million)
#[repr(C)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
pub struct NodeFlags {
    pub inner: u32,
}
impl NodeFlags {
    const CONTENTEDITABLE_BIT: u32 = 1 << 31;
    const TAB_INDEX_MASK: u32 = 0b11 << 29;
    const ANONYMOUS_BIT: u32 = 1 << 28;
    const TAB_VALUE_MASK: u32 = (1 << 28) - 1;
    const TAB_NONE: u32 = 0b00 << 29;
    const TAB_AUTO: u32 = 0b01 << 29;
    const TAB_OVERRIDE: u32 = 0b10 << 29;
    const TAB_NO_KEYBOARD: u32 = 0b11 << 29;
    #[must_use]
2895774
    pub const fn new() -> Self {
2895774
        Self { inner: 0 }
2895774
    }
    #[must_use]
147560291
    pub const fn is_contenteditable(&self) -> bool {
147560291
        (self.inner & Self::CONTENTEDITABLE_BIT) != 0
147560291
    }
    #[must_use]
2
    pub const fn set_contenteditable(mut self, v: bool) -> Self {
2
        if v {
1
            self.inner |= Self::CONTENTEDITABLE_BIT;
1
        } else {
1
            self.inner &= !Self::CONTENTEDITABLE_BIT;
1
        }
2
        self
2
    }
13288
    pub const fn set_contenteditable_mut(&mut self, v: bool) {
13288
        if v {
13285
            self.inner |= Self::CONTENTEDITABLE_BIT;
13285
        } else {
3
            self.inner &= !Self::CONTENTEDITABLE_BIT;
3
        }
13288
    }
    #[must_use]
3424119
    pub const fn get_tab_index(&self) -> Option<TabIndex> {
3424119
        match self.inner & Self::TAB_INDEX_MASK {
3424119
            x if x == Self::TAB_NONE => None,
324570
            x if x == Self::TAB_AUTO => Some(TabIndex::Auto),
3912
            x if x == Self::TAB_OVERRIDE => {
2954
                let val = self.inner & Self::TAB_VALUE_MASK;
2954
                Some(TabIndex::OverrideInParent(val))
            }
958
            x if x == Self::TAB_NO_KEYBOARD => Some(TabIndex::NoKeyboardFocus),
            _ => None,
        }
3424119
    }
    /// Returns whether this node is an anonymous box generated for table layout.
    #[must_use]
82979555
    pub const fn is_anonymous(&self) -> bool {
82979555
        (self.inner & Self::ANONYMOUS_BIT) != 0
82979555
    }
15
    pub const fn set_anonymous(&mut self, v: bool) {
15
        if v {
14
            self.inner |= Self::ANONYMOUS_BIT;
14
        } else {
1
            self.inner &= !Self::ANONYMOUS_BIT;
1
        }
15
    }
332184
    pub const fn set_tab_index(&mut self, tab_index: Option<TabIndex>) {
        // Clear tab index bits (bits 29-30) and value bits (bits 0-27)
        // keep contenteditable bit (31) and anonymous bit (28)
332184
        self.inner &= Self::CONTENTEDITABLE_BIT | Self::ANONYMOUS_BIT;
332182
        match tab_index {
2
            None => { /* TAB_NONE = 0, already cleared */ }
331115
            Some(TabIndex::Auto) => {
331115
                self.inner |= Self::TAB_AUTO;
331115
            }
794
            Some(TabIndex::OverrideInParent(val)) => {
794
                self.inner |= Self::TAB_OVERRIDE | (val & Self::TAB_VALUE_MASK);
794
            }
273
            Some(TabIndex::NoKeyboardFocus) => {
273
                self.inner |= Self::TAB_NO_KEYBOARD;
273
            }
        }
332184
    }
}
impl Default for NodeData {
6
    fn default() -> Self {
6
        Self::create_node(NodeType::Div)
6
    }
}
impl fmt::Display for NodeData {
8
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
8
        let html_type = self.node_type.get_path();
8
        let attributes_string = node_data_to_string(self);
8
        match self.node_type.format() {
7
            Some(content) => write!(f, "<{html_type}{attributes_string}>{content}</{html_type}>"),
1
            None => write!(f, "<{html_type}{attributes_string}/>"),
        }
8
    }
}
341
fn node_data_to_string(node_data: &NodeData) -> String {
341
    let mut id_string = String::new();
341
    let ids = node_data
341
        .attributes()
341
        .as_ref()
341
        .iter()
341
        .filter_map(|s| s.as_id())
341
        .collect::<Vec<_>>()
341
        .join(" ");
341
    if !ids.is_empty() {
36
        id_string = format!(" id=\"{ids}\" ");
305
    }
341
    let mut class_string = String::new();
341
    let classes = node_data
341
        .attributes()
341
        .as_ref()
341
        .iter()
341
        .filter_map(|s| s.as_class())
341
        .collect::<Vec<_>>()
341
        .join(" ");
341
    if !classes.is_empty() {
16
        class_string = format!(" class=\"{classes}\" ");
325
    }
341
    let tabindex_string = node_data
341
        .get_tab_index()
341
        .map_or_else(String::new, |tab_index| {
1
            format!(" tabindex=\"{}\" ", tab_index.get_index())
1
        });
341
    format!("{id_string}{class_string}{tabindex_string}")
341
}
impl NodeData {
    /// Creates a new `NodeData` instance from a given `NodeType`.
    #[inline]
    #[must_use]
2895756
    pub const fn create_node(node_type: NodeType) -> Self {
2895756
        Self {
2895756
            node_type,
2895756
            callbacks: CoreCallbackDataVec::from_const_slice(&[]),
2895756
            style: azul_css::css::Css {
2895756
                rules: azul_css::css::CssRuleBlockVec::from_const_slice(&[]),
2895756
                keyframes: azul_css::css::KeyframesVec::from_const_slice(&[]),
2895756
            },
2895756
            flags: NodeFlags::new(),
2895756
            accessibility: None,
2895756
            extra: None,
2895756
        }
2895756
    }
    /// Returns a reference to the node's attributes (from `NodeDataExt`).
    /// Returns an empty slice if no attributes have been set.
    #[inline]
    #[must_use]
11529897
    pub fn attributes(&self) -> &AttributeTypeVec {
        static EMPTY: AttributeTypeVec = AttributeTypeVec::from_const_slice(&[]);
11529897
        self.extra.as_ref().map_or(&EMPTY, |ext| &ext.attributes)
11529897
    }
    /// Returns a mutable reference to the node's attributes,
    /// lazily allocating `NodeDataExt` if needed.
    #[inline]
955628
    pub fn attributes_mut(&mut self) -> &mut AttributeTypeVec {
955628
        &mut self
955628
            .extra
955628
            .get_or_insert_with(|| Box::new(NodeDataExt::default()))
            .attributes
955628
    }
    /// Sets the node's attributes, replacing any existing ones.
    #[inline]
969626
    pub fn set_attributes(&mut self, attrs: AttributeTypeVec) {
969626
        self.extra
969626
            .get_or_insert_with(|| Box::new(NodeDataExt::default()))
969626
            .attributes = attrs;
969626
    }
    /// Shorthand for `NodeData::create_node(NodeType::Body)`.
    #[inline]
    #[must_use]
3084
    pub const fn create_body() -> Self {
3084
        Self::create_node(NodeType::Body)
3084
    }
    /// Shorthand for `NodeData::create_node(NodeType::Div)`.
    #[inline]
    #[must_use]
173369
    pub const fn create_div() -> Self {
173369
        Self::create_node(NodeType::Div)
173369
    }
    /// Shorthand for `NodeData::create_node(NodeType::Br)`.
    #[inline]
    #[must_use]
4
    pub const fn create_br() -> Self {
4
        Self::create_node(NodeType::Br)
4
    }
    /// Creates a raw text node - only valid as the leaf inside a block-level
    /// wrapper (`p`, `div`, `h1`, ...).
    ///
    /// Azul does not auto-wrap text in an anonymous block the way browsers
    /// do: a bare text node has no box, so every box-model property,
    /// callback, `tab_index` and `dataset` on it is inert. Prefer
    /// `create_*_with_text` (`Dom::create_p_with_text`,
    /// `Dom::create_div_with_text`, `Dom::create_span_with_text`, ...)
    /// instead. The engine logs a warning after layout if it finds an
    /// unwrapped text node.
    ///
    /// Shorthand for `NodeData::create_node(NodeType::Text(value.into()))`.
    #[inline]
56993
    pub fn create_text_do_not_use_without_block_level_wrapper<S: Into<AzString>>(value: S) -> Self {
56993
        Self::create_node(NodeType::Text(BoxOrStatic::heap(value.into())))
56993
    }
    /// Shorthand for `NodeData::create_node(NodeType::Image(image_id))`.
    #[inline]
    #[must_use]
16
    pub fn create_image(image: ImageRef) -> Self {
16
        Self::create_node(NodeType::Image(BoxOrStatic::heap(image)))
16
    }
    #[inline]
311
    pub fn create_virtual_view(data: RefAny, callback: impl Into<VirtualViewCallback>) -> Self {
311
        let mut nd = Self::create_node(NodeType::VirtualView);
311
        let ext = nd
311
            .extra
311
            .get_or_insert_with(|| Box::new(NodeDataExt::default()));
311
        ext.virtual_view = Some(VirtualViewNode {
311
            callback: callback.into(),
311
            refany: data,
311
        });
311
        nd
311
    }
    // -- Accessibility-aware NodeData constructors --
    // Each a11y-able element has two constructors: the canonical one takes a
    // `SmallAriaInfo` so the caller must opt in to an accessible name, and the
    // `*_no_a11y` variant is a deliberate escape hatch with a longer name.
358
    fn with_attribute(mut self, attr: AttributeType) -> Self {
358
        let mut v = self.attributes().clone().into_library_owned_vec();
358
        v.push(attr);
358
        self.set_attributes(v.into());
358
        self
358
    }
    /// Creates a button `NodeData` with accessibility information.
    #[inline]
    #[allow(clippy::needless_pass_by_value)] // owned azul C-ABI value taken by value (FFI ownership-transfer convention)
    #[must_use]
3
    pub fn create_button(aria: SmallAriaInfo) -> Self {
3
        let mut nd = Self::create_node(NodeType::Button);
3
        nd.set_accessibility_info(aria.to_full_info());
3
        nd
3
    }
    /// Creates a button `NodeData` without accessibility information.
    #[inline]
    #[must_use]
58
    pub const fn create_button_no_a11y() -> Self {
58
        Self::create_node(NodeType::Button)
58
    }
    /// Creates an anchor `NodeData` with an href and accessibility information.
    #[inline]
    #[allow(clippy::needless_pass_by_value)] // owned azul C-ABI value taken by value (FFI ownership-transfer convention)
    #[must_use]
2
    pub fn create_a(href: AzString, aria: SmallAriaInfo) -> Self {
2
        let mut nd = Self::create_node(NodeType::A).with_attribute(AttributeType::Href(href));
2
        nd.set_accessibility_info(aria.to_full_info());
2
        nd
2
    }
    /// Creates an anchor `NodeData` with an href but no accessibility information.
    #[inline]
    #[must_use]
3
    pub fn create_a_no_a11y(href: AzString) -> Self {
3
        Self::create_node(NodeType::A).with_attribute(AttributeType::Href(href))
3
    }
    /// Creates an input `NodeData` with accessibility information.
    #[inline]
    #[allow(clippy::needless_pass_by_value)] // owned azul C-ABI value taken by value (FFI ownership-transfer convention)
    #[must_use]
2
    pub fn create_input(
2
        input_type: AzString,
2
        name: AzString,
2
        label: AzString,
2
        aria: SmallAriaInfo,
2
    ) -> Self {
2
        let mut nd = Self::create_node(NodeType::Input)
2
            .with_attribute(AttributeType::InputType(input_type))
2
            .with_attribute(AttributeType::Name(name))
2
            .with_attribute(AttributeType::AriaLabel(label));
2
        nd.set_accessibility_info(aria.to_full_info());
2
        nd
2
    }
    /// Creates an input `NodeData` without accessibility information.
    #[inline]
    #[must_use]
2
    pub fn create_input_no_a11y(input_type: AzString, name: AzString, label: AzString) -> Self {
2
        Self::create_node(NodeType::Input)
2
            .with_attribute(AttributeType::InputType(input_type))
2
            .with_attribute(AttributeType::Name(name))
2
            .with_attribute(AttributeType::AriaLabel(label))
2
    }
    /// Creates a textarea `NodeData` with accessibility information.
    #[inline]
    #[allow(clippy::needless_pass_by_value)] // owned azul C-ABI value taken by value (FFI ownership-transfer convention)
    #[must_use]
1
    pub fn create_textarea(name: AzString, label: AzString, aria: SmallAriaInfo) -> Self {
1
        let mut nd = Self::create_node(NodeType::TextArea)
1
            .with_attribute(AttributeType::Name(name))
1
            .with_attribute(AttributeType::AriaLabel(label));
1
        nd.set_accessibility_info(aria.to_full_info());
1
        nd
1
    }
    /// Creates a textarea `NodeData` without accessibility information.
    #[inline]
    #[must_use]
2
    pub fn create_textarea_no_a11y(name: AzString, label: AzString) -> Self {
2
        Self::create_node(NodeType::TextArea)
2
            .with_attribute(AttributeType::Name(name))
2
            .with_attribute(AttributeType::AriaLabel(label))
2
    }
    /// Creates a select `NodeData` with accessibility information.
    #[inline]
    #[allow(clippy::needless_pass_by_value)] // owned azul C-ABI value taken by value (FFI ownership-transfer convention)
    #[must_use]
1
    pub fn create_select(name: AzString, label: AzString, aria: SmallAriaInfo) -> Self {
1
        let mut nd = Self::create_node(NodeType::Select)
1
            .with_attribute(AttributeType::Name(name))
1
            .with_attribute(AttributeType::AriaLabel(label));
1
        nd.set_accessibility_info(aria.to_full_info());
1
        nd
1
    }
    /// Creates a select `NodeData` without accessibility information.
    #[inline]
    #[must_use]
2
    pub fn create_select_no_a11y(name: AzString, label: AzString) -> Self {
2
        Self::create_node(NodeType::Select)
2
            .with_attribute(AttributeType::Name(name))
2
            .with_attribute(AttributeType::AriaLabel(label))
2
    }
    /// Creates a table `NodeData` with accessibility information.
    #[inline]
    #[allow(clippy::needless_pass_by_value)] // owned azul C-ABI value taken by value (FFI ownership-transfer convention)
    #[must_use]
2
    pub fn create_table(aria: SmallAriaInfo) -> Self {
2
        let mut nd = Self::create_node(NodeType::Table);
2
        nd.set_accessibility_info(aria.to_full_info());
2
        nd
2
    }
    /// Creates a table `NodeData` without accessibility information.
    #[inline]
    #[must_use]
2
    pub const fn create_table_no_a11y() -> Self {
2
        Self::create_node(NodeType::Table)
2
    }
    /// Creates a label `NodeData` with an associated control ID and accessibility
    /// information.
    #[inline]
    #[allow(clippy::needless_pass_by_value)] // owned azul C-ABI value taken by value (FFI ownership-transfer convention)
    #[must_use]
1
    pub fn create_label(for_id: AzString, aria: SmallAriaInfo) -> Self {
1
        let mut nd = Self::create_node(NodeType::Label).with_attribute(AttributeType::Custom(
1
            AttributeNameValue {
1
                attr_name: "for".into(),
1
                value: for_id,
1
            },
1
        ));
1
        nd.set_accessibility_info(aria.to_full_info());
1
        nd
1
    }
    /// Creates a label `NodeData` with an associated control ID but no
    /// accessibility information.
    #[inline]
    #[must_use]
2
    pub fn create_label_no_a11y(for_id: AzString) -> Self {
2
        Self::create_node(NodeType::Label).with_attribute(AttributeType::Custom(
2
            AttributeNameValue {
2
                attr_name: "for".into(),
2
                value: for_id,
2
            },
2
        ))
2
    }
    /// Checks whether this node is of the given node type (div, image, text).
    #[inline]
    #[allow(clippy::needless_pass_by_value)] // owned azul C-ABI value taken by value (FFI ownership-transfer convention)
    #[must_use]
29
    pub fn is_node_type(&self, searched_type: NodeType) -> bool {
29
        self.node_type == searched_type
29
    }
    /// Checks whether this node has the searched ID attached.
    #[must_use]
9793
    pub fn has_id(&self, id: &str) -> bool {
9793
        self.attributes()
9793
            .iter()
9801
            .any(|attr| attr.as_id() == Some(id))
9793
    }
    /// Checks whether this node has the searched class attached.
    #[must_use]
404138
    pub fn has_class(&self, class: &str) -> bool {
404138
        self.attributes()
404138
            .iter()
404146
            .any(|attr| attr.as_class() == Some(class))
404138
    }
    #[must_use]
2135048
    pub fn has_context_menu(&self) -> bool {
2135048
        self.extra
2135048
            .as_ref()
2135048
            .is_some_and(|m| m.context_menu.is_some())
2135048
    }
    #[must_use]
92911999
    pub const fn is_text_node(&self) -> bool {
92911999
        matches!(self.node_type, NodeType::Text(_))
92911999
    }
    #[must_use]
651821
    pub const fn is_virtual_view_node(&self) -> bool {
651821
        matches!(self.node_type, NodeType::VirtualView)
651821
    }
    // NOTE: Getters are used here in order to allow changing the memory allocator for the NodeData
    // in the future (which is why the fields are all private).
    #[inline]
    #[must_use]
17958236
    pub const fn get_node_type(&self) -> &NodeType {
17958236
        &self.node_type
17958236
    }
    #[inline]
17
    pub fn get_dataset_mut(&mut self) -> Option<&mut RefAny> {
17
        self.extra.as_mut().and_then(|e| e.dataset.as_mut())
17
    }
    #[inline]
    #[must_use]
1627538
    pub fn get_dataset(&self) -> Option<&RefAny> {
1627538
        self.extra.as_ref().and_then(|e| e.dataset.as_ref())
1627538
    }
    /// Take the dataset out of the node, replacing it with None.
377
    pub fn take_dataset(&mut self) -> Option<RefAny> {
377
        self.extra.as_mut().and_then(|e| e.dataset.take())
377
    }
    /// Returns IDs and classes as a computed `IdOrClassVec`.
    /// Note: this allocates a new vec each time, prefer `has_id()`/`has_class()` for checks.
    #[inline]
    #[must_use]
123304
    pub fn get_ids_and_classes(&self) -> IdOrClassVec {
123304
        let v: Vec<IdOrClass> = self
123304
            .attributes()
123304
            .as_ref()
123304
            .iter()
123308
            .filter_map(|attr| match attr {
101
                AttributeType::Id(s) => Some(IdOrClass::Id(s.clone())),
8584
                AttributeType::Class(s) => Some(IdOrClass::Class(s.clone())),
4
                _ => None,
8689
            })
123304
            .collect();
123304
        v.into()
123304
    }
    #[inline]
    #[must_use]
6904305
    pub const fn get_callbacks(&self) -> &CoreCallbackDataVec {
6904305
        &self.callbacks
6904305
    }
    #[inline]
    #[must_use]
126242
    pub const fn get_style(&self) -> &azul_css::css::Css {
126242
        &self.style
126242
    }
    #[inline]
    #[must_use]
2246015
    pub fn get_svg_data(&self) -> Option<&SvgNodeData> {
2246015
        self.extra.as_ref().and_then(|e| e.svg_data.as_ref())
2246015
    }
    /// Is this node an image whose content is a null/placeholder image?
    ///
    /// Capture widgets (camera, screencapture, microphone level) build their
    /// node with `ImageRef::null_image(...)` and fill it by writeback later, so
    /// "placeholder" means "no frame yet" — see `diff::transfer_states`, which
    /// uses this to keep the previous frame visible across a DOM rebuild
    /// instead of flashing back to the placeholder.
    #[must_use]
499
    pub fn image_is_placeholder(&self) -> bool {
499
        match &self.node_type {
10
            NodeType::Image(img) => img.as_ref().is_null_image(),
489
            _ => false,
        }
499
    }
    /// Clone this node's `ImageRef`, if it is an image node.
    #[must_use]
2
    pub fn get_image_ref_cloned(&self) -> Option<ImageRef> {
2
        match &self.node_type {
2
            NodeType::Image(img) => Some(img.as_ref().clone()),
            _ => None,
        }
2
    }
    /// Replace this node's image. No-op on non-image nodes.
1
    pub fn set_image_ref(&mut self, image: ImageRef) {
1
        if let NodeType::Image(slot) = &mut self.node_type {
1
            *slot = BoxOrStatic::heap(image);
1
        }
1
    }
    /// Legacy accessor for raster clip mask. Returns `Some` only for `SvgNodeData::ImageClipMask`.
    #[inline]
    #[must_use]
4
    pub fn get_image_clip_mask(&self) -> Option<&ImageMask> {
4
        match self.get_svg_data()? {
1
            SvgNodeData::ImageClipMask(m) => Some(m),
1
            _ => None,
        }
4
    }
    #[inline]
    #[must_use]
3423390
    pub const fn get_tab_index(&self) -> Option<TabIndex> {
3423390
        self.flags.get_tab_index()
3423390
    }
    #[inline]
    #[must_use]
690668
    pub fn get_accessibility_info(&self) -> Option<&AccessibilityInfo> {
690668
        self.accessibility.as_deref()
690668
    }
    #[inline]
    #[must_use]
6
    pub fn get_menu_bar(&self) -> Option<&Menu> {
6
        self.extra.as_ref().and_then(|e| e.menu_bar.as_deref())
6
    }
    #[inline]
    #[must_use]
2134990
    pub fn get_context_menu(&self) -> Option<&Menu> {
2134990
        self.extra.as_ref().and_then(|e| e.context_menu.as_deref())
2134990
    }
    /// Returns whether this node is an anonymous box generated for table layout.
    #[inline]
    #[must_use]
82979542
    pub const fn is_anonymous(&self) -> bool {
82979542
        self.flags.is_anonymous()
82979542
    }
    #[inline]
86
    pub fn set_node_type(&mut self, node_type: NodeType) {
86
        self.node_type = node_type;
86
    }
    #[inline]
    /// The node's component-attached animation functions (empty for the
    /// ~100% of nodes that have none — no `extra` allocation is made by
    /// reading).
    #[must_use]
22
    pub fn animation_callbacks(&self) -> &[crate::resources::AnimationFunction] {
22
        self.extra
22
            .as_ref()
22
            .map_or(&[], |e| e.animation_callbacks.as_slice())
22
    }
    /// Attach a presence-animation function under `name`, resolvable from
    /// this node's `-azul-animation-in` / `-azul-animation-out` after
    /// stylesheet `@keyframes`. `callback` is the TYPE-ERASED
    /// `azul_layout::callbacks::ZombieAnimFnType` fn pointer cast to
    /// `usize` (the type-erased `ZombieAnimCallback.cb`).
12
    pub fn add_animation_callback(
12
        &mut self,
12
        name: AzString,
12
        callback: crate::resources::ZombieAnimCallback,
12
        data: RefAny,
12
    ) {
12
        self.extra
12
            .get_or_insert_with(|| Box::new(NodeDataExt::default()))
            .animation_callbacks
12
            .push(crate::resources::AnimationFunction {
12
                name,
12
                callback,
12
                data,
12
            });
12
    }
    /// Stamp an app-chosen marker string on this node — see
    /// [`NodeDataExt::marker`]. `None` clears it.
2246
    pub fn set_marker(&mut self, marker: OptionString) {
2246
        match marker {
            OptionString::None => {
                if let Some(ext) = self.extra.as_mut() {
                    ext.marker = None;
                }
            }
2246
            OptionString::Some(s) => {
2246
                self.extra
2246
                    .get_or_insert_with(|| Box::new(NodeDataExt::default()))
2246
                    .marker = Some(s);
            }
        }
2246
    }
    /// The marker string stamped on this node, if any.
    #[must_use]
695
    pub fn get_marker(&self) -> Option<&AzString> {
695
        self.extra.as_ref().and_then(|ext| ext.marker.as_ref())
695
    }
    /// Builder form of [`Self::set_marker`].
    #[inline]
    #[must_use]
2
    pub fn with_marker(mut self, marker: OptionString) -> Self {
2
        self.set_marker(marker);
2
        self
2
    }
35601
    pub fn set_dataset(&mut self, data: OptionRefAny) {
35601
        match data {
            OptionRefAny::None => {
2
                if let Some(ext) = self.extra.as_mut() {
1
                    ext.dataset = None;
1
                }
            }
35599
            OptionRefAny::Some(r) => {
35599
                self.extra
35599
                    .get_or_insert_with(|| Box::new(NodeDataExt::default()))
35599
                    .dataset = Some(r);
            }
        }
35601
    }
    /// Sets the IDs and classes by converting `IdOrClassVec` entries into
    /// `AttributeType::Id`/`AttributeType::Class` and merging them into `self.attributes`.
    /// Any existing Id/Class attributes are removed first.
    #[inline]
    #[allow(clippy::needless_pass_by_value)] // owned azul C-ABI value taken by value (FFI
                                             // ownership-transfer convention)
932248
    pub fn set_ids_and_classes(&mut self, ids_and_classes: IdOrClassVec) {
        // Remove existing Id/Class from attributes
932248
        let mut v: AttributeTypeVec = Vec::new().into();
932248
        mem::swap(&mut v, self.attributes_mut());
932248
        let mut v = v.into_library_owned_vec();
932249
        v.retain(|a| !matches!(a, AttributeType::Id(_) | AttributeType::Class(_)));
        // Convert and append
990104
        for ioc in ids_and_classes.as_ref() {
990103
            match ioc {
2447
                IdOrClass::Id(s) => v.push(AttributeType::Id(s.clone())),
987656
                IdOrClass::Class(s) => v.push(AttributeType::Class(s.clone())),
            }
        }
932248
        self.set_attributes(v.into());
932248
    }
    #[inline]
1
    pub fn set_callbacks(&mut self, callbacks: CoreCallbackDataVec) {
1
        self.callbacks = callbacks;
1
    }
    /// Legacy: replace this node's inline style with a flat list of property+conditions.
    /// Each entry becomes a single-declaration rule at `rule_priority::INLINE`. Prefer
    /// `set_style` (or `with_style` / `with_css(&str)`) for new code.
    #[inline]
1479
    pub fn set_css_props(&mut self, css_props: CssPropertyWithConditionsVec) {
1479
        self.style = css_props.into();
1479
    }
    /// Upsert one runtime-patched CSS property into this node's inline style.
    ///
    /// Every UNCONDITIONAL inline declaration of the same property type is
    /// removed (a patch replaces the property's resting value), then the new
    /// value is appended as its own unconditional rule at
    /// `rule_priority::INLINE`. Conditional declarations (`:hover` styles,
    /// `@media` rules) are left untouched: a runtime patch changes the
    /// property's base value, not the node's whole style.
    ///
    /// The content chokepoint used to `set_css_props(vec![patch])` here,
    /// which REPLACED the entire inline style — a gallery panel patched to
    /// `display: flex` lost its `position: absolute; top: ...` and flowed
    /// into the row, off-window. Remove-then-append also keeps repeated
    /// toggles from growing the style without bound.
1747
    pub fn upsert_inline_css_property(&mut self, prop: azul_css::props::property::CssProperty) {
        use azul_css::css::{rule_priority, CssDeclaration, CssPath, CssRuleBlock};
1747
        let ty = prop.get_type();
1747
        let mut rules = mem::take(&mut self.style.rules).into_library_owned_vec();
15000
        for rule in &mut rules {
13253
            if !rule.conditions.as_ref().is_empty() {
2937
                continue;
10316
            }
10316
            let mut decls = mem::take(&mut rule.declarations).into_library_owned_vec();
10316
            decls.retain(|d| match d {
10316
                CssDeclaration::Static(p) => p.get_type() != ty,
                CssDeclaration::Dynamic(_) => true,
10316
            });
10316
            rule.declarations = decls.into();
        }
        // Drop rules the retain above emptied out entirely.
13261
        rules.retain(|r| !r.declarations.as_ref().is_empty());
1747
        rules.push(CssRuleBlock {
1747
            path: CssPath {
1747
                selectors: Vec::new().into(),
1747
            },
1747
            declarations: alloc::vec![CssDeclaration::Static(prop)].into(),
1747
            conditions: Vec::new().into(),
1747
            priority: rule_priority::INLINE,
1747
        });
1747
        self.style.rules = rules.into();
1747
    }
    /// Replace this node's inline style with a `Css` value. The Css's rules apply only
    /// to this node (implicit `:scope`).
    #[inline]
1
    pub fn set_style(&mut self, style: azul_css::css::Css) {
1
        self.style = style;
1
    }
    #[inline]
1
    pub fn set_clip_mask(&mut self, clip_mask: ImageMask) {
1
        self.extra
1
            .get_or_insert_with(|| Box::new(NodeDataExt::default()))
1
            .svg_data = Some(SvgNodeData::ImageClipMask(clip_mask));
1
    }
    #[inline]
686
    pub fn set_svg_data(&mut self, data: SvgNodeData) {
686
        self.extra
686
            .get_or_insert_with(|| Box::new(NodeDataExt::default()))
686
            .svg_data = Some(data);
686
    }
    #[inline]
332168
    pub const fn set_tab_index(&mut self, tab_index: TabIndex) {
332168
        self.flags.set_tab_index(Some(tab_index));
332168
    }
    #[inline]
13280
    pub const fn set_contenteditable(&mut self, contenteditable: bool) {
13280
        self.flags.set_contenteditable_mut(contenteditable);
13280
    }
    #[inline]
    #[must_use]
147560278
    pub const fn is_contenteditable(&self) -> bool {
147560278
        self.flags.is_contenteditable()
147560278
    }
    #[inline]
340965
    pub fn set_accessibility_info(&mut self, accessibility_info: AccessibilityInfo) {
340965
        self.accessibility = Some(Box::new(accessibility_info));
340965
    }
    /// Marks this node as an anonymous box (generated for table layout).
    #[inline]
11
    pub const fn set_anonymous(&mut self, is_anonymous: bool) {
11
        self.flags.set_anonymous(is_anonymous);
11
    }
    #[inline]
4
    pub fn set_menu_bar(&mut self, menu_bar: Menu) {
4
        self.extra
4
            .get_or_insert_with(|| Box::new(NodeDataExt::default()))
4
            .menu_bar = Some(Box::new(menu_bar));
4
    }
    #[inline]
233
    pub fn set_context_menu(&mut self, context_menu: Menu) {
233
        self.extra
233
            .get_or_insert_with(|| Box::new(NodeDataExt::default()))
233
            .context_menu = Some(Box::new(context_menu));
233
    }
    /// Sets a stable key for this node used in reconciliation.
    ///
    /// This key is used to track node identity across DOM updates, enabling
    /// the framework to distinguish between "moving" a node and "destroying/creating" one.
    /// This is crucial for correct lifecycle events when lists are reordered.
    ///
    /// # Example
    /// ```rust
    /// # use azul_core::dom::NodeData;
    /// # let mut node_data = NodeData::create_div();
    /// node_data.set_key("user-123");
    /// ```
    #[inline]
49
    pub fn set_key<K: Hash>(&mut self, key: K) {
        use core::hash::Hasher;
49
        let mut hasher = crate::hash::DefaultHasher::new();
49
        key.hash(&mut hasher);
49
        self.extra
49
            .get_or_insert_with(|| Box::new(NodeDataExt::default()))
49
            .key = Some(hasher.finish());
49
    }
    /// Gets the key for this node, if set.
    #[inline]
    #[must_use]
2360573
    pub fn get_key(&self) -> Option<u64> {
2360573
        self.extra.as_ref().and_then(|ext| ext.key)
2360573
    }
    /// Sets a dataset merge callback for this node.
    ///
    /// The merge callback is invoked during reconciliation when a node from the
    /// previous frame is matched with a node in the new frame. It allows heavy
    /// resources (video decoders, GL textures, network connections) to be
    /// transferred from the old node to the new node instead of being destroyed.
    ///
    /// # Type Safety
    ///
    /// The callback stores the `TypeId` of `T`. During execution, both the old
    /// and new datasets must match this type, otherwise the merge is skipped.
    ///
    /// # Example
    /// ```rust,ignore
    /// struct VideoPlayer {
    ///     url: String,
    ///     decoder: Option<DecoderHandle>,
    /// }
    ///
    /// extern "C" fn merge_video(new_data: RefAny, old_data: RefAny) -> RefAny {
    ///     // Transfer the heavy decoder handle from old to new
    ///     if let (Some(mut new), Some(old)) = (
    ///         new_data.downcast_mut::<VideoPlayer>(),
    ///         old_data.downcast_ref::<VideoPlayer>()
    ///     ) {
    ///         new.decoder = old.decoder.take();
    ///     }
    ///     new_data
    /// }
    ///
    /// node_data.set_merge_callback(merge_video);
    /// ```
    #[inline]
1840
    pub fn set_merge_callback<C: Into<DatasetMergeCallback>>(&mut self, callback: C) {
1840
        self.extra
1840
            .get_or_insert_with(|| Box::new(NodeDataExt::default()))
1840
            .dataset_merge_callback = Some(callback.into());
1840
    }
    /// Gets the merge callback for this node, if set.
    #[inline]
    #[must_use]
767
    pub fn get_merge_callback(&self) -> Option<DatasetMergeCallback> {
767
        self.extra
767
            .as_ref()
767
            .and_then(|ext| ext.dataset_merge_callback.clone())
767
    }
    /// Sets the component origin for this node.
    ///
    /// This stamps the node with information about which component rendered it,
    /// enabling the debugger to reconstruct the component invocation tree.
    #[inline]
1
    pub fn set_component_origin(&mut self, origin: ComponentOrigin) {
1
        self.extra
1
            .get_or_insert_with(|| Box::new(NodeDataExt::default()))
1
            .component_origin = Some(origin);
1
    }
    /// Gets the component origin for this node, if set.
    #[inline]
    #[must_use]
3
    pub fn get_component_origin(&self) -> Option<&ComponentOrigin> {
3
        self.extra
3
            .as_ref()
3
            .and_then(|ext| ext.component_origin.as_ref())
3
    }
    #[inline]
    #[must_use]
1
    pub fn with_menu_bar(mut self, menu_bar: Menu) -> Self {
1
        self.set_menu_bar(menu_bar);
1
        self
1
    }
    #[inline]
    #[must_use]
1
    pub fn with_context_menu(mut self, context_menu: Menu) -> Self {
1
        self.set_context_menu(context_menu);
1
        self
1
    }
    #[inline]
3056
    pub fn add_callback<C: Into<CoreCallback>>(
3056
        &mut self,
3056
        event: EventFilter,
3056
        data: RefAny,
3056
        callback: C,
3056
    ) {
3056
        let callback = callback.into();
3056
        let mut v: CoreCallbackDataVec = Vec::new().into();
3056
        mem::swap(&mut v, &mut self.callbacks);
3056
        let mut v = v.into_library_owned_vec();
3056
        v.push(CoreCallbackData {
3056
            event,
3056
            refany: data,
3056
            callback,
3056
        });
3056
        self.callbacks = v.into();
3056
    }
    #[inline]
1083
    pub fn add_id(&mut self, s: AzString) {
1083
        let mut v: AttributeTypeVec = Vec::new().into();
1083
        mem::swap(&mut v, self.attributes_mut());
1083
        let mut v = v.into_library_owned_vec();
1083
        v.push(AttributeType::Id(s));
1083
        self.set_attributes(v.into());
1083
    }
    #[inline]
1130
    pub fn add_class(&mut self, s: AzString) {
1130
        let mut v: AttributeTypeVec = Vec::new().into();
1130
        mem::swap(&mut v, self.attributes_mut());
1130
        let mut v = v.into_library_owned_vec();
1130
        v.push(AttributeType::Class(s));
1130
        self.set_attributes(v.into());
1130
    }
    /// Add a CSS property with optional conditions (hover, focus, active, etc.).
    ///
    /// Wraps the property in a single-declaration rule at `rule_priority::INLINE`
    /// and appends it to this node's inline style.
    #[inline]
3193
    pub fn add_css_property(&mut self, p: CssPropertyWithConditions) {
        use azul_css::css::{rule_priority, CssDeclaration, CssPath, CssRuleBlock};
3193
        let rule = CssRuleBlock {
3193
            path: CssPath {
3193
                selectors: Vec::new().into(),
3193
            },
3193
            declarations: vec![CssDeclaration::Static(p.property)].into(),
3193
            conditions: p.apply_if,
3193
            priority: rule_priority::INLINE,
3193
        };
3193
        let mut v: azul_css::css::CssRuleBlockVec = Vec::new().into();
3193
        mem::swap(&mut v, &mut self.style.rules);
3193
        let mut v = v.into_library_owned_vec();
3193
        v.push(rule);
3193
        self.style.rules = v.into();
3193
    }
    /// Calculates a deterministic node hash for this node.
    #[must_use]
140433
    pub fn calculate_node_data_hash(&self) -> DomNodeHash {
        use core::hash::Hasher;
140433
        let mut hasher = crate::hash::DefaultHasher::new();
140433
        self.hash(&mut hasher);
140433
        let h = hasher.finish();
140433
        DomNodeHash { inner: h }
140433
    }
    /// Calculates a structural hash for DOM reconciliation that ignores text content.
    ///
    /// This hash is used for matching nodes across DOM frames where the text content
    /// may have changed (e.g., contenteditable text being edited). It hashes:
    /// - Node type discriminant (but NOT the text content for Text nodes)
    /// - IDs and classes
    /// - Attributes (but NOT contenteditable state which may change with focus)
    /// - Callback events and types
    ///
    /// This allows a Text("Hello") node to match Text("Hello World") during reconciliation,
    /// preserving cursor position and selection state.
    #[must_use]
35526
    pub fn calculate_structural_hash(&self) -> DomNodeHash {
        use core::hash::{Hasher, Hasher as StdHasher};
35526
        let mut hasher = crate::hash::DefaultHasher::new();
        // Hash node type discriminant only, not content
        // This means Text("A") and Text("B") have the same structural hash
35526
        mem::discriminant(&self.node_type).hash(&mut hasher);
        // For VirtualView nodes, hash the callback to distinguish different virtualized views
35526
        if self.node_type == NodeType::VirtualView {
            if let Some(ext) = self.extra.as_ref() {
                if let Some(vv) = ext.virtual_view.as_ref() {
                    vv.hash(&mut hasher);
                }
            }
35526
        }
        // For Image nodes, hash the image reference to distinguish different images.
        // For callback images, hash the callback function pointer and RefAny type ID
        // instead of the heap pointer, so that the same callback produces the same
        // structural hash across frames (the heap pointer differs each frame because
        // ImageRef::new() does Box::into_raw(Box::new(...))).
35526
        if let NodeType::Image(ref img_ref) = self.node_type {
1
            match img_ref.get_data() {
                crate::resources::DecodedImage::Callback(cb) => {
                    // Hash callback function pointer (stable across frames)
                    cb.callback.cb.hash(&mut hasher);
                    // Hash RefAny type ID (not instance pointer)
                    cb.refany.get_type_id().hash(&mut hasher);
                }
1
                _ => {
1
                    // Raw images / GL textures: hash normally (pointer identity)
1
                    img_ref.hash(&mut hasher);
1
                }
            }
35525
        }
        // Hash IDs and classes - these are structural and shouldn't change
        // (They are now stored as AttributeType::Id / AttributeType::Class in attributes)
35526
        for attr in self.attributes().as_ref() {
22069
            match attr {
19526
                AttributeType::Id(s) => {
19526
                    0u8.hash(&mut hasher);
19526
                    s.as_str().hash(&mut hasher);
19526
                }
2543
                AttributeType::Class(s) => {
2543
                    1u8.hash(&mut hasher);
2543
                    s.as_str().hash(&mut hasher);
2543
                }
                _ => {}
            }
        }
        // Hash other attributes - but skip contenteditable since that might change
        // Also skip Id/Class since they were already hashed above
35526
        for attr in self.attributes().as_ref() {
            if !matches!(
22069
                attr,
                AttributeType::ContentEditable(_) | AttributeType::Id(_) | AttributeType::Class(_)
            ) {
                attr.hash(&mut hasher);
22069
            }
        }
        // Hash callback events (not the actual callback function pointers)
35526
        for callback in self.callbacks.as_ref() {
691
            callback.event.hash(&mut hasher);
691
        }
35526
        let h = hasher.finish();
35526
        DomNodeHash { inner: h }
35526
    }
    #[inline]
    #[must_use]
7
    pub const fn with_tab_index(mut self, tab_index: TabIndex) -> Self {
7
        self.set_tab_index(tab_index);
7
        self
7
    }
    #[inline]
    #[must_use]
8
    pub const fn with_contenteditable(mut self, contenteditable: bool) -> Self {
8
        self.set_contenteditable(contenteditable);
8
        self
8
    }
    #[inline]
    #[must_use]
1
    pub fn with_node_type(mut self, node_type: NodeType) -> Self {
1
        self.set_node_type(node_type);
1
        self
1
    }
    #[inline]
    #[must_use]
6
    pub fn with_callback<C: Into<CoreCallback>>(
6
        mut self,
6
        event: EventFilter,
6
        data: RefAny,
6
        callback: C,
6
    ) -> Self {
6
        self.add_callback(event, data, callback);
6
        self
6
    }
    #[inline]
    #[must_use]
3
    pub fn with_dataset(mut self, data: OptionRefAny) -> Self {
3
        self.set_dataset(data);
3
        self
3
    }
    #[inline]
    #[must_use]
24
    pub fn with_ids_and_classes(mut self, ids_and_classes: IdOrClassVec) -> Self {
24
        self.set_ids_and_classes(ids_and_classes);
24
        self
24
    }
    #[inline]
    #[must_use]
    pub fn with_callbacks(mut self, callbacks: CoreCallbackDataVec) -> Self {
        self.callbacks = callbacks;
        self
    }
    /// Legacy: builder-form of `set_css_props`. Each `CssPropertyWithConditions`
    /// becomes a single-declaration rule at `rule_priority::INLINE`.
    /// Prefer `with_style(Css)` for new code.
    #[inline]
    #[must_use]
    pub fn with_css_props(mut self, css_props: CssPropertyWithConditionsVec) -> Self {
        self.style = css_props.into();
        self
    }
    /// Builder-form of `set_style`.
    #[inline]
    #[must_use]
    pub fn with_style(mut self, style: azul_css::css::Css) -> Self {
        self.style = style;
        self
    }
    /// Assigns a stable key to this node for reconciliation.
    ///
    /// This is crucial for performance and correct state preservation when
    /// lists of items change order or items are inserted/removed. Without keys,
    /// the reconciliation algorithm falls back to hash-based matching.
    ///
    /// # Example
    /// ```rust
    /// # use azul_core::dom::NodeData;
    /// NodeData::create_div().with_key("user-avatar-123");
    /// ```
    #[inline]
    #[must_use]
26
    pub fn with_key<K: Hash>(mut self, key: K) -> Self {
26
        self.set_key(key);
26
        self
26
    }
    /// Registers a callback to merge dataset state from the previous frame.
    ///
    /// This is used for components that maintain heavy internal state (video players,
    /// WebGL contexts, network connections) that should not be destroyed and recreated
    /// on every render frame.
    ///
    /// The callback receives both datasets as `RefAny` (cheap shallow clones) and
    /// returns the `RefAny` that should be used for the new node.
    ///
    /// # Example
    /// ```rust,ignore
    /// struct VideoPlayer {
    ///     url: String,
    ///     decoder_handle: Option<DecoderHandle>,
    /// }
    ///
    /// extern "C" fn merge_video(new_data: RefAny, old_data: RefAny) -> RefAny {
    ///     if let (Some(mut new), Some(old)) = (
    ///         new_data.downcast_mut::<VideoPlayer>(),
    ///         old_data.downcast_ref::<VideoPlayer>()
    ///     ) {
    ///         new.decoder_handle = old.decoder_handle.take();
    ///     }
    ///     new_data
    /// }
    ///
    /// NodeData::create_div()
    ///     .with_dataset(RefAny::new(VideoPlayer::new("movie.mp4")).into())
    ///     .with_merge_callback(merge_video)
    /// ```
    #[inline]
    #[must_use]
    pub fn with_merge_callback<C: Into<DatasetMergeCallback>>(mut self, callback: C) -> Self {
        self.set_merge_callback(callback);
        self
    }
    /// Parse and set CSS styles with full selector support.
    ///
    /// This is the unified API for setting inline CSS on a node. It supports:
    /// - Simple properties: `color: red; font-size: 14px;`
    /// - Pseudo-selectors: `:hover { background: blue; }`
    /// - @-rules: `@os linux { font-size: 14px; }`
    /// - Nesting: `@os linux { font-size: 14px; :hover { color: red; }}`
    ///
    /// # Examples
    /// ```rust
    /// # use azul_core::dom::NodeData;
    /// NodeData::create_div().with_css(
    ///     "
    ///     color: blue;
    ///     :hover { color: red; }
    ///     @os linux { font-size: 14px; }
    /// ",
    /// );
    /// ```
291
    pub fn set_css(&mut self, style: &str) {
        // Parse via Css::parse_inline so the inline path goes through the same
        // selector + nesting machinery as author CSS. Rules are tagged
        // `rule_priority::INLINE` and appended to whatever this node already has.
291
        let parsed = azul_css::css::Css::parse_inline(style);
291
        let mut current: azul_css::css::CssRuleBlockVec = Vec::new().into();
291
        mem::swap(&mut current, &mut self.style.rules);
291
        let mut v = current.into_library_owned_vec();
291
        v.extend(parsed.rules.into_library_owned_vec());
291
        self.style.rules = v.into();
291
    }
    /// Builder method for `set_css`
    #[must_use]
275
    pub fn with_css(mut self, style: &str) -> Self {
275
        self.set_css(style);
275
        self
275
    }
    #[inline]
    #[must_use]
1
    pub const fn swap_with_default(&mut self) -> Self {
1
        let mut s = Self::create_div();
1
        mem::swap(&mut s, self);
1
        s
1
    }
    #[inline]
    #[must_use]
757686
    pub fn copy_special(&self) -> Self {
757686
        Self {
757686
            node_type: self.node_type.to_library_owned_nodetype(),
757686
            style: self.style.clone(),
757686
            callbacks: self.callbacks.clone(),
757686
            flags: self.flags,
757686
            accessibility: self.accessibility.clone(),
757686
            extra: self.extra.clone(),
757686
        }
757686
    }
    /// Like [`copy_special`], but MOVES the inline `style` and the `extra` (`NodeDataExt`)
    /// box out of `self` into the returned copy instead of cloning them.
    ///
    /// Both the derived `Clone` for the `CssProperty` values inside `style` AND the derived
    /// `Clone` for `Box<NodeDataExt>` (which transitively clones an `AttributeTypeVec` of
    /// `AzString`s, menus, etc.) lower to indirect-jump jump tables that remill mis-lifts on
    /// the web backend: the mis-lifted clone reads/writes wrong-sized data, which on the
    /// stack clobbers the adjacent `style` temporary inside `copy_special` and produces a
    /// "memory access out of bounds" later in the cascade (`StyledDom::create` → `restyle`'s
    /// inheritance loop reads the corrupted `style`). Native builds are unaffected.
    ///
    /// `convert_dom_into_compact_dom` consumes the `Dom`, so moving these fields out is sound:
    /// `copy_special` then clones an EMPTY style + `None` extra (no broken clone runs), and we
    /// restore the moved-out values afterward. Mirrors the pre-existing `style`-only fix.
757685
    pub(crate) fn copy_special_moving_complex(&mut self) -> Self {
        // WEB-LIFT (2026-06-03): `copy_special`'s `to_library_owned_nodetype()` RECONSTRUCTS the
        // node_type (Text/Image arms clone the boxed AzString + rebuild the variant); the lifted
        // sret store of that data-bearing variant DROPS the whole thing (disc 177->0 AND the box
        // ptr -> styled_dom text node_type = all-zero, box LOST). Earlier attempts to fix this
        // "trapped" — but that was the missing `-C target-feature=-lse` build flag (LSE atomics
        // remill can't lift), NOT this code. With -lse + the fork remill, MOVE the node_type out
        // bitwise instead of reconstructing it: transfers the ORIGINAL box (preserving disc + the
        // AzString) with no clone. The Dom is consumed by convert_dom_into_compact_dom so moving is
        // sound; self.node_type becomes Div (no heap) -> dropped trivially. ptr::write avoids
        // dropping copy's placeholder Div (whose auto-Drop disc-match could mis-lift).
757685
        let taken_style = mem::take(&mut self.style);
757685
        let taken_extra = self.extra.take();
757685
        let taken_node_type = mem::replace(&mut self.node_type, NodeType::Div);
757685
        let mut copy = self.copy_special();
        // SAFETY: `&raw mut copy.node_type` is aligned and points at an initialized
        // `NodeType` (the placeholder `Div` that `copy_special` reconstructed from
        // `self.node_type`, which we replaced with `NodeType::Div` above). `ptr::write`
        // overwrites it WITHOUT running its `Drop` — this is deliberate (the Drop
        // mis-lifts on the web backend) and leaks nothing, because the overwritten
        // value is a heap-free `Div`. Kept unsafe (not a plain `=` assignment)
        // specifically to skip that Drop.
757685
        unsafe {
757685
            core::ptr::write(&raw mut copy.node_type, taken_node_type);
757685
        }
757685
        copy.style = taken_style;
757685
        copy.extra = taken_extra;
757685
        copy
757685
    }
    #[must_use]
716154
    pub fn is_focusable(&self) -> bool {
        // Inherently focusable elements per HTML spec
672708
        if matches!(
716154
            self.node_type,
            NodeType::A
                | NodeType::Button
                | NodeType::Input
                | NodeType::Select
                | NodeType::TextArea
        ) {
43446
            return true;
672708
        }
        // Contenteditable elements are implicitly focusable (W3C spec)
672708
        if self.is_contenteditable() {
6664
            return true;
666044
        }
        // Element is focusable if it has a tab index or any focus-related callback
666044
        self.get_tab_index().is_some()
663671
            || self
663671
                .get_callbacks()
663671
                .iter()
663671
                .any(|cb| cb.event.is_focus_callback())
716154
    }
    /// Returns true if this element has "activation behavior" per HTML5 spec.
    ///
    /// Elements with activation behavior can be activated via Enter or Space key
    /// when focused, which generates a synthetic click event.
    ///
    /// Per HTML5 spec, elements with activation behavior include:
    /// - Button elements
    /// - Input elements (submit, button, reset, checkbox, radio)
    /// - Anchor elements with href
    /// - Any element with a click callback (implicit activation)
    ///
    /// See: <https://html.spec.whatwg.org/multipage/interaction.html#activation-behavior>
    #[must_use]
333740
    pub fn has_activation_behavior(&self) -> bool {
        use crate::events::{EventFilter, HoverEventFilter};
        // Inherently activatable elements per HTML spec
333740
        if matches!(self.node_type, NodeType::A | NodeType::Button) {
22327
            return true;
311413
        }
        // Check for click callback (most common case for Azul)
        // In Azul, "click" is typically LeftMouseUp
        // `Click` is the activation filter; MouseUp / LeftMouseUp stay
        // recognised so a widget that still listens for a raw release (a
        // drag-release, or code predating `On::Click`) is still activatable
        // from the keyboard and from assistive technology.
311413
        let has_click_callback = self.get_callbacks().iter().any(|cb| {
41797
            matches!(
43227
                cb.event,
                EventFilter::Hover(
                    HoverEventFilter::Click
                        | HoverEventFilter::MouseUp
                        | HoverEventFilter::LeftMouseUp
                )
            )
49899
        });
311413
        if has_click_callback {
8102
            return true;
303311
        }
        // Check accessibility role for button-like elements
303311
        if let Some(ref accessibility) = self.accessibility {
            use crate::a11y::AccessibilityRole;
2365
            match accessibility.role {
                AccessibilityRole::PushButton  // Button
                | AccessibilityRole::Link
                | AccessibilityRole::CheckButton  // Checkbox
                | AccessibilityRole::RadioButton  // Radio
                | AccessibilityRole::MenuItem
                | AccessibilityRole::PageTab  // Tab
865
                => return true,
1500
                _ => {}
            }
300946
        }
302446
        false
333740
    }
    /// Returns true if this element is currently activatable.
    ///
    /// An element is activatable if it has activation behavior AND is not disabled.
    /// This checks for common disability patterns (aria-disabled, disabled attribute).
    #[must_use]
5092
    pub fn is_activatable(&self) -> bool {
5092
        if !self.has_activation_behavior() {
2341
            return false;
2751
        }
        // Check for disabled state in accessibility info
2751
        if let Some(ref accessibility) = self.accessibility {
            // Check if explicitly marked as unavailable
805
            if accessibility
805
                .states
805
                .as_ref()
805
                .iter()
805
                .any(|s| matches!(s, AccessibilityState::Unavailable))
            {
769
                return false;
36
            }
1946
        }
        // Not disabled, so activatable
1982
        true
5092
    }
    /// Returns the tab index for this element.
    ///
    /// Tab index determines keyboard navigation order:
    /// - `None`: Not in tab order (unless naturally focusable)
    /// - `Some(-1)`: Focusable programmatically but not via Tab
    /// - `Some(0)`: In natural tab order
    /// - `Some(n > 0)`: In tab order with priority n (higher = later)
    #[must_use]
5
    pub fn get_effective_tabindex(&self) -> Option<i32> {
5
        self.flags.get_tab_index().map_or_else(
2
            || {
2
                if self
2
                    .get_callbacks()
2
                    .iter()
2
                    .any(|cb| cb.event.is_focus_callback())
                {
1
                    Some(0)
                } else {
1
                    None
                }
2
            },
3
            |tab_idx| match tab_idx {
1
                TabIndex::Auto => Some(0),
1
                TabIndex::OverrideInParent(n) => Some(i32::try_from(n).unwrap_or(i32::MAX)),
1
                TabIndex::NoKeyboardFocus => Some(-1),
3
            },
        )
5
    }
    /// Returns the accessible label for this node.
    ///
    /// Priority: `aria-label` attribute > `alt` attribute > `title` attribute > None.
    /// Does NOT include child text — the caller should collect that separately
    /// using the DOM hierarchy.
    #[must_use]
328643
    pub fn get_accessible_label(&self) -> Option<&str> {
328646
        for attr in self.attributes().as_ref() {
148365
            if let AttributeType::AriaLabel(s) = attr {
26
                return Some(s.as_str());
148339
            }
        }
328617
        for attr in self.attributes().as_ref() {
148335
            match attr {
2
                AttributeType::Alt(s) | AttributeType::Title(s) => return Some(s.as_str()),
148333
                _ => {}
            }
        }
328615
        None
328643
    }
    /// Returns the accessible value for this node.
    ///
    /// Priority: `value` attribute > None.
    /// For text inputs, this is the input's current value.
    #[must_use]
328640
    pub fn get_accessible_value(&self) -> Option<&str> {
328640
        for attr in self.attributes().as_ref() {
148406
            if let AttributeType::Value(s) = attr {
25
                return Some(s.as_str());
148381
            }
        }
328615
        None
328640
    }
    /// Whether this node asked to take focus when its window first appears
    /// (the `autofocus` attribute).
    #[must_use]
2
    pub fn has_autofocus(&self) -> bool {
2
        self.attributes()
2
            .as_ref()
2
            .iter()
2
            .any(|a| matches!(a, AttributeType::Autofocus))
2
    }
    /// Returns the placeholder text for this node.
    #[must_use]
1461635
    pub fn get_placeholder(&self) -> Option<&str> {
1461636
        for attr in self.attributes().as_ref() {
451432
            if let AttributeType::Placeholder(s) = attr {
2305
                return Some(s.as_str());
449127
            }
        }
1459330
        None
1461635
    }
24
    pub fn get_virtual_view_node(&mut self) -> Option<&mut VirtualViewNode> {
24
        self.extra.as_mut()?.virtual_view.as_mut()
24
    }
    #[must_use]
1212
    pub fn get_virtual_view_node_ref(&self) -> Option<&VirtualViewNode> {
1212
        self.extra.as_ref()?.virtual_view.as_ref()
1212
    }
    pub fn get_render_image_callback_node(
        &mut self,
    ) -> Option<(&mut CoreImageCallback, ImageRefHash)> {
        match &mut self.node_type {
            NodeType::Image(ref mut img) => {
                let hash = image_ref_get_hash(img.as_ref());
                img.as_mut().get_image_callback_mut().map(|r| (r, hash))
            }
            _ => None,
        }
    }
331
    pub fn debug_print_start(
331
        &self,
331
        css_cache: &CssPropertyCache,
331
        node_id: &NodeId,
331
        node_state: &StyledNodeState,
331
    ) -> String {
331
        let html_type = self.node_type.get_path();
331
        let attributes_string = node_data_to_string(self);
331
        let style = css_cache.get_computed_css_style_string(self, node_id, node_state);
331
        format!(
331
            "<{} data-az-node-id=\"{}\" {} {style}>",
            html_type,
331
            node_id.index(),
            attributes_string,
331
            style = if style.trim().is_empty() {
                String::new()
            } else {
331
                format!("style=\"{style}\"")
            }
        )
331
    }
    #[must_use]
332
    pub fn debug_print_end(&self) -> String {
332
        let html_type = self.node_type.get_path();
332
        format!("</{html_type}>")
332
    }
}
impl crate::events::ActivationBehavior for NodeData {
2
    fn has_activation_behavior(&self) -> bool {
2
        Self::has_activation_behavior(self)
2
    }
1
    fn is_activatable(&self) -> bool {
1
        Self::is_activatable(self)
1
    }
}
impl crate::events::Focusable for NodeData {
    fn get_tabindex(&self) -> Option<i32> {
        self.get_effective_tabindex()
    }
1
    fn is_focusable(&self) -> bool {
1
        Self::is_focusable(self)
1
    }
3
    fn is_naturally_focusable(&self) -> bool {
1
        matches!(
3
            self.node_type,
            NodeType::A
                | NodeType::Button
                | NodeType::Input
                | NodeType::Select
                | NodeType::TextArea
        )
3
    }
}
/// A unique, runtime-generated identifier for a single `Dom` instance.
#[derive(Debug, Copy, Clone, PartialEq, Eq, Ord, PartialOrd, Hash)]
#[repr(C)]
pub struct DomId {
    pub inner: usize,
}
impl fmt::Display for DomId {
2
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2
        write!(f, "{}", self.inner)
2
    }
}
impl DomId {
    pub const ROOT_ID: Self = Self { inner: 0 };
}
impl Default for DomId {
1
    fn default() -> Self {
1
        Self::ROOT_ID
1
    }
}
impl_option!(
    DomId,
    OptionDomId,
    [Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash]
);
impl_vec!(
    DomId,
    DomIdVec,
    DomIdVecDestructor,
    DomIdVecDestructorType,
    DomIdVecSlice,
    OptionDomId
);
impl_vec_debug!(DomId, DomIdVec);
impl_vec_clone!(DomId, DomIdVec, DomIdVecDestructor);
impl_vec_partialeq!(DomId, DomIdVec);
impl_vec_partialord!(DomId, DomIdVec);
/// A UUID for a DOM node within a `LayoutWindow`.
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[repr(C)]
pub struct DomNodeId {
    /// The ID of the `Dom` this node belongs to.
    pub dom: DomId,
    /// The hierarchical ID of the node within its `Dom`.
    pub node: NodeHierarchyItemId,
}
impl_option!(
    DomNodeId,
    OptionDomNodeId,
    [Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash]
);
impl_vec!(
    DomNodeId,
    DomNodeIdVec,
    DomNodeIdVecDestructor,
    DomNodeIdVecDestructorType,
    DomNodeIdVecSlice,
    OptionDomNodeId
);
impl_vec_debug!(DomNodeId, DomNodeIdVec);
impl_vec_clone!(DomNodeId, DomNodeIdVec, DomNodeIdVecDestructor);
impl_vec_partialeq!(DomNodeId, DomNodeIdVec);
impl_vec_partialord!(DomNodeId, DomNodeIdVec);
impl DomNodeId {
    pub const ROOT: Self = Self {
        dom: DomId::ROOT_ID,
        node: NodeHierarchyItemId::NONE,
    };
}
/// The document model, similar to HTML. This is a create-only structure, you don't actually read
/// anything back from it. It's designed for ease of construction.
///
/// This is the "slow" tree-based DOM. For bulk construction (XML parsing),
/// use `FastDom` which builds flat arenas directly and skips the tree→arena conversion.
#[repr(C)]
#[derive(PartialEq, Clone)]
pub struct Dom {
    /// The data for the root node of this DOM (or sub-DOM).
    pub root: NodeData,
    /// The children of this DOM node.
    pub children: DomVec,
    /// Ordered list of CSS stylesheets to apply to this DOM subtree.
    /// Stylesheets are applied in push order during the single deferred cascade pass.
    /// Later entries override earlier ones (higher cascade priority).
    pub css: azul_css::css::CssVec,
    // Tracks the number of sub-children of the current children, so that
    // the `Dom` can be converted into a `CompactDom`.
    //
    // AUDIT: this is a cached count that MUST equal the recursive
    // `1-per-descendant` total of `children`. The builder methods
    // (`add_child` / `set_children` / `with_child*` / `FromIterator`) keep it in
    // sync, but `children` is a public field — mutating it directly desyncs this
    // counter. A too-small value makes `convert_dom_into_compact_dom` under-allocate
    // its arenas and panic on out-of-bounds writes. Call
    // `fixup_children_estimated()` after any direct `children` mutation;
    // `StyledDom::new` already does so as a safety net. Debug builds assert
    // consistency in the builder methods (see `recompute_estimated_total_children`).
    pub estimated_total_children: usize,
}
/// CSS stylesheet associated with a specific node ID in the flat arena.
///
/// In the tree DOM, each node carries its own `css` field. In the flat arena,
/// we record which node a stylesheet scopes to (e.g. for `<style>` tags
/// in different parts of the document).
#[repr(C)]
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd)]
pub struct CssWithNodeId {
    /// 1-based encoded `NodeId` (0 = root / global scope).
    pub node_id: usize,
    /// The CSS stylesheet.
    pub css: azul_css::css::Css,
}
impl_vec!(
    CssWithNodeId,
    CssWithNodeIdVec,
    CssWithNodeIdVecDestructor,
    CssWithNodeIdVecDestructorType,
    CssWithNodeIdVecSlice,
    OptionCssWithNodeId
);
impl_option!(
    CssWithNodeId,
    OptionCssWithNodeId,
    copy = false,
    [Debug, Clone, PartialEq, Eq, PartialOrd]
);
impl_vec_clone!(CssWithNodeId, CssWithNodeIdVec, CssWithNodeIdVecDestructor);
impl_vec_mut!(CssWithNodeId, CssWithNodeIdVec);
impl_vec_debug!(CssWithNodeId, CssWithNodeIdVec);
impl_vec_partialord!(CssWithNodeId, CssWithNodeIdVec);
impl_vec_partialeq!(CssWithNodeId, CssWithNodeIdVec);
/// Arena-based DOM for bulk construction (e.g. XML/XHTML parsing).
/// The hierarchy and node data are stored in two parallel flat vectors,
/// skipping the tree→arena conversion step entirely.
///
/// Use `FastDom::into_dom()` to convert to a tree-based `Dom` if needed.
/// `StyledDom::create_from_fast_dom()` consumes this directly without conversion.
#[repr(C)]
#[derive(Debug, Clone, PartialEq, PartialOrd)]
pub struct FastDom {
    /// Flat arena of parent/child/sibling relationships.
    pub node_hierarchy: crate::styled_dom::NodeHierarchyItemVec,
    /// Flat arena of node data, parallel to `node_hierarchy`.
    pub node_data: NodeDataVec,
    /// CSS stylesheets with the node ID they scope to.
    pub css: CssWithNodeIdVec,
}
// Manual Eq/Hash/Ord impls that skip the transient `css` field,
// since CssVec does not implement Eq/Hash/Ord.
impl Eq for Dom {}
impl Hash for Dom {
8
    fn hash<H: Hasher>(&self, state: &mut H) {
8
        self.root.hash(state);
8
        self.children.hash(state);
8
        self.estimated_total_children.hash(state);
8
    }
}
// PartialOrd delegates to the field-wise Ord so the two never diverge.
impl PartialOrd for Dom {
    fn partial_cmp(&self, other: &Self) -> Option<core::cmp::Ordering> {
        Some(self.cmp(other))
    }
}
impl Ord for Dom {
    fn cmp(&self, other: &Self) -> core::cmp::Ordering {
        self.root
            .cmp(&other.root)
            .then_with(|| self.children.cmp(&other.children))
            .then_with(|| {
                self.estimated_total_children
                    .cmp(&other.estimated_total_children)
            })
    }
}
impl_option!(
    Dom,
    OptionDom,
    copy = false,
    [Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash]
);
impl_vec!(
    Dom,
    DomVec,
    DomVecDestructor,
    DomVecDestructorType,
    DomVecSlice,
    OptionDom
);
impl_vec_clone!(Dom, DomVec, DomVecDestructor);
impl_vec_mut!(Dom, DomVec);
impl_vec_debug!(Dom, DomVec);
impl_vec_partialord!(Dom, DomVec);
impl_vec_ord!(Dom, DomVec);
impl_vec_partialeq!(Dom, DomVec);
impl_vec_eq!(Dom, DomVec);
impl_vec_hash!(Dom, DomVec);
/// An empty `<body>` DOM. Used as the safe fallback return value when a layout
/// callback cannot produce a DOM (e.g. a foreign-language binding's trampoline
/// raised, or an app-data downcast failed). `StyledDom` is the post-cascade
/// CSSOM; layout callbacks return an un-cascaded `Dom`, so an empty body is the
/// natural "nothing to show" default.
impl Default for Dom {
98
    fn default() -> Self {
98
        Self::create_body()
98
    }
}
impl Dom {
    // ----- DOM CONSTRUCTORS
    /// Creates an empty DOM with a given `NodeType`. Doesn't allocate until
    /// you add at least one child node.
    #[inline]
    #[must_use]
755901
    pub fn create_node(node_type: NodeType) -> Self {
755901
        Self {
755901
            root: NodeData::create_node(node_type),
755901
            children: Vec::new().into(),
755901
            css: Vec::new().into(),
755901
            estimated_total_children: 0,
755901
        }
755901
    }
    #[inline]
    #[must_use]
10127
    pub fn create_from_data(node_data: NodeData) -> Self {
10127
        Self {
10127
            root: node_data,
10127
            children: Vec::new().into(),
10127
            css: Vec::new().into(),
10127
            estimated_total_children: 0,
10127
        }
10127
    }
    // Document Structure Elements
    /// Creates the root HTML element.
    ///
    /// **Accessibility**: The `<html>` element is the root of an HTML document and should have a
    /// `lang` attribute.
    #[inline]
    #[must_use]
1035
    pub const fn create_html() -> Self {
1035
        Self {
1035
            root: NodeData::create_node(NodeType::Html),
1035
            children: DomVec::from_const_slice(&[]),
1035
            css: azul_css::css::CssVec::from_const_slice(&[]),
1035
            estimated_total_children: 0,
1035
        }
1035
    }
    /// Creates the document head element.
    ///
    /// **Accessibility**: The `<head>` contains metadata. Use `<title>` for page titles.
    #[inline]
    #[must_use]
1
    pub const fn create_head() -> Self {
1
        Self {
1
            root: NodeData::create_node(NodeType::Head),
1
            children: DomVec::from_const_slice(&[]),
1
            css: azul_css::css::CssVec::from_const_slice(&[]),
1
            estimated_total_children: 0,
1
        }
1
    }
    #[inline]
    #[must_use]
57843
    pub const fn create_body() -> Self {
57843
        Self {
57843
            root: NodeData::create_node(NodeType::Body),
57843
            children: DomVec::from_const_slice(&[]),
57843
            css: azul_css::css::CssVec::from_const_slice(&[]),
57843
            estimated_total_children: 0,
57843
        }
57843
    }
    /// Creates a generic block-level container.
    ///
    /// **Accessibility**: Prefer semantic elements like `<article>`, `<section>`, `<nav>` when
    /// applicable.
    #[inline]
    #[must_use]
1175850
    pub const fn create_div() -> Self {
1175850
        Self {
1175850
            root: NodeData::create_node(NodeType::Div),
1175850
            children: DomVec::from_const_slice(&[]),
1175850
            css: azul_css::css::CssVec::from_const_slice(&[]),
1175850
            estimated_total_children: 0,
1175850
        }
1175850
    }
    // Semantic Structure Elements
    /// Creates an article element.
    ///
    /// **Accessibility**: Represents self-contained content that could be distributed
    /// independently. Screen readers can navigate by articles. Consider adding aria-label for
    /// multiple articles.
    #[inline]
    #[must_use]
    pub const fn create_article() -> Self {
        Self {
            root: NodeData::create_node(NodeType::Article),
            children: DomVec::from_const_slice(&[]),
            css: azul_css::css::CssVec::from_const_slice(&[]),
            estimated_total_children: 0,
        }
    }
    /// Creates a section element.
    ///
    /// **Accessibility**: Represents a thematic grouping of content with a heading.
    /// Should typically have a heading (h1-h6) as a child. Consider aria-labelledby.
    #[inline]
    #[must_use]
    pub const fn create_section() -> Self {
        Self {
            root: NodeData::create_node(NodeType::Section),
            children: DomVec::from_const_slice(&[]),
            css: azul_css::css::CssVec::from_const_slice(&[]),
            estimated_total_children: 0,
        }
    }
    /// Creates a navigation element.
    ///
    /// **Accessibility**: Represents navigation links. Screen readers can jump to navigation.
    /// Use aria-label to distinguish multiple nav elements (e.g., "Main navigation", "Footer
    /// links").
    #[inline]
    #[must_use]
    pub const fn create_nav() -> Self {
        Self {
            root: NodeData::create_node(NodeType::Nav),
            children: DomVec::from_const_slice(&[]),
            css: azul_css::css::CssVec::from_const_slice(&[]),
            estimated_total_children: 0,
        }
    }
    /// Creates an aside element.
    ///
    /// **Accessibility**: Represents content tangentially related to main content (sidebars,
    /// callouts). Screen readers announce this as complementary content.
    #[inline]
    #[must_use]
    pub const fn create_aside() -> Self {
        Self {
            root: NodeData::create_node(NodeType::Aside),
            children: DomVec::from_const_slice(&[]),
            css: azul_css::css::CssVec::from_const_slice(&[]),
            estimated_total_children: 0,
        }
    }
    /// Creates a header element.
    ///
    /// **Accessibility**: Represents introductory content or navigational aids.
    /// Can be used for page headers or section headers.
    #[inline]
    #[must_use]
    pub const fn create_header() -> Self {
        Self {
            root: NodeData::create_node(NodeType::Header),
            children: DomVec::from_const_slice(&[]),
            css: azul_css::css::CssVec::from_const_slice(&[]),
            estimated_total_children: 0,
        }
    }
    /// Creates a footer element.
    ///
    /// **Accessibility**: Represents footer for nearest section or page.
    /// Typically contains copyright, author info, or related links.
    #[inline]
    #[must_use]
    pub const fn create_footer() -> Self {
        Self {
            root: NodeData::create_node(NodeType::Footer),
            children: DomVec::from_const_slice(&[]),
            css: azul_css::css::CssVec::from_const_slice(&[]),
            estimated_total_children: 0,
        }
    }
    /// Creates a main content element.
    ///
    /// **Accessibility**: Represents the dominant content. There should be only ONE main per page.
    /// Screen readers can jump directly to main content. Do not nest inside
    /// article/aside/footer/header/nav.
    #[inline]
    #[must_use]
    pub const fn create_main() -> Self {
        Self {
            root: NodeData::create_node(NodeType::Main),
            children: DomVec::from_const_slice(&[]),
            css: azul_css::css::CssVec::from_const_slice(&[]),
            estimated_total_children: 0,
        }
    }
    /// Creates a figure element.
    ///
    /// **Accessibility**: Represents self-contained content like diagrams, photos, code listings.
    /// Use with `<figcaption>` to provide a caption. Screen readers associate caption with figure.
    #[inline]
    #[must_use]
    pub const fn create_figure() -> Self {
        Self {
            root: NodeData::create_node(NodeType::Figure),
            children: DomVec::from_const_slice(&[]),
            css: azul_css::css::CssVec::from_const_slice(&[]),
            estimated_total_children: 0,
        }
    }
    /// Creates a figure caption element.
    ///
    /// **Accessibility**: Provides a caption for `<figure>`. Screen readers announce this as the
    /// figure description.
    #[inline]
    #[must_use]
    pub const fn create_figcaption() -> Self {
        Self {
            root: NodeData::create_node(NodeType::FigCaption),
            children: DomVec::from_const_slice(&[]),
            css: azul_css::css::CssVec::from_const_slice(&[]),
            estimated_total_children: 0,
        }
    }
    // Interactive Elements
    /// Creates a details disclosure element without accessibility information.
    ///
    /// Prefer [`Dom::create_details`] so that screen readers announce the
    /// disclosure widget's purpose.
    #[inline]
    #[must_use]
    pub const fn create_details_no_a11y() -> Self {
        Self {
            root: NodeData::create_node(NodeType::Details),
            children: DomVec::from_const_slice(&[]),
            css: azul_css::css::CssVec::from_const_slice(&[]),
            estimated_total_children: 0,
        }
    }
    /// Creates a details disclosure element with accessibility information.
    ///
    /// **Accessibility**: Creates a disclosure widget. Screen readers announce expanded/collapsed
    /// state. Must contain a `<summary>` element. Keyboard accessible by default.
    ///
    /// Use [`Dom::create_details_no_a11y`] only as a deliberate escape hatch.
    #[inline]
    #[allow(clippy::needless_pass_by_value)] // owned azul C-ABI value taken by value (FFI ownership-transfer convention)
    #[must_use]
    pub fn create_details(aria: SmallAriaInfo) -> Self {
        Self::create_details_no_a11y().with_accessibility_info(aria.to_full_info())
    }
    /// Creates an empty summary element for details without accessibility information.
    ///
    /// Prefer [`Dom::create_summary`] so that screen readers can announce the
    /// disclosure heading.
    #[inline]
    #[must_use]
    pub const fn create_summary_no_a11y() -> Self {
        Self {
            root: NodeData::create_node(NodeType::Summary),
            children: DomVec::from_const_slice(&[]),
            css: azul_css::css::CssVec::from_const_slice(&[]),
            estimated_total_children: 0,
        }
    }
    /// Creates an empty summary element for details with accessibility information.
    ///
    /// **Accessibility**: The visible heading/label for `<details>`.
    /// Must be the first child of details. Keyboard accessible (Enter/Space to toggle).
    ///
    /// Use [`Dom::create_summary_no_a11y`] only as a deliberate escape hatch.
    #[inline]
    #[allow(clippy::needless_pass_by_value)] // owned azul C-ABI value taken by value (FFI ownership-transfer convention)
    #[must_use]
    pub fn create_summary(aria: SmallAriaInfo) -> Self {
        Self::create_summary_no_a11y().with_accessibility_info(aria.to_full_info())
    }
    /// Creates a summary element with text without accessibility information.
    ///
    /// Prefer [`Dom::create_summary_with_text`] so that screen readers
    /// announce the disclosure heading.
    #[inline]
    pub fn create_summary_with_text_no_a11y<S: Into<AzString>>(text: S) -> Self {
        Self::create_summary_no_a11y().with_child(
            Self::create_text_do_not_use_without_block_level_wrapper(text),
        )
    }
    /// Creates a summary element with text and accessibility information for details.
    ///
    /// **Accessibility**: The visible heading/label for `<details>`.
    /// Must be the first child of details. Keyboard accessible (Enter/Space to toggle).
    ///
    /// Use [`Dom::create_summary_with_text_no_a11y`] only as a deliberate escape hatch.
    #[inline]
    #[allow(clippy::needless_pass_by_value)] // owned azul C-ABI value taken by value (FFI
                                             // ownership-transfer convention)
    pub fn create_summary_with_text<S: Into<AzString>>(text: S, aria: SmallAriaInfo) -> Self {
        Self::create_summary_with_text_no_a11y(text).with_accessibility_info(aria.to_full_info())
    }
    /// Creates a dialog element without accessibility information.
    ///
    /// Prefer [`Dom::create_dialog`] so that the dialog's purpose, modality,
    /// and described-by relationship are surfaced to assistive technologies.
    #[inline]
    #[must_use]
    pub const fn create_dialog_no_a11y() -> Self {
        Self {
            root: NodeData::create_node(NodeType::Dialog),
            children: DomVec::from_const_slice(&[]),
            css: azul_css::css::CssVec::from_const_slice(&[]),
            estimated_total_children: 0,
        }
    }
    /// Creates a dialog element with accessibility information.
    ///
    /// **Accessibility**: Represents a modal or non-modal dialog.
    /// When opened as modal, focus is trapped. Use aria-label or aria-labelledby.
    /// Escape key should close modal dialogs.
    #[inline]
    #[allow(clippy::needless_pass_by_value)] // owned azul C-ABI value taken by value (FFI ownership-transfer convention)
    #[must_use]
    pub fn create_dialog(aria: DialogAriaInfo) -> Self {
        Self::create_dialog_no_a11y().with_accessibility_info(aria.to_full_info())
    }
    // Basic Structural Elements
    #[inline]
    #[must_use]
1
    pub const fn create_br() -> Self {
1
        Self {
1
            root: NodeData::create_node(NodeType::Br),
1
            children: DomVec::from_const_slice(&[]),
1
            css: azul_css::css::CssVec::from_const_slice(&[]),
1
            estimated_total_children: 0,
1
        }
1
    }
    /// Creates a raw text node - only valid as the leaf inside a block-level
    /// wrapper (`p`, `div`, `h1`, ...).
    ///
    /// Azul does not auto-wrap text in an anonymous block the way browsers
    /// do: a bare text node has no box, so every box-model property,
    /// callback, `tab_index` and `dataset` on it is inert. Prefer
    /// `create_*_with_text` ([`Dom::create_p_with_text`],
    /// [`Dom::create_div_with_text`], [`Dom::create_span_with_text`], ...)
    /// instead. The engine logs a warning after layout if it finds an
    /// unwrapped text node.
    #[inline]
124626
    pub fn create_text_do_not_use_without_block_level_wrapper<S: Into<AzString>>(value: S) -> Self {
124626
        Self::create_node(NodeType::Text(BoxOrStatic::heap(value.into())))
124626
    }
    #[inline]
    #[must_use]
1364
    pub fn create_image(image: ImageRef) -> Self {
1364
        Self::create_node(NodeType::Image(BoxOrStatic::heap(image)))
1364
    }
    /// Creates an icon node with the given icon name.
    ///
    /// The icon name should match names from the icon provider (e.g., "home", "settings",
    /// "search"). Icons are resolved to actual content (font glyph, image, etc.) during
    /// `StyledDom` creation based on the configured `IconProvider`.
    ///
    /// # Example
    /// ```rust,ignore
    /// Dom::create_icon("home")
    ///     .with_class("nav-icon")
    /// ```
    #[inline]
20803
    pub fn create_icon<S: Into<AzString>>(icon_name: S) -> Self {
        // The empty text leaf is where icon resolution writes a font icon's
        // glyph (the node itself becomes the inline `<span>` box around it):
        // the arena is DFS-ordered, so the leaf has to exist from the start -
        // see `icon::resolve_icons_in_styled_dom`. `<icon>name</icon>` in
        // markup has its spec text in that place.
20803
        Self::create_node(NodeType::Icon(BoxOrStatic::heap(icon_name.into())))
20803
            .with_child(Self::create_text_do_not_use_without_block_level_wrapper(""))
20803
    }
    /// An icon that can be SWAPPED at runtime, without a full `layout()`.
    ///
    /// Wraps the icon in a `VirtualView`: the view owns the icon spec and
    /// re-renders `create_icon(spec)` as its child DOM, so
    /// `CallbackInfo::set_icon` can swap it without relayouting anything
    /// else. A view is needed rather than an in-place swap because an icon
    /// resolves to a subtree (an SVG icon is a tree of paths), not one node.
    ///
    /// Sizes like a replaced element (an `<img>`): `auto` gives the icon's
    /// measured natural size, a definite size wins.
    ///
    /// # Example
    /// ```rust,ignore
    /// Dom::create_icon_view("system:window-maximize,maximize")
    ///     .with_class("csd-button-icon")
    /// ```
    #[inline]
    #[must_use]
7
    pub fn create_icon_view<S: Into<AzString>>(icon_name: S) -> Self {
7
        crate::icon::icon_view(icon_name)
7
    }
    #[inline]
310
    pub fn create_virtual_view(data: RefAny, callback: impl Into<VirtualViewCallback>) -> Self {
310
        Self::create_from_data(NodeData::create_virtual_view(data, callback))
310
    }
    /// Creates an invisible node that signals "this subtree needs the
    /// user's location": it lays out as zero-size, and the framework
    /// starts/stops the platform location service for as long as it stays
    /// in the tree.
    #[inline]
    #[must_use]
1
    pub fn create_geolocation_probe(config: crate::geolocation::GeolocationProbeConfig) -> Self {
1
        Self::create_node(NodeType::GeolocationProbe(config))
1
    }
    // Semantic HTML Elements with Accessibility Guidance
    /// Creates a paragraph element.
    ///
    /// **Accessibility**: Paragraphs provide semantic structure for screen readers.
    #[inline]
    #[must_use]
452556
    pub const fn create_p() -> Self {
452556
        Self {
452556
            root: NodeData::create_node(NodeType::P),
452556
            children: DomVec::from_const_slice(&[]),
452556
            css: azul_css::css::CssVec::from_const_slice(&[]),
452556
            estimated_total_children: 0,
452556
        }
452556
    }
    /// Creates an empty heading level 1 element.
    ///
    /// **Accessibility**: Use `h1` for the main page title. There should typically be only one `h1`
    /// per page.
    #[inline]
    #[must_use]
23
    pub const fn create_h1() -> Self {
23
        Self {
23
            root: NodeData::create_node(NodeType::H1),
23
            children: DomVec::from_const_slice(&[]),
23
            css: azul_css::css::CssVec::from_const_slice(&[]),
23
            estimated_total_children: 0,
23
        }
23
    }
    /// Creates a heading level 1 element with text.
    ///
    /// **Accessibility**: Use `h1` for the main page title. There should typically be only one `h1`
    /// per page.
    ///
    /// **Parameters:**
    /// - `text`: Heading text
    #[inline]
3
    pub fn create_h1_with_text<S: Into<AzString>>(text: S) -> Self {
3
        Self::create_h1().with_child(Self::create_text_do_not_use_without_block_level_wrapper(
3
            text,
        ))
3
    }
    /// Creates an empty heading level 2 element.
    ///
    /// **Accessibility**: Use `h2` for major section headings under `h1`.
    #[inline]
    #[must_use]
11
    pub const fn create_h2() -> Self {
11
        Self {
11
            root: NodeData::create_node(NodeType::H2),
11
            children: DomVec::from_const_slice(&[]),
11
            css: azul_css::css::CssVec::from_const_slice(&[]),
11
            estimated_total_children: 0,
11
        }
11
    }
    /// Creates a heading level 2 element with text.
    ///
    /// **Accessibility**: Use `h2` for major section headings under `h1`.
    ///
    /// **Parameters:**
    /// - `text`: Heading text
    #[inline]
1
    pub fn create_h2_with_text<S: Into<AzString>>(text: S) -> Self {
1
        Self::create_h2().with_child(Self::create_text_do_not_use_without_block_level_wrapper(
1
            text,
        ))
1
    }
    /// Creates an empty heading level 3 element.
    ///
    /// **Accessibility**: Use `h3` for subsections under `h2`.
    #[inline]
    #[must_use]
22
    pub const fn create_h3() -> Self {
22
        Self {
22
            root: NodeData::create_node(NodeType::H3),
22
            children: DomVec::from_const_slice(&[]),
22
            css: azul_css::css::CssVec::from_const_slice(&[]),
22
            estimated_total_children: 0,
22
        }
22
    }
    /// Creates a heading level 3 element with text.
    ///
    /// **Accessibility**: Use `h3` for subsections under `h2`.
    ///
    /// **Parameters:**
    /// - `text`: Heading text
    #[inline]
2
    pub fn create_h3_with_text<S: Into<AzString>>(text: S) -> Self {
2
        Self::create_h3().with_child(Self::create_text_do_not_use_without_block_level_wrapper(
2
            text,
        ))
2
    }
    /// Creates an empty heading level 4 element.
    #[inline]
    #[must_use]
    pub const fn create_h4() -> Self {
        Self {
            root: NodeData::create_node(NodeType::H4),
            children: DomVec::from_const_slice(&[]),
            css: azul_css::css::CssVec::from_const_slice(&[]),
            estimated_total_children: 0,
        }
    }
    /// Creates a heading level 4 element with text.
    ///
    /// **Parameters:**
    /// - `text`: Heading text
    #[inline]
    pub fn create_h4_with_text<S: Into<AzString>>(text: S) -> Self {
        Self::create_h4().with_child(Self::create_text_do_not_use_without_block_level_wrapper(
            text,
        ))
    }
    /// Creates an empty heading level 5 element.
    #[inline]
    #[must_use]
    pub const fn create_h5() -> Self {
        Self {
            root: NodeData::create_node(NodeType::H5),
            children: DomVec::from_const_slice(&[]),
            css: azul_css::css::CssVec::from_const_slice(&[]),
            estimated_total_children: 0,
        }
    }
    /// Creates a heading level 5 element with text.
    ///
    /// **Parameters:**
    /// - `text`: Heading text
    #[inline]
    pub fn create_h5_with_text<S: Into<AzString>>(text: S) -> Self {
        Self::create_h5().with_child(Self::create_text_do_not_use_without_block_level_wrapper(
            text,
        ))
    }
    /// Creates an empty heading level 6 element.
    #[inline]
    #[must_use]
    pub const fn create_h6() -> Self {
        Self {
            root: NodeData::create_node(NodeType::H6),
            children: DomVec::from_const_slice(&[]),
            css: azul_css::css::CssVec::from_const_slice(&[]),
            estimated_total_children: 0,
        }
    }
    /// Creates a heading level 6 element with text.
    ///
    /// **Parameters:**
    /// - `text`: Heading text
    #[inline]
    pub fn create_h6_with_text<S: Into<AzString>>(text: S) -> Self {
        Self::create_h6().with_child(Self::create_text_do_not_use_without_block_level_wrapper(
            text,
        ))
    }
    /// Creates an empty generic inline container (span).
    ///
    /// **Accessibility**: Prefer semantic elements like `strong`, `em`, `code`, etc. when
    /// applicable.
    #[inline]
    #[must_use]
594
    pub const fn create_span() -> Self {
594
        Self {
594
            root: NodeData::create_node(NodeType::Span),
594
            children: DomVec::from_const_slice(&[]),
594
            css: azul_css::css::CssVec::from_const_slice(&[]),
594
            estimated_total_children: 0,
594
        }
594
    }
    /// Creates a generic inline container (span) with text.
    ///
    /// **Accessibility**: Prefer semantic elements like `strong`, `em`, `code`, etc. when
    /// applicable.
    ///
    /// **Parameters:**
    /// - `text`: Span content
    #[inline]
62
    pub fn create_span_with_text<S: Into<AzString>>(text: S) -> Self {
62
        Self::create_span().with_child(Self::create_text_do_not_use_without_block_level_wrapper(
62
            text,
        ))
62
    }
    /// Creates an empty strong importance element.
    ///
    /// **Accessibility**: Use `strong` instead of `b` for semantic meaning.
    #[inline]
    #[must_use]
    pub const fn create_strong() -> Self {
        Self {
            root: NodeData::create_node(NodeType::Strong),
            children: DomVec::from_const_slice(&[]),
            css: azul_css::css::CssVec::from_const_slice(&[]),
            estimated_total_children: 0,
        }
    }
    /// Creates a strongly emphasized text element with text (strong importance).
    ///
    /// **Accessibility**: Use `strong` instead of `b` for semantic meaning. Screen readers can
    /// convey the importance. Use for text that has strong importance, seriousness, or urgency.
    ///
    /// **Parameters:**
    /// - `text`: Text to emphasize
    #[inline]
    pub fn create_strong_with_text<S: Into<AzString>>(text: S) -> Self {
        Self::create_strong().with_child(Self::create_text_do_not_use_without_block_level_wrapper(
            text,
        ))
    }
    /// Creates an empty emphasis element (stress emphasis).
    ///
    /// **Accessibility**: Use `em` instead of `i` for semantic meaning.
    #[inline]
    #[must_use]
1
    pub const fn create_em() -> Self {
1
        Self {
1
            root: NodeData::create_node(NodeType::Em),
1
            children: DomVec::from_const_slice(&[]),
1
            css: azul_css::css::CssVec::from_const_slice(&[]),
1
            estimated_total_children: 0,
1
        }
1
    }
    /// Creates an emphasized text element with text (stress emphasis).
    ///
    /// **Accessibility**: Use `em` instead of `i` for semantic meaning. Screen readers can
    /// convey the emphasis. Use for text that has stress emphasis.
    ///
    /// **Parameters:**
    /// - `text`: Text to emphasize
    #[inline]
    pub fn create_em_with_text<S: Into<AzString>>(text: S) -> Self {
        Self::create_em().with_child(Self::create_text_do_not_use_without_block_level_wrapper(
            text,
        ))
    }
    /// Creates an empty code element.
    ///
    /// **Accessibility**: Represents a fragment of computer code.
    #[inline]
    #[must_use]
    pub fn create_code() -> Self {
        Self::create_node(NodeType::Code)
    }
    /// Creates a code/computer code element with text.
    ///
    /// **Accessibility**: Represents a fragment of computer code. Screen readers can identify
    /// this as code content.
    ///
    /// **Parameters:**
    /// - `code`: Code content
    #[inline]
    pub fn create_code_with_text<S: Into<AzString>>(code: S) -> Self {
        Self::create_code().with_child(Self::create_text_do_not_use_without_block_level_wrapper(
            code,
        ))
    }
    /// Creates an empty preformatted text element.
    ///
    /// **Accessibility**: Preserves whitespace and line breaks.
    #[inline]
    #[must_use]
11
    pub fn create_pre() -> Self {
11
        Self::create_node(NodeType::Pre)
11
    }
    /// Creates a preformatted text element with text.
    ///
    /// **Accessibility**: Preserves whitespace and line breaks. Useful for code blocks or
    /// ASCII art. Screen readers will read the content as-is.
    ///
    /// **Parameters:**
    /// - `text`: Preformatted content
    #[inline]
1
    pub fn create_pre_with_text<S: Into<AzString>>(text: S) -> Self {
1
        Self::create_pre().with_child(Self::create_text_do_not_use_without_block_level_wrapper(
1
            text,
        ))
1
    }
    /// Creates an empty blockquote element.
    ///
    /// **Accessibility**: Represents a section quoted from another source.
    #[inline]
    #[must_use]
    pub fn create_blockquote() -> Self {
        Self::create_node(NodeType::BlockQuote)
    }
    /// Creates a blockquote element with text.
    ///
    /// **Accessibility**: Represents a section quoted from another source. Screen readers
    /// can identify quoted content. Consider adding a `cite` attribute.
    ///
    /// **Parameters:**
    /// - `text`: Quote content
    #[inline]
    pub fn create_blockquote_with_text<S: Into<AzString>>(text: S) -> Self {
        Self::create_blockquote().with_child(
            Self::create_text_do_not_use_without_block_level_wrapper(text),
        )
    }
    /// Creates an empty citation element.
    ///
    /// **Accessibility**: Represents a reference to a creative work.
    #[inline]
    #[must_use]
    pub fn create_cite() -> Self {
        Self::create_node(NodeType::Cite)
    }
    /// Creates a citation element with text.
    ///
    /// **Accessibility**: Represents a reference to a creative work. Screen readers can
    /// identify citations.
    ///
    /// **Parameters:**
    /// - `text`: Citation text
    #[inline]
    pub fn create_cite_with_text<S: Into<AzString>>(text: S) -> Self {
        Self::create_cite().with_child(Self::create_text_do_not_use_without_block_level_wrapper(
            text,
        ))
    }
    /// Creates an empty abbreviation element.
    ///
    /// **Accessibility**: Represents an abbreviation or acronym. Use with a `title` attribute
    /// to provide the full expansion for screen readers.
    #[inline]
    #[must_use]
    pub fn create_abbr() -> Self {
        Self::create_node(NodeType::Abbr)
    }
    /// Creates an abbreviation element with abbreviated text and a `title` expansion.
    ///
    /// **Accessibility**: Represents an abbreviation or acronym. The `title` attribute
    /// provides the full expansion for screen readers.
    ///
    /// **Parameters:**
    /// - `abbr_text`: Abbreviated text
    /// - `title`: Full expansion
    #[inline]
    #[must_use]
    pub fn create_abbr_with_title(abbr_text: AzString, title: AzString) -> Self {
        Self::create_node(NodeType::Abbr)
            .with_attribute(AttributeType::Title(title))
            .with_child(Self::create_text_do_not_use_without_block_level_wrapper(
                abbr_text,
            ))
    }
    /// Creates an empty keyboard input element.
    ///
    /// **Accessibility**: Represents keyboard input or key combinations.
    #[inline]
    #[must_use]
    pub fn create_kbd() -> Self {
        Self::create_node(NodeType::Kbd)
    }
    /// Creates a keyboard input element with text.
    ///
    /// **Accessibility**: Represents keyboard input or key combinations. Screen readers can
    /// identify keyboard instructions.
    ///
    /// **Parameters:**
    /// - `text`: Keyboard instruction
    #[inline]
    pub fn create_kbd_with_text<S: Into<AzString>>(text: S) -> Self {
        Self::create_kbd().with_child(Self::create_text_do_not_use_without_block_level_wrapper(
            text,
        ))
    }
    /// Creates an empty sample output element.
    ///
    /// **Accessibility**: Represents sample output from a program or computing system.
    #[inline]
    #[must_use]
    pub fn create_samp() -> Self {
        Self::create_node(NodeType::Samp)
    }
    /// Creates a sample output element with text.
    ///
    /// **Accessibility**: Represents sample output from a program or computing system.
    ///
    /// **Parameters:**
    /// - `text`: Sample text
    #[inline]
    pub fn create_samp_with_text<S: Into<AzString>>(text: S) -> Self {
        Self::create_samp().with_child(Self::create_text_do_not_use_without_block_level_wrapper(
            text,
        ))
    }
    /// Creates an empty variable element.
    ///
    /// **Accessibility**: Represents a variable in mathematical expressions or programming.
    #[inline]
    #[must_use]
    pub fn create_var() -> Self {
        Self::create_node(NodeType::Var)
    }
    /// Creates a variable element with text.
    ///
    /// **Accessibility**: Represents a variable in mathematical expressions or programming.
    ///
    /// **Parameters:**
    /// - `text`: Variable name
    #[inline]
    pub fn create_var_with_text<S: Into<AzString>>(text: S) -> Self {
        Self::create_var().with_child(Self::create_text_do_not_use_without_block_level_wrapper(
            text,
        ))
    }
    /// Creates an empty subscript element.
    #[inline]
    #[must_use]
    pub fn create_sub() -> Self {
        Self::create_node(NodeType::Sub)
    }
    /// Creates a subscript element with text.
    ///
    /// **Accessibility**: Screen readers may announce subscript formatting.
    ///
    /// **Parameters:**
    /// - `text`: Subscript content
    #[inline]
    pub fn create_sub_with_text<S: Into<AzString>>(text: S) -> Self {
        Self::create_sub().with_child(Self::create_text_do_not_use_without_block_level_wrapper(
            text,
        ))
    }
    /// Creates an empty superscript element.
    #[inline]
    #[must_use]
    pub fn create_sup() -> Self {
        Self::create_node(NodeType::Sup)
    }
    /// Creates a superscript element with text.
    ///
    /// **Accessibility**: Screen readers may announce superscript formatting.
    ///
    /// **Parameters:**
    /// - `text`: Superscript content
    #[inline]
    pub fn create_sup_with_text<S: Into<AzString>>(text: S) -> Self {
        Self::create_sup().with_child(Self::create_text_do_not_use_without_block_level_wrapper(
            text,
        ))
    }
    /// Creates an empty underline element.
    #[inline]
    #[must_use]
    pub fn create_u() -> Self {
        Self::create_node(NodeType::U)
    }
    /// Creates an underline text element with text.
    ///
    /// **Accessibility**: Screen readers typically don't announce underline formatting.
    /// Use semantic elements when possible (e.g., `<em>` for emphasis).
    #[inline]
    pub fn create_u_with_text<S: Into<AzString>>(text: S) -> Self {
        Self::create_u().with_child(Self::create_text_do_not_use_without_block_level_wrapper(
            text,
        ))
    }
    /// Creates an empty strikethrough element.
    #[inline]
    #[must_use]
    pub fn create_s() -> Self {
        Self::create_node(NodeType::S)
    }
    /// Creates a strikethrough text element with text.
    ///
    /// **Accessibility**: Represents text that is no longer accurate or relevant.
    /// Consider using `<del>` for deleted content with datetime attribute.
    #[inline]
    pub fn create_s_with_text<S: Into<AzString>>(text: S) -> Self {
        Self::create_s().with_child(Self::create_text_do_not_use_without_block_level_wrapper(
            text,
        ))
    }
    /// Creates an empty mark element.
    #[inline]
    #[must_use]
    pub fn create_mark() -> Self {
        Self::create_node(NodeType::Mark)
    }
    /// Creates a marked/highlighted text element with text.
    ///
    /// **Accessibility**: Represents text marked for reference or notation purposes.
    /// Screen readers may announce this as "highlighted".
    #[inline]
    pub fn create_mark_with_text<S: Into<AzString>>(text: S) -> Self {
        Self::create_mark().with_child(Self::create_text_do_not_use_without_block_level_wrapper(
            text,
        ))
    }
    /// Creates an empty deleted text element.
    #[inline]
    #[must_use]
    pub fn create_del() -> Self {
        Self::create_node(NodeType::Del)
    }
    /// Creates a deleted text element with text.
    ///
    /// **Accessibility**: Represents deleted content in document edits.
    /// Use with `datetime` and `cite` attributes for edit tracking.
    #[inline]
    pub fn create_del_with_text<S: Into<AzString>>(text: S) -> Self {
        Self::create_del().with_child(Self::create_text_do_not_use_without_block_level_wrapper(
            text,
        ))
    }
    /// Creates an empty inserted text element.
    #[inline]
    #[must_use]
    pub fn create_ins() -> Self {
        Self::create_node(NodeType::Ins)
    }
    /// Creates an inserted text element with text.
    ///
    /// **Accessibility**: Represents inserted content in document edits.
    /// Use with `datetime` and `cite` attributes for edit tracking.
    #[inline]
    pub fn create_ins_with_text<S: Into<AzString>>(text: S) -> Self {
        Self::create_ins().with_child(Self::create_text_do_not_use_without_block_level_wrapper(
            text,
        ))
    }
    /// Creates an empty definition element.
    #[inline]
    #[must_use]
    pub fn create_dfn() -> Self {
        Self::create_node(NodeType::Dfn)
    }
    /// Creates a definition element with text.
    ///
    /// **Accessibility**: Represents the defining instance of a term.
    /// Often used within a definition list or with `<abbr>`.
    #[inline]
    pub fn create_dfn_with_text<S: Into<AzString>>(text: S) -> Self {
        Self::create_dfn().with_child(Self::create_text_do_not_use_without_block_level_wrapper(
            text,
        ))
    }
    /// Creates a time element.
    ///
    /// **Accessibility**: Represents a specific time or date.
    /// Use `datetime` attribute for machine-readable format.
    ///
    /// **Parameters:**
    /// - `text`: Human-readable time/date
    /// - `datetime`: Optional machine-readable datetime
    #[inline]
    #[must_use]
    pub fn create_time(text: AzString, datetime: OptionString) -> Self {
        let mut element = Self::create_node(NodeType::Time).with_child(
            Self::create_text_do_not_use_without_block_level_wrapper(text),
        );
        if let OptionString::Some(dt) = datetime {
            element = element.with_attribute(AttributeType::Custom(AttributeNameValue {
                attr_name: "datetime".into(),
                value: dt,
            }));
        }
        element
    }
    /// Creates an empty bi-directional override element.
    ///
    /// **Accessibility**: Overrides text direction. Use `dir` attribute (ltr/rtl).
    #[inline]
    #[must_use]
    pub fn create_bdo() -> Self {
        Self::create_node(NodeType::Bdo)
    }
    /// Creates a bi-directional override element with text.
    ///
    /// **Accessibility**: Overrides text direction. Use `dir` attribute (ltr/rtl).
    #[inline]
    pub fn create_bdo_with_text<S: Into<AzString>>(text: S) -> Self {
        Self::create_bdo().with_child(Self::create_text_do_not_use_without_block_level_wrapper(
            text,
        ))
    }
    // Additional inline / text-level elements
    /// Creates an empty bold element.
    ///
    /// **Accessibility**: Prefer `<strong>` for semantic emphasis. `<b>` is purely stylistic.
    #[inline]
    #[must_use]
    pub fn create_b() -> Self {
        Self::create_node(NodeType::B)
    }
    /// Creates a bold element with text.
    ///
    /// **Accessibility**: Prefer `<strong>` for semantic emphasis. `<b>` is purely stylistic.
    ///
    /// **Parameters:**
    /// - `text`: Bold text content
    #[inline]
    pub fn create_b_with_text<S: Into<AzString>>(text: S) -> Self {
        Self::create_b().with_child(Self::create_text_do_not_use_without_block_level_wrapper(
            text,
        ))
    }
    /// Creates an empty italic element.
    ///
    /// **Accessibility**: Prefer `<em>` for stress emphasis. `<i>` is purely stylistic.
    #[inline]
    #[must_use]
    pub fn create_i() -> Self {
        Self::create_node(NodeType::I)
    }
    /// Creates an italic element with text.
    ///
    /// **Accessibility**: Prefer `<em>` for stress emphasis. `<i>` is purely stylistic.
    ///
    /// **Parameters:**
    /// - `text`: Italic text content
    #[inline]
    pub fn create_i_with_text<S: Into<AzString>>(text: S) -> Self {
        Self::create_i().with_child(Self::create_text_do_not_use_without_block_level_wrapper(
            text,
        ))
    }
    /// Creates an empty small text element.
    ///
    /// **Accessibility**: Represents side-comments and small print like copyright/legal text.
    #[inline]
    #[must_use]
    pub fn create_small() -> Self {
        Self::create_node(NodeType::Small)
    }
    /// Creates a small text element with text.
    ///
    /// **Parameters:**
    /// - `text`: Small text content
    #[inline]
    pub fn create_small_with_text<S: Into<AzString>>(text: S) -> Self {
        Self::create_small().with_child(Self::create_text_do_not_use_without_block_level_wrapper(
            text,
        ))
    }
    /// Creates an empty `<big>` element.
    ///
    /// **Note**: Deprecated in HTML5. Prefer CSS `font-size`.
    #[inline]
    #[must_use]
    pub fn create_big() -> Self {
        Self::create_node(NodeType::Big)
    }
    /// Creates a `<big>` element with text.
    ///
    /// **Note**: Deprecated in HTML5. Prefer CSS `font-size`.
    #[inline]
    pub fn create_big_with_text<S: Into<AzString>>(text: S) -> Self {
        Self::create_big().with_child(Self::create_text_do_not_use_without_block_level_wrapper(
            text,
        ))
    }
    /// Creates an empty bi-directional isolate element.
    ///
    /// **Accessibility**: Used to isolate text whose direction is unknown,
    /// keeping it from affecting surrounding bidi layout.
    #[inline]
    #[must_use]
    pub fn create_bdi() -> Self {
        Self::create_node(NodeType::Bdi)
    }
    /// Creates a bi-directional isolate element with text.
    ///
    /// **Accessibility**: Used to isolate text whose direction is unknown,
    /// keeping it from affecting surrounding bidi layout.
    #[inline]
    pub fn create_bdi_with_text<S: Into<AzString>>(text: S) -> Self {
        Self::create_bdi().with_child(Self::create_text_do_not_use_without_block_level_wrapper(
            text,
        ))
    }
    /// Creates an empty word break opportunity element.
    ///
    /// **Note**: `<wbr>` is a self-closing element that suggests a line-break opportunity.
    /// It does not take text content.
    #[inline]
    #[must_use]
    pub fn create_wbr() -> Self {
        Self::create_node(NodeType::Wbr)
    }
    /// Creates an empty ruby annotation element.
    ///
    /// **Accessibility**: Used for East Asian typography to provide
    /// pronunciation/translation annotations. Wraps `<rt>`/`<rp>` children.
    #[inline]
    #[must_use]
    pub fn create_ruby() -> Self {
        Self::create_node(NodeType::Ruby)
    }
    /// Creates an empty ruby text element.
    ///
    /// **Accessibility**: Pronunciation/translation annotation inside `<ruby>`.
    #[inline]
    #[must_use]
    pub fn create_rt() -> Self {
        Self::create_node(NodeType::Rt)
    }
    /// Creates a ruby text element with text.
    ///
    /// **Parameters:**
    /// - `text`: Ruby annotation content
    #[inline]
    pub fn create_rt_with_text<S: Into<AzString>>(text: S) -> Self {
        Self::create_rt().with_child(Self::create_text_do_not_use_without_block_level_wrapper(
            text,
        ))
    }
    /// Creates an empty ruby text container element.
    ///
    /// **Accessibility**: Container for ruby text annotations.
    #[inline]
    #[must_use]
    pub fn create_rtc() -> Self {
        Self::create_node(NodeType::Rtc)
    }
    /// Creates an empty ruby fallback parenthesis element.
    ///
    /// **Accessibility**: Provides parentheses around `<rt>` for browsers without ruby support.
    #[inline]
    #[must_use]
    pub fn create_rp() -> Self {
        Self::create_node(NodeType::Rp)
    }
    /// Creates a ruby fallback parenthesis element with text.
    ///
    /// **Parameters:**
    /// - `text`: Parenthesis text (typically "(" or ")")
    #[inline]
    pub fn create_rp_with_text<S: Into<AzString>>(text: S) -> Self {
        Self::create_rp().with_child(Self::create_text_do_not_use_without_block_level_wrapper(
            text,
        ))
    }
    /// Creates a `<data>` element binding a machine-readable value to its content.
    ///
    /// **Parameters:**
    /// - `value`: Machine-readable value for the `value` attribute.
    #[inline]
    #[must_use]
    pub fn create_data(value: AzString) -> Self {
        Self::create_node(NodeType::Data).with_attribute(AttributeType::Value(value))
    }
    /// Creates a `<data>` element with both a machine-readable value and visible text.
    ///
    /// **Parameters:**
    /// - `value`: Machine-readable value for the `value` attribute.
    /// - `text`: Human-readable text content.
    #[inline]
    #[must_use]
    pub fn create_data_with_text(value: AzString, text: AzString) -> Self {
        Self::create_data(value).with_child(
            Self::create_text_do_not_use_without_block_level_wrapper(text),
        )
    }
    /// Creates an empty directory list element.
    ///
    /// **Note**: Deprecated in HTML5. Use `<ul>` instead.
    #[inline]
    #[must_use]
    pub fn create_dir() -> Self {
        Self::create_node(NodeType::Dir)
    }
    /// Creates an empty SVG container element.
    ///
    /// **Accessibility**: Provide `aria-label` or `<title>` child for assistive tech.
    #[inline]
    #[must_use]
    pub fn create_svg() -> Self {
        Self::create_node(NodeType::Svg)
    }
    /// Creates an anchor/hyperlink element without accessibility information.
    ///
    /// Prefer [`Dom::create_a`] so that screen readers get a meaningful label.
    ///
    /// **Parameters:**
    /// - `href`: Link destination URL
    /// - `label`: Link text (pass `None` for image-only links with alt text)
    #[inline]
    #[must_use]
2
    pub fn create_a_no_a11y(href: AzString, label: OptionString) -> Self {
2
        let mut link = Self::create_node(NodeType::A).with_attribute(AttributeType::Href(href));
2
        if let OptionString::Some(text) = label {
1
            link = link.with_child(Self::create_text_do_not_use_without_block_level_wrapper(
1
                text,
1
            ));
1
        }
2
        link
2
    }
    /// Creates a button element without accessibility information.
    ///
    /// Prefer [`Dom::create_button`] so that the element has a meaningful accessible
    /// name for screen readers.
    ///
    /// **Parameters:**
    /// - `text`: Button label text
    #[inline]
    #[must_use]
3
    pub fn create_button_no_a11y(text: AzString) -> Self {
3
        Self::create_node(NodeType::Button).with_child(
3
            Self::create_text_do_not_use_without_block_level_wrapper(text),
        )
3
    }
    /// Creates a label element for form controls without accessibility information.
    ///
    /// Prefer [`Dom::create_label`] so that screen readers get a descriptive label.
    ///
    /// **Parameters:**
    /// - `for_id`: ID of the associated form control
    /// - `text`: Label text
    #[inline]
    #[must_use]
2
    pub fn create_label_no_a11y(for_id: AzString, text: AzString) -> Self {
2
        Self::create_node(NodeType::Label)
2
            .with_attribute(AttributeType::Custom(AttributeNameValue {
2
                attr_name: "for".into(),
2
                value: for_id,
2
            }))
2
            .with_child(Self::create_text_do_not_use_without_block_level_wrapper(
2
                text,
            ))
2
    }
    /// Creates an input element without accessibility information.
    ///
    /// Prefer [`Dom::create_input`] so that screen readers get a descriptive label
    /// beyond the HTML `aria-label` attribute.
    ///
    /// **Parameters:**
    /// - `input_type`: Input type (text, password, email, etc.)
    /// - `name`: Form field name
    /// - `label`: Accessibility label (required)
    #[inline]
    #[must_use]
2
    pub fn create_input_no_a11y(input_type: AzString, name: AzString, label: AzString) -> Self {
2
        Self::create_node(NodeType::Input)
2
            .with_attribute(AttributeType::InputType(input_type))
2
            .with_attribute(AttributeType::Name(name))
2
            .with_attribute(AttributeType::AriaLabel(label))
2
    }
    /// Creates a textarea element without accessibility information.
    ///
    /// Prefer [`Dom::create_textarea`] so that screen readers get an accurate
    /// description of the control.
    ///
    /// **Parameters:**
    /// - `name`: Form field name
    /// - `label`: Accessibility label (required)
    #[inline]
    #[must_use]
2
    pub fn create_textarea_no_a11y(name: AzString, label: AzString) -> Self {
2
        Self::create_node(NodeType::TextArea)
2
            .with_attribute(AttributeType::Name(name))
2
            .with_attribute(AttributeType::AriaLabel(label))
2
    }
    /// Creates a select dropdown element without accessibility information.
    ///
    /// Prefer [`Dom::create_select`] so that screen readers announce the control
    /// appropriately.
    ///
    /// **Parameters:**
    /// - `name`: Form field name
    /// - `label`: Accessibility label (required)
    #[inline]
    #[must_use]
2
    pub fn create_select_no_a11y(name: AzString, label: AzString) -> Self {
2
        Self::create_node(NodeType::Select)
2
            .with_attribute(AttributeType::Name(name))
2
            .with_attribute(AttributeType::AriaLabel(label))
2
    }
    /// Creates an option element for select dropdowns.
    ///
    /// **Parameters:**
    /// - `value`: Option value
    /// - `text`: Display text
    #[inline]
    #[must_use]
    pub fn create_option_no_a11y(value: AzString, text: AzString) -> Self {
        Self::create_node(NodeType::SelectOption)
            .with_attribute(AttributeType::Value(value))
            .with_child(Self::create_text_do_not_use_without_block_level_wrapper(
                text,
            ))
    }
    /// Creates an option element for select dropdowns with accessibility information.
    ///
    /// **Parameters:**
    /// - `value`: Option value
    /// - `text`: Display text
    /// - `aria`: Accessibility information (description, etc.)
    ///
    /// Use [`Dom::create_option_no_a11y`] only as a deliberate escape hatch.
    #[inline]
    #[allow(clippy::needless_pass_by_value)] // owned azul C-ABI value taken by value (FFI ownership-transfer convention)
    #[must_use]
    pub fn create_option(value: AzString, text: AzString, aria: SmallAriaInfo) -> Self {
        Self::create_option_no_a11y(value, text).with_accessibility_info(aria.to_full_info())
    }
    /// Creates an unordered list element.
    ///
    /// **Accessibility**: Screen readers announce lists and item counts, helping users
    /// understand content structure.
    #[inline]
    #[must_use]
33
    pub fn create_ul() -> Self {
33
        Self::create_node(NodeType::Ul)
33
    }
    /// Creates an ordered list element.
    ///
    /// **Accessibility**: Screen readers announce lists and item counts, helping users
    /// understand content structure and numbering.
    #[inline]
    #[must_use]
    pub fn create_ol() -> Self {
        Self::create_node(NodeType::Ol)
    }
    /// Creates a list item element.
    ///
    /// **Accessibility**: Must be a child of `ul`, `ol`, or `menu`. Screen readers announce
    /// list item position (e.g., "2 of 5").
    #[inline]
    #[must_use]
99
    pub fn create_li() -> Self {
99
        Self::create_node(NodeType::Li)
99
    }
    /// Creates a table element without accessibility information.
    ///
    /// Prefer [`Dom::create_table`] so that screen readers can announce the table's
    /// purpose alongside its caption.
    #[inline]
    #[must_use]
3
    pub fn create_table_no_a11y() -> Self {
3
        Self::create_node(NodeType::Table)
3
    }
    /// Creates a table caption element.
    ///
    /// **Accessibility**: Describes the purpose of the table. Screen readers announce this first.
    #[inline]
    #[must_use]
1
    pub fn create_caption() -> Self {
1
        Self::create_node(NodeType::Caption)
1
    }
    /// Creates a table header element.
    ///
    /// **Accessibility**: Groups header rows. Screen readers can navigate table structure.
    #[inline]
    #[must_use]
1
    pub fn create_thead() -> Self {
1
        Self::create_node(NodeType::THead)
1
    }
    /// Creates a table body element.
    ///
    /// **Accessibility**: Groups body rows. Screen readers can navigate table structure.
    #[inline]
    #[must_use]
    pub fn create_tbody() -> Self {
        Self::create_node(NodeType::TBody)
    }
    /// Creates a table footer element.
    ///
    /// **Accessibility**: Groups footer rows. Screen readers can navigate table structure.
    #[inline]
    #[must_use]
    pub fn create_tfoot() -> Self {
        Self::create_node(NodeType::TFoot)
    }
    /// Creates a table row element.
    #[inline]
    #[must_use]
1
    pub fn create_tr() -> Self {
1
        Self::create_node(NodeType::Tr)
1
    }
    /// Creates a table header cell element.
    ///
    /// **Accessibility**: Use `scope` attribute ("col" or "row") to associate headers with
    /// data cells. Screen readers use this to announce cell context.
    #[inline]
    #[must_use]
2
    pub fn create_th() -> Self {
2
        Self::create_node(NodeType::Th)
2
    }
    /// Creates a table data cell element.
    #[inline]
    #[must_use]
    pub fn create_td() -> Self {
        Self::create_node(NodeType::Td)
    }
    /// Creates a form element without accessibility information.
    ///
    /// Prefer [`Dom::create_form`] so that screen readers can announce the form's purpose.
    #[inline]
    #[must_use]
    pub fn create_form_no_a11y() -> Self {
        Self::create_node(NodeType::Form)
    }
    /// Creates a form element with accessibility information.
    ///
    /// **Accessibility**: Group related form controls with `fieldset` and `legend`.
    /// Provide clear labels for all inputs. Consider `aria-describedby` for instructions.
    ///
    /// Use [`Dom::create_form_no_a11y`] only as a deliberate escape hatch.
    #[inline]
    #[allow(clippy::needless_pass_by_value)] // owned azul C-ABI value taken by value (FFI ownership-transfer convention)
    #[must_use]
    pub fn create_form(aria: SmallAriaInfo) -> Self {
        Self::create_form_no_a11y().with_accessibility_info(aria.to_full_info())
    }
    /// Creates a fieldset element for grouping form controls without accessibility info.
    ///
    /// Prefer [`Dom::create_fieldset`] so that screen readers can announce the group's purpose.
    #[inline]
    #[must_use]
    pub fn create_fieldset_no_a11y() -> Self {
        Self::create_node(NodeType::FieldSet)
    }
    /// Creates a fieldset element with accessibility information.
    ///
    /// **Accessibility**: Groups related form controls. Always include a `legend` as the
    /// first child to describe the group. Screen readers announce the legend when entering
    /// the fieldset.
    ///
    /// Use [`Dom::create_fieldset_no_a11y`] only as a deliberate escape hatch.
    #[inline]
    #[allow(clippy::needless_pass_by_value)] // owned azul C-ABI value taken by value (FFI ownership-transfer convention)
    #[must_use]
    pub fn create_fieldset(aria: SmallAriaInfo) -> Self {
        Self::create_fieldset_no_a11y().with_accessibility_info(aria.to_full_info())
    }
    /// Creates a legend element without accessibility information.
    ///
    /// Prefer [`Dom::create_legend`] so that the legend's accessible name is explicit.
    #[inline]
    #[must_use]
    pub fn create_legend_no_a11y() -> Self {
        Self::create_node(NodeType::Legend)
    }
    /// Creates a legend element with accessibility information.
    ///
    /// **Accessibility**: Describes the purpose of a fieldset. Must be the first child of
    /// a fieldset. Screen readers announce this when entering the fieldset.
    ///
    /// Use [`Dom::create_legend_no_a11y`] only as a deliberate escape hatch.
    #[inline]
    #[allow(clippy::needless_pass_by_value)] // owned azul C-ABI value taken by value (FFI ownership-transfer convention)
    #[must_use]
    pub fn create_legend(aria: SmallAriaInfo) -> Self {
        Self::create_legend_no_a11y().with_accessibility_info(aria.to_full_info())
    }
    /// Creates a horizontal rule element.
    ///
    /// **Accessibility**: Represents a thematic break. Screen readers may announce this as
    /// a separator. Consider using CSS borders for purely decorative lines.
    #[inline]
    #[must_use]
    pub fn create_hr() -> Self {
        Self::create_node(NodeType::Hr)
    }
    /// Creates THE canonical page-break element: a zero-size block with
    /// `break-before: page`, carrying the `__azul-native-pagebreak` class.
    ///
    /// This is the one break element the pagination estimator and a screen
    /// DOM treat identically (see `pagination_to_dom_breaks` in
    /// azul-layout): an application materializes an estimated break by
    /// inserting this node at the returned child-index path, and the layout
    /// of the surrounding content does not move - the element is an empty
    /// block with no margins, borders or padding, so sibling margins keep
    /// collapsing through it exactly as they did without it.
    ///
    /// The XML pipeline's `<pagebreak/>` builtin renders the equivalent
    /// element.
    #[must_use]
36
    pub fn create_page_break() -> Self {
36
        Self::create_node(NodeType::PageBreak)
36
    }
    // Additional Element Constructors
    /// Creates an address element.
    ///
    /// **Accessibility**: Represents contact information. Screen readers identify this
    /// as address content.
    #[inline]
    #[must_use]
    pub const fn create_address() -> Self {
        Self {
            root: NodeData::create_node(NodeType::Address),
            children: DomVec::from_const_slice(&[]),
            css: azul_css::css::CssVec::from_const_slice(&[]),
            estimated_total_children: 0,
        }
    }
    /// Creates a definition list element.
    ///
    /// **Accessibility**: Screen readers announce definition lists and their structure.
    #[inline]
    #[must_use]
    pub const fn create_dl() -> Self {
        Self {
            root: NodeData::create_node(NodeType::Dl),
            children: DomVec::from_const_slice(&[]),
            css: azul_css::css::CssVec::from_const_slice(&[]),
            estimated_total_children: 0,
        }
    }
    /// Creates a definition term element.
    ///
    /// **Accessibility**: Must be a child of `dl`. Represents the term being defined.
    #[inline]
    #[must_use]
    pub const fn create_dt() -> Self {
        Self {
            root: NodeData::create_node(NodeType::Dt),
            children: DomVec::from_const_slice(&[]),
            css: azul_css::css::CssVec::from_const_slice(&[]),
            estimated_total_children: 0,
        }
    }
    /// Creates a definition description element.
    ///
    /// **Accessibility**: Must be a child of `dl`. Provides the definition for the term.
    #[inline]
    #[must_use]
    pub const fn create_dd() -> Self {
        Self {
            root: NodeData::create_node(NodeType::Dd),
            children: DomVec::from_const_slice(&[]),
            css: azul_css::css::CssVec::from_const_slice(&[]),
            estimated_total_children: 0,
        }
    }
    /// Creates a table column group element.
    #[inline]
    #[must_use]
    pub const fn create_colgroup() -> Self {
        Self {
            root: NodeData::create_node(NodeType::ColGroup),
            children: DomVec::from_const_slice(&[]),
            css: azul_css::css::CssVec::from_const_slice(&[]),
            estimated_total_children: 0,
        }
    }
    /// Creates a table column element.
    #[inline]
    #[must_use]
    pub fn create_col(span: i32) -> Self {
        Self::create_node(NodeType::Col).with_attribute(AttributeType::ColSpan(span))
    }
    /// Creates an optgroup element for grouping select options without accessibility info.
    ///
    /// Prefer [`Dom::create_optgroup`] so that screen readers can announce the group's purpose.
    ///
    /// **Parameters:**
    /// - `label`: Label for the option group
    #[inline]
    #[must_use]
    pub fn create_optgroup_no_a11y(label: AzString) -> Self {
        Self::create_node(NodeType::OptGroup).with_attribute(AttributeType::AriaLabel(label))
    }
    /// Creates an optgroup element for grouping select options with accessibility information.
    ///
    /// **Parameters:**
    /// - `label`: Label for the option group (visible)
    /// - `aria`: Additional accessibility information (description, etc.)
    ///
    /// Use [`Dom::create_optgroup_no_a11y`] only as a deliberate escape hatch.
    #[inline]
    #[allow(clippy::needless_pass_by_value)] // owned azul C-ABI value taken by value (FFI ownership-transfer convention)
    #[must_use]
    pub fn create_optgroup(label: AzString, aria: SmallAriaInfo) -> Self {
        Self::create_optgroup_no_a11y(label).with_accessibility_info(aria.to_full_info())
    }
    /// Creates a quotation element.
    ///
    /// **Accessibility**: Represents an inline quotation.
    #[inline]
    #[must_use]
    pub const fn create_q() -> Self {
        Self {
            root: NodeData::create_node(NodeType::Q),
            children: DomVec::from_const_slice(&[]),
            css: azul_css::css::CssVec::from_const_slice(&[]),
            estimated_total_children: 0,
        }
    }
    /// Creates an empty acronym element.
    ///
    /// **Note**: Deprecated in HTML5. Consider using `create_abbr()` instead.
    #[inline]
    #[must_use]
    pub const fn create_acronym() -> Self {
        Self {
            root: NodeData::create_node(NodeType::Acronym),
            children: DomVec::from_const_slice(&[]),
            css: azul_css::css::CssVec::from_const_slice(&[]),
            estimated_total_children: 0,
        }
    }
    /// Creates an acronym element with text.
    ///
    /// **Note**: Deprecated in HTML5. Consider using `create_abbr_with_title()` instead.
    #[inline]
    pub fn create_acronym_with_text<S: Into<AzString>>(text: S) -> Self {
        Self::create_acronym().with_child(Self::create_text_do_not_use_without_block_level_wrapper(
            text,
        ))
    }
    /// Creates a menu element without accessibility information.
    ///
    /// Prefer [`Dom::create_menu`] so that the menu's purpose is announced.
    #[inline]
    #[must_use]
    pub const fn create_menu_no_a11y() -> Self {
        Self {
            root: NodeData::create_node(NodeType::Menu),
            children: DomVec::from_const_slice(&[]),
            css: azul_css::css::CssVec::from_const_slice(&[]),
            estimated_total_children: 0,
        }
    }
    /// Creates a menu element with accessibility information.
    ///
    /// **Accessibility**: Represents a list of commands. Similar to `<ul>` but semantic for
    /// toolbars/menus.
    ///
    /// Use [`Dom::create_menu_no_a11y`] only as a deliberate escape hatch.
    #[inline]
    #[allow(clippy::needless_pass_by_value)] // owned azul C-ABI value taken by value (FFI ownership-transfer convention)
    #[must_use]
    pub fn create_menu(aria: SmallAriaInfo) -> Self {
        Self::create_menu_no_a11y().with_accessibility_info(aria.to_full_info())
    }
    /// Creates an empty menu item element without accessibility information.
    ///
    /// Prefer [`Dom::create_menuitem`] so that the menu item's purpose is announced.
    #[inline]
    #[must_use]
    pub const fn create_menuitem_no_a11y() -> Self {
        Self {
            root: NodeData::create_node(NodeType::MenuItem),
            children: DomVec::from_const_slice(&[]),
            css: azul_css::css::CssVec::from_const_slice(&[]),
            estimated_total_children: 0,
        }
    }
    /// Creates an empty menu item element with accessibility information.
    ///
    /// **Accessibility**: Represents a command in a menu. Use with appropriate role/aria
    /// attributes.
    ///
    /// Use [`Dom::create_menuitem_no_a11y`] only as a deliberate escape hatch.
    #[inline]
    #[allow(clippy::needless_pass_by_value)] // owned azul C-ABI value taken by value (FFI ownership-transfer convention)
    #[must_use]
    pub fn create_menuitem(aria: SmallAriaInfo) -> Self {
        Self::create_menuitem_no_a11y().with_accessibility_info(aria.to_full_info())
    }
    /// Creates a menu item element with text but without accessibility information.
    ///
    /// Prefer [`Dom::create_menuitem_with_text`] so that screen readers get a
    /// distinct accessible name in addition to the visible text.
    #[inline]
    pub fn create_menuitem_with_text_no_a11y<S: Into<AzString>>(text: S) -> Self {
        Self::create_menuitem_no_a11y().with_child(
            Self::create_text_do_not_use_without_block_level_wrapper(text),
        )
    }
    /// Creates a menu item element with text and accessibility information.
    ///
    /// **Accessibility**: Represents a command in a menu. Use with appropriate role/aria
    /// attributes.
    ///
    /// Use [`Dom::create_menuitem_with_text_no_a11y`] only as a deliberate escape hatch.
    #[inline]
    #[allow(clippy::needless_pass_by_value)] // owned azul C-ABI value taken by value (FFI
                                             // ownership-transfer convention)
    pub fn create_menuitem_with_text<S: Into<AzString>>(text: S, aria: SmallAriaInfo) -> Self {
        Self::create_menuitem_with_text_no_a11y(text).with_accessibility_info(aria.to_full_info())
    }
    /// Creates an output element without accessibility information.
    ///
    /// Prefer [`Dom::create_output`] so that screen readers can announce the
    /// computed value's purpose.
    #[inline]
    #[must_use]
    pub const fn create_output_no_a11y() -> Self {
        Self {
            root: NodeData::create_node(NodeType::Output),
            children: DomVec::from_const_slice(&[]),
            css: azul_css::css::CssVec::from_const_slice(&[]),
            estimated_total_children: 0,
        }
    }
    /// Creates an output element with accessibility information.
    ///
    /// **Accessibility**: Represents the result of a calculation or user action.
    /// Use `for` attribute to associate with input elements. Screen readers announce updates.
    ///
    /// Use [`Dom::create_output_no_a11y`] only as a deliberate escape hatch.
    #[inline]
    #[allow(clippy::needless_pass_by_value)] // owned azul C-ABI value taken by value (FFI ownership-transfer convention)
    #[must_use]
    pub fn create_output(aria: SmallAriaInfo) -> Self {
        Self::create_output_no_a11y().with_accessibility_info(aria.to_full_info())
    }
    /// Creates a progress indicator element without accessibility information.
    ///
    /// Prefer [`Dom::create_progress`] so that the task being measured is announced.
    ///
    /// **Parameters:**
    /// - `value`: Current progress value
    /// - `max`: Maximum value
    #[inline]
    #[must_use]
    pub fn create_progress_no_a11y(value: f32, max: f32) -> Self {
        Self::create_node(NodeType::Progress)
            .with_attribute(AttributeType::Custom(AttributeNameValue {
                attr_name: "value".into(),
                value: value.to_string().into(),
            }))
            .with_attribute(AttributeType::Custom(AttributeNameValue {
                attr_name: "max".into(),
                value: max.to_string().into(),
            }))
    }
    /// Creates a progress indicator element with accessibility information.
    ///
    /// **Accessibility**: Represents task progress. Screen readers announce progress
    /// percentage. The `aria` value carries the label, current value, max, and an
    /// indeterminate flag for spinners with no known endpoint.
    ///
    /// Use [`Dom::create_progress_no_a11y`] only as a deliberate escape hatch.
    #[inline]
    #[allow(clippy::needless_pass_by_value)] // owned azul C-ABI value taken by value (FFI ownership-transfer convention)
    #[must_use]
    pub fn create_progress(aria: ProgressAriaInfo) -> Self {
        let mut node = Self::create_node(NodeType::Progress);
        if !aria.indeterminate {
            if let azul_css::OptionF32::Some(v) = aria.current_value {
                node = node.with_attribute(AttributeType::Custom(AttributeNameValue {
                    attr_name: "value".into(),
                    value: v.to_string().into(),
                }));
            }
        }
        if let azul_css::OptionF32::Some(m) = aria.max {
            node = node.with_attribute(AttributeType::Custom(AttributeNameValue {
                attr_name: "max".into(),
                value: m.to_string().into(),
            }));
        }
        node.with_accessibility_info(aria.to_full_info())
    }
    /// Creates a meter gauge element without accessibility information.
    ///
    /// Prefer [`Dom::create_meter`] so that the measurement's purpose is announced.
    ///
    /// **Parameters:**
    /// - `value`: Current meter value
    /// - `min`: Minimum value
    /// - `max`: Maximum value
    #[inline]
    #[must_use]
    pub fn create_meter_no_a11y(value: f32, min: f32, max: f32) -> Self {
        Self::create_node(NodeType::Meter)
            .with_attribute(AttributeType::Custom(AttributeNameValue {
                attr_name: "value".into(),
                value: value.to_string().into(),
            }))
            .with_attribute(AttributeType::Custom(AttributeNameValue {
                attr_name: "min".into(),
                value: min.to_string().into(),
            }))
            .with_attribute(AttributeType::Custom(AttributeNameValue {
                attr_name: "max".into(),
                value: max.to_string().into(),
            }))
    }
    /// Creates a meter gauge element with accessibility information.
    ///
    /// **Accessibility**: Represents a scalar measurement within a known range.
    /// Screen readers announce the measurement. The `aria` value carries the
    /// label plus value/min/max/low/high/optimum metadata.
    ///
    /// Use [`Dom::create_meter_no_a11y`] only as a deliberate escape hatch.
    #[inline]
    #[allow(clippy::needless_pass_by_value)] // owned azul C-ABI value taken by value (FFI ownership-transfer convention)
    #[must_use]
    pub fn create_meter(aria: MeterAriaInfo) -> Self {
        let mut node = Self::create_meter_no_a11y(aria.current_value, aria.min, aria.max);
        if let azul_css::OptionF32::Some(v) = aria.low {
            node = node.with_attribute(AttributeType::Custom(AttributeNameValue {
                attr_name: "low".into(),
                value: v.to_string().into(),
            }));
        }
        if let azul_css::OptionF32::Some(v) = aria.high {
            node = node.with_attribute(AttributeType::Custom(AttributeNameValue {
                attr_name: "high".into(),
                value: v.to_string().into(),
            }));
        }
        if let azul_css::OptionF32::Some(v) = aria.optimum {
            node = node.with_attribute(AttributeType::Custom(AttributeNameValue {
                attr_name: "optimum".into(),
                value: v.to_string().into(),
            }));
        }
        node.with_accessibility_info(aria.to_full_info())
    }
    /// Creates a datalist element without accessibility information.
    ///
    /// Prefer [`Dom::create_datalist`] so that the suggestion list's purpose is announced.
    #[inline]
    #[must_use]
    pub const fn create_datalist_no_a11y() -> Self {
        Self {
            root: NodeData::create_node(NodeType::DataList),
            children: DomVec::from_const_slice(&[]),
            css: azul_css::css::CssVec::from_const_slice(&[]),
            estimated_total_children: 0,
        }
    }
    /// Creates a datalist element with accessibility information.
    ///
    /// **Accessibility**: Provides autocomplete options for inputs.
    /// Associate with input using `list` attribute. Screen readers announce available options.
    ///
    /// Use [`Dom::create_datalist_no_a11y`] only as a deliberate escape hatch.
    #[inline]
    #[allow(clippy::needless_pass_by_value)] // owned azul C-ABI value taken by value (FFI ownership-transfer convention)
    #[must_use]
    pub fn create_datalist(aria: SmallAriaInfo) -> Self {
        Self::create_datalist_no_a11y().with_accessibility_info(aria.to_full_info())
    }
    // Embedded Content Elements
    /// Creates a canvas element for graphics without accessibility information.
    ///
    /// Prefer [`Dom::create_canvas`] so that the canvas's purpose is announced; canvas
    /// content is otherwise opaque to assistive technologies.
    #[inline]
    #[must_use]
    pub const fn create_canvas_no_a11y() -> Self {
        Self {
            root: NodeData::create_node(NodeType::Canvas),
            children: DomVec::from_const_slice(&[]),
            css: azul_css::css::CssVec::from_const_slice(&[]),
            estimated_total_children: 0,
        }
    }
    /// Creates a canvas element for graphics with accessibility information.
    ///
    /// **Accessibility**: Canvas content is not accessible by default.
    /// Always provide fallback content as children and/or detailed aria-label.
    /// Consider using SVG for accessible graphics when possible.
    ///
    /// Use [`Dom::create_canvas_no_a11y`] only as a deliberate escape hatch.
    #[inline]
    #[allow(clippy::needless_pass_by_value)] // owned azul C-ABI value taken by value (FFI ownership-transfer convention)
    #[must_use]
    pub fn create_canvas(aria: SmallAriaInfo) -> Self {
        Self::create_canvas_no_a11y().with_accessibility_info(aria.to_full_info())
    }
    /// Creates an object element for embedded content.
    ///
    /// **Accessibility**: Provide fallback content as children. Use aria-label to describe content.
    #[inline]
    #[must_use]
    pub const fn create_object() -> Self {
        Self {
            root: NodeData::create_node(NodeType::Object),
            children: DomVec::from_const_slice(&[]),
            css: azul_css::css::CssVec::from_const_slice(&[]),
            estimated_total_children: 0,
        }
    }
    /// Creates a param element for object parameters.
    ///
    /// **Parameters:**
    /// - `name`: Parameter name
    /// - `value`: Parameter value
    #[inline]
    #[must_use]
    pub fn create_param(name: AzString, value: AzString) -> Self {
        Self::create_node(NodeType::Param)
            .with_attribute(AttributeType::Name(name))
            .with_attribute(AttributeType::Value(value))
    }
    /// Creates an embed element.
    ///
    /// **Accessibility**: Provide alternative content or link. Use aria-label to describe embedded
    /// content.
    #[inline]
    #[must_use]
    pub const fn create_embed() -> Self {
        Self {
            root: NodeData::create_node(NodeType::Embed),
            children: DomVec::from_const_slice(&[]),
            css: azul_css::css::CssVec::from_const_slice(&[]),
            estimated_total_children: 0,
        }
    }
    /// Creates an audio element without accessibility information.
    ///
    /// Prefer [`Dom::create_audio`] so that screen readers announce the audio's purpose.
    #[inline]
    #[must_use]
    pub const fn create_audio_no_a11y() -> Self {
        Self {
            root: NodeData::create_node(NodeType::Audio),
            children: DomVec::from_const_slice(&[]),
            css: azul_css::css::CssVec::from_const_slice(&[]),
            estimated_total_children: 0,
        }
    }
    /// Creates an audio element with accessibility information.
    ///
    /// **Accessibility**: Always provide controls. Use `<track>` for captions/subtitles.
    /// Provide fallback text for unsupported browsers.
    ///
    /// Use [`Dom::create_audio_no_a11y`] only as a deliberate escape hatch.
    #[inline]
    #[allow(clippy::needless_pass_by_value)] // owned azul C-ABI value taken by value (FFI ownership-transfer convention)
    #[must_use]
    pub fn create_audio(aria: SmallAriaInfo) -> Self {
        Self::create_audio_no_a11y().with_accessibility_info(aria.to_full_info())
    }
    /// Creates a video element without accessibility information.
    ///
    /// Prefer [`Dom::create_video`] so that screen readers announce the video's purpose.
    #[inline]
    #[must_use]
    pub const fn create_video_no_a11y() -> Self {
        Self {
            root: NodeData::create_node(NodeType::Video),
            children: DomVec::from_const_slice(&[]),
            css: azul_css::css::CssVec::from_const_slice(&[]),
            estimated_total_children: 0,
        }
    }
    /// Creates a video element with accessibility information.
    ///
    /// **Accessibility**: Always provide controls. Use `<track>` for
    /// captions/subtitles/descriptions. Provide fallback text. Consider providing transcript.
    ///
    /// Use [`Dom::create_video_no_a11y`] only as a deliberate escape hatch.
    #[inline]
    #[allow(clippy::needless_pass_by_value)] // owned azul C-ABI value taken by value (FFI ownership-transfer convention)
    #[must_use]
    pub fn create_video(aria: SmallAriaInfo) -> Self {
        Self::create_video_no_a11y().with_accessibility_info(aria.to_full_info())
    }
    /// Creates a source element for media.
    ///
    /// **Parameters:**
    /// - `src`: Media source URL
    /// - `media_type`: MIME type (e.g., "video/mp4", "audio/ogg")
    #[inline]
    #[must_use]
    pub fn create_source(src: AzString, media_type: AzString) -> Self {
        Self::create_node(NodeType::Source)
            .with_attribute(AttributeType::Src(src))
            .with_attribute(AttributeType::Custom(AttributeNameValue {
                attr_name: "type".into(),
                value: media_type,
            }))
    }
    /// Creates a track element for media captions/subtitles.
    ///
    /// **Accessibility**: Essential for deaf/hard-of-hearing users and non-native speakers.
    /// Use `kind` (subtitles/captions/descriptions), `srclang`, and `label` attributes.
    ///
    /// **Parameters:**
    /// - `src`: Track file URL (`WebVTT` format)
    /// - `kind`: Track kind ("subtitles", "captions", "descriptions", "chapters", "metadata")
    #[inline]
    #[must_use]
    pub fn create_track(src: AzString, kind: AzString) -> Self {
        Self::create_node(NodeType::Track)
            .with_attribute(AttributeType::Src(src))
            .with_attribute(AttributeType::Custom(AttributeNameValue {
                attr_name: "kind".into(),
                value: kind,
            }))
    }
    /// Creates a map element for image maps.
    ///
    /// **Accessibility**: Provide text alternatives. Ensure all areas have alt text.
    #[inline]
    #[must_use]
    pub const fn create_map() -> Self {
        Self {
            root: NodeData::create_node(NodeType::Map),
            children: DomVec::from_const_slice(&[]),
            css: azul_css::css::CssVec::from_const_slice(&[]),
            estimated_total_children: 0,
        }
    }
    /// Creates an area element for image map regions without accessibility information.
    ///
    /// Prefer [`Dom::create_area`] so that screen readers can announce the region's purpose.
    #[inline]
    #[must_use]
    pub const fn create_area_no_a11y() -> Self {
        Self {
            root: NodeData::create_node(NodeType::Area),
            children: DomVec::from_const_slice(&[]),
            css: azul_css::css::CssVec::from_const_slice(&[]),
            estimated_total_children: 0,
        }
    }
    /// Creates an area element for image map regions with accessibility information.
    ///
    /// **Accessibility**: Always provide `alt` text describing the region/link purpose.
    /// Keyboard users should be able to navigate areas.
    ///
    /// Use [`Dom::create_area_no_a11y`] only as a deliberate escape hatch.
    #[inline]
    #[allow(clippy::needless_pass_by_value)] // owned azul C-ABI value taken by value (FFI ownership-transfer convention)
    #[must_use]
    pub fn create_area(aria: SmallAriaInfo) -> Self {
        Self::create_area_no_a11y().with_accessibility_info(aria.to_full_info())
    }
    // Metadata Elements
    /// Creates an empty title element for document title.
    ///
    /// **Accessibility**: Required for all pages. Screen readers announce this first.
    #[inline]
    #[must_use]
    pub fn create_title() -> Self {
        Self::create_node(NodeType::Title)
    }
    /// Creates a title element for document title with text.
    ///
    /// **Accessibility**: Required for all pages. Screen readers announce this first.
    /// Should be unique and descriptive. Keep under 60 characters.
    #[inline]
    pub fn create_title_with_text<S: Into<AzString>>(text: S) -> Self {
        Self::create_title().with_child(Self::create_text_do_not_use_without_block_level_wrapper(
            text,
        ))
    }
    /// Creates a meta element.
    ///
    /// **Accessibility**: Use for charset, viewport, description. Crucial for proper text display.
    #[inline]
    #[must_use]
    pub const fn create_meta() -> Self {
        Self {
            root: NodeData::create_node(NodeType::Meta),
            children: DomVec::from_const_slice(&[]),
            css: azul_css::css::CssVec::from_const_slice(&[]),
            estimated_total_children: 0,
        }
    }
    /// Creates a link element for external resources.
    ///
    /// **Accessibility**: Use for stylesheets, icons, alternate versions.
    /// Provide meaningful `title` attribute for alternate stylesheets.
    #[inline]
    #[must_use]
    pub const fn create_link() -> Self {
        Self {
            root: NodeData::create_node(NodeType::Link),
            children: DomVec::from_const_slice(&[]),
            css: azul_css::css::CssVec::from_const_slice(&[]),
            estimated_total_children: 0,
        }
    }
    /// Creates a script element.
    ///
    /// **Accessibility**: Ensure scripted content is accessible.
    /// Provide noscript fallbacks for critical functionality.
    #[inline]
    #[must_use]
    pub const fn create_script() -> Self {
        Self {
            root: NodeData::create_node(NodeType::Script),
            children: DomVec::from_const_slice(&[]),
            css: azul_css::css::CssVec::from_const_slice(&[]),
            estimated_total_children: 0,
        }
    }
    /// Creates an empty style element for embedded CSS.
    ///
    /// **Note**: In Azul, use `.with_css()` instead for styling.
    /// This creates a `<style>` HTML element for embedded stylesheets.
    #[inline]
    #[must_use]
    pub const fn create_style() -> Self {
        Self {
            root: NodeData::create_node(NodeType::Style),
            children: DomVec::from_const_slice(&[]),
            css: azul_css::css::CssVec::from_const_slice(&[]),
            estimated_total_children: 0,
        }
    }
    /// Creates a style element for embedded CSS with the given stylesheet text.
    ///
    /// **Note**: In Azul, use `.with_css()` instead for styling.
    /// This creates a `<style>` HTML element for embedded stylesheets.
    #[inline]
    pub fn create_style_with_text<S: Into<AzString>>(text: S) -> Self {
        Self::create_style().with_child(Self::create_text_do_not_use_without_block_level_wrapper(
            text,
        ))
    }
    /// Creates a base element for document base URL.
    ///
    /// **Parameters:**
    /// - `href`: Base URL for relative URLs in the document
    #[inline]
    #[must_use]
    pub fn create_base(href: AzString) -> Self {
        Self::create_node(NodeType::Base).with_attribute(AttributeType::Href(href))
    }
    // Advanced Constructors with Parameters
    /// Creates a table header cell with scope.
    ///
    /// **Parameters:**
    /// - `scope`: "col", "row", "colgroup", or "rowgroup"
    /// - `text`: Header text
    ///
    /// **Accessibility**: The scope attribute is crucial for associating headers with data cells.
    #[inline]
    #[must_use]
    pub fn create_th_with_scope(scope: AzString, text: AzString) -> Self {
        Self::create_node(NodeType::Th)
            .with_attribute(AttributeType::Scope(scope))
            .with_child(Self::create_text_do_not_use_without_block_level_wrapper(
                text,
            ))
    }
    /// Creates a table data cell with text.
    ///
    /// **Parameters:**
    /// - `text`: Cell content
    #[inline]
    pub fn create_td_with_text<S: Into<AzString>>(text: S) -> Self {
        Self::create_td().with_child(Self::create_text_do_not_use_without_block_level_wrapper(
            text,
        ))
    }
    /// Creates a table header cell with text.
    ///
    /// **Parameters:**
    /// - `text`: Header text
    #[inline]
    pub fn create_th_with_text<S: Into<AzString>>(text: S) -> Self {
        Self::create_th().with_child(Self::create_text_do_not_use_without_block_level_wrapper(
            text,
        ))
    }
    /// Creates a list item with text.
    ///
    /// **Parameters:**
    /// - `text`: List item content
    #[inline]
9
    pub fn create_li_with_text<S: Into<AzString>>(text: S) -> Self {
9
        Self::create_li().with_child(Self::create_text_do_not_use_without_block_level_wrapper(
9
            text,
        ))
9
    }
    /// Creates a paragraph with text.
    ///
    /// **Parameters:**
    /// - `text`: Paragraph content
    #[inline]
116
    pub fn create_p_with_text<S: Into<AzString>>(text: S) -> Self {
116
        Self::create_p().with_child(Self::create_text_do_not_use_without_block_level_wrapper(
116
            text,
        ))
116
    }
    /// Creates a generic block container (div) with text.
    ///
    /// **Parameters:**
    /// - `text`: Div content
    #[inline]
1
    pub fn create_div_with_text<S: Into<AzString>>(text: S) -> Self {
1
        Self::create_div().with_child(Self::create_text_do_not_use_without_block_level_wrapper(
1
            text,
        ))
1
    }
    // Accessibility-Aware Constructors
    // These constructors require explicit accessibility information.
    // Use the `*_no_a11y` variants only as a deliberate escape hatch.
    /// Creates a button with text content and accessibility information.
    ///
    /// Use [`Dom::create_button_no_a11y`] to skip the accessibility information.
    ///
    /// **Parameters:**
    /// - `text`: The visible button text
    /// - `aria`: Accessibility information (role, description, etc.)
    #[inline]
    #[allow(clippy::needless_pass_by_value)] // owned azul C-ABI value taken by value (FFI
                                             // ownership-transfer convention)
2
    pub fn create_button<S: Into<AzString>>(text: S, aria: SmallAriaInfo) -> Self {
2
        let mut btn = Self::create_button_no_a11y(text.into());
2
        btn.root.set_accessibility_info(aria.to_full_info());
2
        btn
2
    }
    /// Creates a link (anchor) with href, text, and accessibility information.
    ///
    /// Use [`Dom::create_a_no_a11y`] to skip the accessibility information (e.g. for
    /// image-only links whose accessible name comes from an `<img alt>`).
    ///
    /// **Parameters:**
    /// - `href`: The link destination
    /// - `text`: The visible link text
    /// - `aria`: Accessibility information (expanded description, etc.)
    #[inline]
    #[allow(clippy::needless_pass_by_value)] // owned azul C-ABI value taken by value (FFI
                                             // ownership-transfer convention)
1
    pub fn create_a<S1: Into<AzString>, S2: Into<AzString>>(
1
        href: S1,
1
        text: S2,
1
        aria: SmallAriaInfo,
1
    ) -> Self {
1
        let mut link = Self::create_a_no_a11y(href.into(), OptionString::Some(text.into()));
1
        link.root.set_accessibility_info(aria.to_full_info());
1
        link
1
    }
    /// Creates an input element with type, name, and accessibility information.
    ///
    /// Use [`Dom::create_input_no_a11y`] to skip the accessibility information.
    ///
    /// **Parameters:**
    /// - `input_type`: The input type (text, password, email, etc.)
    /// - `name`: The form field name
    /// - `label`: Base accessibility label
    /// - `aria`: Additional accessibility information (description, etc.)
    #[inline]
    #[allow(clippy::needless_pass_by_value)] // owned azul C-ABI value taken by value (FFI
                                             // ownership-transfer convention)
1
    pub fn create_input<S1: Into<AzString>, S2: Into<AzString>, S3: Into<AzString>>(
1
        input_type: S1,
1
        name: S2,
1
        label: S3,
1
        aria: SmallAriaInfo,
1
    ) -> Self {
1
        let mut input = Self::create_input_no_a11y(input_type.into(), name.into(), label.into());
1
        input.root.set_accessibility_info(aria.to_full_info());
1
        input
1
    }
    /// Creates a textarea with name and accessibility information.
    ///
    /// Use [`Dom::create_textarea_no_a11y`] to skip the accessibility information.
    ///
    /// **Parameters:**
    /// - `name`: The form field name
    /// - `label`: Base accessibility label
    /// - `aria`: Additional accessibility information (description, etc.)
    #[inline]
    #[allow(clippy::needless_pass_by_value)] // owned azul C-ABI value taken by value (FFI
                                             // ownership-transfer convention)
1
    pub fn create_textarea<S1: Into<AzString>, S2: Into<AzString>>(
1
        name: S1,
1
        label: S2,
1
        aria: SmallAriaInfo,
1
    ) -> Self {
1
        let mut textarea = Self::create_textarea_no_a11y(name.into(), label.into());
1
        textarea.root.set_accessibility_info(aria.to_full_info());
1
        textarea
1
    }
    /// Creates a select dropdown with name and accessibility information.
    ///
    /// Use [`Dom::create_select_no_a11y`] to skip the accessibility information.
    ///
    /// **Parameters:**
    /// - `name`: The form field name
    /// - `label`: Base accessibility label
    /// - `aria`: Additional accessibility information (description, etc.)
    #[inline]
    #[allow(clippy::needless_pass_by_value)] // owned azul C-ABI value taken by value (FFI
                                             // ownership-transfer convention)
1
    pub fn create_select<S1: Into<AzString>, S2: Into<AzString>>(
1
        name: S1,
1
        label: S2,
1
        aria: SmallAriaInfo,
1
    ) -> Self {
1
        let mut select = Self::create_select_no_a11y(name.into(), label.into());
1
        select.root.set_accessibility_info(aria.to_full_info());
1
        select
1
    }
    /// Creates a table with caption and accessibility information.
    ///
    /// Use [`Dom::create_table_no_a11y`] to skip the caption and accessibility
    /// information.
    ///
    /// **Parameters:**
    /// - `caption`: Table caption (visible title)
    /// - `aria`: Accessibility information describing table purpose
    #[inline]
    #[allow(clippy::needless_pass_by_value)] // owned azul C-ABI value taken by value (FFI
                                             // ownership-transfer convention)
1
    pub fn create_table<S: Into<AzString>>(caption: S, aria: SmallAriaInfo) -> Self {
1
        let mut table = Self::create_table_no_a11y().with_child(Self::create_caption().with_child(
1
            Self::create_text_do_not_use_without_block_level_wrapper(caption),
        ));
1
        table.root.set_accessibility_info(aria.to_full_info());
1
        table
1
    }
    /// Creates a label for a form control with additional accessibility information.
    ///
    /// Use [`Dom::create_label_no_a11y`] to skip the accessibility information.
    ///
    /// **Parameters:**
    /// - `for_id`: The ID of the associated form control
    /// - `text`: The visible label text
    /// - `aria`: Additional accessibility information (description, etc.)
    #[inline]
    #[allow(clippy::needless_pass_by_value)] // owned azul C-ABI value taken by value (FFI
                                             // ownership-transfer convention)
1
    pub fn create_label<S1: Into<AzString>, S2: Into<AzString>>(
1
        for_id: S1,
1
        text: S2,
1
        aria: SmallAriaInfo,
1
    ) -> Self {
1
        let mut label = Self::create_label_no_a11y(for_id.into(), text.into());
1
        label.root.set_accessibility_info(aria.to_full_info());
1
        label
1
    }
    /// Parse XML/XHTML string into a DOM
    ///
    /// This is a simple wrapper that parses XML and converts it to a DOM.
    /// For now, it just creates a text node with the content since full XML parsing
    /// requires the xml feature and more complex parsing logic.
    #[cfg(feature = "xml")]
    pub fn from_xml<S: AsRef<str>>(xml_str: S) -> Self {
        // TODO: Implement full XML parsing
        // For now, just create a text node showing that XML was loaded
        Self::create_text_do_not_use_without_block_level_wrapper(format!(
            "XML content loaded ({} bytes)",
            xml_str.as_ref().len()
        ))
    }
    /// Parse XML/XHTML string into a DOM (fallback without xml feature)
    #[cfg(not(feature = "xml"))]
    pub fn from_xml<S: AsRef<str>>(xml_str: S) -> Self {
        Self::create_text_do_not_use_without_block_level_wrapper(format!(
            "XML parsing requires 'xml' feature ({} bytes)",
            xml_str.as_ref().len()
        ))
    }
    // Swaps `self` with a default DOM, necessary for builder methods
    #[inline]
    #[must_use]
1
    pub const fn swap_with_default(&mut self) -> Self {
1
        let mut s = Self {
1
            root: NodeData::create_div(),
1
            children: DomVec::from_const_slice(&[]),
1
            css: azul_css::css::CssVec::from_const_slice(&[]),
1
            estimated_total_children: 0,
1
        };
1
        mem::swap(&mut s, self);
1
        s
1
    }
    /// AUDIT: recompute the authoritative descendant count (1 per descendant)
    /// from `children`, without mutating anything. Used by the debug-only
    /// consistency assertions in the builder methods so a stale
    /// `estimated_total_children` (from direct `children` mutation) is caught in
    /// tests before it can under-allocate the arena in
    /// `convert_dom_into_compact_dom`.
    #[must_use]
7991
    pub fn recompute_estimated_total_children(&self) -> usize {
7991
        self.children
7991
            .iter()
7991
            .map(|c| c.recompute_estimated_total_children() + 1)
7991
            .sum()
7991
    }
    #[inline]
1022349
    pub fn add_child(&mut self, child: Self) {
        // AUDIT: cheap ONE-LEVEL consistency check (O(child.children), not the
        // full O(subtree) recompute — `add_child` is a per-child hot path, so a
        // recursive assert would make debug DOM construction O(n^2)). Assuming
        // grandchildren are already consistent (they are when the tree is built
        // bottom-up), this catches a direct mutation of `child.children` that
        // skipped `fixup_children_estimated()`.
1022349
        debug_assert_eq!(
            child.estimated_total_children,
            child
                .children
                .iter()
                .map(|c| c.estimated_total_children + 1)
                .sum::<usize>(),
            "Dom.estimated_total_children desynced for added child; call \
             fixup_children_estimated() after mutating `children` directly",
        );
1022349
        let estimated = child.estimated_total_children;
1022349
        let mut v: DomVec = Vec::new().into();
1022349
        mem::swap(&mut v, &mut self.children);
1022349
        let mut v = v.into_library_owned_vec();
1022349
        v.push(child);
1022349
        self.children = v.into();
1022349
        self.estimated_total_children += estimated + 1;
1022349
    }
    #[inline]
443438
    pub fn set_children(&mut self, children: DomVec) {
        // AUDIT: one-level check per child (see `add_child`) — verifies each
        // child's own cached estimate is internally consistent before we trust
        // it, without an O(subtree) recompute.
443438
        debug_assert!(
            children.iter().all(|c| c.estimated_total_children
                == c.children
                    .iter()
                    .map(|g| g.estimated_total_children + 1)
                    .sum::<usize>()),
            "Dom.estimated_total_children desynced in set_children; a child's own estimate was \
             stale — call fixup_children_estimated() first",
        );
443438
        let children_estimated = children
443438
            .iter()
506132
            .map(|s| s.estimated_total_children + 1)
443438
            .sum();
443438
        self.children = children;
443438
        self.estimated_total_children = children_estimated;
443438
    }
    #[must_use]
    pub fn copy_except_for_root(&mut self) -> Self {
        Self {
            root: self.root.copy_special(),
            children: self.children.clone(),
            css: self.css.clone(),
            estimated_total_children: self.estimated_total_children,
        }
    }
    #[must_use]
24
    pub const fn node_count(&self) -> usize {
        // `saturating_add`, not `+`. `estimated_total_children` is a PUBLIC
        // field, so a caller can put `usize::MAX` in it. With `+` that is a
        // panic in debug and a silent wrap to **0** in release — and 0 is the
        // worst available answer, because it reads as "this DOM is empty" and
        // every caller believes it. Saturating gives the same result for every
        // sane value and a defined, obviously-wrong-way-up one otherwise.
24
        self.estimated_total_children.saturating_add(1)
24
    }
    /// Push a parsed `Css` onto this Dom subtree's `.css` list (the
    /// `@scope`-like mechanism that `with_css(&str)` also feeds — a string
    /// parses to a `Css` and lands here). The cascade selector-matches every
    /// entry against the subtree; later pushes win at equal specificity.
    /// This is the low-level Css-struct entry point; prefer `with_css(&str)`.
571390
    pub fn add_component_css(&mut self, css: azul_css::css::Css) {
571390
        let mut v = Vec::new().into();
571390
        mem::swap(&mut v, &mut self.css);
571390
        let mut v: Vec<azul_css::css::Css> = v.into_library_owned_vec();
571390
        v.push(css);
571390
        self.css = v.into();
571390
    }
    /// Builder form of [`Self::add_component_css`]: attach a parsed
    /// stylesheet and hand the `Dom` back, so a component builds in one
    /// expression. `with_css(&str)` is the same thing for a string that still
    /// has to be parsed.
    #[must_use]
491112
    pub fn with_component_css(mut self, css: azul_css::css::Css) -> Self {
491112
        self.add_component_css(css);
491112
        self
491112
    }
    /// Replace the subtree's entire component-level CSS list with the
    /// provided one. Use `add_component_css` / `with_component_css` for
    /// stacking; this is the wholesale-replace form.
1
    pub fn set_component_css(&mut self, css: azul_css::css::CssVec) {
1
        self.css = css;
1
    }
    #[inline]
    #[must_use]
443398
    pub fn with_children(mut self, children: DomVec) -> Self {
443398
        self.set_children(children);
443398
        self
443398
    }
    #[inline]
    #[must_use]
1016245
    pub fn with_child(mut self, child: Self) -> Self {
1016245
        self.add_child(child);
1016245
        self
1016245
    }
    #[inline]
    #[must_use]
    pub fn with_node_type(mut self, node_type: NodeType) -> Self {
        self.root.set_node_type(node_type);
        self
    }
    #[inline]
    #[must_use]
4
    pub fn with_id(mut self, id: AzString) -> Self {
4
        self.root.add_id(id);
4
        self
4
    }
    #[inline]
    #[must_use]
651
    pub fn with_class(mut self, class: AzString) -> Self {
651
        self.root.add_class(class);
651
        self
651
    }
    #[inline]
    #[must_use]
2466
    pub fn with_callback<C: Into<CoreCallback>>(
2466
        mut self,
2466
        event: EventFilter,
2466
        data: RefAny,
2466
        callback: C,
2466
    ) -> Self {
2466
        self.root.add_callback(event, data, callback);
2466
        self
2466
    }
    /// Add a CSS property with optional conditions (hover, focus, active, etc.)
    #[inline]
    #[must_use]
    pub fn with_css_property(mut self, prop: CssPropertyWithConditions) -> Self {
        self.root.add_css_property(prop);
        self
    }
    /// Add a CSS property with optional conditions (hover, focus, active, etc.)
    #[inline]
    pub fn add_css_property(&mut self, prop: CssPropertyWithConditions) {
        self.root.add_css_property(prop);
    }
    #[inline]
    pub fn add_class(&mut self, class: AzString) {
        self.root.add_class(class);
    }
    #[inline]
    pub fn add_callback<C: Into<CoreCallback>>(
        &mut self,
        event: EventFilter,
        data: RefAny,
        callback: C,
    ) {
        self.root.add_callback(event, data, callback);
    }
    #[inline]
162
    pub const fn set_tab_index(&mut self, tab_index: TabIndex) {
162
        self.root.set_tab_index(tab_index);
162
    }
    #[inline]
645
    pub const fn set_contenteditable(&mut self, contenteditable: bool) {
645
        self.root.set_contenteditable(contenteditable);
645
    }
    #[inline]
    #[must_use]
303644
    pub const fn with_tab_index(mut self, tab_index: TabIndex) -> Self {
303644
        self.root.set_tab_index(tab_index);
303644
        self
303644
    }
    #[inline]
    #[must_use]
10824
    pub const fn with_contenteditable(mut self, contenteditable: bool) -> Self {
10824
        self.root.set_contenteditable(contenteditable);
10824
        self
10824
    }
    #[inline]
    #[must_use]
30165
    pub fn with_dataset(mut self, data: OptionRefAny) -> Self {
30165
        self.root.set_dataset(data);
30165
        self
30165
    }
    /// Setter form of [`Self::with_dataset`].
    #[inline]
    pub fn set_dataset(&mut self, data: OptionRefAny) {
        self.root.set_dataset(data);
    }
    /// Stamp an app-chosen marker string on the root node, resolvable to a
    /// `(DomId, NodeId)` via `CallbackInfo::get_node_id_by_marker` — the
    /// clean way for one widget's callback to find another widget without
    /// knowing its internals. Invisible to CSS matching, unlike an id.
    #[inline]
    #[must_use]
2057
    pub fn with_marker(mut self, marker: OptionString) -> Self {
2057
        self.root.set_marker(marker);
2057
        self
2057
    }
    /// Setter form of [`Self::with_marker`].
    #[inline]
    pub fn set_marker(&mut self, marker: OptionString) {
        self.root.set_marker(marker);
    }
    /// Setter form of [`Self::with_key`].
    #[inline]
    pub fn set_key<K: Hash>(&mut self, key: K) {
        self.root.set_key(key);
    }
    /// Setter form of [`Self::with_merge_callback`].
    #[inline]
    pub fn set_merge_callback<C: Into<DatasetMergeCallback>>(&mut self, callback: C) {
        self.root.set_merge_callback(callback);
    }
    /// Setter form of [`Self::with_svg_data`].
    #[inline]
    pub fn set_svg_data(&mut self, data: SvgNodeData) {
        self.root.set_svg_data(data);
    }
    /// Setter form of [`Self::with_attributes`].
    #[inline]
    pub fn set_attributes(&mut self, attributes: AttributeTypeVec) {
        self.root.set_attributes(attributes);
    }
    /// Attach a presence-animation function to this node — see
    /// [`NodeData::add_animation_callback`].
    #[must_use]
    pub fn with_animation_callback(
        mut self,
        name: AzString,
        callback: crate::resources::ZombieAnimCallback,
        data: RefAny,
    ) -> Self {
        self.root.add_animation_callback(name, callback, data);
        self
    }
    #[inline]
    #[must_use]
850210
    pub fn with_ids_and_classes(mut self, ids_and_classes: IdOrClassVec) -> Self {
850210
        self.root.set_ids_and_classes(ids_and_classes);
850210
        self
850210
    }
    /// Adds an attribute to this DOM element.
    #[inline]
    #[must_use]
9766
    pub fn with_attribute(mut self, attr: AttributeType) -> Self {
9766
        let mut attrs = self.root.attributes().clone();
9766
        let mut v = attrs.into_library_owned_vec();
9766
        v.push(attr);
9766
        self.root.set_attributes(v.into());
9766
        self
9766
    }
    /// Adds multiple attributes to this DOM element.
    #[inline]
    #[must_use]
1
    pub fn with_attributes(mut self, attributes: AttributeTypeVec) -> Self {
1
        self.root.set_attributes(attributes);
1
        self
1
    }
    #[inline]
    #[must_use]
349844
    pub fn with_callbacks(mut self, callbacks: CoreCallbackDataVec) -> Self {
349844
        self.root.callbacks = callbacks;
349844
        self
349844
    }
    /// Legacy: builder-form for the flat property+conditions list. Each entry
    /// becomes a single-declaration rule at `rule_priority::INLINE`.
    #[inline]
    #[must_use]
1111696
    pub fn with_css_props(mut self, css_props: CssPropertyWithConditionsVec) -> Self {
1111696
        self.root.style = css_props.into();
1111696
        self
1111696
    }
    /// Builder-form for setting the inline `Css` directly.
    #[inline]
    #[must_use]
    pub fn with_style(mut self, style: azul_css::css::Css) -> Self {
        self.root.style = style;
        self
    }
    /// Assigns a stable key to the root node of this DOM for reconciliation.
    ///
    /// This is crucial for performance and correct state preservation when
    /// lists of items change order or items are inserted/removed.
    ///
    /// # Example
    /// ```rust
    /// # use azul_core::dom::Dom;
    /// Dom::create_div().with_key("user-avatar-123");
    /// ```
    #[inline]
    #[must_use]
    pub fn with_key<K: Hash>(mut self, key: K) -> Self {
        self.root.set_key(key);
        self
    }
    /// Registers a callback to merge dataset state from the previous frame.
    ///
    /// This is used for components that maintain heavy internal state (video players,
    /// WebGL contexts, network connections) that should not be destroyed and recreated
    /// on every render frame.
    ///
    /// The callback receives both datasets as `RefAny` (cheap shallow clones) and
    /// returns the `RefAny` that should be used for the new node.
    #[inline]
    #[must_use]
483
    pub fn with_merge_callback<C: Into<DatasetMergeCallback>>(mut self, callback: C) -> Self {
483
        self.root.set_merge_callback(callback);
483
        self
483
    }
    /// Parse and set CSS styles with full selector support.
    ///
    /// This is the unified API for setting inline CSS on a DOM node. It supports:
    /// - Simple properties: `color: red; font-size: 14px;`
    /// - Pseudo-selectors: `:hover { background: blue; }`
    /// - @-rules: `@os linux { font-size: 14px; }`
    /// - Nesting: `@os linux { font-size: 14px; :hover { color: red; }}`
    ///
    /// # Examples
    /// ```rust
    /// # use azul_core::dom::Dom;
    /// // Simple inline styles
    /// Dom::create_div().with_css("color: red; font-size: 14px;");
    ///
    /// // With hover and active states
    /// Dom::create_div().with_css(
    ///     "
    ///     color: blue;
    ///     :hover { color: red; }
    ///     :active { color: green; }
    /// ",
    /// );
    ///
    /// // OS-specific with nested hover
    /// Dom::create_div().with_css(
    ///     "
    ///     font-size: 12px;
    ///     @os linux { font-size: 14px; :hover { color: red; }}
    ///     @os windows { font-size: 13px; }
    /// ",
    /// );
    /// ```
80208
    pub fn set_css(&mut self, style: &str) {
        // Unified, `@scope`-like model: a CSS string parses into a `Css` struct that is
        // pushed onto THIS Dom subtree's `.css` vec, where the cascade selector-matches
        // it against the subtree (`collect_css_from_dom` → `CssPropertyCache::restyle`).
        // `with_css` is the single CSS entry point — there is no separate node-only inline
        // path, and the old `with_component_css` is folded into this. A bare-declaration
        // string (`color: red`) parses to `* { color: red }` and so applies to the whole
        // subtree, exactly like attaching a `@scope { :scope { ... } }` block.
80208
        self.add_component_css(azul_css::css::Css::parse_inline(style));
80208
    }
    /// Builder method for `set_css`
    #[must_use]
80121
    pub fn with_css(mut self, style: &str) -> Self {
80121
        self.set_css(style);
80121
        self
80121
    }
    /// Sets the context menu for the root node
    #[inline]
209
    pub fn set_context_menu(&mut self, context_menu: Menu) {
209
        self.root.set_context_menu(context_menu);
209
    }
    #[inline]
    #[must_use]
209
    pub fn with_context_menu(mut self, context_menu: Menu) -> Self {
209
        self.set_context_menu(context_menu);
209
        self
209
    }
    /// Sets the menu bar for the root node
    #[inline]
    pub fn set_menu_bar(&mut self, menu_bar: Menu) {
        self.root.set_menu_bar(menu_bar);
    }
    #[inline]
    #[must_use]
    pub fn with_menu_bar(mut self, menu_bar: Menu) -> Self {
        self.set_menu_bar(menu_bar);
        self
    }
    #[inline]
    #[must_use]
    pub fn with_clip_mask(mut self, clip_mask: ImageMask) -> Self {
        self.root.set_clip_mask(clip_mask);
        self
    }
    #[inline]
    #[must_use]
10
    pub fn with_svg_clip_path(mut self, clip: crate::svg::SvgMultiPolygon) -> Self {
10
        self.root.set_svg_data(SvgNodeData::Path(clip));
10
        self
10
    }
    #[inline]
    #[must_use]
    pub fn with_svg_data(mut self, data: SvgNodeData) -> Self {
        self.root.set_svg_data(data);
        self
    }
    #[inline]
    /// Give this node an accessible name, keeping whatever else it already
    /// declares.
    ///
    /// This is the override `with_accessibility_info` can't give you: a
    /// widget fills in what it knows (a slider's role and live value, a
    /// checkbox's checked state) but not what the control is called - only
    /// the app knows that. Replacing the whole struct to add a name would
    /// discard the role and value with it.
    ///
    /// ```ignore
    /// Slider::new(volume).dom().with_accessibility_name("Volume")
    /// ```
    #[must_use]
4
    pub fn with_accessibility_name<S: Into<AzString>>(self, name: S) -> Self {
4
        self.with_accessibility_assign(AccessibilityInfo {
4
            accessibility_name: Some(name.into()).into(),
4
            ..AccessibilityInfo::default()
4
        })
4
    }
    /// Overlay a partial accessibility declaration, keeping every field the
    /// patch does not set.
    ///
    /// The general form of the two helpers around it, and the one to reach for
    /// when setting more than one thing at once:
    ///
    /// ```ignore
    /// slider.dom().with_accessibility_assign(&AccessibilityInfo {
    ///     accessibility_name: Some("Volume".into()).into(),
    ///     description: Some("0 to 100".into()).into(),
    ///     ..Default::default()
    /// })
    /// // the widget's role, live value and states all survive
    /// ```
    ///
    /// See [`AccessibilityInfo::assign`] for exactly which fields count as
    /// "set" — `None`, an empty vec and `Unknown` all mean "not specified".
    #[must_use]
156
    pub fn with_accessibility_assign(mut self, patch: AccessibilityInfo) -> Self {
156
        let info = self
156
            .root
156
            .accessibility
156
            .as_ref()
156
            .map_or_else(AccessibilityInfo::default, |b| (**b).clone());
156
        self.root.set_accessibility_info(info.assigned(patch));
156
        self
156
    }
    /// Point this node at the node that already names it, keeping the rest of
    /// its declaration.
    ///
    /// Preferred over copying the label text: a duplicated name drifts the
    /// moment someone edits the visible label and forgets the spoken one.
    #[must_use]
    pub fn with_accessibility_labelled_by(self, label: DomNodeId) -> Self {
        self.with_accessibility_assign(AccessibilityInfo {
            labelled_by: Some(label).into(),
            ..AccessibilityInfo::default()
        })
    }
    #[must_use]
339864
    pub fn with_accessibility_info(mut self, accessibility_info: AccessibilityInfo) -> Self {
339864
        self.root.set_accessibility_info(accessibility_info);
339864
        self
339864
    }
1926512
    pub fn fixup_children_estimated(&mut self) -> usize {
1926512
        if self.children.is_empty() {
928098
            self.estimated_total_children = 0;
928098
        } else {
998414
            self.estimated_total_children = self
998414
                .children
998414
                .iter_mut()
1830087
                .map(|s| s.fixup_children_estimated() + 1)
998414
                .sum();
        }
1926512
        self.estimated_total_children
1926512
    }
}
impl core::iter::FromIterator<Self> for Dom {
21
    fn from_iter<I: IntoIterator<Item = Self>>(iter: I) -> Self {
21
        let mut estimated_total_children = 0;
21
        let children = iter
21
            .into_iter()
55
            .inspect(|c| {
55
                estimated_total_children += c.estimated_total_children + 1;
55
            })
21
            .collect::<Vec<Self>>();
21
        Self {
21
            root: NodeData::create_div(),
21
            children: children.into(),
21
            css: azul_css::css::CssVec::from_const_slice(&[]),
21
            estimated_total_children,
21
        }
21
    }
}
impl fmt::Debug for Dom {
1
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
4
        fn print_dom(d: &Dom, f: &mut fmt::Formatter<'_>) -> fmt::Result {
4
            write!(f, "Dom {{\r\n")?;
4
            write!(f, "\troot: {:#?}\r\n", d.root)?;
4
            write!(
4
                f,
4
                "\testimated_total_children: {:#?}\r\n",
                d.estimated_total_children
            )?;
4
            write!(f, "\tchildren: [\r\n")?;
7
            for c in &d.children {
3
                print_dom(c, f)?;
            }
4
            write!(f, "\t]\r\n")?;
4
            write!(f, "}}\r\n")?;
4
            Ok(())
4
        }
1
        print_dom(self, f)
1
    }
}
#[cfg(test)]
#[path = "dom_test.rs"]
mod dom_test;