LibWeb: Move to_font_slope from StyleValue to FontStyleStyleValue

This method only operated on `FontStyleStyleValue`s anyway so this is a
better place to have it
This commit is contained in:
Callum Law 2025-09-02 22:41:48 +12:00 committed by Sam Atkins
commit 10793aef56
Notes: github-actions[bot] 2025-09-19 09:07:50 +00:00
6 changed files with 33 additions and 26 deletions

View file

@ -5,6 +5,7 @@
*/
#include "FontStyleStyleValue.h"
#include <LibGfx/Font/FontStyleMapping.h>
#include <LibWeb/CSS/Serialize.h>
#include <LibWeb/CSS/StyleValues/AngleStyleValue.h>
#include <LibWeb/CSS/StyleValues/StyleValue.h>
@ -20,6 +21,23 @@ FontStyleStyleValue::FontStyleStyleValue(FontStyle font_style, ValueComparingRef
FontStyleStyleValue::~FontStyleStyleValue() = default;
int FontStyleStyleValue::to_font_slope() const
{
// FIXME: Implement oblique <angle>
switch (as_font_style().font_style()) {
case FontStyle::Italic:
static int italic_slope = Gfx::name_to_slope("Italic"sv);
return italic_slope;
case FontStyle::Oblique:
static int oblique_slope = Gfx::name_to_slope("Oblique"sv);
return oblique_slope;
case FontStyle::Normal:
default:
static int normal_slope = Gfx::name_to_slope("Normal"sv);
return normal_slope;
}
}
String FontStyleStyleValue::to_string(SerializationMode mode) const
{
Optional<String> angle_string;