Skip to content

Move image-orientation property outside of mako - #19766

Merged
bors-servo merged 1 commit into
servo:masterfrom
jonleighton:issue-19765
Jan 15, 2018
Merged

bors-servo merged 1 commit into
servo:masterfrom
jonleighton:issue-19765

Conversation

@jonleighton

@jonleighton jonleighton commented Jan 14, 2018 •

Copy link
Copy Markdown
Contributor

Fixes #19765

r? emilio


This change is Reviewable

@highfive

Copy link
Copy Markdown

Heads up! This PR modifies the following files:

  • @bholley: components/style/values/specified/inherited_box.rs, components/style/values/computed/inherited_box.rs, components/style/values/specified/mod.rs, components/style/properties/gecko.mako.rs, components/style/values/computed/mod.rs and 1 more
  • @canaltinova: components/style/values/specified/inherited_box.rs, components/style/values/computed/inherited_box.rs, components/style/values/specified/mod.rs, components/style/properties/gecko.mako.rs, components/style/values/computed/mod.rs and 1 more
  • @emilio: components/style/values/specified/inherited_box.rs, components/style/values/computed/inherited_box.rs, components/style/values/specified/mod.rs, components/style/properties/gecko.mako.rs, components/style/values/computed/mod.rs and 1 more

@highfive

Copy link
Copy Markdown

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 Jan 14, 2018
animation_value_type="discrete",
gecko_pref="layout.css.image-orientation.enabled",
spec="https://drafts.csswg.org/css-images/#propdef-image-orientation, \
/// additional values in https://developer.mozilla.org/en-US/docs/Web/CSS/image-orientation")}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I had to indent this weirdly to prevent a test-tidy error due to the line length. Alternative suggestions welcome.

@CYBAI CYBAI Jan 14, 2018 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

How about putting the second line as a documentation comment for type ImageOrientation?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yeah, this is kinda weird, but it's not worse than what there was before, so feel free to leave it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm actually not sure I understand why we need the second link at all? Could we just remove it?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Sure, we can.

@emilio emilio left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good, just some minor nits. Thanks for doing this!

}

impl Orientation {
#[allow(missing_docs)]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Let's add docs, something like:

/// Get the actual angle that this orientation value represents.

Comment thread components/style/values/computed/mod.rs Outdated
@@ -82,6 +84,8 @@ pub mod flex;
pub mod font;
pub mod image;
#[cfg(feature = "gecko")]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This doesn't have anything Gecko-specific, right? Let's just build it for Servo too so we have less divergence.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Right, I think I thought that might trigger warnings, but quite possibly I thought wrong!

* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

//! Specified values for inherited box
//! Only used by gecko

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

And let's remove this.

// This computation introduces rounding error. Gecko previously
// didn't handle the negative case correctly; by branching we can
// match Gecko's behavior when it was correct.
rounded_angle = rounded_angle + TWO_PI;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This can be rounded_angle += TWO_PI;

use values::computed::{Context, Orientation, ToComputedValue};
use values::specified::Angle;

#[allow(missing_docs)]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Let's add docs for this, like:

/// The specified value of the `image-orientation` property.
/// https://drafts.csswg.org/css-images/#propdef-image-orientation

) -> Result<Self, ParseError<'i>> {
if input.try(|input| input.expect_ident_matching("from-image")).is_ok() {
// Handle from-image
Ok(ImageOrientation { angle: None, flipped: false })

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I know this is just moving code around, but this could be cleaner if you early-return instead. No big deal if you don't feel like doing it of course :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Just curious, why do you find early-returning in this situation cleaner? Personally I marginally prefer the existing style as I feel like it gives equal "weight" to each branch, since each is equally valid/likely. I prefer to save early-returning for handling edges cases, unexpected values, etc (this is coming from a Ruby background, where we sometimes have to manually "type check" method parameters...)

Anyway, I really don't care very much either way and I'm happy to change it, just interested in your perspective!

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

No worries!

I generally prefer early returning because when I read it feels a bit more natural. In this case it's not a big deal, but in other places not returning causes a lot of rightward drift in the code. Anyway, fine to not change it :)

animation_value_type="discrete",
gecko_pref="layout.css.image-orientation.enabled",
spec="https://drafts.csswg.org/css-images/#propdef-image-orientation, \
/// additional values in https://developer.mozilla.org/en-US/docs/Web/CSS/image-orientation")}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yeah, this is kinda weird, but it's not worse than what there was before, so feel free to leave it.

@emilio emilio left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good to me, thanks!

@emilio

emilio commented Jan 14, 2018

Copy link
Copy Markdown
Member

@bors-servo r+

Feel free to submit the removal of the extra link as a followup, or to here (in which case I'll re-approve :P).

@bors-servo

Copy link
Copy Markdown
Contributor

📌 Commit bd55639 has been approved by emilio

@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. labels Jan 14, 2018
@bors-servo

Copy link
Copy Markdown
Contributor

⌛ Testing commit bd55639 with merge ec34023...

bors-servo pushed a commit that referenced this pull request Jan 14, 2018
Move image-orientation property outside of mako

Fixes #19765

r? emilio

<!-- 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/19766)
<!-- Reviewable:end -->
@bors-servo

Copy link
Copy Markdown
Contributor

☀️ Test successful - android, arm32, arm64, linux-dev, linux-rel-css, linux-rel-wpt, mac-dev-unit, mac-rel-css1, mac-rel-css2, mac-rel-wpt1, mac-rel-wpt2, mac-rel-wpt3, mac-rel-wpt4, windows-msvc-dev
Approved by: emilio
Pushing ec34023 to master...

@bors-servo
bors-servo merged commit bd55639 into servo:master Jan 15, 2018
@highfive highfive removed the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Jan 15, 2018
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.

5 participants