aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHuxley <framlog@gmail.com>2017-02-17 14:29:07 +0800
committerHuxley <framlog@gmail.com>2017-02-19 22:59:51 +0800
commit06650f8428f4ef7ec8477b8ec234d85b8c84c189 (patch)
treec57f86fcdee6cf518235204fb4d204cfb39e0b30
parent11396b4dd3834d6794bd4e32f30c1df96fc6a01d (diff)
downloadservo-06650f8428f4ef7ec8477b8ec234d85b8c84c189.tar.gz
servo-06650f8428f4ef7ec8477b8ec234d85b8c84c189.zip
fixed the wrong behavior of border-spacing
-rw-r--r--components/style/properties/longhand/inherited_table.mako.rs8
-rw-r--r--tests/unit/style/parsing/border.rs9
-rw-r--r--tests/unit/style/parsing/mod.rs11
3 files changed, 22 insertions, 6 deletions
diff --git a/components/style/properties/longhand/inherited_table.mako.rs b/components/style/properties/longhand/inherited_table.mako.rs
index 21930ed0114..c80fe9779fe 100644
--- a/components/style/properties/longhand/inherited_table.mako.rs
+++ b/components/style/properties/longhand/inherited_table.mako.rs
@@ -113,15 +113,11 @@ ${helpers.single_keyword("caption-side", "top bottom",
Err(()) => (),
Ok(length) => {
first = Some(length);
- match specified::Length::parse_non_negative(input) {
- Err(()) => (),
- Ok(length) => second = Some(length),
+ if let Ok(len) = input.try(|input| specified::Length::parse_non_negative(input)) {
+ second = Some(len);
}
}
}
- if input.next().is_ok() {
- return Err(())
- }
match (first, second) {
(None, None) => Err(()),
(Some(length), None) => {
diff --git a/tests/unit/style/parsing/border.rs b/tests/unit/style/parsing/border.rs
index 56a0ad47a90..fe6ef2ef087 100644
--- a/tests/unit/style/parsing/border.rs
+++ b/tests/unit/style/parsing/border.rs
@@ -139,3 +139,12 @@ fn test_border_style() {
assert_roundtrip_with_context!(BorderStyle::parse, r#"inset"#);
assert_roundtrip_with_context!(BorderStyle::parse, r#"outset"#);
}
+
+#[test]
+fn test_border_spacing() {
+ use style::properties::longhands::border_spacing;
+
+ assert_parser_exhausted!(border_spacing, "1px rubbish", false);
+ assert_parser_exhausted!(border_spacing, "1px", true);
+ assert_parser_exhausted!(border_spacing, "1px 2px", true);
+}
diff --git a/tests/unit/style/parsing/mod.rs b/tests/unit/style/parsing/mod.rs
index 4d968cc97d0..d5142efffca 100644
--- a/tests/unit/style/parsing/mod.rs
+++ b/tests/unit/style/parsing/mod.rs
@@ -58,6 +58,17 @@ macro_rules! assert_roundtrip {
}
}
+macro_rules! assert_parser_exhausted {
+ ($name:ident, $string:expr, $should_exhausted:expr) => {{
+ let url = ::servo_url::ServoUrl::parse("http://localhost").unwrap();
+ let context = ParserContext::new(Origin::Author, &url, Box::new(CSSErrorReporterTest));
+ let mut parser = Parser::new($string);
+ let parsed = $name::parse(&context, &mut parser);
+ assert_eq!(parsed.is_ok(), true);
+ assert_eq!(parser.is_exhausted(), $should_exhausted);
+ }}
+}
+
macro_rules! parse_longhand {
($name:ident, $s:expr) => {{
let url = ::servo_url::ServoUrl::parse("http://localhost").unwrap();