mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
Auto merge of #18210 - mantaroh:clip-interpolation-fix, r=nox
Skip adding/accumulating ClipRect values which corresponding rect offset is auto. <!-- Please describe your changes on the following line: --> This is a PR for https://bugzilla.mozilla.org/show_bug.cgi?id=1390352 This patch will skip adding/accumulating the values which corresponding rect offset is auto, and make Servo_AnimationValues_ComputeDistance return negative value instead of 0.0 when the function fails to distinguish its failure. --- <!-- 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 <!-- Either: --> There are already these tests in dom/smil/tests of gecko, this PR will enable these tests. For detail, see https://bugzilla.mozilla.org/show_bug.cgi?id=1390352. <!-- 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/17288) <!-- Reviewable:end -->
This commit is contained in:
commit
5624c0e3f1
3 changed files with 25 additions and 2 deletions
|
@ -924,6 +924,27 @@ impl Into<FontStretch> for f64 {
|
||||||
impl<H, V> RepeatableListAnimatable for generic_position::Position<H, V>
|
impl<H, V> RepeatableListAnimatable for generic_position::Position<H, V>
|
||||||
where H: RepeatableListAnimatable, V: RepeatableListAnimatable {}
|
where H: RepeatableListAnimatable, V: RepeatableListAnimatable {}
|
||||||
|
|
||||||
|
/// https://drafts.csswg.org/css-transitions/#animtype-rect
|
||||||
|
impl Animate for ClipRect {
|
||||||
|
#[inline]
|
||||||
|
fn animate(&self, other: &Self, procedure: Procedure) -> Result<Self, ()> {
|
||||||
|
let animate_component = |this: &Option<Au>, other: &Option<Au>| {
|
||||||
|
match (this.animate(other, procedure)?, procedure) {
|
||||||
|
(None, Procedure::Interpolate { .. }) => Ok(None),
|
||||||
|
(None, _) => Err(()),
|
||||||
|
(result, _) => Ok(result),
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
Ok(ClipRect {
|
||||||
|
top: animate_component(&self.top, &other.top)?,
|
||||||
|
right: animate_component(&self.right, &other.right)?,
|
||||||
|
bottom: animate_component(&self.bottom, &other.bottom)?,
|
||||||
|
left: animate_component(&self.left, &other.left)?,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl ToAnimatedZero for ClipRect {
|
impl ToAnimatedZero for ClipRect {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn to_animated_zero(&self) -> Result<Self, ()> { Err(()) }
|
fn to_animated_zero(&self) -> Result<Self, ()> { Err(()) }
|
||||||
|
|
|
@ -445,7 +445,7 @@ pub type NonNegativeLengthOrPercentageOrNumber = Either<NonNegativeNumber, NonNe
|
||||||
|
|
||||||
#[allow(missing_docs)]
|
#[allow(missing_docs)]
|
||||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||||
#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, Eq, PartialEq)]
|
#[derive(Clone, ComputeSquaredDistance, Copy, Debug, Eq, PartialEq)]
|
||||||
/// A computed cliprect for clip and image-region
|
/// A computed cliprect for clip and image-region
|
||||||
pub struct ClipRect {
|
pub struct ClipRect {
|
||||||
pub top: Option<Au>,
|
pub top: Option<Au>,
|
||||||
|
|
|
@ -379,7 +379,9 @@ pub extern "C" fn Servo_AnimationValues_ComputeDistance(from: RawServoAnimationV
|
||||||
-> f64 {
|
-> f64 {
|
||||||
let from_value = AnimationValue::as_arc(&from);
|
let from_value = AnimationValue::as_arc(&from);
|
||||||
let to_value = AnimationValue::as_arc(&to);
|
let to_value = AnimationValue::as_arc(&to);
|
||||||
from_value.compute_squared_distance(to_value).map(|d| d.sqrt()).unwrap_or(0.0)
|
// If compute_squared_distance() failed, this function will return negative value
|
||||||
|
// in order to check whether we support the specified paced animation values.
|
||||||
|
from_value.compute_squared_distance(to_value).map(|d| d.sqrt()).unwrap_or(-1.0)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue