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
Handle 3- and 4- valued <position>s in style #13042
Conversation
Heads up! This PR modifies the following files:
|
@Manishearth Sorry accidentally deleted the branch and it closed the other pr :( (-d instead of -f) Updated the commit could you look at it when you are available? This is not building yet. |
keyword == Keyword::Top => LengthOrPercentage::Percentage(Percentage(0.0)), | ||
PositionComponent::Keyword(keyword) if keyword == Keyword::Right || | ||
keyword == Keyword::Bottom => LengthOrPercentage::Percentage(Percentage(1.0)), | ||
PositionComponent::Keyword(_) => unimplemented!(), // TODO: All keywords are covered but rust forcing me to add this too? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe match
further on keyword
looks better and eliminate the compiler's complain?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right. Probably this is better solution. I'll update soon, thanks!
Could you write tests for these in tests/unit/style/parsing/position.rs (by using the examples from the spec)? Your changes may make the basic shape tests fail. That is okay, comment them out for now, I'll fix them later. basic-shape serializes positions differently. |
if let Ok(third) = input.try(PositionComponent::parse) { | ||
if let Ok(fourth) = input.try(PositionComponent::parse) { | ||
// Handle 4 value background position | ||
Position::new(Some(second), Some(fourth), Some(first), Some(third)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
4-value can also be specified with the horizontal ones first.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, nvm, Position::new solves that.
@Manishearth Made a new commit can you review when you have time? I made a new commit instead of squashing first, so you can review more easily. After last changes I can squash them. |
assert_roundtrip!(Position::parse, "right 10px bottom", "right 10px bottom"); | ||
assert_roundtrip!(Position::parse, "bottom right 10px", "right 10px bottom"); | ||
assert_roundtrip!(Position::parse, "center right 10px", "right 10px center"); | ||
assert_roundtrip!(Position::parse, "center bottom 10px", "center bottom 10px"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added some additional example apart from specs to cover most of cases.
Looking good, with a few small issues. |
}; | ||
|
||
// Unwrap positions from PositionComponent and wrap with Option | ||
let (horiz_position, vert_position) = if let Some(PositionComponent::Length(horiz_pos)) = first_position { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use match first_position, second_position)
here. But this is ok too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed it thanks!
@bors-servo try |
Handle 3- and 4- valued <position>s in style <!-- Please describe your changes on the following line: --> This is first part of fix #12690 and covers just specified style part for now. r? @Manishearth --- - [X] These changes fix #12690 (github issue number if applicable). <!-- 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/13042) <!-- Reviewable:end -->
💔 Test failed - linux-rel |
|
Handle 3- and 4- valued <position>s in style <!-- Please describe your changes on the following line: --> This is first part of fix #12690 and covers just specified style part for now. r? @Manishearth --- - [X] These changes fix #12690 (github issue number if applicable). <!-- 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/13042) <!-- Reviewable:end -->
Handle 3- and 4- valued <position>s in style <!-- Please describe your changes on the following line: --> This is first part of fix #12690 and covers just specified style part for now. r? @Manishearth --- - [X] These changes fix #12690 (github issue number if applicable). <!-- 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/13042) <!-- Reviewable:end -->
☀️ Test successful - arm32, arm64, linux-dev, linux-rel, mac-dev-unit, mac-rel-css, mac-rel-wpt, windows-dev |
Needs to error on |
Oh, it already does, just not there. @bors-servo r+ |
📌 Commit 8372f29 has been approved by |
@Manishearth Is something wrong with bors? :) |
@bors-servo r+ try- retry it doesn't forget the |
💡 This pull request was already approved, no need to approve it again. |
📌 Commit 8372f29 has been approved by |
Handle 3- and 4- valued <position>s in style <!-- Please describe your changes on the following line: --> This is first part of fix #12690 and covers just specified style part for now. r? @Manishearth --- - [X] These changes fix #12690 (github issue number if applicable). <!-- 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/13042) <!-- Reviewable:end -->
☀️ Test successful - arm32, arm64, linux-dev, linux-rel, mac-dev-unit, mac-rel-css, mac-rel-wpt, windows-dev |
Thanks! |
@Manishearth Thank you also for mentoring me on this :) I learned so much and you helped me a lot. I'm sorry if I took a lot of your time :) |
Not much of my time -- most of the time went into figuring out what we were supposed to do, which I would have had to do anyway if I'd have done it myself. And mentoring is fun and it's great to see new contributors work on this project, so it's definitely not a waste of time 😄 |
…nSapin Handle specialized serialization of <position> in basic shapes Fixes #13083 We temporarily broke basic-shape serialization in #13042 when 4-value positions were implemented, since I didn't want to increase the scope of that PR too much. This fixes it. r? @SimonSapin cc @canaltinova <!-- 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/13122) <!-- Reviewable:end -->
This is first part of fix #12690 and covers just specified style part for now.
r? @Manishearth
This change is