Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix parsing/serialization bug in contain property
  • Loading branch information
canova committed Apr 17, 2017
1 parent 86aa4e8 commit 05a4feb
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
10 changes: 6 additions & 4 deletions components/style/properties/longhand/box.mako.rs
Expand Up @@ -2096,8 +2096,10 @@ ${helpers.single_keyword("transform-style",
const LAYOUT = 0x02,
const STYLE = 0x04,
const PAINT = 0x08,
const STRICT = SIZE.bits | LAYOUT.bits | STYLE.bits | PAINT.bits,
const CONTENT = LAYOUT.bits | STYLE.bits | PAINT.bits,
const STRICT = 0x10,
const STRICT_BITS = SIZE.bits | LAYOUT.bits | STYLE.bits | PAINT.bits,
const CONTENT = 0x20,
const CONTENT_BITS = LAYOUT.bits | STYLE.bits | PAINT.bits,
}
}

Expand Down Expand Up @@ -2148,11 +2150,11 @@ ${helpers.single_keyword("transform-style",
return Ok(result)
}
if input.try(|input| input.expect_ident_matching("strict")).is_ok() {
result.insert(STRICT);
result.insert(STRICT | STRICT_BITS);
return Ok(result)
}
if input.try(|input| input.expect_ident_matching("content")).is_ok() {
result.insert(CONTENT);
result.insert(CONTENT | CONTENT_BITS);
return Ok(result)
}

Expand Down
12 changes: 11 additions & 1 deletion tests/unit/style/parsing/containment.rs
Expand Up @@ -3,6 +3,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

use parsing::parse;
use style_traits::ToCss;

#[test]
fn contain_longhand_should_parse_correctly() {
Expand All @@ -13,11 +14,20 @@ fn contain_longhand_should_parse_correctly() {
assert_eq!(none, SpecifiedValue::empty());

let strict = parse_longhand!(contain, "strict");
assert_eq!(strict, contain::STRICT);
assert_eq!(strict, contain::STRICT | contain::STRICT_BITS);

let strict = parse_longhand!(contain, "content");
assert_eq!(strict, contain::CONTENT | contain::CONTENT_BITS);

let style_paint = parse_longhand!(contain, "style paint");
assert_eq!(style_paint, contain::STYLE | contain::PAINT);

assert_roundtrip_with_context!(contain::parse, "strict");
assert_roundtrip_with_context!(contain::parse, "size layout style paint");

assert_roundtrip_with_context!(contain::parse, "content");
assert_roundtrip_with_context!(contain::parse, "layout style paint");

// Assert that the `2px` is not consumed, which would trigger parsing failure in real use
assert_parser_exhausted!(contain::parse, "layout 2px", false);
}

0 comments on commit 05a4feb

Please sign in to comment.