Expand description
The core DOM abstraction in Apace
This crate implements a flexible headless DOM (BaseDocument), which is designed to emebedded in and “driven” by external code. Most users will want
to use a wrapper:
HtmlDocumentfrom the apace-html crate. Allows you to parse HTML (or XHTML) into a ApaceBaseDocument, and can be combined with a markdown-to-html converter like comrak or pulldown-cmark to render/process markdown.DioxusDocumentfrom the dioxus-native crate. Combines aBaseDocumentwith a DioxusVirtualDomto enable dynamic rendering and event handling.
It includes: A DOM tree respresentation, CSS parsing and resolution, layout and event handling. Additional functionality is available in separate crates, including html parsing (apace-html), networking (apace-net), rendering (apace-paint) and windowing (apace-shell).
Most of the functionality in this crates is provided through the struct.
apace-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).
The goal behind this crate is that any implementor can interact with the DOM and render it out using any renderer they want.
Re-exports§
pub use crate::node::Widget;pub use node::Attribute;pub use node::DocumentData;pub use node::ElementData;pub use node::Node;pub use node::NodeData;pub use node::TextNodeData;pub use util::Point;pub use util::decode_font_bytes;
Modules§
- net
- node
- The nodes themsleves, and their data.
- profile
- Opt-in, bounded engine phase measurements. Samples are inclusive; nested text work and parallel worker totals must not be added to wall time.
- traversal
- util
Macros§
- local_
name - Takes a local name as a string and returns its key in the string cache.
- namespace_
prefix - Takes a namespace prefix string and returns its key in a string cache.
- namespace_
url - Takes a namespace url string and returns its key in a string cache.
- ns
- Maps the input of
namespace_prefix!to the output ofnamespace_url!. - qual_
name - Creates an markup5ever::QualName. Given a local name and an optional namespace
Structs§
- Base
Document - Bounding
Rect - CssRule
Info - A snapshot of the CSSOM-visible attributes of a rule
- Document
Config - Options used when constructing a
BaseDocument - Document
Mutator - Dummy
Html Parser Provider - Event
Driver - Font
Context - A font database/cache (wrapper around a Fontique
CollectionandSourceCache). - Hoisted
Paint Child - A child with a z_index that is hoisted up to it’s containing Stacking Context for paint purposes
- Image
Load Event - Image
Request Id - One live element consumer, independently of a shared URL fetch.
- Intrinsic
Sizes - The intrinsic dimensions of a replaced element per CSS Images 3 (https://drafts.csswg.org/css-images/#intrinsic-dimensions): an intrinsic width, an intrinsic height, and an intrinsic aspect ratio, each of which may independently be absent.
- Media
Type - https://drafts.csswg.org/mediaqueries/#media-types
- Namespace
Static Set - NodeId
- A versioned identifier for a node in a Apace DOM tree.
- Node
Tree - The versioned map in which the nodes of the DOM tree are stored, backed by
a
slotmap::SlotMap. - Noop
Event Handler - Plain
Document - Prefix
Static Set - Qual
Name - A fully qualified name (with a namespace), used to depict names of tags and attributes.
- Resource
Limits - Resource
Stats - Restyle
Hint - The kind of restyle we need to do for a given element.
- Stacking
Context - TopLayer
- TopLayer
Config - User
Agent Stylesheet - A user-agent stylesheet, parsed with a read-only lock so that it can be shared between documents.
Enums§
- Cssom
Error - Errors from CSSOM mutation operations, mirroring the
DOMExceptionnames which the corresponding JavaScript APIs throw. - DocGuard
- DocGuard
Mut - Image
Load Status - Register
Custom Property Result - Scroll
Behavior - Scroll
Logical Position - Style
Threading - Strategy for Stylo’s style traversal during
resolve. - TopLayer
Error
Constants§
Traits§
- Document
- Abstraction over wrappers around
BaseDocumentto allow for them all to be driven byapace-shell - Event
Handler - Html
Parser Provider
Functions§
- build_
single_ font_ ctx - Convenience builder for the one-font case: produces a
FontContextwith system-font discovery disabled and the supplied font registered as the fallback for every generic family. The standard setup for WASM, where browsers don’t expose system fonts. WOFF/WOFF2 inputs are decoded automatically. - css_
property_ is_ supported - Check whether
namenames a CSS property supported by the style engine. Custom properties (--*) are not considered “supported” here, matching the behaviour of theinoperator onCSSStyleDeclarationobjects in browsers. - dom_
node_ id - Convert a
takia::NodeIdproduced bytakia_node_idback into a ApaceNodeId. - full_
size_ kana - Maps small kana to full-size kana. https://drafts.csswg.org/css-text-3/#small-kana
- full_
width - Maps
cto its full-width form: the reverse of its<wide>decomposition mapping or its<narrow>decomposition mapping, if any. https://drafts.csswg.org/css-text-3/#text-transform-mapping - hoisted_
child_ position - Offset of the hoisted child
child_idfrom the border box of its stacking-context rootsc_root_id, excluding the child’s ownfinal_layout().location: the sum oflocation - scroll_offsetof every box strictly between the two on the child’s positioning chain. - parse_
transform_ matrix - Parse a CSS
transformlist into a 4x4 matrix, as required by theDOMMatrix(DOMString)constructor andDOMMatrix.setMatrixValue()(https://drafts.fxtf.org/geometry/#parse-a-string-into-an-abstract-matrix). - resolve_
2d_ transform - resolved_
style_ property_ names - The names of the properties exposed by the
CSSStyleDeclarationreturned fromgetComputedStyle()(its indexed properties): every enabled longhand, sorted alphabetically. - takia_
node_ id - Convert a Apace
NodeIdinto atakia::NodeId(which wraps au64).