Auto merge of #16624 - chenpighead:stylo-make-border-spacing-animatable, r=boris

stylo: Make border-spacing animatable

Two things are included in this patch:

1. Implement ComputeDistance for border-spacing, so we could get the right
distance while doing animations.

2. Implement clone function for gecko glue code of border-spacing, so we
could make animations of border-spacing work properly in stylo build.

Gecko side patch: Bug 1354437

<!-- Please describe your changes on the following line: -->

---
<!-- 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
- [ ] These changes fix #__ (github issue number if applicable).

<!-- Either: -->
- [ ] There are tests for these changes OR
- [ ] These changes do not require tests because _____

<!-- 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/16624)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2017-04-27 09:33:20 -05:00 committed by GitHub
commit a6c3bc6a49
2 changed files with 22 additions and 2 deletions

View file

@ -3255,6 +3255,13 @@ fn static_assert() {
self.gecko.mBorderSpacingCol = other.gecko.mBorderSpacingCol; self.gecko.mBorderSpacingCol = other.gecko.mBorderSpacingCol;
self.gecko.mBorderSpacingRow = other.gecko.mBorderSpacingRow; self.gecko.mBorderSpacingRow = other.gecko.mBorderSpacingRow;
} }
pub fn clone_border_spacing(&self) -> longhands::border_spacing::computed_value::T {
longhands::border_spacing::computed_value::T {
horizontal: Au(self.gecko.mBorderSpacingCol),
vertical: Au(self.gecko.mBorderSpacingRow)
}
}
</%self:impl_trait> </%self:impl_trait>

View file

@ -20,7 +20,7 @@ ${helpers.single_keyword("caption-side", "top bottom",
animation_value_type="none", animation_value_type="none",
spec="https://drafts.csswg.org/css-tables/#propdef-caption-side")} spec="https://drafts.csswg.org/css-tables/#propdef-caption-side")}
<%helpers:longhand name="border-spacing" animation_value_type="none" boxed="True" <%helpers:longhand name="border-spacing" animation_value_type="ComputedValue" boxed="True"
spec="https://drafts.csswg.org/css-tables/#propdef-border-spacing"> spec="https://drafts.csswg.org/css-tables/#propdef-border-spacing">
use app_units::Au; use app_units::Au;
use std::fmt; use std::fmt;
@ -29,7 +29,7 @@ ${helpers.single_keyword("caption-side", "top bottom",
pub mod computed_value { pub mod computed_value {
use app_units::Au; use app_units::Au;
use properties::animated_properties::Interpolate; use properties::animated_properties::{ComputeDistance, Interpolate};
#[derive(Clone, Copy, Debug, PartialEq)] #[derive(Clone, Copy, Debug, PartialEq)]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))] #[cfg_attr(feature = "servo", derive(HeapSizeOf))]
@ -48,6 +48,19 @@ ${helpers.single_keyword("caption-side", "top bottom",
}) })
} }
} }
impl ComputeDistance for T {
#[inline]
fn compute_distance(&self, other: &Self) -> Result<f64, ()> {
self.compute_squared_distance(other).map(|sd| sd.sqrt())
}
#[inline]
fn compute_squared_distance(&self, other: &Self) -> Result<f64, ()> {
Ok(try!(self.horizontal.compute_squared_distance(&other.horizontal)) +
try!(self.vertical.compute_squared_distance(&other.vertical)))
}
}
} }
impl HasViewportPercentage for SpecifiedValue { impl HasViewportPercentage for SpecifiedValue {