Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/css/css_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2595,6 +2595,7 @@ mod stylesheet_impl {
err: None,
selector_expansion_multiplier: 1,
selector_expansion_total: 0,
split_clone_weight_total: 0,
};

if self.rules.minify(&mut minify_ctx, false).is_err() {
Expand Down
9 changes: 9 additions & 0 deletions src/css/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,11 @@ pub enum MinifyErrorKind {
/// Compiling nested rules for the configured browser targets would expand to
/// more than [`crate::css_rules::MAX_SELECTOR_EXPANSION`] selectors.
selector_expansion_limit_exceeded,
/// Splitting a rule's selectors for the configured browser targets clones
/// the rule's declarations and nested rules once per split-off selector,
/// and the cumulative weight of those clones exceeded
/// [`crate::css_rules::MAX_SELECTOR_SPLIT_CLONE_WEIGHT`].
selector_split_clone_limit_exceeded,
/// Rule minification failed without recording a more specific diagnostic on
/// `MinifyContext::err`. Defensive fallback — every failing path is expected
/// to record one before returning an error.
Expand All @@ -540,6 +545,10 @@ impl fmt::Display for MinifyErrorKind {
"Nested CSS rules expand to more than {} selectors when compiled for the configured browser targets. Reduce the nesting depth or the number of selectors per rule, or target browsers that support CSS nesting.",
crate::css_rules::MAX_SELECTOR_EXPANSION,
),
Self::selector_split_clone_limit_exceeded => write!(
f,
"Splitting nested CSS rules with selectors unsupported by the configured browser targets duplicates too much CSS. Reduce the nesting depth or the number of selectors per rule, or target browsers that support these selectors.",
),
Self::unknown => write!(f, "CSS minification failed"),
}
}
Expand Down
5 changes: 4 additions & 1 deletion src/css/printer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,10 @@ pub struct Printer<'a> {
pub sources: Option<&'a Vec<Box<[u8]>>>,
pub dest: &'a mut dyn Write,
pub loc: Location,
pub indent_amt: u8,
/// Two per nesting level. `u32` because valid stylesheets can nest rules
/// hundreds of levels deep (bounded only by input size), which overflows a
/// `u8` at 128 levels.
pub indent_amt: u32,
pub line: u32,
pub col: u32,
pub minify: bool,
Expand Down
Loading
Loading