style: Remove Options from TransformOperation.

This may or may not be part of the plan to get rid of nsCSSValue ;)

Option is not usable via FFI, and they should not be needed (we should be
following the shortest serialization principle instead). These patches also do
that, which matches the other transform properties. I think that slight change
is fine, if we can make it work, and consistent with other properties.

Alternative is adding more TransformOperation variants or such, which I rather
not do.

Differential Revision: https://phabricator.services.mozilla.com/D21862
This commit is contained in:
Emilio Cobos Álvarez 2019-03-03 11:31:54 +00:00
parent 1418ddc685
commit c16e88d229
6 changed files with 78 additions and 100 deletions

View file

@ -9,6 +9,7 @@ use crate::values::computed::angle::Angle as ComputedAngle;
use crate::values::computed::{Context, ToComputedValue};
use crate::values::specified::calc::CalcNode;
use crate::values::CSSFloat;
use crate::Zero;
use cssparser::{Parser, Token};
use std::f32::consts::PI;
use std::fmt::{self, Write};
@ -32,6 +33,21 @@ pub enum AngleDimension {
Turn(CSSFloat),
}
impl Zero for AngleDimension {
fn zero() -> Self {
AngleDimension::Deg(0.)
}
fn is_zero(&self) -> bool {
match *self {
AngleDimension::Deg(ref f) |
AngleDimension::Grad(ref f) |
AngleDimension::Rad(ref f) |
AngleDimension::Turn(ref f) => *f == 0.,
}
}
}
impl AngleDimension {
/// Returns the amount of degrees this angle represents.
#[inline]
@ -58,6 +74,19 @@ pub struct Angle {
was_calc: bool,
}
impl Zero for Angle {
fn zero() -> Self {
Self {
value: Zero::zero(),
was_calc: false,
}
}
fn is_zero(&self) -> bool {
self.value.is_zero()
}
}
impl ToCss for Angle {
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
where