mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-24 08:59:50 +00:00
LibWeb: Add absolutized method for FontStyleStyleValue
This commit is contained in:
parent
28451b16c9
commit
8284a99f0a
Notes:
github-actions[bot]
2025-10-20 15:14:13 +00:00
Author: https://github.com/Calme1709
Commit: 8284a99f0a
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6426
Reviewed-by: https://github.com/AtkinsSJ ✅
3 changed files with 16 additions and 14 deletions
|
|
@ -3456,18 +3456,7 @@ NonnullRefPtr<StyleValue const> StyleComputer::compute_font_style(NonnullRefPtr<
|
||||||
if (specified_value->is_keyword())
|
if (specified_value->is_keyword())
|
||||||
return FontStyleStyleValue::create(*keyword_to_font_style(specified_value->to_keyword()));
|
return FontStyleStyleValue::create(*keyword_to_font_style(specified_value->to_keyword()));
|
||||||
|
|
||||||
auto const& angle_value = specified_value->as_font_style().angle();
|
return specified_value->absolutized(computation_context);
|
||||||
|
|
||||||
if (!angle_value)
|
|
||||||
return specified_value;
|
|
||||||
|
|
||||||
if (angle_value->is_angle())
|
|
||||||
return FontStyleStyleValue::create(specified_value->as_font_style().font_style(), AngleStyleValue::create(Angle::make_degrees(angle_value->as_angle().angle().to_degrees())));
|
|
||||||
|
|
||||||
if (angle_value->is_calculated())
|
|
||||||
return FontStyleStyleValue::create(specified_value->as_font_style().font_style(), AngleStyleValue::create(angle_value->as_calculated().resolve_angle(CalculationResolutionContext::from_computation_context(computation_context)).value()));
|
|
||||||
|
|
||||||
VERIFY_NOT_REACHED();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NonnullRefPtr<StyleValue const> StyleComputer::compute_font_weight(NonnullRefPtr<StyleValue const> const& specified_value, double inherited_font_weight, ComputationContext const& computation_context)
|
NonnullRefPtr<StyleValue const> StyleComputer::compute_font_weight(NonnullRefPtr<StyleValue const> const& specified_value, double inherited_font_weight, ComputationContext const& computation_context)
|
||||||
|
|
|
||||||
|
|
@ -50,11 +50,23 @@ String FontStyleStyleValue::to_string(SerializationMode mode) const
|
||||||
builder.append(CSS::to_string(m_font_style));
|
builder.append(CSS::to_string(m_font_style));
|
||||||
// https://drafts.csswg.org/css-fonts/#valdef-font-style-oblique-angle--90deg-90deg
|
// https://drafts.csswg.org/css-fonts/#valdef-font-style-oblique-angle--90deg-90deg
|
||||||
// The lack of an <angle> represents 14deg. (Note that a font might internally provide its own mapping for "oblique", but the mapping within the font is disregarded.)
|
// The lack of an <angle> represents 14deg. (Note that a font might internally provide its own mapping for "oblique", but the mapping within the font is disregarded.)
|
||||||
static auto default_angle = Angle::make_degrees(14);
|
if (angle_string.has_value() && angle_string != "14deg"sv)
|
||||||
if (angle_string.has_value() && !(m_angle_value->is_angle() && m_angle_value->as_angle().angle() == default_angle))
|
|
||||||
builder.appendff(" {}", angle_string);
|
builder.appendff(" {}", angle_string);
|
||||||
|
|
||||||
return MUST(builder.to_string());
|
return MUST(builder.to_string());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ValueComparingNonnullRefPtr<StyleValue const> FontStyleStyleValue::absolutized(ComputationContext const& computation_context) const
|
||||||
|
{
|
||||||
|
ValueComparingRefPtr<StyleValue const> absolutized_angle;
|
||||||
|
|
||||||
|
if (m_angle_value)
|
||||||
|
absolutized_angle = m_angle_value->absolutized(computation_context);
|
||||||
|
|
||||||
|
if (absolutized_angle == m_angle_value)
|
||||||
|
return *this;
|
||||||
|
|
||||||
|
return FontStyleStyleValue::create(m_font_style, absolutized_angle);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@ public:
|
||||||
int to_font_slope() const;
|
int to_font_slope() const;
|
||||||
|
|
||||||
virtual String to_string(SerializationMode) const override;
|
virtual String to_string(SerializationMode) const override;
|
||||||
|
virtual ValueComparingNonnullRefPtr<StyleValue const> absolutized(ComputationContext const& computation_context) const override;
|
||||||
|
|
||||||
bool equals(StyleValue const& other) const override
|
bool equals(StyleValue const& other) const override
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue