style: Fix tidy issues and Servo build.

This commit is contained in:
Emilio Cobos Álvarez 2018-04-29 03:02:21 +02:00
parent 64cceb328a
commit 292f899631
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
15 changed files with 32 additions and 56 deletions

2
Cargo.lock generated
View file

@ -997,7 +997,6 @@ dependencies = [
"atomic_refcell 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "atomic_refcell 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"cssparser 0.23.2 (registry+https://github.com/rust-lang/crates.io-index)", "cssparser 0.23.2 (registry+https://github.com/rust-lang/crates.io-index)",
"cstr 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "cstr 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
"env_logger 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.39 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.39 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
"malloc_size_of 0.0.1", "malloc_size_of 0.0.1",
@ -3123,6 +3122,7 @@ dependencies = [
"serde 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)",
"servo_arc 0.1.1", "servo_arc 0.1.1",
"servo_atoms 0.0.1", "servo_atoms 0.0.1",
"servo_url 0.0.1",
"webrender_api 0.57.2 (git+https://github.com/servo/webrender)", "webrender_api 0.57.2 (git+https://github.com/servo/webrender)",
] ]

View file

@ -66,9 +66,9 @@ use style::servo::restyle_damage::ServoRestyleDamage;
use style::values::{Either, RGBA}; use style::values::{Either, RGBA};
use style::values::computed::Gradient; use style::values::computed::Gradient;
use style::values::computed::effects::SimpleShadow; use style::values::computed::effects::SimpleShadow;
use style::values::computed::pointing::Cursor;
use style::values::generics::background::BackgroundSize; use style::values::generics::background::BackgroundSize;
use style::values::generics::image::{GradientKind, Image, PaintWorklet}; use style::values::generics::image::{GradientKind, Image, PaintWorklet};
use style::values::generics::pointing::Cursor;
use style_traits::CSSPixel; use style_traits::CSSPixel;
use style_traits::ToCss; use style_traits::ToCss;
use style_traits::cursor::CursorKind; use style_traits::cursor::CursorKind;
@ -2952,11 +2952,11 @@ impl ComputedValuesCursorUtility for ComputedValues {
fn get_cursor(&self, default_cursor: CursorKind) -> Option<CursorKind> { fn get_cursor(&self, default_cursor: CursorKind) -> Option<CursorKind> {
match ( match (
self.get_pointing().pointer_events, self.get_pointing().pointer_events,
self.get_pointing().cursor, &self.get_pointing().cursor,
) { ) {
(PointerEvents::None, _) => None, (PointerEvents::None, _) => None,
(PointerEvents::Auto, Cursor(CursorKind::Auto)) => Some(default_cursor), (PointerEvents::Auto, &Cursor { keyword: CursorKind::Auto, .. }) => Some(default_cursor),
(PointerEvents::Auto, Cursor(cursor)) => Some(cursor), (PointerEvents::Auto, &Cursor { keyword, .. }) => Some(keyword),
} }
} }
} }

View file

@ -925,7 +925,7 @@ impl<T: 'static> Arc<T> {
/// ///
/// ArcBorrow lets us deal with borrows of known-refcounted objects /// ArcBorrow lets us deal with borrows of known-refcounted objects
/// without needing to worry about how they're actually stored. /// without needing to worry about how they're actually stored.
#[derive(Eq, Debug, PartialEq)] #[derive(Debug, Eq, PartialEq)]
pub struct ArcBorrow<'a, T: 'a>(&'a T); pub struct ArcBorrow<'a, T: 'a>(&'a T);
impl<'a, T> Copy for ArcBorrow<'a, T> {} impl<'a, T> Copy for ArcBorrow<'a, T> {}

View file

@ -450,7 +450,7 @@ ${helpers.predefined_type("-x-text-zoom",
// a lot of code with `if product == gecko` conditionals, we have a // a lot of code with `if product == gecko` conditionals, we have a
// dummy system font module that does nothing // dummy system font module that does nothing
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, ToCss)] #[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, SpecifiedValueInfo, ToCss)]
#[cfg_attr(feature = "servo", derive(MallocSizeOf))] #[cfg_attr(feature = "servo", derive(MallocSizeOf))]
/// void enum for system font, can never exist /// void enum for system font, can never exist
pub enum SystemFont {} pub enum SystemFont {}

View file

@ -23,7 +23,7 @@ use values::computed::{Context, ToComputedValue};
/// ///
/// However, this approach is still not necessarily optimal: See /// However, this approach is still not necessarily optimal: See
/// <https://bugzilla.mozilla.org/show_bug.cgi?id=1347435#c6> /// <https://bugzilla.mozilla.org/show_bug.cgi?id=1347435#c6>
#[derive(Clone, Debug, Deserialize, MallocSizeOf, Serialize)] #[derive(Clone, Debug, Deserialize, MallocSizeOf, Serialize, SpecifiedValueInfo)]
pub struct CssUrl { pub struct CssUrl {
/// The original URI. This might be optional since we may insert computed /// The original URI. This might be optional since we may insert computed
/// values of images into the cascade directly, and we don't bother to /// values of images into the cascade directly, and we don't bother to

View file

@ -145,6 +145,8 @@ pub struct PaintWorklet {
pub arguments: Vec<Arc<custom_properties::SpecifiedValue>>, pub arguments: Vec<Arc<custom_properties::SpecifiedValue>>,
} }
impl ::style_traits::SpecifiedValueInfo for PaintWorklet { }
impl ToCss for PaintWorklet { impl ToCss for PaintWorklet {
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
where where

View file

@ -71,7 +71,7 @@ where
/// Convenience void type to disable some properties and values through types. /// Convenience void type to disable some properties and values through types.
#[cfg_attr(feature = "servo", derive(Deserialize, MallocSizeOf, Serialize))] #[cfg_attr(feature = "servo", derive(Deserialize, MallocSizeOf, Serialize))]
#[derive(Clone, Copy, Debug, PartialEq, ToAnimatedValue, ToComputedValue, ToCss)] #[derive(Clone, Copy, Debug, PartialEq, SpecifiedValueInfo, ToAnimatedValue, ToComputedValue, ToCss)]
pub enum Impossible {} pub enum Impossible {}
// FIXME(nox): This should be derived but the derive code cannot cope // FIXME(nox): This should be derived but the derive code cannot cope
@ -162,7 +162,7 @@ impl ToCss for CustomIdent {
} }
/// <https://drafts.csswg.org/css-animations/#typedef-keyframes-name> /// <https://drafts.csswg.org/css-animations/#typedef-keyframes-name>
#[derive(Clone, Debug, MallocSizeOf, ToComputedValue, SpecifiedValueInfo)] #[derive(Clone, Debug, MallocSizeOf, SpecifiedValueInfo, ToComputedValue)]
pub enum KeyframesName { pub enum KeyframesName {
/// <custom-ident> /// <custom-ident>
Ident(CustomIdent), Ident(CustomIdent),

View file

@ -522,7 +522,7 @@ pub fn assert_touch_action_matches() {
} }
bitflags! { bitflags! {
#[derive(MallocSizeOf, ToComputedValue, SpecifiedValueInfo)] #[derive(MallocSizeOf, SpecifiedValueInfo, ToComputedValue)]
#[value_info(other_values = "none,strict,layout,style,paint")] #[value_info(other_values = "none,strict,layout,style,paint")]
/// Constants for contain: https://drafts.csswg.org/css-contain/#contain-property /// Constants for contain: https://drafts.csswg.org/css-contain/#contain-property
pub struct Contain: u8 { pub struct Contain: u8 {

View file

@ -23,8 +23,8 @@ use values::computed::{Angle as ComputedAngle, Percentage as ComputedPercentage}
use values::computed::{font as computed, Context, Length, NonNegativeLength, ToComputedValue}; use values::computed::{font as computed, Context, Length, NonNegativeLength, ToComputedValue};
use values::computed::font::{FamilyName, FontFamilyList, FontStyleAngle, SingleFontFamily}; use values::computed::font::{FamilyName, FontFamilyList, FontStyleAngle, SingleFontFamily};
use values::generics::NonNegative; use values::generics::NonNegative;
use values::generics::font::{self as generics, FeatureTagValue, FontSettings, FontTag};
use values::generics::font::{KeywordSize, VariationValue}; use values::generics::font::{KeywordSize, VariationValue};
use values::generics::font::{self as generics, FeatureTagValue, FontSettings, FontTag};
use values::specified::{AllowQuirks, Angle, Integer, LengthOrPercentage, NoCalcLength, Number, Percentage}; use values::specified::{AllowQuirks, Angle, Integer, LengthOrPercentage, NoCalcLength, Number, Percentage};
use values::specified::length::{FontBaseSize, AU_PER_PT, AU_PER_PX}; use values::specified::length::{FontBaseSize, AU_PER_PT, AU_PER_PX};

View file

@ -101,7 +101,7 @@ pub fn derive(mut input: DeriveInput) -> Tokens {
quote!() quote!()
} else { } else {
let mut value_list = quote!(); let mut value_list = quote!();
value_list.append_separated(values.iter(), quote!(,)); value_list.append_separated(values.iter(), quote! { , });
quote! { _f(&[#value_list]); } quote! { _f(&[#value_list]); }
}; };

View file

@ -10,7 +10,7 @@ name = "style_traits"
path = "lib.rs" path = "lib.rs"
[features] [features]
servo = ["serde", "servo_atoms", "cssparser/serde", "webrender_api"] servo = ["serde", "servo_atoms", "cssparser/serde", "webrender_api", "servo_url"]
gecko = [] gecko = []
[dependencies] [dependencies]
@ -25,3 +25,4 @@ serde = {version = "1.0", optional = true}
webrender_api = {git = "https://github.com/servo/webrender", optional = true} webrender_api = {git = "https://github.com/servo/webrender", optional = true}
servo_atoms = {path = "../atoms", optional = true} servo_atoms = {path = "../atoms", optional = true}
servo_arc = { path = "../servo_arc" } servo_arc = { path = "../servo_arc" }
servo_url = { path = "../url", optional = true }

View file

@ -22,6 +22,7 @@ extern crate selectors;
#[cfg(feature = "servo")] extern crate webrender_api; #[cfg(feature = "servo")] extern crate webrender_api;
extern crate servo_arc; extern crate servo_arc;
#[cfg(feature = "servo")] extern crate servo_atoms; #[cfg(feature = "servo")] extern crate servo_atoms;
#[cfg(feature = "servo")] extern crate servo_url;
#[cfg(feature = "servo")] pub use webrender_api::DevicePixel; #[cfg(feature = "servo")] pub use webrender_api::DevicePixel;

View file

@ -6,6 +6,7 @@
use servo_arc::Arc; use servo_arc::Arc;
use std::ops::Range; use std::ops::Range;
use std::sync::Arc as StdArc;
/// Type of value that a property supports. This is used by Gecko's /// Type of value that a property supports. This is used by Gecko's
/// devtools to make sense about value it parses, and types listed /// devtools to make sense about value it parses, and types listed
@ -84,6 +85,11 @@ impl SpecifiedValueInfo for u32 {}
impl SpecifiedValueInfo for str {} impl SpecifiedValueInfo for str {}
impl SpecifiedValueInfo for String {} impl SpecifiedValueInfo for String {}
#[cfg(feature = "servo")]
impl SpecifiedValueInfo for ::servo_atoms::Atom {}
#[cfg(feature = "servo")]
impl SpecifiedValueInfo for ::servo_url::ServoUrl {}
impl<T: SpecifiedValueInfo + ?Sized> SpecifiedValueInfo for Box<T> { impl<T: SpecifiedValueInfo + ?Sized> SpecifiedValueInfo for Box<T> {
const SUPPORTED_TYPES: u8 = T::SUPPORTED_TYPES; const SUPPORTED_TYPES: u8 = T::SUPPORTED_TYPES;
fn collect_completion_keywords(f: KeywordsCollectFn) { fn collect_completion_keywords(f: KeywordsCollectFn) {
@ -111,6 +117,7 @@ macro_rules! impl_generic_specified_value_info {
impl_generic_specified_value_info!(Option<T>); impl_generic_specified_value_info!(Option<T>);
impl_generic_specified_value_info!(Vec<T>); impl_generic_specified_value_info!(Vec<T>);
impl_generic_specified_value_info!(Arc<T>); impl_generic_specified_value_info!(Arc<T>);
impl_generic_specified_value_info!(StdArc<T>);
impl_generic_specified_value_info!(Range<Idx>); impl_generic_specified_value_info!(Range<Idx>);
impl<T1, T2> SpecifiedValueInfo for (T1, T2) impl<T1, T2> SpecifiedValueInfo for (T1, T2)

View file

@ -487,42 +487,6 @@ mod shorthand_serialization {
} }
} }
mod outline {
use style::values::specified::outline::OutlineStyle;
use super::*;
#[test]
fn outline_should_show_all_properties_when_set() {
let mut properties = Vec::new();
let width = BorderSideWidth::Length(Length::from_px(4f32));
let style = OutlineStyle::Other(BorderStyle::Solid);
let color = RGBA::new(255, 0, 0, 255).into();
properties.push(PropertyDeclaration::OutlineWidth(width));
properties.push(PropertyDeclaration::OutlineStyle(style));
properties.push(PropertyDeclaration::OutlineColor(color));
let serialization = shorthand_properties_to_string(properties);
assert_eq!(serialization, "outline: 4px solid rgb(255, 0, 0);");
}
#[test]
fn outline_should_serialize_correctly_when_style_is_auto() {
let mut properties = Vec::new();
let width = BorderSideWidth::Length(Length::from_px(4f32));
let style = OutlineStyle::Auto;
let color = RGBA::new(255, 0, 0, 255).into();
properties.push(PropertyDeclaration::OutlineWidth(width));
properties.push(PropertyDeclaration::OutlineStyle(style));
properties.push(PropertyDeclaration::OutlineColor(color));
let serialization = shorthand_properties_to_string(properties);
assert_eq!(serialization, "outline: 4px auto rgb(255, 0, 0);");
}
}
mod background { mod background {
use super::*; use super::*;

View file

@ -62,11 +62,12 @@ fn parse_rules(css: &str) -> Vec<(StyleSource, CascadeLevel)> {
let rules = s.contents.rules.read_with(&guard); let rules = s.contents.rules.read_with(&guard);
rules.0.iter().filter_map(|rule| { rules.0.iter().filter_map(|rule| {
match *rule { match *rule {
CssRule::Style(ref style_rule) => Some(style_rule), CssRule::Style(ref style_rule) => Some((
StyleSource::from_rule(style_rule.clone()),
CascadeLevel::UserNormal,
)),
_ => None, _ => None,
} }
}).cloned().map(StyleSource::Style).map(|s| {
(s, CascadeLevel::UserNormal)
}).collect() }).collect()
} }
@ -78,7 +79,7 @@ fn test_insertion_style_attribute(rule_tree: &RuleTree, rules: &[(StyleSource, C
shared_lock: &SharedRwLock) shared_lock: &SharedRwLock)
-> StrongRuleNode { -> StrongRuleNode {
let mut rules = rules.to_vec(); let mut rules = rules.to_vec();
rules.push((StyleSource::Declarations(Arc::new(shared_lock.wrap(PropertyDeclarationBlock::with_one( rules.push((StyleSource::from_declarations(Arc::new(shared_lock.wrap(PropertyDeclarationBlock::with_one(
PropertyDeclaration::Display( PropertyDeclaration::Display(
longhands::display::SpecifiedValue::Block), longhands::display::SpecifiedValue::Block),
Importance::Normal Importance::Normal