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 support for keyword values for min-width and max-width #14740

Merged
merged 2 commits into from Feb 24, 2017

Conversation

Projects
None yet
8 participants
@glasserc
Copy link
Contributor

commented Dec 26, 2016

This is a follow-up to #14432 which got closed and can no longer be re-opened.

This PR aims to add support for keyword-values max-content, min-content, fit-content, and fill-available to the properties that use them, namely min-width, min-height, max-width, and max-height.

It's still untested because I still haven't figured out how to do that. I guess I should write or find some web page that uses these properties.

Refs #13821.


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

This change is Reviewable

@highfive

This comment has been minimized.

Copy link

commented Dec 26, 2016

Thanks for the pull request, and welcome! The Servo team is excited to review your changes, and you should hear from @SimonSapin (or someone else) soon.

@highfive

This comment has been minimized.

Copy link

commented Dec 26, 2016

Heads up! This PR modifies the following files:

  • @bholley: components/style/properties/gecko.mako.rs, components/style/properties/helpers/animated_properties.mako.rs, components/style/values/mod.rs, components/style/values/computed/length.rs, components/style/values/specified/mod.rs, components/style/values/computed/mod.rs, components/style/properties/longhand/position.mako.rs, components/style/values/specified/length.rs, components/style/gecko/values.rs
  • @emilio: components/style/properties/gecko.mako.rs, components/style/properties/helpers/animated_properties.mako.rs, components/style/values/mod.rs, components/style/values/computed/length.rs, components/style/values/specified/mod.rs, components/style/values/computed/mod.rs, components/style/properties/longhand/position.mako.rs, components/style/values/specified/length.rs, components/style/gecko/values.rs
@highfive

This comment has been minimized.

Copy link

commented Dec 26, 2016

warning Warning warning

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

@glasserc glasserc force-pushed the glasserc:extremum-length branch from b5d83b5 to fc4e5f6 Dec 26, 2016

@wafflespeanut

This comment has been minimized.

Copy link
Member

commented Dec 27, 2016

@glasserc Sorry, I didn't know that it couldn't be reopened. FYI, you can always ping someone in case you need help with something 😄

@bors-servo

This comment has been minimized.

Copy link
Contributor

commented Dec 27, 2016

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

@glasserc glasserc force-pushed the glasserc:extremum-length branch from fc4e5f6 to d867156 Dec 28, 2016

// min-width, min-height, min-block-size, min-inline-size
${helpers.predefined_type("min-%s" % size,
"MinLength",
"computed::MinLength::LengthOrPercentage(computed::LengthOrPercentage::Length(Au(0)))",

This comment has been minimized.

Copy link
@glasserc

glasserc Dec 28, 2016

Author Contributor

This line prevents test-tidy from passing, but I'm not sure what to do about it?

This comment has been minimized.

Copy link
@emilio

emilio Dec 28, 2016

Member

This is pretty much python code, so I guess you can split it among lines?

@bors-servo

This comment has been minimized.

Copy link
Contributor

commented Dec 31, 2016

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

@glasserc glasserc force-pushed the glasserc:extremum-length branch 2 times, most recently from cf9c0d9 to 1cad742 Jan 4, 2017

@glasserc

This comment has been minimized.

Copy link
Contributor Author

commented Jan 4, 2017

I tested this today against an example that I found and then modified. It seems to work for min-width when I tested it manually. Is it possible/encouraged to write automatic tests for something like this? The next steps otherwise are to add these keywords to max-width and max-height, and maybe even regular width and height (seems like it should be there according to https://developer.mozilla.org/en-US/docs/Web/CSS/width). Or should that be another PR?

@jdm

This comment has been minimized.

Copy link
Member

commented Jan 13, 2017

@Manishearth Can you answer the question in the last comment?

@Manishearth

This comment has been minimized.

Copy link
Member

commented Jan 13, 2017

There should already be tests for this in tests/wpt/css-tests, but if there aren't, please write your own wpt tests. Usually we make a pull request, feed it to try, and see if any test results have changed before writing our own.

You can try doing it for width and height in the same PR if you want. They support a couple more values.

@jdm jdm added S-needs-tests and removed S-awaiting-review labels Jan 13, 2017

@bors-servo

This comment has been minimized.

Copy link
Contributor

commented Jan 17, 2017

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

@Manishearth

This comment has been minimized.

Copy link
Member

commented Jan 17, 2017

Any updates?

@glasserc

This comment has been minimized.

Copy link
Contributor Author

commented Jan 18, 2017

No, I haven't had time to look at it over the holiday weekend.

@glasserc glasserc force-pushed the glasserc:extremum-length branch from 1cad742 to c2a2da4 Feb 17, 2017

@glasserc glasserc force-pushed the glasserc:extremum-length branch 2 times, most recently from 9976831 to 40ed692 Feb 17, 2017

@glasserc

This comment has been minimized.

Copy link
Contributor Author

commented Feb 17, 2017

I've added support for max-width and tested it manually. Here are some screenshots.

min-width:
screenshot from 2017-02-17 15-01-00

max-width:
screenshot from 2017-02-17 15-01-08

@glasserc glasserc changed the title WIP: Add support for keyword values for min-width, min-height, max-width, and max-height Add support for keyword values for min-width and max-width Feb 17, 2017

@bors-servo

This comment has been minimized.

Copy link
Contributor

commented Feb 20, 2017

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

@SimonSapin

This comment has been minimized.

Copy link
Member

commented Feb 22, 2017

@SimonSapin SimonSapin assigned Manishearth and unassigned SimonSapin Feb 22, 2017

@@ -18,6 +18,7 @@ use style_traits::ToCss;
use style_traits::values::specified::AllowedNumericType;
use super::{Angle, Number, SimplifiedValueNode, SimplifiedSumNode, Time};
use values::{Auto, CSSFloat, Either, FONT_MEDIUM_PX, HasViewportPercentage, None_, Normal};
use values::ExtremumLength;

This comment has been minimized.

Copy link
@Manishearth

Manishearth Feb 22, 2017

Member

I don't see where ExtremumLength is defined

This comment has been minimized.

This comment has been minimized.

Copy link
@Manishearth

Manishearth Feb 23, 2017

Member

ah, somehow missed that

#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
#[allow(missing_docs)]
pub enum MinLength {

This comment has been minimized.

Copy link
@Manishearth

Manishearth Feb 22, 2017

Member

Is there any semantic difference between MinLength and MaxLength? If not I'd prefer for these to be the same type, called ExtremumLength, and what is currently ExtremumLength can become ExtremumLengthKeyword

This comment has been minimized.

Copy link
@glasserc

glasserc Feb 23, 2017

Author Contributor

The comment just above this snippet explains that MinLength can be auto but not none, and MaxLength can be none but not auto.

This comment has been minimized.

Copy link
@Manishearth

Manishearth Feb 23, 2017

Member

It feels like we could save some code by making ExtremumLength be ExtremumLength<T> where T is either None or Auto. Not necessary though.

This comment has been minimized.

Copy link
@glasserc

glasserc Feb 24, 2017

Author Contributor

The other relevant differences that occur to me:

  • The default for min-width is 0, and the default for max-width is none. But this could be done in the property definitions. (And actually, I had this wrong; I just corrected it.)
  • For min-width, fit-content is "Defined as min(max-content, max(min-content, fill-available)", whereas for max-width, fit-content is "The same as max-content" (according to MDN). But for what I add in this PR, I don't think that's really necessary.

I do think it would be less code, and I could make the change if you prefer.

This comment has been minimized.

Copy link
@Manishearth

Manishearth Feb 24, 2017

Member

It's fine as is then.

Implement a MinLength type
Implement an ExtremumLength type which contains all the enumerated
keyword values for min-width, min-height, max-width, and
max-height. Then, implement a MinLength which can be used for min-width
and min-height. So far this just maps to Gecko values.

Refs #13821.

@glasserc glasserc force-pushed the glasserc:extremum-length branch from 40ed692 to eca97ae Feb 23, 2017

Add support for MaxLength
This builds on the ExtremumLength type from the previous commit.

@glasserc glasserc force-pushed the glasserc:extremum-length branch from eca97ae to dd4f331 Feb 24, 2017

@Manishearth

This comment has been minimized.

Copy link
Member

commented Feb 24, 2017

@bors-servo

This comment has been minimized.

Copy link
Contributor

commented Feb 24, 2017

📌 Commit dd4f331 has been approved by Manishearth

@bors-servo

This comment has been minimized.

Copy link
Contributor

commented Feb 24, 2017

⌛️ Testing commit dd4f331 with merge 26de7c6...

bors-servo added a commit that referenced this pull request Feb 24, 2017

Auto merge of #14740 - glasserc:extremum-length, r=Manishearth
Add support for keyword values for min-width and max-width

This is a follow-up to #14432 which got closed and can no longer be re-opened.

This PR aims to add support for keyword-values max-content, min-content, fit-content, and fill-available to the properties that use them, namely min-width, min-height, max-width, and max-height.

It's still untested because I still haven't figured out how to do that. I guess I should write or find some web page that uses these properties.

Refs #13821.

<!-- Please describe your changes on the following line: -->

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

<!-- Either: -->
- [ ] 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/14740)
<!-- Reviewable:end -->
@bors-servo

This comment has been minimized.

Copy link
Contributor

commented Feb 24, 2017

☀️ Test successful - android, arm32, arm64, linux-dev, linux-rel-css, linux-rel-wpt, mac-dev-unit, mac-rel-css, mac-rel-wpt1, mac-rel-wpt2, windows-gnu-dev, windows-msvc-dev
Approved by: Manishearth
Pushing 26de7c6 to master...

@bors-servo bors-servo merged commit dd4f331 into servo:master Feb 24, 2017

3 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details

@glasserc glasserc deleted the glasserc:extremum-length branch Feb 27, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.