// +spec:box-model:b3a79e - box assigned same styles as generating element; getters read from styled
/// 1. `computed_values` binary search → if `FontSize` is pre- resolved to a px value, use that.
/// 2. Full cascade via `cache.get_font_size(...)`; if an explicit value is present, resolve with
pub fn get_root_font_size(styled_dom: &StyledDom, _node_state: &StyledNodeState) -> f32 {
($fn_name:ident, $cache_method:ident, $return_type:ty, $ua_property:expr, compact = $compact_method:ident) => {
($fn_name:ident, $cache_method:ident, $return_type:ty, $ua_property:expr, compact_u32_dim = $compact_raw_method:ident, $px_variant:path, $auto_variant:path, $min_content_variant:path, $max_content_variant:path) => {
($fn_name:ident, $cache_method:ident, $return_type:ty, $ua_property:expr, compact_u32_struct = $compact_raw_method:ident) => {
azul_css::compact_cache::U32_AUTO | azul_css::compact_cache::U32_NONE => return MultiValue::Auto,
fn extract(&self) -> Option<azul_css::props::style::spatial_nav::StyleSpatialNavigationAction> {
// +spec:overflow:17654b - overflow-block and overflow-inline logical properties resolve to physical
// +spec:overflow:17654b - overflow-block and overflow-inline logical properties resolve to physical
// +spec:writing-modes:3af12f - unicode-bidi does not affect direction for layout; we use direction
// +spec:display-property:346799 - inline-level elements with unicode-bidi:normal have no effect on
// text ordering +spec:writing-modes:3e2632 - unicode-bidi property resolves embedding level for
// bidi algorithm (LRE/RLE/PDF) +spec:writing-modes:d2c94f - direction+unicode-bidi properties map
// +spec:display-property:db5125 - text-box-trim on inline boxes trims content box to text-box-edge
// metric +spec:display-property:dceb24 - text-box-trim on inline boxes: content edges coincide with
// enum/value mapping/dispatch table: one arm per input variant (or cross-type bindings that can't
// +spec:writing-modes:257296 - text-orientation getter for vertical typesetting (upright/sideways)
azul_core::ua_css::get_ua_property(&node_data.node_type, CssPropertyType::VerticalAlign);
/// * `element_size` - The element's own size (width × height) for % resolution. According to CSS
// +spec:stacking-contexts:ae50ae - z-index specifies stack level; auto resolves to 0 (inherited
// +spec:positioning:c041c4 - positioned elements with z-index != auto establish stacking contexts
/// Returns true if z-index is `auto` (the initial value), false if it's an explicit `<integer>`.
/// `background-image` on the root element is `none` AND its `background-color` is `transparent`,
// enum/value mapping/dispatch table: one arm per input variant (or cross-type bindings that can't
let get_node_bg = |nid: NodeId, ndata: &azul_core::dom::NodeData, state: &StyledNodeState| {
azul_css::props::style::StyleBackgroundContent::Image(_) => None, // Has image, not transparent
let first_child_state = &styled_dom.styled_nodes.as_container()[first_child].styled_node_state;
/// For HTML documents, if the root `<html>` element has no background (transparent with no image),
let first_child_state = &styled_dom.styled_nodes.as_container()[first_child].styled_node_state;
#[allow(clippy::too_many_lines)] // large but cohesive: single-purpose layout/render/parse routine (one branch per case)
#[allow(clippy::too_many_lines)] // large but cohesive: single-purpose layout/render/parse routine
let default_text = system_style.and_then(|ss| ss.colors.selection_text.as_option().copied());
// enum/value mapping/dispatch table: one arm per input variant (or cross-type bindings that can't
// +spec:positioning:c31c24 - blockification is a computed-value change for absolute/float/root
// +spec:display-property:641ac5 - computed display value applies blockification/inlinification (not
// +spec:positioning:ce02a1 - out-of-flow boxes (floated or absolutely positioned) get blockified
// display four independent layout-state flags drive the blockification decision; bundling them
// +spec:font-metrics:f7affa - vertical-align shorthand: maps CSS vertical-align values to inline
let shared = if let Some(existing) = bucket.iter().find(|existing| ***existing == built) {
#[allow(clippy::cast_possible_truncation)] // bounded graphics/coord/font/fixed-point/debug-marker cast
#[allow(clippy::too_many_lines, clippy::cognitive_complexity)] // large but cohesive: single-purpose layout/render/parse routine (one branch per case)
/// Panics only on an internal indexing invariant (an in-range `get().unwrap()` over the font-family
get_style_properties_for_state(styled_dom, dom_id, system_style, viewport_size, &node_state)
#[allow(clippy::cast_possible_truncation)] // bounded graphics/coord/font/fixed-point/debug-marker cast
#[allow(clippy::too_many_lines, clippy::cognitive_complexity)] // large but cohesive: single-purpose layout/render/parse routine (one branch per case)
/// Panics only on an internal indexing invariant (an in-range `get().unwrap()` over the font-family
let font_ref = (0..font_families.len()).find_map(|i| match font_families.get(i).unwrap() {
pub fn get_list_style_type(styled_dom: &StyledDom, dom_id: Option<NodeId>) -> StyleListStyleType {
azul_core::ua_css::get_ua_property(node_data.get_node_type(), CssPropertyType::BreakBefore)
use crate::text3::cache::{FontChainKey, FontChainKeyOrRef, FontSelector, FontStack, FontStyle};
/// Contains all unique font stacks and the mapping from `StyleFontFamiliesHash` to `FontChainKey`
pub fn get_for_font_stack(&self, font_stack: &[FontSelector]) -> Option<&FontFallbackChain> {
#[allow(clippy::cast_possible_truncation)] // bounded graphics/coord/font/fixed-point/debug-marker cast
#[allow(clippy::too_many_lines)] // large but cohesive: single-purpose layout/render/parse routine (one branch per case)
let mut font_refs: HashMap<usize, azul_css::props::basic::font::FontRef> = HashMap::new();
pub fn collect_used_codepoints(styled_dom: &StyledDom) -> std::collections::BTreeSet<u32> {
pub fn collect_used_codepoints_all(styled_dom: &StyledDom) -> std::collections::BTreeSet<char> {
/// - `None` keeps the original "all 7 default scripts" behaviour (Cyrillic / Arabic / Devanagari /
/// - `Some(&[])` attaches *no* Unicode fallbacks, suitable for ASCII-only documents. Combined with
/// `prune_chain_to_used_chars` this is what eliminates Arial Unicode MS / CJK / Arabic font loads
/// - `Some(ranges)` attaches fallbacks only for the listed scripts. Production callers compute this
let mut unresolved: std::collections::BTreeSet<String> = std::collections::BTreeSet::new();
fn first_font_in_cache(fc_cache: &FcFontCache) -> Option<(rust_fontconfig::FcPattern, FontId)> {
#[allow(clippy::implicit_hasher)] // internal helper; only ever called with the default-hasher HashMap/HashSet
#[allow(clippy::too_many_lines)] // large but cohesive: single-purpose layout/render/parse routine (one branch per case)
pub fn get_opacity(styled_dom: &StyledDom, node_id: NodeId, node_state: &StyledNodeState) -> f32 {
pub fn is_node_contenteditable_inherited(styled_dom: &StyledDom, node_id: NodeId) -> bool {
pub fn find_contenteditable_ancestor(styled_dom: &StyledDom, node_id: NodeId) -> Option<NodeId> {
fn get_scrollbar_info_from_layout_returns_whatever_layout_stored_including_degenerate_floats() {