New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
stylo: store specified value of grid layout repeat() function #18206
Merged
bors-servo
merged 1 commit into
servo:master
from
ferjm:bug1382369.grid.repeat.function
Sep 11, 2017
+158
−78
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.
| @@ -394,45 +394,27 @@ pub struct TrackRepeat<L> { | ||
|
|
||
| impl<L: ToCss> ToCss for TrackRepeat<L> { | ||
| fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write { | ||
| // If repeat count is an integer instead of a keyword, it should'n serialized | ||
| // with `repeat` function. It should serialized with `N` repeated form. | ||
| let repeat_count = match self.count { | ||
| RepeatCount::Number(integer) => integer.value(), | ||
| _ => { | ||
| dest.write_str("repeat(")?; | ||
| self.count.to_css(dest)?; | ||
| dest.write_str(", ")?; | ||
| 1 | ||
| }, | ||
| }; | ||
|
|
||
| for i in 0..repeat_count { | ||
| if i != 0 { | ||
| dest.write_str("repeat(")?; | ||
| self.count.to_css(dest)?; | ||
| dest.write_str(", ")?; | ||
|
|
||
| let mut line_names_iter = self.line_names.iter(); | ||
| for (i, (ref size, ref names)) in self.track_sizes.iter() | ||
| .zip(&mut line_names_iter).enumerate() { | ||
| if i > 0 { | ||
| dest.write_str(" ")?; | ||
| } | ||
|
|
||
| let mut line_names_iter = self.line_names.iter(); | ||
| 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)?; | ||
| } | ||
| concat_serialize_idents("[", "] ", names, " ", dest)?; | ||
| size.to_css(dest)?; | ||
| } | ||
|
|
||
| match self.count { | ||
| RepeatCount::AutoFill | RepeatCount::AutoFit => { | ||
| dest.write_str(")")?; | ||
| }, | ||
| _ => {}, | ||
| if let Some(line_names_last) = line_names_iter.next() { | ||
| concat_serialize_idents(" [", "]", line_names_last, " ", dest)?; | ||
| } | ||
|
|
||
| dest.write_str(")")?; | ||
|
|
||
| Ok(()) | ||
| } | ||
| } | ||
| @@ -475,6 +457,16 @@ impl<L: Clone> TrackRepeat<L> { | ||
| } | ||
| } | ||
|
|
||
| /// Track list values. Can be <track-size> or <track-repeat> | ||
| #[derive(Clone, Debug, PartialEq, ToComputedValue, ToCss)] | ||
| #[cfg_attr(feature = "servo", derive(HeapSizeOf))] | ||
| pub enum TrackListValue<T> { | ||
ferjm
Author
Member
|
||
| /// A <track-size> value. | ||
| TrackSize(TrackSize<T>), | ||
| /// A <track-repeat> value. | ||
| TrackRepeat(TrackRepeat<T>), | ||
| } | ||
|
|
||
| /// The type of a `<track-list>` as determined during parsing. | ||
| /// | ||
| /// https://drafts.csswg.org/css-grid/#typedef-track-list | ||
| @@ -504,21 +496,20 @@ impl ComputedValueAsSpecified for TrackListType {} | ||
| /// | ||
| /// https://drafts.csswg.org/css-grid/#typedef-track-list | ||
| #[cfg_attr(feature = "servo", derive(HeapSizeOf))] | ||
| #[derive(Clone, Debug, PartialEq, ToComputedValue)] | ||
| #[derive(Clone, Debug, PartialEq)] | ||
| pub struct TrackList<T> { | ||
| /// The type of this `<track-list>` (auto, explicit or general). | ||
| /// | ||
| /// In order to avoid parsing the same value multiple times, this does a single traversal | ||
| /// and arrives at the type of value it has parsed (or bails out gracefully with an error). | ||
| pub list_type: TrackListType, | ||
| /// A vector of `<track-size>` values. | ||
| pub values: Vec<TrackSize<T>>, | ||
| /// A vector of `<track-size> | <track-repeat>` values. | ||
| pub values: Vec<TrackListValue<T>>, | ||
| /// `<line-names>` accompanying `<track-size> | <track-repeat>` values. | ||
| /// | ||
| /// If there's no `<line-names>`, then it's represented by an empty vector. | ||
| /// For N values, there will be N+1 `<line-names>`, and so this vector's | ||
| /// length is always one value more than that of the `<track-size>`. | ||
| #[compute(clone)] | ||
| pub line_names: Box<[Box<[CustomIdent]>]>, | ||
| /// `<auto-repeat>` value. There can only be one `<auto-repeat>` in a TrackList. | ||
| pub auto_repeat: Option<TrackRepeat<T>>, | ||
Oops, something went wrong.
ProTip!
Use n and p to navigate between commits in a pull request.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
We could use😄
Eitherhere - not sure whether it's particularly useful, but that's what I did on 26540df