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

Preserve units in computed Angle #16674

Merged
merged 2 commits into from May 1, 2017
Merged

Preserve units in computed Angle #16674

merged 2 commits into from May 1, 2017

Conversation

canova
Copy link
Contributor

@canova canova commented May 1, 2017

It was converting all angles to radians before. But other browsers preserves the angle units. Fixed that behavior.



This change is Reviewable

Using specified Angle was wrong because it can keep calc
value and serialize with calc(). Also that will allow us to pass
angle unit later.
@highfive
Copy link

highfive commented May 1, 2017

Heads up! This PR modifies the following files:

  • @bholley: components/style/gecko_bindings/bindings.rs, components/style/properties/longhand/effects.mako.rs, components/style/values/specified/mod.rs, components/style/properties/gecko.mako.rs, components/style/values/computed/mod.rs and 3 more
  • @emilio: components/style/gecko_bindings/bindings.rs, components/style/properties/longhand/effects.mako.rs, components/style/values/specified/mod.rs, components/style/properties/gecko.mako.rs, components/style/values/computed/mod.rs and 3 more

@highfive highfive added the S-awaiting-review There is new code that needs to be reviewed. label May 1, 2017
@highfive
Copy link

highfive commented May 1, 2017

warning Warning warning

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

/// Sets Angle value to this nsCSSValue.
pub fn set_angle(&mut self, angle: Angle) {
let (value, unit) = angle.to_gecko_values();
self.mUnit = unit;
Copy link
Member

Choose a reason for hiding this comment

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

Oh, one thing I missed, please assert here we're not leaking anything (that our unit isn't one of the heap ones).

Copy link
Member

Choose a reason for hiding this comment

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

(Not the unit we're setting, but the pre-existing unit)

@canova
Copy link
Contributor Author

canova commented May 1, 2017

Fixed that. That assert was your point, right?

@emilio
Copy link
Member

emilio commented May 1, 2017

How is that assert ever going to be true? We definitely expect to go from eCSSUnit_Null to angle, at least.

I mean to assert it's not one of the actual units that needs freeing stuff in nsCSSValue::DoReset, because otherwise we'd be leaking them.

Copy link
Member

@emilio emilio left a comment

Choose a reason for hiding this comment

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

r=me, assuming it holds, thanks!

We should refactor those methods to make clear when we call them, but I think that's part of https://bugzilla.mozilla.org/show_bug.cgi?id=1361032


/// Sets Angle value to this nsCSSValue.
pub fn set_angle(&mut self, angle: Angle) {
debug_assert!(self.mUnit == nsCSSUnit::eCSSUnit_Null);
Copy link
Member

Choose a reason for hiding this comment

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

nit: debug_assert_eq!?

@canova
Copy link
Contributor Author

canova commented May 1, 2017

@bors-servo r=emilio

@bors-servo
Copy link
Contributor

📌 Commit f8710bc has been approved by emilio

@highfive highfive assigned emilio and unassigned Manishearth May 1, 2017
@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 May 1, 2017
@bors-servo
Copy link
Contributor

⌛ Testing commit f8710bc with merge 0abd5bb...

bors-servo pushed a commit that referenced this pull request May 1, 2017
Preserve units in computed Angle

<!-- Please describe your changes on the following line: -->
It was converting all angles to radians before. But other browsers preserves the angle units. Fixed that behavior.

---
<!-- 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 #16594 and [Bug 1360659](https://bugzilla.mozilla.org/show_bug.cgi?id=1360659)

<!-- 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/16674)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

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

@bors-servo bors-servo merged commit f8710bc into servo:master May 1, 2017
@highfive highfive removed the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label May 1, 2017
@canova canova deleted the angle-unit branch May 1, 2017 19:13
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.

Computed angle should preserve its unit
5 participants