blitz_dom/lib.rs
1//! The core DOM abstraction in Blitz
2//!
3//! This crate implements a flexible headless DOM ([`BaseDocument`]), which is designed to emebedded in and "driven" by external code. Most users will want
4//! to use a wrapper:
5//!
6//! - [`HtmlDocument`](https://docs.rs/blitz-html/latest/blitz_html/struct.HtmlDocument.html) from the [blitz-html](https://docs.rs/blitz-html) crate.
7//! Allows you to parse HTML (or XHTML) into a Blitz [`BaseDocument`], and can be combined with a markdown-to-html converter like [comrak](https://docs.rs/comrak)
8//! or [pulldown-cmark](https://docs.rs/pulldown-cmark) to render/process markdown.
9//! - [`DioxusDocument`](https://docs.rs/dioxus-native/latest/dioxus_native/struct.DioxusDocument.html) from the [dioxus-native](https://docs.rs/dioxus-native) crate.
10//! Combines a [`BaseDocument`] with a Dioxus `VirtualDom` to enable dynamic rendering and event handling.
11//!
12//! It includes: A DOM tree respresentation, CSS parsing and resolution, layout and event handling. Additional functionality is available in
13//! separate crates, including html parsing ([blitz-html](https://docs.rs/blitz-html)), networking ([blitz-net](https://docs.rs/blitz-html)),
14//! rendering ([blitz-paint](https://docs.rs/blitz-paint)) and windowing ([blitz-shell](https://docs.rs/blitz-shell)).
15//!
16//! Most of the functionality in this crates is provided through the struct.
17//!
18//! `blitz-dom` has a native Rust API that is designed for higher-level abstractions to be built on top (although it can also be used directly).
19//!
20//! The goal behind this crate is that any implementor can interact with the DOM and render it out using any renderer
21//! they want.
22//!
23
24// TODO: Document features
25// ## Feature flags
26// - `default`: Enables the features listed below.
27// - `tracing`: Enables tracing support.
28
29pub const DEFAULT_CSS: &str = include_str!("../assets/default.css");
30pub(crate) const BULLET_FONT: &[u8] = include_bytes!("../assets/moz-bullet-font.otf");
31
32const INCREMENTAL: bool = cfg!(feature = "incremental");
33const NON_INCREMENTAL: bool = !INCREMENTAL;
34
35/// The DOM implementation.
36///
37/// This is the primary entry point for this crate.
38mod document;
39
40/// The nodes themsleves, and their data.
41pub mod node;
42
43mod config;
44mod debug;
45mod events;
46mod font_metrics;
47mod form;
48mod html;
49/// Integration of taffy and the DOM.
50mod layout;
51mod mutator;
52mod query_selector;
53/// Implementations that interact with servo's style engine
54mod stylo;
55mod stylo_to_cursor_icon;
56mod stylo_to_parley;
57mod traversal;
58mod url;
59
60pub mod net;
61pub mod util;
62
63#[cfg(feature = "accessibility")]
64mod accessibility;
65
66pub use config::DocumentConfig;
67pub use document::{BaseDocument, Document};
68pub use markup5ever::{
69 LocalName, Namespace, NamespaceStaticSet, Prefix, PrefixStaticSet, QualName, local_name,
70 namespace_prefix, namespace_url, ns,
71};
72pub use mutator::DocumentMutator;
73pub use node::{Attribute, ElementData, Node, NodeData, TextNodeData};
74pub use parley::FontContext;
75pub use style::Atom;
76pub use style::invalidation::element::restyle_hints::RestyleHint;
77pub type SelectorList = selectors::SelectorList<style::selector_parser::SelectorImpl>;
78pub use events::{EventDriver, EventHandler, NoopEventHandler};
79pub use html::{DummyHtmlParserProvider, HtmlParserProvider};
80pub use util::Point;