Skip to content
Merged
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: 0 additions & 1 deletion mordant-baseline.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
"defaulted_failure:src/bun_core/string/immutable.rs" = 1

[bun_css]
"bare_bool_args:src/css/selectors/builder.rs" = 1
"tuple_wants_struct:src/css/css_parser.rs" = 1
"tuple_wants_struct:src/css/values/color.rs" = 5

Expand Down
17 changes: 1 addition & 16 deletions src/css/selectors/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,23 +110,8 @@ impl<Impl: ValidSelectorImpl> SelectorBuilder<Impl> {
/// Consumes the builder, producing a Selector.
///
/// *NOTE*: This will free all allocated memory in the builder
pub(crate) fn build(
&mut self,
parsed_pseudo: bool,
parsed_slotted: bool,
parsed_part: bool,
) -> BuildResult<Impl> {
pub(crate) fn build(&mut self, flags: SelectorFlags) -> BuildResult<Impl> {
let specificity = compute_specificity::<Impl>(self.simple_selectors.slice());
let mut flags = SelectorFlags::empty();
if parsed_pseudo {
flags |= SelectorFlags::HAS_PSEUDO;
}
if parsed_slotted {
flags |= SelectorFlags::HAS_SLOTTED;
}
if parsed_part {
flags |= SelectorFlags::HAS_PART;
}
// `build_with_specificity_and_flags()` drains the contents; `Drop` on
// `SelectorBuilder` frees the SmallList capacity when the builder goes
// out of scope.
Expand Down
20 changes: 14 additions & 6 deletions src/css/selectors/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -673,11 +673,19 @@ fn parse_selector<Impl: BunSelectorImpl>(
}
}

let has_pseudo_element = state.contains(SelectorParsingState::AFTER_PSEUDO_ELEMENT)
|| state.contains(SelectorParsingState::AFTER_UNKNOWN_PSEUDO_ELEMENT);
let slotted = state.contains(SelectorParsingState::AFTER_SLOTTED);
let part = state.contains(SelectorParsingState::AFTER_PART);
let result = builder.build(has_pseudo_element, slotted, part);
let mut flags = SelectorFlags::empty();
if state.contains(SelectorParsingState::AFTER_PSEUDO_ELEMENT)
|| state.contains(SelectorParsingState::AFTER_UNKNOWN_PSEUDO_ELEMENT)
{
flags |= SelectorFlags::HAS_PSEUDO;
}
if state.contains(SelectorParsingState::AFTER_SLOTTED) {
flags |= SelectorFlags::HAS_SLOTTED;
}
if state.contains(SelectorParsingState::AFTER_PART) {
flags |= SelectorFlags::HAS_PART;
}
let result = builder.build(flags);
Ok(GenericSelector {
specificity_and_flags: result.specificity_and_flags,
components: result.components,
Expand Down Expand Up @@ -1883,7 +1891,7 @@ impl<Impl: BunSelectorImpl> GenericSelector<Impl> {
} else {
builder.push_simple_selector(component);
}
let result = builder.build(false, false, false);
let result = builder.build(SelectorFlags::empty());
Self {
specificity_and_flags: result.specificity_and_flags,
components: result.components,
Expand Down
Loading