Skip to content

Commit

Permalink
style: Add support for pref-controlled initial values.
Browse files Browse the repository at this point in the history
  • Loading branch information
heycam authored and emilio committed Apr 16, 2020
1 parent 3cb019a commit 53f7e45
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions components/style/properties/helpers.mako.rs
Expand Up @@ -707,7 +707,8 @@
</%def>

<%def name="single_keyword(name, values, vector=False,
extra_specified=None, needs_conversion=False, **kwargs)">
extra_specified=None, needs_conversion=False,
gecko_pref_controlled_initial_value=None, **kwargs)">
<%
keyword_kwargs = {a: kwargs.pop(a, None) for a in [
'gecko_constant_prefix',
Expand All @@ -724,7 +725,8 @@
]}
%>

<%def name="inner_body(keyword, extra_specified=None, needs_conversion=False)">
<%def name="inner_body(keyword, extra_specified=None, needs_conversion=False,
gecko_pref_controlled_initial_value=None)">
<%def name="variants(variants, include_aliases)">
% for variant in variants:
% if include_aliases:
Expand Down Expand Up @@ -773,10 +775,20 @@
}
#[inline]
pub fn get_initial_value() -> computed_value::T {
% if engine == "gecko" and gecko_pref_controlled_initial_value:
if static_prefs::pref!("${gecko_pref_controlled_initial_value.split('=')[0]}") {
return computed_value::T::${to_camel_case(gecko_pref_controlled_initial_value.split('=')[1])};
}
% endif
computed_value::T::${to_camel_case(values.split()[0])}
}
#[inline]
pub fn get_initial_specified_value() -> SpecifiedValue {
% if engine == "gecko" and gecko_pref_controlled_initial_value:
if static_prefs::pref!("${gecko_pref_controlled_initial_value.split('=')[0]}") {
return SpecifiedValue::${to_camel_case(gecko_pref_controlled_initial_value.split('=')[1])};
}
% endif
SpecifiedValue::${to_camel_case(values.split()[0])}
}
#[inline]
Expand Down Expand Up @@ -805,7 +817,8 @@
% else:
<%call expr="longhand(name, keyword=Keyword(name, values, **keyword_kwargs), **kwargs)">
${inner_body(Keyword(name, values, **keyword_kwargs),
extra_specified=extra_specified, needs_conversion=needs_conversion)}
extra_specified=extra_specified, needs_conversion=needs_conversion,
gecko_pref_controlled_initial_value=gecko_pref_controlled_initial_value)}
% if caller:
${caller.body()}
% endif
Expand Down

0 comments on commit 53f7e45

Please sign in to comment.