mirror of
https://github.com/servo/servo.git
synced 2025-08-04 05:00:08 +01:00
Use helpers.predefined_type for transform property.
This commit is contained in:
parent
fad4d7ae49
commit
8b9bbfea75
7 changed files with 45 additions and 51 deletions
|
@ -2999,13 +2999,13 @@ fn static_assert() {
|
||||||
% endfor
|
% endfor
|
||||||
}
|
}
|
||||||
</%def>
|
</%def>
|
||||||
fn set_single_transform_function(servo_value: &longhands::transform::computed_value::ComputedOperation,
|
fn set_single_transform_function(servo_value: &values::computed::TransformOperation,
|
||||||
gecko_value: &mut structs::nsCSSValue /* output */) {
|
gecko_value: &mut structs::nsCSSValue /* output */) {
|
||||||
use properties::longhands::transform::computed_value::ComputedOperation;
|
|
||||||
use values::computed::{Length, LengthOrNumber, LengthOrPercentage, LengthOrPercentageOrNumber};
|
use values::computed::{Length, LengthOrNumber, LengthOrPercentage, LengthOrPercentageOrNumber};
|
||||||
|
use values::computed::TransformOperation;
|
||||||
use values::generics::transform::{Matrix, Matrix3D};
|
use values::generics::transform::{Matrix, Matrix3D};
|
||||||
|
|
||||||
let convert_to_ns_css_value = |item: &ComputedOperation| -> structs::nsCSSValue {
|
let convert_to_ns_css_value = |item: &TransformOperation| -> structs::nsCSSValue {
|
||||||
let mut value = structs::nsCSSValue::null();
|
let mut value = structs::nsCSSValue::null();
|
||||||
Self::set_single_transform_function(item, &mut value);
|
Self::set_single_transform_function(item, &mut value);
|
||||||
value
|
value
|
||||||
|
@ -3035,7 +3035,7 @@ fn static_assert() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn convert_transform(input: &[longhands::transform::computed_value::ComputedOperation],
|
pub fn convert_transform(input: &[values::computed::TransformOperation],
|
||||||
output: &mut structs::root::RefPtr<structs::root::nsCSSValueSharedList>) {
|
output: &mut structs::root::RefPtr<structs::root::nsCSSValueSharedList>) {
|
||||||
use gecko_bindings::sugar::refptr::RefPtr;
|
use gecko_bindings::sugar::refptr::RefPtr;
|
||||||
|
|
||||||
|
@ -3088,7 +3088,7 @@ fn static_assert() {
|
||||||
pre_symbols = "("
|
pre_symbols = "("
|
||||||
post_symbols = ")"
|
post_symbols = ")"
|
||||||
if keyword == "interpolatematrix" or keyword == "accumulatematrix":
|
if keyword == "interpolatematrix" or keyword == "accumulatematrix":
|
||||||
# We generate this like: "ComputedOperation::InterpolateMatrix {", so the space is
|
# We generate this like: "TransformOperation::InterpolateMatrix {", so the space is
|
||||||
# between "InterpolateMatrix"/"AccumulateMatrix" and '{'
|
# between "InterpolateMatrix"/"AccumulateMatrix" and '{'
|
||||||
pre_symbols = " {"
|
pre_symbols = " {"
|
||||||
post_symbols = "}"
|
post_symbols = "}"
|
||||||
|
@ -3144,14 +3144,13 @@ fn static_assert() {
|
||||||
},
|
},
|
||||||
</%def>
|
</%def>
|
||||||
fn clone_single_transform_function(gecko_value: &structs::nsCSSValue)
|
fn clone_single_transform_function(gecko_value: &structs::nsCSSValue)
|
||||||
-> longhands::transform::computed_value::ComputedOperation {
|
-> values::computed::TransformOperation {
|
||||||
use properties::longhands::transform::computed_value::ComputedOperation;
|
use values::computed::{Length, Percentage, TransformOperation};
|
||||||
use values::computed::{Length, Percentage};
|
|
||||||
use values::generics::transform::{Matrix, Matrix3D};
|
use values::generics::transform::{Matrix, Matrix3D};
|
||||||
use values::generics::transform::Transform;
|
use values::generics::transform::Transform;
|
||||||
|
|
||||||
let convert_shared_list_to_operations = |value: &structs::nsCSSValue|
|
let convert_shared_list_to_operations = |value: &structs::nsCSSValue|
|
||||||
-> Vec<ComputedOperation> {
|
-> Vec<TransformOperation> {
|
||||||
debug_assert!(value.mUnit == structs::nsCSSUnit::eCSSUnit_SharedList);
|
debug_assert!(value.mUnit == structs::nsCSSUnit::eCSSUnit_SharedList);
|
||||||
let value_list = unsafe {
|
let value_list = unsafe {
|
||||||
value.mValue.mSharedList.as_ref()
|
value.mValue.mSharedList.as_ref()
|
||||||
|
|
|
@ -567,42 +567,12 @@ ${helpers.predefined_type(
|
||||||
allow_empty="NotInitial"
|
allow_empty="NotInitial"
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<%helpers:longhand name="transform" extra_prefixes="webkit"
|
${helpers.predefined_type("transform", "Transform",
|
||||||
animation_value_type="ComputedValue"
|
"generics::transform::Transform::none()",
|
||||||
flags="CREATES_STACKING_CONTEXT FIXPOS_CB"
|
extra_prefixes="webkit",
|
||||||
spec="https://drafts.csswg.org/css-transforms/#propdef-transform">
|
animation_value_type="ComputedValue",
|
||||||
use values::generics::transform::Transform;
|
flags="CREATES_STACKING_CONTEXT FIXPOS_CB",
|
||||||
|
spec="https://drafts.csswg.org/css-transforms/#propdef-transform")}
|
||||||
|
|
||||||
pub mod computed_value {
|
|
||||||
pub use values::computed::transform::Transform as T;
|
|
||||||
pub use values::computed::transform::TransformOperation as ComputedOperation;
|
|
||||||
}
|
|
||||||
|
|
||||||
pub use values::specified::transform::Transform as SpecifiedValue;
|
|
||||||
pub use values::specified::transform::TransformOperation as SpecifiedOperation;
|
|
||||||
|
|
||||||
#[inline]
|
|
||||||
pub fn get_initial_value() -> computed_value::T {
|
|
||||||
Transform(vec![])
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// Parses `transform` property.
|
|
||||||
#[inline]
|
|
||||||
pub fn parse<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>)
|
|
||||||
-> Result<SpecifiedValue,ParseError<'i>> {
|
|
||||||
SpecifiedValue::parse_internal(context, input, false)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 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<SpecifiedValue,ParseError<'i>> {
|
|
||||||
SpecifiedValue::parse_internal(context, input, true)
|
|
||||||
}
|
|
||||||
</%helpers:longhand>
|
|
||||||
|
|
||||||
// CSSOM View Module
|
// CSSOM View Module
|
||||||
// https://www.w3.org/TR/cssom-view-1/
|
// https://www.w3.org/TR/cssom-view-1/
|
||||||
|
|
|
@ -363,12 +363,11 @@ macro_rules! try_parse_one {
|
||||||
flags="SHORTHAND_ALIAS_PROPERTY"
|
flags="SHORTHAND_ALIAS_PROPERTY"
|
||||||
derive_serialize="True"
|
derive_serialize="True"
|
||||||
spec="Non-standard: https://developer.mozilla.org/en-US/docs/Web/CSS/transform">
|
spec="Non-standard: https://developer.mozilla.org/en-US/docs/Web/CSS/transform">
|
||||||
use properties::longhands::transform;
|
|
||||||
|
|
||||||
pub fn parse_value<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>)
|
pub fn parse_value<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>)
|
||||||
-> Result<Longhands, ParseError<'i>> {
|
-> Result<Longhands, ParseError<'i>> {
|
||||||
|
use values::specified::transform::Transform;
|
||||||
Ok(expanded! {
|
Ok(expanded! {
|
||||||
transform: transform::parse_prefixed(context, input)?,
|
transform: Transform::parse_prefixed(context, input)?,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
</%helpers:shorthand>
|
</%helpers:shorthand>
|
||||||
|
|
|
@ -57,7 +57,7 @@ pub use self::svg::{SVGLength, SVGOpacity, SVGPaint, SVGPaintKind, SVGStrokeDash
|
||||||
pub use self::table::XSpan;
|
pub use self::table::XSpan;
|
||||||
pub use self::text::{InitialLetter, LetterSpacing, LineHeight, TextOverflow, WordSpacing};
|
pub use self::text::{InitialLetter, LetterSpacing, LineHeight, TextOverflow, WordSpacing};
|
||||||
pub use self::time::Time;
|
pub use self::time::Time;
|
||||||
pub use self::transform::{TimingFunction, TransformOrigin};
|
pub use self::transform::{TimingFunction, Transform, TransformOperation, TransformOrigin};
|
||||||
|
|
||||||
#[cfg(feature = "gecko")]
|
#[cfg(feature = "gecko")]
|
||||||
pub mod align;
|
pub mod align;
|
||||||
|
|
|
@ -450,3 +450,10 @@ impl<T: ToCss> ToCss for Transform<T> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<T> Transform<T> {
|
||||||
|
/// `none`
|
||||||
|
pub fn none() -> Self {
|
||||||
|
Transform(vec![])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -53,7 +53,7 @@ pub use self::svg::{SVGLength, SVGOpacity, SVGPaint, SVGPaintKind, SVGStrokeDash
|
||||||
pub use self::table::XSpan;
|
pub use self::table::XSpan;
|
||||||
pub use self::text::{InitialLetter, LetterSpacing, LineHeight, TextOverflow, WordSpacing};
|
pub use self::text::{InitialLetter, LetterSpacing, LineHeight, TextOverflow, WordSpacing};
|
||||||
pub use self::time::Time;
|
pub use self::time::Time;
|
||||||
pub use self::transform::{TimingFunction, TransformOrigin};
|
pub use self::transform::{TimingFunction, Transform, TransformOrigin};
|
||||||
pub use super::generics::grid::GridTemplateComponent as GenericGridTemplateComponent;
|
pub use super::generics::grid::GridTemplateComponent as GenericGridTemplateComponent;
|
||||||
|
|
||||||
#[cfg(feature = "gecko")]
|
#[cfg(feature = "gecko")]
|
||||||
|
|
|
@ -39,7 +39,7 @@ pub type TransformOrigin = GenericTransformOrigin<OriginComponent<X>, OriginComp
|
||||||
impl Transform {
|
impl Transform {
|
||||||
/// Internal parse function for deciding if we wish to accept prefixed values or not
|
/// Internal parse function for deciding if we wish to accept prefixed values or not
|
||||||
// Allow unitless zero angle for rotate() and skew() to align with gecko
|
// Allow unitless zero angle for rotate() and skew() to align with gecko
|
||||||
pub 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,
|
prefixed: bool,
|
||||||
|
@ -252,6 +252,25 @@ 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 {
|
||||||
|
fn parse<'i, 't>(
|
||||||
|
context: &ParserContext,
|
||||||
|
input: &mut Parser<'i, 't>
|
||||||
|
) -> Result<Self, ParseError<'i>> {
|
||||||
|
Transform::parse_internal(context, input, false)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The specified value of a component of a CSS `<transform-origin>`.
|
/// The specified value of a component of a CSS `<transform-origin>`.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue