servo: Merge #19692 - style: Make Contain::parse simpler (from stevel98:Contain); r=emilio
authorlizhixun <lizhixun@berkeley.edu>
Thu, 04 Jan 2018 19:52:44 -0600
changeset 449649 26c6c1e829af3e0d659d4a3297991a181f2fe647
parent 449648 1f394da377b0250c21506645b5535dc4a8e7cdf0
child 449650 963c2542a81502c45164d44d39af4eefd4eedd97
push id8527
push userCallek@gmail.com
push dateThu, 11 Jan 2018 21:05:50 +0000
treeherdermozilla-beta@95342d212a7a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersemilio
milestone59.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
servo: Merge #19692 - style: Make Contain::parse simpler (from stevel98:Contain); r=emilio <!-- Please describe your changes on the following line: --> --- Makes Contain::parse slightly simpler, as discussed in #19682 - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix #19682 (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [X] These changes do not require tests because refactoring Source-Repo: https://github.com/servo/servo Source-Revision: 0393f9d231ce146761ed6b6b635ac040adfb07f3
servo/components/style/values/specified/box.rs
--- a/servo/components/style/values/specified/box.rs
+++ b/servo/components/style/values/specified/box.rs
@@ -548,28 +548,18 @@ impl Parse for Contain {
         input: &mut Parser<'i, 't>
     ) -> Result<Contain, ParseError<'i>> {
         let mut result = Contain::empty();
         while let Ok(name) = input.try(|i| i.expect_ident_cloned()) {
             let flag = match_ignore_ascii_case! { &name,
                 "layout" => Some(Contain::LAYOUT),
                 "style" => Some(Contain::STYLE),
                 "paint" => Some(Contain::PAINT),
-                "strict" => {
-                    if result.is_empty() {
-                        return Ok(Contain::STRICT | Contain::STRICT_BITS)
-                    }
-                    None
-                },
-                "none" => {
-                    if result.is_empty() {
-                        return Ok(result)
-                    }
-                    None
-                },
+                "strict" if result.is_empty() => return Ok(Contain::STRICT | Contain::STRICT_BITS),
+                "none" if result.is_empty() => return Ok(result),
                 _ => None
             };
 
             let flag = match flag {
                 Some(flag) if !result.contains(flag) => flag,
                 _ => return Err(input.new_custom_error(SelectorParseErrorKind::UnexpectedIdent(name)))
             };
             result.insert(flag);