Auto merge of #18206 - ferjm:bug1382369.grid.repeat.function, r=wafflespeanut

stylo: store specified value of grid layout repeat() function

- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix [Bug 1382369](https://bugzilla.mozilla.org/show_bug.cgi?id=1382369)

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/18206)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2017-09-11 02:32:38 -05:00 committed by GitHub
commit 8129cf5563
5 changed files with 157 additions and 77 deletions

View file

@ -1895,7 +1895,7 @@ fn static_assert() {
use nsstring::nsStringRepr;
use values::CustomIdent;
use values::generics::grid::{GridTemplateComponent, LineNameList, RepeatCount};
use values::generics::grid::{TrackList, TrackListType, TrackRepeat, TrackSize};
use values::generics::grid::{TrackList, TrackListType, TrackListValue, TrackRepeat, TrackSize};
let value = match unsafe { ${self_grid}.mPtr.as_ref() } {
None => return GridTemplateComponent::None,
@ -1965,7 +1965,7 @@ fn static_assert() {
auto_repeat = Some(TrackRepeat{count, line_names, track_sizes});
} else {
values.push(track_size);
values.push(TrackListValue::TrackSize(track_size));
}
}

View file

@ -243,7 +243,8 @@
use parser::Parse;
use properties::longhands::grid_template_areas::TemplateAreas;
use values::{Either, None_};
use values::generics::grid::{LineNameList, TrackSize, TrackList, TrackListType, concat_serialize_idents};
use values::generics::grid::{LineNameList, TrackSize, TrackList, TrackListType};
use values::generics::grid::{TrackListValue, concat_serialize_idents};
use values::specified::{GridTemplateComponent, GenericGridTemplateComponent};
use values::specified::grid::parse_line_names;
@ -287,7 +288,7 @@
line_names.push(names.into_boxed_slice());
strings.push(string);
let size = input.try(|i| TrackSize::parse(context, i)).unwrap_or_default();
values.push(size);
values.push(TrackListValue::TrackSize(size));
names = input.try(parse_line_names).unwrap_or(vec![].into_boxed_slice()).into_vec();
if let Ok(v) = input.try(parse_line_names) {
names.extend(v.into_vec());
@ -380,7 +381,11 @@
GenericGridTemplateComponent::TrackList(ref list) => {
// We should fail if there is a `repeat` function. `grid` and
// `grid-template` shorthands doesn't accept that. Only longhand accepts.
if list.auto_repeat.is_some() {
if list.auto_repeat.is_some() ||
list.values.iter().any(|v| match *v {
TrackListValue::TrackRepeat(_) => true,
_ => false,
}) {
return Ok(());
}
list
@ -395,8 +400,14 @@
match *template_columns {
// We should fail if there is a `repeat` function. `grid` and
// `grid-template` shorthands doesn't accept that. Only longhand accepts that.
GenericGridTemplateComponent::TrackList(ref list) if list.auto_repeat.is_some() => {
return Ok(());
GenericGridTemplateComponent::TrackList(ref list) => {
if list.auto_repeat.is_some() ||
list.values.iter().any(|v| match *v {
TrackListValue::TrackRepeat(_) => true,
_ => false,
}) {
return Ok(());
}
},
// Also the shorthands don't accept subgrids unlike longhand.
// We should fail without an error here.
@ -407,9 +418,9 @@
}
let mut names_iter = track_list.line_names.iter();
for (((i, string), names), size) in areas.strings.iter().enumerate()
.zip(&mut names_iter)
.zip(track_list.values.iter()) {
for (((i, string), names), value) in areas.strings.iter().enumerate()
.zip(&mut names_iter)
.zip(track_list.values.iter()) {
if i > 0 {
dest.write_str(" ")?;
}
@ -420,7 +431,7 @@
string.to_css(dest)?;
dest.write_str(" ")?;
size.to_css(dest)?;
value.to_css(dest)?;
}
if let Some(names) = names_iter.next() {