mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
Auto merge of #20187 - emilio:font-optical-sizing, r=emilio
style: Add font-optical-sizing property. Patch by Jonathan Kew <jkew@mozilla.com>. Bug: 1435692 Reviewed-by: emilio <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/20187) <!-- Reviewable:end -->
This commit is contained in:
commit
df079286c2
4 changed files with 2188 additions and 1246 deletions
File diff suppressed because it is too large
Load diff
|
@ -19,7 +19,7 @@ SYSTEM_FONT_LONGHANDS = """font_family font_size font_style
|
||||||
font_size_adjust font_variant_alternates
|
font_size_adjust font_variant_alternates
|
||||||
font_variant_ligatures font_variant_east_asian
|
font_variant_ligatures font_variant_east_asian
|
||||||
font_variant_numeric font_language_override
|
font_variant_numeric font_language_override
|
||||||
font_feature_settings""".split()
|
font_feature_settings font_optical_sizing""".split()
|
||||||
|
|
||||||
|
|
||||||
def maybe_moz_logical_alias(product, side, prop):
|
def maybe_moz_logical_alias(product, side, prop):
|
||||||
|
|
|
@ -15,15 +15,16 @@ ${helpers.predefined_type("font-family",
|
||||||
spec="https://drafts.csswg.org/css-fonts/#propdef-font-family",
|
spec="https://drafts.csswg.org/css-fonts/#propdef-font-family",
|
||||||
servo_restyle_damage="rebuild_and_reflow")}
|
servo_restyle_damage="rebuild_and_reflow")}
|
||||||
|
|
||||||
${helpers.single_keyword_system("font-style",
|
${helpers.single_keyword_system(
|
||||||
"normal italic oblique",
|
"font-style",
|
||||||
gecko_constant_prefix="NS_FONT_STYLE",
|
"normal italic oblique",
|
||||||
gecko_ffi_name="mFont.style",
|
gecko_constant_prefix="NS_FONT_STYLE",
|
||||||
spec="https://drafts.csswg.org/css-fonts/#propdef-font-style",
|
gecko_ffi_name="mFont.style",
|
||||||
flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER",
|
spec="https://drafts.csswg.org/css-fonts/#propdef-font-style",
|
||||||
animation_value_type="discrete",
|
flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER",
|
||||||
servo_restyle_damage="rebuild_and_reflow")}
|
animation_value_type="discrete",
|
||||||
|
servo_restyle_damage="rebuild_and_reflow"
|
||||||
|
)}
|
||||||
|
|
||||||
<% font_variant_caps_custom_consts= { "small-caps": "SMALLCAPS",
|
<% font_variant_caps_custom_consts= { "small-caps": "SMALLCAPS",
|
||||||
"all-small-caps": "ALLSMALL",
|
"all-small-caps": "ALLSMALL",
|
||||||
|
@ -180,6 +181,16 @@ ${helpers.predefined_type("font-language-override",
|
||||||
flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER",
|
flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER",
|
||||||
spec="https://drafts.csswg.org/css-fonts-3/#propdef-font-language-override")}
|
spec="https://drafts.csswg.org/css-fonts-3/#propdef-font-language-override")}
|
||||||
|
|
||||||
|
${helpers.single_keyword_system("font-optical-sizing",
|
||||||
|
"auto none",
|
||||||
|
products="gecko",
|
||||||
|
gecko_pref="layout.css.font-variations.enabled",
|
||||||
|
gecko_ffi_name="mFont.opticalSizing",
|
||||||
|
gecko_constant_prefix="NS_FONT_OPTICAL_SIZING",
|
||||||
|
animation_value_type="discrete",
|
||||||
|
flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER",
|
||||||
|
spec="https://www.w3.org/TR/css-fonts-4/#font-optical-sizing-def")}
|
||||||
|
|
||||||
${helpers.predefined_type("-x-lang",
|
${helpers.predefined_type("-x-lang",
|
||||||
"XLang",
|
"XLang",
|
||||||
products="gecko",
|
products="gecko",
|
||||||
|
@ -278,9 +289,11 @@ ${helpers.predefined_type("-x-text-zoom",
|
||||||
-moz-list -moz-field""".split()
|
-moz-list -moz-field""".split()
|
||||||
kw_font_props = """font_style font_variant_caps font_stretch
|
kw_font_props = """font_style font_variant_caps font_stretch
|
||||||
font_kerning font_variant_position font_variant_ligatures
|
font_kerning font_variant_position font_variant_ligatures
|
||||||
font_variant_east_asian font_variant_numeric""".split()
|
font_variant_east_asian font_variant_numeric
|
||||||
|
font_optical_sizing""".split()
|
||||||
kw_cast = """font_style font_variant_caps font_stretch
|
kw_cast = """font_style font_variant_caps font_stretch
|
||||||
font_kerning font_variant_position""".split()
|
font_kerning font_variant_position
|
||||||
|
font_optical_sizing""".split()
|
||||||
%>
|
%>
|
||||||
#[derive(Clone, Copy, Debug, Eq, Hash, MallocSizeOf, PartialEq, ToCss)]
|
#[derive(Clone, Copy, Debug, Eq, Hash, MallocSizeOf, PartialEq, ToCss)]
|
||||||
pub enum SystemFont {
|
pub enum SystemFont {
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
font-size line-height font-family
|
font-size line-height font-family
|
||||||
${'font-size-adjust' if product == 'gecko' else ''}
|
${'font-size-adjust' if product == 'gecko' else ''}
|
||||||
${'font-kerning' 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-alternates' if product == 'gecko' else ''}
|
||||||
${'font-variant-east-asian' if product == 'gecko' else ''}
|
${'font-variant-east-asian' if product == 'gecko' else ''}
|
||||||
${'font-variant-ligatures' if product == 'gecko' else ''}
|
${'font-variant-ligatures' if product == 'gecko' else ''}
|
||||||
|
@ -30,7 +31,8 @@
|
||||||
gecko_sub_properties = "kerning language_override size_adjust \
|
gecko_sub_properties = "kerning language_override size_adjust \
|
||||||
variant_alternates variant_east_asian \
|
variant_alternates variant_east_asian \
|
||||||
variant_ligatures variant_numeric \
|
variant_ligatures variant_numeric \
|
||||||
variant_position feature_settings".split()
|
variant_position feature_settings \
|
||||||
|
optical_sizing".split()
|
||||||
%>
|
%>
|
||||||
% if product == "gecko":
|
% if product == "gecko":
|
||||||
% for prop in gecko_sub_properties:
|
% for prop in gecko_sub_properties:
|
||||||
|
@ -155,11 +157,19 @@
|
||||||
% endif
|
% endif
|
||||||
|
|
||||||
% if product == "gecko":
|
% if product == "gecko":
|
||||||
% for name in gecko_sub_properties:
|
if let Some(v) = self.font_optical_sizing {
|
||||||
if self.font_${name} != &font_${name}::get_initial_specified_value() {
|
if v != &font_optical_sizing::get_initial_specified_value() {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
% endfor
|
}
|
||||||
|
|
||||||
|
% for name in gecko_sub_properties:
|
||||||
|
% if name != "optical_sizing":
|
||||||
|
if self.font_${name} != &font_${name}::get_initial_specified_value() {
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
% endif
|
||||||
|
% endfor
|
||||||
% endif
|
% endif
|
||||||
|
|
||||||
// In case of serialization for canvas font, we need to drop
|
// In case of serialization for canvas font, we need to drop
|
||||||
|
@ -193,12 +203,22 @@
|
||||||
let mut all = true;
|
let mut all = true;
|
||||||
|
|
||||||
% for prop in SYSTEM_FONT_LONGHANDS:
|
% for prop in SYSTEM_FONT_LONGHANDS:
|
||||||
if let Some(s) = self.${prop}.get_system() {
|
% if prop == "font_optical_sizing":
|
||||||
debug_assert!(sys.is_none() || s == sys.unwrap());
|
if let Some(value) = self.${prop} {
|
||||||
sys = Some(s);
|
% else:
|
||||||
} else {
|
{
|
||||||
all = false;
|
let value = self.${prop};
|
||||||
|
% endif
|
||||||
|
match value.get_system() {
|
||||||
|
Some(s) => {
|
||||||
|
debug_assert!(sys.is_none() || s == sys.unwrap());
|
||||||
|
sys = Some(s);
|
||||||
|
}
|
||||||
|
None => {
|
||||||
|
all = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
% endfor
|
% endfor
|
||||||
if self.line_height != &LineHeight::normal() {
|
if self.line_height != &LineHeight::normal() {
|
||||||
all = false
|
all = false
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue