mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 02:47:34 +00:00
LibWeb: Part font property using TokenStream
This commit is contained in:
parent
333b705f25
commit
f84ccb8627
2 changed files with 5 additions and 4 deletions
|
@ -3967,7 +3967,7 @@ static bool is_generic_font_family(ValueID identifier)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<StyleValue> Parser::parse_font_value(Vector<ComponentValue> const& component_values)
|
RefPtr<StyleValue> Parser::parse_font_value(TokenStream<ComponentValue>& tokens)
|
||||||
{
|
{
|
||||||
RefPtr<StyleValue> font_stretch;
|
RefPtr<StyleValue> font_stretch;
|
||||||
RefPtr<StyleValue> font_style;
|
RefPtr<StyleValue> font_style;
|
||||||
|
@ -3983,8 +3983,8 @@ RefPtr<StyleValue> Parser::parse_font_value(Vector<ComponentValue> const& compon
|
||||||
// So, we have to handle that separately.
|
// So, we have to handle that separately.
|
||||||
int normal_count = 0;
|
int normal_count = 0;
|
||||||
|
|
||||||
auto tokens = TokenStream { component_values };
|
|
||||||
auto remaining_longhands = Vector { PropertyID::FontSize, PropertyID::FontStretch, PropertyID::FontStyle, PropertyID::FontVariant, PropertyID::FontWeight };
|
auto remaining_longhands = Vector { PropertyID::FontSize, PropertyID::FontStretch, PropertyID::FontStyle, PropertyID::FontVariant, PropertyID::FontWeight };
|
||||||
|
auto transaction = tokens.begin_transaction();
|
||||||
|
|
||||||
while (tokens.has_next_token()) {
|
while (tokens.has_next_token()) {
|
||||||
auto& peek_token = tokens.peek_token();
|
auto& peek_token = tokens.peek_token();
|
||||||
|
@ -4071,6 +4071,7 @@ RefPtr<StyleValue> Parser::parse_font_value(Vector<ComponentValue> const& compon
|
||||||
if (!line_height)
|
if (!line_height)
|
||||||
line_height = property_initial_value(m_context.realm(), PropertyID::LineHeight);
|
line_height = property_initial_value(m_context.realm(), PropertyID::LineHeight);
|
||||||
|
|
||||||
|
transaction.commit();
|
||||||
return ShorthandStyleValue::create(PropertyID::Font,
|
return ShorthandStyleValue::create(PropertyID::Font,
|
||||||
{ PropertyID::FontStyle, PropertyID::FontVariant, PropertyID::FontWeight, PropertyID::FontStretch, PropertyID::FontSize, PropertyID::LineHeight, PropertyID::FontFamily },
|
{ 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() });
|
{ 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() });
|
||||||
|
@ -5810,7 +5811,7 @@ Parser::ParseErrorOr<NonnullRefPtr<StyleValue>> Parser::parse_css_value(Property
|
||||||
return parsed_value.release_nonnull();
|
return parsed_value.release_nonnull();
|
||||||
return ParseError::SyntaxError;
|
return ParseError::SyntaxError;
|
||||||
case PropertyID::Font:
|
case PropertyID::Font:
|
||||||
if (auto parsed_value = parse_font_value(component_values))
|
if (auto parsed_value = parse_font_value(tokens); parsed_value && !tokens.has_next_token())
|
||||||
return parsed_value.release_nonnull();
|
return parsed_value.release_nonnull();
|
||||||
return ParseError::SyntaxError;
|
return ParseError::SyntaxError;
|
||||||
case PropertyID::FontFamily: {
|
case PropertyID::FontFamily: {
|
||||||
|
|
|
@ -238,7 +238,7 @@ private:
|
||||||
RefPtr<StyleValue> parse_display_value(TokenStream<ComponentValue>&);
|
RefPtr<StyleValue> parse_display_value(TokenStream<ComponentValue>&);
|
||||||
RefPtr<StyleValue> parse_flex_value(TokenStream<ComponentValue>&);
|
RefPtr<StyleValue> parse_flex_value(TokenStream<ComponentValue>&);
|
||||||
RefPtr<StyleValue> parse_flex_flow_value(TokenStream<ComponentValue>&);
|
RefPtr<StyleValue> parse_flex_flow_value(TokenStream<ComponentValue>&);
|
||||||
RefPtr<StyleValue> parse_font_value(Vector<ComponentValue> const&);
|
RefPtr<StyleValue> parse_font_value(TokenStream<ComponentValue>&);
|
||||||
RefPtr<StyleValue> parse_font_family_value(TokenStream<ComponentValue>&);
|
RefPtr<StyleValue> parse_font_family_value(TokenStream<ComponentValue>&);
|
||||||
RefPtr<StyleValue> parse_list_style_value(Vector<ComponentValue> const&);
|
RefPtr<StyleValue> parse_list_style_value(Vector<ComponentValue> const&);
|
||||||
RefPtr<StyleValue> parse_math_depth_value(Vector<ComponentValue> const&);
|
RefPtr<StyleValue> parse_math_depth_value(Vector<ComponentValue> const&);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue