1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 08:17:35 +00:00

LibWeb: Replace FontStyleValue with ShorthandStyleValue

Also, actually include font-variant since we were already parsing it but
throwing it away.
This commit is contained in:
Sam Atkins 2023-09-19 16:39:50 +01:00 committed by Sam Atkins
parent 34591549b1
commit 9b4ddff6a9
8 changed files with 25 additions and 35 deletions

View file

@ -46,7 +46,6 @@
#include <LibWeb/CSS/StyleValues/EasingStyleValue.h>
#include <LibWeb/CSS/StyleValues/EdgeStyleValue.h>
#include <LibWeb/CSS/StyleValues/FilterValueListStyleValue.h>
#include <LibWeb/CSS/StyleValues/FontStyleValue.h>
#include <LibWeb/CSS/StyleValues/FrequencyStyleValue.h>
#include <LibWeb/CSS/StyleValues/GridAreaShorthandStyleValue.h>
#include <LibWeb/CSS/StyleValues/GridAutoFlowStyleValue.h>
@ -4094,16 +4093,20 @@ RefPtr<StyleValue> Parser::parse_font_value(Vector<ComponentValue> 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<StyleValue> Parser::parse_font_family_value(TokenStream<ComponentValue>& tokens)

View file

@ -37,7 +37,6 @@
#include <LibWeb/CSS/StyleValues/DisplayStyleValue.h>
#include <LibWeb/CSS/StyleValues/EasingStyleValue.h>
#include <LibWeb/CSS/StyleValues/FilterValueListStyleValue.h>
#include <LibWeb/CSS/StyleValues/FontStyleValue.h>
#include <LibWeb/CSS/StyleValues/GridAreaShorthandStyleValue.h>
#include <LibWeb/CSS/StyleValues/GridTrackPlacementShorthandStyleValue.h>
#include <LibWeb/CSS/StyleValues/GridTrackPlacementStyleValue.h>
@ -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;
}

View file

@ -25,7 +25,6 @@
#include <LibWeb/CSS/StyleValues/EasingStyleValue.h>
#include <LibWeb/CSS/StyleValues/EdgeStyleValue.h>
#include <LibWeb/CSS/StyleValues/FilterValueListStyleValue.h>
#include <LibWeb/CSS/StyleValues/FontStyleValue.h>
#include <LibWeb/CSS/StyleValues/FrequencyStyleValue.h>
#include <LibWeb/CSS/StyleValues/GridAreaShorthandStyleValue.h>
#include <LibWeb/CSS/StyleValues/GridAutoFlowStyleValue.h>

View file

@ -97,7 +97,6 @@ using StyleValueVector = Vector<ValueComparingNonnullRefPtr<StyleValue const>>;
__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) \