Auto merge of #7518 - servo:custom-properties, r=pcwalton

Initial support for CSS Custom Properties

https://drafts.csswg.org/css-variables/

Missing: 

* `var()` in shorthand property declarations.
* Correct handling of EOF in custom property declarations.

r? @pcwalton

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/7518)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2015-09-03 16:09:02 -06:00
commit 05deb3dcc8
104 changed files with 961 additions and 116 deletions

View file

@ -62,7 +62,7 @@ use dom::virtualmethods::{VirtualMethods, vtable_for};
use devtools_traits::AttrInfo;
use smallvec::VecLike;
use style::legacy::{UnsignedIntegerAttribute, from_declaration};
use style::properties::DeclaredValue::SpecifiedValue;
use style::properties::DeclaredValue;
use style::properties::longhands::{self, background_image, border_spacing};
use style::properties::{PropertyDeclarationBlock, PropertyDeclaration, parse_style_attribute};
use style::values::CSSFloat;
@ -271,7 +271,7 @@ impl RawLayoutElementHelpers for Element {
if let Some(color) = bgcolor {
hints.push(from_declaration(
PropertyDeclaration::BackgroundColor(SpecifiedValue(
PropertyDeclaration::BackgroundColor(DeclaredValue::Value(
CSSColor { parsed: Color::RGBA(color), authored: None }))));
}
@ -284,7 +284,7 @@ impl RawLayoutElementHelpers for Element {
if let Some(url) = background {
hints.push(from_declaration(
PropertyDeclaration::BackgroundImage(SpecifiedValue(
PropertyDeclaration::BackgroundImage(DeclaredValue::Value(
background_image::SpecifiedValue(Some(specified::Image::Url(url)))))));
}
@ -297,7 +297,7 @@ impl RawLayoutElementHelpers for Element {
if let Some(color) = color {
hints.push(from_declaration(
PropertyDeclaration::Color(SpecifiedValue(CSSRGBA {
PropertyDeclaration::Color(DeclaredValue::Value(CSSRGBA {
parsed: color,
authored: None,
}))));
@ -313,7 +313,7 @@ impl RawLayoutElementHelpers for Element {
if let Some(cellspacing) = cellspacing {
let width_value = specified::Length::Absolute(Au::from_px(cellspacing as i32));
hints.push(from_declaration(
PropertyDeclaration::BorderSpacing(SpecifiedValue(
PropertyDeclaration::BorderSpacing(DeclaredValue::Value(
border_spacing::SpecifiedValue {
horizontal: width_value,
vertical: width_value,
@ -343,7 +343,7 @@ impl RawLayoutElementHelpers for Element {
let value = specified::Length::ServoCharacterWidth(
specified::CharacterWidth(size));
hints.push(from_declaration(
PropertyDeclaration::Width(SpecifiedValue(
PropertyDeclaration::Width(DeclaredValue::Value(
specified::LengthOrPercentageOrAuto::Length(value)))));
}
@ -367,13 +367,13 @@ impl RawLayoutElementHelpers for Element {
let width_value =
specified::LengthOrPercentageOrAuto::Percentage(specified::Percentage(percentage));
hints.push(from_declaration(
PropertyDeclaration::Width(SpecifiedValue(width_value))));
PropertyDeclaration::Width(DeclaredValue::Value(width_value))));
}
LengthOrPercentageOrAuto::Length(length) => {
let width_value = specified::LengthOrPercentageOrAuto::Length(
specified::Length::Absolute(length));
hints.push(from_declaration(
PropertyDeclaration::Width(SpecifiedValue(width_value))));
PropertyDeclaration::Width(DeclaredValue::Value(width_value))));
}
}
@ -391,13 +391,13 @@ impl RawLayoutElementHelpers for Element {
let height_value =
specified::LengthOrPercentageOrAuto::Percentage(specified::Percentage(percentage));
hints.push(from_declaration(
PropertyDeclaration::Height(SpecifiedValue(height_value))));
PropertyDeclaration::Height(DeclaredValue::Value(height_value))));
}
LengthOrPercentageOrAuto::Length(length) => {
let height_value = specified::LengthOrPercentageOrAuto::Length(
specified::Length::Absolute(length));
hints.push(from_declaration(
PropertyDeclaration::Height(SpecifiedValue(height_value))));
PropertyDeclaration::Height(DeclaredValue::Value(height_value))));
}
}
@ -420,7 +420,7 @@ impl RawLayoutElementHelpers for Element {
// https://html.spec.whatwg.org/multipage/#textarea-effective-width
let value = specified::Length::ServoCharacterWidth(specified::CharacterWidth(cols));
hints.push(from_declaration(
PropertyDeclaration::Width(SpecifiedValue(
PropertyDeclaration::Width(DeclaredValue::Value(
specified::LengthOrPercentageOrAuto::Length(value)))));
}
@ -441,7 +441,7 @@ impl RawLayoutElementHelpers for Element {
// https://html.spec.whatwg.org/multipage/#textarea-effective-height
let value = specified::Length::FontRelative(specified::FontRelativeLength::Em(rows as CSSFloat));
hints.push(from_declaration(
PropertyDeclaration::Height(SpecifiedValue(
PropertyDeclaration::Height(DeclaredValue::Value(
specified::LengthOrPercentageOrAuto::Length(value)))));
}
@ -456,16 +456,16 @@ impl RawLayoutElementHelpers for Element {
if let Some(border) = border {
let width_value = specified::Length::Absolute(Au::from_px(border as i32));
hints.push(from_declaration(
PropertyDeclaration::BorderTopWidth(SpecifiedValue(
PropertyDeclaration::BorderTopWidth(DeclaredValue::Value(
longhands::border_top_width::SpecifiedValue(width_value)))));
hints.push(from_declaration(
PropertyDeclaration::BorderLeftWidth(SpecifiedValue(
PropertyDeclaration::BorderLeftWidth(DeclaredValue::Value(
longhands::border_left_width::SpecifiedValue(width_value)))));
hints.push(from_declaration(
PropertyDeclaration::BorderBottomWidth(SpecifiedValue(
PropertyDeclaration::BorderBottomWidth(DeclaredValue::Value(
longhands::border_bottom_width::SpecifiedValue(width_value)))));
hints.push(from_declaration(
PropertyDeclaration::BorderRightWidth(SpecifiedValue(
PropertyDeclaration::BorderRightWidth(DeclaredValue::Value(
longhands::border_right_width::SpecifiedValue(width_value)))));
}
}