No bug - Fix tidy issues and Servo build, and fix unit test bustage. r=me

MozReview-Commit-ID: 7MFLnVZmZUg
This commit is contained in:
Emilio Cobos Álvarez 2018-04-29 03:02:21 +02:00
Родитель b921c5e746
Коммит b52948e2af
14 изменённых файлов: 31 добавлений и 55 удалений

Просмотреть файл

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

Просмотреть файл

@ -925,7 +925,7 @@ impl<T: 'static> Arc<T> {
///
/// ArcBorrow lets us deal with borrows of known-refcounted objects
/// 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);
impl<'a, T> Copy for ArcBorrow<'a, T> {}

Просмотреть файл

@ -450,7 +450,7 @@ ${helpers.predefined_type("-x-text-zoom",
// a lot of code with `if product == gecko` conditionals, we have a
// 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))]
/// void enum for system font, can never exist
pub enum SystemFont {}

Просмотреть файл

@ -23,7 +23,7 @@ use values::computed::{Context, ToComputedValue};
///
/// However, this approach is still not necessarily optimal: See
/// <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 {
/// 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

Просмотреть файл

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

Просмотреть файл

@ -71,7 +71,7 @@ where
/// Convenience void type to disable some properties and values through types.
#[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 {}
// 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>
#[derive(Clone, Debug, MallocSizeOf, ToComputedValue, SpecifiedValueInfo)]
#[derive(Clone, Debug, MallocSizeOf, SpecifiedValueInfo, ToComputedValue)]
pub enum KeyframesName {
/// <custom-ident>
Ident(CustomIdent),

Просмотреть файл

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

Просмотреть файл

@ -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::{FamilyName, FontFamilyList, FontStyleAngle, SingleFontFamily};
use values::generics::NonNegative;
use values::generics::font::{self as generics, FeatureTagValue, FontSettings, FontTag};
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::length::{FontBaseSize, AU_PER_PT, AU_PER_PX};

Просмотреть файл

@ -4,7 +4,7 @@
use cg;
use quote::Tokens;
use syn::{Data, DeriveInput, Fields, Ident,Type};
use syn::{Data, DeriveInput, Fields, Ident, Type};
use to_css::{CssFieldAttrs, CssInputAttrs, CssVariantAttrs};
pub fn derive(mut input: DeriveInput) -> Tokens {
@ -101,7 +101,7 @@ pub fn derive(mut input: DeriveInput) -> Tokens {
quote!()
} else {
let mut value_list = quote!();
value_list.append_separated(values.iter(), quote!(,));
value_list.append_separated(values.iter(), quote! { , });
quote! { _f(&[#value_list]); }
};

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

@ -6,6 +6,7 @@
use servo_arc::Arc;
use std::ops::Range;
use std::sync::Arc as StdArc;
/// Type of value that a property supports. This is used by Gecko's
/// 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 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> {
const SUPPORTED_TYPES: u8 = T::SUPPORTED_TYPES;
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!(Vec<T>);
impl_generic_specified_value_info!(Arc<T>);
impl_generic_specified_value_info!(StdArc<T>);
impl_generic_specified_value_info!(Range<Idx>);
impl<T1, T2> SpecifiedValueInfo for (T1, T2)

Просмотреть файл

@ -520,42 +520,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 {
use super::*;

Просмотреть файл

@ -62,11 +62,12 @@ fn parse_rules(css: &str) -> Vec<(StyleSource, CascadeLevel)> {
let rules = s.contents.rules.read_with(&guard);
rules.0.iter().filter_map(|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,
}
}).cloned().map(StyleSource::Style).map(|s| {
(s, CascadeLevel::UserNormal)
}).collect()
}
@ -78,7 +79,7 @@ fn test_insertion_style_attribute(rule_tree: &RuleTree, rules: &[(StyleSource, C
shared_lock: &SharedRwLock)
-> StrongRuleNode {
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(
longhands::display::SpecifiedValue::Block),
Importance::Normal