From d90ff1801a5d13ec47a087aef56fc2ee29089678 Mon Sep 17 00:00:00 2001 From: Cameron McCormack Date: Sat, 12 Aug 2017 17:38:06 +0800 Subject: [PATCH] style: Fix origin iteration order. --- components/style/stylesheets/origin.rs | 32 +++++++++++++------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/components/style/stylesheets/origin.rs b/components/style/stylesheets/origin.rs index a9a31bfe124..7ca3e21fcbe 100644 --- a/components/style/stylesheets/origin.rs +++ b/components/style/stylesheets/origin.rs @@ -16,11 +16,11 @@ pub enum Origin { /// https://drafts.csswg.org/css-cascade/#cascade-origin-us UserAgent, - /// https://drafts.csswg.org/css-cascade/#cascade-origin-author - Author, - /// https://drafts.csswg.org/css-cascade/#cascade-origin-user User, + + /// https://drafts.csswg.org/css-cascade/#cascade-origin-author + Author, } /// An object that stores a `T` for each origin of the CSS cascade. @@ -30,11 +30,11 @@ pub struct PerOrigin { /// Data for `Origin::UserAgent`. pub user_agent: T, - /// Data for `Origin::Author`. - pub author: T, - /// Data for `Origin::User`. pub user: T, + + /// Data for `Origin::Author`. + pub author: T, } impl PerOrigin { @@ -43,8 +43,8 @@ impl PerOrigin { pub fn borrow_for_origin(&self, origin: &Origin) -> &T { match *origin { Origin::UserAgent => &self.user_agent, - Origin::Author => &self.author, Origin::User => &self.user, + Origin::Author => &self.author, } } @@ -54,13 +54,13 @@ impl PerOrigin { pub fn borrow_mut_for_origin(&mut self, origin: &Origin) -> &mut T { match *origin { Origin::UserAgent => &mut self.user_agent, - Origin::Author => &mut self.author, Origin::User => &mut self.user, + Origin::Author => &mut self.author, } } /// Iterates over references to per-origin extra style data, from highest - /// level (user) to lowest (user agent). + /// level (author) to lowest (user agent). pub fn iter_origins(&self) -> PerOriginIter { PerOriginIter { data: &self, @@ -69,7 +69,7 @@ impl PerOrigin { } /// Iterates over mutable references to per-origin extra style data, from - /// highest level (user) to lowest (user agent). + /// highest level (author) to lowest (user agent). pub fn iter_mut_origins(&mut self) -> PerOriginIterMut { PerOriginIterMut { data: self, @@ -88,12 +88,12 @@ pub trait PerOriginClear { impl PerOriginClear for PerOrigin where T: PerOriginClear { fn clear(&mut self) { self.user_agent.clear(); - self.author.clear(); self.user.clear(); + self.author.clear(); } } -/// Iterator over `PerOrigin`, from highest level (user) to lowest +/// Iterator over `PerOrigin`, from highest level (author) to lowest /// (user agent). /// /// We rely on this specific order for correctly looking up @font-face, @@ -108,8 +108,8 @@ impl<'a, T> Iterator for PerOriginIter<'a, T> where T: 'a { fn next(&mut self) -> Option { let result = match self.cur { - 0 => (&self.data.user, Origin::User), - 1 => (&self.data.author, Origin::Author), + 0 => (&self.data.author, Origin::Author), + 1 => (&self.data.user, Origin::User), 2 => (&self.data.user_agent, Origin::UserAgent), _ => return None, }; @@ -135,8 +135,8 @@ impl<'a, T> Iterator for PerOriginIterMut<'a, T> where T: 'a { fn next(&mut self) -> Option { let result = match self.cur { - 0 => (unsafe { transmute(&mut (*self.data).user) }, Origin::User), - 1 => (unsafe { transmute(&mut (*self.data).author) }, Origin::Author), + 0 => (unsafe { transmute(&mut (*self.data).author) }, Origin::Author), + 1 => (unsafe { transmute(&mut (*self.data).user) }, Origin::User), 2 => (unsafe { transmute(&mut (*self.data).user_agent) }, Origin::UserAgent), _ => return None, };