Add spec links for margin properties, support spec links on four_sides_shorthand

This commit is contained in:
Manish Goregaokar 2017-01-02 19:19:31 -08:00
parent 6138b6aa75
commit 3128694bff
3 changed files with 12 additions and 7 deletions

View file

@ -551,10 +551,9 @@
% endif
</%def>
<%def name="four_sides_shorthand(name, sub_property_pattern, parser_function, needs_context=True)">
<%self:shorthand name="${name}" sub_properties="${
' '.join(sub_property_pattern % side
for side in ['top', 'right', 'bottom', 'left'])}">
<%def name="four_sides_shorthand(name, sub_property_pattern, parser_function, needs_context=True, **kwargs)">
<% sub_properties=' '.join(sub_property_pattern % side for side in ['top', 'right', 'bottom', 'left']) %>
<%call expr="self.shorthand(name, sub_properties=sub_properties, **kwargs)">
#[allow(unused_imports)]
use parser::Parse;
use super::parse_four_sides;
@ -586,7 +585,7 @@
)
}
}
</%self:shorthand>
</%call>
</%def>
<%def name="logical_setter_helper(name)">

View file

@ -7,7 +7,12 @@
<% data.new_style_struct("Margin", inherited=False) %>
% for side in ALL_SIDES:
<%
spec = "https://drafts.csswg.org/css-box/#propdef-margin-%s" % side[0]
if side[1]:
spec = "https://drafts.csswg.org/css-logical-props/#propdef-margin-%s" % side[1]
%>
${helpers.predefined_type("margin-%s" % side[0], "LengthOrPercentageOrAuto",
"computed::LengthOrPercentageOrAuto::Length(Au(0))",
animatable=True, logical = side[1])}
animatable=True, logical = side[1], spec = spec)}
% endfor

View file

@ -4,4 +4,5 @@
<%namespace name="helpers" file="/helpers.mako.rs" />
${helpers.four_sides_shorthand("margin", "margin-%s", "specified::LengthOrPercentageOrAuto::parse")}
${helpers.four_sides_shorthand("margin", "margin-%s", "specified::LengthOrPercentageOrAuto::parse",
spec="https://drafts.csswg.org/css-box/#propdef-margin")}