mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
style: Unship the legacy syntax for -moz-transform.
Intent to unship link: https://groups.google.com/d/msg/mozilla.dev.platform/T3PGm97MPNU/59XUavMlCgAJ Reviewed-by: xidorn Bug: 1438297 MozReview-Commit-ID: 6ybGBasPAWU
This commit is contained in:
parent
a98da8ce93
commit
7473796aba
8 changed files with 51 additions and 242 deletions
|
@ -866,23 +866,13 @@ impl PropertyDeclarationBlock {
|
||||||
};
|
};
|
||||||
|
|
||||||
// Substeps 7 and 8
|
// Substeps 7 and 8
|
||||||
// We need to check the shorthand whether it's an alias property or not.
|
append_serialization::<Cloned<slice::Iter< _>>, _>(
|
||||||
// If it's an alias property, it should be serialized like its longhand.
|
dest,
|
||||||
if shorthand.flags().contains(PropertyFlags::SHORTHAND_ALIAS_PROPERTY) {
|
&shorthand,
|
||||||
append_serialization::<Cloned<slice::Iter< _>>, _>(
|
value,
|
||||||
dest,
|
importance,
|
||||||
&property,
|
&mut is_first_serialization,
|
||||||
value,
|
)?;
|
||||||
importance,
|
|
||||||
&mut is_first_serialization)?;
|
|
||||||
} else {
|
|
||||||
append_serialization::<Cloned<slice::Iter< _>>, _>(
|
|
||||||
dest,
|
|
||||||
&shorthand,
|
|
||||||
value,
|
|
||||||
importance,
|
|
||||||
&mut is_first_serialization)?;
|
|
||||||
}
|
|
||||||
|
|
||||||
for current_longhand in ¤t_longhands {
|
for current_longhand in ¤t_longhands {
|
||||||
// Substep 9
|
// Substep 9
|
||||||
|
|
|
@ -968,10 +968,7 @@ def set_gecko_property(ffi_name, expr):
|
||||||
<%
|
<%
|
||||||
transform_functions = [
|
transform_functions = [
|
||||||
("Matrix3D", "matrix3d", ["number"] * 16),
|
("Matrix3D", "matrix3d", ["number"] * 16),
|
||||||
("PrefixedMatrix3D", "matrix3d", ["number"] * 12 + ["lopon"] * 2
|
|
||||||
+ ["lon"] + ["number"]),
|
|
||||||
("Matrix", "matrix", ["number"] * 6),
|
("Matrix", "matrix", ["number"] * 6),
|
||||||
("PrefixedMatrix", "matrix", ["number"] * 4 + ["lopon"] * 2),
|
|
||||||
("Translate", "translate", ["lop", "optional_lop"]),
|
("Translate", "translate", ["lop", "optional_lop"]),
|
||||||
("Translate3D", "translate3d", ["lop", "lop", "length"]),
|
("Translate3D", "translate3d", ["lop", "lop", "length"]),
|
||||||
("TranslateX", "translatex", ["lop"]),
|
("TranslateX", "translatex", ["lop"]),
|
||||||
|
@ -1027,8 +1024,6 @@ transform_functions = [
|
||||||
# need to cast it to f32.
|
# need to cast it to f32.
|
||||||
"integer_to_percentage" : "bindings::Gecko_CSSValue_SetPercentage(%s, %s as f32)",
|
"integer_to_percentage" : "bindings::Gecko_CSSValue_SetPercentage(%s, %s as f32)",
|
||||||
"lop" : "%s.set_lop(%s)",
|
"lop" : "%s.set_lop(%s)",
|
||||||
"lopon" : "set_lopon(%s, %s)",
|
|
||||||
"lon" : "set_lon(%s, %s)",
|
|
||||||
"angle" : "%s.set_angle(%s)",
|
"angle" : "%s.set_angle(%s)",
|
||||||
"number" : "bindings::Gecko_CSSValue_SetNumber(%s, %s)",
|
"number" : "bindings::Gecko_CSSValue_SetNumber(%s, %s)",
|
||||||
# Note: We use nsCSSValueSharedList here, instead of nsCSSValueList_heap
|
# Note: We use nsCSSValueSharedList here, instead of nsCSSValueList_heap
|
||||||
|
@ -1106,16 +1101,7 @@ transform_functions = [
|
||||||
field_names = ["from_list", "to_list", "count"]
|
field_names = ["from_list", "to_list", "count"]
|
||||||
|
|
||||||
%>
|
%>
|
||||||
<%
|
structs::nsCSSKeyword::eCSSKeyword_${keyword} => {
|
||||||
|
|
||||||
guard = ""
|
|
||||||
if name == "Matrix3D" or name == "Matrix":
|
|
||||||
guard = "if !needs_prefix "
|
|
||||||
elif name == "PrefixedMatrix3D" or name == "PrefixedMatrix":
|
|
||||||
guard = "if needs_prefix "
|
|
||||||
|
|
||||||
%>
|
|
||||||
structs::nsCSSKeyword::eCSSKeyword_${keyword} ${guard}=> {
|
|
||||||
::values::generics::transform::TransformOperation::${name}${pre_symbols}
|
::values::generics::transform::TransformOperation::${name}${pre_symbols}
|
||||||
% for index, item in enumerate(items):
|
% for index, item in enumerate(items):
|
||||||
% if keyword == "matrix3d":
|
% if keyword == "matrix3d":
|
||||||
|
@ -1149,7 +1135,6 @@ fn set_single_transform_function(
|
||||||
servo_value: &values::computed::TransformOperation,
|
servo_value: &values::computed::TransformOperation,
|
||||||
gecko_value: &mut structs::nsCSSValue /* output */
|
gecko_value: &mut structs::nsCSSValue /* output */
|
||||||
) {
|
) {
|
||||||
use values::computed::{Length, LengthOrNumber, LengthOrPercentage, LengthOrPercentageOrNumber};
|
|
||||||
use values::computed::TransformOperation;
|
use values::computed::TransformOperation;
|
||||||
use values::generics::transform::{Matrix, Matrix3D};
|
use values::generics::transform::{Matrix, Matrix3D};
|
||||||
|
|
||||||
|
@ -1159,22 +1144,6 @@ fn set_single_transform_function(
|
||||||
value
|
value
|
||||||
};
|
};
|
||||||
|
|
||||||
unsafe fn set_lopon(css: &mut structs::nsCSSValue, lopon: LengthOrPercentageOrNumber) {
|
|
||||||
let lop = match lopon {
|
|
||||||
Either::First(number) => LengthOrPercentage::Length(Length::new(number)),
|
|
||||||
Either::Second(lop) => lop,
|
|
||||||
};
|
|
||||||
css.set_lop(lop);
|
|
||||||
}
|
|
||||||
|
|
||||||
unsafe fn set_lon(css: &mut structs::nsCSSValue, lopon: LengthOrNumber) {
|
|
||||||
let length = match lopon {
|
|
||||||
Either::Second(number) => Length::new(number),
|
|
||||||
Either::First(l) => l,
|
|
||||||
};
|
|
||||||
bindings::Gecko_CSSValue_SetPixelLength(css, length.px())
|
|
||||||
}
|
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
match *servo_value {
|
match *servo_value {
|
||||||
% for servo, gecko, format in transform_functions:
|
% for servo, gecko, format in transform_functions:
|
||||||
|
@ -1228,19 +1197,6 @@ fn clone_single_transform_function(
|
||||||
bindings::Gecko_CSSValue_GetKeyword(bindings::Gecko_CSSValue_GetArrayItemConst(gecko_value, 0))
|
bindings::Gecko_CSSValue_GetKeyword(bindings::Gecko_CSSValue_GetArrayItemConst(gecko_value, 0))
|
||||||
};
|
};
|
||||||
|
|
||||||
let needs_prefix = if transform_function == structs::nsCSSKeyword::eCSSKeyword_matrix3d {
|
|
||||||
unsafe {
|
|
||||||
bindings::Gecko_CSSValue_GetArrayItemConst(gecko_value, 13).mUnit
|
|
||||||
!= structs::nsCSSUnit::eCSSUnit_Number ||
|
|
||||||
bindings::Gecko_CSSValue_GetArrayItemConst(gecko_value, 14).mUnit
|
|
||||||
!= structs::nsCSSUnit::eCSSUnit_Number ||
|
|
||||||
bindings::Gecko_CSSValue_GetArrayItemConst(gecko_value, 15).mUnit
|
|
||||||
!= structs::nsCSSUnit::eCSSUnit_Number
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
false
|
|
||||||
};
|
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
match transform_function {
|
match transform_function {
|
||||||
% for servo, gecko, format in transform_functions:
|
% for servo, gecko, format in transform_functions:
|
||||||
|
|
|
@ -395,7 +395,7 @@ ${helpers.predefined_type(
|
||||||
|
|
||||||
${helpers.predefined_type("transform", "Transform",
|
${helpers.predefined_type("transform", "Transform",
|
||||||
"generics::transform::Transform::none()",
|
"generics::transform::Transform::none()",
|
||||||
extra_prefixes="webkit",
|
extra_prefixes="webkit moz",
|
||||||
animation_value_type="ComputedValue",
|
animation_value_type="ComputedValue",
|
||||||
gecko_ffi_name="mSpecifiedTransform",
|
gecko_ffi_name="mSpecifiedTransform",
|
||||||
flags="CREATES_STACKING_CONTEXT FIXPOS_CB",
|
flags="CREATES_STACKING_CONTEXT FIXPOS_CB",
|
||||||
|
|
|
@ -793,14 +793,12 @@ bitflags! {
|
||||||
/// This property has values that can establish a containing block for
|
/// This property has values that can establish a containing block for
|
||||||
/// absolutely positioned elements.
|
/// absolutely positioned elements.
|
||||||
const ABSPOS_CB = 1 << 2;
|
const ABSPOS_CB = 1 << 2;
|
||||||
/// This shorthand property is an alias of another property.
|
|
||||||
const SHORTHAND_ALIAS_PROPERTY = 1 << 3;
|
|
||||||
/// This longhand property applies to ::first-letter.
|
/// This longhand property applies to ::first-letter.
|
||||||
const APPLIES_TO_FIRST_LETTER = 1 << 4;
|
const APPLIES_TO_FIRST_LETTER = 1 << 3;
|
||||||
/// This longhand property applies to ::first-line.
|
/// This longhand property applies to ::first-line.
|
||||||
const APPLIES_TO_FIRST_LINE = 1 << 5;
|
const APPLIES_TO_FIRST_LINE = 1 << 4;
|
||||||
/// This longhand property applies to ::placeholder.
|
/// This longhand property applies to ::placeholder.
|
||||||
const APPLIES_TO_PLACEHOLDER = 1 << 6;
|
const APPLIES_TO_PLACEHOLDER = 1 << 5;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1687,17 +1685,10 @@ impl ToCss for VariableDeclaration {
|
||||||
{
|
{
|
||||||
// https://drafts.csswg.org/css-variables/#variables-in-shorthands
|
// https://drafts.csswg.org/css-variables/#variables-in-shorthands
|
||||||
match self.value.from_shorthand {
|
match self.value.from_shorthand {
|
||||||
// Normally, we shouldn't be printing variables here if they came from
|
|
||||||
// shorthands. But we should allow properties that came from shorthand
|
|
||||||
// aliases. That also matches with the Gecko behavior.
|
|
||||||
// FIXME(emilio): This is just a hack for `-moz-transform`.
|
|
||||||
Some(shorthand) if shorthand.flags().contains(PropertyFlags::SHORTHAND_ALIAS_PROPERTY) => {
|
|
||||||
dest.write_str(&*self.value.css)?
|
|
||||||
}
|
|
||||||
None => {
|
None => {
|
||||||
dest.write_str(&*self.value.css)?
|
dest.write_str(&*self.value.css)?
|
||||||
}
|
}
|
||||||
_ => {},
|
Some(..) => {},
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -1768,20 +1759,11 @@ impl PropertyDeclaration {
|
||||||
fn with_variables_from_shorthand(&self, shorthand: ShorthandId) -> Option< &str> {
|
fn with_variables_from_shorthand(&self, shorthand: ShorthandId) -> Option< &str> {
|
||||||
match *self {
|
match *self {
|
||||||
PropertyDeclaration::WithVariables(ref declaration) => {
|
PropertyDeclaration::WithVariables(ref declaration) => {
|
||||||
if let Some(s) = declaration.value.from_shorthand {
|
let s = declaration.value.from_shorthand?;
|
||||||
if s == shorthand {
|
if s != shorthand {
|
||||||
Some(&*declaration.value.css)
|
return None;
|
||||||
} else { None }
|
|
||||||
} else {
|
|
||||||
// Normally, longhand property that doesn't come from a shorthand
|
|
||||||
// should return None here. But we return Some to longhands if they
|
|
||||||
// came from a shorthand alias. Because for example, we should be able to
|
|
||||||
// get -moz-transform's value from transform.
|
|
||||||
if shorthand.flags().contains(PropertyFlags::SHORTHAND_ALIAS_PROPERTY) {
|
|
||||||
return Some(&*declaration.value.css);
|
|
||||||
}
|
|
||||||
None
|
|
||||||
}
|
}
|
||||||
|
Some(&*declaration.value.css)
|
||||||
},
|
},
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
|
|
|
@ -392,7 +392,7 @@ macro_rules! try_parse_one {
|
||||||
spec="https://wicg.github.io/overscroll-behavior/#overscroll-behavior-properties">
|
spec="https://wicg.github.io/overscroll-behavior/#overscroll-behavior-properties">
|
||||||
pub fn parse_value<'i, 't>(
|
pub fn parse_value<'i, 't>(
|
||||||
_: &ParserContext,
|
_: &ParserContext,
|
||||||
input: &mut Parser<'i, 't>
|
input: &mut Parser<'i, 't>,
|
||||||
) -> Result<Longhands, ParseError<'i>> {
|
) -> Result<Longhands, ParseError<'i>> {
|
||||||
use values::specified::OverscrollBehavior;
|
use values::specified::OverscrollBehavior;
|
||||||
let behavior_x = OverscrollBehavior::parse(input)?;
|
let behavior_x = OverscrollBehavior::parse(input)?;
|
||||||
|
@ -416,18 +416,3 @@ macro_rules! try_parse_one {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</%helpers:shorthand>
|
</%helpers:shorthand>
|
||||||
|
|
||||||
<%helpers:shorthand name="-moz-transform" products="gecko"
|
|
||||||
sub_properties="transform"
|
|
||||||
gecko_pref="layout.css.prefixes.transforms"
|
|
||||||
flags="SHORTHAND_ALIAS_PROPERTY"
|
|
||||||
derive_serialize="True"
|
|
||||||
spec="Non-standard: https://developer.mozilla.org/en-US/docs/Web/CSS/transform">
|
|
||||||
pub fn parse_value<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>)
|
|
||||||
-> Result<Longhands, ParseError<'i>> {
|
|
||||||
use values::specified::transform::Transform;
|
|
||||||
Ok(expanded! {
|
|
||||||
transform: Transform::parse_prefixed(context, input)?,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
</%helpers:shorthand>
|
|
||||||
|
|
|
@ -6,10 +6,9 @@
|
||||||
|
|
||||||
use euclid::{Transform3D, Vector3D};
|
use euclid::{Transform3D, Vector3D};
|
||||||
use num_traits::Zero;
|
use num_traits::Zero;
|
||||||
use super::{CSSFloat, Either};
|
use super::CSSFloat;
|
||||||
use values::animated::ToAnimatedZero;
|
use values::animated::ToAnimatedZero;
|
||||||
use values::computed::{Angle, Integer, Length, LengthOrPercentage, Number, Percentage};
|
use values::computed::{Angle, Integer, Length, LengthOrPercentage, Number, Percentage};
|
||||||
use values::computed::{LengthOrNumber, LengthOrPercentageOrNumber};
|
|
||||||
use values::generics::transform::{self, Matrix as GenericMatrix, Matrix3D as GenericMatrix3D};
|
use values::generics::transform::{self, Matrix as GenericMatrix, Matrix3D as GenericMatrix3D};
|
||||||
use values::generics::transform::{Transform as GenericTransform, TransformOperation as GenericTransformOperation};
|
use values::generics::transform::{Transform as GenericTransform, TransformOperation as GenericTransformOperation};
|
||||||
use values::generics::transform::Rotate as GenericRotate;
|
use values::generics::transform::Rotate as GenericRotate;
|
||||||
|
@ -26,9 +25,7 @@ pub type TransformOperation = GenericTransformOperation<
|
||||||
Number,
|
Number,
|
||||||
Length,
|
Length,
|
||||||
Integer,
|
Integer,
|
||||||
LengthOrNumber,
|
|
||||||
LengthOrPercentage,
|
LengthOrPercentage,
|
||||||
LengthOrPercentageOrNumber,
|
|
||||||
>;
|
>;
|
||||||
/// A computed CSS `transform`
|
/// A computed CSS `transform`
|
||||||
pub type Transform = GenericTransform<TransformOperation>;
|
pub type Transform = GenericTransform<TransformOperation>;
|
||||||
|
@ -56,12 +53,8 @@ impl TransformOrigin {
|
||||||
|
|
||||||
/// computed value of matrix3d()
|
/// computed value of matrix3d()
|
||||||
pub type Matrix3D = GenericMatrix3D<Number>;
|
pub type Matrix3D = GenericMatrix3D<Number>;
|
||||||
/// computed value of matrix3d() in -moz-transform
|
|
||||||
pub type PrefixedMatrix3D = GenericMatrix3D<Number, LengthOrPercentageOrNumber, LengthOrNumber>;
|
|
||||||
/// computed value of matrix()
|
/// computed value of matrix()
|
||||||
pub type Matrix = GenericMatrix<Number>;
|
pub type Matrix = GenericMatrix<Number>;
|
||||||
/// computed value of matrix() in -moz-transform
|
|
||||||
pub type PrefixedMatrix = GenericMatrix<Number, LengthOrPercentageOrNumber>;
|
|
||||||
|
|
||||||
// we rustfmt_skip here because we want the matrices to look like
|
// we rustfmt_skip here because we want the matrices to look like
|
||||||
// matrices instead of being split across lines
|
// matrices instead of being split across lines
|
||||||
|
@ -95,21 +88,6 @@ impl Matrix3D {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(rustfmt, rustfmt_skip)]
|
|
||||||
impl PrefixedMatrix3D {
|
|
||||||
#[inline]
|
|
||||||
/// Get an identity matrix
|
|
||||||
pub fn identity() -> Self {
|
|
||||||
Self {
|
|
||||||
m11: 1.0, m12: 0.0, m13: 0.0, m14: 0.0,
|
|
||||||
m21: 0.0, m22: 1.0, m23: 0.0, m24: 0.0,
|
|
||||||
m31: 0.0, m32: 0.0, m33: 1.0, m34: 0.0,
|
|
||||||
m41: Either::First(0.), m42: Either::First(0.),
|
|
||||||
m43: Either::First(Length::new(0.)), m44: 1.0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg_attr(rustfmt, rustfmt_skip)]
|
#[cfg_attr(rustfmt, rustfmt_skip)]
|
||||||
impl Matrix {
|
impl Matrix {
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -136,20 +114,6 @@ impl From<Matrix> for Matrix3D {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(rustfmt, rustfmt_skip)]
|
|
||||||
impl PrefixedMatrix {
|
|
||||||
#[inline]
|
|
||||||
/// Get an identity matrix
|
|
||||||
pub fn identity() -> Self {
|
|
||||||
Self {
|
|
||||||
a: 1., c: 0., /* 0 0 */
|
|
||||||
b: 0., d: 1., /* 0 0 */
|
|
||||||
/* 0 0 1 0 */
|
|
||||||
e: Either::First(0.), f: Either::First(0.), /* 0 1 */
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg_attr(rustfmt, rustfmt_skip)]
|
#[cfg_attr(rustfmt, rustfmt_skip)]
|
||||||
impl From<Transform3D<CSSFloat>> for Matrix3D {
|
impl From<Transform3D<CSSFloat>> for Matrix3D {
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -213,17 +177,7 @@ impl ToAnimatedZero for TransformOperation {
|
||||||
fn to_animated_zero(&self) -> Result<Self, ()> {
|
fn to_animated_zero(&self) -> Result<Self, ()> {
|
||||||
match *self {
|
match *self {
|
||||||
GenericTransformOperation::Matrix3D(..) => Ok(GenericTransformOperation::Matrix3D(Matrix3D::identity())),
|
GenericTransformOperation::Matrix3D(..) => Ok(GenericTransformOperation::Matrix3D(Matrix3D::identity())),
|
||||||
GenericTransformOperation::PrefixedMatrix3D(..) => {
|
|
||||||
Ok(GenericTransformOperation::PrefixedMatrix3D(
|
|
||||||
PrefixedMatrix3D::identity(),
|
|
||||||
))
|
|
||||||
},
|
|
||||||
GenericTransformOperation::Matrix(..) => Ok(GenericTransformOperation::Matrix(Matrix::identity())),
|
GenericTransformOperation::Matrix(..) => Ok(GenericTransformOperation::Matrix(Matrix::identity())),
|
||||||
GenericTransformOperation::PrefixedMatrix(..) => {
|
|
||||||
Ok(GenericTransformOperation::PrefixedMatrix(
|
|
||||||
PrefixedMatrix::identity(),
|
|
||||||
))
|
|
||||||
},
|
|
||||||
GenericTransformOperation::Skew(sx, sy) => {
|
GenericTransformOperation::Skew(sx, sy) => {
|
||||||
Ok(GenericTransformOperation::Skew(
|
Ok(GenericTransformOperation::Skew(
|
||||||
sx.to_animated_zero()?,
|
sx.to_animated_zero()?,
|
||||||
|
|
|
@ -19,24 +19,24 @@ use values::specified::length::LengthOrPercentage as SpecifiedLengthOrPercentage
|
||||||
#[allow(missing_docs)]
|
#[allow(missing_docs)]
|
||||||
#[derive(Clone, Copy, Debug, MallocSizeOf, PartialEq, ToComputedValue, ToCss)]
|
#[derive(Clone, Copy, Debug, MallocSizeOf, PartialEq, ToComputedValue, ToCss)]
|
||||||
#[css(comma, function)]
|
#[css(comma, function)]
|
||||||
pub struct Matrix<T, U = T> {
|
pub struct Matrix<T> {
|
||||||
pub a: T,
|
pub a: T,
|
||||||
pub b: T,
|
pub b: T,
|
||||||
pub c: T,
|
pub c: T,
|
||||||
pub d: T,
|
pub d: T,
|
||||||
pub e: U,
|
pub e: T,
|
||||||
pub f: U,
|
pub f: T,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(missing_docs)]
|
#[allow(missing_docs)]
|
||||||
#[cfg_attr(rustfmt, rustfmt_skip)]
|
#[cfg_attr(rustfmt, rustfmt_skip)]
|
||||||
#[css(comma, function = "matrix3d")]
|
#[css(comma, function = "matrix3d")]
|
||||||
#[derive(Clone, Copy, Debug, MallocSizeOf, PartialEq, ToComputedValue, ToCss)]
|
#[derive(Clone, Copy, Debug, MallocSizeOf, PartialEq, ToComputedValue, ToCss)]
|
||||||
pub struct Matrix3D<T, U = T, V = T> {
|
pub struct Matrix3D<T> {
|
||||||
pub m11: T, pub m12: T, pub m13: T, pub m14: T,
|
pub m11: T, pub m12: T, pub m13: T, pub m14: T,
|
||||||
pub m21: T, pub m22: T, pub m23: T, pub m24: T,
|
pub m21: T, pub m22: T, pub m23: T, pub m24: T,
|
||||||
pub m31: T, pub m32: T, pub m33: T, pub m34: T,
|
pub m31: T, pub m32: T, pub m33: T, pub m34: T,
|
||||||
pub m41: U, pub m42: U, pub m43: V, pub m44: T,
|
pub m41: T, pub m42: T, pub m43: T, pub m44: T,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(rustfmt, rustfmt_skip)]
|
#[cfg_attr(rustfmt, rustfmt_skip)]
|
||||||
|
@ -200,17 +200,11 @@ impl TimingKeyword {
|
||||||
|
|
||||||
#[derive(Clone, Debug, MallocSizeOf, PartialEq, ToComputedValue, ToCss)]
|
#[derive(Clone, Debug, MallocSizeOf, PartialEq, ToComputedValue, ToCss)]
|
||||||
/// A single operation in the list of a `transform` value
|
/// A single operation in the list of a `transform` value
|
||||||
pub enum TransformOperation<Angle, Number, Length, Integer, LengthOrNumber, LengthOrPercentage, LoPoNumber> {
|
pub enum TransformOperation<Angle, Number, Length, Integer, LengthOrPercentage> {
|
||||||
/// Represents a 2D 2x3 matrix.
|
/// Represents a 2D 2x3 matrix.
|
||||||
Matrix(Matrix<Number>),
|
Matrix(Matrix<Number>),
|
||||||
/// Represents a 3D 4x4 matrix with percentage and length values.
|
|
||||||
/// For `moz-transform`.
|
|
||||||
PrefixedMatrix(Matrix<Number, LoPoNumber>),
|
|
||||||
/// Represents a 3D 4x4 matrix.
|
/// Represents a 3D 4x4 matrix.
|
||||||
Matrix3D(Matrix3D<Number>),
|
Matrix3D(Matrix3D<Number>),
|
||||||
/// Represents a 3D 4x4 matrix with percentage and length values.
|
|
||||||
/// For `moz-transform`.
|
|
||||||
PrefixedMatrix3D(Matrix3D<Number, LoPoNumber, LengthOrNumber>),
|
|
||||||
/// A 2D skew.
|
/// A 2D skew.
|
||||||
///
|
///
|
||||||
/// If the second angle is not provided it is assumed zero.
|
/// If the second angle is not provided it is assumed zero.
|
||||||
|
@ -300,9 +294,7 @@ pub enum TransformOperation<Angle, Number, Length, Integer, LengthOrNumber, Leng
|
||||||
Number,
|
Number,
|
||||||
Length,
|
Length,
|
||||||
Integer,
|
Integer,
|
||||||
LengthOrNumber,
|
|
||||||
LengthOrPercentage,
|
LengthOrPercentage,
|
||||||
LoPoNumber,
|
|
||||||
>,
|
>,
|
||||||
>,
|
>,
|
||||||
#[compute(ignore_bound)]
|
#[compute(ignore_bound)]
|
||||||
|
@ -313,9 +305,7 @@ pub enum TransformOperation<Angle, Number, Length, Integer, LengthOrNumber, Leng
|
||||||
Number,
|
Number,
|
||||||
Length,
|
Length,
|
||||||
Integer,
|
Integer,
|
||||||
LengthOrNumber,
|
|
||||||
LengthOrPercentage,
|
LengthOrPercentage,
|
||||||
LoPoNumber,
|
|
||||||
>,
|
>,
|
||||||
>,
|
>,
|
||||||
#[compute(clone)]
|
#[compute(clone)]
|
||||||
|
@ -333,9 +323,7 @@ pub enum TransformOperation<Angle, Number, Length, Integer, LengthOrNumber, Leng
|
||||||
Number,
|
Number,
|
||||||
Length,
|
Length,
|
||||||
Integer,
|
Integer,
|
||||||
LengthOrNumber,
|
|
||||||
LengthOrPercentage,
|
LengthOrPercentage,
|
||||||
LoPoNumber,
|
|
||||||
>,
|
>,
|
||||||
>,
|
>,
|
||||||
#[compute(ignore_bound)]
|
#[compute(ignore_bound)]
|
||||||
|
@ -346,9 +334,7 @@ pub enum TransformOperation<Angle, Number, Length, Integer, LengthOrNumber, Leng
|
||||||
Number,
|
Number,
|
||||||
Length,
|
Length,
|
||||||
Integer,
|
Integer,
|
||||||
LengthOrNumber,
|
|
||||||
LengthOrPercentage,
|
LengthOrPercentage,
|
||||||
LoPoNumber,
|
|
||||||
>,
|
>,
|
||||||
>,
|
>,
|
||||||
count: Integer,
|
count: Integer,
|
||||||
|
@ -360,8 +346,8 @@ pub enum TransformOperation<Angle, Number, Length, Integer, LengthOrNumber, Leng
|
||||||
/// A value of the `transform` property
|
/// A value of the `transform` property
|
||||||
pub struct Transform<T>(pub Vec<T>);
|
pub struct Transform<T>(pub Vec<T>);
|
||||||
|
|
||||||
impl<Angle, Number, Length, Integer, LengthOrNumber, LengthOrPercentage, LoPoNumber>
|
impl<Angle, Number, Length, Integer, LengthOrPercentage>
|
||||||
TransformOperation<Angle, Number, Length, Integer, LengthOrNumber, LengthOrPercentage, LoPoNumber> {
|
TransformOperation<Angle, Number, Length, Integer, LengthOrPercentage> {
|
||||||
/// Check if it is any translate function
|
/// Check if it is any translate function
|
||||||
pub fn is_translate(&self) -> bool {
|
pub fn is_translate(&self) -> bool {
|
||||||
use self::TransformOperation::*;
|
use self::TransformOperation::*;
|
||||||
|
@ -450,8 +436,8 @@ pub trait ToMatrix {
|
||||||
fn to_3d_matrix(&self, reference_box: Option<&Rect<Au>>) -> Result<Transform3D<f64>, ()>;
|
fn to_3d_matrix(&self, reference_box: Option<&Rect<Au>>) -> Result<Transform3D<f64>, ()>;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Angle, Number, Length, Integer, LoN, LoP, LoPoNumber> ToMatrix
|
impl<Angle, Number, Length, Integer, LoP> ToMatrix
|
||||||
for TransformOperation<Angle, Number, Length, Integer, LoN, LoP, LoPoNumber>
|
for TransformOperation<Angle, Number, Length, Integer, LoP>
|
||||||
where
|
where
|
||||||
Angle: Copy + AsRef<computed::angle::Angle>,
|
Angle: Copy + AsRef<computed::angle::Angle>,
|
||||||
Number: Copy + Into<f32> + Into<f64>,
|
Number: Copy + Into<f32> + Into<f64>,
|
||||||
|
@ -464,8 +450,7 @@ where
|
||||||
match *self {
|
match *self {
|
||||||
Translate3D(..) | TranslateZ(..) |
|
Translate3D(..) | TranslateZ(..) |
|
||||||
Rotate3D(..) | RotateX(..) | RotateY(..) | RotateZ(..) |
|
Rotate3D(..) | RotateX(..) | RotateY(..) | RotateZ(..) |
|
||||||
Scale3D(..) | ScaleZ(..) |
|
Scale3D(..) | ScaleZ(..) | Perspective(..) | Matrix3D(..) => true,
|
||||||
Perspective(..) | Matrix3D(..) | PrefixedMatrix3D(..) => true,
|
|
||||||
_ => false,
|
_ => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -553,10 +538,6 @@ where
|
||||||
},
|
},
|
||||||
Matrix3D(m) => m.into(),
|
Matrix3D(m) => m.into(),
|
||||||
Matrix(m) => m.into(),
|
Matrix(m) => m.into(),
|
||||||
PrefixedMatrix3D(_) | PrefixedMatrix(_) => {
|
|
||||||
unreachable!("-moz-transform` is not implemented in Servo yet, and DOMMatrix \
|
|
||||||
doesn't support this")
|
|
||||||
},
|
|
||||||
InterpolateMatrix { .. } | AccumulateMatrix { .. } => {
|
InterpolateMatrix { .. } | AccumulateMatrix { .. } => {
|
||||||
// TODO: Convert InterpolateMatrix/AccumulateMatrix into a valid Transform3D by
|
// TODO: Convert InterpolateMatrix/AccumulateMatrix into a valid Transform3D by
|
||||||
// the reference box and do interpolation on these two Transform3D matrices.
|
// the reference box and do interpolation on these two Transform3D matrices.
|
||||||
|
|
|
@ -18,8 +18,7 @@ use values::generics::transform::Rotate as GenericRotate;
|
||||||
use values::generics::transform::Scale as GenericScale;
|
use values::generics::transform::Scale as GenericScale;
|
||||||
use values::generics::transform::TransformOperation as GenericTransformOperation;
|
use values::generics::transform::TransformOperation as GenericTransformOperation;
|
||||||
use values::generics::transform::Translate as GenericTranslate;
|
use values::generics::transform::Translate as GenericTranslate;
|
||||||
use values::specified::{self, Angle, Number, Length, Integer};
|
use values::specified::{self, Angle, Number, Length, Integer, LengthOrPercentage};
|
||||||
use values::specified::{LengthOrNumber, LengthOrPercentage, LengthOrPercentageOrNumber};
|
|
||||||
use values::specified::position::{Side, X, Y};
|
use values::specified::position::{Side, X, Y};
|
||||||
|
|
||||||
pub use values::generics::transform::TransformStyle;
|
pub use values::generics::transform::TransformStyle;
|
||||||
|
@ -30,9 +29,7 @@ pub type TransformOperation = GenericTransformOperation<
|
||||||
Number,
|
Number,
|
||||||
Length,
|
Length,
|
||||||
Integer,
|
Integer,
|
||||||
LengthOrNumber,
|
|
||||||
LengthOrPercentage,
|
LengthOrPercentage,
|
||||||
LengthOrPercentageOrNumber,
|
|
||||||
>;
|
>;
|
||||||
|
|
||||||
/// A specified CSS `transform`
|
/// A specified CSS `transform`
|
||||||
|
@ -49,7 +46,6 @@ impl Transform {
|
||||||
fn parse_internal<'i, 't>(
|
fn parse_internal<'i, 't>(
|
||||||
context: &ParserContext,
|
context: &ParserContext,
|
||||||
input: &mut Parser<'i, 't>,
|
input: &mut Parser<'i, 't>,
|
||||||
prefixed: bool,
|
|
||||||
) -> Result<Self, ParseError<'i>> {
|
) -> Result<Self, ParseError<'i>> {
|
||||||
use style_traits::{Separator, Space};
|
use style_traits::{Separator, Space};
|
||||||
|
|
||||||
|
@ -75,19 +71,11 @@ impl Transform {
|
||||||
input.expect_comma()?;
|
input.expect_comma()?;
|
||||||
let d = Number::parse(context, input)?;
|
let d = Number::parse(context, input)?;
|
||||||
input.expect_comma()?;
|
input.expect_comma()?;
|
||||||
if !prefixed {
|
// Standard matrix parsing.
|
||||||
// Standard matrix parsing.
|
let e = Number::parse(context, input)?;
|
||||||
let e = Number::parse(context, input)?;
|
input.expect_comma()?;
|
||||||
input.expect_comma()?;
|
let f = Number::parse(context, input)?;
|
||||||
let f = Number::parse(context, input)?;
|
Ok(GenericTransformOperation::Matrix(Matrix { a, b, c, d, e, f }))
|
||||||
Ok(GenericTransformOperation::Matrix(Matrix { a, b, c, d, e, f }))
|
|
||||||
} else {
|
|
||||||
// Non-standard prefixed matrix parsing for -moz-transform.
|
|
||||||
let e = LengthOrPercentageOrNumber::parse(context, input)?;
|
|
||||||
input.expect_comma()?;
|
|
||||||
let f = LengthOrPercentageOrNumber::parse(context, input)?;
|
|
||||||
Ok(GenericTransformOperation::PrefixedMatrix(Matrix { a, b, c, d, e, f }))
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"matrix3d" => {
|
"matrix3d" => {
|
||||||
let m11 = Number::parse(context, input)?;
|
let m11 = Number::parse(context, input)?;
|
||||||
|
@ -114,37 +102,20 @@ impl Transform {
|
||||||
input.expect_comma()?;
|
input.expect_comma()?;
|
||||||
let m34 = Number::parse(context, input)?;
|
let m34 = Number::parse(context, input)?;
|
||||||
input.expect_comma()?;
|
input.expect_comma()?;
|
||||||
if !prefixed {
|
// Standard matrix3d parsing.
|
||||||
// Standard matrix3d parsing.
|
let m41 = Number::parse(context, input)?;
|
||||||
let m41 = Number::parse(context, input)?;
|
input.expect_comma()?;
|
||||||
input.expect_comma()?;
|
let m42 = Number::parse(context, input)?;
|
||||||
let m42 = Number::parse(context, input)?;
|
input.expect_comma()?;
|
||||||
input.expect_comma()?;
|
let m43 = Number::parse(context, input)?;
|
||||||
let m43 = Number::parse(context, input)?;
|
input.expect_comma()?;
|
||||||
input.expect_comma()?;
|
let m44 = Number::parse(context, input)?;
|
||||||
let m44 = Number::parse(context, input)?;
|
Ok(GenericTransformOperation::Matrix3D(Matrix3D {
|
||||||
Ok(GenericTransformOperation::Matrix3D(Matrix3D {
|
m11, m12, m13, m14,
|
||||||
m11, m12, m13, m14,
|
m21, m22, m23, m24,
|
||||||
m21, m22, m23, m24,
|
m31, m32, m33, m34,
|
||||||
m31, m32, m33, m34,
|
m41, m42, m43, m44,
|
||||||
m41, m42, m43, m44,
|
}))
|
||||||
}))
|
|
||||||
} else {
|
|
||||||
// Non-standard prefixed matrix parsing for -moz-transform.
|
|
||||||
let m41 = LengthOrPercentageOrNumber::parse(context, input)?;
|
|
||||||
input.expect_comma()?;
|
|
||||||
let m42 = LengthOrPercentageOrNumber::parse(context, input)?;
|
|
||||||
input.expect_comma()?;
|
|
||||||
let m43 = LengthOrNumber::parse(context, input)?;
|
|
||||||
input.expect_comma()?;
|
|
||||||
let m44 = Number::parse(context, input)?;
|
|
||||||
Ok(GenericTransformOperation::PrefixedMatrix3D(Matrix3D {
|
|
||||||
m11, m12, m13, m14,
|
|
||||||
m21, m22, m23, m24,
|
|
||||||
m31, m32, m33, m34,
|
|
||||||
m41, m42, m43, m44,
|
|
||||||
}))
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"translate" => {
|
"translate" => {
|
||||||
let sx = specified::LengthOrPercentage::parse(context, input)?;
|
let sx = specified::LengthOrPercentage::parse(context, input)?;
|
||||||
|
@ -259,16 +230,6 @@ impl Transform {
|
||||||
})
|
})
|
||||||
})?))
|
})?))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Parses `-moz-transform` property. This prefixed property also accepts LengthOrPercentage
|
|
||||||
/// in the nondiagonal homogeneous components of matrix and matrix3d.
|
|
||||||
#[inline]
|
|
||||||
pub fn parse_prefixed<'i, 't>(
|
|
||||||
context: &ParserContext,
|
|
||||||
input: &mut Parser<'i, 't>,
|
|
||||||
) -> Result<Self, ParseError<'i>> {
|
|
||||||
Transform::parse_internal(context, input, true)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Parse for Transform {
|
impl Parse for Transform {
|
||||||
|
@ -276,7 +237,7 @@ impl Parse for Transform {
|
||||||
context: &ParserContext,
|
context: &ParserContext,
|
||||||
input: &mut Parser<'i, 't>
|
input: &mut Parser<'i, 't>
|
||||||
) -> Result<Self, ParseError<'i>> {
|
) -> Result<Self, ParseError<'i>> {
|
||||||
Transform::parse_internal(context, input, false)
|
Transform::parse_internal(context, input)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue