Fix !important in custom properties.

Test changes are also in https://github.com/w3c/csswg-test/pull/847/files
This commit is contained in:
Simon Sapin 2015-09-07 16:07:56 +02:00
parent 4abe7cdf97
commit c7622bf22f
9 changed files with 38 additions and 81 deletions

View file

@ -137,7 +137,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.6 (registry+https://github.com/rust-lang/crates.io-index)",
"cssparser 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.2.0 (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)",
@ -154,7 +154,7 @@ name = "canvas_traits"
version = "0.0.1"
dependencies = [
"azure 0.1.0 (git+https://github.com/servo/rust-azure)",
"cssparser 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
"cssparser 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.2.0 (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)",
@ -290,7 +290,7 @@ dependencies = [
[[package]]
name = "cssparser"
version = "0.3.6"
version = "0.3.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"encoding 0.2.32 (registry+https://github.com/rust-lang/crates.io-index)",
@ -929,7 +929,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.6 (registry+https://github.com/rust-lang/crates.io-index)",
"cssparser 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
"encoding 0.2.32 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"fnv 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
@ -1414,7 +1414,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.6 (registry+https://github.com/rust-lang/crates.io-index)",
"cssparser 0.3.8 (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.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
@ -1480,7 +1480,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.6 (registry+https://github.com/rust-lang/crates.io-index)",
"cssparser 0.3.8 (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)",
@ -1622,7 +1622,7 @@ name = "style"
version = "0.0.1"
dependencies = [
"bitflags 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
"cssparser 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
"cssparser 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
"encoding 0.2.32 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"fnv 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
@ -1647,7 +1647,7 @@ dependencies = [
name = "style_tests"
version = "0.0.1"
dependencies = [
"cssparser 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
"cssparser 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"selectors 0.1.0 (git+https://github.com/servo/rust-selectors)",
"string_cache 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)",
@ -1662,7 +1662,7 @@ dependencies = [
name = "style_traits"
version = "0.0.1"
dependencies = [
"cssparser 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
"cssparser 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
@ -1784,7 +1784,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.6 (registry+https://github.com/rust-lang/crates.io-index)",
"cssparser 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.2.0 (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.4 (registry+https://github.com/rust-lang/crates.io-index)",

View file

@ -23,7 +23,7 @@ git = "https://github.com/servo/rust-selectors"
features = ["unstable"]
[dependencies.cssparser]
version = "0.3.6"
version = "0.3.8"
features = [ "serde-serialization" ]
[dependencies.url]

View file

@ -2,7 +2,7 @@
* 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, SourcePosition};
use cssparser::{Parser, Token, SourcePosition, Delimiter};
use properties::DeclaredValue;
use std::collections::{HashMap, HashSet};
use std::sync::Arc;
@ -37,8 +37,6 @@ pub struct BorrowedValue<'a> {
pub fn parse(input: &mut Parser) -> Result<Value, ()> {
let start = input.position();
let mut references = Some(HashSet::new());
// FIXME: dont 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(),
@ -49,42 +47,13 @@ pub fn parse(input: &mut Parser) -> Result<Value, ()> {
/// https://drafts.csswg.org/css-syntax-3/#typedef-declaration-value
pub fn parse_declaration_value(input: &mut Parser, references: &mut Option<HashSet<Name>>)
-> Result<(), ()> {
input.parse_until_before(Delimiter::Bang | Delimiter::Semicolon, |input| {
if input.is_exhausted() {
// Need at least one token
return Err(())
}
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!(input.parse_nested_block(|input| {
parse_var_function(input, references)
}));
}
Token::Function(_) |
Token::ParenthesisBlock |
Token::CurlyBracketBlock |
Token::SquareBracketBlock => {
try!(input.parse_nested_block(|input| {
parse_declaration_value_block(input, references)
}));
}
_ => {}
}
}
Ok(())
})
}
/// Like parse_declaration_value,
@ -312,11 +281,11 @@ fn substitute_block<F>(input: &mut Parser,
-> Result<(), ()>
where F: FnMut(&Name, &mut String) -> Result<(), ()> {
loop {
let input_slice = input.slice_from(*start);
let before_this_token = input.position();
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);
substituted.push_str(input.slice(*start..before_this_token));
try!(input.parse_nested_block(|input| {
// parse_var_function() ensures neither .unwrap() will fail.
let name = input.expect_ident().unwrap();

18
ports/cef/Cargo.lock generated
View file

@ -129,7 +129,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.6 (registry+https://github.com/rust-lang/crates.io-index)",
"cssparser 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.2.0 (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)",
@ -146,7 +146,7 @@ name = "canvas_traits"
version = "0.0.1"
dependencies = [
"azure 0.1.0 (git+https://github.com/servo/rust-azure)",
"cssparser 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
"cssparser 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.2.0 (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)",
@ -282,7 +282,7 @@ dependencies = [
[[package]]
name = "cssparser"
version = "0.3.6"
version = "0.3.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"encoding 0.2.32 (registry+https://github.com/rust-lang/crates.io-index)",
@ -880,7 +880,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.6 (registry+https://github.com/rust-lang/crates.io-index)",
"cssparser 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
"encoding 0.2.32 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"fnv 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
@ -1348,7 +1348,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.6 (registry+https://github.com/rust-lang/crates.io-index)",
"cssparser 0.3.8 (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.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
@ -1406,7 +1406,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.6 (registry+https://github.com/rust-lang/crates.io-index)",
"cssparser 0.3.8 (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)",
@ -1581,7 +1581,7 @@ name = "style"
version = "0.0.1"
dependencies = [
"bitflags 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
"cssparser 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
"cssparser 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
"encoding 0.2.32 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"fnv 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
@ -1606,7 +1606,7 @@ dependencies = [
name = "style_traits"
version = "0.0.1"
dependencies = [
"cssparser 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
"cssparser 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
@ -1728,7 +1728,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.6 (registry+https://github.com/rust-lang/crates.io-index)",
"cssparser 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.2.0 (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.4 (registry+https://github.com/rust-lang/crates.io-index)",

18
ports/gonk/Cargo.lock generated
View file

@ -110,7 +110,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.6 (registry+https://github.com/rust-lang/crates.io-index)",
"cssparser 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.2.0 (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)",
@ -127,7 +127,7 @@ name = "canvas_traits"
version = "0.0.1"
dependencies = [
"azure 0.1.0 (git+https://github.com/servo/rust-azure)",
"cssparser 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
"cssparser 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.2.0 (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)",
@ -252,7 +252,7 @@ dependencies = [
[[package]]
name = "cssparser"
version = "0.3.6"
version = "0.3.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"encoding 0.2.32 (registry+https://github.com/rust-lang/crates.io-index)",
@ -764,7 +764,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.6 (registry+https://github.com/rust-lang/crates.io-index)",
"cssparser 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
"encoding 0.2.32 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"fnv 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
@ -1214,7 +1214,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.6 (registry+https://github.com/rust-lang/crates.io-index)",
"cssparser 0.3.8 (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.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
@ -1272,7 +1272,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.6 (registry+https://github.com/rust-lang/crates.io-index)",
"cssparser 0.3.8 (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)",
@ -1427,7 +1427,7 @@ name = "style"
version = "0.0.1"
dependencies = [
"bitflags 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
"cssparser 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
"cssparser 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
"encoding 0.2.32 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"fnv 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
@ -1452,7 +1452,7 @@ dependencies = [
name = "style_traits"
version = "0.0.1"
dependencies = [
"cssparser 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
"cssparser 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
@ -1563,7 +1563,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.6 (registry+https://github.com/rust-lang/crates.io-index)",
"cssparser 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.2.0 (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.4 (registry+https://github.com/rust-lang/crates.io-index)",

View file

@ -1,3 +0,0 @@
[css-vars-custom-property-inheritance.htm]
type: reftest
expected: FAIL

View file

@ -1,3 +0,0 @@
[variable-declaration-20.htm]
type: reftest
expected: FAIL

View file

@ -1,3 +0,0 @@
[variable-reference-13.htm]
type: reftest
expected: FAIL

View file

@ -1,3 +0,0 @@
[variable-reference-14.htm]
type: reftest
expected: FAIL