diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2016-09-22 23:14:48 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-09-22 23:14:48 -0500 |
commit | fb52bb7c8d70f0d7b85bb35d89779d83a25f2bc2 (patch) | |
tree | a9fb7e6f2fa4d702ac36b8bd30177f0cd5d48a2a /components/style/values/specified/mod.rs | |
parent | ee3f916b652ad99e5925f574e7fa074dd3be9ad9 (diff) | |
parent | d81c6af59c99bb067d838592239a7887c1aa7203 (diff) | |
download | servo-fb52bb7c8d70f0d7b85bb35d89779d83a25f2bc2.tar.gz servo-fb52bb7c8d70f0d7b85bb35d89779d83a25f2bc2.zip |
Auto merge of #13228 - Manishearth:uncompute, r=heycam
Add uncompute functionality (WIP)
As discussed in Taipei we plan to do animations in Stylo on the Rust side. For cascading properly, we need to "uncompute" these,
i.e. convert them into a cascadeable specified value which when computed gets us the same thing again.
This patch starts work on this. Before writing uncompute code for everything, I'd like to check that this is an acceptable amount of mako magic,
and that the general design is okay (to avoid having to rewrite everything once it's done).
Preliminary r? @SimonSapin @birtles
<!-- 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/13228)
<!-- Reviewable:end -->
Diffstat (limited to 'components/style/values/specified/mod.rs')
-rw-r--r-- | components/style/values/specified/mod.rs | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/components/style/values/specified/mod.rs b/components/style/values/specified/mod.rs index 14cd7cccd0e..64c66ccc729 100644 --- a/components/style/values/specified/mod.rs +++ b/components/style/values/specified/mod.rs @@ -17,7 +17,7 @@ use std::fmt; use std::ops::Mul; use style_traits::values::specified::AllowedNumericType; use super::{CSSFloat, FONT_MEDIUM_PX, HasViewportPercentage, LocalToCss, NoViewportPercentage}; -use super::computed::{self, Context, ToComputedValue}; +use super::computed::{self, ComputedValueAsSpecified, Context, ToComputedValue}; use url::Url; pub mod basic_shape; @@ -456,7 +456,7 @@ enum CalcUnit { Time, } -#[derive(Clone, PartialEq, Copy, Debug)] +#[derive(Clone, PartialEq, Copy, Debug, Default)] #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub struct CalcLengthOrPercentage { pub absolute: Option<Au>, @@ -1525,14 +1525,7 @@ impl Time { } } -impl ToComputedValue for Time { - type ComputedValue = Time; - - #[inline] - fn to_computed_value(&self, _: &Context) -> Time { - *self - } -} +impl ComputedValueAsSpecified for Time {} impl ToCss for Time { fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write { @@ -1572,6 +1565,11 @@ impl ToComputedValue for Number { #[inline] fn to_computed_value(&self, _: &Context) -> CSSFloat { self.0 } + + #[inline] + fn from_computed_value(computed: &CSSFloat) -> Self { + Number(*computed) + } } impl ToCss for Number { @@ -1605,6 +1603,11 @@ impl ToComputedValue for Opacity { self.0 } } + + #[inline] + fn from_computed_value(computed: &CSSFloat) -> Self { + Opacity(*computed) + } } impl ToCss for Opacity { |