mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-20 16:28:54 +00:00
LibWeb: Parse URL values using TokenStream
This commit is contained in:
parent
cfa221944c
commit
e00f41a274
Notes:
sideshowbarker
2024-07-17 03:25:24 +09:00
Author: https://github.com/AtkinsSJ
Commit: e00f41a274
Pull-request: https://github.com/SerenityOS/serenity/pull/24062
Reviewed-by: https://github.com/Hendiadyoin1
2 changed files with 6 additions and 8 deletions
|
@ -1195,11 +1195,12 @@ Optional<URL::URL> Parser::parse_url_function(ComponentValue const& component_va
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<StyleValue> Parser::parse_url_value(ComponentValue const& component_value)
|
RefPtr<StyleValue> Parser::parse_url_value(TokenStream<ComponentValue>& tokens)
|
||||||
{
|
{
|
||||||
auto url = parse_url_function(component_value);
|
auto url = parse_url_function(tokens.peek_token());
|
||||||
if (!url.has_value())
|
if (!url.has_value())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
(void)tokens.next_token();
|
||||||
return URLStyleValue::create(*url);
|
return URLStyleValue::create(*url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2585,8 +2586,7 @@ RefPtr<StyleValue> Parser::parse_paint_value(TokenStream<ComponentValue>& tokens
|
||||||
if (auto color_or_none = parse_color_or_none(); color_or_none.has_value())
|
if (auto color_or_none = parse_color_or_none(); color_or_none.has_value())
|
||||||
return *color_or_none;
|
return *color_or_none;
|
||||||
|
|
||||||
if (auto url = parse_url_value(tokens.peek_token())) {
|
if (auto url = parse_url_value(tokens)) {
|
||||||
(void)tokens.next_token();
|
|
||||||
tokens.skip_whitespace();
|
tokens.skip_whitespace();
|
||||||
if (auto color_or_none = parse_color_or_none(); color_or_none == nullptr) {
|
if (auto color_or_none = parse_color_or_none(); color_or_none == nullptr) {
|
||||||
// Fail to parse if the fallback is invalid, but otherwise ignore it.
|
// Fail to parse if the fallback is invalid, but otherwise ignore it.
|
||||||
|
@ -6561,11 +6561,9 @@ Optional<Parser::PropertyAndValue> Parser::parse_css_value_for_properties(Readon
|
||||||
}
|
}
|
||||||
|
|
||||||
if (auto property = any_property_accepts_type(property_ids, ValueType::Url); property.has_value()) {
|
if (auto property = any_property_accepts_type(property_ids, ValueType::Url); property.has_value()) {
|
||||||
if (auto url = parse_url_value(peek_token)) {
|
if (auto url = parse_url_value(tokens))
|
||||||
(void)tokens.next_token();
|
|
||||||
return PropertyAndValue { *property, url };
|
return PropertyAndValue { *property, url };
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
bool property_accepts_dimension = any_property_accepts_type(property_ids, ValueType::Angle).has_value()
|
bool property_accepts_dimension = any_property_accepts_type(property_ids, ValueType::Angle).has_value()
|
||||||
|| any_property_accepts_type(property_ids, ValueType::Flex).has_value()
|
|| any_property_accepts_type(property_ids, ValueType::Flex).has_value()
|
||||||
|
|
|
@ -196,7 +196,7 @@ private:
|
||||||
Optional<ExplicitGridTrack> parse_track_sizing_function(ComponentValue const&);
|
Optional<ExplicitGridTrack> parse_track_sizing_function(ComponentValue const&);
|
||||||
|
|
||||||
Optional<URL::URL> parse_url_function(ComponentValue const&);
|
Optional<URL::URL> parse_url_function(ComponentValue const&);
|
||||||
RefPtr<StyleValue> parse_url_value(ComponentValue const&);
|
RefPtr<StyleValue> parse_url_value(TokenStream<ComponentValue>&);
|
||||||
|
|
||||||
template<typename TElement>
|
template<typename TElement>
|
||||||
Optional<Vector<TElement>> parse_color_stop_list(TokenStream<ComponentValue>& tokens, auto is_position, auto get_position);
|
Optional<Vector<TElement>> parse_color_stop_list(TokenStream<ComponentValue>& tokens, auto is_position, auto get_position);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue