mirror of
https://github.com/servo/servo.git
synced 2025-10-04 02:29:12 +01:00
Stylo: replace product={gecko,servo} with engine={gecko,servo-2013,servo-2020}
Renaming the variable helped make sure I looked at every use.
This commit is contained in:
parent
f1300bb98b
commit
ddb4e369dd
52 changed files with 870 additions and 469 deletions
|
@ -5,22 +5,33 @@
|
|||
<%namespace name="helpers" file="/helpers.mako.rs" />
|
||||
<% from data import SYSTEM_FONT_LONGHANDS %>
|
||||
|
||||
<%helpers:shorthand name="font"
|
||||
sub_properties="font-style font-variant-caps font-weight font-stretch
|
||||
font-size line-height font-family
|
||||
${'font-size-adjust' if product == 'gecko' else ''}
|
||||
${'font-kerning' if product == 'gecko' else ''}
|
||||
${'font-optical-sizing' if product == 'gecko' else ''}
|
||||
${'font-variant-alternates' if product == 'gecko' else ''}
|
||||
${'font-variant-east-asian' if product == 'gecko' else ''}
|
||||
${'font-variant-ligatures' if product == 'gecko' else ''}
|
||||
${'font-variant-numeric' if product == 'gecko' else ''}
|
||||
${'font-variant-position' if product == 'gecko' else ''}
|
||||
${'font-language-override' if product == 'gecko' else ''}
|
||||
${'font-feature-settings' if product == 'gecko' else ''}
|
||||
${'font-variation-settings' if product == 'gecko' else ''}"
|
||||
derive_value_info="False"
|
||||
spec="https://drafts.csswg.org/css-fonts-3/#propdef-font">
|
||||
<%helpers:shorthand
|
||||
name="font"
|
||||
engines="gecko servo-2013 servo-2020"
|
||||
servo_2020_pref="layout.2020.unimplemented"
|
||||
sub_properties="
|
||||
font-style
|
||||
font-variant-caps
|
||||
font-weight
|
||||
font-stretch
|
||||
font-size
|
||||
line-height
|
||||
font-family
|
||||
${'font-size-adjust' if engine == 'gecko' else ''}
|
||||
${'font-kerning' if engine == 'gecko' else ''}
|
||||
${'font-optical-sizing' if engine == 'gecko' else ''}
|
||||
${'font-variant-alternates' if engine == 'gecko' else ''}
|
||||
${'font-variant-east-asian' if engine == 'gecko' else ''}
|
||||
${'font-variant-ligatures' if engine == 'gecko' else ''}
|
||||
${'font-variant-numeric' if engine == 'gecko' else ''}
|
||||
${'font-variant-position' if engine == 'gecko' else ''}
|
||||
${'font-language-override' if engine == 'gecko' else ''}
|
||||
${'font-feature-settings' if engine == 'gecko' else ''}
|
||||
${'font-variation-settings' if engine == 'gecko' else ''}
|
||||
"
|
||||
derive_value_info="False"
|
||||
spec="https://drafts.csswg.org/css-fonts-3/#propdef-font"
|
||||
>
|
||||
use crate::parser::Parse;
|
||||
use crate::properties::longhands::{font_family, font_style, font_weight, font_stretch};
|
||||
use crate::properties::longhands::font_variant_caps;
|
||||
|
@ -37,7 +48,7 @@
|
|||
variant_position feature_settings \
|
||||
variation_settings optical_sizing".split()
|
||||
%>
|
||||
% if product == "gecko":
|
||||
% if engine == "gecko":
|
||||
% for prop in gecko_sub_properties:
|
||||
use crate::properties::longhands::font_${prop};
|
||||
% endfor
|
||||
|
@ -54,7 +65,7 @@
|
|||
let mut weight = None;
|
||||
let mut stretch = None;
|
||||
let size;
|
||||
% if product == "gecko":
|
||||
% if engine == "gecko":
|
||||
if let Ok(sys) = input.try(SystemFont::parse) {
|
||||
return Ok(expanded! {
|
||||
% for name in SYSTEM_FONT_LONGHANDS:
|
||||
|
@ -135,7 +146,7 @@
|
|||
font_size: size,
|
||||
line_height: line_height.unwrap_or(LineHeight::normal()),
|
||||
font_family: family,
|
||||
% if product == "gecko":
|
||||
% if engine == "gecko":
|
||||
% for name in gecko_sub_properties:
|
||||
font_${name}: font_${name}::get_initial_specified_value(),
|
||||
% endfor
|
||||
|
@ -143,7 +154,7 @@
|
|||
})
|
||||
}
|
||||
|
||||
% if product == "gecko":
|
||||
% if engine == "gecko":
|
||||
enum CheckSystemResult {
|
||||
AllSystem(SystemFont),
|
||||
SomeSystem,
|
||||
|
@ -153,7 +164,7 @@
|
|||
|
||||
impl<'a> ToCss for LonghandsToSerialize<'a> {
|
||||
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result where W: fmt::Write {
|
||||
% if product == "gecko":
|
||||
% if engine == "gecko":
|
||||
match self.check_system() {
|
||||
CheckSystemResult::AllSystem(sys) => return sys.to_css(dest),
|
||||
CheckSystemResult::SomeSystem => return Ok(()),
|
||||
|
@ -161,7 +172,7 @@
|
|||
}
|
||||
% endif
|
||||
|
||||
% if product == "gecko":
|
||||
% if engine == "gecko":
|
||||
if let Some(v) = self.font_optical_sizing {
|
||||
if v != &font_optical_sizing::get_initial_specified_value() {
|
||||
return Ok(());
|
||||
|
@ -222,7 +233,7 @@
|
|||
}
|
||||
|
||||
impl<'a> LonghandsToSerialize<'a> {
|
||||
% if product == "gecko":
|
||||
% if engine == "gecko":
|
||||
/// Check if some or all members are system fonts
|
||||
fn check_system(&self) -> CheckSystemResult {
|
||||
let mut sys = None;
|
||||
|
@ -285,18 +296,19 @@
|
|||
</%helpers:shorthand>
|
||||
|
||||
<%helpers:shorthand name="font-variant"
|
||||
engines="gecko servo-2013"
|
||||
flags="SHORTHAND_IN_GETCS"
|
||||
sub_properties="font-variant-caps
|
||||
${'font-variant-alternates' if product == 'gecko' else ''}
|
||||
${'font-variant-east-asian' if product == 'gecko' else ''}
|
||||
${'font-variant-ligatures' if product == 'gecko' else ''}
|
||||
${'font-variant-numeric' if product == 'gecko' else ''}
|
||||
${'font-variant-position' if product == 'gecko' else ''}"
|
||||
${'font-variant-alternates' if engine == 'gecko' else ''}
|
||||
${'font-variant-east-asian' if engine == 'gecko' else ''}
|
||||
${'font-variant-ligatures' if engine == 'gecko' else ''}
|
||||
${'font-variant-numeric' if engine == 'gecko' else ''}
|
||||
${'font-variant-position' if engine == 'gecko' else ''}"
|
||||
spec="https://drafts.csswg.org/css-fonts-3/#propdef-font-variant">
|
||||
<% gecko_sub_properties = "alternates east_asian ligatures numeric position".split() %>
|
||||
<%
|
||||
sub_properties = ["caps"]
|
||||
if product == "gecko":
|
||||
if engine == "gecko":
|
||||
sub_properties += gecko_sub_properties
|
||||
%>
|
||||
|
||||
|
@ -319,7 +331,7 @@
|
|||
} else if input.try(|input| input.expect_ident_matching("none")).is_ok() {
|
||||
// The 'none' value sets 'font-variant-ligatures' to 'none' and resets all other sub properties
|
||||
// to their initial value.
|
||||
% if product == "gecko":
|
||||
% if engine == "gecko":
|
||||
ligatures = Some(FontVariantLigatures::none());
|
||||
% endif
|
||||
} else {
|
||||
|
@ -359,7 +371,7 @@
|
|||
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result where W: fmt::Write {
|
||||
|
||||
let has_none_ligatures =
|
||||
% if product == "gecko":
|
||||
% if engine == "gecko":
|
||||
self.font_variant_ligatures == &FontVariantLigatures::none();
|
||||
% else:
|
||||
false;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue