From 72497330a9cb97ba19360d959125deffda980c9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Thu, 5 Oct 2017 13:56:07 +0200 Subject: [PATCH] style: Iterate in the expected order in the custom_properties module. In #18745, I replaced a few manual iterations over `index` with the iterator, and it changed the behavior of `layout/style/test/test_variables_order.html`, since it turns out that the iterator iterates right to left. I think this is just an accident that happened due to inconsistencies in how we were iterating over it, and that our behavior was inconsistent (since we iterated rtl in some cases, but ltr in others seems like it'd be inconsistent depending on the depth of the tree and different stuff). This brings back the expected behavior again, and ensures we iterate over a consistent order every time. --- components/style/custom_properties.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/components/style/custom_properties.rs b/components/style/custom_properties.rs index 7a1302b4644..8351248a388 100644 --- a/components/style/custom_properties.rs +++ b/components/style/custom_properties.rs @@ -190,14 +190,14 @@ where type Item = (&'a K, &'a V); fn next(&mut self) -> Option { - let ref index = self.inner.index; - if self.pos >= index.len() { - return None; - } + let key = match self.inner.index.get(self.pos) { + Some(k) => k, + None => return None, + }; - let ref key = index[index.len() - self.pos - 1]; self.pos += 1; let value = &self.inner.values[key]; + Some((key, value)) } }