mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
Auto merge of #18102 - hiikezoe:compute-distance-for-shadow-list, r=boris
Implement distance for shadow list. <!-- Please describe your changes on the following line: --> https://bugzilla.mozilla.org/show_bug.cgi?id=1387973 --- - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors <!-- 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/18102) <!-- Reviewable:end -->
This commit is contained in:
commit
846b6dcb07
1 changed files with 17 additions and 4 deletions
|
@ -104,11 +104,24 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
impl<S> ComputeSquaredDistance for ShadowList<S> {
|
||||
impl<S> ComputeSquaredDistance for ShadowList<S>
|
||||
where
|
||||
S: ComputeSquaredDistance + ToAnimatedZero,
|
||||
{
|
||||
#[inline]
|
||||
fn compute_squared_distance(&self, _other: &Self) -> Result<SquaredDistance, ()> {
|
||||
// FIXME: This should be implemented.
|
||||
Err(())
|
||||
fn compute_squared_distance(&self, other: &Self) -> Result<SquaredDistance, ()> {
|
||||
use itertools::{EitherOrBoth, Itertools};
|
||||
|
||||
self.0.iter().zip_longest(other.0.iter()).map(|it| {
|
||||
match it {
|
||||
EitherOrBoth::Both(from, to) => {
|
||||
from.compute_squared_distance(to)
|
||||
},
|
||||
EitherOrBoth::Left(list) | EitherOrBoth::Right(list) => {
|
||||
list.compute_squared_distance(&list.to_animated_zero()?)
|
||||
},
|
||||
}
|
||||
}).sum()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue