mirror of
https://github.com/servo/servo.git
synced 2025-07-23 15:23:42 +01:00
style: Rustfmt recent changes.
This commit is contained in:
parent
deba73a528
commit
57874ae90a
10 changed files with 73 additions and 56 deletions
|
@ -270,8 +270,7 @@ where
|
||||||
Component::Combinator(..) => {
|
Component::Combinator(..) => {
|
||||||
unreachable!("Found combinator in simple selectors vector?");
|
unreachable!("Found combinator in simple selectors vector?");
|
||||||
},
|
},
|
||||||
Component::Part(..) |
|
Component::Part(..) | Component::PseudoElement(..) | Component::LocalName(..) => {
|
||||||
Component::PseudoElement(..) | Component::LocalName(..) => {
|
|
||||||
specificity.element_selectors += 1
|
specificity.element_selectors += 1
|
||||||
},
|
},
|
||||||
Component::Slotted(ref selector) => {
|
Component::Slotted(ref selector) => {
|
||||||
|
|
|
@ -30,10 +30,14 @@ pub trait PseudoElement: Sized + ToCss {
|
||||||
|
|
||||||
/// Whether the pseudo-element supports a given state selector to the right
|
/// Whether the pseudo-element supports a given state selector to the right
|
||||||
/// of it.
|
/// of it.
|
||||||
fn accepts_state_pseudo_classes(&self) -> bool { false }
|
fn accepts_state_pseudo_classes(&self) -> bool {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
|
||||||
/// Whether this pseudo-element is valid after a ::slotted(..) pseudo.
|
/// Whether this pseudo-element is valid after a ::slotted(..) pseudo.
|
||||||
fn valid_after_slotted(&self) -> bool { false }
|
fn valid_after_slotted(&self) -> bool {
|
||||||
|
false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A trait that represents a pseudo-class.
|
/// A trait that represents a pseudo-class.
|
||||||
|
@ -116,7 +120,10 @@ impl SelectorParsingState {
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn allows_non_functional_pseudo_classes(self) -> bool {
|
fn allows_non_functional_pseudo_classes(self) -> bool {
|
||||||
!self.intersects(SelectorParsingState::AFTER_SLOTTED | SelectorParsingState::AFTER_NON_STATEFUL_PSEUDO_ELEMENT)
|
!self.intersects(
|
||||||
|
SelectorParsingState::AFTER_SLOTTED |
|
||||||
|
SelectorParsingState::AFTER_NON_STATEFUL_PSEUDO_ELEMENT,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -1221,9 +1228,7 @@ impl ToCss for Combinator {
|
||||||
Combinator::Descendant => dest.write_str(" "),
|
Combinator::Descendant => dest.write_str(" "),
|
||||||
Combinator::NextSibling => dest.write_str(" + "),
|
Combinator::NextSibling => dest.write_str(" + "),
|
||||||
Combinator::LaterSibling => dest.write_str(" ~ "),
|
Combinator::LaterSibling => dest.write_str(" ~ "),
|
||||||
Combinator::PseudoElement |
|
Combinator::PseudoElement | Combinator::Part | Combinator::SlotAssignment => Ok(()),
|
||||||
Combinator::Part |
|
|
||||||
Combinator::SlotAssignment => Ok(()),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1979,11 +1984,10 @@ where
|
||||||
|
|
||||||
let mut state = SelectorParsingState::empty();
|
let mut state = SelectorParsingState::empty();
|
||||||
loop {
|
loop {
|
||||||
let parse_result =
|
let parse_result = match parse_one_simple_selector(parser, input, state)? {
|
||||||
match parse_one_simple_selector(parser, input, state)? {
|
None => break,
|
||||||
None => break,
|
Some(result) => result,
|
||||||
Some(result) => result,
|
};
|
||||||
};
|
|
||||||
|
|
||||||
empty = false;
|
empty = false;
|
||||||
|
|
||||||
|
@ -2034,9 +2038,7 @@ where
|
||||||
Impl: SelectorImpl,
|
Impl: SelectorImpl,
|
||||||
{
|
{
|
||||||
if !state.allows_functional_pseudo_classes() {
|
if !state.allows_functional_pseudo_classes() {
|
||||||
return Err(input.new_custom_error(
|
return Err(input.new_custom_error(SelectorParseErrorKind::InvalidState));
|
||||||
SelectorParseErrorKind::InvalidState
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
debug_assert!(state.allows_tree_structural_pseudo_classes());
|
debug_assert!(state.allows_tree_structural_pseudo_classes());
|
||||||
match_ignore_ascii_case! { &name,
|
match_ignore_ascii_case! { &name,
|
||||||
|
@ -2102,7 +2104,7 @@ where
|
||||||
Err(..) => {
|
Err(..) => {
|
||||||
input.reset(&start);
|
input.reset(&start);
|
||||||
return Ok(None);
|
return Ok(None);
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(Some(match token {
|
Ok(Some(match token {
|
||||||
|
@ -2122,7 +2124,7 @@ where
|
||||||
Token::Ident(ref class) => class,
|
Token::Ident(ref class) => class,
|
||||||
ref t => {
|
ref t => {
|
||||||
let e = SelectorParseErrorKind::ClassNeedsIdent(t.clone());
|
let e = SelectorParseErrorKind::ClassNeedsIdent(t.clone());
|
||||||
return Err(location.new_custom_error(e))
|
return Err(location.new_custom_error(e));
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
let class = Component::Class(class.as_ref().into());
|
let class = Component::Class(class.as_ref().into());
|
||||||
|
@ -2149,8 +2151,7 @@ where
|
||||||
return Err(input.new_custom_error(e));
|
return Err(input.new_custom_error(e));
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
let is_pseudo_element =
|
let is_pseudo_element = !is_single_colon || is_css2_pseudo_element(&name);
|
||||||
!is_single_colon || is_css2_pseudo_element(&name);
|
|
||||||
if is_pseudo_element {
|
if is_pseudo_element {
|
||||||
if state.intersects(SelectorParsingState::AFTER_PSEUDO_ELEMENT) {
|
if state.intersects(SelectorParsingState::AFTER_PSEUDO_ELEMENT) {
|
||||||
return Err(input.new_custom_error(SelectorParseErrorKind::InvalidState));
|
return Err(input.new_custom_error(SelectorParseErrorKind::InvalidState));
|
||||||
|
@ -2158,7 +2159,9 @@ where
|
||||||
let pseudo_element = if is_functional {
|
let pseudo_element = if is_functional {
|
||||||
if P::parse_part(parser) && name.eq_ignore_ascii_case("part") {
|
if P::parse_part(parser) && name.eq_ignore_ascii_case("part") {
|
||||||
if !state.allows_part() {
|
if !state.allows_part() {
|
||||||
return Err(input.new_custom_error(SelectorParseErrorKind::InvalidState));
|
return Err(
|
||||||
|
input.new_custom_error(SelectorParseErrorKind::InvalidState)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
let name = input.parse_nested_block(|input| {
|
let name = input.parse_nested_block(|input| {
|
||||||
Ok(input.expect_ident()?.as_ref().into())
|
Ok(input.expect_ident()?.as_ref().into())
|
||||||
|
@ -2167,7 +2170,9 @@ where
|
||||||
}
|
}
|
||||||
if P::parse_slotted(parser) && name.eq_ignore_ascii_case("slotted") {
|
if P::parse_slotted(parser) && name.eq_ignore_ascii_case("slotted") {
|
||||||
if !state.allows_slotted() {
|
if !state.allows_slotted() {
|
||||||
return Err(input.new_custom_error(SelectorParseErrorKind::InvalidState));
|
return Err(
|
||||||
|
input.new_custom_error(SelectorParseErrorKind::InvalidState)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
let selector = input.parse_nested_block(|input| {
|
let selector = input.parse_nested_block(|input| {
|
||||||
parse_inner_compound_selector(parser, input)
|
parse_inner_compound_selector(parser, input)
|
||||||
|
@ -2181,7 +2186,9 @@ where
|
||||||
P::parse_pseudo_element(parser, location, name)?
|
P::parse_pseudo_element(parser, location, name)?
|
||||||
};
|
};
|
||||||
|
|
||||||
if state.intersects(SelectorParsingState::AFTER_SLOTTED) && !pseudo_element.valid_after_slotted() {
|
if state.intersects(SelectorParsingState::AFTER_SLOTTED) &&
|
||||||
|
!pseudo_element.valid_after_slotted()
|
||||||
|
{
|
||||||
return Err(input.new_custom_error(SelectorParseErrorKind::InvalidState));
|
return Err(input.new_custom_error(SelectorParseErrorKind::InvalidState));
|
||||||
}
|
}
|
||||||
SimpleSelectorParseResult::PseudoElement(pseudo_element)
|
SimpleSelectorParseResult::PseudoElement(pseudo_element)
|
||||||
|
@ -2198,7 +2205,7 @@ where
|
||||||
},
|
},
|
||||||
_ => {
|
_ => {
|
||||||
input.reset(&start);
|
input.reset(&start);
|
||||||
return Ok(None)
|
return Ok(None);
|
||||||
},
|
},
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
@ -2234,7 +2241,9 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
let pseudo_class = P::parse_non_ts_pseudo_class(parser, location, name)?;
|
let pseudo_class = P::parse_non_ts_pseudo_class(parser, location, name)?;
|
||||||
if state.intersects(SelectorParsingState::AFTER_PSEUDO_ELEMENT) && !pseudo_class.is_user_action_state() {
|
if state.intersects(SelectorParsingState::AFTER_PSEUDO_ELEMENT) &&
|
||||||
|
!pseudo_class.is_user_action_state()
|
||||||
|
{
|
||||||
return Err(location.new_custom_error(SelectorParseErrorKind::InvalidState));
|
return Err(location.new_custom_error(SelectorParseErrorKind::InvalidState));
|
||||||
}
|
}
|
||||||
Ok(Component::NonTSPseudoClass(pseudo_class))
|
Ok(Component::NonTSPseudoClass(pseudo_class))
|
||||||
|
@ -2266,9 +2275,13 @@ pub mod tests {
|
||||||
impl parser::PseudoElement for PseudoElement {
|
impl parser::PseudoElement for PseudoElement {
|
||||||
type Impl = DummySelectorImpl;
|
type Impl = DummySelectorImpl;
|
||||||
|
|
||||||
fn accepts_state_pseudo_classes(&self) -> bool { true }
|
fn accepts_state_pseudo_classes(&self) -> bool {
|
||||||
|
true
|
||||||
|
}
|
||||||
|
|
||||||
fn valid_after_slotted(&self) -> bool { true }
|
fn valid_after_slotted(&self) -> bool {
|
||||||
|
true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl parser::NonTSPseudoClass for PseudoClass {
|
impl parser::NonTSPseudoClass for PseudoClass {
|
||||||
|
|
|
@ -110,10 +110,7 @@ pub trait Element: Sized + Clone + Debug {
|
||||||
case_sensitivity: CaseSensitivity,
|
case_sensitivity: CaseSensitivity,
|
||||||
) -> bool;
|
) -> bool;
|
||||||
|
|
||||||
fn is_part(
|
fn is_part(&self, name: &<Self::Impl as SelectorImpl>::PartName) -> bool;
|
||||||
&self,
|
|
||||||
name: &<Self::Impl as SelectorImpl>::PartName,
|
|
||||||
) -> bool;
|
|
||||||
|
|
||||||
/// Returns whether this element matches `:empty`.
|
/// Returns whether this element matches `:empty`.
|
||||||
///
|
///
|
||||||
|
|
|
@ -49,8 +49,8 @@ use selectors::NthIndexCache;
|
||||||
use servo_arc::{Arc, ArcBorrow};
|
use servo_arc::{Arc, ArcBorrow};
|
||||||
use smallbitvec::SmallBitVec;
|
use smallbitvec::SmallBitVec;
|
||||||
use smallvec::SmallVec;
|
use smallvec::SmallVec;
|
||||||
use std::{mem, ops};
|
|
||||||
use std::sync::Mutex;
|
use std::sync::Mutex;
|
||||||
|
use std::{mem, ops};
|
||||||
use style_traits::viewport::ViewportConstraints;
|
use style_traits::viewport::ViewportConstraints;
|
||||||
|
|
||||||
/// The type of the stylesheets that the stylist contains.
|
/// The type of the stylesheets that the stylist contains.
|
||||||
|
@ -271,12 +271,8 @@ impl DocumentCascadeData {
|
||||||
let origin_sheets = flusher.origin_sheets(Origin::UserAgent);
|
let origin_sheets = flusher.origin_sheets(Origin::UserAgent);
|
||||||
let _unused_cascade_datas = {
|
let _unused_cascade_datas = {
|
||||||
let mut ua_cache = UA_CASCADE_DATA_CACHE.lock().unwrap();
|
let mut ua_cache = UA_CASCADE_DATA_CACHE.lock().unwrap();
|
||||||
self.user_agent = ua_cache.lookup(
|
self.user_agent =
|
||||||
origin_sheets,
|
ua_cache.lookup(origin_sheets, device, quirks_mode, guards.ua_or_user)?;
|
||||||
device,
|
|
||||||
quirks_mode,
|
|
||||||
guards.ua_or_user,
|
|
||||||
)?;
|
|
||||||
debug!("User agent data cache size {:?}", ua_cache.len());
|
debug!("User agent data cache size {:?}", ua_cache.len());
|
||||||
ua_cache.take_unused()
|
ua_cache.take_unused()
|
||||||
};
|
};
|
||||||
|
|
|
@ -86,8 +86,8 @@ pub use self::transform::{TransformOrigin, TransformStyle, Translate};
|
||||||
#[cfg(feature = "gecko")]
|
#[cfg(feature = "gecko")]
|
||||||
pub use self::ui::CursorImage;
|
pub use self::ui::CursorImage;
|
||||||
pub use self::ui::{Cursor, MozForceBrokenImageIcon, UserSelect};
|
pub use self::ui::{Cursor, MozForceBrokenImageIcon, UserSelect};
|
||||||
pub use super::specified::{BorderStyle, TextDecorationLine};
|
|
||||||
pub use super::specified::TextTransform;
|
pub use super::specified::TextTransform;
|
||||||
|
pub use super::specified::{BorderStyle, TextDecorationLine};
|
||||||
pub use super::{Auto, Either, None_};
|
pub use super::{Auto, Either, None_};
|
||||||
pub use app_units::Au;
|
pub use app_units::Au;
|
||||||
|
|
||||||
|
|
|
@ -19,9 +19,9 @@ use std::fmt::{self, Write};
|
||||||
use style_traits::{CssWriter, ToCss};
|
use style_traits::{CssWriter, ToCss};
|
||||||
|
|
||||||
pub use crate::values::specified::TextAlignKeyword as TextAlign;
|
pub use crate::values::specified::TextAlignKeyword as TextAlign;
|
||||||
|
pub use crate::values::specified::TextTransform;
|
||||||
pub use crate::values::specified::{OverflowWrap, WordBreak};
|
pub use crate::values::specified::{OverflowWrap, WordBreak};
|
||||||
pub use crate::values::specified::{TextDecorationLine, TextEmphasisPosition};
|
pub use crate::values::specified::{TextDecorationLine, TextEmphasisPosition};
|
||||||
pub use crate::values::specified::TextTransform;
|
|
||||||
|
|
||||||
/// A computed value for the `initial-letter` property.
|
/// A computed value for the `initial-letter` property.
|
||||||
pub type InitialLetter = GenericInitialLetter<CSSFloat, CSSInteger>;
|
pub type InitialLetter = GenericInitialLetter<CSSFloat, CSSInteger>;
|
||||||
|
|
|
@ -280,7 +280,9 @@ impl Parse for VerticalAlign {
|
||||||
return Ok(GenericVerticalAlign::Length(lp));
|
return Ok(GenericVerticalAlign::Length(lp));
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(GenericVerticalAlign::Keyword(VerticalAlignKeyword::parse(input)?))
|
Ok(GenericVerticalAlign::Keyword(VerticalAlignKeyword::parse(
|
||||||
|
input,
|
||||||
|
)?))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -510,13 +510,16 @@ impl Gradient {
|
||||||
items.sort_by(|a, b| {
|
items.sort_by(|a, b| {
|
||||||
match (a, b) {
|
match (a, b) {
|
||||||
(
|
(
|
||||||
&generic::GradientItem::ComplexColorStop { position: ref a_position, .. },
|
&generic::GradientItem::ComplexColorStop {
|
||||||
&generic::GradientItem::ComplexColorStop { position: ref b_position, .. },
|
position: ref a_position,
|
||||||
|
..
|
||||||
|
},
|
||||||
|
&generic::GradientItem::ComplexColorStop {
|
||||||
|
position: ref b_position,
|
||||||
|
..
|
||||||
|
},
|
||||||
) => match (a_position, b_position) {
|
) => match (a_position, b_position) {
|
||||||
(
|
(&LengthPercentage::Percentage(a), &LengthPercentage::Percentage(b)) => {
|
||||||
&LengthPercentage::Percentage(a),
|
|
||||||
&LengthPercentage::Percentage(b),
|
|
||||||
) => {
|
|
||||||
return a.0.partial_cmp(&b.0).unwrap_or(Ordering::Equal);
|
return a.0.partial_cmp(&b.0).unwrap_or(Ordering::Equal);
|
||||||
},
|
},
|
||||||
_ => {},
|
_ => {},
|
||||||
|
@ -786,7 +789,7 @@ impl LineDirection {
|
||||||
#[cfg(feature = "gecko")]
|
#[cfg(feature = "gecko")]
|
||||||
{
|
{
|
||||||
// `-moz-` prefixed linear gradient can be both Angle and Position.
|
// `-moz-` prefixed linear gradient can be both Angle and Position.
|
||||||
if *compat_mode == CompatMode::Moz && !simple_moz_gradient(){
|
if *compat_mode == CompatMode::Moz && !simple_moz_gradient() {
|
||||||
let position = i.try(|i| LegacyPosition::parse(context, i)).ok();
|
let position = i.try(|i| LegacyPosition::parse(context, i)).ok();
|
||||||
if _angle.is_none() {
|
if _angle.is_none() {
|
||||||
_angle = i.try(|i| Angle::parse(context, i)).ok();
|
_angle = i.try(|i| Angle::parse(context, i)).ok();
|
||||||
|
@ -961,10 +964,13 @@ impl GradientItem {
|
||||||
if let Ok(multi_position) = input.try(|i| LengthPercentage::parse(context, i)) {
|
if let Ok(multi_position) = input.try(|i| LengthPercentage::parse(context, i)) {
|
||||||
let stop_color = stop.color.clone();
|
let stop_color = stop.color.clone();
|
||||||
items.push(stop.into_item());
|
items.push(stop.into_item());
|
||||||
items.push(ColorStop {
|
items.push(
|
||||||
color: stop_color,
|
ColorStop {
|
||||||
position: Some(multi_position),
|
color: stop_color,
|
||||||
}.into_item());
|
position: Some(multi_position),
|
||||||
|
}
|
||||||
|
.into_item(),
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
items.push(stop.into_item());
|
items.push(stop.into_item());
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,10 +80,10 @@ pub use self::svg::{SVGLength, SVGOpacity, SVGPaint, SVGPaintKind};
|
||||||
pub use self::svg::{SVGPaintOrder, SVGStrokeDashArray, SVGWidth};
|
pub use self::svg::{SVGPaintOrder, SVGStrokeDashArray, SVGWidth};
|
||||||
pub use self::svg_path::SVGPathData;
|
pub use self::svg_path::SVGPathData;
|
||||||
pub use self::table::XSpan;
|
pub use self::table::XSpan;
|
||||||
|
pub use self::text::TextTransform;
|
||||||
pub use self::text::{InitialLetter, LetterSpacing, LineHeight, TextAlign};
|
pub use self::text::{InitialLetter, LetterSpacing, LineHeight, TextAlign};
|
||||||
pub use self::text::{OverflowWrap, TextEmphasisPosition, TextEmphasisStyle, WordBreak};
|
pub use self::text::{OverflowWrap, TextEmphasisPosition, TextEmphasisStyle, WordBreak};
|
||||||
pub use self::text::{TextAlignKeyword, TextDecorationLine, TextOverflow, WordSpacing};
|
pub use self::text::{TextAlignKeyword, TextDecorationLine, TextOverflow, WordSpacing};
|
||||||
pub use self::text::TextTransform;
|
|
||||||
pub use self::time::Time;
|
pub use self::time::Time;
|
||||||
pub use self::transform::{Rotate, Scale, Transform};
|
pub use self::transform::{Rotate, Scale, Transform};
|
||||||
pub use self::transform::{TransformOrigin, TransformStyle, Translate};
|
pub use self::transform::{TransformOrigin, TransformStyle, Translate};
|
||||||
|
|
|
@ -361,7 +361,8 @@ impl TextDecorationLine {
|
||||||
SpecifiedValueInfo,
|
SpecifiedValueInfo,
|
||||||
ToComputedValue,
|
ToComputedValue,
|
||||||
ToResolvedValue,
|
ToResolvedValue,
|
||||||
ToShmem)]
|
ToShmem,
|
||||||
|
)]
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
/// Specified value of the text-transform property, stored in two parts:
|
/// Specified value of the text-transform property, stored in two parts:
|
||||||
/// the case-related transforms (mutually exclusive, only one may be in effect), and others (non-exclusive).
|
/// the case-related transforms (mutually exclusive, only one may be in effect), and others (non-exclusive).
|
||||||
|
@ -468,7 +469,8 @@ impl ToCss for TextTransform {
|
||||||
ToComputedValue,
|
ToComputedValue,
|
||||||
ToCss,
|
ToCss,
|
||||||
ToResolvedValue,
|
ToResolvedValue,
|
||||||
ToShmem)]
|
ToShmem,
|
||||||
|
)]
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
/// Specified keyword values for case transforms in the text-transform property. (These are exclusive.)
|
/// Specified keyword values for case transforms in the text-transform property. (These are exclusive.)
|
||||||
pub enum TextTransformCase {
|
pub enum TextTransformCase {
|
||||||
|
@ -563,7 +565,9 @@ pub enum TextAlignKeyword {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Specified value of text-align property.
|
/// Specified value of text-align property.
|
||||||
#[derive(Clone, Copy, Debug, Eq, Hash, MallocSizeOf, Parse, PartialEq, SpecifiedValueInfo, ToCss, ToShmem)]
|
#[derive(
|
||||||
|
Clone, Copy, Debug, Eq, Hash, MallocSizeOf, Parse, PartialEq, SpecifiedValueInfo, ToCss, ToShmem,
|
||||||
|
)]
|
||||||
pub enum TextAlign {
|
pub enum TextAlign {
|
||||||
/// Keyword value of text-align property.
|
/// Keyword value of text-align property.
|
||||||
Keyword(TextAlignKeyword),
|
Keyword(TextAlignKeyword),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue