diff --git a/Meta/gn/secondary/Userland/Libraries/LibWeb/CSS/StyleValues/BUILD.gn b/Meta/gn/secondary/Userland/Libraries/LibWeb/CSS/StyleValues/BUILD.gn index 10f9f2577c..d464f239f8 100644 --- a/Meta/gn/secondary/Userland/Libraries/LibWeb/CSS/StyleValues/BUILD.gn +++ b/Meta/gn/secondary/Userland/Libraries/LibWeb/CSS/StyleValues/BUILD.gn @@ -15,7 +15,6 @@ source_set("StyleValues") { "EasingStyleValue.cpp", "EdgeStyleValue.cpp", "FilterValueListStyleValue.cpp", - "FontStyleValue.cpp", "GridAreaShorthandStyleValue.cpp", "GridAutoFlowStyleValue.cpp", "GridTemplateAreaStyleValue.cpp", diff --git a/Userland/Libraries/LibWeb/CMakeLists.txt b/Userland/Libraries/LibWeb/CMakeLists.txt index 5e5fa7082d..e2aad66281 100644 --- a/Userland/Libraries/LibWeb/CMakeLists.txt +++ b/Userland/Libraries/LibWeb/CMakeLists.txt @@ -92,7 +92,6 @@ set(SOURCES CSS/StyleValues/EasingStyleValue.cpp CSS/StyleValues/EdgeStyleValue.cpp CSS/StyleValues/FilterValueListStyleValue.cpp - CSS/StyleValues/FontStyleValue.cpp CSS/StyleValues/GridAreaShorthandStyleValue.cpp CSS/StyleValues/GridAutoFlowStyleValue.cpp CSS/StyleValues/GridTemplateAreaStyleValue.cpp diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp index 8663a6d5c4..effcdc5b6d 100644 --- a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp +++ b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp @@ -46,7 +46,6 @@ #include #include #include -#include #include #include #include @@ -4094,16 +4093,20 @@ RefPtr Parser::parse_font_value(Vector const& compon if (!font_size || !font_families) return nullptr; - if (!font_stretch) - font_stretch = property_initial_value(m_context.realm(), PropertyID::FontStretch); if (!font_style) font_style = property_initial_value(m_context.realm(), PropertyID::FontStyle); + if (!font_variant) + font_variant = property_initial_value(m_context.realm(), PropertyID::FontVariant); if (!font_weight) font_weight = property_initial_value(m_context.realm(), PropertyID::FontWeight); + if (!font_stretch) + font_stretch = property_initial_value(m_context.realm(), PropertyID::FontStretch); if (!line_height) line_height = property_initial_value(m_context.realm(), PropertyID::LineHeight); - return FontStyleValue::create(font_stretch.release_nonnull(), font_style.release_nonnull(), font_weight.release_nonnull(), font_size.release_nonnull(), line_height.release_nonnull(), font_families.release_nonnull()); + return ShorthandStyleValue::create(PropertyID::Font, + { PropertyID::FontStyle, PropertyID::FontVariant, PropertyID::FontWeight, PropertyID::FontStretch, PropertyID::FontSize, PropertyID::LineHeight, PropertyID::FontFamily }, + { font_style.release_nonnull(), font_variant.release_nonnull(), font_weight.release_nonnull(), font_stretch.release_nonnull(), font_size.release_nonnull(), line_height.release_nonnull(), font_families.release_nonnull() }); } RefPtr Parser::parse_font_family_value(TokenStream& tokens) diff --git a/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp b/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp index 2e3f877bec..e6ef47246b 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp +++ b/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp @@ -37,7 +37,6 @@ #include #include #include -#include #include #include #include @@ -751,25 +750,13 @@ static void set_property_expanding_shorthands(StyleProperties& style, CSS::Prope } if (property_id == CSS::PropertyID::Font) { - if (value.is_font()) { - auto const& font_shorthand = value.as_font(); - set_longhand_property(CSS::PropertyID::FontSize, font_shorthand.font_size()); - set_longhand_property(CSS::PropertyID::FontFamily, font_shorthand.font_families()); - set_longhand_property(CSS::PropertyID::FontStretch, font_shorthand.font_stretch()); - set_longhand_property(CSS::PropertyID::FontStyle, font_shorthand.font_style()); - set_longhand_property(CSS::PropertyID::FontWeight, font_shorthand.font_weight()); - set_longhand_property(CSS::PropertyID::LineHeight, font_shorthand.line_height()); - // FIXME: Implement font-variant - return; - } - + set_longhand_property(CSS::PropertyID::FontStyle, value); + set_longhand_property(CSS::PropertyID::FontVariant, value); + set_longhand_property(CSS::PropertyID::FontWeight, value); set_longhand_property(CSS::PropertyID::FontStretch, value); set_longhand_property(CSS::PropertyID::FontSize, value); - set_longhand_property(CSS::PropertyID::FontFamily, value); - set_longhand_property(CSS::PropertyID::FontStyle, value); - set_longhand_property(CSS::PropertyID::FontWeight, value); set_longhand_property(CSS::PropertyID::LineHeight, value); - // FIXME: Implement font-variant + set_longhand_property(CSS::PropertyID::FontFamily, value); return; } diff --git a/Userland/Libraries/LibWeb/CSS/StyleValue.cpp b/Userland/Libraries/LibWeb/CSS/StyleValue.cpp index a8599d35e7..9ee5257fb8 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleValue.cpp +++ b/Userland/Libraries/LibWeb/CSS/StyleValue.cpp @@ -25,7 +25,6 @@ #include #include #include -#include #include #include #include diff --git a/Userland/Libraries/LibWeb/CSS/StyleValue.h b/Userland/Libraries/LibWeb/CSS/StyleValue.h index 447ae169fb..a698d1f914 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleValue.h +++ b/Userland/Libraries/LibWeb/CSS/StyleValue.h @@ -97,7 +97,6 @@ using StyleValueVector = Vector>; __ENUMERATE_STYLE_VALUE_TYPE(Easing, easing) \ __ENUMERATE_STYLE_VALUE_TYPE(Edge, edge) \ __ENUMERATE_STYLE_VALUE_TYPE(FilterValueList, filter_value_list) \ - __ENUMERATE_STYLE_VALUE_TYPE(Font, font) \ __ENUMERATE_STYLE_VALUE_TYPE(Frequency, frequency) \ __ENUMERATE_STYLE_VALUE_TYPE(GridAreaShorthand, grid_area_shorthand) \ __ENUMERATE_STYLE_VALUE_TYPE(GridAutoFlow, grid_auto_flow) \ diff --git a/Userland/Libraries/LibWeb/Forward.h b/Userland/Libraries/LibWeb/Forward.h index a179db0d28..b0d6090b6b 100644 --- a/Userland/Libraries/LibWeb/Forward.h +++ b/Userland/Libraries/LibWeb/Forward.h @@ -103,7 +103,6 @@ class ElementInlineCSSStyleDeclaration; class ExplicitGridTrack; class FilterValueListStyleValue; class FontFace; -class FontStyleValue; class Frequency; class FrequencyOrCalculated; class FrequencyPercentage; diff --git a/Userland/Libraries/LibWeb/HTML/Canvas/CanvasTextDrawingStyles.h b/Userland/Libraries/LibWeb/HTML/Canvas/CanvasTextDrawingStyles.h index 71288a8eeb..208bd4dedc 100644 --- a/Userland/Libraries/LibWeb/HTML/Canvas/CanvasTextDrawingStyles.h +++ b/Userland/Libraries/LibWeb/HTML/Canvas/CanvasTextDrawingStyles.h @@ -8,7 +8,7 @@ #include #include -#include +#include #include #include @@ -28,12 +28,12 @@ public: } // On getting, the font attribute must return the serialized form of the current font of the context (with no 'line-height' component). - auto const& font_style_value = my_drawing_state().font_style_value->as_font(); - return DeprecatedString::formatted("{} {} {} {}", - font_style_value.font_style()->to_string(), - font_style_value.font_weight()->to_string(), - font_style_value.font_size()->to_string(), - font_style_value.font_families()->to_string()); + auto const& font_style_value = my_drawing_state().font_style_value->as_shorthand(); + auto font_style = font_style_value.longhand(CSS::PropertyID::FontStyle); + auto font_weight = font_style_value.longhand(CSS::PropertyID::FontWeight); + auto font_size = font_style_value.longhand(CSS::PropertyID::FontSize); + auto font_family = font_style_value.longhand(CSS::PropertyID::FontFamily); + return DeprecatedString::formatted("{} {} {} {}", font_style->to_string(), font_weight->to_string(), font_size->to_string(), font_family->to_string()); } void set_font(StringView font) @@ -51,9 +51,14 @@ public: my_drawing_state().font_style_value = font_style_value_result.release_nonnull(); // Load font with font style value properties - auto const& font_style_value = my_drawing_state().font_style_value->as_font(); + auto const& font_style_value = my_drawing_state().font_style_value->as_shorthand(); auto& canvas_element = reinterpret_cast(*this).canvas_element(); - my_drawing_state().current_font = canvas_element.document().style_computer().compute_font_for_style_values(&canvas_element, {}, font_style_value.font_families(), font_style_value.font_size(), font_style_value.font_style(), font_style_value.font_weight(), font_style_value.font_stretch()); + auto& font_style = *font_style_value.longhand(CSS::PropertyID::FontStyle); + auto& font_weight = *font_style_value.longhand(CSS::PropertyID::FontWeight); + auto& font_stretch = *font_style_value.longhand(CSS::PropertyID::FontStretch); + auto& font_size = *font_style_value.longhand(CSS::PropertyID::FontSize); + auto& font_family = *font_style_value.longhand(CSS::PropertyID::FontFamily); + my_drawing_state().current_font = canvas_element.document().style_computer().compute_font_for_style_values(&canvas_element, {}, font_family, font_size, font_style, font_weight, font_stretch); } Bindings::CanvasTextAlign text_align() const { return my_drawing_state().text_align; }