mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
Run rustfmt on selectors, servo_arc, and style.
This was generated with: ./mach cargo fmt --package selectors && ./mach cargo fmt --package servo_arc && ./mach cargo fmt --package style Using rustfmt 0.4.1-nightly (a4462d1 2018-03-26)
This commit is contained in:
parent
f7ae1a37e3
commit
c99bcdd4b8
181 changed files with 9981 additions and 7933 deletions
|
@ -7,7 +7,7 @@
|
|||
use Atom;
|
||||
use app_units::Au;
|
||||
use byteorder::{BigEndian, ByteOrder};
|
||||
use cssparser::{CssStringWriter, Parser, serialize_identifier};
|
||||
use cssparser::{serialize_identifier, CssStringWriter, Parser};
|
||||
#[cfg(feature = "gecko")]
|
||||
use gecko_bindings::{bindings, structs};
|
||||
#[cfg(feature = "gecko")]
|
||||
|
@ -22,14 +22,14 @@ use std::slice;
|
|||
use style_traits::{CssWriter, ParseError, ToCss};
|
||||
use values::CSSFloat;
|
||||
use values::animated::{ToAnimatedValue, ToAnimatedZero};
|
||||
use values::computed::{Context, NonNegativeLength, ToComputedValue, Integer, Number};
|
||||
use values::generics::font::{FontSettings, FeatureTagValue};
|
||||
use values::computed::{Context, Integer, NonNegativeLength, Number, ToComputedValue};
|
||||
use values::generics::font::{FeatureTagValue, FontSettings};
|
||||
use values::generics::font::{KeywordInfo as GenericKeywordInfo, VariationValue};
|
||||
use values::specified::font as specified;
|
||||
use values::specified::length::{FontBaseSize, NoCalcLength};
|
||||
|
||||
pub use values::computed::Length as MozScriptMinSize;
|
||||
pub use values::specified::font::{XTextZoom, XLang, MozScriptSizeMultiplier, FontSynthesis};
|
||||
pub use values::specified::font::{FontSynthesis, MozScriptSizeMultiplier, XLang, XTextZoom};
|
||||
|
||||
/// As of CSS Fonts Module Level 3, only the following values are
|
||||
/// valid: 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900
|
||||
|
@ -40,8 +40,8 @@ pub use values::specified::font::{XTextZoom, XLang, MozScriptSizeMultiplier, Fon
|
|||
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
|
||||
pub struct FontWeight(pub u16);
|
||||
|
||||
#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf)]
|
||||
#[derive(PartialEq, ToAnimatedZero, ToCss)]
|
||||
#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, PartialEq,
|
||||
ToAnimatedZero, ToCss)]
|
||||
/// The computed value of font-size
|
||||
pub struct FontSize {
|
||||
/// The size.
|
||||
|
@ -120,7 +120,7 @@ impl FontSize {
|
|||
pub fn medium() -> Self {
|
||||
Self {
|
||||
size: Au::from_px(specified::FONT_MEDIUM_PX).into(),
|
||||
keyword_info: Some(KeywordInfo::medium())
|
||||
keyword_info: Some(KeywordInfo::medium()),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -130,15 +130,22 @@ impl FontSize {
|
|||
// If inheriting, we must recompute font-size in case of language
|
||||
// changes using the font_size_keyword. We also need to do this to
|
||||
// handle mathml scriptlevel changes
|
||||
let kw_inherited_size = context.builder.get_parent_font()
|
||||
.clone_font_size()
|
||||
.keyword_info.map(|info| {
|
||||
specified::FontSize::Keyword(info).to_computed_value(context).size
|
||||
});
|
||||
let kw_inherited_size = context
|
||||
.builder
|
||||
.get_parent_font()
|
||||
.clone_font_size()
|
||||
.keyword_info
|
||||
.map(|info| {
|
||||
specified::FontSize::Keyword(info)
|
||||
.to_computed_value(context)
|
||||
.size
|
||||
});
|
||||
let mut font = context.builder.take_font();
|
||||
font.inherit_font_size_from(context.builder.get_parent_font(),
|
||||
kw_inherited_size,
|
||||
context.builder.device);
|
||||
font.inherit_font_size_from(
|
||||
context.builder.get_parent_font(),
|
||||
kw_inherited_size,
|
||||
context.builder.device,
|
||||
);
|
||||
context.builder.put_font(font);
|
||||
}
|
||||
|
||||
|
@ -153,7 +160,8 @@ impl FontSize {
|
|||
// compute to the same value and depends on the font
|
||||
let computed = specified::FontSize::medium().to_computed_value(context);
|
||||
context.builder.mutate_font().set_font_size(computed);
|
||||
#[cfg(feature = "gecko")] {
|
||||
#[cfg(feature = "gecko")]
|
||||
{
|
||||
let device = context.builder.device;
|
||||
context.builder.mutate_font().fixup_font_min_size(device);
|
||||
}
|
||||
|
@ -190,9 +198,9 @@ impl FontFamily {
|
|||
#[inline]
|
||||
/// Get default font family as `serif` which is a generic font-family
|
||||
pub fn serif() -> Self {
|
||||
FontFamily(
|
||||
FontFamilyList::new(Box::new([SingleFontFamily::Generic(atom!("serif"))]))
|
||||
)
|
||||
FontFamily(FontFamilyList::new(Box::new([
|
||||
SingleFontFamily::Generic(atom!("serif")),
|
||||
])))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -202,16 +210,15 @@ impl MallocSizeOf for FontFamily {
|
|||
// SharedFontList objects are generally shared from the pointer
|
||||
// stored in the specified value. So only count this if the
|
||||
// SharedFontList is unshared.
|
||||
unsafe {
|
||||
bindings::Gecko_SharedFontList_SizeOfIncludingThisIfUnshared(
|
||||
(self.0).0.get()
|
||||
)
|
||||
}
|
||||
unsafe { bindings::Gecko_SharedFontList_SizeOfIncludingThisIfUnshared((self.0).0.get()) }
|
||||
}
|
||||
}
|
||||
|
||||
impl ToCss for FontFamily {
|
||||
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result where W: fmt::Write {
|
||||
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
|
||||
where
|
||||
W: fmt::Write,
|
||||
{
|
||||
let mut iter = self.0.iter();
|
||||
iter.next().unwrap().to_css(dest)?;
|
||||
for family in iter {
|
||||
|
@ -233,13 +240,16 @@ pub struct FamilyName {
|
|||
}
|
||||
|
||||
impl ToCss for FamilyName {
|
||||
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result where W: fmt::Write {
|
||||
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
|
||||
where
|
||||
W: fmt::Write,
|
||||
{
|
||||
match self.syntax {
|
||||
FamilyNameSyntax::Quoted => {
|
||||
dest.write_char('"')?;
|
||||
write!(CssStringWriter::new(dest), "{}", self.name)?;
|
||||
dest.write_char('"')
|
||||
}
|
||||
},
|
||||
FamilyNameSyntax::Identifiers => {
|
||||
let mut first = true;
|
||||
for ident in self.name.to_string().split(' ') {
|
||||
|
@ -248,13 +258,16 @@ impl ToCss for FamilyName {
|
|||
} else {
|
||||
dest.write_char(' ')?;
|
||||
}
|
||||
debug_assert!(!ident.is_empty(), "Family name with leading, \
|
||||
trailing, or consecutive white spaces should \
|
||||
have been marked quoted by the parser");
|
||||
debug_assert!(
|
||||
!ident.is_empty(),
|
||||
"Family name with leading, \
|
||||
trailing, or consecutive white spaces should \
|
||||
have been marked quoted by the parser"
|
||||
);
|
||||
serialize_identifier(ident, dest)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -308,10 +321,8 @@ impl SingleFontFamily {
|
|||
atom!("sans-serif") |
|
||||
atom!("cursive") |
|
||||
atom!("fantasy") |
|
||||
atom!("monospace") => {
|
||||
return SingleFontFamily::Generic(input)
|
||||
}
|
||||
_ => {}
|
||||
atom!("monospace") => return SingleFontFamily::Generic(input),
|
||||
_ => {},
|
||||
}
|
||||
match_ignore_ascii_case! { &input,
|
||||
"serif" => return SingleFontFamily::Generic(atom!("serif")),
|
||||
|
@ -336,7 +347,7 @@ impl SingleFontFamily {
|
|||
return Ok(SingleFontFamily::FamilyName(FamilyName {
|
||||
name: Atom::from(&*value),
|
||||
syntax: FamilyNameSyntax::Quoted,
|
||||
}))
|
||||
}));
|
||||
}
|
||||
let first_ident = input.expect_ident()?.clone();
|
||||
|
||||
|
@ -392,7 +403,7 @@ impl SingleFontFamily {
|
|||
};
|
||||
Ok(SingleFontFamily::FamilyName(FamilyName {
|
||||
name: Atom::from(value),
|
||||
syntax
|
||||
syntax,
|
||||
}))
|
||||
}
|
||||
|
||||
|
@ -401,23 +412,32 @@ impl SingleFontFamily {
|
|||
pub fn generic(name: &Atom) -> (structs::FontFamilyType, u8) {
|
||||
use gecko_bindings::structs::FontFamilyType;
|
||||
if *name == atom!("serif") {
|
||||
(FontFamilyType::eFamily_serif,
|
||||
structs::kGenericFont_serif)
|
||||
(FontFamilyType::eFamily_serif, structs::kGenericFont_serif)
|
||||
} else if *name == atom!("sans-serif") {
|
||||
(FontFamilyType::eFamily_sans_serif,
|
||||
structs::kGenericFont_sans_serif)
|
||||
(
|
||||
FontFamilyType::eFamily_sans_serif,
|
||||
structs::kGenericFont_sans_serif,
|
||||
)
|
||||
} else if *name == atom!("cursive") {
|
||||
(FontFamilyType::eFamily_cursive,
|
||||
structs::kGenericFont_cursive)
|
||||
(
|
||||
FontFamilyType::eFamily_cursive,
|
||||
structs::kGenericFont_cursive,
|
||||
)
|
||||
} else if *name == atom!("fantasy") {
|
||||
(FontFamilyType::eFamily_fantasy,
|
||||
structs::kGenericFont_fantasy)
|
||||
(
|
||||
FontFamilyType::eFamily_fantasy,
|
||||
structs::kGenericFont_fantasy,
|
||||
)
|
||||
} else if *name == atom!("monospace") {
|
||||
(FontFamilyType::eFamily_monospace,
|
||||
structs::kGenericFont_monospace)
|
||||
(
|
||||
FontFamilyType::eFamily_monospace,
|
||||
structs::kGenericFont_monospace,
|
||||
)
|
||||
} else if *name == atom!("-moz-fixed") {
|
||||
(FontFamilyType::eFamily_moz_fixed,
|
||||
structs::kGenericFont_moz_fixed)
|
||||
(
|
||||
FontFamilyType::eFamily_moz_fixed,
|
||||
structs::kGenericFont_moz_fixed,
|
||||
)
|
||||
} else {
|
||||
panic!("Unknown generic {}", name);
|
||||
}
|
||||
|
@ -434,7 +454,9 @@ impl SingleFontFamily {
|
|||
FontFamilyType::eFamily_monospace => SingleFontFamily::Generic(atom!("monospace")),
|
||||
FontFamilyType::eFamily_cursive => SingleFontFamily::Generic(atom!("cursive")),
|
||||
FontFamilyType::eFamily_fantasy => SingleFontFamily::Generic(atom!("fantasy")),
|
||||
FontFamilyType::eFamily_moz_fixed => SingleFontFamily::Generic(Atom::from("-moz-fixed")),
|
||||
FontFamilyType::eFamily_moz_fixed => {
|
||||
SingleFontFamily::Generic(Atom::from("-moz-fixed"))
|
||||
},
|
||||
FontFamilyType::eFamily_named => {
|
||||
let name = Atom::from(&*family.mName);
|
||||
SingleFontFamily::FamilyName(FamilyName {
|
||||
|
@ -452,13 +474,17 @@ impl SingleFontFamily {
|
|||
}
|
||||
|
||||
impl ToCss for SingleFontFamily {
|
||||
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result where W: fmt::Write {
|
||||
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
|
||||
where
|
||||
W: fmt::Write,
|
||||
{
|
||||
match *self {
|
||||
SingleFontFamily::FamilyName(ref name) => name.to_css(dest),
|
||||
|
||||
// All generic values accepted by the parser are known to not require escaping.
|
||||
SingleFontFamily::Generic(ref name) => {
|
||||
#[cfg(feature = "gecko")] {
|
||||
#[cfg(feature = "gecko")]
|
||||
{
|
||||
// We should treat -moz-fixed as monospace
|
||||
if name == &atom!("-moz-fixed") {
|
||||
return dest.write_str("monospace");
|
||||
|
@ -483,7 +509,10 @@ pub struct FontFamilyList(pub RefPtr<structs::SharedFontList>);
|
|||
|
||||
#[cfg(feature = "gecko")]
|
||||
impl Hash for FontFamilyList {
|
||||
fn hash<H>(&self, state: &mut H) where H: Hasher {
|
||||
fn hash<H>(&self, state: &mut H)
|
||||
where
|
||||
H: Hasher,
|
||||
{
|
||||
for name in self.0.mNames.iter() {
|
||||
name.mType.hash(state);
|
||||
name.mName.hash(state);
|
||||
|
@ -535,19 +564,16 @@ impl FontFamilyList {
|
|||
bindings::Gecko_nsTArray_FontFamilyName_AppendNamed(
|
||||
names,
|
||||
f.name.as_ptr(),
|
||||
quoted
|
||||
quoted,
|
||||
);
|
||||
}
|
||||
}
|
||||
},
|
||||
SingleFontFamily::Generic(ref name) => {
|
||||
let (family_type, _generic) = SingleFontFamily::generic(name);
|
||||
unsafe {
|
||||
bindings::Gecko_nsTArray_FontFamilyName_AppendGeneric(
|
||||
names,
|
||||
family_type
|
||||
);
|
||||
bindings::Gecko_nsTArray_FontFamilyName_AppendGeneric(names, family_type);
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -651,7 +677,7 @@ impl ToAnimatedValue for FontSizeAdjust {
|
|||
fn from_animated_value(animated: Self::AnimatedValue) -> Self {
|
||||
match animated {
|
||||
FontSizeAdjust::Number(number) => FontSizeAdjust::Number(number.max(0.)),
|
||||
_ => animated
|
||||
_ => animated,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -698,11 +724,14 @@ impl FontLanguageOverride {
|
|||
}
|
||||
|
||||
impl ToCss for FontLanguageOverride {
|
||||
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result where W: fmt::Write {
|
||||
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
|
||||
where
|
||||
W: fmt::Write,
|
||||
{
|
||||
use std::str;
|
||||
|
||||
if self.0 == 0 {
|
||||
return dest.write_str("normal")
|
||||
return dest.write_str("normal");
|
||||
}
|
||||
let mut buf = [0; 4];
|
||||
BigEndian::write_u32(&mut buf, self.0);
|
||||
|
@ -738,15 +767,11 @@ impl ToComputedValue for specified::MozScriptMinSize {
|
|||
// we use the parent size
|
||||
let base_size = FontBaseSize::InheritedStyle;
|
||||
match self.0 {
|
||||
NoCalcLength::FontRelative(value) => {
|
||||
value.to_computed_value(cx, base_size)
|
||||
}
|
||||
NoCalcLength::FontRelative(value) => value.to_computed_value(cx, base_size),
|
||||
NoCalcLength::ServoCharacterWidth(value) => {
|
||||
value.to_computed_value(base_size.resolve(cx))
|
||||
}
|
||||
ref l => {
|
||||
l.to_computed_value(cx)
|
||||
}
|
||||
},
|
||||
ref l => l.to_computed_value(cx),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -775,11 +800,11 @@ impl ToComputedValue for specified::MozScriptLevel {
|
|||
} else {
|
||||
parent
|
||||
}
|
||||
}
|
||||
},
|
||||
specified::MozScriptLevel::Relative(rel) => {
|
||||
let parent = cx.builder.get_parent_font().clone__moz_script_level();
|
||||
parent as i32 + rel
|
||||
}
|
||||
},
|
||||
specified::MozScriptLevel::MozAbsolute(abs) => abs,
|
||||
};
|
||||
cmp::min(int, i8::MAX as i32) as i8
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue