Skip to content

Commit

Permalink
Distinguish the emptiness of a property from its initial value
Browse files Browse the repository at this point in the history
  • Loading branch information
nox committed Jun 23, 2017
1 parent 1230954 commit f01ea53
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 39 deletions.
10 changes: 7 additions & 3 deletions components/style/properties/helpers.mako.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

<%def name="predefined_type(name, type, initial_value, parse_method='parse',
needs_context=True, vector=False, computed_type=None, initial_specified_value=None,
allow_quirks=False, **kwargs)">
allow_quirks=False, allow_empty=False, **kwargs)">
<%def name="predefined_type_inner(name, type, initial_value, parse_method)">
#[allow(unused_imports)]
use app_units::Au;
Expand All @@ -27,7 +27,9 @@
pub use values::computed::${type} as T;
% endif
}
% if initial_value:
#[inline] pub fn get_initial_value() -> computed_value::T { ${initial_value} }
% endif
% if initial_specified_value:
#[inline] pub fn get_initial_specified_value() -> SpecifiedValue { ${initial_specified_value} }
% endif
Expand All @@ -46,7 +48,9 @@
}
</%def>
% if vector:
<%call expr="vector_longhand(name, predefined_type=type, **kwargs)">
<%call
expr="vector_longhand(name, predefined_type=type, allow_empty=allow_empty or not initial_value, **kwargs)"
>
${predefined_type_inner(name, type, initial_value, parse_method)}
% if caller:
${caller.body()}
Expand Down Expand Up @@ -202,7 +206,7 @@
}

pub fn get_initial_value() -> computed_value::T {
% if allow_empty:
% if allow_empty and allow_empty != "NotInitial":
computed_value::T(SmallVec::new())
% else:
let mut v = SmallVec::new();
Expand Down
45 changes: 24 additions & 21 deletions components/style/properties/longhand/box.mako.rs
Original file line number Diff line number Diff line change
Expand Up @@ -429,17 +429,19 @@ ${helpers.predefined_type("transition-timing-function",
extra_prefixes="moz webkit",
spec="https://drafts.csswg.org/css-transitions/#propdef-transition-timing-function")}

${helpers.predefined_type("transition-property",
"TransitionProperty",
"computed::TransitionProperty::All",
initial_specified_value="specified::TransitionProperty::All",
vector=True,
allow_empty=True,
need_index=True,
needs_context=False,
animation_value_type="none",
extra_prefixes="moz webkit",
spec="https://drafts.csswg.org/css-transitions/#propdef-transition-property")}
${helpers.predefined_type(
"transition-property",
"TransitionProperty",
"computed::TransitionProperty::All",
initial_specified_value="specified::TransitionProperty::All",
vector=True,
allow_empty="NotInitial",
need_index=True,
needs_context=False,
animation_value_type="none",
extra_prefixes="moz webkit",
spec="https://drafts.csswg.org/css-transitions/#propdef-transition-property",
)}

${helpers.predefined_type("transition-delay",
"Time",
Expand Down Expand Up @@ -668,16 +670,17 @@ ${helpers.predefined_type("scroll-snap-destination",
spec="Nonstandard (https://developer.mozilla.org/en-US/docs/Web/CSS/scroll-snap-destination)",
animation_value_type="ComputedValue")}

${helpers.predefined_type("scroll-snap-coordinate",
"Position",
"computed::Position::zero()",
vector=True,
products="gecko",
spec="Nonstandard (https://developer.mozilla.org/en-US/docs/Web/CSS/scroll-snap-destination)",
animation_value_type="ComputedValue",
allow_empty=True,
delegate_animate=True)}

${helpers.predefined_type(
"scroll-snap-coordinate",
"Position",
"computed::Position::zero()",
vector=True,
products="gecko",
spec="Nonstandard (https://developer.mozilla.org/en-US/docs/Web/CSS/scroll-snap-destination)",
animation_value_type="ComputedValue",
allow_empty="NotInitial",
delegate_animate=True,
)}

<%helpers:longhand name="transform" extra_prefixes="webkit"
animation_value_type="ComputedValue"
Expand Down
23 changes: 12 additions & 11 deletions components/style/properties/longhand/inherited_svg.mako.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,17 +88,18 @@ ${helpers.predefined_type("stroke-opacity", "Opacity", "1.0",
products="gecko", animation_value_type="ComputedValue",
spec="https://www.w3.org/TR/SVG11/painting.html#StrokeOpacityProperty")}

${helpers.predefined_type("stroke-dasharray",
"LengthOrPercentageOrNumber",
"Either::First(0.0)",
"parse_non_negative",
vector="True",
delegate_animate="True",
allow_empty="True",
products="gecko",
animation_value_type="ComputedValue",
space_separated_allowed="True",
spec="https://www.w3.org/TR/SVG2/painting.html#StrokeDashing")}
${helpers.predefined_type(
"stroke-dasharray",
"LengthOrPercentageOrNumber",
None,
"parse_non_negative",
vector=True,
delegate_animate=True,
products="gecko",
animation_value_type="ComputedValue",
space_separated_allowed="True",
spec="https://www.w3.org/TR/SVG2/painting.html#StrokeDashing",
)}

${helpers.predefined_type(
"stroke-dashoffset", "LengthOrPercentageOrNumber",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,3 @@
[parse 'all, none']
expected: FAIL

[parse 'initial']
expected: FAIL

2 changes: 1 addition & 1 deletion tests/wpt/mozilla/meta/MANIFEST.json
Original file line number Diff line number Diff line change
Expand Up @@ -25556,7 +25556,7 @@
"testharness"
],
"mozilla/calc.html": [
"a1f441f7fd4b9ab3ae9e1cb5403cfe8de90bb71c",
"5d59d5b367a023e778ce6968acdeca6b8b7c3197",
"testharness"
],
"mozilla/canvas.initial.reset.2dstate.html": [
Expand Down
1 change: 1 addition & 0 deletions tests/wpt/mozilla/tests/mozilla/calc.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#inner {
border-style: solid; /* So used border == computed border */
outline-style: solid; /* So used outline-width == computed outline-width */
transition-property: none; /* so that tests don't occur in the middle of a transition */
}
</style>
</head>
Expand Down

0 comments on commit f01ea53

Please sign in to comment.