style: Update font-style to css-fonts-4.

Bug: 1455358
Reviewed-by: xidorn
MozReview-Commit-ID: 1Nq5DyCjaZe
This commit is contained in:
Emilio Cobos Álvarez 2018-04-19 20:38:08 +02:00
parent f7636e6662
commit 32d4da8a99
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
11 changed files with 361 additions and 63 deletions

View file

@ -2614,7 +2614,6 @@ fn static_assert() {
unsafe { bindings::Gecko_FontStretch_SetFloat(&mut self.gecko.mFont.stretch, (v.0).0) };
}
${impl_simple_copy('font_stretch', 'mFont.stretch')}
pub fn clone_font_stretch(&self) -> longhands::font_stretch::computed_value::T {
use values::computed::Percentage;
use values::generics::NonNegative;
@ -2625,6 +2624,21 @@ fn static_assert() {
NonNegative(Percentage(stretch))
}
pub fn set_font_style(&mut self, v: longhands::font_style::computed_value::T) {
use values::computed::font::FontStyle;
self.gecko.mFont.style = match v {
FontStyle::Normal => structs::NS_STYLE_FONT_STYLE_NORMAL,
FontStyle::Italic => structs::NS_STYLE_FONT_STYLE_ITALIC,
// FIXME(emilio): Honor the angle.
FontStyle::Oblique(ref _angle) => structs::NS_STYLE_FONT_STYLE_OBLIQUE,
} as u8;
}
${impl_simple_copy('font_style', 'mFont.style')}
pub fn clone_font_style(&self) -> longhands::font_style::computed_value::T {
use values::computed::font::FontStyle;
FontStyle::from_gecko(self.gecko.mFont.style)
}
${impl_simple_type_with_conversion("font_synthesis", "mFont.synthesis")}
pub fn set_font_size_adjust(&mut self, v: longhands::font_size_adjust::computed_value::T) {

View file

@ -15,15 +15,16 @@ ${helpers.predefined_type("font-family",
spec="https://drafts.csswg.org/css-fonts/#propdef-font-family",
servo_restyle_damage="rebuild_and_reflow")}
${helpers.single_keyword_system(
${helpers.predefined_type(
"font-style",
"normal italic oblique",
gecko_constant_prefix="NS_FONT_STYLE",
gecko_ffi_name="mFont.style",
spec="https://drafts.csswg.org/css-fonts/#propdef-font-style",
"FontStyle",
initial_value="computed::FontStyle::Normal",
initial_specified_value="specified::FontStyle::Normal",
# FIXME(emilio): This won't handle clamping correctly.
animation_value_type="ComputedValue",
flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER",
animation_value_type="discrete",
servo_restyle_damage="rebuild_and_reflow"
spec="https://drafts.csswg.org/css-fonts/#propdef-font-style",
servo_restyle_damage="rebuild_and_reflow",
)}
<% font_variant_caps_custom_consts= { "small-caps": "SMALLCAPS",
@ -289,12 +290,11 @@ ${helpers.predefined_type("-x-text-zoom",
-moz-window -moz-document -moz-workspace -moz-desktop
-moz-info -moz-dialog -moz-button -moz-pull-down-menu
-moz-list -moz-field""".split()
kw_font_props = """font_style font_variant_caps
kw_font_props = """font_variant_caps
font_kerning font_variant_position font_variant_ligatures
font_variant_east_asian font_variant_numeric
font_optical_sizing""".split()
kw_cast = """font_style font_variant_caps
font_kerning font_variant_position
kw_cast = """font_variant_caps font_kerning font_variant_position
font_optical_sizing""".split()
%>
#[derive(Clone, Copy, Debug, Eq, Hash, MallocSizeOf, PartialEq, ToCss)]
@ -330,7 +330,7 @@ ${helpers.predefined_type("-x-text-zoom",
use gecko_bindings::structs::{LookAndFeel_FontID, nsFont};
use std::mem;
use values::computed::Percentage;
use values::computed::font::{FontSize, FontFamilyList};
use values::computed::font::{FontSize, FontStyle, FontFamilyList};
use values::generics::NonNegative;
let id = match *self {
@ -352,6 +352,7 @@ ${helpers.predefined_type("-x-text-zoom",
}
let font_weight = longhands::font_weight::computed_value::T::from_gecko_weight(system.weight);
let font_stretch = NonNegative(Percentage(system.stretch as f32));
let font_style = FontStyle::from_gecko(system.style);
let ret = ComputedSystemFont {
font_family: longhands::font_family::computed_value::T(
FontFamilyList(
@ -359,11 +360,12 @@ ${helpers.predefined_type("-x-text-zoom",
)
),
font_size: FontSize {
size: Au(system.size).into(),
keyword_info: None
size: Au(system.size).into(),
keyword_info: None
},
font_weight,
font_stretch,
font_style,
font_size_adjust: longhands::font_size_adjust::computed_value
::T::from_gecko_adjust(system.sizeAdjust),
% for kwprop in kw_font_props: