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

stylo: Bug 1362896 - Implement ComputeSquaredDistance for TransformList #18086

Merged
merged 4 commits into from Aug 18, 2017

Conversation

@BorisChiou
Copy link
Contributor

BorisChiou commented Aug 15, 2017

We implement ComputeSquaredDistance for TransformList.


  • ./mach build -d does not report any errors
  • ./mach test-tidy does not report any errors
  • These changes fix Bug 1362896.
  • These changes do not require tests because Gecko has related tests.

This change is Reviewable

@highfive
Copy link

highfive commented Aug 15, 2017

Heads up! This PR modifies the following files:

  • @bholley: components/style/values/distance.rs, components/style/values/computed/length.rs, components/style/properties/helpers/animated_properties.mako.rs
  • @canaltinova: components/style/values/distance.rs, components/style/values/computed/length.rs, components/style/properties/helpers/animated_properties.mako.rs
  • @emilio: components/style/values/distance.rs, components/style/values/computed/length.rs, components/style/properties/helpers/animated_properties.mako.rs
@highfive
Copy link

highfive commented Aug 15, 2017

warning Warning warning

  • These commits modify style code, but no tests are modified. Please consider adding a test!
@BorisChiou
Copy link
Contributor Author

BorisChiou commented Aug 15, 2017

r?@nox

@highfive highfive assigned nox and unassigned emilio Aug 15, 2017
@BorisChiou
Copy link
Contributor Author

BorisChiou commented Aug 15, 2017

Most parts are also reviewed by @birtles.

@BorisChiou
Copy link
Contributor Author

BorisChiou commented Aug 15, 2017

@bors-servo
Copy link
Contributor

bors-servo commented Aug 15, 2017

Trying commit 7285b51 with merge 36b01f4...

bors-servo added a commit that referenced this pull request Aug 15, 2017
stylo: Bug 1362896 - Implement ComputeSquaredDistance for TransformList

We implement ComputeSquaredDistance for TransformList.

---
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix [Bug 1362896](https://bugzilla.mozilla.org/show_bug.cgi?id=1362896).
- [X] These changes do not require tests because Gecko has related tests.

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

bors-servo commented Aug 15, 2017

@BorisChiou
Copy link
Contributor Author

BorisChiou commented Aug 16, 2017

Hi @emilio, it seems nox is on PTO in these days? Could you please take a look at these patches? Thanks.

@emilio
Copy link
Member

emilio commented Aug 16, 2017

@nox should be back, yesterday was holiday in France. I can take a look if he can't, though.

fn compute_squared_distance(&self, other: &Self) -> Result<SquaredDistance, ()> {
// If possible, we should convert the InnerMatrix2D into types with physical meaning.
// Therefore, we compute the squared distance from each matrix item, and this makes the
// result different from that in Gecko if we have skew/shear factor in the ComputedMatrix.

This comment has been minimized.

@nox

nox Aug 16, 2017

Member

Shear?

This comment has been minimized.

@BorisChiou

BorisChiou Aug 17, 2017

Author Contributor

Shear is used in Gecko. I think I should remove this word to avoid confusing people.

impl ComputeSquaredDistance for InnerMatrix2D {
#[inline]
fn compute_squared_distance(&self, other: &Self) -> Result<SquaredDistance, ()> {
// If possible, we should convert the InnerMatrix2D into types with physical meaning.

This comment has been minimized.

@nox

nox Aug 16, 2017

Member

Is that something that should be done? If yes, add "FIXME: " before the comment.

This comment has been minimized.

@BorisChiou

BorisChiou Aug 17, 2017

Author Contributor

Thanks. Yes, I will add "FIXME:"

@@ -1563,6 +1563,19 @@ impl Animatable for InnerMatrix2D {
}
}

impl ComputeSquaredDistance for InnerMatrix2D {

This comment has been minimized.

@nox

nox Aug 16, 2017

Member

This implementation can be derived.

@@ -1572,6 +1585,14 @@ impl Animatable for Translate2D {
}
}

impl ComputeSquaredDistance for Translate2D {

This comment has been minimized.

@nox

nox Aug 16, 2017

Member

This implementation can be derived.

@@ -1581,6 +1602,14 @@ impl Animatable for Scale2D {
}
}

impl ComputeSquaredDistance for Scale2D {

This comment has been minimized.

@nox

nox Aug 16, 2017

Member

This implementation can be derived.

@@ -2104,6 +2271,18 @@ impl Animatable for MatrixDecomposed3D {
}
}

impl ComputeSquaredDistance for MatrixDecomposed3D {

This comment has been minimized.

@nox

nox Aug 16, 2017

Member

This implementation can be derived if you implement that trait for Quaternion, which you should instead of having an intrinsic distance method.

This comment has been minimized.

@BorisChiou

BorisChiou Aug 17, 2017

Author Contributor

I see. This sounds much better.

// FIXME: This should be implemented.
Err(())
fn compute_squared_distance(&self, other: &Self) -> Result<SquaredDistance, ()> {
match (&self.0, &other.0) {

This comment has been minimized.

@nox

nox Aug 16, 2017

Member

Nit: you could otherwise match on (self.0.as_ref(), other.0.as_ref()).

@@ -78,7 +78,8 @@ impl ComputeSquaredDistance for CalcLengthOrPercentage {
// FIXME(nox): This looks incorrect to me, to add a distance between lengths
// with a distance between percentages.
Ok(
self.unclamped_length().compute_squared_distance(&other.unclamped_length())? +
self.unclamped_length().to_f64_px().compute_squared_distance(
&other.unclamped_length().to_f64_px())? +

This comment has been minimized.

@nox

nox Aug 16, 2017

Member

Why is it correct at all to mix lengths and percentages? Cf. the FIXME I left just above that change.

This comment has been minimized.

@BorisChiou

BorisChiou Aug 17, 2017

Author Contributor

Actually, this doesn't make any sense. However, while computing the distance or doing interpolation, we only have computed values (i.e. we shouldn't use used values), so this is a temporary? way to define its distance, and the test cases in Gecko use this way to produce the expected values.
We should keep the "FIXME:" because I hope one day we could use a better way to define the distance.

This comment has been minimized.

@nox

nox Aug 17, 2017

Member

Ok.

fn add_assign(&mut self, rhs: Self) {
*self = *self + rhs;
}
}

This comment has been minimized.

@nox

nox Aug 16, 2017

Member

This shouldn't be needed.

to_list: &[TransformOperation])
-> Result<SquaredDistance, ()> {
let mut squared_distance = SquaredDistance::Value(0.);
for (from, to) in from_list.iter().zip(to_list.iter()) {

This comment has been minimized.

@nox

nox Aug 16, 2017

Member

You don't need a for loop at all here, just map on the iterator and sum it at the end.

@nox
Copy link
Member

nox commented Aug 16, 2017

"Tweak CalcLengthOrPerecentage to use pixel value." fix that typo.

BorisChiou added 4 commits Aug 9, 2017
We compute the distance for eCSSUnit_Calc by pixel value in Gecko,
so let's follow the same rules.
The unit of gfxQuaternion in Gecko is gfxFloat, which is "double", so
it's better to use f64 to match the precision of Gecko.
@BorisChiou BorisChiou force-pushed the BorisChiou:stylo/transform/distance branch from 7285b51 to e8fad23 Aug 17, 2017
@nox
nox approved these changes Aug 17, 2017
@@ -2013,6 +2162,15 @@ impl Animatable for Skew {
}
}

impl ComputeSquaredDistance for Skew {

This comment has been minimized.

@nox

nox Aug 17, 2017

Member

Oh right.

@@ -78,7 +78,8 @@ impl ComputeSquaredDistance for CalcLengthOrPercentage {
// FIXME(nox): This looks incorrect to me, to add a distance between lengths
// with a distance between percentages.
Ok(
self.unclamped_length().compute_squared_distance(&other.unclamped_length())? +
self.unclamped_length().to_f64_px().compute_squared_distance(
&other.unclamped_length().to_f64_px())? +

This comment has been minimized.

@nox

nox Aug 17, 2017

Member

Ok.

@nox
Copy link
Member

nox commented Aug 17, 2017

r=me if the geckotry failures are unrelated.

@nox nox removed the S-awaiting-review label Aug 17, 2017
@bors-servo
Copy link
Contributor

bors-servo commented Aug 18, 2017

📌 Commit e8fad23 has been approved by nox,

@BorisChiou
Copy link
Contributor Author

BorisChiou commented Aug 18, 2017

@bors-servo r=nox,birtles

Thanks, nox. Those geckotry failures are intermittents.

@bors-servo
Copy link
Contributor

bors-servo commented Aug 18, 2017

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

  • There's another pull request that is currently being tested, blocking this pull request: #18139
@bors-servo
Copy link
Contributor

bors-servo commented Aug 18, 2017

📌 Commit e8fad23 has been approved by nox,birtles

@bors-servo
Copy link
Contributor

bors-servo commented Aug 18, 2017

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

  • There's another pull request that is currently being tested, blocking this pull request: #18139
@bors-servo
Copy link
Contributor

bors-servo commented Aug 18, 2017

📌 Commit e8fad23 has been approved by nox,

@bors-servo
Copy link
Contributor

bors-servo commented Aug 18, 2017

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

  • There's another pull request that is currently being tested, blocking this pull request: #18139
@bors-servo
Copy link
Contributor

bors-servo commented Aug 18, 2017

📌 Commit e8fad23 has been approved by nox,birtles

@bors-servo
Copy link
Contributor

bors-servo commented Aug 18, 2017

Testing commit e8fad23 with merge 494dcd7...

bors-servo added a commit that referenced this pull request Aug 18, 2017
…tles

stylo: Bug 1362896 - Implement ComputeSquaredDistance for TransformList

We implement ComputeSquaredDistance for TransformList.

---
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix [Bug 1362896](https://bugzilla.mozilla.org/show_bug.cgi?id=1362896).
- [X] These changes do not require tests because Gecko has related tests.

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

bors-servo commented Aug 18, 2017

@bors-servo bors-servo merged commit e8fad23 into servo:master Aug 18, 2017
3 checks passed
3 checks passed
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

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