Merge CSSColor into Color.

This commit is contained in:
Xidorn Quan 2017-06-08 10:42:27 +10:00
parent bf77f81ed6
commit 7568a19688
25 changed files with 181 additions and 264 deletions

View file

@ -5,7 +5,7 @@
use cssparser::RGBA;
use parsing::parse;
use style::values::{Auto, Either};
use style::values::specified::{CSSColor, Color};
use style::values::specified::Color;
use style_traits::ToCss;
#[test]
@ -33,13 +33,13 @@ fn test_caret_color() {
let auto = parse_longhand!(caret_color, "auto");
assert_eq!(auto, Either::Second(Auto));
let blue_color = CSSColor {
parsed: Color::RGBA(RGBA {
let blue_color = Color::Numeric {
parsed: RGBA {
red: 0,
green: 0,
blue: 255,
alpha: 255,
}),
},
authored: Some(String::from("blue").into_boxed_str()),
};

View file

@ -8,7 +8,7 @@ use style::properties::{PropertyDeclaration, Importance, PropertyId};
use style::properties::parse_property_declaration_list;
use style::values::{RGBA, Auto};
use style::values::CustomIdent;
use style::values::specified::{BorderStyle, BorderSideWidth, CSSColor};
use style::values::specified::{BorderStyle, BorderSideWidth, Color};
use style::values::specified::{Length, LengthOrPercentage};
use style::values::specified::{LengthOrPercentageOrAuto, LengthOrPercentageOrAutoOrContent};
use style::values::specified::{NoCalcLength, PositionComponent};
@ -110,10 +110,7 @@ mod shorthand_serialization {
let line = TextDecorationLine::OVERLINE;
let style = TextDecorationStyle::dotted;
let color = CSSColor {
parsed: RGBA::new(128, 0, 128, 255).into(),
authored: None
};
let color = RGBA::new(128, 0, 128, 255).into();
properties.push(PropertyDeclaration::TextDecorationLine(line));
properties.push(PropertyDeclaration::TextDecorationStyle(style));
@ -129,7 +126,7 @@ mod shorthand_serialization {
let line = TextDecorationLine::UNDERLINE;
let style = TextDecorationStyle::solid;
let color = CSSColor::currentcolor();
let color = Color::currentcolor();
properties.push(PropertyDeclaration::TextDecorationLine(line));
properties.push(PropertyDeclaration::TextDecorationStyle(style));
@ -229,10 +226,7 @@ mod shorthand_serialization {
properties.push(PropertyDeclaration::BorderBottomWidth(px_30.clone()));
properties.push(PropertyDeclaration::BorderLeftWidth(px_10.clone()));
let blue = CSSColor {
parsed: RGBA::new(0, 0, 255, 255).into(),
authored: None
};
let blue = Color::rgba(RGBA::new(0, 0, 255, 255));
properties.push(PropertyDeclaration::BorderTopColor(blue.clone()));
properties.push(PropertyDeclaration::BorderRightColor(blue.clone()));
@ -262,10 +256,7 @@ mod shorthand_serialization {
properties.push(PropertyDeclaration::BorderBottomWidth(px_30.clone()));
properties.push(PropertyDeclaration::BorderLeftWidth(px_30.clone()));
let blue = CSSColor {
parsed: RGBA::new(0, 0, 255, 255).into(),
authored: None
};
let blue = Color::rgba(RGBA::new(0, 0, 255, 255));
properties.push(PropertyDeclaration::BorderTopColor(blue.clone()));
properties.push(PropertyDeclaration::BorderRightColor(blue.clone()));
@ -332,15 +323,8 @@ mod shorthand_serialization {
fn border_color_should_serialize_correctly() {
let mut properties = Vec::new();
let red = CSSColor {
parsed: RGBA::new(255, 0, 0, 255).into(),
authored: None
};
let blue = CSSColor {
parsed: RGBA::new(0, 0, 255, 255).into(),
authored: None
};
let red = Color::rgba(RGBA::new(255, 0, 0, 255));
let blue = Color::rgba(RGBA::new(0, 0, 255, 255));
properties.push(PropertyDeclaration::BorderTopColor(blue.clone()));
properties.push(PropertyDeclaration::BorderRightColor(red.clone()));
@ -405,10 +389,7 @@ mod shorthand_serialization {
let width = BorderSideWidth::Length(Length::from_px(4f32));
let style = BorderStyle::solid;
let color = CSSColor {
parsed: RGBA::new(255, 0, 0, 255).into(),
authored: None
};
let color = RGBA::new(255, 0, 0, 255).into();
properties.push(PropertyDeclaration::BorderTopWidth(width));
properties.push(PropertyDeclaration::BorderTopStyle(style));
@ -418,10 +399,10 @@ mod shorthand_serialization {
assert_eq!(serialization, "border-top: 4px solid rgb(255, 0, 0);");
}
fn get_border_property_values() -> (BorderSideWidth, BorderStyle, CSSColor) {
fn get_border_property_values() -> (BorderSideWidth, BorderStyle, Color) {
(BorderSideWidth::Length(Length::from_px(4f32)),
BorderStyle::solid,
CSSColor::currentcolor())
Color::currentcolor())
}
#[test]
@ -532,10 +513,7 @@ mod shorthand_serialization {
let width = BorderSideWidth::Length(Length::from_px(4f32));
let style = Either::Second(BorderStyle::solid);
let color = CSSColor {
parsed: RGBA::new(255, 0, 0, 255).into(),
authored: None
};
let color = RGBA::new(255, 0, 0, 255).into();
properties.push(PropertyDeclaration::OutlineWidth(width));
properties.push(PropertyDeclaration::OutlineStyle(style));
@ -551,10 +529,7 @@ mod shorthand_serialization {
let width = BorderSideWidth::Length(Length::from_px(4f32));
let style = Either::First(Auto);
let color = CSSColor {
parsed: RGBA::new(255, 0, 0, 255).into(),
authored: None
};
let color = RGBA::new(255, 0, 0, 255).into();
properties.push(PropertyDeclaration::OutlineWidth(width));
properties.push(PropertyDeclaration::OutlineStyle(style));
properties.push(PropertyDeclaration::OutlineColor(color));

View file

@ -158,9 +158,9 @@ fn test_parse_stylesheet() {
)),
block: Arc::new(stylesheet.shared_lock.wrap(block_from(vec![
(PropertyDeclaration::BackgroundColor(
longhands::background_color::SpecifiedValue {
longhands::background_color::SpecifiedValue::Numeric {
authored: Some("blue".to_owned().into_boxed_str()),
parsed: cssparser::RGBA::new(0, 0, 255, 255).into(),
parsed: cssparser::RGBA::new(0, 0, 255, 255),
}
),
Importance::Normal),

View file

@ -1,5 +0,0 @@
[cssstyledeclaration-csstext.htm]
type: testharness
[uppercase value]
expected: FAIL