mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
style: Rustfmt recent changes.
This commit is contained in:
parent
71daec59eb
commit
be616c31e8
15 changed files with 41 additions and 37 deletions
|
@ -85,7 +85,9 @@ impl Device {
|
||||||
assert!(!pres_context.is_null());
|
assert!(!pres_context.is_null());
|
||||||
Device {
|
Device {
|
||||||
pres_context,
|
pres_context,
|
||||||
default_values: ComputedValues::default_values(unsafe { &*(*pres_context).mDocument.mRawPtr }),
|
default_values: ComputedValues::default_values(unsafe {
|
||||||
|
&*(*pres_context).mDocument.mRawPtr
|
||||||
|
}),
|
||||||
// FIXME(bz): Seems dubious?
|
// FIXME(bz): Seems dubious?
|
||||||
root_font_size: AtomicIsize::new(FontSize::medium().size().0 as isize),
|
root_font_size: AtomicIsize::new(FontSize::medium().size().0 as isize),
|
||||||
body_text_color: AtomicUsize::new(unsafe { &*pres_context }.mDefaultColor as usize),
|
body_text_color: AtomicUsize::new(unsafe { &*pres_context }.mDefaultColor as usize),
|
||||||
|
|
|
@ -8,7 +8,9 @@ use crate::gecko::values::{convert_nscolor_to_rgba, convert_rgba_to_nscolor};
|
||||||
use crate::gecko_bindings::structs::StyleComplexColor;
|
use crate::gecko_bindings::structs::StyleComplexColor;
|
||||||
use crate::gecko_bindings::structs::StyleComplexColor_Tag as Tag;
|
use crate::gecko_bindings::structs::StyleComplexColor_Tag as Tag;
|
||||||
use crate::values::computed::{Color as ComputedColor, ColorOrAuto, RGBAColor as ComputedRGBA};
|
use crate::values::computed::{Color as ComputedColor, ColorOrAuto, RGBAColor as ComputedRGBA};
|
||||||
use crate::values::generics::color::{Color as GenericColor, ColorOrAuto as GenericColorOrAuto, ComplexColorRatios};
|
use crate::values::generics::color::{
|
||||||
|
Color as GenericColor, ColorOrAuto as GenericColorOrAuto, ComplexColorRatios,
|
||||||
|
};
|
||||||
|
|
||||||
impl StyleComplexColor {
|
impl StyleComplexColor {
|
||||||
/// Create a `StyleComplexColor` value that represents `currentColor`.
|
/// Create a `StyleComplexColor` value that represents `currentColor`.
|
||||||
|
|
|
@ -9,7 +9,9 @@ use crate::values::animated::ToAnimatedValue;
|
||||||
use crate::values::computed::NonNegativeNumber;
|
use crate::values::computed::NonNegativeNumber;
|
||||||
use crate::values::distance::{ComputeSquaredDistance, SquaredDistance};
|
use crate::values::distance::{ComputeSquaredDistance, SquaredDistance};
|
||||||
use crate::values::generics::length as generics;
|
use crate::values::generics::length as generics;
|
||||||
use crate::values::generics::length::{MaxSize as GenericMaxSize, Size as GenericSize, GenericLengthOrNumber};
|
use crate::values::generics::length::{
|
||||||
|
GenericLengthOrNumber, MaxSize as GenericMaxSize, Size as GenericSize,
|
||||||
|
};
|
||||||
use crate::values::generics::transform::IsZeroLength;
|
use crate::values::generics::transform::IsZeroLength;
|
||||||
use crate::values::generics::NonNegative;
|
use crate::values::generics::NonNegative;
|
||||||
use crate::values::specified::length::ViewportPercentageLength;
|
use crate::values::specified::length::ViewportPercentageLength;
|
||||||
|
|
|
@ -21,7 +21,8 @@ pub type TransformOperation =
|
||||||
pub type Transform = generic::Transform<TransformOperation>;
|
pub type Transform = generic::Transform<TransformOperation>;
|
||||||
|
|
||||||
/// The computed value of a CSS `<transform-origin>`
|
/// The computed value of a CSS `<transform-origin>`
|
||||||
pub type TransformOrigin = generic::GenericTransformOrigin<LengthPercentage, LengthPercentage, Length>;
|
pub type TransformOrigin =
|
||||||
|
generic::GenericTransformOrigin<LengthPercentage, LengthPercentage, Length>;
|
||||||
|
|
||||||
/// A vector to represent the direction vector (rotate axis) for Rotate3D.
|
/// A vector to represent the direction vector (rotate axis) for Rotate3D.
|
||||||
pub type DirectionVector = Vector3D<CSSFloat>;
|
pub type DirectionVector = Vector3D<CSSFloat>;
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
//! Generic types for CSS values related to backgrounds.
|
//! Generic types for CSS values related to backgrounds.
|
||||||
|
|
||||||
use crate::values::generics::length::{LengthPercentageOrAuto, GenericLengthPercentageOrAuto};
|
use crate::values::generics::length::{GenericLengthPercentageOrAuto, LengthPercentageOrAuto};
|
||||||
use std::fmt::{self, Write};
|
use std::fmt::{self, Write};
|
||||||
use style_traits::{CssWriter, ToCss};
|
use style_traits::{CssWriter, ToCss};
|
||||||
|
|
||||||
|
|
|
@ -127,8 +127,8 @@ impl Parse for CounterStyleOrNone {
|
||||||
let symbols = Symbols::parse(context, input)?;
|
let symbols = Symbols::parse(context, input)?;
|
||||||
// There must be at least two symbols for alphabetic or
|
// There must be at least two symbols for alphabetic or
|
||||||
// numeric system.
|
// numeric system.
|
||||||
if (symbols_type == SymbolsType::Alphabetic ||
|
if (symbols_type == SymbolsType::Alphabetic || symbols_type == SymbolsType::Numeric) &&
|
||||||
symbols_type == SymbolsType::Numeric) && symbols.0.len() < 2
|
symbols.0.len() < 2
|
||||||
{
|
{
|
||||||
return Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError));
|
return Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError));
|
||||||
}
|
}
|
||||||
|
@ -177,7 +177,7 @@ impl SpecifiedValueInfo for CounterStyleOrNone {
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
pub struct NonNegative<T>(pub T);
|
pub struct NonNegative<T>(pub T);
|
||||||
|
|
||||||
impl <T: Add<Output = T>> Add<NonNegative<T>> for NonNegative<T> {
|
impl<T: Add<Output = T>> Add<NonNegative<T>> for NonNegative<T> {
|
||||||
type Output = Self;
|
type Output = Self;
|
||||||
|
|
||||||
fn add(self, other: Self) -> Self {
|
fn add(self, other: Self) -> Self {
|
||||||
|
@ -185,7 +185,7 @@ impl <T: Add<Output = T>> Add<NonNegative<T>> for NonNegative<T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl <T: Zero> Zero for NonNegative<T> {
|
impl<T: Zero> Zero for NonNegative<T> {
|
||||||
fn is_zero(&self) -> bool {
|
fn is_zero(&self) -> bool {
|
||||||
self.0.is_zero()
|
self.0.is_zero()
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,10 @@ pub use self::GenericPosition as Position;
|
||||||
impl<H, V> Position<H, V> {
|
impl<H, V> Position<H, V> {
|
||||||
/// Returns a new position.
|
/// Returns a new position.
|
||||||
pub fn new(horizontal: H, vertical: V) -> Self {
|
pub fn new(horizontal: H, vertical: V) -> Self {
|
||||||
Self { horizontal, vertical }
|
Self {
|
||||||
|
horizontal,
|
||||||
|
vertical,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -98,7 +98,11 @@ pub use self::GenericTransformOrigin as TransformOrigin;
|
||||||
impl<H, V, D> TransformOrigin<H, V, D> {
|
impl<H, V, D> TransformOrigin<H, V, D> {
|
||||||
/// Returns a new transform origin.
|
/// Returns a new transform origin.
|
||||||
pub fn new(horizontal: H, vertical: V, depth: D) -> Self {
|
pub fn new(horizontal: H, vertical: V, depth: D) -> Self {
|
||||||
Self { horizontal, vertical, depth }
|
Self {
|
||||||
|
horizontal,
|
||||||
|
vertical,
|
||||||
|
depth,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -419,16 +419,7 @@ pub enum ScrollSnapAlignKeyword {
|
||||||
/// https://drafts.csswg.org/css-scroll-snap-1/#scroll-snap-align
|
/// https://drafts.csswg.org/css-scroll-snap-1/#scroll-snap-align
|
||||||
#[allow(missing_docs)]
|
#[allow(missing_docs)]
|
||||||
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
|
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
|
||||||
#[derive(
|
#[derive(Clone, Copy, Debug, Eq, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToComputedValue)]
|
||||||
Clone,
|
|
||||||
Copy,
|
|
||||||
Debug,
|
|
||||||
Eq,
|
|
||||||
MallocSizeOf,
|
|
||||||
PartialEq,
|
|
||||||
SpecifiedValueInfo,
|
|
||||||
ToComputedValue,
|
|
||||||
)]
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub struct ScrollSnapAlign {
|
pub struct ScrollSnapAlign {
|
||||||
block: ScrollSnapAlignKeyword,
|
block: ScrollSnapAlignKeyword,
|
||||||
|
|
|
@ -17,7 +17,7 @@ use crate::values::generics::font::{KeywordSize, VariationValue};
|
||||||
use crate::values::generics::NonNegative;
|
use crate::values::generics::NonNegative;
|
||||||
use crate::values::specified::length::{FontBaseSize, AU_PER_PT, AU_PER_PX};
|
use crate::values::specified::length::{FontBaseSize, AU_PER_PT, AU_PER_PX};
|
||||||
use crate::values::specified::{AllowQuirks, Angle, Integer, LengthPercentage};
|
use crate::values::specified::{AllowQuirks, Angle, Integer, LengthPercentage};
|
||||||
use crate::values::specified::{NoCalcLength, Number, NonNegativeNumber, Percentage};
|
use crate::values::specified::{NoCalcLength, NonNegativeNumber, Number, Percentage};
|
||||||
use crate::values::CustomIdent;
|
use crate::values::CustomIdent;
|
||||||
use crate::Atom;
|
use crate::Atom;
|
||||||
use app_units::Au;
|
use app_units::Au;
|
||||||
|
|
|
@ -11,11 +11,13 @@ use crate::font_metrics::FontMetricsQueryResult;
|
||||||
use crate::parser::{Parse, ParserContext};
|
use crate::parser::{Parse, ParserContext};
|
||||||
use crate::values::computed::{self, CSSPixelLength, Context};
|
use crate::values::computed::{self, CSSPixelLength, Context};
|
||||||
use crate::values::generics::length as generics;
|
use crate::values::generics::length as generics;
|
||||||
use crate::values::generics::length::{MaxSize as GenericMaxSize, Size as GenericSize, GenericLengthOrNumber};
|
use crate::values::generics::length::{
|
||||||
|
GenericLengthOrNumber, MaxSize as GenericMaxSize, Size as GenericSize,
|
||||||
|
};
|
||||||
use crate::values::generics::transform::IsZeroLength;
|
use crate::values::generics::transform::IsZeroLength;
|
||||||
use crate::values::generics::NonNegative;
|
use crate::values::generics::NonNegative;
|
||||||
use crate::values::specified::NonNegativeNumber;
|
|
||||||
use crate::values::specified::calc::CalcNode;
|
use crate::values::specified::calc::CalcNode;
|
||||||
|
use crate::values::specified::NonNegativeNumber;
|
||||||
use crate::values::{Auto, CSSFloat, Either, Normal};
|
use crate::values::{Auto, CSSFloat, Either, Normal};
|
||||||
use app_units::Au;
|
use app_units::Au;
|
||||||
use cssparser::{Parser, Token};
|
use cssparser::{Parser, Token};
|
||||||
|
|
|
@ -19,10 +19,10 @@ use crate::values::serialize_atom_identifier;
|
||||||
use crate::values::specified::calc::CalcNode;
|
use crate::values::specified::calc::CalcNode;
|
||||||
use crate::{Atom, Namespace, Prefix};
|
use crate::{Atom, Namespace, Prefix};
|
||||||
use cssparser::{Parser, Token};
|
use cssparser::{Parser, Token};
|
||||||
use num_traits::{Zero, One};
|
use num_traits::{One, Zero};
|
||||||
use std::f32;
|
use std::f32;
|
||||||
use std::ops::Add;
|
|
||||||
use std::fmt::{self, Write};
|
use std::fmt::{self, Write};
|
||||||
|
use std::ops::Add;
|
||||||
use style_traits::values::specified::AllowedNumericType;
|
use style_traits::values::specified::AllowedNumericType;
|
||||||
use style_traits::{CssWriter, ParseError, SpecifiedValueInfo, StyleParseErrorKind, ToCss};
|
use style_traits::{CssWriter, ParseError, SpecifiedValueInfo, StyleParseErrorKind, ToCss};
|
||||||
|
|
||||||
|
|
|
@ -64,7 +64,7 @@ impl Parse for SVGStrokeDashArray {
|
||||||
NonNegativeSvgLengthPercentageOrNumber::parse(context, i)
|
NonNegativeSvgLengthPercentageOrNumber::parse(context, i)
|
||||||
})
|
})
|
||||||
}) {
|
}) {
|
||||||
return Ok(generic::SVGStrokeDashArray::Values(values))
|
return Ok(generic::SVGStrokeDashArray::Values(values));
|
||||||
}
|
}
|
||||||
|
|
||||||
try_match_ident_ignore_ascii_case! { input,
|
try_match_ident_ignore_ascii_case! { input,
|
||||||
|
|
|
@ -14,9 +14,9 @@ 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;
|
use crate::values::generics::text::Spacing;
|
||||||
|
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};
|
||||||
use crate::values::specified::length::{NonNegativeLengthPercentage};
|
|
||||||
use crate::values::specified::{AllowQuirks, Integer, NonNegativeNumber, Number};
|
use crate::values::specified::{AllowQuirks, Integer, NonNegativeNumber, Number};
|
||||||
use cssparser::{Parser, Token};
|
use cssparser::{Parser, Token};
|
||||||
use selectors::parser::SelectorParseErrorKind;
|
use selectors::parser::SelectorParseErrorKind;
|
||||||
|
|
|
@ -70,12 +70,14 @@ pub fn derive(mut input: DeriveInput) -> TokenStream {
|
||||||
{
|
{
|
||||||
let mut where_clause = input.generics.where_clause.take();
|
let mut where_clause = input.generics.where_clause.take();
|
||||||
for param in input.generics.type_params() {
|
for param in input.generics.type_params() {
|
||||||
cg::add_predicate(&mut where_clause, parse_quote!(#param: crate::parser::Parse));
|
cg::add_predicate(
|
||||||
|
&mut where_clause,
|
||||||
|
parse_quote!(#param: crate::parser::Parse),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
input.generics.where_clause = where_clause;
|
input.generics.where_clause = where_clause;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
let name = &input.ident;
|
let name = &input.ident;
|
||||||
let s = Structure::new(&input);
|
let s = Structure::new(&input);
|
||||||
|
|
||||||
|
@ -140,13 +142,8 @@ 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 = parse_non_keyword_variant(
|
let parse_variant =
|
||||||
name,
|
parse_non_keyword_variant(name, variant, css_attrs, parse_attrs, skip_try);
|
||||||
variant,
|
|
||||||
css_attrs,
|
|
||||||
parse_attrs,
|
|
||||||
skip_try,
|
|
||||||
);
|
|
||||||
parse_non_keywords.extend(parse_variant);
|
parse_non_keywords.extend(parse_variant);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue