LibWeb/CSS: Qualify uses of LibURL

To prepare for introducing a CSS::URL type, we need to qualify any use
of LibURL as `::URL::foo` instead of `URL::foo` so the compiler doesn't
get confused.

Many of these uses will be replaced, but I don't want to mix this in
with what will likely already be a large change.
This commit is contained in:
Sam Atkins 2025-04-08 13:35:26 +01:00 committed by Tim Ledbetter
commit c82f4b46a2
Notes: github-actions[bot] 2025-04-09 17:48:07 +00:00
24 changed files with 77 additions and 76 deletions

View file

@ -42,7 +42,7 @@ GC::Ref<JS::Realm> internal_css_realm()
return *realm;
}
CSS::CSSStyleSheet* parse_css_stylesheet(CSS::Parser::ParsingParams const& context, StringView css, Optional<URL::URL> location, Vector<NonnullRefPtr<CSS::MediaQuery>> media_query_list)
CSS::CSSStyleSheet* parse_css_stylesheet(CSS::Parser::ParsingParams const& context, StringView css, Optional<::URL::URL> location, Vector<NonnullRefPtr<CSS::MediaQuery>> media_query_list)
{
if (css.is_empty()) {
auto rule_list = CSS::CSSRuleList::create_empty(*context.realm);

View file

@ -45,14 +45,14 @@ ParsingParams::ParsingParams(JS::Realm& realm, ParsingMode mode)
{
}
ParsingParams::ParsingParams(JS::Realm& realm, URL::URL url, ParsingMode mode)
ParsingParams::ParsingParams(JS::Realm& realm, ::URL::URL url, ParsingMode mode)
: realm(realm)
, url(move(url))
, mode(mode)
{
}
ParsingParams::ParsingParams(DOM::Document const& document, URL::URL url, ParsingMode mode)
ParsingParams::ParsingParams(DOM::Document const& document, ::URL::URL url, ParsingMode mode)
: realm(const_cast<JS::Realm&>(document.realm()))
, document(&document)
, url(move(url))
@ -86,7 +86,7 @@ Parser::Parser(ParsingParams const& context, Vector<Token> tokens)
// https://drafts.csswg.org/css-syntax/#parse-stylesheet
template<typename T>
Parser::ParsedStyleSheet Parser::parse_a_stylesheet(TokenStream<T>& input, Optional<URL::URL> location)
Parser::ParsedStyleSheet Parser::parse_a_stylesheet(TokenStream<T>& input, Optional<::URL::URL> location)
{
// To parse a stylesheet from an input given an optional url location:
@ -119,7 +119,7 @@ Vector<Rule> Parser::parse_a_stylesheets_contents(TokenStream<T>& input)
}
// https://drafts.csswg.org/css-syntax/#parse-a-css-stylesheet
CSSStyleSheet* Parser::parse_as_css_stylesheet(Optional<URL::URL> location, Vector<NonnullRefPtr<MediaQuery>> media_query_list)
CSSStyleSheet* Parser::parse_as_css_stylesheet(Optional<::URL::URL> location, Vector<NonnullRefPtr<MediaQuery>> media_query_list)
{
// To parse a CSS stylesheet, first parse a stylesheet.
auto const& style_sheet = parse_a_stylesheet(m_token_stream, {});
@ -1772,8 +1772,8 @@ Parser::ContextType Parser::context_type_for_at_rule(FlyString const& name)
return ContextType::Unknown;
}
template Parser::ParsedStyleSheet Parser::parse_a_stylesheet(TokenStream<Token>&, Optional<URL::URL>);
template Parser::ParsedStyleSheet Parser::parse_a_stylesheet(TokenStream<ComponentValue>&, Optional<URL::URL>);
template Parser::ParsedStyleSheet Parser::parse_a_stylesheet(TokenStream<Token>&, Optional<::URL::URL>);
template Parser::ParsedStyleSheet Parser::parse_a_stylesheet(TokenStream<ComponentValue>&, Optional<::URL::URL>);
template Vector<Rule> Parser::parse_a_stylesheets_contents(TokenStream<Token>& input);
template Vector<Rule> Parser::parse_a_stylesheets_contents(TokenStream<ComponentValue>& input);
@ -1853,10 +1853,10 @@ bool Parser::is_parsing_svg_presentation_attribute() const
// https://www.w3.org/TR/css-values-4/#relative-urls
// FIXME: URLs shouldn't be completed during parsing, but when used.
Optional<URL::URL> Parser::complete_url(StringView relative_url) const
Optional<::URL::URL> Parser::complete_url(StringView relative_url) const
{
if (!m_url.is_valid())
return URL::Parser::basic_parse(relative_url);
return ::URL::Parser::basic_parse(relative_url);
return m_url.complete_url(relative_url);
}

View file

@ -69,13 +69,13 @@ enum class ParsingMode {
struct ParsingParams {
explicit ParsingParams(ParsingMode = ParsingMode::Normal);
explicit ParsingParams(JS::Realm&, ParsingMode = ParsingMode::Normal);
explicit ParsingParams(JS::Realm&, URL::URL, ParsingMode = ParsingMode::Normal);
explicit ParsingParams(DOM::Document const&, URL::URL, ParsingMode = ParsingMode::Normal);
explicit ParsingParams(JS::Realm&, ::URL::URL, ParsingMode = ParsingMode::Normal);
explicit ParsingParams(DOM::Document const&, ::URL::URL, ParsingMode = ParsingMode::Normal);
explicit ParsingParams(DOM::Document const&, ParsingMode = ParsingMode::Normal);
GC::Ptr<JS::Realm> realm;
GC::Ptr<DOM::Document const> document;
URL::URL url;
::URL::URL url;
ParsingMode mode { ParsingMode::Normal };
};
@ -89,7 +89,7 @@ class Parser {
public:
static Parser create(ParsingParams const&, StringView input, StringView encoding = "utf-8"sv);
CSSStyleSheet* parse_as_css_stylesheet(Optional<URL::URL> location, Vector<NonnullRefPtr<MediaQuery>> media_query_list = {});
CSSStyleSheet* parse_as_css_stylesheet(Optional<::URL::URL> location, Vector<NonnullRefPtr<MediaQuery>> media_query_list = {});
struct PropertiesAndCustomProperties {
Vector<StyleProperty> properties;
@ -142,11 +142,11 @@ private:
// "Parse a stylesheet" is intended to be the normal parser entry point, for parsing stylesheets.
struct ParsedStyleSheet {
Optional<URL::URL> location;
Optional<::URL::URL> location;
Vector<Rule> rules;
};
template<typename T>
ParsedStyleSheet parse_a_stylesheet(TokenStream<T>&, Optional<URL::URL> location);
ParsedStyleSheet parse_a_stylesheet(TokenStream<T>&, Optional<::URL::URL> location);
// "Parse a stylesheets contents" is intended for use by the CSSStyleSheet replace() method, and similar, which parse text into the contents of an existing stylesheet.
template<typename T>
@ -276,7 +276,7 @@ private:
Optional<GridRepeat> parse_repeat(Vector<ComponentValue> const&);
Optional<ExplicitGridTrack> parse_track_sizing_function(ComponentValue const&);
Optional<URL::URL> parse_url_function(TokenStream<ComponentValue>&);
Optional<::URL::URL> parse_url_function(TokenStream<ComponentValue>&);
RefPtr<CSSStyleValue> parse_url_value(TokenStream<ComponentValue>&);
Optional<ShapeRadius> parse_shape_radius(TokenStream<ComponentValue>&);
@ -471,11 +471,11 @@ private:
JS::Realm& realm() const;
bool in_quirks_mode() const;
bool is_parsing_svg_presentation_attribute() const;
Optional<URL::URL> complete_url(StringView) const;
Optional<::URL::URL> complete_url(StringView) const;
GC::Ptr<DOM::Document const> m_document;
GC::Ptr<JS::Realm> m_realm;
URL::URL m_url;
::URL::URL m_url;
ParsingMode m_parsing_mode { ParsingMode::Normal };
Vector<Token> m_tokens;
@ -519,7 +519,7 @@ private:
namespace Web {
CSS::CSSStyleSheet* parse_css_stylesheet(CSS::Parser::ParsingParams const&, StringView, Optional<URL::URL> location = {}, Vector<NonnullRefPtr<CSS::MediaQuery>> = {});
CSS::CSSStyleSheet* parse_css_stylesheet(CSS::Parser::ParsingParams const&, StringView, Optional<::URL::URL> location = {}, Vector<NonnullRefPtr<CSS::MediaQuery>> = {});
CSS::Parser::Parser::PropertiesAndCustomProperties parse_css_style_attribute(CSS::Parser::ParsingParams const&, StringView);
Vector<CSS::Descriptor> parse_css_list_of_descriptors(CSS::Parser::ParsingParams const&, CSS::AtRuleID, StringView);
RefPtr<CSS::CSSStyleValue> parse_css_value(CSS::Parser::ParsingParams const&, StringView, CSS::PropertyID property_id = CSS::PropertyID::Invalid);

View file

@ -153,7 +153,7 @@ GC::Ptr<CSSImportRule> Parser::convert_to_import_rule(AtRule const& rule)
TokenStream tokens { rule.prelude };
tokens.discard_whitespace();
Optional<URL::URL> url = parse_url_function(tokens);
Optional<::URL::URL> url = parse_url_function(tokens);
if (!url.has_value() && tokens.next_token().is(Token::Type::String))
url = complete_url(tokens.consume_a_token().token().string());

View file

@ -2014,7 +2014,7 @@ RefPtr<AbstractImageStyleValue> Parser::parse_image_value(TokenStream<ComponentV
if (url.has_value()) {
// If the value is a 'url(..)' parse as image, but if it is just a reference 'url(#xx)', leave it alone,
// so we can parse as URL further on. These URLs are used as references inside SVG documents for masks.
if (!url.value().equals(m_url, URL::ExcludeFragment::Yes)) {
if (!url.value().equals(m_url, ::URL::ExcludeFragment::Yes)) {
tokens.discard_a_mark();
return ImageStyleValue::create(url.value());
}
@ -2562,12 +2562,12 @@ RefPtr<CSSStyleValue> Parser::parse_easing_value(TokenStream<ComponentValue>& to
return nullptr;
}
Optional<URL::URL> Parser::parse_url_function(TokenStream<ComponentValue>& tokens)
Optional<::URL::URL> Parser::parse_url_function(TokenStream<ComponentValue>& tokens)
{
auto transaction = tokens.begin_transaction();
auto& component_value = tokens.consume_a_token();
auto convert_string_to_url = [&](StringView url_string) -> Optional<URL::URL> {
auto convert_string_to_url = [&](StringView url_string) -> Optional<::URL::URL> {
auto url = complete_url(url_string);
if (url.has_value()) {
transaction.commit();