servo: Merge #15612 - fixed the wrong behavior of border-spacing (from UnICorN21:master); r=canaltinova

fixed the wrong behavior of border-spacing
---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #15489.

<!-- Either: -->
- [X] There are tests for these changes OR
- [ ] These changes do not require tests because _____

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

Source-Repo: https://github.com/servo/servo
Source-Revision: d724bffde80fec1698a485698d8743022a1e9d57

--HG--
extra : subtree_source : https%3A//hg.mozilla.org/projects/converted-servo-linear
extra : subtree_revision : dc82e9b07fe6ec0541c1a4672865c5ca792e5cf2
This commit is contained in:
Huxley 2017-02-21 01:09:35 -08:00
parent 6aa1497673
commit c9fa1b34e6
3 changed files with 22 additions and 6 deletions

View File

@ -114,15 +114,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) => {

View File

@ -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);
}

View File

@ -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();