aboutsummaryrefslogtreecommitdiffstats
path: root/components/style/properties/helpers.mako.rs
diff options
context:
space:
mode:
authorManish Goregaokar <manishearth@gmail.com>2017-05-02 21:58:21 -0700
committerManish Goregaokar <manishsmail@gmail.com>2017-05-04 07:15:16 -0700
commitc85aae4abd4d90641c474ff6100d409d6fb5ca41 (patch)
tree9861b21b54701672b5c409a6457cfe1764924331 /components/style/properties/helpers.mako.rs
parent36f26148e6f3decfac7858455c3170d7bf7d8b3f (diff)
downloadservo-c85aae4abd4d90641c474ff6100d409d6fb5ca41.tar.gz
servo-c85aae4abd4d90641c474ff6100d409d6fb5ca41.zip
Add iterators for vector types
MozReview-Commit-ID: I7oOpYhVP5S
Diffstat (limited to 'components/style/properties/helpers.mako.rs')
-rw-r--r--components/style/properties/helpers.mako.rs14
1 files changed, 12 insertions, 2 deletions
diff --git a/components/style/properties/helpers.mako.rs b/components/style/properties/helpers.mako.rs
index b69057f916c..65478210d4e 100644
--- a/components/style/properties/helpers.mako.rs
+++ b/components/style/properties/helpers.mako.rs
@@ -74,7 +74,7 @@
</%doc>
<%def name="vector_longhand(name, gecko_only=False, allow_empty=False,
delegate_animate=False, space_separated_allowed=False, **kwargs)">
- <%call expr="longhand(name, **kwargs)">
+ <%call expr="longhand(name, vector=True, **kwargs)">
% if not gecko_only:
use smallvec::SmallVec;
use std::fmt;
@@ -103,6 +103,8 @@
pub use super::single_value::computed_value as single_value;
pub use self::single_value::T as SingleComputedValue;
use smallvec::SmallVec;
+ use values::computed::ComputedVecIter;
+
/// The computed value, effectively a list of single values.
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
@@ -129,6 +131,8 @@
}
}
% endif
+
+ pub type Iter<'a, 'cx, 'cx_a> = ComputedVecIter<'a, 'cx, 'cx_a, super::single_value::SpecifiedValue>;
}
impl ToCss for computed_value::T {
@@ -212,12 +216,18 @@
pub use self::single_value::SpecifiedValue as SingleSpecifiedValue;
+ impl SpecifiedValue {
+ pub fn compute_iter<'a, 'cx, 'cx_a>(&'a self, context: &'cx Context<'cx_a>) -> computed_value::Iter<'a, 'cx, 'cx_a> {
+ computed_value::Iter::new(context, &self.0)
+ }
+ }
+
impl ToComputedValue for SpecifiedValue {
type ComputedValue = computed_value::T;
#[inline]
fn to_computed_value(&self, context: &Context) -> computed_value::T {
- computed_value::T(self.0.iter().map(|x| x.to_computed_value(context)).collect())
+ computed_value::T(self.compute_iter(context).collect())
}
#[inline]
fn from_computed_value(computed: &computed_value::T) -> Self {