Use helpers.predefined_type for transform property.

This commit is contained in:
Xidorn Quan 2017-11-07 15:40:41 -08:00
parent fad4d7ae49
commit 8b9bbfea75
7 changed files with 45 additions and 51 deletions

View file

@ -2999,13 +2999,13 @@ fn static_assert() {
% endfor
}
</%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 */) {
use properties::longhands::transform::computed_value::ComputedOperation;
use values::computed::{Length, LengthOrNumber, LengthOrPercentage, LengthOrPercentageOrNumber};
use values::computed::TransformOperation;
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();
Self::set_single_transform_function(item, &mut 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>) {
use gecko_bindings::sugar::refptr::RefPtr;
@ -3088,7 +3088,7 @@ fn static_assert() {
pre_symbols = "("
post_symbols = ")"
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 '{'
pre_symbols = " {"
post_symbols = "}"
@ -3144,14 +3144,13 @@ fn static_assert() {
},
</%def>
fn clone_single_transform_function(gecko_value: &structs::nsCSSValue)
-> longhands::transform::computed_value::ComputedOperation {
use properties::longhands::transform::computed_value::ComputedOperation;
use values::computed::{Length, Percentage};
-> values::computed::TransformOperation {
use values::computed::{Length, Percentage, TransformOperation};
use values::generics::transform::{Matrix, Matrix3D};
use values::generics::transform::Transform;
let convert_shared_list_to_operations = |value: &structs::nsCSSValue|
-> Vec<ComputedOperation> {
-> Vec<TransformOperation> {
debug_assert!(value.mUnit == structs::nsCSSUnit::eCSSUnit_SharedList);
let value_list = unsafe {
value.mValue.mSharedList.as_ref()

View file

@ -567,42 +567,12 @@ ${helpers.predefined_type(
allow_empty="NotInitial"
)}
<%helpers:longhand name="transform" extra_prefixes="webkit"
animation_value_type="ComputedValue"
flags="CREATES_STACKING_CONTEXT FIXPOS_CB"
spec="https://drafts.csswg.org/css-transforms/#propdef-transform">
use values::generics::transform::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>
${helpers.predefined_type("transform", "Transform",
"generics::transform::Transform::none()",
extra_prefixes="webkit",
animation_value_type="ComputedValue",
flags="CREATES_STACKING_CONTEXT FIXPOS_CB",
spec="https://drafts.csswg.org/css-transforms/#propdef-transform")}
// CSSOM View Module
// https://www.w3.org/TR/cssom-view-1/

View file

@ -363,12 +363,11 @@ macro_rules! try_parse_one {
flags="SHORTHAND_ALIAS_PROPERTY"
derive_serialize="True"
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>)
-> Result<Longhands, ParseError<'i>> {
use values::specified::transform::Transform;
Ok(expanded! {
transform: transform::parse_prefixed(context, input)?,
transform: Transform::parse_prefixed(context, input)?,
})
}
</%helpers:shorthand>