Keep validated policy storage within the renderer feature

This commit is contained in:
Terra854
2026-11-17 19:12:08 +08:00
parent 6d0fa2c26d
commit 76a27e21d7
+8 -1
View File
@@ -167,6 +167,7 @@ pub fn root_unitless_size(svg: &str, limits: &Limits) -> Result<Option<(f64, f64
/// SVG text after shared byte, entity, attribute, XML and expansion-depth checks.
/// Keep it opaque so consumers use the same checked tree and don't reparse XML locally.
pub struct Preflight<'s> {
#[cfg(feature = "tree-render")]
limits: Limits,
xml: roxmltree::Document<'s>,
depth: usize,
@@ -248,7 +249,13 @@ pub fn preflight<'s>(svg: &'s str, limits: &Limits) -> Result<Preflight<'s>, Err
let Some(height) = height(&xml, limits.tree_depth)? else {
return Err(Error::TooDeep(limits.tree_depth));
};
Ok(Preflight { limits: *limits, xml, depth, height })
Ok(Preflight {
#[cfg(feature = "tree-render")]
limits: *limits,
xml,
depth,
height,
})
}
/// Dimensions of an SVG viewport in SVG user units.