Skip to content

style: Move grid-template-areas outside of mako - #19412

Merged
bors-servo merged 1 commit into
servo:masterfrom
CYBAI:grid-template-areas-out-of-mako
Nov 29, 2017
Merged

bors-servo merged 1 commit into
servo:masterfrom
CYBAI:grid-template-areas-out-of-mako

Conversation

@CYBAI

@CYBAI CYBAI commented Nov 28, 2017 •

Copy link
Copy Markdown
Member

This is a sub-PR of #19015
r? emilio



This change is Reviewable

@highfive

Copy link
Copy Markdown

Heads up! This PR modifies the following files:

  • @bholley: components/style/properties/gecko.mako.rs, components/style/values/specified/mod.rs, components/style/values/computed/position.rs, components/style/values/computed/mod.rs, components/style/properties/shorthand/position.mako.rs and 2 more
  • @canaltinova: components/style/properties/gecko.mako.rs, components/style/values/specified/mod.rs, components/style/values/computed/position.rs, components/style/values/computed/mod.rs, components/style/properties/shorthand/position.mako.rs and 2 more
  • @emilio: components/style/properties/gecko.mako.rs, components/style/values/specified/mod.rs, components/style/values/computed/position.rs, components/style/values/computed/mod.rs, components/style/properties/shorthand/position.mako.rs and 2 more

@highfive highfive added the S-awaiting-review There is new code that needs to be reviewed. label Nov 28, 2017
@highfive

Copy link
Copy Markdown

warning Warning warning

  • These commits modify style code, but no tests are modified. Please consider adding a test!

@emilio emilio left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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, ()> {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: no need to be pub.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the catching!

@CYBAI CYBAI Nov 29, 2017 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found it's used in shorthand mako so maybe we still need it as a pub method?

let template_areas = TemplateAreas::from_vec(strings)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, indeed, nvm then :)


/// Tokenize the string into a list of the tokens,
/// using longest-match semantics
struct Tokenizer<'a>(&'a str);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This name is super-generic, let's rename this to TemplateAreasTokenizer or something like it?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)>, ()>;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Just Result<Option<&'a str>, ()>.

let mut width = 0;
{
let mut row = 0u32;
let mut area_indices = FnvHashMap::<(&str), usize>::default();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: assert_ne!.


#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
#[derive(Clone, Debug, PartialEq)]
/// Single template area

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, this is not a single area, right? Also, this would probably benefit from a spec link

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what "named area containing" is supposed to mean... @nox, you implemented this, any nice idea about how to document this?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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! 😄

@CYBAI
CYBAI force-pushed the grid-template-areas-out-of-mako branch from d592bed to 003ddfc Compare November 29, 2017 14:42
@CYBAI

CYBAI commented Nov 29, 2017

Copy link
Copy Markdown
Member Author

@emilio In case single making misleading to other contributors, I removed the single keyword in other documentation comment. Besides, please let me create an issue for refcounting improvement after this PR merged. Thanks!

@emilio

emilio commented Nov 29, 2017

Copy link
Copy Markdown
Member

@bors-servo r+

@bors-servo

Copy link
Copy Markdown
Contributor

📌 Commit 003ddfc has been approved by emilio

@highfive highfive added S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. and removed S-awaiting-review There is new code that needs to be reviewed. labels Nov 29, 2017
@bors-servo

Copy link
Copy Markdown
Contributor

⌛ Testing commit 003ddfc with merge fa3f389...

bors-servo pushed a commit that referenced this pull request Nov 29, 2017
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 -->
@bors-servo

Copy link
Copy Markdown
Contributor

☀️ 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
Approved by: emilio
Pushing fa3f389 to master...

@bors-servo
bors-servo merged commit 003ddfc into servo:master Nov 29, 2017
@highfive highfive removed the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Nov 29, 2017
@CYBAI
CYBAI deleted the grid-template-areas-out-of-mako branch November 30, 2017 01:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Move grid-template-areas outside of mako.

4 participants