Skip to content

Commit 399eedc

Browse files
committed
feat: add property iter utils
1 parent 4348038 commit 399eedc

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

float-pigment-css/src/query.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ use crate::sheet::{RuleWeight, Theme};
1212
use crate::typing::{Length, LengthType};
1313

1414
/// The status of media query, i.e. screen size, screen type, etc.
15+
///
16+
/// This also contains some global environment values, such as `env(...)` values in CSS.
17+
///
1518
#[derive(Debug, Clone, PartialEq)]
1619
pub struct MediaQueryStatus<L: LengthNum> {
1720
/// The viewport is a `screen` media type.
@@ -517,6 +520,20 @@ impl MatchedRuleList {
517520
}
518521
}
519522

523+
/// Iterate properties with weights.
524+
pub fn for_each_property(&self, mut f: impl FnMut(&Property, u64)) {
525+
for matched_rule in self.rules.iter() {
526+
let weight = matched_rule.weight;
527+
for pm in matched_rule.rule.properties.iter() {
528+
if pm.is_disabled() { continue }
529+
let w = if pm.is_important() { weight.important() } else { weight.normal() };
530+
for p in pm.iter() {
531+
f(p, w);
532+
}
533+
}
534+
}
535+
}
536+
520537
/// Find the style scope of the rule which contains the applied `animation-name` property.
521538
///
522539
/// This call is designed for the search of keyframes with style scopes.

0 commit comments

Comments
 (0)