mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Add iterators for vector types
MozReview-Commit-ID: I7oOpYhVP5S
This commit is contained in:
parent
36f26148e6
commit
c85aae4abd
3 changed files with 43 additions and 3 deletions
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue