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

Negative value on flex-basis should be rejected #15902

Closed
upsuper opened this issue Mar 10, 2017 · 13 comments
Closed

Negative value on flex-basis should be rejected #15902

upsuper opened this issue Mar 10, 2017 · 13 comments

Comments

@upsuper
Copy link
Member

@upsuper upsuper commented Mar 10, 2017

Relevant code:

${helpers.predefined_type("flex-basis",
"LengthOrPercentageOrAuto" if product == "gecko" else
"LengthOrPercentageOrAutoOrContent",
"computed::LengthOrPercentageOrAuto::Auto" if product == "gecko" else
"computed::LengthOrPercentageOrAutoOrContent::Auto",
spec="https://drafts.csswg.org/css-flexbox/#flex-basis-property",
extra_prefixes="webkit",
animatable=True if product == "gecko" else False)}

Should be an easy one although I cannot provide how to fix it without further investigation.

@highfive
Copy link

@highfive highfive commented Mar 10, 2017

Hi! If you have any questions regarding this issue, feel free to make a comment here, or ask it in the #servo channel in IRC.

If you intend to work on this issue, then add @highfive: assign me to your comment, and I'll assign this to you. 😄

@upsuper
Copy link
Member Author

@upsuper upsuper commented Mar 10, 2017

@canova
Copy link
Member

@canova canova commented Mar 10, 2017

This can be fixed by adding "parse_non_negative" and needs_context=False parameters to this helpers.predefined_type before the spec parameter. This will work fine in stylo build (can be built with ./mach build-geckolib) But will break servo build because LengthOrPercentageOrAutoOrContent doesn't have a parse_non_negative method. We need to add this function to enum like LengthOrPercentageOrAuto implementation except it will have additional content parsing.

@canova
Copy link
Member

@canova canova commented Mar 10, 2017

Oh, scratch that. It looks like LengthOrPercentageOrAutoOrContent's parse function is already rejecting negative values. Passing something like these parameters will solve the problem without changing parse implementations: "parse_non_negative" if product == "gecko" else "parse" needs_context=False if product == "gecko" else True,

@wafflespeanut
Copy link
Member

@wafflespeanut wafflespeanut commented Mar 10, 2017

Instead of going for a lot of if ... else blocks inside the definition, let's have two definitions - one for each servo and gecko.

@mrkalling
Copy link

@mrkalling mrkalling commented Mar 10, 2017

Hi, I like to work on this @highfive: assign me

@highfive highfive added the C-assigned label Mar 10, 2017
@highfive
Copy link

@highfive highfive commented Mar 10, 2017

Hey @mrkalling! Thanks for your interest in working on this issue. It's now assigned to you!

@wafflespeanut
Copy link
Member

@wafflespeanut wafflespeanut commented Mar 21, 2017

@mrkalling Did you start working on this?

@mrkalling
Copy link

@mrkalling mrkalling commented Mar 21, 2017

I have looked at it but I don't understand what is the problem. When I test to set flex-basis to a negative number servo seems to ignore it which is what we want, right?

@upsuper upsuper added the A-stylo label Mar 21, 2017
@upsuper
Copy link
Member Author

@upsuper upsuper commented Mar 21, 2017

It looks like Servo's LengthOrPercentageOrAutoOrContent is already only parsing non-negatives, while the Gecko port uses LengthOrPercentageOrAuto which does normal parsing. So it is a stylo-only issue. We probably need to use LengthOrPercentageOrAuto::parse_non_negative for that.

@upsuper
Copy link
Member Author

@upsuper upsuper commented Mar 21, 2017

Probably adding a new line

"parse_non_negative" if product == "gecko" else "parse",

would be enough.

@wafflespeanut
Copy link
Member

@wafflespeanut wafflespeanut commented Mar 27, 2017

@mrkalling ping?

@emilio
Copy link
Member

@emilio emilio commented Apr 5, 2017

This is Gecko only, and I'm helping out someone working on this.

@emilio emilio added the C-assigned label Apr 5, 2017
CipherCit added a commit to CipherCit/servo that referenced this issue Apr 5, 2017
CipherCit added a commit to CipherCit/servo that referenced this issue Apr 5, 2017
@CipherCit CipherCit mentioned this issue Apr 5, 2017
4 of 4 tasks complete
bors-servo added a commit that referenced this issue Apr 5, 2017
Reject negative values of flex-basis.

Fixes #15902

<!-- 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: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix #15902 (github issue number if applicable).

<!-- Either: -->
- [x] There are tests for these changes OR

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- 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/16274)
<!-- Reviewable:end -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

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