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

Serialization of border-radius and -moz-outline-radius shorthand is wrong #15169

Closed
upsuper opened this issue Jan 24, 2017 · 20 comments
Closed

Serialization of border-radius and -moz-outline-radius shorthand is wrong #15169

upsuper opened this issue Jan 24, 2017 · 20 comments

Comments

@upsuper
Copy link
Member

@upsuper upsuper commented Jan 24, 2017

For example, border-radius: 1px 2px 3px 4px / 5px 6px 7px 8px is incorrectly serialized as border-radius: 1px 5px 2px 6px 3px 7px 4px 8px.

@upsuper upsuper added the E-easy label Jan 24, 2017
@highfive
Copy link

@highfive highfive commented Jan 24, 2017

Please make a comment here if you intend to work on this issue. Thank you!

@upsuper
Copy link
Member Author

@upsuper upsuper commented Jan 24, 2017

Note that, this also affects Gecko-only -moz-outline-radius, which uses basically the same syntax.

@upsuper upsuper changed the title Serialization of border-radius shorthand is wrong Serialization of border-radius and -moz-outline-radius shorthand is wrong Jan 24, 2017
@jdm jdm added the A-content/css label Jan 24, 2017
@jdm
Copy link
Member

@jdm jdm commented Jan 24, 2017

<div style="border-radius: 1px 2px 3px 4px / 5px 6px 7px 8px">
<script>console.log(document.querySelector('div').style.borderRadius)</script>
@Aaron-Tang
Copy link

@Aaron-Tang Aaron-Tang commented Jan 26, 2017

Hi, I intend to work on this issue

@upsuper
Copy link
Member Author

@upsuper upsuper commented Jan 26, 2017

Great! Feel free to ask any questions.

@upsuper upsuper added the C-assigned label Jan 26, 2017
@upsuper
Copy link
Member Author

@upsuper upsuper commented Feb 6, 2017

In addition to the / separator, the serialization should also be condensed to the shortest form when possible, which means border-radius: 1px 1px 1px 1px / 2px 2px 2px 2px should be serialized to border-radius: 1px / 2px, and border-radius: 1px 1px 1px 1px / 1px 1px 1px 1px should be border-radius: 1px.

@jdm
Copy link
Member

@jdm jdm commented Feb 6, 2017

@Aaron-Tang have you made progress? Any questions?

@Aaron-Tang
Copy link

@Aaron-Tang Aaron-Tang commented Feb 8, 2017

Sorry I haven't been able to sit down and work on it that much, I'll probably get to it this weekend. Quick question however, which part of the code should I be working on? There doesn't seem to be anything linked in the issue.

@Aaron-Tang
Copy link

@Aaron-Tang Aaron-Tang commented Feb 20, 2017

Um I have a few questions about the linked code; I'm new to rust and I'm trying to understand the code first:

  • What does "fn to_css_declared(&self, dest: &mut W) -> fmt::Result where W: fmt::Write" do?
  • Do border_top_left_radius and the other ones have two fields (as in the example you gave above it seems that border_top_left_radius is equal to both 1px and 5px).
  • If yes how would i access the fields? Is it like accessing an array value (somelist[2] = some_value) or is there a way unique to rust to do this?
@upsuper
Copy link
Member Author

@upsuper upsuper commented Feb 21, 2017

@wafflespeanut
Copy link
Member

@wafflespeanut wafflespeanut commented Mar 2, 2017

@Aaron-Tang ping?

@Aaron-Tang
Copy link

@Aaron-Tang Aaron-Tang commented Mar 4, 2017

Sorry I'm still very confused on how to fix this bug. I understand that the issue now is that the to_css function gets both the height and width of the borderradius into the dest object, which is then written using write. I'm trying to figure out how to access the height and width attributes of BorderRadiusSize before this occurs so I can run checks to see if it can be shortened. I can't seem to find a way to do so. I don't think I mentioned before that I'm totally new to rust which is why a lot of this is confusing to me. Any help would be greatly appreciated.

@wafflespeanut
Copy link
Member

@wafflespeanut wafflespeanut commented Mar 5, 2017

You don't really need to worry about everything. Let's go through some stuff. We know that the parsing code which uses the existing BorderRadius implementation works just fine, but the serializing code directly writes these values (separated by spaces, just like the issue says), which is not what we want. The clue lies in the existing ToCss implementation of BorderRadius.

@austinprete
Copy link
Contributor

@austinprete austinprete commented Mar 25, 2017

@wafflespeanut is this issue now open for someone else to pick up? (I saw that you removed the assigned label, and the discussion has been stale for a while) If so, I'd like to work on it, though it'd probably be until next weekend before I'd have time to make progress. (Busy school week for me)

@KiChjang
Copy link
Member

@KiChjang KiChjang commented Mar 25, 2017

@austinprete Let us know when you start working on it then. In the meantime, this issue is still open!

@bholley bholley added the A-stylo label Mar 26, 2017
@highfive
Copy link

@highfive highfive commented Mar 26, 2017

cc @emilio

@fnune
Copy link
Contributor

@fnune fnune commented Apr 9, 2017

Hello! I would like to work on this issue. I am new to the language: my only experience is a couple small applications that use APIs from services like Slack, Asana and my company's own backends.

I think with the comments on this wall and some effort I'll be able to tackle it, though!

@jdm
Copy link
Member

@jdm jdm commented Apr 9, 2017

Great! Please ask questions if anything is unclear!

@jdm jdm added the C-assigned label Apr 9, 2017
@fnune fnune mentioned this issue Apr 10, 2017
4 of 4 tasks complete
@wafflespeanut
Copy link
Member

@wafflespeanut wafflespeanut commented Apr 12, 2017

Wonderful. I never noticed that this addresses #12655.

bors-servo added a commit that referenced this issue Apr 14, 2017
…tion, r=Wafflespeanut

Fix -moz-outline-radius shorthand serialization

<!-- Please describe your changes on the following line: -->
These changes aim to solve #15169 correcting the `ToCss` implementation for `LonghandsToSerialize` for the `border-radius` shorthands. They also reduce redundant values like `1px 2px 1px 2px` to `1px 2px` to either sides of the slash.

---
<!-- 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 #15169 (github issue number if applicable).

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

<!-- 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/16340)
<!-- 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.

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