#![allow(clippy::collapsible_if)]
pub const DEFAULT_CSS: &str = include_str!("../assets/default.css");
pub const BULLET_FONT: &[u8] = include_bytes!("../assets/moz-bullet-font.otf");
const INCREMENTAL: bool = cfg!(feature = "incremental");
const NON_INCREMENTAL: bool = !INCREMENTAL;
mod document;
pub mod node;
mod config;
mod debug;
mod events;
mod font_metrics;
mod form;
mod html;
mod layout;
mod mutator;
mod query_selector;
mod resolve;
mod selection;
mod stylo;
mod stylo_to_cursor_icon;
mod stylo_to_kurbo;
mod stylo_to_parley;
mod traversal;
mod url;
pub use stylo_to_kurbo::resolve_2d_transform;
pub mod net;
pub mod util;
#[cfg(feature = "accessibility")]
mod accessibility;
#[cfg(feature = "custom-widget")]
pub use crate::node::Widget;
pub use config::{DocumentConfig, StyleThreading};
pub use document::{BaseDocument, DocGuard, DocGuardMut, Document, PlainDocument};
pub use markup5ever::{
LocalName, Namespace, NamespaceStaticSet, Prefix, PrefixStaticSet, QualName, local_name,
namespace_prefix, namespace_url, ns,
};
pub use mutator::DocumentMutator;
pub use node::{Attribute, ElementData, Node, NodeData, TextNodeData};
pub use parley::FontContext;
pub use style::Atom;
pub use style::invalidation::element::restyle_hints::RestyleHint;
pub use style::media_queries::MediaType;
pub type SelectorList = selectors::SelectorList<style::selector_parser::SelectorImpl>;
pub use events::{EventDriver, EventHandler, NoopEventHandler};
pub use html::{DummyHtmlParserProvider, HtmlParserProvider};
pub use util::{Point, decode_font_bytes};
pub fn build_single_font_ctx(font_data: &[u8]) -> FontContext {
use parley::fontique::{Blob, Collection, CollectionOptions, GenericFamily, SourceCache};
use std::sync::Arc;
let mut ctx = FontContext {
source_cache: SourceCache::new_shared(),
collection: Collection::new(CollectionOptions {
shared: false,
system_fonts: false,
}),
};
let decoded = decode_font_bytes(font_data).into_owned();
let registered = ctx
.collection
.register_fonts(Blob::new(Arc::new(decoded) as _), None);
let family_ids: Vec<_> = registered.iter().map(|(id, _)| *id).collect();
for generic in [
GenericFamily::SansSerif,
GenericFamily::Serif,
GenericFamily::Monospace,
GenericFamily::SystemUi,
] {
ctx.collection
.append_generic_families(generic, family_ids.iter().copied());
}
ctx
}