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

Handle 3- and 4- valued <position>s in style #13042

Merged
merged 2 commits into from Aug 29, 2016
Merged

Conversation

canova
Copy link
Contributor

@canova canova commented Aug 25, 2016

This is first part of fix #12690 and covers just specified style part for now.

r? @Manishearth



This change is Reviewable

@highfive
Copy link

Heads up! This PR modifies the following files:

  • @bholley: components/style/properties/longhand/background.mako.rs, components/style/values/specified/basic_shape.rs, components/style/values/specified/position.rs

@highfive
Copy link

warning Warning warning

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

@highfive highfive added the S-awaiting-review There is new code that needs to be reviewed. label Aug 25, 2016
@canova
Copy link
Contributor Author

canova commented Aug 25, 2016

@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. to_computed_value function needs to change because horiz_position and vert_position need unwrapping. But I wanted to wait until this function change.
Destructing the Option values messed the code :(

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?
Copy link
Contributor

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?

Copy link
Contributor Author

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!

@Manishearth
Copy link
Member

Manishearth commented Aug 26, 2016

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))
Copy link
Member

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.

Copy link
Member

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.

@canova
Copy link
Contributor Author

canova commented Aug 27, 2016

@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");
Copy link
Contributor Author

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.

@Manishearth
Copy link
Member

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 {
Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed it thanks!

@Manishearth
Copy link
Member

@bors-servo try

@bors-servo
Copy link
Contributor

⌛ Trying commit 8372f29 with merge 255da48...

bors-servo pushed a commit that referenced this pull request Aug 28, 2016
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 -->
@bors-servo
Copy link
Contributor

💔 Test failed - linux-rel

@highfive highfive added the S-tests-failed The changes caused existing tests to fail. label Aug 28, 2016
@highfive
Copy link

  ▶ FAIL [expected PASS] /css-transforms-1_dev/html/transform-table-007.htm
  └   → /css-transforms-1_dev/html/transform-table-007.htm a5c014b20ef1363bea6f24eda28c7efb7c45698a
/css-transforms-1_dev/html/reference/transform-blank-ref.htm fa6407b1acbbfea27e27061e7d1bdeca98e4a728
Testing a5c014b20ef1363bea6f24eda28c7efb7c45698a == fa6407b1acbbfea27e27061e7d1bdeca98e4a728

@Manishearth
Copy link
Member

Manishearth commented Aug 28, 2016

@bors-servo
Copy link
Contributor

⌛ Trying commit 8372f29 with merge 832d01f...

bors-servo pushed a commit that referenced this pull request Aug 28, 2016
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 -->
@bors-servo
Copy link
Contributor

⌛ Trying commit 8372f29 with merge 3c995ab...

bors-servo pushed a commit that referenced this pull request Aug 28, 2016
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 -->
@bors-servo
Copy link
Contributor

☀️ Test successful - arm32, arm64, linux-dev, linux-rel, mac-dev-unit, mac-rel-css, mac-rel-wpt, windows-dev

@Manishearth
Copy link
Member

Needs to error on center NotKeyword and we're good

@Manishearth
Copy link
Member

Oh, it already does, just not there.

@bors-servo r+

@bors-servo
Copy link
Contributor

📌 Commit 8372f29 has been approved by Manishearth

@highfive highfive added S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. and removed S-awaiting-review There is new code that needs to be reviewed. S-tests-failed The changes caused existing tests to fail. labels Aug 28, 2016
@canova
Copy link
Contributor Author

canova commented Aug 29, 2016

@Manishearth Is something wrong with bors? :)

@Manishearth
Copy link
Member

@bors-servo r+ try- retry

it doesn't forget the try state.

@bors-servo
Copy link
Contributor

💡 This pull request was already approved, no need to approve it again.

@bors-servo
Copy link
Contributor

📌 Commit 8372f29 has been approved by Manishearth

@bors-servo
Copy link
Contributor

⌛ Testing commit 8372f29 with merge b8d725d...

bors-servo pushed a commit that referenced this pull request Aug 29, 2016
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 -->
@bors-servo
Copy link
Contributor

☀️ Test successful - arm32, arm64, linux-dev, linux-rel, mac-dev-unit, mac-rel-css, mac-rel-wpt, windows-dev

@bors-servo bors-servo merged commit 8372f29 into servo:master Aug 29, 2016
@highfive highfive removed the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Aug 29, 2016
@Manishearth
Copy link
Member

Thanks!

@canova
Copy link
Contributor Author

canova commented Aug 29, 2016

@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 :)

@canova canova deleted the position branch August 29, 2016 15:21
@Manishearth
Copy link
Member

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 😄

bors-servo pushed a commit that referenced this pull request Sep 1, 2016
…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 -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Handle 3- and 4- valued <position>s in style
5 participants