Skip to content
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

Add keyword "auto" to flexbox min-size property #14332

Closed
wants to merge 3 commits into from

Conversation

@shinglyu
Copy link
Member

shinglyu commented Nov 23, 2016

This is the first patch for #12610, the algorithm itself took longer than I expected, so I'm landing this foundational work first.

This adds a new initial value auto to the min-width and min-height specified on a flexitem. It also provides a fallback of "0px" if we try to get the min-width/height on a non-flexitem box using getComputedStyle.

The auto resolution algorithm is not ready yet, so we fall back to 0px during layout.

r?@stshine


  • ./mach build -d does not report any errors
  • ./mach test-tidy does not report any errors
  • These changes fix #__ (github issue number if applicable).
  • There are tests for these changes OR
  • These changes do not require tests because _____

This change is Reviewable

Copy link
Contributor

stshine left a comment

Generally this looks good to me, but need some changes.
Disclaimer: I do not have the right to approve this pull request, just give out some suggestions.

LengthOrPercentageOrAuto::Auto => Au(0),
}
}

This comment has been minimized.

Copy link
@stshine

stshine Nov 23, 2016

Contributor

This function is unnessasary, and its name is quite confusing, hinting that it will return a MaybeAuto type. Use MaybeAuto::from_style().specified_or_zero() should be enough.

computed::LengthOrPercentageOrAuto::Length(Au(0))
);
}
% endfor

This comment has been minimized.

Copy link
@stshine

stshine Nov 23, 2016

Contributor

I can not understand why we need this. I assume that you are going to change specified_or_auto() later? But use MaybeAuto::from_style().specified_or_zero() should provide us enough flexibility.

This comment has been minimized.

Copy link
@stshine

stshine Nov 23, 2016

Contributor

Just found that for non-flex items the computed value of min-width should be 0px if not specified, never mind.

This comment has been minimized.

Copy link
@shinglyu

shinglyu Nov 25, 2016

Author Member

Yes, I also added a wpt test for that. But I'm not sure if I put it in the correct location.

This comment has been minimized.

Copy link
@stshine

stshine Nov 25, 2016

Contributor

:) It is ok to put css tests there because they can not be easily upstreamed.

@stshine
Copy link
Contributor

stshine commented Nov 23, 2016

cc @SimonSapin for the style part changes.

@SimonSapin SimonSapin self-assigned this Nov 27, 2016
@SimonSapin
Copy link
Member

SimonSapin commented Nov 28, 2016

Reviewed 8 of 8 files at r1, 1 of 1 files at r2, 2 of 2 files at r3.
Review status: all files reviewed at latest revision, 3 unresolved discussions, some commit checks failed.


components/layout/model.rs, line 460 at r3 (raw file):

Previously, stshine wrote…

This function is unnessasary, and its name is quite confusing, hinting that it will return a MaybeAuto type. Use MaybeAuto::from_style().specified_or_zero() should be enough.

I agree that the name should indicate that 'auto' is treated as zero.


components/style/properties/properties.mako.rs, line 1706 at r2 (raw file):
This is more specific than flex items:

https://drafts.csswg.org/css-flexbox/#valdef-min-width-auto

On a flex item whose overflow is visible in the main axis, when specified on the flex item’s main-axis min-size property


Comments from Reviewable

@bors-servo
Copy link
Contributor

bors-servo commented Dec 12, 2016

The latest upstream changes (presumably #14490) made this pull request unmergeable. Please resolve the merge conflicts.

@shinglyu
Copy link
Member Author

shinglyu commented Dec 21, 2016

Based on the new comment, it's non-trivial to determine if an element is a flex item, so I need some other way around this:

    // FIXME(heycam): We should look past any display:contents ancestors to
    // determine if we are a flex or grid item, but we don't have access to
    // grandparent or higher style here.
@stshine
Copy link
Contributor

stshine commented Dec 21, 2016

IMO we currently do not support display: contents in servo, so maybe you do not need to worry about it too much since the quoted spec is for layout.

@SimonSapin
Copy link
Member

SimonSapin commented Dec 21, 2016

But Firefox does support display: contents, and therefore Stylo will need it.

In terms of threading / parallel tree traversal, the styling of ancestors is finished by the time we style an element. It should be possible to make this available to the cascading code.

@emilio
Copy link
Member

emilio commented Jan 17, 2017

Yeah, this will need to look up (or have some kind of hint from the parent). It's not problematic for now though, and you can ignore that until we implement display contents for stylo.

@jdm
Copy link
Member

jdm commented Jan 27, 2017

What's the next step here? Who's responsible for it?

@SimonSapin
Copy link
Member

SimonSapin commented Jan 28, 2017

I’ve requested code changes from @shinglyu, the most significant one being checking not just for flex items but also "whose overflow is visible [etc.]" #14332 (comment)

@shinglyu
Copy link
Member Author

shinglyu commented Jan 28, 2017

@nox
Copy link
Member

nox commented Mar 3, 2017

@shinglyu Status?

@shinglyu
Copy link
Member Author

shinglyu commented Mar 6, 2017

I'm fully occupied by Stylo right now. Maybe need to postpone this for a while. If anyone is interested to take over please go ahead.

@stshine
Copy link
Contributor

stshine commented Mar 13, 2017

@shinglyu I would like to finish this if you do not have time.

@emilio
Copy link
Member

emilio commented Mar 13, 2017

That'd be awesome @stshine! :)

@stshine
Copy link
Contributor

stshine commented Mar 13, 2017

@emilio I'll take a look at the stylo implemention first :)

bors-servo added a commit that referenced this pull request Mar 15, 2017
style: Support "auto" keyword on min-{width, height} properties

<!-- Please describe your changes on the following line: -->
Based on the work of #14332 .

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [ ] These changes fix #__ (github issue number if applicable).

<!-- Either: -->
- [X] There are tests for these changes OR
- [ ] These changes do not require tests because _____

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- 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/15969)
<!-- Reviewable:end -->
bors-servo added a commit that referenced this pull request Mar 15, 2017
style: Support "auto" keyword on min-{width, height} properties

<!-- Please describe your changes on the following line: -->
Based on the work of #14332 .

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [ ] These changes fix #__ (github issue number if applicable).

<!-- Either: -->
- [X] There are tests for these changes OR
- [ ] These changes do not require tests because _____

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- 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/15969)
<!-- Reviewable:end -->
bors-servo added a commit that referenced this pull request Mar 15, 2017
style: Support "auto" keyword on min-{width, height} properties

<!-- Please describe your changes on the following line: -->
Based on the work of #14332 .

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [ ] These changes fix #__ (github issue number if applicable).

<!-- Either: -->
- [X] There are tests for these changes OR
- [ ] These changes do not require tests because _____

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- 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/15969)
<!-- Reviewable:end -->
@nox nox closed this Mar 24, 2017
@nox nox reopened this Mar 24, 2017
bors-servo added a commit that referenced this pull request May 1, 2017
style: Support "auto" keyword on min-{width, height} properties

<!-- Please describe your changes on the following line: -->
Based on the work of #14332 .

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [ ] These changes fix #__ (github issue number if applicable).

<!-- Either: -->
- [X] There are tests for these changes OR
- [ ] These changes do not require tests because _____

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- 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/15969)
<!-- Reviewable:end -->
bors-servo added a commit that referenced this pull request May 1, 2017
style: Support "auto" keyword on min-{width, height} properties

<!-- Please describe your changes on the following line: -->
Based on the work of #14332 .

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [ ] These changes fix #__ (github issue number if applicable).

<!-- Either: -->
- [X] There are tests for these changes OR
- [ ] These changes do not require tests because _____

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- 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/15969)
<!-- Reviewable:end -->
bors-servo added a commit that referenced this pull request May 1, 2017
style: Support "auto" keyword on min-{width, height} properties

<!-- Please describe your changes on the following line: -->
Based on the work of #14332 .

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [ ] These changes fix #__ (github issue number if applicable).

<!-- Either: -->
- [X] There are tests for these changes OR
- [ ] These changes do not require tests because _____

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- 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/15969)
<!-- Reviewable:end -->
bors-servo added a commit that referenced this pull request May 2, 2017
style: Support "auto" keyword on min-{width, height} properties

<!-- Please describe your changes on the following line: -->
Based on the work of #14332 .

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [ ] These changes fix #__ (github issue number if applicable).

<!-- Either: -->
- [X] There are tests for these changes OR
- [ ] These changes do not require tests because _____

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- 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/15969)
<!-- Reviewable:end -->
bors-servo added a commit that referenced this pull request May 2, 2017
style: Support "auto" keyword on min-{width, height} properties

<!-- Please describe your changes on the following line: -->
Based on the work of #14332 .

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [ ] These changes fix #__ (github issue number if applicable).

<!-- Either: -->
- [X] There are tests for these changes OR
- [ ] These changes do not require tests because _____

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- 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/15969)
<!-- Reviewable:end -->
@emilio
Copy link
Member

emilio commented Sep 5, 2017

Let's close this due to inactivity, and given it needs a huge rebase.

@emilio emilio closed this Sep 5, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

8 participants
You can’t perform that action at this time.