mirror of
https://github.com/servo/servo.git
synced 2025-08-04 13:10:20 +01:00
style: Move moz-control-character-visibility out of mako, and remove support for gecko_pref_controlled_initial_value
No behavior change, just cleanup. Actually seem this technically _adds_ some code even though it's a cleanup, but that's mostly because of the wrapping of the derive list. The resulting code is simpler (more in-line with our usual things, so I think it's an improvement). Differential Revision: https://phabricator.services.mozilla.com/D111551
This commit is contained in:
parent
fac547276f
commit
743f213c25
5 changed files with 48 additions and 32 deletions
|
@ -483,6 +483,7 @@ class Longhand(Property):
|
||||||
"LineBreak",
|
"LineBreak",
|
||||||
"MasonryAutoFlow",
|
"MasonryAutoFlow",
|
||||||
"MozForceBrokenImageIcon",
|
"MozForceBrokenImageIcon",
|
||||||
|
"text::MozControlCharacterVisibility",
|
||||||
"MozListReversed",
|
"MozListReversed",
|
||||||
"MathDepth",
|
"MathDepth",
|
||||||
"MozScriptMinSize",
|
"MozScriptMinSize",
|
||||||
|
|
|
@ -707,8 +707,7 @@
|
||||||
</%def>
|
</%def>
|
||||||
|
|
||||||
<%def name="single_keyword(name, values, vector=False,
|
<%def name="single_keyword(name, values, vector=False,
|
||||||
needs_conversion=False, gecko_pref_controlled_initial_value=None,
|
needs_conversion=False, **kwargs)">
|
||||||
**kwargs)">
|
|
||||||
<%
|
<%
|
||||||
keyword_kwargs = {a: kwargs.pop(a, None) for a in [
|
keyword_kwargs = {a: kwargs.pop(a, None) for a in [
|
||||||
'gecko_constant_prefix',
|
'gecko_constant_prefix',
|
||||||
|
@ -725,10 +724,13 @@
|
||||||
]}
|
]}
|
||||||
%>
|
%>
|
||||||
|
|
||||||
<%def name="inner_body(keyword, needs_conversion=False,
|
<%def name="inner_body(keyword, needs_conversion=False)">
|
||||||
gecko_pref_controlled_initial_value=None)">
|
pub use self::computed_value::T as SpecifiedValue;
|
||||||
<%def name="variants(variants)">
|
pub mod computed_value {
|
||||||
% for variant in variants:
|
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
|
||||||
|
#[derive(Clone, Copy, Debug, Eq, FromPrimitive, MallocSizeOf, Parse, PartialEq, SpecifiedValueInfo, ToComputedValue, ToCss, ToResolvedValue, ToShmem)]
|
||||||
|
pub enum T {
|
||||||
|
% for variant in keyword.values_for(engine):
|
||||||
<%
|
<%
|
||||||
aliases = []
|
aliases = []
|
||||||
for alias, v in keyword.aliases_for(engine).items():
|
for alias, v in keyword.aliases_for(engine).items():
|
||||||
|
@ -740,31 +742,14 @@
|
||||||
% endif
|
% endif
|
||||||
${to_camel_case(variant)},
|
${to_camel_case(variant)},
|
||||||
% endfor
|
% endfor
|
||||||
</%def>
|
|
||||||
pub use self::computed_value::T as SpecifiedValue;
|
|
||||||
pub mod computed_value {
|
|
||||||
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
|
|
||||||
#[derive(Clone, Copy, Debug, Eq, FromPrimitive, MallocSizeOf, Parse, PartialEq, SpecifiedValueInfo, ToComputedValue, ToCss, ToResolvedValue, ToShmem)]
|
|
||||||
pub enum T {
|
|
||||||
${variants(data.longhands_by_name[name].keyword.values_for(engine))}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn get_initial_value() -> computed_value::T {
|
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])}
|
computed_value::T::${to_camel_case(values.split()[0])}
|
||||||
}
|
}
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn get_initial_specified_value() -> SpecifiedValue {
|
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])}
|
SpecifiedValue::${to_camel_case(values.split()[0])}
|
||||||
}
|
}
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -790,8 +775,7 @@
|
||||||
% else:
|
% else:
|
||||||
<%call expr="longhand(name, keyword=Keyword(name, values, **keyword_kwargs), **kwargs)">
|
<%call expr="longhand(name, keyword=Keyword(name, values, **keyword_kwargs), **kwargs)">
|
||||||
${inner_body(Keyword(name, values, **keyword_kwargs),
|
${inner_body(Keyword(name, values, **keyword_kwargs),
|
||||||
needs_conversion=needs_conversion,
|
needs_conversion=needs_conversion)}
|
||||||
gecko_pref_controlled_initial_value=gecko_pref_controlled_initial_value)}
|
|
||||||
% if caller:
|
% if caller:
|
||||||
${caller.body()}
|
${caller.body()}
|
||||||
% endif
|
% endif
|
||||||
|
|
|
@ -331,15 +331,13 @@ ${helpers.single_keyword(
|
||||||
servo_restyle_damage="rebuild_and_reflow",
|
servo_restyle_damage="rebuild_and_reflow",
|
||||||
)}
|
)}
|
||||||
|
|
||||||
${helpers.single_keyword(
|
${helpers.predefined_type(
|
||||||
"-moz-control-character-visibility",
|
"-moz-control-character-visibility",
|
||||||
"hidden visible",
|
"text::MozControlCharacterVisibility",
|
||||||
|
"Default::default()",
|
||||||
engines="gecko",
|
engines="gecko",
|
||||||
gecko_enum_prefix="StyleControlCharacterVisibility",
|
|
||||||
gecko_pref_controlled_initial_value="layout.css.control-characters.visible=visible",
|
|
||||||
animation_value_type="none",
|
animation_value_type="none",
|
||||||
gecko_ffi_name="mControlCharacterVisibility",
|
spec="Nonstandard"
|
||||||
spec="Nonstandard",
|
|
||||||
)}
|
)}
|
||||||
|
|
||||||
// text underline offset
|
// text underline offset
|
||||||
|
|
|
@ -18,7 +18,7 @@ use crate::Zero;
|
||||||
use std::fmt::{self, Write};
|
use std::fmt::{self, Write};
|
||||||
use style_traits::{CssWriter, ToCss};
|
use style_traits::{CssWriter, ToCss};
|
||||||
|
|
||||||
pub use crate::values::specified::text::{TextAlignLast, TextUnderlinePosition};
|
pub use crate::values::specified::text::{TextAlignLast, TextUnderlinePosition, MozControlCharacterVisibility};
|
||||||
pub use crate::values::specified::{LineBreak, OverflowWrap, RubyPosition, WordBreak};
|
pub use crate::values::specified::{LineBreak, OverflowWrap, RubyPosition, WordBreak};
|
||||||
pub use crate::values::specified::{TextDecorationLine, TextEmphasisPosition};
|
pub use crate::values::specified::{TextDecorationLine, TextEmphasisPosition};
|
||||||
pub use crate::values::specified::{TextDecorationSkipInk, TextJustify, TextTransform};
|
pub use crate::values::specified::{TextDecorationSkipInk, TextJustify, TextTransform};
|
||||||
|
|
|
@ -1028,6 +1028,39 @@ pub enum TextJustify {
|
||||||
InterCharacter,
|
InterCharacter,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Values for the `-moz-control-character-visibility` CSS property.
|
||||||
|
#[repr(u8)]
|
||||||
|
#[derive(
|
||||||
|
Clone,
|
||||||
|
Copy,
|
||||||
|
Debug,
|
||||||
|
Eq,
|
||||||
|
MallocSizeOf,
|
||||||
|
Parse,
|
||||||
|
PartialEq,
|
||||||
|
SpecifiedValueInfo,
|
||||||
|
ToComputedValue,
|
||||||
|
ToCss,
|
||||||
|
ToResolvedValue,
|
||||||
|
ToShmem,
|
||||||
|
)]
|
||||||
|
#[allow(missing_docs)]
|
||||||
|
pub enum MozControlCharacterVisibility {
|
||||||
|
Hidden,
|
||||||
|
Visible,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for MozControlCharacterVisibility {
|
||||||
|
fn default() -> Self {
|
||||||
|
if static_prefs::pref!("layout.css.control-characters.visible") {
|
||||||
|
Self::Visible
|
||||||
|
} else {
|
||||||
|
Self::Hidden
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// Values for the `line-break` property.
|
/// Values for the `line-break` property.
|
||||||
#[repr(u8)]
|
#[repr(u8)]
|
||||||
#[derive(
|
#[derive(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue