aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEmilio Cobos Álvarez <emilio@crisal.io>2017-06-02 12:51:33 +0200
committerEmilio Cobos Álvarez <emilio@crisal.io>2017-06-02 12:51:33 +0200
commit26ef0f6178341d7155ac0d3bb2654f2f613bdee1 (patch)
tree25e473f6dbecfdbe0f8ae7b2d961a62ac00f93be
parentd6e703a9e9a5f2f71877e7895468f0c8748343c6 (diff)
downloadservo-26ef0f6178341d7155ac0d3bb2654f2f613bdee1.tar.gz
servo-26ef0f6178341d7155ac0d3bb2654f2f613bdee1.zip
style: Simplify some attr() parsing code.
-rw-r--r--components/style/values/specified/mod.rs39
1 files changed, 20 insertions, 19 deletions
diff --git a/components/style/values/specified/mod.rs b/components/style/values/specified/mod.rs
index 7eb637315d3..0131bdb5f28 100644
--- a/components/style/values/specified/mod.rs
+++ b/components/style/values/specified/mod.rs
@@ -1425,27 +1425,28 @@ impl Attr {
let first = input.try(|i| i.expect_ident()).ok();
if let Ok(token) = input.try(|i| i.next_including_whitespace()) {
match token {
- Token::Delim('|') => {
- // must be followed by an ident
- let second_token = match input.next_including_whitespace()? {
- Token::Ident(second) => second,
- _ => return Err(()),
- };
- let ns_with_id = if let Some(ns) = first {
- let ns: Namespace = ns.into();
- let id = get_id_for_namespace(&ns, context)?;
- Some((ns, id))
- } else {
- None
- };
- return Ok(Attr {
- namespace: ns_with_id,
- attribute: second_token.into_owned(),
- })
- }
- _ => return Err(())
+ Token::Delim('|') => {}
+ _ => return Err(()),
}
+ // must be followed by an ident
+ let second_token = match input.next_including_whitespace()? {
+ Token::Ident(second) => second,
+ _ => return Err(()),
+ };
+
+ let ns_with_id = if let Some(ns) = first {
+ let ns: Namespace = ns.into();
+ let id = get_id_for_namespace(&ns, context)?;
+ Some((ns, id))
+ } else {
+ None
+ };
+ return Ok(Attr {
+ namespace: ns_with_id,
+ attribute: second_token.into_owned(),
+ })
}
+
if let Some(first) = first {
Ok(Attr {
namespace: None,