Repository navigation
style: Move grid-template-areas outside of mako - #19412
Conversation
|
Heads up! This PR modifies the following files:
|
emilio
left a comment
There was a problem hiding this comment.
Code wise looks good, but now that mako is no longer, we can do some cleanup to.
I wonder if we should refcount this given that this is effectively SpecifiedValueAsComputed, and contains a bunch of allocated stuff... Can you leave a FIXME or open an issue for that?
It'd be a matter of making:
pub type GridTemplateAreas = Either<TemplateAreas, None_>; Become:
pub type GridTemplateAreas = Either<Arc<TemplateAreas>, None_>;
|
|
||
| impl TemplateAreas { | ||
| /// Transform `vector` of str into single `template area` | ||
| pub fn from_vec(strings: Vec<Box<str>>) -> Result<TemplateAreas, ()> { |
There was a problem hiding this comment.
I found it's used in shorthand mako so maybe we still need it as a pub method?
|
|
||
| /// Tokenize the string into a list of the tokens, | ||
| /// using longest-match semantics | ||
| struct Tokenizer<'a>(&'a str); |
There was a problem hiding this comment.
This name is super-generic, let's rename this to TemplateAreasTokenizer or something like it?
There was a problem hiding this comment.
Yes, it's better to name it with TemplateAreas prefix.
| struct Tokenizer<'a>(&'a str); | ||
|
|
||
| impl<'a> Iterator for Tokenizer<'a> { | ||
| type Item = Result<Option<(&'a str)>, ()>; |
There was a problem hiding this comment.
nit: Just Result<Option<&'a str>, ()>.
| let mut width = 0; | ||
| { | ||
| let mut row = 0u32; | ||
| let mut area_indices = FnvHashMap::<(&str), usize>::default(); |
There was a problem hiding this comment.
Ditto, no need for (&str), just &str.
| } | ||
| if let Some(index) = current_area_index { | ||
| if areas[index].columns.end != column + 1 { | ||
| assert!(areas[index].rows.start != row); |
|
|
||
| #[cfg_attr(feature = "gecko", derive(MallocSizeOf))] | ||
| #[derive(Clone, Debug, PartialEq)] | ||
| /// Single template area |
There was a problem hiding this comment.
Hmm, this is not a single area, right? Also, this would probably benefit from a spec link
There was a problem hiding this comment.
Hmm, yeah, it's not real single but belongs to each grid-template-areas; thus, that's why I documented it with Single.
But I think you're right, this wording might have misleading.
Just let me document it with the spec link! Thanks!
| pub areas: Box<[NamedArea]>, | ||
| /// The original CSS string value of each single template area | ||
| pub strings: Box<[Box<str>]>, | ||
| /// width of each single template area |
There was a problem hiding this comment.
This should be The number of columns of the grid.
| #[derive(Clone, Debug, PartialEq)] | ||
| /// Single template area | ||
| pub struct TemplateAreas { | ||
| /// `named area` containing for each single template area |
There was a problem hiding this comment.
I'm not sure what "named area containing" is supposed to mean... @nox, you implemented this, any nice idea about how to document this?
There was a problem hiding this comment.
Hmm... after reading the spec, I think this attribute means each NamedArea parsed from the strings.
Maybe this comment is not good for documentation.
Please teach me how to make it better! 😄
d592bed to
003ddfc
Compare
|
@emilio In case |
|
@bors-servo r+ |
|
📌 Commit 003ddfc has been approved by |
style: Move grid-template-areas outside of mako This is a sub-PR of #19015 r? emilio --- - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #19409 - [x] These changes do not require tests <!-- 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/19412) <!-- Reviewable:end -->
|
☀️ Test successful - android, arm32, arm64, linux-dev, linux-rel-css, linux-rel-wpt, mac-dev-unit, mac-rel-css1, mac-rel-css2, mac-rel-wpt1, mac-rel-wpt2, mac-rel-wpt3, mac-rel-wpt4, windows-msvc-dev |
This is a sub-PR of #19015
r? emilio
./mach build -ddoes not report any errors./mach test-tidydoes not report any errorsThis change is