mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 19:47:42 +00:00
LibWeb: Remove unused PropertyID parameter to StyleValue parsing methods
It's no longer used, and awkward to pass around.
This commit is contained in:
parent
8e4a4fd4db
commit
c66689ea76
2 changed files with 27 additions and 29 deletions
|
@ -1804,7 +1804,7 @@ RefPtr<StyleValue> Parser::parse_background_value(ParsingContext const& context,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto value = parse_css_value(context, PropertyID::Background, part);
|
auto value = parse_css_value(context, part);
|
||||||
if (!value) {
|
if (!value) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -1834,7 +1834,7 @@ RefPtr<StyleValue> Parser::parse_background_value(ParsingContext const& context,
|
||||||
|
|
||||||
// Check following value, if it's also a repeat, set both.
|
// Check following value, if it's also a repeat, set both.
|
||||||
if (i + 1 < component_values.size()) {
|
if (i + 1 < component_values.size()) {
|
||||||
auto next_value = parse_css_value(context, PropertyID::Background, component_values[i + 1]);
|
auto next_value = parse_css_value(context, component_values[i + 1]);
|
||||||
if (next_value && is_background_repeat(*next_value)) {
|
if (next_value && is_background_repeat(*next_value)) {
|
||||||
++i;
|
++i;
|
||||||
repeat_x = value.release_nonnull();
|
repeat_x = value.release_nonnull();
|
||||||
|
@ -1866,7 +1866,7 @@ RefPtr<StyleValue> Parser::parse_background_value(ParsingContext const& context,
|
||||||
RefPtr<StyleValue> Parser::parse_background_image_value(ParsingContext const& context, Vector<StyleComponentValueRule> const& component_values)
|
RefPtr<StyleValue> Parser::parse_background_image_value(ParsingContext const& context, Vector<StyleComponentValueRule> const& component_values)
|
||||||
{
|
{
|
||||||
if (component_values.size() == 1) {
|
if (component_values.size() == 1) {
|
||||||
auto maybe_value = parse_css_value(context, PropertyID::BackgroundImage, component_values.first());
|
auto maybe_value = parse_css_value(context, component_values.first());
|
||||||
if (!maybe_value)
|
if (!maybe_value)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
auto value = maybe_value.release_nonnull();
|
auto value = maybe_value.release_nonnull();
|
||||||
|
@ -1888,7 +1888,7 @@ RefPtr<StyleValue> Parser::parse_background_repeat_value(ParsingContext const& c
|
||||||
};
|
};
|
||||||
|
|
||||||
if (component_values.size() == 1) {
|
if (component_values.size() == 1) {
|
||||||
auto maybe_value = parse_css_value(context, PropertyID::BackgroundRepeat, component_values.first());
|
auto maybe_value = parse_css_value(context, component_values.first());
|
||||||
if (!maybe_value)
|
if (!maybe_value)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
auto value = maybe_value.release_nonnull();
|
auto value = maybe_value.release_nonnull();
|
||||||
|
@ -1905,8 +1905,8 @@ RefPtr<StyleValue> Parser::parse_background_repeat_value(ParsingContext const& c
|
||||||
}
|
}
|
||||||
|
|
||||||
if (component_values.size() == 2) {
|
if (component_values.size() == 2) {
|
||||||
auto maybe_x_value = parse_css_value(context, PropertyID::BackgroundRepeatX, component_values[0]);
|
auto maybe_x_value = parse_css_value(context, component_values[0]);
|
||||||
auto maybe_y_value = parse_css_value(context, PropertyID::BackgroundRepeatY, component_values[1]);
|
auto maybe_y_value = parse_css_value(context, component_values[1]);
|
||||||
if (!maybe_x_value || !maybe_y_value)
|
if (!maybe_x_value || !maybe_y_value)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
|
@ -1924,7 +1924,7 @@ RefPtr<StyleValue> Parser::parse_background_repeat_value(ParsingContext const& c
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<StyleValue> Parser::parse_border_value(ParsingContext const& context, PropertyID property_id, Vector<StyleComponentValueRule> const& component_values)
|
RefPtr<StyleValue> Parser::parse_border_value(ParsingContext const& context, Vector<StyleComponentValueRule> const& component_values)
|
||||||
{
|
{
|
||||||
auto is_line_style = [](StyleValue const& value) -> bool {
|
auto is_line_style = [](StyleValue const& value) -> bool {
|
||||||
switch (value.to_identifier()) {
|
switch (value.to_identifier()) {
|
||||||
|
@ -1965,7 +1965,7 @@ RefPtr<StyleValue> Parser::parse_border_value(ParsingContext const& context, Pro
|
||||||
RefPtr<StyleValue> border_style;
|
RefPtr<StyleValue> border_style;
|
||||||
|
|
||||||
for (auto& part : component_values) {
|
for (auto& part : component_values) {
|
||||||
auto value = parse_css_value(context, property_id, part);
|
auto value = parse_css_value(context, part);
|
||||||
if (!value)
|
if (!value)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
|
@ -2167,7 +2167,7 @@ RefPtr<StyleValue> Parser::parse_flex_value(ParsingContext const& context, Vecto
|
||||||
};
|
};
|
||||||
|
|
||||||
if (component_values.size() == 1) {
|
if (component_values.size() == 1) {
|
||||||
auto value = parse_css_value(context, PropertyID::Flex, component_values[0]);
|
auto value = parse_css_value(context, component_values[0]);
|
||||||
if (!value)
|
if (!value)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
|
@ -2190,7 +2190,7 @@ RefPtr<StyleValue> Parser::parse_flex_value(ParsingContext const& context, Vecto
|
||||||
RefPtr<StyleValue> flex_basis;
|
RefPtr<StyleValue> flex_basis;
|
||||||
|
|
||||||
for (size_t i = 0; i < component_values.size(); ++i) {
|
for (size_t i = 0; i < component_values.size(); ++i) {
|
||||||
auto value = parse_css_value(context, PropertyID::Flex, component_values[i]);
|
auto value = parse_css_value(context, component_values[i]);
|
||||||
if (!value)
|
if (!value)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
|
@ -2209,7 +2209,7 @@ RefPtr<StyleValue> Parser::parse_flex_value(ParsingContext const& context, Vecto
|
||||||
|
|
||||||
// Flex-shrink may optionally follow directly after.
|
// Flex-shrink may optionally follow directly after.
|
||||||
if (i + 1 < component_values.size()) {
|
if (i + 1 < component_values.size()) {
|
||||||
auto second_value = parse_css_value(context, PropertyID::Flex, component_values[i + 1]);
|
auto second_value = parse_css_value(context, component_values[i + 1]);
|
||||||
if (second_value && is_flex_grow_or_shrink(*second_value)) {
|
if (second_value && is_flex_grow_or_shrink(*second_value)) {
|
||||||
flex_shrink = second_value.release_nonnull();
|
flex_shrink = second_value.release_nonnull();
|
||||||
i++;
|
i++;
|
||||||
|
@ -2270,7 +2270,7 @@ RefPtr<StyleValue> Parser::parse_flex_flow_value(ParsingContext const& context,
|
||||||
RefPtr<StyleValue> flex_wrap;
|
RefPtr<StyleValue> flex_wrap;
|
||||||
|
|
||||||
for (auto& part : component_values) {
|
for (auto& part : component_values) {
|
||||||
auto value = parse_css_value(context, PropertyID::FlexFlow, part);
|
auto value = parse_css_value(context, part);
|
||||||
if (!value)
|
if (!value)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
if (is_flex_direction(*value)) {
|
if (is_flex_direction(*value)) {
|
||||||
|
@ -2369,7 +2369,7 @@ RefPtr<StyleValue> Parser::parse_font_value(ParsingContext const& context, Vecto
|
||||||
int normal_count = 0;
|
int normal_count = 0;
|
||||||
|
|
||||||
for (size_t i = 0; i < component_values.size(); ++i) {
|
for (size_t i = 0; i < component_values.size(); ++i) {
|
||||||
auto value = parse_css_value(context, PropertyID::Font, component_values[i]);
|
auto value = parse_css_value(context, component_values[i]);
|
||||||
if (!value)
|
if (!value)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
|
@ -2398,7 +2398,7 @@ RefPtr<StyleValue> Parser::parse_font_value(ParsingContext const& context, Vecto
|
||||||
if (i + 2 < component_values.size()) {
|
if (i + 2 < component_values.size()) {
|
||||||
auto maybe_solidus = component_values[i + 1];
|
auto maybe_solidus = component_values[i + 1];
|
||||||
if (maybe_solidus.is(Token::Type::Delim) && maybe_solidus.token().delim() == "/"sv) {
|
if (maybe_solidus.is(Token::Type::Delim) && maybe_solidus.token().delim() == "/"sv) {
|
||||||
auto maybe_line_height = parse_css_value(context, PropertyID::Font, component_values[i + 2]);
|
auto maybe_line_height = parse_css_value(context, component_values[i + 2]);
|
||||||
if (!(maybe_line_height && is_line_height(*maybe_line_height)))
|
if (!(maybe_line_height && is_line_height(*maybe_line_height)))
|
||||||
return nullptr;
|
return nullptr;
|
||||||
line_height = maybe_line_height.release_nonnull();
|
line_height = maybe_line_height.release_nonnull();
|
||||||
|
@ -2485,7 +2485,7 @@ RefPtr<StyleValue> Parser::parse_font_family_value(ParsingContext const& context
|
||||||
}
|
}
|
||||||
if (part.is(Token::Type::Ident)) {
|
if (part.is(Token::Type::Ident)) {
|
||||||
// If this is a valid identifier, it's NOT a custom-ident and can't be part of a larger name.
|
// If this is a valid identifier, it's NOT a custom-ident and can't be part of a larger name.
|
||||||
auto maybe_ident = parse_css_value(context, PropertyID::FontFamily, part);
|
auto maybe_ident = parse_css_value(context, part);
|
||||||
if (maybe_ident) {
|
if (maybe_ident) {
|
||||||
// CSS-wide keywords are not allowed
|
// CSS-wide keywords are not allowed
|
||||||
if (maybe_ident->is_builtin())
|
if (maybe_ident->is_builtin())
|
||||||
|
@ -2577,7 +2577,7 @@ RefPtr<StyleValue> Parser::parse_list_style_value(ParsingContext const& context,
|
||||||
int found_nones = 0;
|
int found_nones = 0;
|
||||||
|
|
||||||
for (auto& part : component_values) {
|
for (auto& part : component_values) {
|
||||||
auto value = parse_css_value(context, PropertyID::ListStyle, part);
|
auto value = parse_css_value(context, part);
|
||||||
if (!value)
|
if (!value)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
|
@ -2652,7 +2652,7 @@ RefPtr<StyleValue> Parser::parse_overflow_value(ParsingContext const& context, V
|
||||||
};
|
};
|
||||||
|
|
||||||
if (component_values.size() == 1) {
|
if (component_values.size() == 1) {
|
||||||
auto maybe_value = parse_css_value(context, PropertyID::Overflow, component_values.first());
|
auto maybe_value = parse_css_value(context, component_values.first());
|
||||||
if (!maybe_value)
|
if (!maybe_value)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
auto value = maybe_value.release_nonnull();
|
auto value = maybe_value.release_nonnull();
|
||||||
|
@ -2662,8 +2662,8 @@ RefPtr<StyleValue> Parser::parse_overflow_value(ParsingContext const& context, V
|
||||||
}
|
}
|
||||||
|
|
||||||
if (component_values.size() == 2) {
|
if (component_values.size() == 2) {
|
||||||
auto maybe_x_value = parse_css_value(context, PropertyID::OverflowX, component_values[0]);
|
auto maybe_x_value = parse_css_value(context, component_values[0]);
|
||||||
auto maybe_y_value = parse_css_value(context, PropertyID::OverflowY, component_values[1]);
|
auto maybe_y_value = parse_css_value(context, component_values[1]);
|
||||||
|
|
||||||
if (!maybe_x_value || !maybe_y_value)
|
if (!maybe_x_value || !maybe_y_value)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -2714,7 +2714,7 @@ RefPtr<StyleValue> Parser::parse_text_decoration_value(ParsingContext const& con
|
||||||
// FIXME: Implement 'text-decoration-thickness' parameter. https://www.w3.org/TR/css-text-decor-4/#text-decoration-width-property
|
// FIXME: Implement 'text-decoration-thickness' parameter. https://www.w3.org/TR/css-text-decor-4/#text-decoration-width-property
|
||||||
|
|
||||||
for (auto& part : component_values) {
|
for (auto& part : component_values) {
|
||||||
auto value = parse_css_value(context, PropertyID::TextDecoration, part);
|
auto value = parse_css_value(context, part);
|
||||||
if (!value)
|
if (!value)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
|
@ -2804,7 +2804,7 @@ RefPtr<StyleValue> Parser::parse_css_value(PropertyID property_id, TokenStream<S
|
||||||
case PropertyID::BorderLeft:
|
case PropertyID::BorderLeft:
|
||||||
case PropertyID::BorderRight:
|
case PropertyID::BorderRight:
|
||||||
case PropertyID::BorderTop:
|
case PropertyID::BorderTop:
|
||||||
if (auto parsed_value = parse_border_value(m_context, property_id, component_values))
|
if (auto parsed_value = parse_border_value(m_context, component_values))
|
||||||
return parsed_value;
|
return parsed_value;
|
||||||
break;
|
break;
|
||||||
case PropertyID::BorderTopLeftRadius:
|
case PropertyID::BorderTopLeftRadius:
|
||||||
|
@ -2855,13 +2855,13 @@ RefPtr<StyleValue> Parser::parse_css_value(PropertyID property_id, TokenStream<S
|
||||||
}
|
}
|
||||||
|
|
||||||
if (component_values.size() == 1)
|
if (component_values.size() == 1)
|
||||||
return parse_css_value(m_context, property_id, component_values.first());
|
return parse_css_value(m_context, component_values.first());
|
||||||
|
|
||||||
// We have multiple values, so treat them as a StyleValueList.
|
// We have multiple values, so treat them as a StyleValueList.
|
||||||
// FIXME: Specify in Properties.json whether to permit this for each property.
|
// FIXME: Specify in Properties.json whether to permit this for each property.
|
||||||
NonnullRefPtrVector<StyleValue> parsed_values;
|
NonnullRefPtrVector<StyleValue> parsed_values;
|
||||||
for (auto& component_value : component_values) {
|
for (auto& component_value : component_values) {
|
||||||
auto parsed = parse_css_value(m_context, property_id, component_value);
|
auto parsed = parse_css_value(m_context, component_value);
|
||||||
if (!parsed)
|
if (!parsed)
|
||||||
return {};
|
return {};
|
||||||
parsed_values.append(parsed.release_nonnull());
|
parsed_values.append(parsed.release_nonnull());
|
||||||
|
@ -2872,7 +2872,7 @@ RefPtr<StyleValue> Parser::parse_css_value(PropertyID property_id, TokenStream<S
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<StyleValue> Parser::parse_css_value(ParsingContext const& context, PropertyID, StyleComponentValueRule const& component_value)
|
RefPtr<StyleValue> Parser::parse_css_value(ParsingContext const& context, StyleComponentValueRule const& component_value)
|
||||||
{
|
{
|
||||||
if (auto builtin = parse_builtin_value(context, component_value))
|
if (auto builtin = parse_builtin_value(context, component_value))
|
||||||
return builtin;
|
return builtin;
|
||||||
|
|
|
@ -99,10 +99,6 @@ public:
|
||||||
|
|
||||||
RefPtr<StyleValue> parse_as_css_value(PropertyID);
|
RefPtr<StyleValue> parse_as_css_value(PropertyID);
|
||||||
|
|
||||||
// FIXME: These want to be private, but StyleResolver still uses them for now.
|
|
||||||
RefPtr<StyleValue> parse_css_value(PropertyID, TokenStream<StyleComponentValueRule>&);
|
|
||||||
static RefPtr<StyleValue> parse_css_value(ParsingContext const&, PropertyID, StyleComponentValueRule const&);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
template<typename T>
|
template<typename T>
|
||||||
NonnullRefPtr<CSSStyleSheet> parse_a_stylesheet(TokenStream<T>&);
|
NonnullRefPtr<CSSStyleSheet> parse_a_stylesheet(TokenStream<T>&);
|
||||||
|
@ -172,6 +168,8 @@ private:
|
||||||
static Optional<Length> parse_length(ParsingContext const&, StyleComponentValueRule const&);
|
static Optional<Length> parse_length(ParsingContext const&, StyleComponentValueRule const&);
|
||||||
static Optional<URL> parse_url_function(ParsingContext const&, StyleComponentValueRule const&);
|
static Optional<URL> parse_url_function(ParsingContext const&, StyleComponentValueRule const&);
|
||||||
|
|
||||||
|
RefPtr<StyleValue> parse_css_value(PropertyID, TokenStream<StyleComponentValueRule>&);
|
||||||
|
static RefPtr<StyleValue> parse_css_value(ParsingContext const&, StyleComponentValueRule const&);
|
||||||
static RefPtr<StyleValue> parse_builtin_value(ParsingContext const&, StyleComponentValueRule const&);
|
static RefPtr<StyleValue> parse_builtin_value(ParsingContext const&, StyleComponentValueRule const&);
|
||||||
static RefPtr<StyleValue> parse_dynamic_value(ParsingContext const&, StyleComponentValueRule const&);
|
static RefPtr<StyleValue> parse_dynamic_value(ParsingContext const&, StyleComponentValueRule const&);
|
||||||
static RefPtr<StyleValue> parse_length_value(ParsingContext const&, StyleComponentValueRule const&);
|
static RefPtr<StyleValue> parse_length_value(ParsingContext const&, StyleComponentValueRule const&);
|
||||||
|
@ -183,7 +181,7 @@ private:
|
||||||
static RefPtr<StyleValue> parse_background_value(ParsingContext const&, Vector<StyleComponentValueRule> const&);
|
static RefPtr<StyleValue> parse_background_value(ParsingContext const&, Vector<StyleComponentValueRule> const&);
|
||||||
static RefPtr<StyleValue> parse_background_image_value(ParsingContext const&, Vector<StyleComponentValueRule> const&);
|
static RefPtr<StyleValue> parse_background_image_value(ParsingContext const&, Vector<StyleComponentValueRule> const&);
|
||||||
static RefPtr<StyleValue> parse_background_repeat_value(ParsingContext const&, Vector<StyleComponentValueRule> const&);
|
static RefPtr<StyleValue> parse_background_repeat_value(ParsingContext const&, Vector<StyleComponentValueRule> const&);
|
||||||
static RefPtr<StyleValue> parse_border_value(ParsingContext const&, PropertyID, Vector<StyleComponentValueRule> const&);
|
static RefPtr<StyleValue> parse_border_value(ParsingContext const&, Vector<StyleComponentValueRule> const&);
|
||||||
static RefPtr<StyleValue> parse_border_radius_value(ParsingContext const&, Vector<StyleComponentValueRule> const&);
|
static RefPtr<StyleValue> parse_border_radius_value(ParsingContext const&, Vector<StyleComponentValueRule> const&);
|
||||||
static RefPtr<StyleValue> parse_border_radius_shorthand_value(ParsingContext const&, Vector<StyleComponentValueRule> const&);
|
static RefPtr<StyleValue> parse_border_radius_shorthand_value(ParsingContext const&, Vector<StyleComponentValueRule> const&);
|
||||||
static RefPtr<StyleValue> parse_box_shadow_value(ParsingContext const&, Vector<StyleComponentValueRule> const&);
|
static RefPtr<StyleValue> parse_box_shadow_value(ParsingContext const&, Vector<StyleComponentValueRule> const&);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue