style: Fix formatting of recent changes.

This commit is contained in:
Emilio Cobos Álvarez 2019-08-15 15:41:34 +02:00
parent cea6966fd2
commit 4d8fc4b8f7
No known key found for this signature in database
GPG key ID: E1152D0994E4BF8A
9 changed files with 157 additions and 160 deletions

View file

@ -187,8 +187,9 @@ impl PseudoElement {
PseudoElement::FirstLine => PropertyFlags::APPLIES_TO_FIRST_LINE, PseudoElement::FirstLine => PropertyFlags::APPLIES_TO_FIRST_LINE,
PseudoElement::Placeholder => PropertyFlags::APPLIES_TO_PLACEHOLDER, PseudoElement::Placeholder => PropertyFlags::APPLIES_TO_PLACEHOLDER,
PseudoElement::Cue => PropertyFlags::APPLIES_TO_CUE, PseudoElement::Cue => PropertyFlags::APPLIES_TO_CUE,
PseudoElement::Marker if static_prefs::pref!("layout.css.marker.restricted") => PseudoElement::Marker if static_prefs::pref!("layout.css.marker.restricted") => {
PropertyFlags::APPLIES_TO_MARKER, PropertyFlags::APPLIES_TO_MARKER
},
_ => return None, _ => return None,
}) })
} }

View file

@ -8,12 +8,12 @@
use crate::dom::TElement; use crate::dom::TElement;
use crate::properties::computed_value_flags::ComputedValueFlags; use crate::properties::computed_value_flags::ComputedValueFlags;
use crate::properties::longhands::display::computed_value::T as Display; use crate::properties::longhands::display::computed_value::T as Display;
#[cfg(feature = "gecko")]
use crate::values::specified::box_::DisplayInside;
use crate::properties::longhands::float::computed_value::T as Float; use crate::properties::longhands::float::computed_value::T as Float;
use crate::properties::longhands::overflow_x::computed_value::T as Overflow; use crate::properties::longhands::overflow_x::computed_value::T as Overflow;
use crate::properties::longhands::position::computed_value::T as Position; use crate::properties::longhands::position::computed_value::T as Position;
use crate::properties::{self, ComputedValues, StyleBuilder}; use crate::properties::{self, ComputedValues, StyleBuilder};
#[cfg(feature = "gecko")]
use crate::values::specified::box_::DisplayInside;
use app_units::Au; use app_units::Au;
/// A struct that implements all the adjustment methods. /// A struct that implements all the adjustment methods.
@ -209,8 +209,10 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
#[cfg(feature = "gecko")] #[cfg(feature = "gecko")]
blockify_if!( blockify_if!(
self.style.pseudo.map_or(false, |p| p.is_marker()) && self.style.pseudo.map_or(false, |p| p.is_marker()) &&
self.style.get_parent_list().clone_list_style_position() == ListStylePosition::Outside && self.style.get_parent_list().clone_list_style_position() ==
layout_parent_style.get_box().clone_display().inside() != DisplayInside::Inline); ListStylePosition::Outside &&
layout_parent_style.get_box().clone_display().inside() != DisplayInside::Inline
);
if !blockify { if !blockify {
return; return;

View file

@ -76,10 +76,10 @@ pub use self::svg::MozContextProperties;
pub use self::svg::{SVGLength, SVGOpacity, SVGPaint, SVGPaintKind}; 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::table::XSpan; pub use self::table::XSpan;
pub use self::text::{TextDecorationLength, TextDecorationSkipInk};
pub use self::text::{InitialLetter, LetterSpacing, LineBreak, LineHeight}; pub use self::text::{InitialLetter, LetterSpacing, LineBreak, LineHeight};
pub use self::text::{OverflowWrap, TextOverflow, WordBreak, WordSpacing}; pub use self::text::{OverflowWrap, TextOverflow, WordBreak, WordSpacing};
pub use self::text::{TextAlign, TextEmphasisPosition, TextEmphasisStyle}; pub use self::text::{TextAlign, TextEmphasisPosition, TextEmphasisStyle};
pub use self::text::{TextDecorationLength, TextDecorationSkipInk};
pub use self::time::Time; pub use self::time::Time;
pub use self::transform::{Rotate, Scale, Transform, TransformOperation}; pub use self::transform::{Rotate, Scale, Transform, TransformOperation};
pub use self::transform::{TransformOrigin, TransformStyle, Translate}; pub use self::transform::{TransformOrigin, TransformStyle, Translate};

View file

@ -10,7 +10,7 @@ use crate::values::computed::length::{Length, LengthPercentage};
use crate::values::computed::{Context, NonNegativeLength, NonNegativeNumber, ToComputedValue}; use crate::values::computed::{Context, NonNegativeLength, NonNegativeNumber, ToComputedValue};
use crate::values::generics::text::InitialLetter as GenericInitialLetter; use crate::values::generics::text::InitialLetter as GenericInitialLetter;
use crate::values::generics::text::LineHeight as GenericLineHeight; use crate::values::generics::text::LineHeight as GenericLineHeight;
use crate::values::generics::text::{Spacing, GenericTextDecorationLength}; use crate::values::generics::text::{GenericTextDecorationLength, Spacing};
use crate::values::specified::text::{self as specified, TextOverflowSide}; use crate::values::specified::text::{self as specified, TextOverflowSide};
use crate::values::specified::text::{TextEmphasisFillMode, TextEmphasisShapeKeyword}; use crate::values::specified::text::{TextEmphasisFillMode, TextEmphasisShapeKeyword};
use crate::values::{CSSFloat, CSSInteger}; use crate::values::{CSSFloat, CSSInteger};

View file

@ -419,7 +419,7 @@ impl Parse for RepeatCount<specified::Integer> {
if i.value() > MAX_GRID_LINE { if i.value() > MAX_GRID_LINE {
i = specified::Integer::new(MAX_GRID_LINE); i = specified::Integer::new(MAX_GRID_LINE);
} }
return Ok(RepeatCount::Number(i)) return Ok(RepeatCount::Number(i));
} }
try_match_ident_ignore_ascii_case! { input, try_match_ident_ignore_ascii_case! { input,
"auto-fill" => Ok(RepeatCount::AutoFill), "auto-fill" => Ok(RepeatCount::AutoFill),
@ -527,7 +527,16 @@ impl<L, I> TrackListValue<L, I> {
/// A grid `<track-list>` type. /// A grid `<track-list>` type.
/// ///
/// <https://drafts.csswg.org/css-grid/#typedef-track-list> /// <https://drafts.csswg.org/css-grid/#typedef-track-list>
#[derive(Clone, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToComputedValue, ToResolvedValue, ToShmem)] #[derive(
Clone,
Debug,
MallocSizeOf,
PartialEq,
SpecifiedValueInfo,
ToComputedValue,
ToResolvedValue,
ToShmem,
)]
#[repr(C)] #[repr(C)]
pub struct GenericTrackList<LengthPercentage, Integer> { pub struct GenericTrackList<LengthPercentage, Integer> {
/// The index in `values` where our `<auto-repeat>` value is, if in bounds. /// The index in `values` where our `<auto-repeat>` value is, if in bounds.

View file

@ -51,18 +51,7 @@ fn parse_unimplemented_in_servo_2020(_context: &ParserContext) -> bool {
/// the two basic qualities of how an element generates boxes /// the two basic qualities of how an element generates boxes
/// <https://drafts.csswg.org/css-display/#propdef-display> /// <https://drafts.csswg.org/css-display/#propdef-display>
#[allow(missing_docs)] #[allow(missing_docs)]
#[derive( #[derive(Clone, Copy, Debug, Eq, FromPrimitive, Hash, MallocSizeOf, PartialEq, ToCss, ToShmem)]
MallocSizeOf,
ToShmem,
Clone,
Copy,
Debug,
Eq,
FromPrimitive,
Hash,
PartialEq,
ToCss,
)]
#[cfg(feature = "gecko")] #[cfg(feature = "gecko")]
#[repr(u8)] #[repr(u8)]
pub enum DisplayOutside { pub enum DisplayOutside {
@ -76,18 +65,7 @@ pub enum DisplayOutside {
} }
#[allow(missing_docs)] #[allow(missing_docs)]
#[derive( #[derive(Clone, Copy, Debug, Eq, FromPrimitive, Hash, MallocSizeOf, PartialEq, ToCss, ToShmem)]
MallocSizeOf,
ToShmem,
Clone,
Copy,
Debug,
Eq,
FromPrimitive,
Hash,
PartialEq,
ToCss,
)]
#[cfg(feature = "gecko")] #[cfg(feature = "gecko")]
#[repr(u8)] #[repr(u8)]
pub enum DisplayInside { pub enum DisplayInside {
@ -174,19 +152,36 @@ impl Display {
pub const ListItem: Self = Self::new_list_item(DisplayOutside::Block, DisplayInside::Block); pub const ListItem: Self = Self::new_list_item(DisplayOutside::Block, DisplayInside::Block);
/// Internal table boxes. /// Internal table boxes.
pub const TableRowGroup : Self = Self::new(DisplayOutside::InternalTable, DisplayInside::TableRowGroup); pub const TableRowGroup: Self =
pub const TableHeaderGroup : Self = Self::new(DisplayOutside::InternalTable, DisplayInside::TableHeaderGroup); Self::new(DisplayOutside::InternalTable, DisplayInside::TableRowGroup);
pub const TableFooterGroup : Self = Self::new(DisplayOutside::InternalTable, DisplayInside::TableFooterGroup); pub const TableHeaderGroup: Self = Self::new(
pub const TableColumn : Self = Self::new(DisplayOutside::InternalTable, DisplayInside::TableColumn); DisplayOutside::InternalTable,
pub const TableColumnGroup : Self = Self::new(DisplayOutside::InternalTable, DisplayInside::TableColumnGroup); DisplayInside::TableHeaderGroup,
);
pub const TableFooterGroup: Self = Self::new(
DisplayOutside::InternalTable,
DisplayInside::TableFooterGroup,
);
pub const TableColumn: Self =
Self::new(DisplayOutside::InternalTable, DisplayInside::TableColumn);
pub const TableColumnGroup: Self = Self::new(
DisplayOutside::InternalTable,
DisplayInside::TableColumnGroup,
);
pub const TableRow: Self = Self::new(DisplayOutside::InternalTable, DisplayInside::TableRow); pub const TableRow: Self = Self::new(DisplayOutside::InternalTable, DisplayInside::TableRow);
pub const TableCell: Self = Self::new(DisplayOutside::InternalTable, DisplayInside::TableCell); pub const TableCell: Self = Self::new(DisplayOutside::InternalTable, DisplayInside::TableCell);
/// Internal ruby boxes. /// Internal ruby boxes.
pub const RubyBase: Self = Self::new(DisplayOutside::InternalRuby, DisplayInside::RubyBase); pub const RubyBase: Self = Self::new(DisplayOutside::InternalRuby, DisplayInside::RubyBase);
pub const RubyBaseContainer : Self = Self::new(DisplayOutside::InternalRuby, DisplayInside::RubyBaseContainer); pub const RubyBaseContainer: Self = Self::new(
DisplayOutside::InternalRuby,
DisplayInside::RubyBaseContainer,
);
pub const RubyText: Self = Self::new(DisplayOutside::InternalRuby, DisplayInside::RubyText); pub const RubyText: Self = Self::new(DisplayOutside::InternalRuby, DisplayInside::RubyText);
pub const RubyTextContainer : Self = Self::new(DisplayOutside::InternalRuby, DisplayInside::RubyTextContainer); pub const RubyTextContainer: Self = Self::new(
DisplayOutside::InternalRuby,
DisplayInside::RubyTextContainer,
);
/// XUL boxes. /// XUL boxes.
pub const MozBox: Self = Self::new(DisplayOutside::XUL, DisplayInside::MozBox); pub const MozBox: Self = Self::new(DisplayOutside::XUL, DisplayInside::MozBox);
@ -245,8 +240,9 @@ impl Display {
#[inline] #[inline]
pub fn outside(&self) -> DisplayOutside { pub fn outside(&self) -> DisplayOutside {
DisplayOutside::from_u16( DisplayOutside::from_u16(
(self.0 >> Self::DISPLAY_INSIDE_BITS) & ((1 << Self::DISPLAY_OUTSIDE_BITS) - 1) (self.0 >> Self::DISPLAY_INSIDE_BITS) & ((1 << Self::DISPLAY_OUTSIDE_BITS) - 1),
).unwrap() )
.unwrap()
} }
/// Returns whether this `display` value is some kind of list-item. /// Returns whether this `display` value is some kind of list-item.
@ -443,12 +439,10 @@ impl Display {
}; };
Display::from3(DisplayOutside::Inline, inside, self.is_list_item()) Display::from3(DisplayOutside::Inline, inside, self.is_list_item())
}, },
DisplayOutside::XUL => { DisplayOutside::XUL => match self.inside() {
match self.inside() {
DisplayInside::MozBox => Display::MozInlineBox, DisplayInside::MozBox => Display::MozInlineBox,
DisplayInside::MozStack => Display::MozInlineStack, DisplayInside::MozStack => Display::MozInlineStack,
_ => *self, _ => *self,
}
}, },
_ => *self, _ => *self,
} }
@ -477,8 +471,11 @@ impl ToCss for Display {
where where
W: fmt::Write, W: fmt::Write,
{ {
debug_assert_ne!(self.inside(), DisplayInside::Flow, debug_assert_ne!(
"`flow` never appears in `display` computed value"); self.inside(),
DisplayInside::Flow,
"`flow` never appears in `display` computed value"
);
let outside = self.outside(); let outside = self.outside();
let inside = match self.inside() { let inside = match self.inside() {
DisplayInside::Block | DisplayInside::Inline => DisplayInside::Flow, DisplayInside::Block | DisplayInside::Inline => DisplayInside::Flow,
@ -499,10 +496,8 @@ impl ToCss for Display {
(DisplayOutside::Inline, DisplayInside::Table) => { (DisplayOutside::Inline, DisplayInside::Table) => {
dest.write_str("inline-")?; dest.write_str("inline-")?;
inside.to_css(dest) inside.to_css(dest)
} },
(DisplayOutside::Block, DisplayInside::Ruby) => { (DisplayOutside::Block, DisplayInside::Ruby) => dest.write_str("block ruby"),
dest.write_str("block ruby")
}
(_, inside) => { (_, inside) => {
if self.is_list_item() { if self.is_list_item() {
if outside != DisplayOutside::Block { if outside != DisplayOutside::Block {
@ -517,8 +512,8 @@ impl ToCss for Display {
} else { } else {
inside.to_css(dest) inside.to_css(dest)
} }
} },
} },
} }
} }
} }
@ -565,17 +560,16 @@ fn parse_display_inside_for_list_item<'i, 't>(
} }
/// Test a <display-inside> Result for same values as above. /// Test a <display-inside> Result for same values as above.
#[cfg(feature = "gecko")] #[cfg(feature = "gecko")]
fn is_valid_inside_for_list_item<'i>( fn is_valid_inside_for_list_item<'i>(inside: &Result<DisplayInside, ParseError<'i>>) -> bool {
inside: &Result<DisplayInside, ParseError<'i>>, matches!(
) -> bool { inside,
matches!(inside, Ok(DisplayInside::Flow) | Ok(DisplayInside::FlowRoot)) Ok(DisplayInside::Flow) | Ok(DisplayInside::FlowRoot)
)
} }
/// Parse `list-item`. /// Parse `list-item`.
#[cfg(feature = "gecko")] #[cfg(feature = "gecko")]
fn parse_list_item<'i, 't>( fn parse_list_item<'i, 't>(input: &mut Parser<'i, 't>) -> Result<(), ParseError<'i>> {
input: &mut Parser<'i, 't>,
) -> Result<(), ParseError<'i>> {
Ok(try_match_ident_ignore_ascii_case! { input, Ok(try_match_ident_ignore_ascii_case! { input,
"list-item" => (), "list-item" => (),
}) })
@ -617,15 +611,13 @@ impl Parse for Display {
} }
if got_list_item || inside.is_ok() || outside.is_ok() { if got_list_item || inside.is_ok() || outside.is_ok() {
let inside = inside.unwrap_or(DisplayInside::Flow); let inside = inside.unwrap_or(DisplayInside::Flow);
let outside = outside.unwrap_or( let outside = outside.unwrap_or(match inside {
match inside {
// "If <display-outside> is omitted, the elements outside display type // "If <display-outside> is omitted, the elements outside display type
// defaults to block — except for ruby, which defaults to inline." // defaults to block — except for ruby, which defaults to inline."
// https://drafts.csswg.org/css-display/#inside-model // https://drafts.csswg.org/css-display/#inside-model
DisplayInside::Ruby => DisplayOutside::Inline, DisplayInside::Ruby => DisplayOutside::Inline,
_ => DisplayOutside::Block, _ => DisplayOutside::Block,
} });
);
return Ok(Display::from3(outside, inside, got_list_item)); return Ok(Display::from3(outside, inside, got_list_item));
} }
@ -671,7 +663,8 @@ impl Parse for Display {
#[cfg(feature = "gecko")] #[cfg(feature = "gecko")]
impl SpecifiedValueInfo for Display { impl SpecifiedValueInfo for Display {
fn collect_completion_keywords(f: KeywordsCollectFn) { fn collect_completion_keywords(f: KeywordsCollectFn) {
f(&["block", f(&[
"block",
"contents", "contents",
"flex", "flex",
"flow-root", "flow-root",

View file

@ -169,8 +169,7 @@ impl TrackRepeat<LengthPercentage, Integer> {
let mut current_names; let mut current_names;
loop { loop {
current_names = current_names = input.try(parse_line_names).unwrap_or_default();
input.try(parse_line_names).unwrap_or_default();
if let Ok(track_size) = input.try(|i| TrackSize::parse(context, i)) { if let Ok(track_size) = input.try(|i| TrackSize::parse(context, i)) {
if !track_size.is_fixed() { if !track_size.is_fixed() {
if is_auto { if is_auto {
@ -193,11 +192,7 @@ impl TrackRepeat<LengthPercentage, Integer> {
// one `TrackSize`. But in current version of the spec, this is deprecated // one `TrackSize`. But in current version of the spec, this is deprecated
// but we are adding this for gecko parity. We should remove this when // but we are adding this for gecko parity. We should remove this when
// gecko implements new spec. // gecko implements new spec.
names.push( names.push(input.try(parse_line_names).unwrap_or_default());
input
.try(parse_line_names)
.unwrap_or_default()
);
break; break;
} }
} else { } else {
@ -239,11 +234,7 @@ impl Parse for TrackList<LengthPercentage, Integer> {
// assume that everything is <fixed-size>. This flag is useful when we encounter <auto-repeat> // assume that everything is <fixed-size>. This flag is useful when we encounter <auto-repeat>
let mut at_least_one_not_fixed = false; let mut at_least_one_not_fixed = false;
loop { loop {
current_names.extend_from_slice( current_names.extend_from_slice(&mut input.try(parse_line_names).unwrap_or_default());
&mut input
.try(parse_line_names)
.unwrap_or_default()
);
if let Ok(track_size) = input.try(|i| TrackSize::parse(context, i)) { if let Ok(track_size) = input.try(|i| TrackSize::parse(context, i)) {
if !track_size.is_fixed() { if !track_size.is_fixed() {
at_least_one_not_fixed = true; at_least_one_not_fixed = true;

View file

@ -12,7 +12,7 @@ use crate::values::computed::text::TextOverflow as ComputedTextOverflow;
use crate::values::computed::{Context, ToComputedValue}; use crate::values::computed::{Context, ToComputedValue};
use crate::values::generics::text::InitialLetter as GenericInitialLetter; use crate::values::generics::text::InitialLetter as GenericInitialLetter;
use crate::values::generics::text::LineHeight as GenericLineHeight; use crate::values::generics::text::LineHeight as GenericLineHeight;
use crate::values::generics::text::{Spacing, GenericTextDecorationLength}; use crate::values::generics::text::{GenericTextDecorationLength, Spacing};
use crate::values::specified::length::NonNegativeLengthPercentage; use crate::values::specified::length::NonNegativeLengthPercentage;
use crate::values::specified::length::{FontRelativeLength, Length}; use crate::values::specified::length::{FontRelativeLength, Length};
use crate::values::specified::length::{LengthPercentage, NoCalcLength}; use crate::values::specified::length::{LengthPercentage, NoCalcLength};

View file

@ -56,6 +56,7 @@ files = [
"./components/net/tests/parsable_mime/text", "./components/net/tests/parsable_mime/text",
# Mako does not lend itself easily to splitting long lines # Mako does not lend itself easily to splitting long lines
"./components/style/properties/helpers/animated_properties.mako.rs", "./components/style/properties/helpers/animated_properties.mako.rs",
"./components/style/properties/shorthands/text.mako.rs",
# Long regexes are long. # Long regexes are long.
"./components/style/gecko/regen_atoms.py", "./components/style/gecko/regen_atoms.py",
# Helper macro where actually a pseudo-element per line makes sense. # Helper macro where actually a pseudo-element per line makes sense.