Auto merge of #20072 - emilio:moz-transform, r=xidorn

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

<!-- 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/20072)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2018-02-19 05:46:16 -05:00 committed by GitHub
commit 6afdf7c1cb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 114 additions and 295 deletions

View file

@ -911,6 +911,8 @@ pub mod root {
}
pub type pair_first_type<_T1> = _T1;
pub type pair_second_type<_T2> = _T2;
pub type pair__PCCP = u8;
pub type pair__PCCFP = u8;
#[repr(C)]
#[derive(Debug, Copy)]
pub struct input_iterator_tag {
@ -968,6 +970,14 @@ pub mod root {
#[allow(unused_imports)]
use self::super::super::root;
}
pub type __int8_t = ::std::os::raw::c_schar;
pub type __uint8_t = ::std::os::raw::c_uchar;
pub type __int16_t = ::std::os::raw::c_short;
pub type __uint16_t = ::std::os::raw::c_ushort;
pub type __int32_t = ::std::os::raw::c_int;
pub type __uint32_t = ::std::os::raw::c_uint;
pub type __int64_t = ::std::os::raw::c_long;
pub type __uint64_t = ::std::os::raw::c_ulong;
pub mod mozilla {
#[allow(unused_imports)]
use self::super::super::root;
@ -8261,7 +8271,6 @@ pub mod root {
pub const SERVO_PREF_ENABLED__moz_top_layer: bool = false;
pub const SERVO_PREF_ENABLED_touch_action: bool = true;
pub const SERVO_PREF_ENABLED_transform: bool = false;
pub const SERVO_PREF_ENABLED__moz_transform: bool = true;
pub const SERVO_PREF_ENABLED_transform_box: bool = true;
pub const SERVO_PREF_ENABLED_transform_origin: bool = false;
pub const SERVO_PREF_ENABLED_transform_style: bool = false;
@ -8293,6 +8302,7 @@ pub mod root {
pub const SERVO_PREF_ENABLED_writing_mode: bool = false;
pub const SERVO_PREF_ENABLED_z_index: bool = false;
pub const SERVO_PREF_ENABLED_word_wrap: bool = false;
pub const SERVO_PREF_ENABLED__moz_transform: bool = true;
pub const SERVO_PREF_ENABLED__moz_transform_origin: bool = true;
pub const SERVO_PREF_ENABLED__moz_perspective_origin: bool = true;
pub const SERVO_PREF_ENABLED__moz_perspective: bool = true;
@ -17629,31 +17639,31 @@ pub mod root {
pub struct RawServoSelectorList {
_unused: [u8; 0],
}
pub const NODE_HAS_LISTENERMANAGER: root::_bindgen_ty_83 = 4;
pub const NODE_HAS_PROPERTIES: root::_bindgen_ty_83 = 8;
pub const NODE_IS_ANONYMOUS_ROOT: root::_bindgen_ty_83 = 16;
pub const NODE_IS_IN_NATIVE_ANONYMOUS_SUBTREE: root::_bindgen_ty_83 = 32;
pub const NODE_IS_NATIVE_ANONYMOUS_ROOT: root::_bindgen_ty_83 = 64;
pub const NODE_FORCE_XBL_BINDINGS: root::_bindgen_ty_83 = 128;
pub const NODE_MAY_BE_IN_BINDING_MNGR: root::_bindgen_ty_83 = 256;
pub const NODE_IS_EDITABLE: root::_bindgen_ty_83 = 512;
pub const NODE_IS_NATIVE_ANONYMOUS: root::_bindgen_ty_83 = 1024;
pub const NODE_IS_IN_SHADOW_TREE: root::_bindgen_ty_83 = 2048;
pub const NODE_HAS_EMPTY_SELECTOR: root::_bindgen_ty_83 = 4096;
pub const NODE_HAS_SLOW_SELECTOR: root::_bindgen_ty_83 = 8192;
pub const NODE_HAS_EDGE_CHILD_SELECTOR: root::_bindgen_ty_83 = 16384;
pub const NODE_HAS_SLOW_SELECTOR_LATER_SIBLINGS: root::_bindgen_ty_83 = 32768;
pub const NODE_ALL_SELECTOR_FLAGS: root::_bindgen_ty_83 = 61440;
pub const NODE_NEEDS_FRAME: root::_bindgen_ty_83 = 65536;
pub const NODE_DESCENDANTS_NEED_FRAMES: root::_bindgen_ty_83 = 131072;
pub const NODE_HAS_ACCESSKEY: root::_bindgen_ty_83 = 262144;
pub const NODE_HAS_DIRECTION_RTL: root::_bindgen_ty_83 = 524288;
pub const NODE_HAS_DIRECTION_LTR: root::_bindgen_ty_83 = 1048576;
pub const NODE_ALL_DIRECTION_FLAGS: root::_bindgen_ty_83 = 1572864;
pub const NODE_CHROME_ONLY_ACCESS: root::_bindgen_ty_83 = 2097152;
pub const NODE_IS_ROOT_OF_CHROME_ONLY_ACCESS: root::_bindgen_ty_83 = 4194304;
pub const NODE_TYPE_SPECIFIC_BITS_OFFSET: root::_bindgen_ty_83 = 21;
pub type _bindgen_ty_83 = u32;
pub const NODE_HAS_LISTENERMANAGER: root::_bindgen_ty_77 = 4;
pub const NODE_HAS_PROPERTIES: root::_bindgen_ty_77 = 8;
pub const NODE_IS_ANONYMOUS_ROOT: root::_bindgen_ty_77 = 16;
pub const NODE_IS_IN_NATIVE_ANONYMOUS_SUBTREE: root::_bindgen_ty_77 = 32;
pub const NODE_IS_NATIVE_ANONYMOUS_ROOT: root::_bindgen_ty_77 = 64;
pub const NODE_FORCE_XBL_BINDINGS: root::_bindgen_ty_77 = 128;
pub const NODE_MAY_BE_IN_BINDING_MNGR: root::_bindgen_ty_77 = 256;
pub const NODE_IS_EDITABLE: root::_bindgen_ty_77 = 512;
pub const NODE_IS_NATIVE_ANONYMOUS: root::_bindgen_ty_77 = 1024;
pub const NODE_IS_IN_SHADOW_TREE: root::_bindgen_ty_77 = 2048;
pub const NODE_HAS_EMPTY_SELECTOR: root::_bindgen_ty_77 = 4096;
pub const NODE_HAS_SLOW_SELECTOR: root::_bindgen_ty_77 = 8192;
pub const NODE_HAS_EDGE_CHILD_SELECTOR: root::_bindgen_ty_77 = 16384;
pub const NODE_HAS_SLOW_SELECTOR_LATER_SIBLINGS: root::_bindgen_ty_77 = 32768;
pub const NODE_ALL_SELECTOR_FLAGS: root::_bindgen_ty_77 = 61440;
pub const NODE_NEEDS_FRAME: root::_bindgen_ty_77 = 65536;
pub const NODE_DESCENDANTS_NEED_FRAMES: root::_bindgen_ty_77 = 131072;
pub const NODE_HAS_ACCESSKEY: root::_bindgen_ty_77 = 262144;
pub const NODE_HAS_DIRECTION_RTL: root::_bindgen_ty_77 = 524288;
pub const NODE_HAS_DIRECTION_LTR: root::_bindgen_ty_77 = 1048576;
pub const NODE_ALL_DIRECTION_FLAGS: root::_bindgen_ty_77 = 1572864;
pub const NODE_CHROME_ONLY_ACCESS: root::_bindgen_ty_77 = 2097152;
pub const NODE_IS_ROOT_OF_CHROME_ONLY_ACCESS: root::_bindgen_ty_77 = 4194304;
pub const NODE_TYPE_SPECIFIC_BITS_OFFSET: root::_bindgen_ty_77 = 21;
pub type _bindgen_ty_77 = u32;
/// An internal interface that abstracts some DOMNode-related parts that both
/// nsIContent and nsIDocument share. An instance of this interface has a list
/// of nsIContent children and provides access to them.
@ -21516,9 +21526,9 @@ pub mod root {
eCSSProperty_text_decoration = 371,
eCSSProperty_text_emphasis = 372,
eCSSProperty__webkit_text_stroke = 373,
eCSSProperty__moz_transform = 374,
eCSSProperty_transition = 375,
eCSSPropertyAlias_WordWrap = 376,
eCSSProperty_transition = 374,
eCSSPropertyAlias_WordWrap = 375,
eCSSPropertyAlias_MozTransform = 376,
eCSSPropertyAlias_MozTransformOrigin = 377,
eCSSPropertyAlias_MozPerspectiveOrigin = 378,
eCSSPropertyAlias_MozPerspective = 379,
@ -26153,7 +26163,7 @@ pub mod root {
}
extern "C" {
#[link_name = "\u{1}_ZN10nsCSSProps11kFlagsTableE"]
pub static mut nsCSSProps_kFlagsTable: [u32; 376usize];
pub static mut nsCSSProps_kFlagsTable: [u32; 375usize];
}
extern "C" {
#[link_name = "\u{1}_ZN10nsCSSProps19kParserVariantTableE"]
@ -26161,7 +26171,7 @@ pub mod root {
}
extern "C" {
#[link_name = "\u{1}_ZN10nsCSSProps17kSubpropertyTableE"]
pub static mut nsCSSProps_kSubpropertyTable: [*const root::nsCSSPropertyID; 50usize];
pub static mut nsCSSProps_kSubpropertyTable: [*const root::nsCSSPropertyID; 49usize];
}
extern "C" {
#[link_name = "\u{1}_ZN10nsCSSProps26gShorthandsContainingTableE"]
@ -26190,11 +26200,11 @@ pub mod root {
}
extern "C" {
#[link_name = "\u{1}_ZN10nsCSSProps13kIDLNameTableE"]
pub static mut nsCSSProps_kIDLNameTable: [*const ::std::os::raw::c_char; 376usize];
pub static mut nsCSSProps_kIDLNameTable: [*const ::std::os::raw::c_char; 375usize];
}
extern "C" {
#[link_name = "\u{1}_ZN10nsCSSProps25kIDLNameSortPositionTableE"]
pub static mut nsCSSProps_kIDLNameSortPositionTable: [i32; 376usize];
pub static mut nsCSSProps_kIDLNameSortPositionTable: [i32; 375usize];
}
extern "C" {
#[link_name = "\u{1}_ZN10nsCSSProps19gPropertyUseCounterE"]
@ -36429,27 +36439,27 @@ pub mod root {
)
);
}
pub const ELEMENT_SHARED_RESTYLE_BIT_1: root::_bindgen_ty_85 = 8388608;
pub const ELEMENT_SHARED_RESTYLE_BIT_2: root::_bindgen_ty_85 = 16777216;
pub const ELEMENT_SHARED_RESTYLE_BIT_3: root::_bindgen_ty_85 = 33554432;
pub const ELEMENT_SHARED_RESTYLE_BIT_4: root::_bindgen_ty_85 = 67108864;
pub const ELEMENT_SHARED_RESTYLE_BITS: root::_bindgen_ty_85 = 125829120;
pub const ELEMENT_HAS_DIRTY_DESCENDANTS_FOR_SERVO: root::_bindgen_ty_85 = 8388608;
pub const ELEMENT_HAS_ANIMATION_ONLY_DIRTY_DESCENDANTS_FOR_SERVO: root::_bindgen_ty_85 =
pub const ELEMENT_SHARED_RESTYLE_BIT_1: root::_bindgen_ty_79 = 8388608;
pub const ELEMENT_SHARED_RESTYLE_BIT_2: root::_bindgen_ty_79 = 16777216;
pub const ELEMENT_SHARED_RESTYLE_BIT_3: root::_bindgen_ty_79 = 33554432;
pub const ELEMENT_SHARED_RESTYLE_BIT_4: root::_bindgen_ty_79 = 67108864;
pub const ELEMENT_SHARED_RESTYLE_BITS: root::_bindgen_ty_79 = 125829120;
pub const ELEMENT_HAS_DIRTY_DESCENDANTS_FOR_SERVO: root::_bindgen_ty_79 = 8388608;
pub const ELEMENT_HAS_ANIMATION_ONLY_DIRTY_DESCENDANTS_FOR_SERVO: root::_bindgen_ty_79 =
16777216;
pub const ELEMENT_HAS_SNAPSHOT: root::_bindgen_ty_85 = 33554432;
pub const ELEMENT_HANDLED_SNAPSHOT: root::_bindgen_ty_85 = 67108864;
pub const ELEMENT_HAS_PENDING_RESTYLE: root::_bindgen_ty_85 = 8388608;
pub const ELEMENT_IS_POTENTIAL_RESTYLE_ROOT: root::_bindgen_ty_85 = 16777216;
pub const ELEMENT_HAS_PENDING_ANIMATION_ONLY_RESTYLE: root::_bindgen_ty_85 = 33554432;
pub const ELEMENT_IS_POTENTIAL_ANIMATION_ONLY_RESTYLE_ROOT: root::_bindgen_ty_85 = 67108864;
pub const ELEMENT_IS_CONDITIONAL_RESTYLE_ANCESTOR: root::_bindgen_ty_85 = 134217728;
pub const ELEMENT_HAS_CHILD_WITH_LATER_SIBLINGS_HINT: root::_bindgen_ty_85 = 268435456;
pub const ELEMENT_PENDING_RESTYLE_FLAGS: root::_bindgen_ty_85 = 41943040;
pub const ELEMENT_POTENTIAL_RESTYLE_ROOT_FLAGS: root::_bindgen_ty_85 = 83886080;
pub const ELEMENT_ALL_RESTYLE_FLAGS: root::_bindgen_ty_85 = 260046848;
pub const ELEMENT_TYPE_SPECIFIC_BITS_OFFSET: root::_bindgen_ty_85 = 27;
pub type _bindgen_ty_85 = u32;
pub const ELEMENT_HAS_SNAPSHOT: root::_bindgen_ty_79 = 33554432;
pub const ELEMENT_HANDLED_SNAPSHOT: root::_bindgen_ty_79 = 67108864;
pub const ELEMENT_HAS_PENDING_RESTYLE: root::_bindgen_ty_79 = 8388608;
pub const ELEMENT_IS_POTENTIAL_RESTYLE_ROOT: root::_bindgen_ty_79 = 16777216;
pub const ELEMENT_HAS_PENDING_ANIMATION_ONLY_RESTYLE: root::_bindgen_ty_79 = 33554432;
pub const ELEMENT_IS_POTENTIAL_ANIMATION_ONLY_RESTYLE_ROOT: root::_bindgen_ty_79 = 67108864;
pub const ELEMENT_IS_CONDITIONAL_RESTYLE_ANCESTOR: root::_bindgen_ty_79 = 134217728;
pub const ELEMENT_HAS_CHILD_WITH_LATER_SIBLINGS_HINT: root::_bindgen_ty_79 = 268435456;
pub const ELEMENT_PENDING_RESTYLE_FLAGS: root::_bindgen_ty_79 = 41943040;
pub const ELEMENT_POTENTIAL_RESTYLE_ROOT_FLAGS: root::_bindgen_ty_79 = 83886080;
pub const ELEMENT_ALL_RESTYLE_FLAGS: root::_bindgen_ty_79 = 260046848;
pub const ELEMENT_TYPE_SPECIFIC_BITS_OFFSET: root::_bindgen_ty_79 = 27;
pub type _bindgen_ty_79 = u32;
pub type nsStyledElementBase = root::mozilla::dom::Element;
#[repr(C)]
pub struct nsStyledElement {

View file

@ -866,23 +866,13 @@ impl PropertyDeclarationBlock {
};
// Substeps 7 and 8
// We need to check the shorthand whether it's an alias property or not.
// If it's an alias property, it should be serialized like its longhand.
if shorthand.flags().contains(PropertyFlags::SHORTHAND_ALIAS_PROPERTY) {
append_serialization::<Cloned<slice::Iter< _>>, _>(
dest,
&property,
value,
importance,
&mut is_first_serialization)?;
} else {
append_serialization::<Cloned<slice::Iter< _>>, _>(
dest,
&shorthand,
value,
importance,
&mut is_first_serialization)?;
}
append_serialization::<Cloned<slice::Iter< _>>, _>(
dest,
&shorthand,
value,
importance,
&mut is_first_serialization,
)?;
for current_longhand in &current_longhands {
// Substep 9

View file

@ -968,10 +968,7 @@ def set_gecko_property(ffi_name, expr):
<%
transform_functions = [
("Matrix3D", "matrix3d", ["number"] * 16),
("PrefixedMatrix3D", "matrix3d", ["number"] * 12 + ["lopon"] * 2
+ ["lon"] + ["number"]),
("Matrix", "matrix", ["number"] * 6),
("PrefixedMatrix", "matrix", ["number"] * 4 + ["lopon"] * 2),
("Translate", "translate", ["lop", "optional_lop"]),
("Translate3D", "translate3d", ["lop", "lop", "length"]),
("TranslateX", "translatex", ["lop"]),
@ -1027,8 +1024,6 @@ transform_functions = [
# need to cast it to f32.
"integer_to_percentage" : "bindings::Gecko_CSSValue_SetPercentage(%s, %s as f32)",
"lop" : "%s.set_lop(%s)",
"lopon" : "set_lopon(%s, %s)",
"lon" : "set_lon(%s, %s)",
"angle" : "%s.set_angle(%s)",
"number" : "bindings::Gecko_CSSValue_SetNumber(%s, %s)",
# Note: We use nsCSSValueSharedList here, instead of nsCSSValueList_heap
@ -1106,16 +1101,7 @@ transform_functions = [
field_names = ["from_list", "to_list", "count"]
%>
<%
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}=> {
structs::nsCSSKeyword::eCSSKeyword_${keyword} => {
::values::generics::transform::TransformOperation::${name}${pre_symbols}
% for index, item in enumerate(items):
% if keyword == "matrix3d":
@ -1149,7 +1135,6 @@ fn set_single_transform_function(
servo_value: &values::computed::TransformOperation,
gecko_value: &mut structs::nsCSSValue /* output */
) {
use values::computed::{Length, LengthOrNumber, LengthOrPercentage, LengthOrPercentageOrNumber};
use values::computed::TransformOperation;
use values::generics::transform::{Matrix, Matrix3D};
@ -1159,22 +1144,6 @@ fn set_single_transform_function(
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 {
match *servo_value {
% 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))
};
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 {
match transform_function {
% for servo, gecko, format in transform_functions:

View file

@ -395,7 +395,7 @@ ${helpers.predefined_type(
${helpers.predefined_type("transform", "Transform",
"generics::transform::Transform::none()",
extra_prefixes="webkit",
extra_prefixes="webkit moz",
animation_value_type="ComputedValue",
gecko_ffi_name="mSpecifiedTransform",
flags="CREATES_STACKING_CONTEXT FIXPOS_CB",

View file

@ -793,14 +793,12 @@ bitflags! {
/// This property has values that can establish a containing block for
/// absolutely positioned elements.
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.
const APPLIES_TO_FIRST_LETTER = 1 << 4;
const APPLIES_TO_FIRST_LETTER = 1 << 3;
/// 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.
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
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 => {
dest.write_str(&*self.value.css)?
}
_ => {},
Some(..) => {},
}
Ok(())
}
@ -1768,20 +1759,11 @@ impl PropertyDeclaration {
fn with_variables_from_shorthand(&self, shorthand: ShorthandId) -> Option< &str> {
match *self {
PropertyDeclaration::WithVariables(ref declaration) => {
if let Some(s) = declaration.value.from_shorthand {
if s == shorthand {
Some(&*declaration.value.css)
} 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
let s = declaration.value.from_shorthand?;
if s != shorthand {
return None;
}
Some(&*declaration.value.css)
},
_ => None,
}

View file

@ -392,7 +392,7 @@ macro_rules! try_parse_one {
spec="https://wicg.github.io/overscroll-behavior/#overscroll-behavior-properties">
pub fn parse_value<'i, 't>(
_: &ParserContext,
input: &mut Parser<'i, 't>
input: &mut Parser<'i, 't>,
) -> Result<Longhands, ParseError<'i>> {
use values::specified::OverscrollBehavior;
let behavior_x = OverscrollBehavior::parse(input)?;
@ -416,18 +416,3 @@ macro_rules! try_parse_one {
}
}
</%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>

View file

@ -6,10 +6,9 @@
use euclid::{Transform3D, Vector3D};
use num_traits::Zero;
use super::{CSSFloat, Either};
use super::CSSFloat;
use values::animated::ToAnimatedZero;
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::{Transform as GenericTransform, TransformOperation as GenericTransformOperation};
use values::generics::transform::Rotate as GenericRotate;
@ -26,9 +25,7 @@ pub type TransformOperation = GenericTransformOperation<
Number,
Length,
Integer,
LengthOrNumber,
LengthOrPercentage,
LengthOrPercentageOrNumber,
>;
/// A computed CSS `transform`
pub type Transform = GenericTransform<TransformOperation>;
@ -56,12 +53,8 @@ impl TransformOrigin {
/// computed value of matrix3d()
pub type Matrix3D = GenericMatrix3D<Number>;
/// computed value of matrix3d() in -moz-transform
pub type PrefixedMatrix3D = GenericMatrix3D<Number, LengthOrPercentageOrNumber, LengthOrNumber>;
/// computed value of matrix()
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
// 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)]
impl Matrix {
#[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)]
impl From<Transform3D<CSSFloat>> for Matrix3D {
#[inline]
@ -213,17 +177,7 @@ impl ToAnimatedZero for TransformOperation {
fn to_animated_zero(&self) -> Result<Self, ()> {
match *self {
GenericTransformOperation::Matrix3D(..) => Ok(GenericTransformOperation::Matrix3D(Matrix3D::identity())),
GenericTransformOperation::PrefixedMatrix3D(..) => {
Ok(GenericTransformOperation::PrefixedMatrix3D(
PrefixedMatrix3D::identity(),
))
},
GenericTransformOperation::Matrix(..) => Ok(GenericTransformOperation::Matrix(Matrix::identity())),
GenericTransformOperation::PrefixedMatrix(..) => {
Ok(GenericTransformOperation::PrefixedMatrix(
PrefixedMatrix::identity(),
))
},
GenericTransformOperation::Skew(sx, sy) => {
Ok(GenericTransformOperation::Skew(
sx.to_animated_zero()?,

View file

@ -19,24 +19,24 @@ use values::specified::length::LengthOrPercentage as SpecifiedLengthOrPercentage
#[allow(missing_docs)]
#[derive(Clone, Copy, Debug, MallocSizeOf, PartialEq, ToComputedValue, ToCss)]
#[css(comma, function)]
pub struct Matrix<T, U = T> {
pub struct Matrix<T> {
pub a: T,
pub b: T,
pub c: T,
pub d: T,
pub e: U,
pub f: U,
pub e: T,
pub f: T,
}
#[allow(missing_docs)]
#[cfg_attr(rustfmt, rustfmt_skip)]
#[css(comma, function = "matrix3d")]
#[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 m21: T, pub m22: T, pub m23: T, pub m24: 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)]
@ -200,17 +200,11 @@ impl TimingKeyword {
#[derive(Clone, Debug, MallocSizeOf, PartialEq, ToComputedValue, ToCss)]
/// 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.
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.
Matrix3D(Matrix3D<Number>),
/// Represents a 3D 4x4 matrix with percentage and length values.
/// For `moz-transform`.
PrefixedMatrix3D(Matrix3D<Number, LoPoNumber, LengthOrNumber>),
/// A 2D skew.
///
/// 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,
Length,
Integer,
LengthOrNumber,
LengthOrPercentage,
LoPoNumber,
>,
>,
#[compute(ignore_bound)]
@ -313,9 +305,7 @@ pub enum TransformOperation<Angle, Number, Length, Integer, LengthOrNumber, Leng
Number,
Length,
Integer,
LengthOrNumber,
LengthOrPercentage,
LoPoNumber,
>,
>,
#[compute(clone)]
@ -333,9 +323,7 @@ pub enum TransformOperation<Angle, Number, Length, Integer, LengthOrNumber, Leng
Number,
Length,
Integer,
LengthOrNumber,
LengthOrPercentage,
LoPoNumber,
>,
>,
#[compute(ignore_bound)]
@ -346,9 +334,7 @@ pub enum TransformOperation<Angle, Number, Length, Integer, LengthOrNumber, Leng
Number,
Length,
Integer,
LengthOrNumber,
LengthOrPercentage,
LoPoNumber,
>,
>,
count: Integer,
@ -360,8 +346,8 @@ pub enum TransformOperation<Angle, Number, Length, Integer, LengthOrNumber, Leng
/// A value of the `transform` property
pub struct Transform<T>(pub Vec<T>);
impl<Angle, Number, Length, Integer, LengthOrNumber, LengthOrPercentage, LoPoNumber>
TransformOperation<Angle, Number, Length, Integer, LengthOrNumber, LengthOrPercentage, LoPoNumber> {
impl<Angle, Number, Length, Integer, LengthOrPercentage>
TransformOperation<Angle, Number, Length, Integer, LengthOrPercentage> {
/// Check if it is any translate function
pub fn is_translate(&self) -> bool {
use self::TransformOperation::*;
@ -450,8 +436,8 @@ pub trait ToMatrix {
fn to_3d_matrix(&self, reference_box: Option<&Rect<Au>>) -> Result<Transform3D<f64>, ()>;
}
impl<Angle, Number, Length, Integer, LoN, LoP, LoPoNumber> ToMatrix
for TransformOperation<Angle, Number, Length, Integer, LoN, LoP, LoPoNumber>
impl<Angle, Number, Length, Integer, LoP> ToMatrix
for TransformOperation<Angle, Number, Length, Integer, LoP>
where
Angle: Copy + AsRef<computed::angle::Angle>,
Number: Copy + Into<f32> + Into<f64>,
@ -464,8 +450,7 @@ where
match *self {
Translate3D(..) | TranslateZ(..) |
Rotate3D(..) | RotateX(..) | RotateY(..) | RotateZ(..) |
Scale3D(..) | ScaleZ(..) |
Perspective(..) | Matrix3D(..) | PrefixedMatrix3D(..) => true,
Scale3D(..) | ScaleZ(..) | Perspective(..) | Matrix3D(..) => true,
_ => false,
}
}
@ -553,10 +538,6 @@ where
},
Matrix3D(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 { .. } => {
// TODO: Convert InterpolateMatrix/AccumulateMatrix into a valid Transform3D by
// the reference box and do interpolation on these two Transform3D matrices.

View file

@ -18,8 +18,7 @@ use values::generics::transform::Rotate as GenericRotate;
use values::generics::transform::Scale as GenericScale;
use values::generics::transform::TransformOperation as GenericTransformOperation;
use values::generics::transform::Translate as GenericTranslate;
use values::specified::{self, Angle, Number, Length, Integer};
use values::specified::{LengthOrNumber, LengthOrPercentage, LengthOrPercentageOrNumber};
use values::specified::{self, Angle, Number, Length, Integer, LengthOrPercentage};
use values::specified::position::{Side, X, Y};
pub use values::generics::transform::TransformStyle;
@ -30,9 +29,7 @@ pub type TransformOperation = GenericTransformOperation<
Number,
Length,
Integer,
LengthOrNumber,
LengthOrPercentage,
LengthOrPercentageOrNumber,
>;
/// A specified CSS `transform`
@ -49,7 +46,6 @@ impl Transform {
fn parse_internal<'i, 't>(
context: &ParserContext,
input: &mut Parser<'i, 't>,
prefixed: bool,
) -> Result<Self, ParseError<'i>> {
use style_traits::{Separator, Space};
@ -75,19 +71,11 @@ impl Transform {
input.expect_comma()?;
let d = Number::parse(context, input)?;
input.expect_comma()?;
if !prefixed {
// Standard matrix parsing.
let e = Number::parse(context, input)?;
input.expect_comma()?;
let f = Number::parse(context, input)?;
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 }))
}
// Standard matrix parsing.
let e = Number::parse(context, input)?;
input.expect_comma()?;
let f = Number::parse(context, input)?;
Ok(GenericTransformOperation::Matrix(Matrix { a, b, c, d, e, f }))
},
"matrix3d" => {
let m11 = Number::parse(context, input)?;
@ -114,37 +102,20 @@ impl Transform {
input.expect_comma()?;
let m34 = Number::parse(context, input)?;
input.expect_comma()?;
if !prefixed {
// Standard matrix3d parsing.
let m41 = Number::parse(context, input)?;
input.expect_comma()?;
let m42 = Number::parse(context, input)?;
input.expect_comma()?;
let m43 = Number::parse(context, input)?;
input.expect_comma()?;
let m44 = Number::parse(context, input)?;
Ok(GenericTransformOperation::Matrix3D(Matrix3D {
m11, m12, m13, m14,
m21, m22, m23, m24,
m31, m32, m33, m34,
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,
}))
}
// Standard matrix3d parsing.
let m41 = Number::parse(context, input)?;
input.expect_comma()?;
let m42 = Number::parse(context, input)?;
input.expect_comma()?;
let m43 = Number::parse(context, input)?;
input.expect_comma()?;
let m44 = Number::parse(context, input)?;
Ok(GenericTransformOperation::Matrix3D(Matrix3D {
m11, m12, m13, m14,
m21, m22, m23, m24,
m31, m32, m33, m34,
m41, m42, m43, m44,
}))
},
"translate" => {
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 {
@ -276,7 +237,7 @@ impl Parse for Transform {
context: &ParserContext,
input: &mut Parser<'i, 't>
) -> Result<Self, ParseError<'i>> {
Transform::parse_internal(context, input, false)
Transform::parse_internal(context, input)
}
}