Add gecko leagcy logical properties aliases

This commit is contained in:
Xidorn Quan 2017-01-10 20:21:41 +11:00
parent e494a0f0a7
commit 2f2044e4b7
4 changed files with 16 additions and 3 deletions

View file

@ -14,6 +14,14 @@ ALL_SIDES = [(side, False) for side in PHYSICAL_SIDES] + [(side, True) for side
ALL_SIZES = [(size, False) for size in PHYSICAL_SIZES] + [(size, True) for size in LOGICAL_SIZES]
def maybe_moz_logical_alias(product, side, prop):
if product == "gecko" and side[1]:
axis, dir = side[0].split("-")
if axis == "inline":
return prop % dir
return None
def to_rust_ident(name):
name = name.replace("-", "_")
if name in ["static", "super", "box", "move"]: # Rust keywords

View file

@ -3,7 +3,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
<%namespace name="helpers" file="/helpers.mako.rs" />
<% from data import Method, PHYSICAL_SIDES, ALL_SIDES %>
<% from data import Method, PHYSICAL_SIDES, ALL_SIDES, maybe_moz_logical_alias %>
<% data.new_style_struct("Border", inherited=False,
additional_methods=[Method("border_" + side + "_has_nonzero_width",
@ -18,6 +18,7 @@
% for side in ALL_SIDES:
${helpers.predefined_type("border-%s-color" % side[0], "CSSColor",
"::cssparser::Color::CurrentColor",
alias=maybe_moz_logical_alias(product, side, "-moz-border-%s-color"),
spec=maybe_logical_spec(side, "color"),
animatable=True, logical = side[1])}
% endfor
@ -26,12 +27,14 @@
${helpers.predefined_type("border-%s-style" % side[0], "BorderStyle",
"specified::BorderStyle::none",
needs_context=False, need_clone=True,
alias=maybe_moz_logical_alias(product, side, "-moz-border-%s-style"),
spec=maybe_logical_spec(side, "style"),
animatable=False, logical = side[1])}
% endfor
% for side in ALL_SIDES:
<%helpers:longhand name="border-${side[0]}-width" animatable="True" logical="${side[1]}"
alias=maybe_moz_logical_alias(product, side, "-moz-border-%s-width")
spec="${maybe_logical_spec(side, 'width')}">
use app_units::Au;
use std::fmt;

View file

@ -3,7 +3,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
<%namespace name="helpers" file="/helpers.mako.rs" />
<% from data import ALL_SIDES %>
<% from data import ALL_SIDES, maybe_moz_logical_alias %>
<% data.new_style_struct("Margin", inherited=False) %>
% for side in ALL_SIDES:
@ -14,5 +14,6 @@
%>
${helpers.predefined_type("margin-%s" % side[0], "LengthOrPercentageOrAuto",
"computed::LengthOrPercentageOrAuto::Length(Au(0))",
alias=maybe_moz_logical_alias(product, side, "-moz-margin-%s"),
animatable=True, logical = side[1], spec = spec)}
% endfor

View file

@ -3,7 +3,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
<%namespace name="helpers" file="/helpers.mako.rs" />
<% from data import ALL_SIDES %>
<% from data import ALL_SIDES, maybe_moz_logical_alias %>
<% data.new_style_struct("Padding", inherited=False) %>
% for side in ALL_SIDES:
@ -15,6 +15,7 @@
${helpers.predefined_type("padding-%s" % side[0], "LengthOrPercentage",
"computed::LengthOrPercentage::Length(Au(0))",
"parse_non_negative",
alias=maybe_moz_logical_alias(product, side, "-moz-padding-%s"),
needs_context=False,
animatable=True,
logical = side[1],