style: Rustfmt recent changes.

This commit is contained in:
Emilio Cobos Álvarez 2020-06-04 02:02:50 +02:00
parent 69c7077b3d
commit 762abbaf9f
No known key found for this signature in database
GPG key ID: E1152D0994E4BF8A
19 changed files with 163 additions and 101 deletions

View file

@ -144,9 +144,7 @@ impl SelectorParsingState {
#[inline] #[inline]
fn allows_non_functional_pseudo_classes(self) -> bool { fn allows_non_functional_pseudo_classes(self) -> bool {
!self.intersects( !self.intersects(Self::AFTER_SLOTTED | Self::AFTER_NON_STATEFUL_PSEUDO_ELEMENT)
Self::AFTER_SLOTTED | Self::AFTER_NON_STATEFUL_PSEUDO_ELEMENT,
)
} }
#[inline] #[inline]
@ -354,10 +352,9 @@ impl<Impl: SelectorImpl> SelectorList<Impl> {
{ {
let mut values = SmallVec::new(); let mut values = SmallVec::new();
loop { loop {
values.push( values.push(input.parse_until_before(Delimiter::Comma, |input| {
input parse_selector(parser, input, state)
.parse_until_before(Delimiter::Comma, |input| parse_selector(parser, input, state))?, })?);
);
match input.next() { match input.next() {
Err(_) => return Ok(SelectorList(values)), Err(_) => return Ok(SelectorList(values)),
Ok(&Token::Comma) => continue, Ok(&Token::Comma) => continue,
@ -382,7 +379,11 @@ where
P: Parser<'i, Impl = Impl>, P: Parser<'i, Impl = Impl>,
Impl: SelectorImpl, Impl: SelectorImpl,
{ {
parse_selector(parser, input, state | SelectorParsingState::DISALLOW_PSEUDOS | SelectorParsingState::DISALLOW_COMBINATORS) parse_selector(
parser,
input,
state | SelectorParsingState::DISALLOW_PSEUDOS | SelectorParsingState::DISALLOW_COMBINATORS,
)
} }
/// Parse a comma separated list of compound selectors. /// Parse a comma separated list of compound selectors.
@ -395,7 +396,9 @@ where
Impl: SelectorImpl, Impl: SelectorImpl,
{ {
input input
.parse_comma_separated(|input| parse_inner_compound_selector(parser, input, SelectorParsingState::empty())) .parse_comma_separated(|input| {
parse_inner_compound_selector(parser, input, SelectorParsingState::empty())
})
.map(|selectors| selectors.into_boxed_slice()) .map(|selectors| selectors.into_boxed_slice())
} }
@ -450,9 +453,7 @@ where
}, },
// In quirks mode, class and id selectors should match // In quirks mode, class and id selectors should match
// case-insensitively, so just avoid inserting them into the filter. // case-insensitively, so just avoid inserting them into the filter.
Component::ID(ref id) if quirks_mode != QuirksMode::Quirks => { Component::ID(ref id) if quirks_mode != QuirksMode::Quirks => id.precomputed_hash(),
id.precomputed_hash()
},
Component::Class(ref class) if quirks_mode != QuirksMode::Quirks => { Component::Class(ref class) if quirks_mode != QuirksMode::Quirks => {
class.precomputed_hash() class.precomputed_hash()
}, },
@ -466,7 +467,7 @@ where
} }
} }
continue; continue;
} },
_ => continue, _ => continue,
}; };
@ -1086,11 +1087,14 @@ impl<Impl: SelectorImpl> Component<Impl> {
pub fn maybe_allowed_after_pseudo_element(&self) -> bool { pub fn maybe_allowed_after_pseudo_element(&self) -> bool {
match *self { match *self {
Component::NonTSPseudoClass(..) => true, Component::NonTSPseudoClass(..) => true,
Component::Negation(ref components) => components.iter().all(|c| c.maybe_allowed_after_pseudo_element()), Component::Negation(ref components) => components
Component::Is(ref selectors) | .iter()
Component::Where(ref selectors) => { .all(|c| c.maybe_allowed_after_pseudo_element()),
Component::Is(ref selectors) | Component::Where(ref selectors) => {
selectors.iter().all(|selector| { selectors.iter().all(|selector| {
selector.iter_raw_match_order().all(|c| c.maybe_allowed_after_pseudo_element()) selector
.iter_raw_match_order()
.all(|c| c.maybe_allowed_after_pseudo_element())
}) })
}, },
_ => false, _ => false,
@ -1110,12 +1114,14 @@ impl<Impl: SelectorImpl> Component<Impl> {
*self *self
); );
match *self { match *self {
Component::Negation(ref components) => { Component::Negation(ref components) => !components
!components.iter().all(|c| c.matches_for_stateless_pseudo_element()) .iter()
}, .all(|c| c.matches_for_stateless_pseudo_element()),
Component::Is(ref selectors) | Component::Where(ref selectors) => { Component::Is(ref selectors) | Component::Where(ref selectors) => {
selectors.iter().any(|selector| { selectors.iter().any(|selector| {
selector.iter_raw_match_order().all(|c| c.matches_for_stateless_pseudo_element()) selector
.iter_raw_match_order()
.all(|c| c.matches_for_stateless_pseudo_element())
}) })
}, },
_ => false, _ => false,
@ -2254,7 +2260,11 @@ where
// Pseudo-elements cannot be represented by the matches-any // Pseudo-elements cannot be represented by the matches-any
// pseudo-class; they are not valid within :is(). // pseudo-class; they are not valid within :is().
// //
let inner = SelectorList::parse_with_state(parser, input, state | SelectorParsingState::DISALLOW_PSEUDOS)?; let inner = SelectorList::parse_with_state(
parser,
input,
state | SelectorParsingState::DISALLOW_PSEUDOS,
)?;
Ok(component(inner.0.into_vec().into_boxed_slice())) Ok(component(inner.0.into_vec().into_boxed_slice()))
} }

View file

@ -131,6 +131,7 @@ impl BuilderExt for Builder {
// them. // them.
let mut builder = Builder::default() let mut builder = Builder::default()
.rust_target(RustTarget::Stable_1_25) .rust_target(RustTarget::Stable_1_25)
.size_t_is_usize(true)
.disable_untagged_union(); .disable_untagged_union();
let rustfmt_path = env::var_os("RUSTFMT") let rustfmt_path = env::var_os("RUSTFMT")

View file

@ -7,9 +7,9 @@
use crate::context::QuirksMode; use crate::context::QuirksMode;
use crate::dom::{TDocument, TElement, TNode, TShadowRoot}; use crate::dom::{TDocument, TElement, TNode, TShadowRoot};
use crate::invalidation::element::invalidation_map::Dependency;
use crate::invalidation::element::invalidator::{DescendantInvalidationLists, Invalidation}; use crate::invalidation::element::invalidator::{DescendantInvalidationLists, Invalidation};
use crate::invalidation::element::invalidator::{InvalidationProcessor, InvalidationVector}; use crate::invalidation::element::invalidator::{InvalidationProcessor, InvalidationVector};
use crate::invalidation::element::invalidation_map::Dependency;
use crate::Atom; use crate::Atom;
use selectors::attr::CaseSensitivity; use selectors::attr::CaseSensitivity;
use selectors::matching::{self, MatchingContext, MatchingMode}; use selectors::matching::{self, MatchingContext, MatchingMode};
@ -145,7 +145,10 @@ where
} }
fn check_outer_dependency(&mut self, _: &Dependency, _: E) -> bool { fn check_outer_dependency(&mut self, _: &Dependency, _: E) -> bool {
debug_assert!(false, "How? We should only have parent-less dependencies here!"); debug_assert!(
false,
"How? We should only have parent-less dependencies here!"
);
true true
} }
@ -647,9 +650,11 @@ pub fn query_selector<E, Q>(
if root_element.is_some() || !invalidation_may_be_useful { if root_element.is_some() || !invalidation_may_be_useful {
query_selector_slow::<E, Q>(root, selector_list, results, &mut matching_context); query_selector_slow::<E, Q>(root, selector_list, results, &mut matching_context);
} else { } else {
let dependencies = selector_list.0.iter().map(|selector| { let dependencies = selector_list
Dependency::for_full_selector_invalidation(selector.clone()) .0
}).collect::<SmallVec<[_; 5]>>(); .iter()
.map(|selector| Dependency::for_full_selector_invalidation(selector.clone()))
.collect::<SmallVec<[_; 5]>>();
let mut processor = QuerySelectorProcessor::<E, Q> { let mut processor = QuerySelectorProcessor::<E, Q> {
results, results,
matching_context, matching_context,

View file

@ -703,7 +703,6 @@ pub static MEDIA_FEATURES: [MediaFeatureDescription; 53] = [
keyword_evaluator!(eval_any_hover, Hover), keyword_evaluator!(eval_any_hover, Hover),
ParsingRequirements::empty(), ParsingRequirements::empty(),
), ),
// Internal -moz-is-glyph media feature: applies only inside SVG glyphs. // Internal -moz-is-glyph media feature: applies only inside SVG glyphs.
// Internal because it is really only useful in the user agent anyway // Internal because it is really only useful in the user agent anyway
// and therefore not worth standardizing. // and therefore not worth standardizing.

View file

@ -161,11 +161,13 @@ impl PseudoElement {
/// Whether this pseudo-element is enabled for all content. /// Whether this pseudo-element is enabled for all content.
pub fn enabled_in_content(&self) -> bool { pub fn enabled_in_content(&self) -> bool {
match *self { match *self {
PseudoElement::MozFocusOuter => static_prefs::pref!("layout.css.moz-focus-outer.enabled"), PseudoElement::MozFocusOuter => {
PseudoElement::FileChooserButton => static_prefs::pref!("layout.css.file-chooser-button.enabled"), static_prefs::pref!("layout.css.moz-focus-outer.enabled")
_ => { },
(self.flags() & structs::CSS_PSEUDO_ELEMENT_ENABLED_IN_UA_SHEETS_AND_CHROME) == 0 PseudoElement::FileChooserButton => {
} static_prefs::pref!("layout.css.file-chooser-button.enabled")
},
_ => (self.flags() & structs::CSS_PSEUDO_ELEMENT_ENABLED_IN_UA_SHEETS_AND_CHROME) == 0,
} }
} }

View file

@ -343,7 +343,8 @@ impl<'a, 'i> ::selectors::Parser<'i> for SelectorParser<'a> {
#[inline] #[inline]
fn parse_is_and_where(&self) -> bool { fn parse_is_and_where(&self) -> bool {
self.in_user_agent_stylesheet() || static_prefs::pref!("layout.css.is-where-selectors.enabled") self.in_user_agent_stylesheet() ||
static_prefs::pref!("layout.css.is-where-selectors.enabled")
} }
#[inline] #[inline]

View file

@ -4,12 +4,12 @@
//! Helpers for different FFI pointer kinds that Gecko's FFI layer uses. //! Helpers for different FFI pointer kinds that Gecko's FFI layer uses.
use gecko_bindings::structs::root::mozilla::detail::CopyablePtr;
use servo_arc::{Arc, RawOffsetArc}; use servo_arc::{Arc, RawOffsetArc};
use std::marker::PhantomData; use std::marker::PhantomData;
use std::mem::{forget, transmute}; use std::mem::{forget, transmute};
use std::ops::{Deref, DerefMut}; use std::ops::{Deref, DerefMut};
use std::ptr; use std::ptr;
use gecko_bindings::structs::root::mozilla::detail::CopyablePtr;
/// Indicates that a given Servo type has a corresponding Gecko FFI type. /// Indicates that a given Servo type has a corresponding Gecko FFI type.
pub unsafe trait HasFFI: Sized + 'static { pub unsafe trait HasFFI: Sized + 'static {
@ -345,4 +345,4 @@ impl<T> DerefMut for CopyablePtr<T> {
fn deref_mut<'a>(&'a mut self) -> &'a mut T { fn deref_mut<'a>(&'a mut self) -> &'a mut T {
&mut self.mPtr &mut self.mPtr
} }
} }

View file

@ -67,7 +67,10 @@ where
I: Iterator<Item = &'a CascadeData>, I: Iterator<Item = &'a CascadeData>,
{ {
fn check_outer_dependency(&mut self, _: &Dependency, _: E) -> bool { fn check_outer_dependency(&mut self, _: &Dependency, _: E) -> bool {
debug_assert!(false, "how, we should only have parent-less dependencies here!"); debug_assert!(
false,
"how, we should only have parent-less dependencies here!"
);
true true
} }

View file

@ -6,7 +6,9 @@
use crate::context::QuirksMode; use crate::context::QuirksMode;
use crate::element_state::{DocumentState, ElementState}; use crate::element_state::{DocumentState, ElementState};
use crate::selector_map::{MaybeCaseInsensitiveHashMap, PrecomputedHashMap, SelectorMap, SelectorMapEntry}; use crate::selector_map::{
MaybeCaseInsensitiveHashMap, PrecomputedHashMap, SelectorMap, SelectorMapEntry,
};
use crate::selector_parser::SelectorImpl; use crate::selector_parser::SelectorImpl;
use crate::{Atom, LocalName, Namespace}; use crate::{Atom, LocalName, Namespace};
use fallible::FallibleVec; use fallible::FallibleVec;
@ -196,7 +198,8 @@ pub struct InvalidationMap {
/// A list of document state dependencies in the rules we represent. /// A list of document state dependencies in the rules we represent.
pub document_state_selectors: Vec<DocumentStateDependency>, pub document_state_selectors: Vec<DocumentStateDependency>,
/// A map of other attribute affecting selectors. /// A map of other attribute affecting selectors.
pub other_attribute_affecting_selectors: PrecomputedHashMap<LocalName, SmallVec<[Dependency; 1]>>, pub other_attribute_affecting_selectors:
PrecomputedHashMap<LocalName, SmallVec<[Dependency; 1]>>,
} }
impl InvalidationMap { impl InvalidationMap {
@ -331,7 +334,11 @@ impl<'a> SelectorDependencyCollector<'a> {
self.visit_whole_selector_from(iter, 0) self.visit_whole_selector_from(iter, 0)
} }
fn visit_whole_selector_from(&mut self, mut iter: SelectorIter<SelectorImpl>, mut index: usize) -> bool { fn visit_whole_selector_from(
&mut self,
mut iter: SelectorIter<SelectorImpl>,
mut index: usize,
) -> bool {
loop { loop {
// Reset the compound state. // Reset the compound state.
self.compound_state = PerCompoundState::new(index); self.compound_state = PerCompoundState::new(index);
@ -384,7 +391,7 @@ impl<'a> SelectorDependencyCollector<'a> {
Err(err) => { Err(err) => {
*self.alloc_error = Some(err); *self.alloc_error = Some(err);
return false; return false;
} },
} }
} }
@ -395,8 +402,7 @@ impl<'a> SelectorDependencyCollector<'a> {
// cache them or something. // cache them or something.
for &(ref selector, ref selector_offset) in self.parent_selectors.iter() { for &(ref selector, ref selector_offset) in self.parent_selectors.iter() {
debug_assert_ne!( debug_assert_ne!(
self.compound_state.offset, self.compound_state.offset, 0,
0,
"Shouldn't bother creating nested dependencies for the rightmost compound", "Shouldn't bother creating nested dependencies for the rightmost compound",
); );
let new_parent = Dependency { let new_parent = Dependency {
@ -442,7 +448,8 @@ impl<'a> SelectorVisitor for SelectorDependencyCollector<'a> {
index += 1; // account for the combinator. index += 1; // account for the combinator.
self.parent_selectors.push((self.selector.clone(), self.compound_state.offset)); self.parent_selectors
.push((self.selector.clone(), self.compound_state.offset));
let mut nested = SelectorDependencyCollector { let mut nested = SelectorDependencyCollector {
map: &mut *self.map, map: &mut *self.map,
document_state: &mut *self.document_state, document_state: &mut *self.document_state,
@ -483,7 +490,7 @@ impl<'a> SelectorVisitor for SelectorDependencyCollector<'a> {
Err(err) => { Err(err) => {
*self.alloc_error = Some(err); *self.alloc_error = Some(err);
return false; return false;
} },
} }
}, },
Component::NonTSPseudoClass(ref pc) => { Component::NonTSPseudoClass(ref pc) => {

View file

@ -177,13 +177,10 @@ pub struct Invalidation<'a> {
impl<'a> Invalidation<'a> { impl<'a> Invalidation<'a> {
/// Create a new invalidation for matching a dependency. /// Create a new invalidation for matching a dependency.
pub fn new( pub fn new(dependency: &'a Dependency, scope: Option<OpaqueElement>) -> Self {
dependency: &'a Dependency,
scope: Option<OpaqueElement>,
) -> Self {
debug_assert!( debug_assert!(
dependency.selector_offset == dependency.selector.len() + 1 || dependency.selector_offset == dependency.selector.len() + 1 ||
dependency.invalidation_kind() != DependencyInvalidationKind::Element, dependency.invalidation_kind() != DependencyInvalidationKind::Element,
"No point to this, if the dependency matched the element we should just invalidate it" "No point to this, if the dependency matched the element we should just invalidate it"
); );
Self { Self {
@ -206,7 +203,11 @@ impl<'a> Invalidation<'a> {
// for the weird pseudos in <input type="number">. // for the weird pseudos in <input type="number">.
// //
// We should be able to do better here! // We should be able to do better here!
match self.dependency.selector.combinator_at_parse_order(self.offset - 1) { match self
.dependency
.selector
.combinator_at_parse_order(self.offset - 1)
{
Combinator::Descendant | Combinator::LaterSibling | Combinator::PseudoElement => true, Combinator::Descendant | Combinator::LaterSibling | Combinator::PseudoElement => true,
Combinator::Part | Combinator::Part |
Combinator::SlotAssignment | Combinator::SlotAssignment |
@ -220,7 +221,11 @@ impl<'a> Invalidation<'a> {
return InvalidationKind::Descendant(DescendantInvalidationKind::Dom); return InvalidationKind::Descendant(DescendantInvalidationKind::Dom);
} }
match self.dependency.selector.combinator_at_parse_order(self.offset - 1) { match self
.dependency
.selector
.combinator_at_parse_order(self.offset - 1)
{
Combinator::Child | Combinator::Descendant | Combinator::PseudoElement => { Combinator::Child | Combinator::Descendant | Combinator::PseudoElement => {
InvalidationKind::Descendant(DescendantInvalidationKind::Dom) InvalidationKind::Descendant(DescendantInvalidationKind::Dom)
}, },
@ -238,7 +243,11 @@ impl<'a> fmt::Debug for Invalidation<'a> {
use cssparser::ToCss; use cssparser::ToCss;
f.write_str("Invalidation(")?; f.write_str("Invalidation(")?;
for component in self.dependency.selector.iter_raw_parse_order_from(self.offset) { for component in self
.dependency
.selector
.iter_raw_parse_order_from(self.offset)
{
if matches!(*component, Component::Combinator(..)) { if matches!(*component, Component::Combinator(..)) {
break; break;
} }
@ -816,9 +825,11 @@ where
let mut cur_dependency = invalidation.dependency; let mut cur_dependency = invalidation.dependency;
loop { loop {
cur_dependency = match cur_dependency.parent { cur_dependency = match cur_dependency.parent {
None => return SingleInvalidationResult { None => {
invalidated_self: true, return SingleInvalidationResult {
matched: true, invalidated_self: true,
matched: true,
}
}, },
Some(ref p) => &**p, Some(ref p) => &**p,
}; };
@ -828,11 +839,14 @@ where
// The inner selector changed, now check if the full // The inner selector changed, now check if the full
// previous part of the selector did, before keeping // previous part of the selector did, before keeping
// checking for descendants. // checking for descendants.
if !self.processor.check_outer_dependency(cur_dependency, self.element) { if !self
.processor
.check_outer_dependency(cur_dependency, self.element)
{
return SingleInvalidationResult { return SingleInvalidationResult {
invalidated_self: false, invalidated_self: false,
matched: false, matched: false,
} };
} }
if cur_dependency.invalidation_kind() == DependencyInvalidationKind::Element { if cur_dependency.invalidation_kind() == DependencyInvalidationKind::Element {
@ -840,24 +854,21 @@ where
} }
debug!(" > Generating invalidation"); debug!(" > Generating invalidation");
break Invalidation::new(cur_dependency, invalidation.scope) break Invalidation::new(cur_dependency, invalidation.scope);
} }
}, },
CompoundSelectorMatchingResult::Matched { CompoundSelectorMatchingResult::Matched {
next_combinator_offset, next_combinator_offset,
} => { } => Invalidation {
Invalidation { dependency: invalidation.dependency,
dependency: invalidation.dependency, scope: invalidation.scope,
scope: invalidation.scope, offset: next_combinator_offset + 1,
offset: next_combinator_offset + 1, matched_by_any_previous: false,
matched_by_any_previous: false,
}
}, },
}; };
debug_assert_ne!( debug_assert_ne!(
next_invalidation.offset, next_invalidation.offset, 0,
0,
"Rightmost selectors shouldn't generate more invalidations", "Rightmost selectors shouldn't generate more invalidations",
); );
@ -886,7 +897,9 @@ where
c.maybe_allowed_after_pseudo_element(), c.maybe_allowed_after_pseudo_element(),
"Someone seriously messed up selector parsing: \ "Someone seriously messed up selector parsing: \
{:?} at offset {:?}: {:?}", {:?} at offset {:?}: {:?}",
next_invalidation.dependency, next_invalidation.offset, c, next_invalidation.dependency,
next_invalidation.offset,
c,
); );
None None

View file

@ -254,7 +254,9 @@ where
); );
} }
let mut attributes_changed = false; let mut attributes_changed = false;
snapshot.each_attr_changed(|_| { attributes_changed = true; }); snapshot.each_attr_changed(|_| {
attributes_changed = true;
});
if attributes_changed { if attributes_changed {
debug!( debug!(
" > attributes changed, old: {}", " > attributes changed, old: {}",
@ -436,7 +438,12 @@ where
/// Check whether a dependency should be taken into account. /// Check whether a dependency should be taken into account.
#[inline] #[inline]
fn check_dependency(&mut self, dependency: &Dependency) -> bool { fn check_dependency(&mut self, dependency: &Dependency) -> bool {
check_dependency(dependency, &self.element, &self.wrapper, &mut self.matching_context) check_dependency(
dependency,
&self.element,
&self.wrapper,
&mut self.matching_context,
)
} }
fn scan_dependency(&mut self, dependency: &'selectors Dependency) { fn scan_dependency(&mut self, dependency: &'selectors Dependency) {
@ -472,10 +479,8 @@ where
debug_assert_ne!(dependency.selector_offset, 0); debug_assert_ne!(dependency.selector_offset, 0);
debug_assert_ne!(dependency.selector_offset, dependency.selector.len()); debug_assert_ne!(dependency.selector_offset, dependency.selector.len());
let invalidation = Invalidation::new( let invalidation =
&dependency, Invalidation::new(&dependency, self.matching_context.current_host.clone());
self.matching_context.current_host.clone(),
);
match invalidation_kind { match invalidation_kind {
DependencyInvalidationKind::Element => unreachable!(), DependencyInvalidationKind::Element => unreachable!(),

View file

@ -208,13 +208,19 @@ where
} }
impl Parse for crate::OwnedStr { impl Parse for crate::OwnedStr {
fn parse<'i, 't>(_: &ParserContext, input: &mut Parser<'i, 't>) -> Result<Self, ParseError<'i>> { fn parse<'i, 't>(
_: &ParserContext,
input: &mut Parser<'i, 't>,
) -> Result<Self, ParseError<'i>> {
Ok(input.expect_string()?.as_ref().to_owned().into()) Ok(input.expect_string()?.as_ref().to_owned().into())
} }
} }
impl Parse for UnicodeRange { impl Parse for UnicodeRange {
fn parse<'i, 't>(_: &ParserContext, input: &mut Parser<'i, 't>) -> Result<Self, ParseError<'i>> { fn parse<'i, 't>(
_: &ParserContext,
input: &mut Parser<'i, 't>,
) -> Result<Self, ParseError<'i>> {
Ok(UnicodeRange::parse(input)?) Ok(UnicodeRange::parse(input)?)
} }
} }

View file

@ -331,8 +331,9 @@ impl<T: SelectorMapEntry> SelectorMap<T> {
.try_entry(url.clone())? .try_entry(url.clone())?
.or_insert_with(SmallVec::new), .or_insert_with(SmallVec::new),
Bucket::Universal => &mut self.other, Bucket::Universal => &mut self.other,
}.try_push($entry)?; }
}} .try_push($entry)?;
}};
} }
let bucket = { let bucket = {
@ -354,7 +355,11 @@ impl<T: SelectorMapEntry> SelectorMap<T> {
// This is specially true if there's any universal selector in the // This is specially true if there's any universal selector in the
// `disjoint_selectors` set, at which point we'd just be doing // `disjoint_selectors` set, at which point we'd just be doing
// wasted work. // wasted work.
if !disjoint_buckets.is_empty() && disjoint_buckets.iter().all(|b| b.more_specific_than(&bucket)) { if !disjoint_buckets.is_empty() &&
disjoint_buckets
.iter()
.all(|b| b.more_specific_than(&bucket))
{
for bucket in &disjoint_buckets { for bucket in &disjoint_buckets {
let entry = entry.clone(); let entry = entry.clone();
insert_into_bucket!(entry, *bucket); insert_into_bucket!(entry, *bucket);

View file

@ -10,7 +10,8 @@ use crate::values::computed::{Context, ToComputedValue};
use crate::values::specified; use crate::values::specified;
pub use super::specified::{ pub use super::specified::{
AlignContent, AlignItems, AlignTracks, ContentDistribution, JustifyContent, JustifyTracks, SelfAlignment, AlignContent, AlignItems, AlignTracks, ContentDistribution, JustifyContent, JustifyTracks,
SelfAlignment,
}; };
pub use super::specified::{AlignSelf, JustifySelf}; pub use super::specified::{AlignSelf, JustifySelf};

View file

@ -29,7 +29,10 @@ use std::cmp;
use std::f32; use std::f32;
#[cfg(feature = "gecko")] #[cfg(feature = "gecko")]
pub use self::align::{AlignContent, AlignItems, AlignTracks, JustifyContent, JustifyItems, JustifyTracks, SelfAlignment}; pub use self::align::{
AlignContent, AlignItems, AlignTracks, JustifyContent, JustifyItems, JustifyTracks,
SelfAlignment,
};
#[cfg(feature = "gecko")] #[cfg(feature = "gecko")]
pub use self::align::{AlignSelf, JustifySelf}; pub use self::align::{AlignSelf, JustifySelf};
pub use self::angle::Angle; pub use self::angle::Angle;
@ -69,7 +72,9 @@ pub use self::motion::{OffsetPath, OffsetRotate};
pub use self::outline::OutlineStyle; pub use self::outline::OutlineStyle;
pub use self::percentage::{NonNegativePercentage, Percentage}; pub use self::percentage::{NonNegativePercentage, Percentage};
pub use self::position::AspectRatio; pub use self::position::AspectRatio;
pub use self::position::{GridAutoFlow, GridTemplateAreas, MasonryAutoFlow, Position, PositionOrAuto, ZIndex}; pub use self::position::{
GridAutoFlow, GridTemplateAreas, MasonryAutoFlow, Position, PositionOrAuto, ZIndex,
};
pub use self::rect::NonNegativeLengthOrNumberRect; pub use self::rect::NonNegativeLengthOrNumberRect;
pub use self::resolution::Resolution; pub use self::resolution::Resolution;
pub use self::svg::MozContextProperties; pub use self::svg::MozContextProperties;

View file

@ -300,19 +300,14 @@ impl SpecifiedValueInfo for AlignContent {
)] )]
#[repr(transparent)] #[repr(transparent)]
#[css(comma)] #[css(comma)]
pub struct AlignTracks( pub struct AlignTracks(#[css(iterable, if_empty = "normal")] pub crate::OwnedSlice<AlignContent>);
#[css(iterable, if_empty = "normal")]
pub crate::OwnedSlice<AlignContent>
);
impl Parse for AlignTracks { impl Parse for AlignTracks {
fn parse<'i, 't>( fn parse<'i, 't>(
context: &ParserContext, context: &ParserContext,
input: &mut Parser<'i, 't>, input: &mut Parser<'i, 't>,
) -> Result<Self, ParseError<'i>> { ) -> Result<Self, ParseError<'i>> {
let values = input.parse_comma_separated(|input| { let values = input.parse_comma_separated(|input| AlignContent::parse(context, input))?;
AlignContent::parse(context, input)
})?;
Ok(AlignTracks(values.into())) Ok(AlignTracks(values.into()))
} }
} }
@ -373,8 +368,7 @@ impl SpecifiedValueInfo for JustifyContent {
#[repr(transparent)] #[repr(transparent)]
#[css(comma)] #[css(comma)]
pub struct JustifyTracks( pub struct JustifyTracks(
#[css(iterable, if_empty = "normal")] #[css(iterable, if_empty = "normal")] pub crate::OwnedSlice<JustifyContent>,
pub crate::OwnedSlice<JustifyContent>
); );
impl Parse for JustifyTracks { impl Parse for JustifyTracks {
@ -382,9 +376,7 @@ impl Parse for JustifyTracks {
context: &ParserContext, context: &ParserContext,
input: &mut Parser<'i, 't>, input: &mut Parser<'i, 't>,
) -> Result<Self, ParseError<'i>> { ) -> Result<Self, ParseError<'i>> {
let values = input.parse_comma_separated(|input| { let values = input.parse_comma_separated(|input| JustifyContent::parse(context, input))?;
JustifyContent::parse(context, input)
})?;
Ok(JustifyTracks(values.into())) Ok(JustifyTracks(values.into()))
} }
} }

View file

@ -72,7 +72,9 @@ pub use self::motion::{OffsetPath, OffsetRotate};
pub use self::outline::OutlineStyle; pub use self::outline::OutlineStyle;
pub use self::percentage::Percentage; pub use self::percentage::Percentage;
pub use self::position::AspectRatio; pub use self::position::AspectRatio;
pub use self::position::{GridAutoFlow, GridTemplateAreas, MasonryAutoFlow, Position, PositionOrAuto}; pub use self::position::{
GridAutoFlow, GridTemplateAreas, MasonryAutoFlow, Position, PositionOrAuto,
};
pub use self::position::{PositionComponent, ZIndex}; pub use self::position::{PositionComponent, ZIndex};
pub use self::rect::NonNegativeLengthOrNumberRect; pub use self::rect::NonNegativeLengthOrNumberRect;
pub use self::resolution::Resolution; pub use self::resolution::Resolution;

View file

@ -452,13 +452,12 @@ pub struct MasonryAutoFlow {
#[inline] #[inline]
fn is_pack_with_non_default_order(placement: &MasonryPlacement, order: &MasonryItemOrder) -> bool { fn is_pack_with_non_default_order(placement: &MasonryPlacement, order: &MasonryItemOrder) -> bool {
*placement == MasonryPlacement::Pack && *placement == MasonryPlacement::Pack && *order != MasonryItemOrder::DefiniteFirst
*order != MasonryItemOrder::DefiniteFirst
} }
#[inline] #[inline]
fn is_item_order_definite_first(order: &MasonryItemOrder) -> bool { fn is_item_order_definite_first(order: &MasonryItemOrder) -> bool {
*order == MasonryItemOrder::DefiniteFirst *order == MasonryItemOrder::DefiniteFirst
} }
impl MasonryAutoFlow { impl MasonryAutoFlow {

View file

@ -154,8 +154,14 @@ pub fn derive(mut input: DeriveInput) -> TokenStream {
let mut parse_non_keywords = quote! {}; let mut parse_non_keywords = quote! {};
for (i, (variant, css_attrs, parse_attrs)) in non_keywords.iter().enumerate() { for (i, (variant, css_attrs, parse_attrs)) in non_keywords.iter().enumerate() {
let skip_try = !has_keywords && i == non_keywords.len() - 1; let skip_try = !has_keywords && i == non_keywords.len() - 1;
let parse_variant = let parse_variant = parse_non_keyword_variant(
parse_non_keyword_variant(&mut where_clause, name, variant, css_attrs, parse_attrs, skip_try); &mut where_clause,
name,
variant,
css_attrs,
parse_attrs,
skip_try,
);
parse_non_keywords.extend(parse_variant); parse_non_keywords.extend(parse_variant);
} }