mirror of
https://github.com/servo/servo.git
synced 2025-08-07 22:45:34 +01:00
style: Reformat recent changes.
This commit is contained in:
parent
7c96aed31d
commit
f76acc84c6
30 changed files with 330 additions and 191 deletions
|
@ -126,12 +126,7 @@ impl Parse for ClipPath {
|
|||
return Ok(ClipPath::Url(url));
|
||||
}
|
||||
|
||||
parse_shape_or_box(
|
||||
context,
|
||||
input,
|
||||
ClipPath::Shape,
|
||||
ClipPath::Box,
|
||||
)
|
||||
parse_shape_or_box(context, input, ClipPath::Shape, ClipPath::Box)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -152,12 +147,7 @@ impl Parse for ShapeOutside {
|
|||
return Ok(ShapeOutside::Image(image));
|
||||
}
|
||||
|
||||
parse_shape_or_box(
|
||||
context,
|
||||
input,
|
||||
ShapeOutside::Shape,
|
||||
ShapeOutside::Box,
|
||||
)
|
||||
parse_shape_or_box(context, input, ShapeOutside::Shape, ShapeOutside::Box)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -15,8 +15,8 @@ use crate::values::specified::{self, Angle, Time};
|
|||
use crate::values::{CSSFloat, CSSInteger};
|
||||
use cssparser::{AngleOrNumber, CowRcStr, NumberOrPercentage, Parser, Token};
|
||||
use smallvec::SmallVec;
|
||||
use std::fmt::{self, Write};
|
||||
use std::cmp;
|
||||
use std::fmt::{self, Write};
|
||||
use style_traits::values::specified::AllowedNumericType;
|
||||
use style_traits::{CssWriter, ParseError, SpecifiedValueInfo, StyleParseErrorKind, ToCss};
|
||||
|
||||
|
@ -116,8 +116,10 @@ impl PartialOrd for Leaf {
|
|||
match *self {
|
||||
Length(..) | Percentage(..) | Angle(..) | Time(..) | Number(..) => {},
|
||||
}
|
||||
unsafe { debug_unreachable!("Forgot a branch?"); }
|
||||
}
|
||||
unsafe {
|
||||
debug_unreachable!("Forgot a branch?");
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -126,8 +128,7 @@ impl generic::CalcNodeLeaf for Leaf {
|
|||
fn is_negative(&self) -> bool {
|
||||
match *self {
|
||||
Self::Length(ref l) => l.is_negative(),
|
||||
Self::Percentage(n) |
|
||||
Self::Number(n) => n < 0.,
|
||||
Self::Percentage(n) | Self::Number(n) => n < 0.,
|
||||
Self::Angle(ref a) => a.degrees() < 0.,
|
||||
Self::Time(ref t) => t.seconds() < 0.,
|
||||
}
|
||||
|
@ -215,8 +216,10 @@ impl generic::CalcNodeLeaf for Leaf {
|
|||
match *other {
|
||||
Number(..) | Percentage(..) | Angle(..) | Time(..) | Length(..) => {},
|
||||
}
|
||||
unsafe { debug_unreachable!(); }
|
||||
}
|
||||
unsafe {
|
||||
debug_unreachable!();
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
@ -252,11 +255,9 @@ impl CalcNode {
|
|||
value, ref unit, ..
|
||||
},
|
||||
CalcUnit::LengthPercentage,
|
||||
) => {
|
||||
match NoCalcLength::parse_dimension(context, value, unit) {
|
||||
Ok(l) => Ok(CalcNode::Leaf(Leaf::Length(l))),
|
||||
Err(()) => Err(location.new_custom_error(StyleParseErrorKind::UnspecifiedError)),
|
||||
}
|
||||
) => match NoCalcLength::parse_dimension(context, value, unit) {
|
||||
Ok(l) => Ok(CalcNode::Leaf(Leaf::Length(l))),
|
||||
Err(()) => Err(location.new_custom_error(StyleParseErrorKind::UnspecifiedError)),
|
||||
},
|
||||
(
|
||||
&Token::Dimension {
|
||||
|
@ -266,7 +267,9 @@ impl CalcNode {
|
|||
) => {
|
||||
match Angle::parse_dimension(value, unit, /* from_calc = */ true) {
|
||||
Ok(a) => Ok(CalcNode::Leaf(Leaf::Angle(a))),
|
||||
Err(()) => Err(location.new_custom_error(StyleParseErrorKind::UnspecifiedError)),
|
||||
Err(()) => {
|
||||
Err(location.new_custom_error(StyleParseErrorKind::UnspecifiedError))
|
||||
},
|
||||
}
|
||||
},
|
||||
(
|
||||
|
@ -277,7 +280,9 @@ impl CalcNode {
|
|||
) => {
|
||||
match Time::parse_dimension(value, unit, /* from_calc = */ true) {
|
||||
Ok(t) => Ok(CalcNode::Leaf(Leaf::Time(t))),
|
||||
Err(()) => Err(location.new_custom_error(StyleParseErrorKind::UnspecifiedError)),
|
||||
Err(()) => {
|
||||
Err(location.new_custom_error(StyleParseErrorKind::UnspecifiedError))
|
||||
},
|
||||
}
|
||||
},
|
||||
(&Token::Percentage { unit_value, .. }, CalcUnit::LengthPercentage) |
|
||||
|
@ -328,10 +333,9 @@ impl CalcNode {
|
|||
//
|
||||
// Consider adding an API to cssparser to specify the
|
||||
// initial vector capacity?
|
||||
let arguments = input
|
||||
.parse_comma_separated(|input| {
|
||||
Self::parse_argument(context, input, expected_unit)
|
||||
})?;
|
||||
let arguments = input.parse_comma_separated(|input| {
|
||||
Self::parse_argument(context, input, expected_unit)
|
||||
})?;
|
||||
|
||||
let op = match function {
|
||||
MathFunction::Min => MinMaxOp::Min,
|
||||
|
@ -474,43 +478,35 @@ impl CalcNode {
|
|||
|
||||
/// Tries to simplify this expression into a `<time>` value.
|
||||
fn to_time(&self) -> Result<Time, ()> {
|
||||
let seconds = self.resolve(|leaf| {
|
||||
match *leaf {
|
||||
Leaf::Time(ref t) => Ok(t.seconds()),
|
||||
_ => Err(()),
|
||||
}
|
||||
let seconds = self.resolve(|leaf| match *leaf {
|
||||
Leaf::Time(ref t) => Ok(t.seconds()),
|
||||
_ => Err(()),
|
||||
})?;
|
||||
Ok(Time::from_calc(seconds))
|
||||
}
|
||||
|
||||
/// Tries to simplify this expression into an `Angle` value.
|
||||
fn to_angle(&self) -> Result<Angle, ()> {
|
||||
let degrees = self.resolve(|leaf| {
|
||||
match *leaf {
|
||||
Leaf::Angle(ref angle) => Ok(angle.degrees()),
|
||||
_ => Err(()),
|
||||
}
|
||||
let degrees = self.resolve(|leaf| match *leaf {
|
||||
Leaf::Angle(ref angle) => Ok(angle.degrees()),
|
||||
_ => Err(()),
|
||||
})?;
|
||||
Ok(Angle::from_calc(degrees))
|
||||
}
|
||||
|
||||
/// Tries to simplify this expression into a `<number>` value.
|
||||
fn to_number(&self) -> Result<CSSFloat, ()> {
|
||||
self.resolve(|leaf| {
|
||||
match *leaf {
|
||||
Leaf::Number(n) => Ok(n),
|
||||
_ => Err(()),
|
||||
}
|
||||
self.resolve(|leaf| match *leaf {
|
||||
Leaf::Number(n) => Ok(n),
|
||||
_ => Err(()),
|
||||
})
|
||||
}
|
||||
|
||||
/// Tries to simplify this expression into a `<percentage>` value.
|
||||
fn to_percentage(&self) -> Result<CSSFloat, ()> {
|
||||
self.resolve(|leaf| {
|
||||
match *leaf {
|
||||
Leaf::Percentage(p) => Ok(p),
|
||||
_ => Err(()),
|
||||
}
|
||||
self.resolve(|leaf| match *leaf {
|
||||
Leaf::Percentage(p) => Ok(p),
|
||||
_ => Err(()),
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,8 @@ use crate::values::specified::position::{HorizontalPositionKeyword, VerticalPosi
|
|||
use crate::values::specified::position::{Position, PositionComponent, Side};
|
||||
use crate::values::specified::url::SpecifiedImageUrl;
|
||||
use crate::values::specified::{
|
||||
Angle, AngleOrPercentage, Color, Length, LengthPercentage, NonNegativeLength, NonNegativeLengthPercentage,
|
||||
Angle, AngleOrPercentage, Color, Length, LengthPercentage, NonNegativeLength,
|
||||
NonNegativeLengthPercentage,
|
||||
};
|
||||
use crate::values::specified::{Number, NumberOrPercentage, Percentage};
|
||||
use crate::Atom;
|
||||
|
@ -73,10 +74,7 @@ impl SpecifiedValueInfo for Gradient {
|
|||
]);
|
||||
|
||||
if static_prefs::pref!("layout.css.conic-gradient.enabled") {
|
||||
f(&[
|
||||
"conic-gradient",
|
||||
"repeating-conic-gradient",
|
||||
]);
|
||||
f(&["conic-gradient", "repeating-conic-gradient"]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -527,7 +525,8 @@ impl Gradient {
|
|||
context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>,
|
||||
) -> Result<LengthPercentageItemList, ParseError<'i>> {
|
||||
let items = generic::GradientItem::parse_comma_separated(context, input, LengthPercentage::parse)?;
|
||||
let items =
|
||||
generic::GradientItem::parse_comma_separated(context, input, LengthPercentage::parse)?;
|
||||
if items.len() < 2 {
|
||||
return Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError));
|
||||
}
|
||||
|
@ -633,7 +632,11 @@ impl Gradient {
|
|||
|
||||
let angle = angle.unwrap_or(Angle::zero());
|
||||
let position = position.unwrap_or(Position::center());
|
||||
let items = generic::GradientItem::parse_comma_separated(context, input, AngleOrPercentage::parse_with_unitless)?;
|
||||
let items = generic::GradientItem::parse_comma_separated(
|
||||
context,
|
||||
input,
|
||||
AngleOrPercentage::parse_with_unitless,
|
||||
)?;
|
||||
|
||||
if items.len() < 2 {
|
||||
return Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError));
|
||||
|
@ -853,7 +856,8 @@ impl<T> generic::GradientItem<Color, T> {
|
|||
fn parse_comma_separated<'i, 't>(
|
||||
context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>,
|
||||
parse_position: impl for<'i1, 't1> Fn(&ParserContext, &mut Parser<'i1, 't1>) -> Result<T, ParseError<'i1>> + Copy,
|
||||
parse_position: impl for<'i1, 't1> Fn(&ParserContext, &mut Parser<'i1, 't1>) -> Result<T, ParseError<'i1>>
|
||||
+ Copy,
|
||||
) -> Result<crate::OwnedSlice<Self>, ParseError<'i>> {
|
||||
let mut items = Vec::new();
|
||||
let mut seen_stop = false;
|
||||
|
@ -906,7 +910,10 @@ impl<T> generic::ColorStop<Color, T> {
|
|||
fn parse<'i, 't>(
|
||||
context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>,
|
||||
parse_position: impl for<'i1, 't1> Fn(&ParserContext, &mut Parser<'i1, 't1>) -> Result<T, ParseError<'i1>>,
|
||||
parse_position: impl for<'i1, 't1> Fn(
|
||||
&ParserContext,
|
||||
&mut Parser<'i1, 't1>,
|
||||
) -> Result<T, ParseError<'i1>>,
|
||||
) -> Result<Self, ParseError<'i>> {
|
||||
Ok(generic::ColorStop {
|
||||
color: Color::parse(context, input)?,
|
||||
|
|
|
@ -28,8 +28,8 @@ use std::ops::{Add, Mul};
|
|||
use style_traits::values::specified::AllowedNumericType;
|
||||
use style_traits::{ParseError, SpecifiedValueInfo, StyleParseErrorKind};
|
||||
|
||||
pub use super::image::{EndingShape as GradientEndingShape, Gradient};
|
||||
pub use super::image::Image;
|
||||
pub use super::image::{EndingShape as GradientEndingShape, Gradient};
|
||||
pub use crate::values::specified::calc::CalcLengthPercentage;
|
||||
|
||||
/// Number of app units per pixel
|
||||
|
|
|
@ -80,12 +80,12 @@ pub use self::svg::MozContextProperties;
|
|||
pub use self::svg::{SVGLength, SVGOpacity, SVGPaint};
|
||||
pub use self::svg::{SVGPaintOrder, SVGStrokeDashArray, SVGWidth};
|
||||
pub use self::svg_path::SVGPathData;
|
||||
pub use self::text::TextAlignLast;
|
||||
pub use self::text::TextUnderlinePosition;
|
||||
pub use self::text::{InitialLetter, LetterSpacing, LineBreak, LineHeight, TextAlign};
|
||||
pub use self::text::{OverflowWrap, TextEmphasisPosition, TextEmphasisStyle, WordBreak};
|
||||
pub use self::text::{TextAlignKeyword, TextDecorationLine, TextOverflow, WordSpacing};
|
||||
pub use self::text::{TextDecorationLength, TextDecorationSkipInk, TextTransform};
|
||||
pub use self::text::TextAlignLast;
|
||||
pub use self::time::Time;
|
||||
pub use self::transform::{Rotate, Scale, Transform};
|
||||
pub use self::transform::{TransformOrigin, TransformStyle, Translate};
|
||||
|
|
|
@ -35,8 +35,7 @@ use style_traits::{CssWriter, ParseError, StyleParseErrorKind, ToCss};
|
|||
pub struct SVGPathData(
|
||||
// TODO(emilio): Should probably measure this somehow only from the
|
||||
// specified values.
|
||||
#[ignore_malloc_size_of = "Arc"]
|
||||
pub crate::ArcSlice<PathCommand>,
|
||||
#[ignore_malloc_size_of = "Arc"] pub crate::ArcSlice<PathCommand>,
|
||||
);
|
||||
|
||||
impl SVGPathData {
|
||||
|
@ -541,7 +540,17 @@ impl CoordPair {
|
|||
|
||||
/// The EllipticalArc flag type.
|
||||
#[derive(
|
||||
Clone, Copy, Debug, Deserialize, MallocSizeOf, PartialEq, Serialize, SpecifiedValueInfo, ToComputedValue, ToResolvedValue, ToShmem,
|
||||
Clone,
|
||||
Copy,
|
||||
Debug,
|
||||
Deserialize,
|
||||
MallocSizeOf,
|
||||
PartialEq,
|
||||
Serialize,
|
||||
SpecifiedValueInfo,
|
||||
ToComputedValue,
|
||||
ToResolvedValue,
|
||||
ToShmem,
|
||||
)]
|
||||
#[repr(C)]
|
||||
pub struct ArcFlag(bool);
|
||||
|
|
|
@ -122,7 +122,18 @@ impl ToComputedValue for LineHeight {
|
|||
}
|
||||
|
||||
/// A generic value for the `text-overflow` property.
|
||||
#[derive(Clone, Debug, Eq, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToComputedValue, ToCss, ToResolvedValue, ToShmem)]
|
||||
#[derive(
|
||||
Clone,
|
||||
Debug,
|
||||
Eq,
|
||||
MallocSizeOf,
|
||||
PartialEq,
|
||||
SpecifiedValueInfo,
|
||||
ToComputedValue,
|
||||
ToCss,
|
||||
ToResolvedValue,
|
||||
ToShmem,
|
||||
)]
|
||||
#[repr(C, u8)]
|
||||
pub enum TextOverflowSide {
|
||||
/// Clip inline content.
|
||||
|
@ -687,7 +698,19 @@ pub enum TextEmphasisStyle {
|
|||
}
|
||||
|
||||
/// Fill mode for the text-emphasis-style property
|
||||
#[derive(Clone, Copy, Debug, MallocSizeOf, Parse, PartialEq, SpecifiedValueInfo, ToCss, ToComputedValue, ToResolvedValue, ToShmem)]
|
||||
#[derive(
|
||||
Clone,
|
||||
Copy,
|
||||
Debug,
|
||||
MallocSizeOf,
|
||||
Parse,
|
||||
PartialEq,
|
||||
SpecifiedValueInfo,
|
||||
ToCss,
|
||||
ToComputedValue,
|
||||
ToResolvedValue,
|
||||
ToShmem,
|
||||
)]
|
||||
#[repr(u8)]
|
||||
pub enum TextEmphasisFillMode {
|
||||
/// `filled`
|
||||
|
|
|
@ -58,7 +58,12 @@ impl Parse for CursorImage {
|
|||
hotspot_y = Number::parse(context, input)?;
|
||||
}
|
||||
|
||||
Ok(Self { url, has_hotspot, hotspot_x, hotspot_y })
|
||||
Ok(Self {
|
||||
url,
|
||||
has_hotspot,
|
||||
hotspot_x,
|
||||
hotspot_y,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue