mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
Fix the serialization of TrackRepeat
It was printing `repeat(n, <line-names>)` for number TrackRepeat. But it should just print n times <line-names> instead. MozReview-Commit-ID: FEmL8O2osVb
This commit is contained in:
parent
9d9d99ec25
commit
5eb33bac8f
1 changed files with 32 additions and 13 deletions
|
@ -380,26 +380,45 @@ pub struct TrackRepeat<L> {
|
||||||
|
|
||||||
impl<L: ToCss> ToCss for TrackRepeat<L> {
|
impl<L: ToCss> ToCss for TrackRepeat<L> {
|
||||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||||
dest.write_str("repeat(")?;
|
// If repeat count is an integer instead of a keyword, it should'n serialized
|
||||||
self.count.to_css(dest)?;
|
// with `repeat` function. It should serialized with `N` repeated form.
|
||||||
dest.write_str(", ")?;
|
let repeat_count = match self.count {
|
||||||
|
RepeatCount::Number(integer) => integer.value(),
|
||||||
|
_ => {
|
||||||
|
dest.write_str("repeat(")?;
|
||||||
|
self.count.to_css(dest)?;
|
||||||
|
dest.write_str(", ")?;
|
||||||
|
1
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
let mut line_names_iter = self.line_names.iter();
|
for i in 0..repeat_count {
|
||||||
for (i, (ref size, ref names)) in self.track_sizes.iter()
|
if i != 0 {
|
||||||
.zip(&mut line_names_iter).enumerate() {
|
|
||||||
if i > 0 {
|
|
||||||
dest.write_str(" ")?;
|
dest.write_str(" ")?;
|
||||||
}
|
}
|
||||||
|
|
||||||
concat_serialize_idents("[", "] ", names, " ", dest)?;
|
let mut line_names_iter = self.line_names.iter();
|
||||||
size.to_css(dest)?;
|
for (i, (ref size, ref names)) in self.track_sizes.iter()
|
||||||
|
.zip(&mut line_names_iter).enumerate() {
|
||||||
|
if i > 0 {
|
||||||
|
dest.write_str(" ")?;
|
||||||
|
}
|
||||||
|
|
||||||
|
concat_serialize_idents("[", "] ", names, " ", dest)?;
|
||||||
|
size.to_css(dest)?;
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Some(line_names_last) = line_names_iter.next() {
|
||||||
|
concat_serialize_idents(" [", "]", line_names_last, " ", dest)?;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(line_names_last) = line_names_iter.next() {
|
match self.count {
|
||||||
concat_serialize_idents(" [", "]", line_names_last, " ", dest)?;
|
RepeatCount::AutoFill | RepeatCount::AutoFit => {
|
||||||
|
dest.write_str(")")?;
|
||||||
|
},
|
||||||
|
_ => {},
|
||||||
}
|
}
|
||||||
|
|
||||||
dest.write_str(")")?;
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue