mirror of
https://github.com/servo/servo.git
synced 2025-08-15 02:15:33 +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
|
||||
// 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 ¤t_longhands {
|
||||
// Substep 9
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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,
|
||||
}
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue