mirror of
https://github.com/servo/servo.git
synced 2025-10-04 02:29:12 +01:00
style: Run rustfmt on servo/components/style and servo/ports/geckolib
This patch is generated by running `cargo +nightly fmt` under `servo/components/style/` and `servo/ports/geckolib` against mozilla-central https://hg.mozilla.org/mozilla-central/rev/b193f2e7a6a5d1f042c957ea4acd5c89bf210512 My nightly version is: 1.58.0-nightly (c9c4b5d72 2021-11-17) Manually remove the redundant braces in author_styles.rs to fix a warning. Differential Revision: https://phabricator.services.mozilla.com/D131556
This commit is contained in:
parent
33ad82c3da
commit
a0617bff0d
50 changed files with 486 additions and 340 deletions
|
@ -6,7 +6,7 @@
|
|||
|
||||
use crate::values::animated::color::RGBA as AnimatedRGBA;
|
||||
use crate::values::animated::ToAnimatedValue;
|
||||
use crate::values::generics::color::{GenericColor, GenericColorOrAuto, GenericCaretColor};
|
||||
use crate::values::generics::color::{GenericCaretColor, GenericColor, GenericColorOrAuto};
|
||||
use cssparser::{Color as CSSParserColor, RGBA};
|
||||
use std::fmt;
|
||||
use style_traits::{CssWriter, ToCss};
|
||||
|
|
|
@ -202,7 +202,6 @@ macro_rules! static_font_family {
|
|||
};
|
||||
}
|
||||
|
||||
|
||||
impl FontFamily {
|
||||
#[inline]
|
||||
/// Get default font family as `serif` which is a generic font-family
|
||||
|
@ -213,10 +212,13 @@ impl FontFamily {
|
|||
/// Returns the font family for `-moz-bullet-font`.
|
||||
#[cfg(feature = "gecko")]
|
||||
pub(crate) fn moz_bullet() -> &'static Self {
|
||||
static_font_family!(MOZ_BULLET, SingleFontFamily::FamilyName(FamilyName {
|
||||
name: atom!("-moz-bullet-font"),
|
||||
syntax: FontFamilyNameSyntax::Identifiers,
|
||||
}));
|
||||
static_font_family!(
|
||||
MOZ_BULLET,
|
||||
SingleFontFamily::FamilyName(FamilyName {
|
||||
name: atom!("-moz-bullet-font"),
|
||||
syntax: FontFamilyNameSyntax::Identifiers,
|
||||
})
|
||||
);
|
||||
|
||||
&*MOZ_BULLET
|
||||
}
|
||||
|
@ -226,10 +228,12 @@ impl FontFamily {
|
|||
pub fn for_system_font(name: &str) -> Self {
|
||||
Self {
|
||||
families: FontFamilyList {
|
||||
list: crate::ArcSlice::from_iter(std::iter::once(SingleFontFamily::FamilyName(FamilyName {
|
||||
name: Atom::from(name),
|
||||
syntax: FontFamilyNameSyntax::Identifiers,
|
||||
}))),
|
||||
list: crate::ArcSlice::from_iter(std::iter::once(SingleFontFamily::FamilyName(
|
||||
FamilyName {
|
||||
name: Atom::from(name),
|
||||
syntax: FontFamilyNameSyntax::Identifiers,
|
||||
},
|
||||
))),
|
||||
fallback: GenericFontFamily::None,
|
||||
},
|
||||
is_system_font: true,
|
||||
|
@ -240,8 +244,11 @@ impl FontFamily {
|
|||
pub fn generic(generic: GenericFontFamily) -> &'static Self {
|
||||
macro_rules! generic_font_family {
|
||||
($ident:ident, $family:ident) => {
|
||||
static_font_family!($ident, SingleFontFamily::Generic(GenericFontFamily::$family))
|
||||
}
|
||||
static_font_family!(
|
||||
$ident,
|
||||
SingleFontFamily::Generic(GenericFontFamily::$family)
|
||||
)
|
||||
};
|
||||
}
|
||||
|
||||
generic_font_family!(SERIF, Serif);
|
||||
|
@ -257,7 +264,7 @@ impl FontFamily {
|
|||
GenericFontFamily::None => {
|
||||
debug_assert!(false, "Bogus caller!");
|
||||
&*SERIF
|
||||
}
|
||||
},
|
||||
GenericFontFamily::Serif => &*SERIF,
|
||||
GenericFontFamily::SansSerif => &*SANS_SERIF,
|
||||
GenericFontFamily::Monospace => &*MONOSPACE,
|
||||
|
@ -444,24 +451,21 @@ impl GenericFontFamily {
|
|||
/// families that the website might specify, since they're not configured by
|
||||
/// the user. See bug 789788 and bug 1730098.
|
||||
#[cfg(feature = "gecko")]
|
||||
pub (crate) fn valid_for_user_font_prioritization(self) -> bool {
|
||||
pub(crate) fn valid_for_user_font_prioritization(self) -> bool {
|
||||
match self {
|
||||
Self::None |
|
||||
Self::Fantasy |
|
||||
Self::Cursive |
|
||||
Self::SystemUi |
|
||||
Self::MozEmoji => false,
|
||||
Self::None | Self::Fantasy | Self::Cursive | Self::SystemUi | Self::MozEmoji => false,
|
||||
|
||||
Self::Serif |
|
||||
Self::SansSerif |
|
||||
Self::Monospace => true,
|
||||
Self::Serif | Self::SansSerif | Self::Monospace => true,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Parse for SingleFontFamily {
|
||||
/// Parse a font-family value.
|
||||
fn parse<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>) -> Result<Self, ParseError<'i>> {
|
||||
fn parse<'i, 't>(
|
||||
context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>,
|
||||
) -> Result<Self, ParseError<'i>> {
|
||||
if let Ok(value) = input.try_parse(|i| i.expect_string_cloned()) {
|
||||
return Ok(SingleFontFamily::FamilyName(FamilyName {
|
||||
name: Atom::from(&*value),
|
||||
|
@ -603,13 +607,11 @@ impl FontFamilyList {
|
|||
/// font prioritization, then move it to the front of the list. Otherwise,
|
||||
/// prepend the default generic.
|
||||
#[cfg(feature = "gecko")]
|
||||
pub (crate) fn prioritize_first_generic_or_prepend(&mut self, generic: GenericFontFamily) {
|
||||
let index_of_first_generic = self.iter().position(|f| {
|
||||
match *f {
|
||||
SingleFontFamily::Generic(f) => f.valid_for_user_font_prioritization(),
|
||||
_ => false,
|
||||
}
|
||||
});
|
||||
pub(crate) fn prioritize_first_generic_or_prepend(&mut self, generic: GenericFontFamily) {
|
||||
let index_of_first_generic = self.iter().position(|f| match *f {
|
||||
SingleFontFamily::Generic(f) => f.valid_for_user_font_prioritization(),
|
||||
_ => false,
|
||||
});
|
||||
|
||||
if let Some(0) = index_of_first_generic {
|
||||
return; // Already first
|
||||
|
|
|
@ -84,7 +84,6 @@ impl ToComputedValue for specified::ImageSet {
|
|||
let mut selected_resolution = items[0].resolution.dppx();
|
||||
|
||||
for (i, item) in items.iter().enumerate() {
|
||||
|
||||
// If the MIME type is not supported, we discard the ImageSetItem
|
||||
if item.has_mime_type && !context.device().is_supported_mime_type(&item.mime_type) {
|
||||
continue;
|
||||
|
|
|
@ -37,7 +37,9 @@ impl ToComputedValue for specified::NoCalcLength {
|
|||
length.to_computed_value(context, FontBaseSize::CurrentStyle)
|
||||
},
|
||||
specified::NoCalcLength::ViewportPercentage(length) => {
|
||||
context.builder.add_flags(ComputedValueFlags::USES_VIEWPORT_UNITS);
|
||||
context
|
||||
.builder
|
||||
.add_flags(ComputedValueFlags::USES_VIEWPORT_UNITS);
|
||||
length.to_computed_value(context.viewport_size_for_viewport_unit_resolution())
|
||||
},
|
||||
specified::NoCalcLength::ServoCharacterWidth(length) => {
|
||||
|
@ -191,7 +193,7 @@ impl Size {
|
|||
GenericSize::MaxContent |
|
||||
GenericSize::FitContent |
|
||||
GenericSize::MozAvailable |
|
||||
GenericSize::FitContentFunction(_) => false
|
||||
GenericSize::FitContentFunction(_) => false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -62,7 +62,7 @@ pub use self::font::{FontSize, FontSizeAdjust, FontStretch, FontSynthesis};
|
|||
pub use self::font::{FontVariantAlternates, FontWeight};
|
||||
pub use self::font::{FontVariantEastAsian, FontVariationSettings};
|
||||
pub use self::font::{MathDepth, MozScriptMinSize, MozScriptSizeMultiplier, XLang, XTextZoom};
|
||||
pub use self::image::{Gradient, Image, LineDirection, MozImageRect, ImageRendering};
|
||||
pub use self::image::{Gradient, Image, ImageRendering, LineDirection, MozImageRect};
|
||||
pub use self::length::{CSSPixelLength, NonNegativeLength};
|
||||
pub use self::length::{Length, LengthOrNumber, LengthPercentage, NonNegativeLengthOrNumber};
|
||||
pub use self::length::{LengthOrAuto, LengthPercentageOrAuto, MaxSize, Size};
|
||||
|
|
|
@ -18,7 +18,9 @@ use crate::Zero;
|
|||
use std::fmt::{self, Write};
|
||||
use style_traits::{CssWriter, ToCss};
|
||||
|
||||
pub use crate::values::specified::text::{TextAlignLast, TextUnderlinePosition, MozControlCharacterVisibility};
|
||||
pub use crate::values::specified::text::{
|
||||
MozControlCharacterVisibility, TextAlignLast, TextUnderlinePosition,
|
||||
};
|
||||
pub use crate::values::specified::{LineBreak, OverflowWrap, RubyPosition, WordBreak};
|
||||
pub use crate::values::specified::{TextDecorationLine, TextEmphasisPosition};
|
||||
pub use crate::values::specified::{TextDecorationSkipInk, TextJustify, TextTransform};
|
||||
|
|
|
@ -520,7 +520,7 @@ impl ToAnimatedZero for TransformOperation {
|
|||
Ok(generic::TransformOperation::Rotate(Angle::zero()))
|
||||
},
|
||||
generic::TransformOperation::Perspective(_) => Ok(
|
||||
generic::TransformOperation::Perspective(generic::PerspectiveFunction::None)
|
||||
generic::TransformOperation::Perspective(generic::PerspectiveFunction::None),
|
||||
),
|
||||
generic::TransformOperation::AccumulateMatrix { .. } |
|
||||
generic::TransformOperation::InterpolateMatrix { .. } => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue