@@ -1078,6 +1078,9 @@ void StyleComputer::collect_animation_into(DOM::AbstractElement abstract_element
10781078 if (auto const & font_width_specified_value = specified_values.get (PropertyID::FontWidth); font_width_specified_value.has_value ())
10791079 result.set (PropertyID::FontWidth, compute_font_width (*font_width_specified_value.value (), parent_length_resolution_context));
10801080
1081+ if (auto const & font_style_specified_value = specified_values.get (PropertyID::FontStyle); font_style_specified_value.has_value ())
1082+ result.set (PropertyID::FontStyle, compute_font_style (*font_style_specified_value.value (), parent_length_resolution_context));
1083+
10811084 PropertyValueComputationContext property_value_computation_context {
10821085 .length_resolution_context = {
10831086 .viewport_rect = viewport_rect (),
@@ -1849,16 +1852,14 @@ CSSPixels StyleComputer::relative_size_mapping(RelativeSize relative_size, CSSPi
18491852 VERIFY_NOT_REACHED ();
18501853}
18511854
1852- RefPtr<Gfx::FontCascadeList const > StyleComputer::compute_font_for_style_values (StyleValue const & font_family, CSSPixels const & font_size, StyleValue const & font_style , double font_weight, Percentage const & font_width) const
1855+ RefPtr<Gfx::FontCascadeList const > StyleComputer::compute_font_for_style_values (StyleValue const & font_family, CSSPixels const & font_size, int slope , double font_weight, Percentage const & font_width) const
18531856{
18541857 // FIXME: We round to int here as that is what is expected by our font infrastructure below
18551858 auto width = round_to<int >(font_width.value ());
18561859
18571860 // FIXME: We round to int here as that is what is expected by our font infrastructure below
18581861 auto weight = round_to<int >(font_weight);
18591862
1860- auto slope = font_style.as_font_style ().to_font_slope ();
1861-
18621863 // FIXME: Implement the full font-matching algorithm: https://www.w3.org/TR/css-fonts-4/#font-matching-algorithm
18631864
18641865 float const font_size_in_pt = font_size * 0 .75f ;
@@ -2002,10 +2003,16 @@ void StyleComputer::compute_font(ComputedProperties& style, Optional<DOM::Abstra
20022003 compute_font_width (font_width_specified_value, length_resolution_context),
20032004 style.is_property_inherited (PropertyID::FontWidth) ? ComputedProperties::Inherited::Yes : ComputedProperties::Inherited::No);
20042005
2006+ auto const & font_style_specified_value = style.property (PropertyID::FontStyle, ComputedProperties::WithAnimationsApplied::No);
2007+
2008+ style.set_property (
2009+ PropertyID::FontStyle,
2010+ compute_font_style (font_style_specified_value, length_resolution_context),
2011+ style.is_property_inherited (PropertyID::FontStyle) ? ComputedProperties::Inherited::Yes : ComputedProperties::Inherited::No);
2012+
20052013 auto const & font_family = style.property (CSS::PropertyID::FontFamily);
2006- auto const & font_style = style.property (CSS::PropertyID::FontStyle);
20072014
2008- auto font_list = compute_font_for_style_values (font_family, style.font_size (), font_style , style.font_weight (), style.font_width ());
2015+ auto font_list = compute_font_for_style_values (font_family, style.font_size (), style. font_slope () , style.font_weight (), style.font_width ());
20092016 VERIFY (font_list);
20102017 VERIFY (!font_list->is_empty ());
20112018
@@ -3261,6 +3268,25 @@ NonnullRefPtr<StyleValue const> StyleComputer::compute_font_size(NonnullRefPtr<S
32613268 VERIFY_NOT_REACHED ();
32623269}
32633270
3271+ NonnullRefPtr<StyleValue const > StyleComputer::compute_font_style (NonnullRefPtr<StyleValue const > const & specified_value, Length::ResolutionContext const & parent_length_resolution_context)
3272+ {
3273+ // https://drafts.csswg.org/css-fonts-4/#font-style-prop
3274+ // the keyword specified, plus angle in degrees if specified
3275+
3276+ auto const & angle_value = specified_value->as_font_style ().angle ();
3277+
3278+ if (!angle_value)
3279+ return specified_value;
3280+
3281+ if (angle_value->is_angle ())
3282+ return FontStyleStyleValue::create (specified_value->as_font_style ().font_style (), AngleStyleValue::create (Angle::make_degrees (angle_value->as_angle ().angle ().to_degrees ())));
3283+
3284+ if (angle_value->is_calculated ())
3285+ return FontStyleStyleValue::create (specified_value->as_font_style ().font_style (), AngleStyleValue::create (angle_value->as_calculated ().resolve_angle ({ .length_resolution_context = parent_length_resolution_context }).value ()));
3286+
3287+ VERIFY_NOT_REACHED ();
3288+ }
3289+
32643290NonnullRefPtr<StyleValue const > StyleComputer::compute_font_weight (NonnullRefPtr<StyleValue const > const & specified_value, double inherited_font_weight, Length::ResolutionContext const & parent_length_resolution_context)
32653291{
32663292 // https://drafts.csswg.org/css-fonts-4/#font-weight-prop
0 commit comments