From 09e60beb78729ad39d421401d5a01fb2d1a6fb4f Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Wed, 22 Jul 2015 17:13:19 +0200 Subject: [PATCH 01/15] Add parsing of CSS Custom Properties. --- components/style/custom_properties.rs | 125 ++++++++++++++++++++++++++ components/style/lib.rs | 1 + components/style/properties.mako.rs | 59 +++++++++--- 3 files changed, 175 insertions(+), 10 deletions(-) create mode 100644 components/style/custom_properties.rs diff --git a/components/style/custom_properties.rs b/components/style/custom_properties.rs new file mode 100644 index 00000000000..fc28e8a5994 --- /dev/null +++ b/components/style/custom_properties.rs @@ -0,0 +1,125 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +use cssparser::{Parser, Token}; +use std::collections::{HashMap, HashSet}; +use std::sync::Arc; +use string_cache::Atom; + +#[derive(Clone)] +pub struct Value { + /// In CSS syntax + pub value: String, + + /// Custom property names in var() functions + pub references: HashSet, +} + +/// Names (atoms) do not include the `--` prefix. +pub type Map = HashMap; + +pub fn parse(input: &mut Parser) -> Result { + let start = input.position(); + let mut references = HashSet::new(); + try!(parse_declaration_value(input, &mut references)); + Ok(Value { + value: input.slice_from(start).to_owned(), + references: references, + }) +} + +/// https://drafts.csswg.org/css-syntax-3/#typedef-declaration-value +fn parse_declaration_value(input: &mut Parser, references: &mut HashSet) -> Result<(), ()> { + while let Ok(token) = input.next() { + match token { + Token::BadUrl | + Token::BadString | + Token::CloseParenthesis | + Token::CloseSquareBracket | + Token::CloseCurlyBracket | + + Token::Semicolon | + Token::Delim('!') => { + return Err(()) + } + + Token::Function(ref name) if name == "var" => { + try!(parse_var_function(input, references)); + } + + Token::Function(_) | + Token::ParenthesisBlock | + Token::CurlyBracketBlock | + Token::SquareBracketBlock => { + try!(parse_declaration_value_block(input, references)) + } + + _ => {} + } + } + Ok(()) +} + +/// Like parse_declaration_value, +/// but accept `!` and `;` since they are only invalid at the top level +fn parse_declaration_value_block(input: &mut Parser, references: &mut HashSet) + -> Result<(), ()> { + while let Ok(token) = input.next() { + match token { + Token::BadUrl | + Token::BadString | + Token::CloseParenthesis | + Token::CloseSquareBracket | + Token::CloseCurlyBracket => { + return Err(()) + } + + Token::Function(ref name) if name == "var" => { + try!(parse_var_function(input, references)); + } + + Token::Function(_) | + Token::ParenthesisBlock | + Token::CurlyBracketBlock | + Token::SquareBracketBlock => { + try!(parse_declaration_value_block(input, references)) + } + + _ => {} + } + } + Ok(()) +} + +// If the var function is valid, return Ok((custom_property_name, fallback)) +fn parse_var_function<'i, 't>(input: &mut Parser<'i, 't>, references: &mut HashSet) + -> Result<(), ()> { + // https://drafts.csswg.org/css-variables/#typedef-custom-property-name + let name = try!(input.expect_ident()); + let name = if name.starts_with("--") { + &name[2..] + } else { + return Err(()) + }; + if input.expect_comma().is_ok() { + try!(parse_declaration_value(input, references)); + } + references.insert(Atom::from_slice(name)); + Ok(()) +} + +pub fn cascade(custom_properties: &mut Option, inherited_custom_properties: &Option>, + name: &Atom, value: &Value) { + let map = match *custom_properties { + Some(ref mut map) => map, + None => { + *custom_properties = Some(match *inherited_custom_properties { + Some(ref arc) => (**arc).clone(), + None => HashMap::new(), + }); + custom_properties.as_mut().unwrap() + } + }; + map.entry(name.clone()).or_insert(value.clone()); +} diff --git a/components/style/lib.rs b/components/style/lib.rs index 99390a4bc3a..1d7622ce088 100644 --- a/components/style/lib.rs +++ b/components/style/lib.rs @@ -43,6 +43,7 @@ extern crate num; extern crate util; +mod custom_properties; pub mod stylesheets; pub mod parser; pub mod selector_matching; diff --git a/components/style/properties.mako.rs b/components/style/properties.mako.rs index 857718e7a44..f0ddef0c503 100644 --- a/components/style/properties.mako.rs +++ b/components/style/properties.mako.rs @@ -22,6 +22,7 @@ use util::logical_geometry::{LogicalMargin, PhysicalSide, WritingMode}; use euclid::SideOffsets2D; use euclid::size::Size2D; use fnv::FnvHasher; +use string_cache::Atom; use computed_values; use parser::{ParserContext, log_css_error}; @@ -5610,6 +5611,7 @@ fn deduplicate_property_declarations(declarations: Vec) -> Vec { let mut deduplicated = vec![]; let mut seen = PropertyBitField::new(); + let mut seen_custom = Vec::new(); for declaration in declarations.into_iter().rev() { match declaration { % for property in LONGHANDS: @@ -5624,6 +5626,12 @@ fn deduplicate_property_declarations(declarations: Vec) % endif }, % endfor + PropertyDeclaration::Custom(ref name, _) => { + if seen_custom.contains(name) { + continue + } + seen_custom.push(name.clone()) + } } deduplicated.push(declaration) } @@ -5675,6 +5683,8 @@ pub enum PropertyDeclaration { % for property in LONGHANDS: ${property.camel_case}(DeclaredValue), % endfor + /// Name (atom) does not include the `--` prefix. + Custom(Atom, ::custom_properties::Value), } @@ -5725,6 +5735,15 @@ impl PropertyDeclaration { pub fn parse(name: &str, context: &ParserContext, input: &mut Parser, result_list: &mut Vec) -> PropertyDeclarationParseResult { + if name.starts_with("--") { + if let Ok(value) = ::custom_properties::parse(input) { + let name = Atom::from_slice(&name[2..]); + result_list.push(PropertyDeclaration::Custom(name, value)); + return PropertyDeclarationParseResult::ValidOrIgnoredDeclaration; + } else { + return PropertyDeclarationParseResult::InvalidValue; + } + } match_ignore_ascii_case! { name, % for property in LONGHANDS: % if property.derived_from is None: @@ -5832,6 +5851,7 @@ pub struct ComputedValues { % for style_struct in STYLE_STRUCTS: ${style_struct.ident}: Arc, % endfor + custom_properties: Option>, shareable: bool, pub writing_mode: WritingMode, pub root_font_size: Au, @@ -6050,6 +6070,7 @@ lazy_static! { % endif }), % endfor + custom_properties: None, shareable: true, writing_mode: WritingMode::empty(), root_font_size: longhands::font_size::get_initial_value(), @@ -6073,6 +6094,7 @@ fn cascade_with_cached_declarations( let mut style_${style_struct.ident} = cached_style.${style_struct.ident}.clone(); % endif % endfor + let mut custom_properties = None; let mut seen = PropertyBitField::new(); // Declaration blocks are stored in increasing precedence order, @@ -6134,6 +6156,10 @@ fn cascade_with_cached_declarations( % endif % endfor % endfor + PropertyDeclaration::Custom(ref name, ref value) => { + ::custom_properties::cascade( + &mut custom_properties, &parent_style.custom_properties, name, value) + } } } } @@ -6148,6 +6174,8 @@ fn cascade_with_cached_declarations( % for style_struct in STYLE_STRUCTS: ${style_struct.ident}: style_${style_struct.ident}, % endfor + custom_properties: custom_properties + .map(Arc::new).or_else(|| parent_style.custom_properties.clone()), shareable: shareable, root_font_size: parent_style.root_font_size, } @@ -6210,7 +6238,6 @@ pub fn cascade(viewport_size: Size2D, Some(parent_style) => (false, parent_style), None => (true, initial_values), }; - let mut context = { let inherited_font_style = inherited_style.get_font(); computed::Context { @@ -6348,12 +6375,14 @@ pub fn cascade(viewport_size: Size2D, % endif .${style_struct.ident}.clone(), % endfor + custom_properties: None, shareable: false, writing_mode: WritingMode::empty(), root_font_size: context.root_font_size, }; let mut cacheable = true; let mut seen = PropertyBitField::new(); + let mut custom_properties = None; // Declaration blocks are stored in increasing precedence order, we want them in decreasing // order here. // @@ -6364,15 +6393,23 @@ pub fn cascade(viewport_size: Size2D, for sub_list in applicable_declarations.iter().rev() { // Declarations are already stored in reverse order. for declaration in sub_list.declarations.iter() { - let discriminant = unsafe { - intrinsics::discriminant_value(declaration) as usize - }; - (cascade_property[discriminant].unwrap())(declaration, - &mut style, - inherited_style, - &context, - &mut seen, - &mut cacheable); + match *declaration { + PropertyDeclaration::Custom(ref name, ref value) => { + ::custom_properties::cascade( + &mut custom_properties, &inherited_style.custom_properties, name, value) + } + _ => { + let discriminant = unsafe { + intrinsics::discriminant_value(declaration) as usize + }; + (cascade_property[discriminant].unwrap())(declaration, + &mut style, + inherited_style, + &context, + &mut seen, + &mut cacheable); + } + } } } }); @@ -6414,6 +6451,8 @@ pub fn cascade(viewport_size: Size2D, % for style_struct in STYLE_STRUCTS: ${style_struct.ident}: style.${style_struct.ident}, % endfor + custom_properties: custom_properties + .map(Arc::new).or_else(|| inherited_style.custom_properties.clone()), shareable: shareable, root_font_size: context.root_font_size, }, cacheable) From 65d4ecaa392b49caa33e7bd86c9d7888dbd3a342 Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Wed, 22 Jul 2015 20:42:04 +0200 Subject: [PATCH 02/15] Remove custom property declarations in dependency cycles. --- components/style/custom_properties.rs | 55 ++++++++++++++++++++++++++- components/style/lib.rs | 1 + components/style/properties.mako.rs | 8 ++-- 3 files changed, 59 insertions(+), 5 deletions(-) diff --git a/components/style/custom_properties.rs b/components/style/custom_properties.rs index fc28e8a5994..5e8d6544073 100644 --- a/components/style/custom_properties.rs +++ b/components/style/custom_properties.rs @@ -12,7 +12,7 @@ pub struct Value { /// In CSS syntax pub value: String, - /// Custom property names in var() functions + /// Custom property names in var() functions. Do not include the `--` prefix. pub references: HashSet, } @@ -109,6 +109,8 @@ fn parse_var_function<'i, 't>(input: &mut Parser<'i, 't>, references: &mut HashS Ok(()) } +/// Add one custom property declaration to a map, +/// unless another with the same name was already there. pub fn cascade(custom_properties: &mut Option, inherited_custom_properties: &Option>, name: &Atom, value: &Value) { let map = match *custom_properties { @@ -123,3 +125,54 @@ pub fn cascade(custom_properties: &mut Option, inherited_custom_properties: }; map.entry(name.clone()).or_insert(value.clone()); } + +/// If any custom property declarations where found for this element (`custom_properties.is_some()`) +/// remove cycles and move the map into an `Arc`. +/// Otherwise, default to the inherited map. +pub fn finish_cascade(custom_properties: Option, + inherited_custom_properties: &Option>) + -> Option> { + if let Some(mut map) = custom_properties { + remove_cycles(&mut map); + Some(Arc::new(map)) + } else { + inherited_custom_properties.clone() + } +} + +/// https://drafts.csswg.org/css-variables/#cycles +fn remove_cycles(map: &mut Map) { + let mut to_remove = HashSet::new(); + { + let mut visited = HashSet::new(); + let mut stack = Vec::new(); + for name in map.keys() { + walk(map, name, &mut stack, &mut visited, &mut to_remove); + + fn walk<'a>(map: &'a Map, name: &'a Atom, stack: &mut Vec<&'a Atom>, + visited: &mut HashSet<&'a Atom>, to_remove: &mut HashSet) { + let was_not_already_present = visited.insert(name); + if !was_not_already_present { + return + } + if let Some(value) = map.get(name) { + stack.push(name); + for next in &value.references { + if let Some(position) = stack.position_elem(&next) { + // Found a cycle + for in_cycle in &stack[position..] { + to_remove.insert((**in_cycle).clone()); + } + } else { + walk(map, next, stack, visited, to_remove); + } + } + stack.pop(); + } + } + } + } + for name in &to_remove { + map.remove(name); + } +} diff --git a/components/style/lib.rs b/components/style/lib.rs index 1d7622ce088..0822c67dd91 100644 --- a/components/style/lib.rs +++ b/components/style/lib.rs @@ -9,6 +9,7 @@ #![feature(custom_attribute)] #![feature(custom_derive)] #![feature(plugin)] +#![feature(slice_position_elem)] #![feature(vec_push_all)] #![plugin(serde_macros)] diff --git a/components/style/properties.mako.rs b/components/style/properties.mako.rs index f0ddef0c503..38dd602a75e 100644 --- a/components/style/properties.mako.rs +++ b/components/style/properties.mako.rs @@ -6174,8 +6174,8 @@ fn cascade_with_cached_declarations( % for style_struct in STYLE_STRUCTS: ${style_struct.ident}: style_${style_struct.ident}, % endfor - custom_properties: custom_properties - .map(Arc::new).or_else(|| parent_style.custom_properties.clone()), + custom_properties: ::custom_properties::finish_cascade( + custom_properties, &parent_style.custom_properties), shareable: shareable, root_font_size: parent_style.root_font_size, } @@ -6451,8 +6451,8 @@ pub fn cascade(viewport_size: Size2D, % for style_struct in STYLE_STRUCTS: ${style_struct.ident}: style.${style_struct.ident}, % endfor - custom_properties: custom_properties - .map(Arc::new).or_else(|| inherited_style.custom_properties.clone()), + custom_properties: ::custom_properties::finish_cascade( + custom_properties, &inherited_style.custom_properties), shareable: shareable, root_font_size: context.root_font_size, }, cacheable) From 3fcd8938f3351e74bbc0c532a2e9745c2a481abd Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Wed, 22 Jul 2015 21:19:37 +0200 Subject: [PATCH 03/15] Support CSS-wide keywords in custom properties --- components/style/custom_properties.rs | 39 ++++++++++++++++++--------- components/style/properties.mako.rs | 30 ++++++++++++++------- 2 files changed, 47 insertions(+), 22 deletions(-) diff --git a/components/style/custom_properties.rs b/components/style/custom_properties.rs index 5e8d6544073..d7bc5bdc1a8 100644 --- a/components/style/custom_properties.rs +++ b/components/style/custom_properties.rs @@ -3,6 +3,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use cssparser::{Parser, Token}; +use properties::DeclaredValue; use std::collections::{HashMap, HashSet}; use std::sync::Arc; use string_cache::Atom; @@ -111,19 +112,33 @@ fn parse_var_function<'i, 't>(input: &mut Parser<'i, 't>, references: &mut HashS /// Add one custom property declaration to a map, /// unless another with the same name was already there. -pub fn cascade(custom_properties: &mut Option, inherited_custom_properties: &Option>, - name: &Atom, value: &Value) { - let map = match *custom_properties { - Some(ref mut map) => map, - None => { - *custom_properties = Some(match *inherited_custom_properties { - Some(ref arc) => (**arc).clone(), - None => HashMap::new(), - }); - custom_properties.as_mut().unwrap() +pub fn cascade<'a>(custom_properties: &mut Option, + inherited_custom_properties: &Option>, + seen: &mut HashSet<&'a Atom>, + name: &'a Atom, + value: &DeclaredValue) { + let was_not_already_present = seen.insert(name); + if was_not_already_present { + let map = match *custom_properties { + Some(ref mut map) => map, + None => { + *custom_properties = Some(match *inherited_custom_properties { + Some(ref arc) => (**arc).clone(), + None => HashMap::new(), + }); + custom_properties.as_mut().unwrap() + } + }; + match *value { + DeclaredValue::SpecifiedValue(ref value) => { + map.insert(name.clone(), value.clone()); + } + DeclaredValue::Initial => { + map.remove(name); + } + DeclaredValue::Inherit => {} // The inherited value is what we already have. } - }; - map.entry(name.clone()).or_insert(value.clone()); + } } /// If any custom property declarations where found for this element (`custom_properties.is_some()`) diff --git a/components/style/properties.mako.rs b/components/style/properties.mako.rs index 38dd602a75e..a2dd00916f1 100644 --- a/components/style/properties.mako.rs +++ b/components/style/properties.mako.rs @@ -6,6 +6,7 @@ use std::ascii::AsciiExt; use std::borrow::ToOwned; +use std::collections::HashSet; use std::default::Default; use std::fmt; use std::fmt::Debug; @@ -5684,7 +5685,7 @@ pub enum PropertyDeclaration { ${property.camel_case}(DeclaredValue), % endfor /// Name (atom) does not include the `--` prefix. - Custom(Atom, ::custom_properties::Value), + Custom(Atom, DeclaredValue<::custom_properties::Value>), } @@ -5736,13 +5737,18 @@ impl PropertyDeclaration { pub fn parse(name: &str, context: &ParserContext, input: &mut Parser, result_list: &mut Vec) -> PropertyDeclarationParseResult { if name.starts_with("--") { - if let Ok(value) = ::custom_properties::parse(input) { - let name = Atom::from_slice(&name[2..]); - result_list.push(PropertyDeclaration::Custom(name, value)); - return PropertyDeclarationParseResult::ValidOrIgnoredDeclaration; - } else { - return PropertyDeclarationParseResult::InvalidValue; - } + let value = match input.try(CSSWideKeyword::parse) { + Ok(CSSWideKeyword::UnsetKeyword) | // Custom properties are alawys inherited + Ok(CSSWideKeyword::InheritKeyword) => DeclaredValue::Inherit, + Ok(CSSWideKeyword::InitialKeyword) => DeclaredValue::Initial, + Err(()) => match ::custom_properties::parse(input) { + Ok(value) => DeclaredValue::SpecifiedValue(value), + Err(()) => return PropertyDeclarationParseResult::InvalidValue, + } + }; + let name = Atom::from_slice(&name[2..]); + result_list.push(PropertyDeclaration::Custom(name, value)); + return PropertyDeclarationParseResult::ValidOrIgnoredDeclaration; } match_ignore_ascii_case! { name, % for property in LONGHANDS: @@ -6097,6 +6103,7 @@ fn cascade_with_cached_declarations( let mut custom_properties = None; let mut seen = PropertyBitField::new(); + let mut seen_custom = HashSet::new(); // Declaration blocks are stored in increasing precedence order, // we want them in decreasing order here. for sub_list in applicable_declarations.iter().rev() { @@ -6158,7 +6165,8 @@ fn cascade_with_cached_declarations( % endfor PropertyDeclaration::Custom(ref name, ref value) => { ::custom_properties::cascade( - &mut custom_properties, &parent_style.custom_properties, name, value) + &mut custom_properties, &parent_style.custom_properties, + &mut seen_custom, name, value) } } } @@ -6390,13 +6398,15 @@ pub fn cascade(viewport_size: Size2D, // of compiled code! To improve i-cache behavior, we outline the individual functions and use // virtual dispatch instead. CASCADE_PROPERTY.with(|cascade_property| { + let mut seen_custom = HashSet::new(); for sub_list in applicable_declarations.iter().rev() { // Declarations are already stored in reverse order. for declaration in sub_list.declarations.iter() { match *declaration { PropertyDeclaration::Custom(ref name, ref value) => { ::custom_properties::cascade( - &mut custom_properties, &inherited_style.custom_properties, name, value) + &mut custom_properties, &inherited_style.custom_properties, + &mut seen_custom, name, value) } _ => { let discriminant = unsafe { From 5fb6acb753cb716f8e80fabae3633f8fd90baa80 Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Thu, 23 Jul 2015 01:14:03 +0200 Subject: [PATCH 04/15] Rename DeclaredValue::SpecifiedValue to DeclaredValue::Value --- components/script/dom/element.rs | 32 ++++++++++++++--------------- components/style/properties.mako.rs | 22 ++++++++++---------- tests/unit/style/stylesheets.rs | 6 +++--- 3 files changed, 30 insertions(+), 30 deletions(-) diff --git a/components/script/dom/element.rs b/components/script/dom/element.rs index f128e25626e..8d55dcdcedd 100644 --- a/components/script/dom/element.rs +++ b/components/script/dom/element.rs @@ -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))))); } } diff --git a/components/style/properties.mako.rs b/components/style/properties.mako.rs index a2dd00916f1..8ab6d2442e9 100644 --- a/components/style/properties.mako.rs +++ b/components/style/properties.mako.rs @@ -156,7 +156,7 @@ pub mod longhands { } seen.set_${property.ident}(); let computed_value = match *declared_value { - DeclaredValue::SpecifiedValue(ref specified_value) => { + DeclaredValue::Value(ref specified_value) => { specified_value.to_computed_value(&context) } DeclaredValue::Initial => get_initial_value(), @@ -209,7 +209,7 @@ pub mod longhands { % if derived_from is None: pub fn parse_specified(context: &ParserContext, input: &mut Parser) -> Result, ()> { - parse(context, input).map(DeclaredValue::SpecifiedValue) + parse(context, input).map(DeclaredValue::Value) } % endif @@ -1653,7 +1653,7 @@ pub mod longhands { Color::RGBA(rgba) => rgba, Color::CurrentColor => return Ok(DeclaredValue::Inherit) }; - Ok(DeclaredValue::SpecifiedValue(CSSRGBA { + Ok(DeclaredValue::Value(CSSRGBA { parsed: rgba, authored: value.authored, })) @@ -5661,7 +5661,7 @@ impl CSSWideKeyword { #[derive(Clone, PartialEq, Eq, Copy, Debug)] pub enum DeclaredValue { - SpecifiedValue(T), + Value(T), Initial, Inherit, // There is no Unset variant here. @@ -5672,7 +5672,7 @@ pub enum DeclaredValue { impl DeclaredValue { pub fn specified_value(&self) -> String { match self { - &DeclaredValue::SpecifiedValue(ref inner) => inner.to_css_string(), + &DeclaredValue::Value(ref inner) => inner.to_css_string(), &DeclaredValue::Initial => "initial".to_owned(), &DeclaredValue::Inherit => "inherit".to_owned(), } @@ -5742,7 +5742,7 @@ impl PropertyDeclaration { Ok(CSSWideKeyword::InheritKeyword) => DeclaredValue::Inherit, Ok(CSSWideKeyword::InitialKeyword) => DeclaredValue::Initial, Err(()) => match ::custom_properties::parse(input) { - Ok(value) => DeclaredValue::SpecifiedValue(value), + Ok(value) => DeclaredValue::Value(value), Err(()) => return PropertyDeclarationParseResult::InvalidValue, } }; @@ -5808,7 +5808,7 @@ impl PropertyDeclaration { % for sub_property in shorthand.sub_properties: result_list.push(PropertyDeclaration::${sub_property.camel_case}( match result.${sub_property.ident} { - Some(value) => DeclaredValue::SpecifiedValue(value), + Some(value) => DeclaredValue::Value(value), None => DeclaredValue::Initial, } )); @@ -6122,7 +6122,7 @@ fn cascade_with_cached_declarations( } seen.set_${property.ident}(); let computed_value = match *declared_value { - DeclaredValue::SpecifiedValue(ref specified_value) + DeclaredValue::Value(ref specified_value) => specified_value.to_computed_value(context), DeclaredValue::Initial => longhands::${property.ident}::get_initial_value(), @@ -6277,7 +6277,7 @@ pub fn cascade(viewport_size: Size2D, macro_rules! get_specified( ($style_struct_getter: ident, $property: ident, $declared_value: expr) => { match *$declared_value { - DeclaredValue::SpecifiedValue(specified_value) => specified_value, + DeclaredValue::Value(specified_value) => specified_value, DeclaredValue::Initial => longhands::$property::get_initial_value(), DeclaredValue::Inherit => inherited_style.$style_struct_getter().$property.clone(), } @@ -6292,7 +6292,7 @@ pub fn cascade(viewport_size: Size2D, match *declaration { PropertyDeclaration::FontSize(ref value) => { context.font_size = match *value { - DeclaredValue::SpecifiedValue(ref specified_value) => { + DeclaredValue::Value(ref specified_value) => { match specified_value.0 { Length::FontRelative(value) => { value.to_computed_value(context.inherited_font_size, @@ -6310,7 +6310,7 @@ pub fn cascade(viewport_size: Size2D, } PropertyDeclaration::Color(ref value) => { context.color = match *value { - DeclaredValue::SpecifiedValue(ref specified_value) => { + DeclaredValue::Value(ref specified_value) => { specified_value.parsed } DeclaredValue::Initial => longhands::color::get_initial_value(), diff --git a/tests/unit/style/stylesheets.rs b/tests/unit/style/stylesheets.rs index 2f1cc1fc3be..8d133e8820e 100644 --- a/tests/unit/style/stylesheets.rs +++ b/tests/unit/style/stylesheets.rs @@ -52,7 +52,7 @@ fn test_parse_stylesheet() { declarations: PropertyDeclarationBlock { normal: Arc::new(vec![]), important: Arc::new(vec![ - PropertyDeclaration::Display(DeclaredValue::SpecifiedValue( + PropertyDeclaration::Display(DeclaredValue::Value( longhands::display::SpecifiedValue::none)), ]), }, @@ -90,7 +90,7 @@ fn test_parse_stylesheet() { ], declarations: PropertyDeclarationBlock { normal: Arc::new(vec![ - PropertyDeclaration::Display(DeclaredValue::SpecifiedValue( + PropertyDeclaration::Display(DeclaredValue::Value( longhands::display::SpecifiedValue::block)), ]), important: Arc::new(vec![]), @@ -123,7 +123,7 @@ fn test_parse_stylesheet() { PropertyDeclaration::BackgroundAttachment(DeclaredValue::Initial), PropertyDeclaration::BackgroundRepeat(DeclaredValue::Initial), PropertyDeclaration::BackgroundPosition(DeclaredValue::Initial), - PropertyDeclaration::BackgroundColor(DeclaredValue::SpecifiedValue( + PropertyDeclaration::BackgroundColor(DeclaredValue::Value( longhands::background_color::SpecifiedValue { authored: Some("blue".to_owned()), parsed: cssparser::Color::RGBA(cssparser::RGBA { From 7bcf9f0c9a8db7fa6cafeb4d34e0bdc6cead751d Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Thu, 23 Jul 2015 01:15:27 +0200 Subject: [PATCH 05/15] Use nested parsers as appropritate --- components/style/custom_properties.rs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/components/style/custom_properties.rs b/components/style/custom_properties.rs index d7bc5bdc1a8..7b913989c87 100644 --- a/components/style/custom_properties.rs +++ b/components/style/custom_properties.rs @@ -46,14 +46,18 @@ fn parse_declaration_value(input: &mut Parser, references: &mut HashSet) - } Token::Function(ref name) if name == "var" => { - try!(parse_var_function(input, references)); + try!(input.parse_nested_block(|input| { + parse_var_function(input, references) + })); } Token::Function(_) | Token::ParenthesisBlock | Token::CurlyBracketBlock | Token::SquareBracketBlock => { - try!(parse_declaration_value_block(input, references)) + try!(input.parse_nested_block(|input| { + parse_declaration_value_block(input, references) + })); } _ => {} @@ -77,14 +81,18 @@ fn parse_declaration_value_block(input: &mut Parser, references: &mut HashSet { - try!(parse_var_function(input, references)); + try!(input.parse_nested_block(|input| { + parse_var_function(input, references) + })); } Token::Function(_) | Token::ParenthesisBlock | Token::CurlyBracketBlock | Token::SquareBracketBlock => { - try!(parse_declaration_value_block(input, references)) + try!(input.parse_nested_block(|input| { + parse_declaration_value_block(input, references) + })); } _ => {} From 1c1a9379a32ce5f9244e4c8a4a8f1f8378fffac6 Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Thu, 23 Jul 2015 01:15:52 +0200 Subject: [PATCH 06/15] Substitute var() in custom properties at computed value time. --- components/style/custom_properties.rs | 142 ++++++++++++++++++++------ components/style/properties.mako.rs | 5 +- 2 files changed, 113 insertions(+), 34 deletions(-) diff --git a/components/style/custom_properties.rs b/components/style/custom_properties.rs index 7b913989c87..6d1654caa34 100644 --- a/components/style/custom_properties.rs +++ b/components/style/custom_properties.rs @@ -2,23 +2,25 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -use cssparser::{Parser, Token}; +use cssparser::{Parser, Token, SourcePosition}; use properties::DeclaredValue; use std::collections::{HashMap, HashSet}; use std::sync::Arc; use string_cache::Atom; -#[derive(Clone)] +#[derive(Clone, PartialEq)] pub struct Value { /// In CSS syntax - pub value: String, + value: String, /// Custom property names in var() functions. Do not include the `--` prefix. - pub references: HashSet, + references: HashSet, } -/// Names (atoms) do not include the `--` prefix. -pub type Map = HashMap; +pub struct BorrowedValue<'a> { + value: &'a str, + references: Option<&'a HashSet>, +} pub fn parse(input: &mut Parser) -> Result { let start = input.position(); @@ -120,51 +122,53 @@ fn parse_var_function<'i, 't>(input: &mut Parser<'i, 't>, references: &mut HashS /// Add one custom property declaration to a map, /// unless another with the same name was already there. -pub fn cascade<'a>(custom_properties: &mut Option, - inherited_custom_properties: &Option>, +pub fn cascade<'a>(custom_properties: &mut Option>>, + inherited_custom_properties: &'a Option>>, seen: &mut HashSet<&'a Atom>, name: &'a Atom, - value: &DeclaredValue) { + value: &'a DeclaredValue) { let was_not_already_present = seen.insert(name); if was_not_already_present { let map = match *custom_properties { Some(ref mut map) => map, None => { *custom_properties = Some(match *inherited_custom_properties { - Some(ref arc) => (**arc).clone(), + Some(ref inherited) => inherited.iter().map(|(key, value)| { + (key, BorrowedValue { value: &value, references: None }) + }).collect(), None => HashMap::new(), }); custom_properties.as_mut().unwrap() } }; match *value { - DeclaredValue::SpecifiedValue(ref value) => { - map.insert(name.clone(), value.clone()); + DeclaredValue::Value(ref value) => { + map.insert(name, BorrowedValue { + value: &value.value, + references: Some(&value.references), + }); } DeclaredValue::Initial => { - map.remove(name); + map.remove(&name); } DeclaredValue::Inherit => {} // The inherited value is what we already have. } } } -/// If any custom property declarations where found for this element (`custom_properties.is_some()`) -/// remove cycles and move the map into an `Arc`. -/// Otherwise, default to the inherited map. -pub fn finish_cascade(custom_properties: Option, - inherited_custom_properties: &Option>) - -> Option> { +pub fn finish_cascade(custom_properties: Option>, + inherited_custom_properties: &Option>>) + -> Option>> { if let Some(mut map) = custom_properties { remove_cycles(&mut map); - Some(Arc::new(map)) + Some(Arc::new(substitute_all(map))) } else { inherited_custom_properties.clone() } } /// https://drafts.csswg.org/css-variables/#cycles -fn remove_cycles(map: &mut Map) { +fn remove_cycles(map: &mut HashMap<&Atom, BorrowedValue>) { let mut to_remove = HashSet::new(); { let mut visited = HashSet::new(); @@ -172,25 +176,30 @@ fn remove_cycles(map: &mut Map) { for name in map.keys() { walk(map, name, &mut stack, &mut visited, &mut to_remove); - fn walk<'a>(map: &'a Map, name: &'a Atom, stack: &mut Vec<&'a Atom>, - visited: &mut HashSet<&'a Atom>, to_remove: &mut HashSet) { + fn walk<'a>(map: &HashMap<&'a Atom, BorrowedValue<'a>>, + name: &'a Atom, + stack: &mut Vec<&'a Atom>, + visited: &mut HashSet<&'a Atom>, + to_remove: &mut HashSet) { let was_not_already_present = visited.insert(name); if !was_not_already_present { return } if let Some(value) = map.get(name) { - stack.push(name); - for next in &value.references { - if let Some(position) = stack.position_elem(&next) { - // Found a cycle - for in_cycle in &stack[position..] { - to_remove.insert((**in_cycle).clone()); + if let Some(references) = value.references { + stack.push(name); + for next in references { + if let Some(position) = stack.position_elem(&next) { + // Found a cycle + for in_cycle in &stack[position..] { + to_remove.insert((**in_cycle).clone()); + } + } else { + walk(map, next, stack, visited, to_remove); } - } else { - walk(map, next, stack, visited, to_remove); } + stack.pop(); } - stack.pop(); } } } @@ -199,3 +208,72 @@ fn remove_cycles(map: &mut Map) { map.remove(name); } } + +fn substitute_all(custom_properties: HashMap<&Atom, BorrowedValue>) -> HashMap { + custom_properties.iter().filter_map(|(&name, value)| { + let mut substituted = String::new(); + if substitute_one(value, &mut substituted, &custom_properties).is_ok() { + Some((name.clone(), substituted)) + } else { + None + } + }).collect() +} + +fn substitute_one(value: &BorrowedValue, + substituted: &mut String, + custom_properties: &HashMap<&Atom, BorrowedValue>) + -> Result<(), ()> { + if let Some(references) = value.references { + if !references.is_empty() { + let mut input = Parser::new(&value.value); + let mut start = input.position(); + try!(substitute_block(&mut input, &mut start, substituted, &custom_properties)); + substituted.push_str(input.slice_from(start)); + return Ok(()) + } + } + substituted.push_str(value.value); + Ok(()) +} + +fn substitute_block(input: &mut Parser, + start: &mut SourcePosition, + substituted: &mut String, + custom_properties: &HashMap<&Atom, BorrowedValue>) + -> Result<(), ()> { + while let Ok(token) = input.next() { + match token { + Token::Function(ref name) if name == "var" => { + substituted.push_str(input.slice_from(*start)); + try!(input.parse_nested_block(|input| { + let name = input.expect_ident().unwrap(); + debug_assert!(name.starts_with("--")); + let name = Atom::from_slice(&name[2..]); + + if let Some(value) = custom_properties.get(&name) { + return substitute_one(value, substituted, custom_properties) + } + try!(input.expect_comma()); + let mut start = input.position(); + try!(substitute_block(input, &mut start, substituted, custom_properties)); + substituted.push_str(input.slice_from(start)); + Ok(()) + })); + *start = input.position(); + } + + Token::Function(_) | + Token::ParenthesisBlock | + Token::CurlyBracketBlock | + Token::SquareBracketBlock => { + try!(input.parse_nested_block(|input| { + substitute_block(input, start, substituted, custom_properties) + })); + } + + _ => {} + } + } + Ok(()) +} diff --git a/components/style/properties.mako.rs b/components/style/properties.mako.rs index 8ab6d2442e9..866d18e5068 100644 --- a/components/style/properties.mako.rs +++ b/components/style/properties.mako.rs @@ -6,7 +6,7 @@ use std::ascii::AsciiExt; use std::borrow::ToOwned; -use std::collections::HashSet; +use std::collections::{HashSet, HashMap}; use std::default::Default; use std::fmt; use std::fmt::Debug; @@ -5857,7 +5857,8 @@ pub struct ComputedValues { % for style_struct in STYLE_STRUCTS: ${style_struct.ident}: Arc, % endfor - custom_properties: Option>, + /// Names (atoms) do not include the `--` prefix. + custom_properties: Option>>, shareable: bool, pub writing_mode: WritingMode, pub root_font_size: Au, From 4bf28417b418d6ba5948807ec5b466ac33678df5 Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Thu, 23 Jul 2015 02:15:34 +0200 Subject: [PATCH 07/15] Make custom property substitution do less work. When var() is substituted, record that result rather than re-compute it later. --- components/style/custom_properties.rs | 88 +++++++++++++++++++-------- 1 file changed, 63 insertions(+), 25 deletions(-) diff --git a/components/style/custom_properties.rs b/components/style/custom_properties.rs index 6d1654caa34..63c4d15afa3 100644 --- a/components/style/custom_properties.rs +++ b/components/style/custom_properties.rs @@ -210,37 +210,67 @@ fn remove_cycles(map: &mut HashMap<&Atom, BorrowedValue>) { } fn substitute_all(custom_properties: HashMap<&Atom, BorrowedValue>) -> HashMap { - custom_properties.iter().filter_map(|(&name, value)| { - let mut substituted = String::new(); - if substitute_one(value, &mut substituted, &custom_properties).is_ok() { - Some((name.clone(), substituted)) - } else { - None - } - }).collect() + let mut substituted_map = HashMap::new(); + let mut invalid = HashSet::new(); + for (&name, value) in &custom_properties { + // If this value is invalid at computed time it won’t be inserted in substituted_map. + // Nothing else to do. + let _ = substitute_one( + name, value, &custom_properties, None, &mut substituted_map, &mut invalid); + } + substituted_map } -fn substitute_one(value: &BorrowedValue, - substituted: &mut String, - custom_properties: &HashMap<&Atom, BorrowedValue>) +fn substitute_one(name: &Atom, + value: &BorrowedValue, + custom_properties: &HashMap<&Atom, BorrowedValue>, + substituted: Option<&mut String>, + substituted_map: &mut HashMap, + invalid: &mut HashSet) -> Result<(), ()> { - if let Some(references) = value.references { + if let Some(value) = substituted_map.get(name) { + if let Some(substituted) = substituted { + substituted.push_str(value) + } + return Ok(()) + } + + if invalid.contains(name) { + return Err(()); + } + let value = if let Some(references) = value.references { if !references.is_empty() { + let mut substituted = String::new(); let mut input = Parser::new(&value.value); let mut start = input.position(); - try!(substitute_block(&mut input, &mut start, substituted, &custom_properties)); + if substitute_block( + custom_properties, &mut input, &mut start, &mut substituted, + substituted_map, invalid, + ).is_err() { + invalid.insert(name.clone()); + return Err(()) + } substituted.push_str(input.slice_from(start)); - return Ok(()) + substituted + } else { + value.value.to_owned() } + } else { + value.value.to_owned() + }; + if let Some(substituted) = substituted { + substituted.push_str(&value) } - substituted.push_str(value.value); + substituted_map.insert(name.clone(), value); Ok(()) } -fn substitute_block(input: &mut Parser, +fn substitute_block(custom_properties: &HashMap<&Atom, BorrowedValue>, + input: &mut Parser, start: &mut SourcePosition, substituted: &mut String, - custom_properties: &HashMap<&Atom, BorrowedValue>) + substituted_map: &mut HashMap, + invalid: &mut HashSet) -> Result<(), ()> { while let Ok(token) = input.next() { match token { @@ -252,12 +282,21 @@ fn substitute_block(input: &mut Parser, let name = Atom::from_slice(&name[2..]); if let Some(value) = custom_properties.get(&name) { - return substitute_one(value, substituted, custom_properties) + try!(substitute_one( + &name, value, custom_properties, + Some(substituted), substituted_map, invalid)); + // Skip over the fallback, as `parse_nested_block` would return `Err` + // if we don’t consume all of `input`. + // FIXME: Add a specialized method to cssparser to do this with less work. + while let Ok(_) = input.next() {} + } else { + try!(input.expect_comma()); + let mut start = input.position(); + try!(substitute_block( + custom_properties, input, &mut start, substituted, + substituted_map, invalid)); + substituted.push_str(input.slice_from(start)); } - try!(input.expect_comma()); - let mut start = input.position(); - try!(substitute_block(input, &mut start, substituted, custom_properties)); - substituted.push_str(input.slice_from(start)); Ok(()) })); *start = input.position(); @@ -267,9 +306,8 @@ fn substitute_block(input: &mut Parser, Token::ParenthesisBlock | Token::CurlyBracketBlock | Token::SquareBracketBlock => { - try!(input.parse_nested_block(|input| { - substitute_block(input, start, substituted, custom_properties) - })); + try!(input.parse_nested_block(|input| substitute_block( + custom_properties, input, start, substituted, substituted_map, invalid))); } _ => {} From c3b8b3943755265f4680b063124752a3f59907cb Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Thu, 23 Jul 2015 11:21:05 +0200 Subject: [PATCH 08/15] An empty is invalid. --- components/style/custom_properties.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/components/style/custom_properties.rs b/components/style/custom_properties.rs index 63c4d15afa3..0992feac2d8 100644 --- a/components/style/custom_properties.rs +++ b/components/style/custom_properties.rs @@ -34,6 +34,10 @@ pub fn parse(input: &mut Parser) -> Result { /// https://drafts.csswg.org/css-syntax-3/#typedef-declaration-value fn parse_declaration_value(input: &mut Parser, references: &mut HashSet) -> Result<(), ()> { + if input.is_exhausted() { + // Need at least one token + return Err(()) + } while let Ok(token) = input.next() { match token { Token::BadUrl | From a18a1a8d79cc527ca559b85bf3a8722f87606300 Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Thu, 23 Jul 2015 11:54:42 +0200 Subject: [PATCH 09/15] =?UTF-8?q?Add=20a=20FIXME=C2=A0comment=20of=20EOF?= =?UTF-8?q?=20handling=20in=20custom=20properties.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/style/custom_properties.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/components/style/custom_properties.rs b/components/style/custom_properties.rs index 0992feac2d8..19607a6ee3b 100644 --- a/components/style/custom_properties.rs +++ b/components/style/custom_properties.rs @@ -317,5 +317,11 @@ fn substitute_block(custom_properties: &HashMap<&Atom, BorrowedValue>, _ => {} } } + // FIXME: deal with things being implicitly closed at the end of the input. E.g. + // ```html + //
+ //

+ //
+ // ``` Ok(()) } From 1d47857be98d2b7e2da4f376084e65a0058e5662 Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Thu, 23 Jul 2015 17:46:59 +0200 Subject: [PATCH 10/15] Invalid at computed-value time customp properties get their inherited value. --- components/style/custom_properties.rs | 66 ++++++++++++++++----------- 1 file changed, 39 insertions(+), 27 deletions(-) diff --git a/components/style/custom_properties.rs b/components/style/custom_properties.rs index 19607a6ee3b..39d2cbcca4b 100644 --- a/components/style/custom_properties.rs +++ b/components/style/custom_properties.rs @@ -25,6 +25,8 @@ pub struct BorrowedValue<'a> { pub fn parse(input: &mut Parser) -> Result { let start = input.position(); let mut references = HashSet::new(); + // FIXME: don’t consume a top-level `!` as that would prevent parsing `!important`. + // Maybe using Parser::parse_until_before? try!(parse_declaration_value(input, &mut references)); Ok(Value { value: input.slice_from(start).to_owned(), @@ -127,7 +129,7 @@ fn parse_var_function<'i, 't>(input: &mut Parser<'i, 't>, references: &mut HashS /// Add one custom property declaration to a map, /// unless another with the same name was already there. pub fn cascade<'a>(custom_properties: &mut Option>>, - inherited_custom_properties: &'a Option>>, + inherited: &'a Option>>, seen: &mut HashSet<&'a Atom>, name: &'a Atom, value: &'a DeclaredValue) { @@ -136,7 +138,7 @@ pub fn cascade<'a>(custom_properties: &mut Option map, None => { - *custom_properties = Some(match *inherited_custom_properties { + *custom_properties = Some(match *inherited { Some(ref inherited) => inherited.iter().map(|(key, value)| { (key, BorrowedValue { value: &value, references: None }) }).collect(), @@ -161,17 +163,18 @@ pub fn cascade<'a>(custom_properties: &mut Option>, - inherited_custom_properties: &Option>>) + inherited: &Option>>) -> Option>> { if let Some(mut map) = custom_properties { remove_cycles(&mut map); - Some(Arc::new(substitute_all(map))) + Some(Arc::new(substitute_all(map, inherited))) } else { - inherited_custom_properties.clone() + inherited.clone() } } /// https://drafts.csswg.org/css-variables/#cycles +/// The initial value of a custom property is represented by this property not being in the map. fn remove_cycles(map: &mut HashMap<&Atom, BorrowedValue>) { let mut to_remove = HashSet::new(); { @@ -195,8 +198,8 @@ fn remove_cycles(map: &mut HashMap<&Atom, BorrowedValue>) { for next in references { if let Some(position) = stack.position_elem(&next) { // Found a cycle - for in_cycle in &stack[position..] { - to_remove.insert((**in_cycle).clone()); + for &in_cycle in &stack[position..] { + to_remove.insert(in_cycle.clone()); } } else { walk(map, next, stack, visited, to_remove); @@ -213,14 +216,16 @@ fn remove_cycles(map: &mut HashMap<&Atom, BorrowedValue>) { } } -fn substitute_all(custom_properties: HashMap<&Atom, BorrowedValue>) -> HashMap { +fn substitute_all(custom_properties: HashMap<&Atom, BorrowedValue>, + inherited: &Option>>) + -> HashMap { let mut substituted_map = HashMap::new(); let mut invalid = HashSet::new(); for (&name, value) in &custom_properties { - // If this value is invalid at computed time it won’t be inserted in substituted_map. + // If this value is invalid at computed-time it won’t be inserted in substituted_map. // Nothing else to do. let _ = substitute_one( - name, value, &custom_properties, None, &mut substituted_map, &mut invalid); + name, value, &custom_properties, inherited, None, &mut substituted_map, &mut invalid); } substituted_map } @@ -228,6 +233,7 @@ fn substitute_all(custom_properties: HashMap<&Atom, BorrowedValue>) -> HashMap, + inherited: &Option>>, substituted: Option<&mut String>, substituted_map: &mut HashMap, invalid: &mut HashSet) @@ -242,22 +248,26 @@ fn substitute_one(name: &Atom, if invalid.contains(name) { return Err(()); } - let value = if let Some(references) = value.references { - if !references.is_empty() { - let mut substituted = String::new(); - let mut input = Parser::new(&value.value); - let mut start = input.position(); - if substitute_block( - custom_properties, &mut input, &mut start, &mut substituted, - substituted_map, invalid, - ).is_err() { - invalid.insert(name.clone()); - return Err(()) - } + let value = if value.references.map(|set| set.is_empty()) == Some(false) { + let mut substituted = String::new(); + let mut input = Parser::new(&value.value); + let mut start = input.position(); + if substitute_block( + custom_properties, inherited, &mut input, &mut start, &mut substituted, + substituted_map, invalid, + ).is_ok() { substituted.push_str(input.slice_from(start)); substituted } else { - value.value.to_owned() + // Invalid at computed-value time. Use the inherited value. + // FIXME: Should it be the inital value instead? + // See https://lists.w3.org/Archives/Public/www-style/2015Jul/0354.html + if let Some(value) = inherited.as_ref().and_then(|i| i.get(name)) { + value.clone() + } else { + invalid.insert(name.clone()); + return Err(()) + } } } else { value.value.to_owned() @@ -270,6 +280,7 @@ fn substitute_one(name: &Atom, } fn substitute_block(custom_properties: &HashMap<&Atom, BorrowedValue>, + inherited: &Option>>, input: &mut Parser, start: &mut SourcePosition, substituted: &mut String, @@ -287,7 +298,7 @@ fn substitute_block(custom_properties: &HashMap<&Atom, BorrowedValue>, if let Some(value) = custom_properties.get(&name) { try!(substitute_one( - &name, value, custom_properties, + &name, value, custom_properties, inherited, Some(substituted), substituted_map, invalid)); // Skip over the fallback, as `parse_nested_block` would return `Err` // if we don’t consume all of `input`. @@ -297,8 +308,8 @@ fn substitute_block(custom_properties: &HashMap<&Atom, BorrowedValue>, try!(input.expect_comma()); let mut start = input.position(); try!(substitute_block( - custom_properties, input, &mut start, substituted, - substituted_map, invalid)); + custom_properties, inherited, input, + &mut start, substituted, substituted_map, invalid)); substituted.push_str(input.slice_from(start)); } Ok(()) @@ -311,7 +322,8 @@ fn substitute_block(custom_properties: &HashMap<&Atom, BorrowedValue>, Token::CurlyBracketBlock | Token::SquareBracketBlock => { try!(input.parse_nested_block(|input| substitute_block( - custom_properties, input, start, substituted, substituted_map, invalid))); + custom_properties, inherited, input, + start, substituted, substituted_map, invalid))); } _ => {} From b2ee8285208124f250230f0e371f7734c5e40489 Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Tue, 4 Aug 2015 17:34:39 +0200 Subject: [PATCH 11/15] [T]::position_elem is deprecated. --- components/style/custom_properties.rs | 2 +- components/style/lib.rs | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/components/style/custom_properties.rs b/components/style/custom_properties.rs index 39d2cbcca4b..7c816185ee7 100644 --- a/components/style/custom_properties.rs +++ b/components/style/custom_properties.rs @@ -196,7 +196,7 @@ fn remove_cycles(map: &mut HashMap<&Atom, BorrowedValue>) { if let Some(references) = value.references { stack.push(name); for next in references { - if let Some(position) = stack.position_elem(&next) { + if let Some(position) = stack.iter().position(|&x| x == next) { // Found a cycle for &in_cycle in &stack[position..] { to_remove.insert(in_cycle.clone()); diff --git a/components/style/lib.rs b/components/style/lib.rs index 0822c67dd91..1d7622ce088 100644 --- a/components/style/lib.rs +++ b/components/style/lib.rs @@ -9,7 +9,6 @@ #![feature(custom_attribute)] #![feature(custom_derive)] #![feature(plugin)] -#![feature(slice_position_elem)] #![feature(vec_push_all)] #![plugin(serde_macros)] From b4fdb5d80368dbed8c609ed840c727e7c72ab29a Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Wed, 2 Sep 2015 22:56:39 +0200 Subject: [PATCH 12/15] Substitute var() in longhand property declarations. --- components/servo/Cargo.lock | 18 +- components/style/Cargo.toml | 2 +- components/style/custom_properties.rs | 110 ++++++++---- components/style/properties.mako.rs | 249 ++++++++++++++++---------- ports/cef/Cargo.lock | 16 +- ports/gonk/Cargo.lock | 16 +- 6 files changed, 254 insertions(+), 157 deletions(-) diff --git a/components/servo/Cargo.lock b/components/servo/Cargo.lock index c0e8618d76f..a8a8c24c644 100644 --- a/components/servo/Cargo.lock +++ b/components/servo/Cargo.lock @@ -135,7 +135,7 @@ version = "0.0.1" dependencies = [ "azure 0.1.0 (git+https://github.com/servo/rust-azure)", "canvas_traits 0.0.1", - "cssparser 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "cssparser 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "gfx_traits 0.0.1", "gleam 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", @@ -152,7 +152,7 @@ name = "canvas_traits" version = "0.0.1" dependencies = [ "azure 0.1.0 (git+https://github.com/servo/rust-azure)", - "cssparser 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "cssparser 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "gfx_traits 0.0.1", "ipc-channel 0.1.0 (git+https://github.com/pcwalton/ipc-channel)", @@ -288,7 +288,7 @@ dependencies = [ [[package]] name = "cssparser" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "encoding 0.2.32 (registry+https://github.com/rust-lang/crates.io-index)", @@ -886,7 +886,7 @@ dependencies = [ "canvas 0.0.1", "canvas_traits 0.0.1", "clock_ticks 0.0.6 (git+https://github.com/tomaka/clock_ticks)", - "cssparser 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "cssparser 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "encoding 0.2.32 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1369,7 +1369,7 @@ dependencies = [ "bitflags 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "canvas 0.0.1", "canvas_traits 0.0.1", - "cssparser 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "cssparser 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "devtools_traits 0.0.1", "encoding 0.2.32 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1435,7 +1435,7 @@ version = "0.1.0" source = "git+https://github.com/servo/rust-selectors#572353b3209af040cd3e6261978b09c7f8122844" dependencies = [ "bitflags 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "cssparser 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "cssparser 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "matches 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "quickersort 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1572,7 +1572,7 @@ name = "style" version = "0.0.1" dependencies = [ "bitflags 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "cssparser 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "cssparser 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "encoding 0.2.32 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1596,7 +1596,7 @@ dependencies = [ name = "style_tests" version = "0.0.1" dependencies = [ - "cssparser 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "cssparser 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "selectors 0.1.0 (git+https://github.com/servo/rust-selectors)", "string_cache 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1714,7 +1714,7 @@ version = "0.0.1" dependencies = [ "azure 0.1.0 (git+https://github.com/servo/rust-azure)", "bitflags 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "cssparser 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "cssparser 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "getopts 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "html5ever 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/components/style/Cargo.toml b/components/style/Cargo.toml index 2bac5a5ddb9..12e2a44656e 100644 --- a/components/style/Cargo.toml +++ b/components/style/Cargo.toml @@ -20,7 +20,7 @@ git = "https://github.com/servo/rust-selectors" features = ["unstable"] [dependencies.cssparser] -version = "0.3" +version = "0.3.6" features = [ "serde-serialization" ] [dependencies.url] diff --git a/components/style/custom_properties.rs b/components/style/custom_properties.rs index 7c816185ee7..18aeb9dd0ca 100644 --- a/components/style/custom_properties.rs +++ b/components/style/custom_properties.rs @@ -24,18 +24,19 @@ pub struct BorrowedValue<'a> { pub fn parse(input: &mut Parser) -> Result { let start = input.position(); - let mut references = HashSet::new(); + let mut references = Some(HashSet::new()); // FIXME: don’t consume a top-level `!` as that would prevent parsing `!important`. // Maybe using Parser::parse_until_before? try!(parse_declaration_value(input, &mut references)); Ok(Value { value: input.slice_from(start).to_owned(), - references: references, + references: references.unwrap(), }) } /// https://drafts.csswg.org/css-syntax-3/#typedef-declaration-value -fn parse_declaration_value(input: &mut Parser, references: &mut HashSet) -> Result<(), ()> { +pub fn parse_declaration_value(input: &mut Parser, references: &mut Option>) + -> Result<(), ()> { if input.is_exhausted() { // Need at least one token return Err(()) @@ -76,7 +77,7 @@ fn parse_declaration_value(input: &mut Parser, references: &mut HashSet) - /// Like parse_declaration_value, /// but accept `!` and `;` since they are only invalid at the top level -fn parse_declaration_value_block(input: &mut Parser, references: &mut HashSet) +fn parse_declaration_value_block(input: &mut Parser, references: &mut Option>) -> Result<(), ()> { while let Ok(token) = input.next() { match token { @@ -110,7 +111,7 @@ fn parse_declaration_value_block(input: &mut Parser, references: &mut HashSet(input: &mut Parser<'i, 't>, references: &mut HashSet) +fn parse_var_function<'i, 't>(input: &mut Parser<'i, 't>, references: &mut Option>) -> Result<(), ()> { // https://drafts.csswg.org/css-variables/#typedef-custom-property-name let name = try!(input.expect_ident()); @@ -122,7 +123,9 @@ fn parse_var_function<'i, 't>(input: &mut Parser<'i, 't>, references: &mut HashS if input.expect_comma().is_ok() { try!(parse_declaration_value(input, references)); } - references.insert(Atom::from_slice(name)); + if let Some(ref mut refs) = *references { + refs.insert(Atom::from_slice(name)); + } Ok(()) } @@ -153,7 +156,8 @@ pub fn cascade<'a>(custom_properties: &mut Option unreachable!(), DeclaredValue::Initial => { map.remove(&name); } @@ -188,8 +192,8 @@ fn remove_cycles(map: &mut HashMap<&Atom, BorrowedValue>) { stack: &mut Vec<&'a Atom>, visited: &mut HashSet<&'a Atom>, to_remove: &mut HashSet) { - let was_not_already_present = visited.insert(name); - if !was_not_already_present { + let already_visited_before = !visited.insert(name); + if already_visited_before { return } if let Some(value) = map.get(name) { @@ -216,6 +220,7 @@ fn remove_cycles(map: &mut HashMap<&Atom, BorrowedValue>) { } } +/// Replace `var()` functions for all custom properties. fn substitute_all(custom_properties: HashMap<&Atom, BorrowedValue>, inherited: &Option>>) -> HashMap { @@ -230,6 +235,9 @@ fn substitute_all(custom_properties: HashMap<&Atom, BorrowedValue>, substituted_map } +/// Replace `var()` functions for one custom property. +/// Also recursively record results for other custom properties referenced by `var()` functions. +/// Return `Err(())` for invalid at computed time. fn substitute_one(name: &Atom, value: &BorrowedValue, custom_properties: &HashMap<&Atom, BorrowedValue>, @@ -252,10 +260,14 @@ fn substitute_one(name: &Atom, let mut substituted = String::new(); let mut input = Parser::new(&value.value); let mut start = input.position(); - if substitute_block( - custom_properties, inherited, &mut input, &mut start, &mut substituted, - substituted_map, invalid, - ).is_ok() { + if substitute_block(&mut input, &mut start, &mut substituted, &mut |name, substituted| { + if let Some(value) = custom_properties.get(name) { + substitute_one(name, value, custom_properties, inherited, + Some(substituted), substituted_map, invalid) + } else { + Err(()) + } + }).is_ok() { substituted.push_str(input.slice_from(start)); substituted } else { @@ -279,27 +291,33 @@ fn substitute_one(name: &Atom, Ok(()) } -fn substitute_block(custom_properties: &HashMap<&Atom, BorrowedValue>, - inherited: &Option>>, - input: &mut Parser, - start: &mut SourcePosition, - substituted: &mut String, - substituted_map: &mut HashMap, - invalid: &mut HashSet) - -> Result<(), ()> { - while let Ok(token) = input.next() { +/// Replace `var()` functions in an arbitrary bit of input. +/// +/// The `substitute_one` callback is called for each `var()` function in `input`. +/// If the variable has its initial value, +/// the callback should return `Err(())` and leave `substituted` unchanged. +/// Otherwise, it should push the value of the variable (with its own `var()` functions replaced) +/// to `substituted` and return `Ok(())`. +/// +/// Return `Err(())` if `input` is invalid at computed-value time. +fn substitute_block(input: &mut Parser, + start: &mut SourcePosition, + substituted: &mut String, + substitute_one: &mut F) + -> Result<(), ()> + where F: FnMut(&Atom, &mut String) -> Result<(), ()> { + loop { + let input_slice = input.slice_from(*start); + let token = if let Ok(token) = input.next() { token } else { break }; match token { Token::Function(ref name) if name == "var" => { - substituted.push_str(input.slice_from(*start)); + substituted.push_str(input_slice); try!(input.parse_nested_block(|input| { let name = input.expect_ident().unwrap(); - debug_assert!(name.starts_with("--")); + debug_assert!(name.starts_with("--")); // Ensured by parse_var_function() let name = Atom::from_slice(&name[2..]); - if let Some(value) = custom_properties.get(&name) { - try!(substitute_one( - &name, value, custom_properties, inherited, - Some(substituted), substituted_map, invalid)); + if substitute_one(&name, substituted).is_ok() { // Skip over the fallback, as `parse_nested_block` would return `Err` // if we don’t consume all of `input`. // FIXME: Add a specialized method to cssparser to do this with less work. @@ -307,9 +325,7 @@ fn substitute_block(custom_properties: &HashMap<&Atom, BorrowedValue>, } else { try!(input.expect_comma()); let mut start = input.position(); - try!(substitute_block( - custom_properties, inherited, input, - &mut start, substituted, substituted_map, invalid)); + try!(substitute_block(input, &mut start, substituted, substitute_one)); substituted.push_str(input.slice_from(start)); } Ok(()) @@ -321,9 +337,9 @@ fn substitute_block(custom_properties: &HashMap<&Atom, BorrowedValue>, Token::ParenthesisBlock | Token::CurlyBracketBlock | Token::SquareBracketBlock => { - try!(input.parse_nested_block(|input| substitute_block( - custom_properties, inherited, input, - start, substituted, substituted_map, invalid))); + try!(input.parse_nested_block(|input| { + substitute_block(input, start, substituted, substitute_one) + })); } _ => {} @@ -337,3 +353,29 @@ fn substitute_block(custom_properties: &HashMap<&Atom, BorrowedValue>, // ``` Ok(()) } + +/// Replace `var()` functions for a non-custom property. +/// Return `Err(())` for invalid at computed time. +pub fn substitute(input: &str, custom_properties: &Option>>) + -> Result { + let empty_map; + let custom_properties = if let &Some(ref arc) = custom_properties { + &**arc + } else { + empty_map = HashMap::new(); + &empty_map + }; + let mut substituted = String::new(); + let mut input = Parser::new(input); + let mut start = input.position(); + try!(substitute_block(&mut input, &mut start, &mut substituted, &mut |name, substituted| { + if let Some(value) = custom_properties.get(name) { + substituted.push_str(value); + Ok(()) + } else { + Err(()) + } + })); + substituted.push_str(input.slice_from(start)); + Ok(substituted) +} diff --git a/components/style/properties.mako.rs b/components/style/properties.mako.rs index 866d18e5068..d50018bf37c 100644 --- a/components/style/properties.mako.rs +++ b/components/style/properties.mako.rs @@ -133,9 +133,11 @@ pub mod longhands { use properties::longhands; use properties::property_bit_field::PropertyBitField; use properties::{ComputedValues, PropertyDeclaration}; + use std::collections::HashMap; use std::sync::Arc; use values::computed::ToComputedValue; use values::{computed, specified}; + use string_cache::Atom; ${caller.body()} #[allow(unused_variables)] pub fn cascade_property(declaration: &PropertyDeclaration, @@ -155,22 +157,25 @@ pub mod longhands { return } seen.set_${property.ident}(); - let computed_value = match *declared_value { - DeclaredValue::Value(ref specified_value) => { - specified_value.to_computed_value(&context) + let computed_value = substitute_variables( + declared_value, &style.custom_properties, |value| match *value { + DeclaredValue::Value(ref specified_value) => { + specified_value.to_computed_value(&context) + } + DeclaredValue::WithVariables { .. } => unreachable!(), + DeclaredValue::Initial => get_initial_value(), + DeclaredValue::Inherit => { + // This is a bit slow, but this is rare so it shouldn't + // matter. + // + // FIXME: is it still? + *cacheable = false; + inherited_style.${THIS_STYLE_STRUCT.ident} + .${property.ident} + .clone() + } } - DeclaredValue::Initial => get_initial_value(), - DeclaredValue::Inherit => { - // This is a bit slow, but this is rare so it shouldn't - // matter. - // - // FIXME: is it still? - *cacheable = false; - inherited_style.${THIS_STYLE_STRUCT.ident} - .${property.ident} - .clone() - } - }; + ); Arc::make_mut(&mut style.${THIS_STYLE_STRUCT.ident}).${property.ident} = computed_value; @@ -188,6 +193,29 @@ pub mod longhands { % endif } % if derived_from is None: + pub fn substitute_variables(value: &DeclaredValue, + custom_properties: &Option>>, + f: F) + -> R + where F: FnOnce(&DeclaredValue) -> R { + if let DeclaredValue::WithVariables { ref css, ref base_url } = *value { + f(& + ::custom_properties::substitute(css, custom_properties) + .and_then(|css| { + // As of this writing, only the base URL is used for property values: + let context = ParserContext::new( + ::stylesheets::Origin::Author, base_url); + parse_specified(&context, &mut Parser::new(&css)) + }) + .unwrap_or( + // Invalid at computed-value time. + DeclaredValue::${"Inherit" if THIS_STYLE_STRUCT.inherited else "Initial"} + ) + ) + } else { + f(value) + } + } pub fn parse_declared(context: &ParserContext, input: &mut Parser) -> Result, ()> { match input.try(CSSWideKeyword::parse) { @@ -195,7 +223,21 @@ pub mod longhands { Ok(CSSWideKeyword::InitialKeyword) => Ok(DeclaredValue::Initial), Ok(CSSWideKeyword::UnsetKeyword) => Ok(DeclaredValue::${ "Inherit" if THIS_STYLE_STRUCT.inherited else "Initial"}), - Err(()) => parse_specified(context, input), + Err(()) => { + input.look_for_var_functions(); + let start = input.position(); + let specified = parse_specified(context, input); + let var = input.seen_var_functions(); + if specified.is_err() && var { + input.reset(start); + try!(::custom_properties::parse_declaration_value(input, &mut None)); + return Ok(DeclaredValue::WithVariables { + css: input.slice_from(start).to_owned(), + base_url: context.base_url.clone(), + }) + } + specified + } } } % endif @@ -1666,7 +1708,6 @@ pub mod longhands { <%self:longhand name="font-family"> use self::computed_value::FontFamily; - use string_cache::Atom; use values::computed::ComputedValueAsSpecified; pub use self::computed_value::T as SpecifiedValue; @@ -5659,9 +5700,10 @@ impl CSSWideKeyword { } -#[derive(Clone, PartialEq, Eq, Copy, Debug)] +#[derive(Clone, PartialEq, Eq, Debug)] pub enum DeclaredValue { Value(T), + WithVariables { css: String, base_url: Url }, Initial, Inherit, // There is no Unset variant here. @@ -5673,6 +5715,7 @@ impl DeclaredValue { pub fn specified_value(&self) -> String { match self { &DeclaredValue::Value(ref inner) => inner.to_css_string(), + &DeclaredValue::WithVariables { ref css, .. } => css.clone(), &DeclaredValue::Initial => "initial".to_owned(), &DeclaredValue::Inherit => "inherit".to_owned(), } @@ -6092,6 +6135,7 @@ fn cascade_with_cached_declarations( shareable: bool, parent_style: &ComputedValues, cached_style: &ComputedValues, + custom_properties: Option>>, context: &computed::Context) -> ComputedValues { % for style_struct in STYLE_STRUCTS: @@ -6101,10 +6145,7 @@ fn cascade_with_cached_declarations( let mut style_${style_struct.ident} = cached_style.${style_struct.ident}.clone(); % endif % endfor - let mut custom_properties = None; - let mut seen = PropertyBitField::new(); - let mut seen_custom = HashSet::new(); // Declaration blocks are stored in increasing precedence order, // we want them in decreasing order here. for sub_list in applicable_declarations.iter().rev() { @@ -6122,21 +6163,25 @@ fn cascade_with_cached_declarations( continue } seen.set_${property.ident}(); - let computed_value = match *declared_value { - DeclaredValue::Value(ref specified_value) - => specified_value.to_computed_value(context), - DeclaredValue::Initial - => longhands::${property.ident}::get_initial_value(), - DeclaredValue::Inherit => { - // This is a bit slow, but this is rare so it shouldn't - // matter. - // - // FIXME: is it still? - parent_style.${style_struct.ident} - .${property.ident} - .clone() + let computed_value = + longhands::${property.ident}::substitute_variables( + declared_value, &custom_properties, |value| match *value { + DeclaredValue::Value(ref specified_value) + => specified_value.to_computed_value(context), + DeclaredValue::Initial + => longhands::${property.ident}::get_initial_value(), + DeclaredValue::Inherit => { + // This is a bit slow, but this is rare so it shouldn't + // matter. + // + // FIXME: is it still? + parent_style.${style_struct.ident} + .${property.ident} + .clone() + } + DeclaredValue::WithVariables { .. } => unreachable!() } - }; + ); Arc::make_mut(&mut style_${style_struct.ident}) .${property.ident} = computed_value; % endif @@ -6164,11 +6209,7 @@ fn cascade_with_cached_declarations( % endif % endfor % endfor - PropertyDeclaration::Custom(ref name, ref value) => { - ::custom_properties::cascade( - &mut custom_properties, &parent_style.custom_properties, - &mut seen_custom, name, value) - } + PropertyDeclaration::Custom(..) => {} } } } @@ -6183,8 +6224,7 @@ fn cascade_with_cached_declarations( % for style_struct in STYLE_STRUCTS: ${style_struct.ident}: style_${style_struct.ident}, % endfor - custom_properties: ::custom_properties::finish_cascade( - custom_properties, &parent_style.custom_properties), + custom_properties: custom_properties, shareable: shareable, root_font_size: parent_style.root_font_size, } @@ -6247,6 +6287,25 @@ pub fn cascade(viewport_size: Size2D, Some(parent_style) => (false, parent_style), None => (true, initial_values), }; + + let mut custom_properties = None; + let mut seen_custom = HashSet::new(); + for sub_list in applicable_declarations.iter().rev() { + // Declarations are already stored in reverse order. + for declaration in sub_list.declarations.iter() { + match *declaration { + PropertyDeclaration::Custom(ref name, ref value) => { + ::custom_properties::cascade( + &mut custom_properties, &inherited_style.custom_properties, + &mut seen_custom, name, value) + } + _ => {} + } + } + } + let custom_properties = ::custom_properties::finish_cascade( + custom_properties, &inherited_style.custom_properties); + let mut context = { let inherited_font_style = inherited_style.get_font(); computed::Context { @@ -6277,11 +6336,16 @@ pub fn cascade(viewport_size: Size2D, // This assumes that the computed and specified values have the same Rust type. macro_rules! get_specified( ($style_struct_getter: ident, $property: ident, $declared_value: expr) => { - match *$declared_value { - DeclaredValue::Value(specified_value) => specified_value, - DeclaredValue::Initial => longhands::$property::get_initial_value(), - DeclaredValue::Inherit => inherited_style.$style_struct_getter().$property.clone(), - } + longhands::$property::substitute_variables( + $declared_value, &custom_properties, |value| match *value { + DeclaredValue::Value(specified_value) => specified_value, + DeclaredValue::Initial => longhands::$property::get_initial_value(), + DeclaredValue::Inherit => { + inherited_style.$style_struct_getter().$property.clone() + } + DeclaredValue::WithVariables { .. } => unreachable!() + } + ) }; ); @@ -6292,31 +6356,37 @@ pub fn cascade(viewport_size: Size2D, for declaration in sub_list.declarations.iter().rev() { match *declaration { PropertyDeclaration::FontSize(ref value) => { - context.font_size = match *value { - DeclaredValue::Value(ref specified_value) => { - match specified_value.0 { - Length::FontRelative(value) => { - value.to_computed_value(context.inherited_font_size, - context.root_font_size) + context.font_size = longhands::font_size::substitute_variables( + value, &custom_properties, |value| match *value { + DeclaredValue::Value(ref specified_value) => { + match specified_value.0 { + Length::FontRelative(value) => { + value.to_computed_value(context.inherited_font_size, + context.root_font_size) + } + Length::ServoCharacterWidth(value) => { + value.to_computed_value(context.inherited_font_size) + } + _ => specified_value.0.to_computed_value(&context) } - Length::ServoCharacterWidth(value) => { - value.to_computed_value(context.inherited_font_size) - } - _ => specified_value.0.to_computed_value(&context) } + DeclaredValue::Initial => longhands::font_size::get_initial_value(), + DeclaredValue::Inherit => context.inherited_font_size, + DeclaredValue::WithVariables { .. } => unreachable!(), } - DeclaredValue::Initial => longhands::font_size::get_initial_value(), - DeclaredValue::Inherit => context.inherited_font_size, - } + ); } PropertyDeclaration::Color(ref value) => { - context.color = match *value { - DeclaredValue::Value(ref specified_value) => { - specified_value.parsed + context.color = longhands::color::substitute_variables( + value, &custom_properties, |value| match *value { + DeclaredValue::Value(ref specified_value) => { + specified_value.parsed + } + DeclaredValue::Initial => longhands::color::get_initial_value(), + DeclaredValue::Inherit => inherited_style.get_color().color.clone(), + DeclaredValue::WithVariables { .. } => unreachable!(), } - DeclaredValue::Initial => longhands::color::get_initial_value(), - DeclaredValue::Inherit => inherited_style.get_color().color.clone(), - }; + ); } PropertyDeclaration::Display(ref value) => { context.display = get_specified!(get_box, display, value); @@ -6368,6 +6438,7 @@ pub fn cascade(viewport_size: Size2D, shareable, parent_style, cached_style, + custom_properties, &context), false) } (_, _) => {} @@ -6384,14 +6455,13 @@ pub fn cascade(viewport_size: Size2D, % endif .${style_struct.ident}.clone(), % endfor - custom_properties: None, - shareable: false, + custom_properties: custom_properties, + shareable: shareable, writing_mode: WritingMode::empty(), root_font_size: context.root_font_size, }; let mut cacheable = true; let mut seen = PropertyBitField::new(); - let mut custom_properties = None; // Declaration blocks are stored in increasing precedence order, we want them in decreasing // order here. // @@ -6399,28 +6469,21 @@ pub fn cascade(viewport_size: Size2D, // of compiled code! To improve i-cache behavior, we outline the individual functions and use // virtual dispatch instead. CASCADE_PROPERTY.with(|cascade_property| { - let mut seen_custom = HashSet::new(); for sub_list in applicable_declarations.iter().rev() { // Declarations are already stored in reverse order. for declaration in sub_list.declarations.iter() { - match *declaration { - PropertyDeclaration::Custom(ref name, ref value) => { - ::custom_properties::cascade( - &mut custom_properties, &inherited_style.custom_properties, - &mut seen_custom, name, value) - } - _ => { - let discriminant = unsafe { - intrinsics::discriminant_value(declaration) as usize - }; - (cascade_property[discriminant].unwrap())(declaration, - &mut style, - inherited_style, - &context, - &mut seen, - &mut cacheable); - } + if let PropertyDeclaration::Custom(..) = *declaration { + continue } + let discriminant = unsafe { + intrinsics::discriminant_value(declaration) as usize + }; + (cascade_property[discriminant].unwrap())(declaration, + &mut style, + inherited_style, + &context, + &mut seen, + &mut cacheable); } } }); @@ -6457,16 +6520,8 @@ pub fn cascade(viewport_size: Size2D, compute_font_hash(&mut *Arc::make_mut(&mut style.font)) } - (ComputedValues { - writing_mode: get_writing_mode(&*style.inheritedbox), - % for style_struct in STYLE_STRUCTS: - ${style_struct.ident}: style.${style_struct.ident}, - % endfor - custom_properties: ::custom_properties::finish_cascade( - custom_properties, &inherited_style.custom_properties), - shareable: shareable, - root_font_size: context.root_font_size, - }, cacheable) + style.writing_mode = get_writing_mode(&*style.inheritedbox); + (style, cacheable) } /// Alters the given style to accommodate replaced content. This is called in flow construction. It diff --git a/ports/cef/Cargo.lock b/ports/cef/Cargo.lock index 09dba1b601b..a1b6fcb972e 100644 --- a/ports/cef/Cargo.lock +++ b/ports/cef/Cargo.lock @@ -127,7 +127,7 @@ version = "0.0.1" dependencies = [ "azure 0.1.0 (git+https://github.com/servo/rust-azure)", "canvas_traits 0.0.1", - "cssparser 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "cssparser 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "gfx_traits 0.0.1", "gleam 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", @@ -144,7 +144,7 @@ name = "canvas_traits" version = "0.0.1" dependencies = [ "azure 0.1.0 (git+https://github.com/servo/rust-azure)", - "cssparser 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "cssparser 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "gfx_traits 0.0.1", "ipc-channel 0.1.0 (git+https://github.com/pcwalton/ipc-channel)", @@ -280,7 +280,7 @@ dependencies = [ [[package]] name = "cssparser" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "encoding 0.2.32 (registry+https://github.com/rust-lang/crates.io-index)", @@ -871,7 +871,7 @@ dependencies = [ "canvas 0.0.1", "canvas_traits 0.0.1", "clock_ticks 0.0.6 (git+https://github.com/tomaka/clock_ticks)", - "cssparser 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "cssparser 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "encoding 0.2.32 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1339,7 +1339,7 @@ dependencies = [ "bitflags 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "canvas 0.0.1", "canvas_traits 0.0.1", - "cssparser 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "cssparser 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "devtools_traits 0.0.1", "encoding 0.2.32 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1397,7 +1397,7 @@ version = "0.1.0" source = "git+https://github.com/servo/rust-selectors#572353b3209af040cd3e6261978b09c7f8122844" dependencies = [ "bitflags 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "cssparser 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "cssparser 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "matches 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "quickersort 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1567,7 +1567,7 @@ name = "style" version = "0.0.1" dependencies = [ "bitflags 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "cssparser 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "cssparser 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "encoding 0.2.32 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1695,7 +1695,7 @@ version = "0.0.1" dependencies = [ "azure 0.1.0 (git+https://github.com/servo/rust-azure)", "bitflags 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "cssparser 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "cssparser 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "getopts 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "html5ever 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/ports/gonk/Cargo.lock b/ports/gonk/Cargo.lock index 34db28d0323..2937310372f 100644 --- a/ports/gonk/Cargo.lock +++ b/ports/gonk/Cargo.lock @@ -108,7 +108,7 @@ version = "0.0.1" dependencies = [ "azure 0.1.0 (git+https://github.com/servo/rust-azure)", "canvas_traits 0.0.1", - "cssparser 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "cssparser 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "gfx_traits 0.0.1", "gleam 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", @@ -125,7 +125,7 @@ name = "canvas_traits" version = "0.0.1" dependencies = [ "azure 0.1.0 (git+https://github.com/servo/rust-azure)", - "cssparser 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "cssparser 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "gfx_traits 0.0.1", "ipc-channel 0.1.0 (git+https://github.com/pcwalton/ipc-channel)", @@ -250,7 +250,7 @@ dependencies = [ [[package]] name = "cssparser" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "encoding 0.2.32 (registry+https://github.com/rust-lang/crates.io-index)", @@ -755,7 +755,7 @@ dependencies = [ "canvas 0.0.1", "canvas_traits 0.0.1", "clock_ticks 0.0.6 (git+https://github.com/tomaka/clock_ticks)", - "cssparser 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "cssparser 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "encoding 0.2.32 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1205,7 +1205,7 @@ dependencies = [ "bitflags 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "canvas 0.0.1", "canvas_traits 0.0.1", - "cssparser 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "cssparser 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "devtools_traits 0.0.1", "encoding 0.2.32 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1263,7 +1263,7 @@ version = "0.1.0" source = "git+https://github.com/servo/rust-selectors#572353b3209af040cd3e6261978b09c7f8122844" dependencies = [ "bitflags 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "cssparser 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "cssparser 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "matches 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "quickersort 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1413,7 +1413,7 @@ name = "style" version = "0.0.1" dependencies = [ "bitflags 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "cssparser 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "cssparser 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "encoding 0.2.32 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1530,7 +1530,7 @@ version = "0.0.1" dependencies = [ "azure 0.1.0 (git+https://github.com/servo/rust-azure)", "bitflags 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "cssparser 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "cssparser 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "getopts 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "html5ever 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", From b0aedc6f4c3ebdc395a5fead514f263313aa103c Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Wed, 2 Sep 2015 23:07:11 +0200 Subject: [PATCH 13/15] Enable css-variables-1 tests ``` Summary ======= Ran 548 tests (525 parents, 23 subtests) Expected results: 242 Unexpected results: 306 (FAIL: 304, TIMEOUT: 2) ``` --- python/servo/testing_commands.py | 1 - tests/wpt/include_css.ini | 6 ++ ...s-vars-custom-property-inheritance.htm.ini | 3 + .../html/test_variable_legal_values.htm.ini | 71 +++++++++++++++++++ .../html/variable-declaration-08.htm.ini | 3 + .../html/variable-declaration-14.htm.ini | 3 + .../html/variable-declaration-20.htm.ini | 3 + .../html/variable-declaration-24.htm.ini | 3 + .../html/variable-declaration-26.htm.ini | 3 + .../html/variable-declaration-37.htm.ini | 3 + .../html/variable-declaration-53.htm.ini | 3 + .../html/variable-declaration-54.htm.ini | 3 + .../html/variable-declaration-55.htm.ini | 3 + .../variable-external-font-face-01.htm.ini | 3 + .../variable-external-supports-01.htm.ini | 3 + .../html/variable-font-face-01.htm.ini | 3 + .../html/variable-font-face-02.htm.ini | 3 + .../html/variable-reference-03.htm.ini | 3 + .../html/variable-reference-04.htm.ini | 3 + .../html/variable-reference-13.htm.ini | 3 + .../html/variable-reference-14.htm.ini | 3 + .../html/variable-reference-15.htm.ini | 3 + .../html/variable-reference-18.htm.ini | 3 + .../html/variable-reference-19.htm.ini | 3 + .../html/variable-reference-20.htm.ini | 3 + .../html/variable-reference-26.htm.ini | 3 + .../html/variable-reference-27.htm.ini | 3 + .../html/variable-reference-36.htm.ini | 3 + .../html/variable-reference-38.htm.ini | 3 + .../html/variable-supports-01.htm.ini | 3 + .../html/variable-supports-02.htm.ini | 3 + .../html/variable-supports-03.htm.ini | 3 + .../html/variable-supports-04.htm.ini | 3 + .../html/variable-supports-05.htm.ini | 3 + .../html/variable-supports-06.htm.ini | 3 + .../html/variable-supports-07.htm.ini | 3 + .../html/variable-supports-08.htm.ini | 3 + .../html/variable-supports-09.htm.ini | 3 + .../html/variable-supports-10.htm.ini | 3 + .../html/variable-supports-11.htm.ini | 3 + .../html/variable-supports-12.htm.ini | 3 + .../html/variable-supports-13.htm.ini | 3 + .../html/variable-supports-14.htm.ini | 3 + .../html/variable-supports-15.htm.ini | 3 + .../html/variable-supports-16.htm.ini | 3 + .../html/variable-supports-17.htm.ini | 3 + .../html/variable-supports-18.htm.ini | 3 + .../html/variable-supports-19.htm.ini | 3 + .../html/variable-supports-20.htm.ini | 3 + .../html/variable-supports-21.htm.ini | 3 + .../html/variable-supports-22.htm.ini | 3 + .../html/variable-supports-23.htm.ini | 3 + .../html/variable-supports-24.htm.ini | 3 + .../html/variable-supports-25.htm.ini | 3 + .../html/variable-supports-26.htm.ini | 3 + .../html/variable-supports-27.htm.ini | 3 + .../html/variable-supports-28.htm.ini | 3 + .../html/variable-supports-29.htm.ini | 3 + .../html/variable-supports-30.htm.ini | 3 + .../html/variable-supports-31.htm.ini | 3 + .../html/variable-supports-32.htm.ini | 3 + .../html/variable-supports-33.htm.ini | 3 + .../html/variable-supports-34.htm.ini | 3 + .../html/variable-supports-35.htm.ini | 3 + .../html/variable-supports-36.htm.ini | 3 + .../html/variable-supports-37.htm.ini | 3 + .../html/variable-supports-38.htm.ini | 3 + .../html/variable-supports-39.htm.ini | 3 + .../html/variable-supports-40.htm.ini | 3 + .../html/variable-supports-41.htm.ini | 3 + .../html/variable-supports-42.htm.ini | 3 + .../html/variable-supports-43.htm.ini | 3 + .../html/variable-supports-44.htm.ini | 3 + .../html/variable-supports-45.htm.ini | 3 + .../html/variable-supports-46.htm.ini | 3 + .../html/variable-supports-47.htm.ini | 3 + .../html/variable-supports-48.htm.ini | 3 + .../html/variable-supports-49.htm.ini | 3 + .../html/variable-supports-50.htm.ini | 3 + .../html/variable-supports-51.htm.ini | 3 + .../html/variable-supports-52.htm.ini | 3 + .../html/variable-supports-53.htm.ini | 3 + .../html/variable-supports-54.htm.ini | 3 + .../html/variable-supports-55.htm.ini | 3 + .../html/variable-supports-56.htm.ini | 3 + .../html/variable-supports-57.htm.ini | 3 + .../html/variable-supports-58.htm.ini | 3 + .../html/variable-supports-59.htm.ini | 3 + .../html/variable-supports-60.htm.ini | 3 + .../html/variable-supports-61.htm.ini | 3 + .../html/variable-supports-62.htm.ini | 3 + .../html/variable-supports-63.htm.ini | 3 + .../html/variable-supports-64.htm.ini | 3 + .../html/variable-supports-65.htm.ini | 3 + .../html/variable-supports-66.htm.ini | 3 + .../html/variable-supports-67.htm.ini | 3 + 96 files changed, 356 insertions(+), 1 deletion(-) create mode 100644 tests/wpt/metadata-css/css-variables-1_dev/html/css-vars-custom-property-inheritance.htm.ini create mode 100644 tests/wpt/metadata-css/css-variables-1_dev/html/test_variable_legal_values.htm.ini create mode 100644 tests/wpt/metadata-css/css-variables-1_dev/html/variable-declaration-08.htm.ini create mode 100644 tests/wpt/metadata-css/css-variables-1_dev/html/variable-declaration-14.htm.ini create mode 100644 tests/wpt/metadata-css/css-variables-1_dev/html/variable-declaration-20.htm.ini create mode 100644 tests/wpt/metadata-css/css-variables-1_dev/html/variable-declaration-24.htm.ini create mode 100644 tests/wpt/metadata-css/css-variables-1_dev/html/variable-declaration-26.htm.ini create mode 100644 tests/wpt/metadata-css/css-variables-1_dev/html/variable-declaration-37.htm.ini create mode 100644 tests/wpt/metadata-css/css-variables-1_dev/html/variable-declaration-53.htm.ini create mode 100644 tests/wpt/metadata-css/css-variables-1_dev/html/variable-declaration-54.htm.ini create mode 100644 tests/wpt/metadata-css/css-variables-1_dev/html/variable-declaration-55.htm.ini create mode 100644 tests/wpt/metadata-css/css-variables-1_dev/html/variable-external-font-face-01.htm.ini create mode 100644 tests/wpt/metadata-css/css-variables-1_dev/html/variable-external-supports-01.htm.ini create mode 100644 tests/wpt/metadata-css/css-variables-1_dev/html/variable-font-face-01.htm.ini create mode 100644 tests/wpt/metadata-css/css-variables-1_dev/html/variable-font-face-02.htm.ini create mode 100644 tests/wpt/metadata-css/css-variables-1_dev/html/variable-reference-03.htm.ini create mode 100644 tests/wpt/metadata-css/css-variables-1_dev/html/variable-reference-04.htm.ini create mode 100644 tests/wpt/metadata-css/css-variables-1_dev/html/variable-reference-13.htm.ini create mode 100644 tests/wpt/metadata-css/css-variables-1_dev/html/variable-reference-14.htm.ini create mode 100644 tests/wpt/metadata-css/css-variables-1_dev/html/variable-reference-15.htm.ini create mode 100644 tests/wpt/metadata-css/css-variables-1_dev/html/variable-reference-18.htm.ini create mode 100644 tests/wpt/metadata-css/css-variables-1_dev/html/variable-reference-19.htm.ini create mode 100644 tests/wpt/metadata-css/css-variables-1_dev/html/variable-reference-20.htm.ini create mode 100644 tests/wpt/metadata-css/css-variables-1_dev/html/variable-reference-26.htm.ini create mode 100644 tests/wpt/metadata-css/css-variables-1_dev/html/variable-reference-27.htm.ini create mode 100644 tests/wpt/metadata-css/css-variables-1_dev/html/variable-reference-36.htm.ini create mode 100644 tests/wpt/metadata-css/css-variables-1_dev/html/variable-reference-38.htm.ini create mode 100644 tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-01.htm.ini create mode 100644 tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-02.htm.ini create mode 100644 tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-03.htm.ini create mode 100644 tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-04.htm.ini create mode 100644 tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-05.htm.ini create mode 100644 tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-06.htm.ini create mode 100644 tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-07.htm.ini create mode 100644 tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-08.htm.ini create mode 100644 tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-09.htm.ini create mode 100644 tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-10.htm.ini create mode 100644 tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-11.htm.ini create mode 100644 tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-12.htm.ini create mode 100644 tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-13.htm.ini create mode 100644 tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-14.htm.ini create mode 100644 tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-15.htm.ini create mode 100644 tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-16.htm.ini create mode 100644 tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-17.htm.ini create mode 100644 tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-18.htm.ini create mode 100644 tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-19.htm.ini create mode 100644 tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-20.htm.ini create mode 100644 tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-21.htm.ini create mode 100644 tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-22.htm.ini create mode 100644 tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-23.htm.ini create mode 100644 tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-24.htm.ini create mode 100644 tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-25.htm.ini create mode 100644 tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-26.htm.ini create mode 100644 tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-27.htm.ini create mode 100644 tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-28.htm.ini create mode 100644 tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-29.htm.ini create mode 100644 tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-30.htm.ini create mode 100644 tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-31.htm.ini create mode 100644 tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-32.htm.ini create mode 100644 tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-33.htm.ini create mode 100644 tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-34.htm.ini create mode 100644 tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-35.htm.ini create mode 100644 tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-36.htm.ini create mode 100644 tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-37.htm.ini create mode 100644 tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-38.htm.ini create mode 100644 tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-39.htm.ini create mode 100644 tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-40.htm.ini create mode 100644 tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-41.htm.ini create mode 100644 tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-42.htm.ini create mode 100644 tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-43.htm.ini create mode 100644 tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-44.htm.ini create mode 100644 tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-45.htm.ini create mode 100644 tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-46.htm.ini create mode 100644 tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-47.htm.ini create mode 100644 tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-48.htm.ini create mode 100644 tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-49.htm.ini create mode 100644 tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-50.htm.ini create mode 100644 tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-51.htm.ini create mode 100644 tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-52.htm.ini create mode 100644 tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-53.htm.ini create mode 100644 tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-54.htm.ini create mode 100644 tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-55.htm.ini create mode 100644 tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-56.htm.ini create mode 100644 tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-57.htm.ini create mode 100644 tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-58.htm.ini create mode 100644 tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-59.htm.ini create mode 100644 tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-60.htm.ini create mode 100644 tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-61.htm.ini create mode 100644 tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-62.htm.ini create mode 100644 tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-63.htm.ini create mode 100644 tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-64.htm.ini create mode 100644 tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-65.htm.ini create mode 100644 tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-66.htm.ini create mode 100644 tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-67.htm.ini diff --git a/python/servo/testing_commands.py b/python/servo/testing_commands.py index b30bc025e02..f8841c51d92 100644 --- a/python/servo/testing_commands.py +++ b/python/servo/testing_commands.py @@ -315,7 +315,6 @@ class MachCommands(CommandBase): parser=updatecommandline.create_parser()) def update_css(self, **kwargs): self.ensure_bootstrapped() - self.ensure_wpt_virtualenv() run_file = path.abspath(path.join("tests", "wpt", "update_css.py")) run_globals = {"__file__": run_file} execfile(run_file, run_globals) diff --git a/tests/wpt/include_css.ini b/tests/wpt/include_css.ini index 6f9d3c343da..59e3ddf5796 100644 --- a/tests/wpt/include_css.ini +++ b/tests/wpt/include_css.ini @@ -29,6 +29,12 @@ skip: true skip: true [xhtml1print] skip: true +[css-variables-1_dev] + skip: false + [xhtml1] + skip: true + [xhtml1print] + skip: true [cssom-1_dev] skip: false [xhtml1] diff --git a/tests/wpt/metadata-css/css-variables-1_dev/html/css-vars-custom-property-inheritance.htm.ini b/tests/wpt/metadata-css/css-variables-1_dev/html/css-vars-custom-property-inheritance.htm.ini new file mode 100644 index 00000000000..87fee1c5ce8 --- /dev/null +++ b/tests/wpt/metadata-css/css-variables-1_dev/html/css-vars-custom-property-inheritance.htm.ini @@ -0,0 +1,3 @@ +[css-vars-custom-property-inheritance.htm] + type: reftest + expected: FAIL diff --git a/tests/wpt/metadata-css/css-variables-1_dev/html/test_variable_legal_values.htm.ini b/tests/wpt/metadata-css/css-variables-1_dev/html/test_variable_legal_values.htm.ini new file mode 100644 index 00000000000..f99869b61c6 --- /dev/null +++ b/tests/wpt/metadata-css/css-variables-1_dev/html/test_variable_legal_values.htm.ini @@ -0,0 +1,71 @@ +[test_variable_legal_values.htm] + type: testharness + [percentage] + expected: FAIL + + [number] + expected: FAIL + + [length] + expected: FAIL + + [time] + expected: FAIL + + [function] + expected: FAIL + + [nested_function] + expected: FAIL + + [parentheses] + expected: FAIL + + [braces] + expected: FAIL + + [brackets] + expected: FAIL + + [at_keyword_unknown] + expected: FAIL + + [at_keyword_known] + expected: FAIL + + [at_keyword_unknown_and_block] + expected: FAIL + + [at_keyword_known_and_block] + expected: FAIL + + [unbalanced_close_bracket_at_toplevel] + expected: FAIL + + [unbalanced_close_paren_at_toplevel] + expected: FAIL + + [unbalanced_close_bracket_in_something_balanced] + expected: FAIL + + [unbalanced_close_paren_in_something_balanced] + expected: FAIL + + [unbalanced_close_brace_in_something_balanced] + expected: FAIL + + [CDO_at_top_level] + expected: FAIL + + [CDC_at_top_level] + expected: FAIL + + [semicolon_not_at_top_level_value_unused] + expected: FAIL + + [CDO_not_at_top_level_value_unused] + expected: FAIL + + [CDC_not_at_top_level_value_unused] + expected: FAIL + diff --git a/tests/wpt/metadata-css/css-variables-1_dev/html/variable-declaration-08.htm.ini b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-declaration-08.htm.ini new file mode 100644 index 00000000000..83e66d3a80e --- /dev/null +++ b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-declaration-08.htm.ini @@ -0,0 +1,3 @@ +[variable-declaration-08.htm] + type: reftest + expected: FAIL diff --git a/tests/wpt/metadata-css/css-variables-1_dev/html/variable-declaration-14.htm.ini b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-declaration-14.htm.ini new file mode 100644 index 00000000000..1b565847071 --- /dev/null +++ b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-declaration-14.htm.ini @@ -0,0 +1,3 @@ +[variable-declaration-14.htm] + type: reftest + expected: FAIL diff --git a/tests/wpt/metadata-css/css-variables-1_dev/html/variable-declaration-20.htm.ini b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-declaration-20.htm.ini new file mode 100644 index 00000000000..e3de1be4109 --- /dev/null +++ b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-declaration-20.htm.ini @@ -0,0 +1,3 @@ +[variable-declaration-20.htm] + type: reftest + expected: FAIL diff --git a/tests/wpt/metadata-css/css-variables-1_dev/html/variable-declaration-24.htm.ini b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-declaration-24.htm.ini new file mode 100644 index 00000000000..ba980233612 --- /dev/null +++ b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-declaration-24.htm.ini @@ -0,0 +1,3 @@ +[variable-declaration-24.htm] + type: reftest + expected: FAIL diff --git a/tests/wpt/metadata-css/css-variables-1_dev/html/variable-declaration-26.htm.ini b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-declaration-26.htm.ini new file mode 100644 index 00000000000..98c918745b5 --- /dev/null +++ b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-declaration-26.htm.ini @@ -0,0 +1,3 @@ +[variable-declaration-26.htm] + type: reftest + expected: FAIL diff --git a/tests/wpt/metadata-css/css-variables-1_dev/html/variable-declaration-37.htm.ini b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-declaration-37.htm.ini new file mode 100644 index 00000000000..6c8b66e14c0 --- /dev/null +++ b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-declaration-37.htm.ini @@ -0,0 +1,3 @@ +[variable-declaration-37.htm] + type: reftest + expected: FAIL diff --git a/tests/wpt/metadata-css/css-variables-1_dev/html/variable-declaration-53.htm.ini b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-declaration-53.htm.ini new file mode 100644 index 00000000000..bc25e718bd5 --- /dev/null +++ b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-declaration-53.htm.ini @@ -0,0 +1,3 @@ +[variable-declaration-53.htm] + type: reftest + expected: FAIL diff --git a/tests/wpt/metadata-css/css-variables-1_dev/html/variable-declaration-54.htm.ini b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-declaration-54.htm.ini new file mode 100644 index 00000000000..362a722c3e7 --- /dev/null +++ b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-declaration-54.htm.ini @@ -0,0 +1,3 @@ +[variable-declaration-54.htm] + type: reftest + expected: FAIL diff --git a/tests/wpt/metadata-css/css-variables-1_dev/html/variable-declaration-55.htm.ini b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-declaration-55.htm.ini new file mode 100644 index 00000000000..ca63a2f84da --- /dev/null +++ b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-declaration-55.htm.ini @@ -0,0 +1,3 @@ +[variable-declaration-55.htm] + type: reftest + expected: FAIL diff --git a/tests/wpt/metadata-css/css-variables-1_dev/html/variable-external-font-face-01.htm.ini b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-external-font-face-01.htm.ini new file mode 100644 index 00000000000..4a30d27d7c4 --- /dev/null +++ b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-external-font-face-01.htm.ini @@ -0,0 +1,3 @@ +[variable-external-font-face-01.htm] + type: reftest + expected: FAIL diff --git a/tests/wpt/metadata-css/css-variables-1_dev/html/variable-external-supports-01.htm.ini b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-external-supports-01.htm.ini new file mode 100644 index 00000000000..2dcc7082d9a --- /dev/null +++ b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-external-supports-01.htm.ini @@ -0,0 +1,3 @@ +[variable-external-supports-01.htm] + type: reftest + expected: FAIL diff --git a/tests/wpt/metadata-css/css-variables-1_dev/html/variable-font-face-01.htm.ini b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-font-face-01.htm.ini new file mode 100644 index 00000000000..609b25df4c6 --- /dev/null +++ b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-font-face-01.htm.ini @@ -0,0 +1,3 @@ +[variable-font-face-01.htm] + type: reftest + expected: FAIL diff --git a/tests/wpt/metadata-css/css-variables-1_dev/html/variable-font-face-02.htm.ini b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-font-face-02.htm.ini new file mode 100644 index 00000000000..b186c8159b9 --- /dev/null +++ b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-font-face-02.htm.ini @@ -0,0 +1,3 @@ +[variable-font-face-02.htm] + type: reftest + expected: FAIL diff --git a/tests/wpt/metadata-css/css-variables-1_dev/html/variable-reference-03.htm.ini b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-reference-03.htm.ini new file mode 100644 index 00000000000..d845cc12cd8 --- /dev/null +++ b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-reference-03.htm.ini @@ -0,0 +1,3 @@ +[variable-reference-03.htm] + type: reftest + expected: FAIL diff --git a/tests/wpt/metadata-css/css-variables-1_dev/html/variable-reference-04.htm.ini b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-reference-04.htm.ini new file mode 100644 index 00000000000..fba032c2710 --- /dev/null +++ b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-reference-04.htm.ini @@ -0,0 +1,3 @@ +[variable-reference-04.htm] + type: reftest + expected: FAIL diff --git a/tests/wpt/metadata-css/css-variables-1_dev/html/variable-reference-13.htm.ini b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-reference-13.htm.ini new file mode 100644 index 00000000000..7f832f8cdac --- /dev/null +++ b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-reference-13.htm.ini @@ -0,0 +1,3 @@ +[variable-reference-13.htm] + type: reftest + expected: FAIL diff --git a/tests/wpt/metadata-css/css-variables-1_dev/html/variable-reference-14.htm.ini b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-reference-14.htm.ini new file mode 100644 index 00000000000..dd849805038 --- /dev/null +++ b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-reference-14.htm.ini @@ -0,0 +1,3 @@ +[variable-reference-14.htm] + type: reftest + expected: FAIL diff --git a/tests/wpt/metadata-css/css-variables-1_dev/html/variable-reference-15.htm.ini b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-reference-15.htm.ini new file mode 100644 index 00000000000..7dcf1687aab --- /dev/null +++ b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-reference-15.htm.ini @@ -0,0 +1,3 @@ +[variable-reference-15.htm] + type: reftest + expected: FAIL diff --git a/tests/wpt/metadata-css/css-variables-1_dev/html/variable-reference-18.htm.ini b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-reference-18.htm.ini new file mode 100644 index 00000000000..e09c394fc76 --- /dev/null +++ b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-reference-18.htm.ini @@ -0,0 +1,3 @@ +[variable-reference-18.htm] + type: reftest + expected: FAIL diff --git a/tests/wpt/metadata-css/css-variables-1_dev/html/variable-reference-19.htm.ini b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-reference-19.htm.ini new file mode 100644 index 00000000000..3847b908e1b --- /dev/null +++ b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-reference-19.htm.ini @@ -0,0 +1,3 @@ +[variable-reference-19.htm] + type: reftest + expected: FAIL diff --git a/tests/wpt/metadata-css/css-variables-1_dev/html/variable-reference-20.htm.ini b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-reference-20.htm.ini new file mode 100644 index 00000000000..4ab2b3816af --- /dev/null +++ b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-reference-20.htm.ini @@ -0,0 +1,3 @@ +[variable-reference-20.htm] + type: reftest + expected: FAIL diff --git a/tests/wpt/metadata-css/css-variables-1_dev/html/variable-reference-26.htm.ini b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-reference-26.htm.ini new file mode 100644 index 00000000000..ebd0652279f --- /dev/null +++ b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-reference-26.htm.ini @@ -0,0 +1,3 @@ +[variable-reference-26.htm] + type: reftest + expected: FAIL diff --git a/tests/wpt/metadata-css/css-variables-1_dev/html/variable-reference-27.htm.ini b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-reference-27.htm.ini new file mode 100644 index 00000000000..8a36f19f2e7 --- /dev/null +++ b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-reference-27.htm.ini @@ -0,0 +1,3 @@ +[variable-reference-27.htm] + type: reftest + expected: FAIL diff --git a/tests/wpt/metadata-css/css-variables-1_dev/html/variable-reference-36.htm.ini b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-reference-36.htm.ini new file mode 100644 index 00000000000..d052a96d261 --- /dev/null +++ b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-reference-36.htm.ini @@ -0,0 +1,3 @@ +[variable-reference-36.htm] + type: reftest + expected: FAIL diff --git a/tests/wpt/metadata-css/css-variables-1_dev/html/variable-reference-38.htm.ini b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-reference-38.htm.ini new file mode 100644 index 00000000000..ae8c7dd94be --- /dev/null +++ b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-reference-38.htm.ini @@ -0,0 +1,3 @@ +[variable-reference-38.htm] + type: reftest + expected: FAIL diff --git a/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-01.htm.ini b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-01.htm.ini new file mode 100644 index 00000000000..d9af1a2c62e --- /dev/null +++ b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-01.htm.ini @@ -0,0 +1,3 @@ +[variable-supports-01.htm] + type: reftest + expected: FAIL diff --git a/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-02.htm.ini b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-02.htm.ini new file mode 100644 index 00000000000..2a76c3bef8c --- /dev/null +++ b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-02.htm.ini @@ -0,0 +1,3 @@ +[variable-supports-02.htm] + type: reftest + expected: FAIL diff --git a/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-03.htm.ini b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-03.htm.ini new file mode 100644 index 00000000000..10b78166bb5 --- /dev/null +++ b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-03.htm.ini @@ -0,0 +1,3 @@ +[variable-supports-03.htm] + type: reftest + expected: FAIL diff --git a/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-04.htm.ini b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-04.htm.ini new file mode 100644 index 00000000000..858c344490d --- /dev/null +++ b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-04.htm.ini @@ -0,0 +1,3 @@ +[variable-supports-04.htm] + type: reftest + expected: FAIL diff --git a/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-05.htm.ini b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-05.htm.ini new file mode 100644 index 00000000000..8c9c589af2a --- /dev/null +++ b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-05.htm.ini @@ -0,0 +1,3 @@ +[variable-supports-05.htm] + type: reftest + expected: FAIL diff --git a/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-06.htm.ini b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-06.htm.ini new file mode 100644 index 00000000000..6655f9efcf2 --- /dev/null +++ b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-06.htm.ini @@ -0,0 +1,3 @@ +[variable-supports-06.htm] + type: reftest + expected: FAIL diff --git a/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-07.htm.ini b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-07.htm.ini new file mode 100644 index 00000000000..bcc47cf7648 --- /dev/null +++ b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-07.htm.ini @@ -0,0 +1,3 @@ +[variable-supports-07.htm] + type: reftest + expected: FAIL diff --git a/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-08.htm.ini b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-08.htm.ini new file mode 100644 index 00000000000..aa70cef5031 --- /dev/null +++ b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-08.htm.ini @@ -0,0 +1,3 @@ +[variable-supports-08.htm] + type: reftest + expected: FAIL diff --git a/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-09.htm.ini b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-09.htm.ini new file mode 100644 index 00000000000..5d6a047685a --- /dev/null +++ b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-09.htm.ini @@ -0,0 +1,3 @@ +[variable-supports-09.htm] + type: reftest + expected: FAIL diff --git a/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-10.htm.ini b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-10.htm.ini new file mode 100644 index 00000000000..429a1de87c6 --- /dev/null +++ b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-10.htm.ini @@ -0,0 +1,3 @@ +[variable-supports-10.htm] + type: reftest + expected: FAIL diff --git a/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-11.htm.ini b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-11.htm.ini new file mode 100644 index 00000000000..00933acf99d --- /dev/null +++ b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-11.htm.ini @@ -0,0 +1,3 @@ +[variable-supports-11.htm] + type: reftest + expected: FAIL diff --git a/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-12.htm.ini b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-12.htm.ini new file mode 100644 index 00000000000..5ff5f5f718a --- /dev/null +++ b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-12.htm.ini @@ -0,0 +1,3 @@ +[variable-supports-12.htm] + type: reftest + expected: FAIL diff --git a/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-13.htm.ini b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-13.htm.ini new file mode 100644 index 00000000000..af3ee6bdb6b --- /dev/null +++ b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-13.htm.ini @@ -0,0 +1,3 @@ +[variable-supports-13.htm] + type: reftest + expected: FAIL diff --git a/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-14.htm.ini b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-14.htm.ini new file mode 100644 index 00000000000..73eefff02e5 --- /dev/null +++ b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-14.htm.ini @@ -0,0 +1,3 @@ +[variable-supports-14.htm] + type: reftest + expected: FAIL diff --git a/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-15.htm.ini b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-15.htm.ini new file mode 100644 index 00000000000..ebe07de6210 --- /dev/null +++ b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-15.htm.ini @@ -0,0 +1,3 @@ +[variable-supports-15.htm] + type: reftest + expected: FAIL diff --git a/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-16.htm.ini b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-16.htm.ini new file mode 100644 index 00000000000..36a136b69cd --- /dev/null +++ b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-16.htm.ini @@ -0,0 +1,3 @@ +[variable-supports-16.htm] + type: reftest + expected: FAIL diff --git a/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-17.htm.ini b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-17.htm.ini new file mode 100644 index 00000000000..75d3acfbe79 --- /dev/null +++ b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-17.htm.ini @@ -0,0 +1,3 @@ +[variable-supports-17.htm] + type: reftest + expected: FAIL diff --git a/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-18.htm.ini b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-18.htm.ini new file mode 100644 index 00000000000..e4dca9950fa --- /dev/null +++ b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-18.htm.ini @@ -0,0 +1,3 @@ +[variable-supports-18.htm] + type: reftest + expected: FAIL diff --git a/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-19.htm.ini b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-19.htm.ini new file mode 100644 index 00000000000..1a8e739f267 --- /dev/null +++ b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-19.htm.ini @@ -0,0 +1,3 @@ +[variable-supports-19.htm] + type: reftest + expected: FAIL diff --git a/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-20.htm.ini b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-20.htm.ini new file mode 100644 index 00000000000..5a758403d11 --- /dev/null +++ b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-20.htm.ini @@ -0,0 +1,3 @@ +[variable-supports-20.htm] + type: reftest + expected: FAIL diff --git a/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-21.htm.ini b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-21.htm.ini new file mode 100644 index 00000000000..7be5fdaa0d1 --- /dev/null +++ b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-21.htm.ini @@ -0,0 +1,3 @@ +[variable-supports-21.htm] + type: reftest + expected: FAIL diff --git a/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-22.htm.ini b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-22.htm.ini new file mode 100644 index 00000000000..4ac881de0d3 --- /dev/null +++ b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-22.htm.ini @@ -0,0 +1,3 @@ +[variable-supports-22.htm] + type: reftest + expected: FAIL diff --git a/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-23.htm.ini b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-23.htm.ini new file mode 100644 index 00000000000..c50ae00f220 --- /dev/null +++ b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-23.htm.ini @@ -0,0 +1,3 @@ +[variable-supports-23.htm] + type: reftest + expected: FAIL diff --git a/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-24.htm.ini b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-24.htm.ini new file mode 100644 index 00000000000..6f8ca87f851 --- /dev/null +++ b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-24.htm.ini @@ -0,0 +1,3 @@ +[variable-supports-24.htm] + type: reftest + expected: FAIL diff --git a/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-25.htm.ini b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-25.htm.ini new file mode 100644 index 00000000000..7b463e52dea --- /dev/null +++ b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-25.htm.ini @@ -0,0 +1,3 @@ +[variable-supports-25.htm] + type: reftest + expected: FAIL diff --git a/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-26.htm.ini b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-26.htm.ini new file mode 100644 index 00000000000..143d383962f --- /dev/null +++ b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-26.htm.ini @@ -0,0 +1,3 @@ +[variable-supports-26.htm] + type: reftest + expected: FAIL diff --git a/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-27.htm.ini b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-27.htm.ini new file mode 100644 index 00000000000..c466b6bb8cc --- /dev/null +++ b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-27.htm.ini @@ -0,0 +1,3 @@ +[variable-supports-27.htm] + type: reftest + expected: FAIL diff --git a/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-28.htm.ini b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-28.htm.ini new file mode 100644 index 00000000000..ffbe66958bb --- /dev/null +++ b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-28.htm.ini @@ -0,0 +1,3 @@ +[variable-supports-28.htm] + type: reftest + expected: FAIL diff --git a/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-29.htm.ini b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-29.htm.ini new file mode 100644 index 00000000000..b9f3eca69b6 --- /dev/null +++ b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-29.htm.ini @@ -0,0 +1,3 @@ +[variable-supports-29.htm] + type: reftest + expected: FAIL diff --git a/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-30.htm.ini b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-30.htm.ini new file mode 100644 index 00000000000..60ab9706d58 --- /dev/null +++ b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-30.htm.ini @@ -0,0 +1,3 @@ +[variable-supports-30.htm] + type: reftest + expected: FAIL diff --git a/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-31.htm.ini b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-31.htm.ini new file mode 100644 index 00000000000..4b5a47f9612 --- /dev/null +++ b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-31.htm.ini @@ -0,0 +1,3 @@ +[variable-supports-31.htm] + type: reftest + expected: FAIL diff --git a/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-32.htm.ini b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-32.htm.ini new file mode 100644 index 00000000000..4927839bf9e --- /dev/null +++ b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-32.htm.ini @@ -0,0 +1,3 @@ +[variable-supports-32.htm] + type: reftest + expected: FAIL diff --git a/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-33.htm.ini b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-33.htm.ini new file mode 100644 index 00000000000..1ecaf6bfd3b --- /dev/null +++ b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-33.htm.ini @@ -0,0 +1,3 @@ +[variable-supports-33.htm] + type: reftest + expected: FAIL diff --git a/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-34.htm.ini b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-34.htm.ini new file mode 100644 index 00000000000..7d0ddaa47cc --- /dev/null +++ b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-34.htm.ini @@ -0,0 +1,3 @@ +[variable-supports-34.htm] + type: reftest + expected: FAIL diff --git a/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-35.htm.ini b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-35.htm.ini new file mode 100644 index 00000000000..859c6bd4580 --- /dev/null +++ b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-35.htm.ini @@ -0,0 +1,3 @@ +[variable-supports-35.htm] + type: reftest + expected: FAIL diff --git a/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-36.htm.ini b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-36.htm.ini new file mode 100644 index 00000000000..762fa0568e8 --- /dev/null +++ b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-36.htm.ini @@ -0,0 +1,3 @@ +[variable-supports-36.htm] + type: reftest + expected: FAIL diff --git a/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-37.htm.ini b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-37.htm.ini new file mode 100644 index 00000000000..27618269abb --- /dev/null +++ b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-37.htm.ini @@ -0,0 +1,3 @@ +[variable-supports-37.htm] + type: reftest + expected: FAIL diff --git a/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-38.htm.ini b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-38.htm.ini new file mode 100644 index 00000000000..55a97c321c8 --- /dev/null +++ b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-38.htm.ini @@ -0,0 +1,3 @@ +[variable-supports-38.htm] + type: reftest + expected: FAIL diff --git a/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-39.htm.ini b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-39.htm.ini new file mode 100644 index 00000000000..cdf10813ceb --- /dev/null +++ b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-39.htm.ini @@ -0,0 +1,3 @@ +[variable-supports-39.htm] + type: reftest + expected: FAIL diff --git a/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-40.htm.ini b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-40.htm.ini new file mode 100644 index 00000000000..99b6289950f --- /dev/null +++ b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-40.htm.ini @@ -0,0 +1,3 @@ +[variable-supports-40.htm] + type: reftest + expected: FAIL diff --git a/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-41.htm.ini b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-41.htm.ini new file mode 100644 index 00000000000..d2d69f5537a --- /dev/null +++ b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-41.htm.ini @@ -0,0 +1,3 @@ +[variable-supports-41.htm] + type: reftest + expected: FAIL diff --git a/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-42.htm.ini b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-42.htm.ini new file mode 100644 index 00000000000..bba3b375886 --- /dev/null +++ b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-42.htm.ini @@ -0,0 +1,3 @@ +[variable-supports-42.htm] + type: reftest + expected: FAIL diff --git a/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-43.htm.ini b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-43.htm.ini new file mode 100644 index 00000000000..0c1e6915bc2 --- /dev/null +++ b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-43.htm.ini @@ -0,0 +1,3 @@ +[variable-supports-43.htm] + type: reftest + expected: FAIL diff --git a/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-44.htm.ini b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-44.htm.ini new file mode 100644 index 00000000000..081028c3c8a --- /dev/null +++ b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-44.htm.ini @@ -0,0 +1,3 @@ +[variable-supports-44.htm] + type: reftest + expected: FAIL diff --git a/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-45.htm.ini b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-45.htm.ini new file mode 100644 index 00000000000..99883fa2a5d --- /dev/null +++ b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-45.htm.ini @@ -0,0 +1,3 @@ +[variable-supports-45.htm] + type: reftest + expected: FAIL diff --git a/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-46.htm.ini b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-46.htm.ini new file mode 100644 index 00000000000..645552e49a3 --- /dev/null +++ b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-46.htm.ini @@ -0,0 +1,3 @@ +[variable-supports-46.htm] + type: reftest + expected: FAIL diff --git a/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-47.htm.ini b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-47.htm.ini new file mode 100644 index 00000000000..5124c4250d2 --- /dev/null +++ b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-47.htm.ini @@ -0,0 +1,3 @@ +[variable-supports-47.htm] + type: reftest + expected: FAIL diff --git a/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-48.htm.ini b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-48.htm.ini new file mode 100644 index 00000000000..ea9414cbdbe --- /dev/null +++ b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-48.htm.ini @@ -0,0 +1,3 @@ +[variable-supports-48.htm] + type: reftest + expected: FAIL diff --git a/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-49.htm.ini b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-49.htm.ini new file mode 100644 index 00000000000..4144bbc5409 --- /dev/null +++ b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-49.htm.ini @@ -0,0 +1,3 @@ +[variable-supports-49.htm] + type: reftest + expected: FAIL diff --git a/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-50.htm.ini b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-50.htm.ini new file mode 100644 index 00000000000..b6439107a90 --- /dev/null +++ b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-50.htm.ini @@ -0,0 +1,3 @@ +[variable-supports-50.htm] + type: reftest + expected: FAIL diff --git a/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-51.htm.ini b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-51.htm.ini new file mode 100644 index 00000000000..b410bb93b12 --- /dev/null +++ b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-51.htm.ini @@ -0,0 +1,3 @@ +[variable-supports-51.htm] + type: reftest + expected: FAIL diff --git a/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-52.htm.ini b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-52.htm.ini new file mode 100644 index 00000000000..2c9e7514109 --- /dev/null +++ b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-52.htm.ini @@ -0,0 +1,3 @@ +[variable-supports-52.htm] + type: reftest + expected: FAIL diff --git a/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-53.htm.ini b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-53.htm.ini new file mode 100644 index 00000000000..4fffd98e875 --- /dev/null +++ b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-53.htm.ini @@ -0,0 +1,3 @@ +[variable-supports-53.htm] + type: reftest + expected: FAIL diff --git a/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-54.htm.ini b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-54.htm.ini new file mode 100644 index 00000000000..37283ae8192 --- /dev/null +++ b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-54.htm.ini @@ -0,0 +1,3 @@ +[variable-supports-54.htm] + type: reftest + expected: FAIL diff --git a/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-55.htm.ini b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-55.htm.ini new file mode 100644 index 00000000000..cb8890afcfa --- /dev/null +++ b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-55.htm.ini @@ -0,0 +1,3 @@ +[variable-supports-55.htm] + type: reftest + expected: FAIL diff --git a/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-56.htm.ini b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-56.htm.ini new file mode 100644 index 00000000000..a562d60c8eb --- /dev/null +++ b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-56.htm.ini @@ -0,0 +1,3 @@ +[variable-supports-56.htm] + type: reftest + expected: FAIL diff --git a/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-57.htm.ini b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-57.htm.ini new file mode 100644 index 00000000000..e5f03795a88 --- /dev/null +++ b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-57.htm.ini @@ -0,0 +1,3 @@ +[variable-supports-57.htm] + type: reftest + expected: FAIL diff --git a/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-58.htm.ini b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-58.htm.ini new file mode 100644 index 00000000000..7ee7e234555 --- /dev/null +++ b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-58.htm.ini @@ -0,0 +1,3 @@ +[variable-supports-58.htm] + type: reftest + expected: FAIL diff --git a/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-59.htm.ini b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-59.htm.ini new file mode 100644 index 00000000000..165dfe7ef8c --- /dev/null +++ b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-59.htm.ini @@ -0,0 +1,3 @@ +[variable-supports-59.htm] + type: reftest + expected: FAIL diff --git a/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-60.htm.ini b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-60.htm.ini new file mode 100644 index 00000000000..a265822da12 --- /dev/null +++ b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-60.htm.ini @@ -0,0 +1,3 @@ +[variable-supports-60.htm] + type: reftest + expected: FAIL diff --git a/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-61.htm.ini b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-61.htm.ini new file mode 100644 index 00000000000..d1226d0e00d --- /dev/null +++ b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-61.htm.ini @@ -0,0 +1,3 @@ +[variable-supports-61.htm] + type: reftest + expected: FAIL diff --git a/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-62.htm.ini b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-62.htm.ini new file mode 100644 index 00000000000..f07a84c252d --- /dev/null +++ b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-62.htm.ini @@ -0,0 +1,3 @@ +[variable-supports-62.htm] + type: reftest + expected: FAIL diff --git a/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-63.htm.ini b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-63.htm.ini new file mode 100644 index 00000000000..3a7f832b090 --- /dev/null +++ b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-63.htm.ini @@ -0,0 +1,3 @@ +[variable-supports-63.htm] + type: reftest + expected: FAIL diff --git a/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-64.htm.ini b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-64.htm.ini new file mode 100644 index 00000000000..7611a917f01 --- /dev/null +++ b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-64.htm.ini @@ -0,0 +1,3 @@ +[variable-supports-64.htm] + type: reftest + expected: FAIL diff --git a/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-65.htm.ini b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-65.htm.ini new file mode 100644 index 00000000000..75a24c09df1 --- /dev/null +++ b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-65.htm.ini @@ -0,0 +1,3 @@ +[variable-supports-65.htm] + type: reftest + expected: FAIL diff --git a/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-66.htm.ini b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-66.htm.ini new file mode 100644 index 00000000000..fa2e8be2530 --- /dev/null +++ b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-66.htm.ini @@ -0,0 +1,3 @@ +[variable-supports-66.htm] + type: reftest + expected: FAIL diff --git a/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-67.htm.ini b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-67.htm.ini new file mode 100644 index 00000000000..e5073eb3163 --- /dev/null +++ b/tests/wpt/metadata-css/css-variables-1_dev/html/variable-supports-67.htm.ini @@ -0,0 +1,3 @@ +[variable-supports-67.htm] + type: reftest + expected: FAIL From a9db4eef14569b58ff98d355d5b4234da1c43bae Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Thu, 3 Sep 2015 08:36:03 +0200 Subject: [PATCH 14/15] Factor out custom property name parsing. --- components/style/custom_properties.rs | 83 +++++++++++++++------------ components/style/properties.mako.rs | 9 +-- 2 files changed, 48 insertions(+), 44 deletions(-) diff --git a/components/style/custom_properties.rs b/components/style/custom_properties.rs index 18aeb9dd0ca..ed8a4c8246a 100644 --- a/components/style/custom_properties.rs +++ b/components/style/custom_properties.rs @@ -8,18 +8,30 @@ use std::collections::{HashMap, HashSet}; use std::sync::Arc; use string_cache::Atom; +// Does not include the `--` prefix +pub type Name = Atom; + +// https://drafts.csswg.org/css-variables/#typedef-custom-property-name +pub fn parse_name(s: &str) -> Result { + if s.starts_with("--") { + Ok(Atom::from_slice(&s[2..])) + } else { + Err(()) + } +} + #[derive(Clone, PartialEq)] pub struct Value { /// In CSS syntax value: String, - /// Custom property names in var() functions. Do not include the `--` prefix. - references: HashSet, + /// Custom property names in var() functions. + references: HashSet, } pub struct BorrowedValue<'a> { value: &'a str, - references: Option<&'a HashSet>, + references: Option<&'a HashSet>, } pub fn parse(input: &mut Parser) -> Result { @@ -35,7 +47,7 @@ pub fn parse(input: &mut Parser) -> Result { } /// https://drafts.csswg.org/css-syntax-3/#typedef-declaration-value -pub fn parse_declaration_value(input: &mut Parser, references: &mut Option>) +pub fn parse_declaration_value(input: &mut Parser, references: &mut Option>) -> Result<(), ()> { if input.is_exhausted() { // Need at least one token @@ -77,7 +89,7 @@ pub fn parse_declaration_value(input: &mut Parser, references: &mut Option>) +fn parse_declaration_value_block(input: &mut Parser, references: &mut Option>) -> Result<(), ()> { while let Ok(token) = input.next() { match token { @@ -111,30 +123,25 @@ fn parse_declaration_value_block(input: &mut Parser, references: &mut Option(input: &mut Parser<'i, 't>, references: &mut Option>) +fn parse_var_function<'i, 't>(input: &mut Parser<'i, 't>, references: &mut Option>) -> Result<(), ()> { - // https://drafts.csswg.org/css-variables/#typedef-custom-property-name let name = try!(input.expect_ident()); - let name = if name.starts_with("--") { - &name[2..] - } else { - return Err(()) - }; + let name = try!(parse_name(&name)); if input.expect_comma().is_ok() { try!(parse_declaration_value(input, references)); } if let Some(ref mut refs) = *references { - refs.insert(Atom::from_slice(name)); + refs.insert(name); } Ok(()) } /// Add one custom property declaration to a map, /// unless another with the same name was already there. -pub fn cascade<'a>(custom_properties: &mut Option>>, - inherited: &'a Option>>, - seen: &mut HashSet<&'a Atom>, - name: &'a Atom, +pub fn cascade<'a>(custom_properties: &mut Option>>, + inherited: &'a Option>>, + seen: &mut HashSet<&'a Name>, + name: &'a Name, value: &'a DeclaredValue) { let was_not_already_present = seen.insert(name); if was_not_already_present { @@ -166,9 +173,9 @@ pub fn cascade<'a>(custom_properties: &mut Option>, - inherited: &Option>>) - -> Option>> { +pub fn finish_cascade(custom_properties: Option>, + inherited: &Option>>) + -> Option>> { if let Some(mut map) = custom_properties { remove_cycles(&mut map); Some(Arc::new(substitute_all(map, inherited))) @@ -179,7 +186,7 @@ pub fn finish_cascade(custom_properties: Option>, /// https://drafts.csswg.org/css-variables/#cycles /// The initial value of a custom property is represented by this property not being in the map. -fn remove_cycles(map: &mut HashMap<&Atom, BorrowedValue>) { +fn remove_cycles(map: &mut HashMap<&Name, BorrowedValue>) { let mut to_remove = HashSet::new(); { let mut visited = HashSet::new(); @@ -187,11 +194,11 @@ fn remove_cycles(map: &mut HashMap<&Atom, BorrowedValue>) { for name in map.keys() { walk(map, name, &mut stack, &mut visited, &mut to_remove); - fn walk<'a>(map: &HashMap<&'a Atom, BorrowedValue<'a>>, - name: &'a Atom, - stack: &mut Vec<&'a Atom>, - visited: &mut HashSet<&'a Atom>, - to_remove: &mut HashSet) { + fn walk<'a>(map: &HashMap<&'a Name, BorrowedValue<'a>>, + name: &'a Name, + stack: &mut Vec<&'a Name>, + visited: &mut HashSet<&'a Name>, + to_remove: &mut HashSet) { let already_visited_before = !visited.insert(name); if already_visited_before { return @@ -221,9 +228,9 @@ fn remove_cycles(map: &mut HashMap<&Atom, BorrowedValue>) { } /// Replace `var()` functions for all custom properties. -fn substitute_all(custom_properties: HashMap<&Atom, BorrowedValue>, - inherited: &Option>>) - -> HashMap { +fn substitute_all(custom_properties: HashMap<&Name, BorrowedValue>, + inherited: &Option>>) + -> HashMap { let mut substituted_map = HashMap::new(); let mut invalid = HashSet::new(); for (&name, value) in &custom_properties { @@ -238,13 +245,13 @@ fn substitute_all(custom_properties: HashMap<&Atom, BorrowedValue>, /// Replace `var()` functions for one custom property. /// Also recursively record results for other custom properties referenced by `var()` functions. /// Return `Err(())` for invalid at computed time. -fn substitute_one(name: &Atom, +fn substitute_one(name: &Name, value: &BorrowedValue, - custom_properties: &HashMap<&Atom, BorrowedValue>, - inherited: &Option>>, + custom_properties: &HashMap<&Name, BorrowedValue>, + inherited: &Option>>, substituted: Option<&mut String>, - substituted_map: &mut HashMap, - invalid: &mut HashSet) + substituted_map: &mut HashMap, + invalid: &mut HashSet) -> Result<(), ()> { if let Some(value) = substituted_map.get(name) { if let Some(substituted) = substituted { @@ -305,7 +312,7 @@ fn substitute_block(input: &mut Parser, substituted: &mut String, substitute_one: &mut F) -> Result<(), ()> - where F: FnMut(&Atom, &mut String) -> Result<(), ()> { + where F: FnMut(&Name, &mut String) -> Result<(), ()> { loop { let input_slice = input.slice_from(*start); let token = if let Ok(token) = input.next() { token } else { break }; @@ -313,9 +320,9 @@ fn substitute_block(input: &mut Parser, Token::Function(ref name) if name == "var" => { substituted.push_str(input_slice); try!(input.parse_nested_block(|input| { + // parse_var_function() ensures neither .unwrap() will fail. let name = input.expect_ident().unwrap(); - debug_assert!(name.starts_with("--")); // Ensured by parse_var_function() - let name = Atom::from_slice(&name[2..]); + let name = parse_name(&name).unwrap(); if substitute_one(&name, substituted).is_ok() { // Skip over the fallback, as `parse_nested_block` would return `Err` @@ -356,7 +363,7 @@ fn substitute_block(input: &mut Parser, /// Replace `var()` functions for a non-custom property. /// Return `Err(())` for invalid at computed time. -pub fn substitute(input: &str, custom_properties: &Option>>) +pub fn substitute(input: &str, custom_properties: &Option>>) -> Result { let empty_map; let custom_properties = if let &Some(ref arc) = custom_properties { diff --git a/components/style/properties.mako.rs b/components/style/properties.mako.rs index d50018bf37c..7f051dfc4cd 100644 --- a/components/style/properties.mako.rs +++ b/components/style/properties.mako.rs @@ -5727,8 +5727,7 @@ pub enum PropertyDeclaration { % for property in LONGHANDS: ${property.camel_case}(DeclaredValue), % endfor - /// Name (atom) does not include the `--` prefix. - Custom(Atom, DeclaredValue<::custom_properties::Value>), + Custom(::custom_properties::Name, DeclaredValue<::custom_properties::Value>), } @@ -5779,7 +5778,7 @@ impl PropertyDeclaration { pub fn parse(name: &str, context: &ParserContext, input: &mut Parser, result_list: &mut Vec) -> PropertyDeclarationParseResult { - if name.starts_with("--") { + if let Ok(name) = ::custom_properties::parse_name(name) { let value = match input.try(CSSWideKeyword::parse) { Ok(CSSWideKeyword::UnsetKeyword) | // Custom properties are alawys inherited Ok(CSSWideKeyword::InheritKeyword) => DeclaredValue::Inherit, @@ -5789,7 +5788,6 @@ impl PropertyDeclaration { Err(()) => return PropertyDeclarationParseResult::InvalidValue, } }; - let name = Atom::from_slice(&name[2..]); result_list.push(PropertyDeclaration::Custom(name, value)); return PropertyDeclarationParseResult::ValidOrIgnoredDeclaration; } @@ -5900,8 +5898,7 @@ pub struct ComputedValues { % for style_struct in STYLE_STRUCTS: ${style_struct.ident}: Arc, % endfor - /// Names (atoms) do not include the `--` prefix. - custom_properties: Option>>, + custom_properties: Option>>, shareable: bool, pub writing_mode: WritingMode, pub root_font_size: Au, From c651c2f3dbeb4f0687b6dad71ae6fc56b0ef4994 Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Thu, 3 Sep 2015 19:20:45 +0200 Subject: [PATCH 15/15] Remove obsolete FIXME comment. See https://lists.w3.org/Archives/Public/www-style/2015Jul/0360.html --- components/style/custom_properties.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/components/style/custom_properties.rs b/components/style/custom_properties.rs index ed8a4c8246a..7a8ce7c2c67 100644 --- a/components/style/custom_properties.rs +++ b/components/style/custom_properties.rs @@ -279,8 +279,6 @@ fn substitute_one(name: &Name, substituted } else { // Invalid at computed-value time. Use the inherited value. - // FIXME: Should it be the inital value instead? - // See https://lists.w3.org/Archives/Public/www-style/2015Jul/0354.html if let Some(value) = inherited.as_ref().and_then(|i| i.get(name)) { value.clone() } else {