mirror of
https://github.com/servo/servo.git
synced 2025-08-05 05:30:08 +01:00
Auto merge of #17603 - servo:derive-all-the-things, r=SimonSapin
Clean up vector_longhand a bit <!-- 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/17603) <!-- Reviewable:end -->
This commit is contained in:
commit
296a215e54
6 changed files with 206 additions and 225 deletions
|
@ -69,20 +69,15 @@
|
||||||
// FIXME (Manishearth): Add computed_value_as_specified argument
|
// FIXME (Manishearth): Add computed_value_as_specified argument
|
||||||
// and handle the empty case correctly
|
// and handle the empty case correctly
|
||||||
<%doc>
|
<%doc>
|
||||||
To be used in cases where we have a grammar like
|
To be used in cases where we have a grammar like "<thing> [ , <thing> ]*".
|
||||||
"<thing> [ , <thing> ]*". `gecko_only` should be set
|
|
||||||
to True for cases where Servo takes a single value
|
|
||||||
and Stylo supports vector values.
|
|
||||||
|
|
||||||
Setting allow_empty to False allows for cases where the vector
|
Setting allow_empty to False allows for cases where the vector
|
||||||
is empty. The grammar for these is usually "none | <thing> [ , <thing> ]*".
|
is empty. The grammar for these is usually "none | <thing> [ , <thing> ]*".
|
||||||
We assume that the default/initial value is an empty vector for these.
|
We assume that the default/initial value is an empty vector for these.
|
||||||
`initial_value` need not be defined for these.
|
`initial_value` need not be defined for these.
|
||||||
</%doc>
|
</%doc>
|
||||||
<%def name="vector_longhand(name, gecko_only=False, allow_empty=False,
|
<%def name="vector_longhand(name, animation_value_type=None, allow_empty=False, separator='Comma', **kwargs)">
|
||||||
delegate_animate=False, separator='Comma', **kwargs)">
|
<%call expr="longhand(name, animation_value_type=animation_value_type, vector=True, **kwargs)">
|
||||||
<%call expr="longhand(name, vector=True, **kwargs)">
|
|
||||||
% if not gecko_only:
|
|
||||||
#[allow(unused_imports)]
|
#[allow(unused_imports)]
|
||||||
use smallvec::SmallVec;
|
use smallvec::SmallVec;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
@ -132,7 +127,7 @@
|
||||||
% endif
|
% endif
|
||||||
);
|
);
|
||||||
|
|
||||||
% if delegate_animate:
|
% if animation_value_type == "ComputedValue":
|
||||||
use properties::animated_properties::Animatable;
|
use properties::animated_properties::Animatable;
|
||||||
impl Animatable for T {
|
impl Animatable for T {
|
||||||
fn add_weighted(&self, other: &Self, self_portion: f64, other_portion: f64)
|
fn add_weighted(&self, other: &Self, self_portion: f64, other_portion: f64)
|
||||||
|
@ -268,9 +263,6 @@
|
||||||
.collect())
|
.collect())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
% else:
|
|
||||||
${caller.body()}
|
|
||||||
% endif
|
|
||||||
</%call>
|
</%call>
|
||||||
</%def>
|
</%def>
|
||||||
<%def name="longhand(*args, **kwargs)">
|
<%def name="longhand(*args, **kwargs)">
|
||||||
|
|
|
@ -16,7 +16,6 @@ use euclid::{Point2D, Size2D};
|
||||||
#[cfg(feature = "gecko")] use gecko_string_cache::Atom;
|
#[cfg(feature = "gecko")] use gecko_string_cache::Atom;
|
||||||
use properties::{CSSWideKeyword, PropertyDeclaration};
|
use properties::{CSSWideKeyword, PropertyDeclaration};
|
||||||
use properties::longhands;
|
use properties::longhands;
|
||||||
use properties::longhands::background_size::computed_value::T as BackgroundSizeList;
|
|
||||||
use properties::longhands::font_weight::computed_value::T as FontWeight;
|
use properties::longhands::font_weight::computed_value::T as FontWeight;
|
||||||
use properties::longhands::font_stretch::computed_value::T as FontStretch;
|
use properties::longhands::font_stretch::computed_value::T as FontStretch;
|
||||||
use properties::longhands::transform::computed_value::ComputedMatrix;
|
use properties::longhands::transform::computed_value::ComputedMatrix;
|
||||||
|
@ -1083,23 +1082,6 @@ impl Animatable for VerticalAlign {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Animatable for BackgroundSizeList {
|
|
||||||
#[inline]
|
|
||||||
fn add_weighted(&self, other: &Self, self_portion: f64, other_portion: f64) -> Result<Self, ()> {
|
|
||||||
self.0.add_weighted(&other.0, self_portion, other_portion).map(BackgroundSizeList)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
|
||||||
fn compute_distance(&self, other: &Self) -> Result<f64, ()> {
|
|
||||||
self.0.compute_distance(&other.0)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
|
||||||
fn compute_squared_distance(&self, other: &Self) -> Result<f64, ()> {
|
|
||||||
self.0.compute_squared_distance(&other.0)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// https://drafts.csswg.org/css-transitions/#animtype-lpcalc
|
/// https://drafts.csswg.org/css-transitions/#animtype-lpcalc
|
||||||
impl Animatable for CalcLengthOrPercentage {
|
impl Animatable for CalcLengthOrPercentage {
|
||||||
#[inline]
|
#[inline]
|
||||||
|
|
|
@ -24,11 +24,15 @@ ${helpers.predefined_type("background-image", "ImageLayer",
|
||||||
ignored_when_colors_disabled="True")}
|
ignored_when_colors_disabled="True")}
|
||||||
|
|
||||||
% for (axis, direction, initial) in [("x", "Horizontal", "left"), ("y", "Vertical", "top")]:
|
% for (axis, direction, initial) in [("x", "Horizontal", "left"), ("y", "Vertical", "top")]:
|
||||||
${helpers.predefined_type("background-position-" + axis, "position::" + direction + "Position",
|
${helpers.predefined_type(
|
||||||
|
"background-position-" + axis,
|
||||||
|
"position::" + direction + "Position",
|
||||||
initial_value="computed::LengthOrPercentage::zero()",
|
initial_value="computed::LengthOrPercentage::zero()",
|
||||||
initial_specified_value="SpecifiedValue::initial_specified_value()",
|
initial_specified_value="SpecifiedValue::initial_specified_value()",
|
||||||
spec="https://drafts.csswg.org/css-backgrounds-4/#propdef-background-position-" + axis,
|
spec="https://drafts.csswg.org/css-backgrounds-4/#propdef-background-position-" + axis,
|
||||||
animation_value_type="ComputedValue", vector=True, delegate_animate=True)}
|
animation_value_type="ComputedValue",
|
||||||
|
vector=True,
|
||||||
|
)}
|
||||||
% endfor
|
% endfor
|
||||||
|
|
||||||
<%helpers:vector_longhand name="background-repeat" animation_value_type="discrete"
|
<%helpers:vector_longhand name="background-repeat" animation_value_type="discrete"
|
||||||
|
|
|
@ -679,8 +679,7 @@ ${helpers.predefined_type(
|
||||||
products="gecko",
|
products="gecko",
|
||||||
spec="Nonstandard (https://developer.mozilla.org/en-US/docs/Web/CSS/scroll-snap-destination)",
|
spec="Nonstandard (https://developer.mozilla.org/en-US/docs/Web/CSS/scroll-snap-destination)",
|
||||||
animation_value_type="ComputedValue",
|
animation_value_type="ComputedValue",
|
||||||
allow_empty="NotInitial",
|
allow_empty="NotInitial"
|
||||||
delegate_animate=True,
|
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<%helpers:longhand name="transform" extra_prefixes="webkit"
|
<%helpers:longhand name="transform" extra_prefixes="webkit"
|
||||||
|
|
|
@ -94,7 +94,6 @@ ${helpers.predefined_type(
|
||||||
None,
|
None,
|
||||||
"parse_non_negative",
|
"parse_non_negative",
|
||||||
vector=True,
|
vector=True,
|
||||||
delegate_animate=True,
|
|
||||||
products="gecko",
|
products="gecko",
|
||||||
animation_value_type="ComputedValue",
|
animation_value_type="ComputedValue",
|
||||||
separator="CommaWithSpace",
|
separator="CommaWithSpace",
|
||||||
|
|
|
@ -89,12 +89,17 @@ ${helpers.single_keyword("mask-mode",
|
||||||
</%helpers:vector_longhand>
|
</%helpers:vector_longhand>
|
||||||
|
|
||||||
% for (axis, direction) in [("x", "Horizontal"), ("y", "Vertical")]:
|
% for (axis, direction) in [("x", "Horizontal"), ("y", "Vertical")]:
|
||||||
${helpers.predefined_type("mask-position-" + axis, "position::" + direction + "Position",
|
${helpers.predefined_type(
|
||||||
products="gecko", extra_prefixes="webkit",
|
"mask-position-" + axis,
|
||||||
|
"position::" + direction + "Position",
|
||||||
|
products="gecko",
|
||||||
|
extra_prefixes="webkit",
|
||||||
initial_value="computed::LengthOrPercentage::zero()",
|
initial_value="computed::LengthOrPercentage::zero()",
|
||||||
initial_specified_value="specified::PositionComponent::Center",
|
initial_specified_value="specified::PositionComponent::Center",
|
||||||
spec="https://drafts.fxtf.org/css-masking/#propdef-mask-position",
|
spec="https://drafts.fxtf.org/css-masking/#propdef-mask-position",
|
||||||
animation_value_type="ComputedValue", vector=True, delegate_animate=True)}
|
animation_value_type="ComputedValue",
|
||||||
|
vector=True,
|
||||||
|
)}
|
||||||
% endfor
|
% endfor
|
||||||
|
|
||||||
${helpers.single_keyword("mask-clip",
|
${helpers.single_keyword("mask-clip",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue