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

LibWeb: Add the Web::URL namespace and move URLEncoder to it

This namespace will be used for all interfaces defined in the URL
specification, like URL and URLSearchParams.

This has the unfortunate side-effect of requiring us to use the fully
qualified AK::URL name whenever we want to refer to the AK class, so
this commit also fixes all such references.
This commit is contained in:
Idan Horowitz 2021-09-13 00:33:23 +03:00 committed by Andreas Kling
parent 2b78e227f2
commit 4629f2e4ad
54 changed files with 236 additions and 225 deletions

View file

@ -10,7 +10,7 @@
namespace Web::CSS {
CSSImportRule::CSSImportRule(URL url)
CSSImportRule::CSSImportRule(AK::URL url)
: m_url(move(url))
{
}

View file

@ -16,14 +16,14 @@ class CSSImportRule : public CSSRule {
AK_MAKE_NONMOVABLE(CSSImportRule);
public:
static NonnullRefPtr<CSSImportRule> create(URL url)
static NonnullRefPtr<CSSImportRule> create(AK::URL url)
{
return adopt_ref(*new CSSImportRule(move(url)));
}
~CSSImportRule();
const URL& url() const { return m_url; }
const AK::URL& url() const { return m_url; }
bool has_import_result() const { return !m_style_sheet.is_null(); }
RefPtr<CSSStyleSheet> loaded_style_sheet() { return m_style_sheet; }
@ -34,9 +34,9 @@ public:
virtual Type type() const { return Type::Import; };
private:
explicit CSSImportRule(URL);
explicit CSSImportRule(AK::URL);
URL m_url;
AK::URL m_url;
RefPtr<CSSStyleSheet> m_style_sheet;
};

View file

@ -50,9 +50,9 @@ bool ParsingContext::in_quirks_mode() const
return m_document ? m_document->in_quirks_mode() : false;
}
URL ParsingContext::complete_url(String const& addr) const
AK::URL ParsingContext::complete_url(String const& addr) const
{
return m_document ? m_document->url().complete_url(addr) : URL::create_with_url_or_path(addr);
return m_document ? m_document->url().complete_url(addr) : AK::URL::create_with_url_or_path(addr);
}
template<typename T>
@ -1159,7 +1159,7 @@ Vector<Vector<StyleComponentValueRule>> Parser::parse_a_comma_separated_list_of_
return lists;
}
Optional<URL> Parser::parse_url_function(ParsingContext const& context, StyleComponentValueRule const& component_value)
Optional<AK::URL> Parser::parse_url_function(ParsingContext const& context, StyleComponentValueRule const& component_value)
{
// FIXME: Handle list of media queries. https://www.w3.org/TR/css-cascade-3/#conditional-import
// FIXME: Handle data: urls (RFC2397)
@ -1201,7 +1201,7 @@ RefPtr<CSSRule> Parser::convert_to_rule(NonnullRefPtr<StyleRule> rule)
return {};
} else if (rule->m_name.equals_ignoring_case("import"sv) && !rule->prelude().is_empty()) {
Optional<URL> url;
Optional<AK::URL> url;
for (auto& token : rule->prelude()) {
if (token.is(Token::Type::Whitespace))
continue;

View file

@ -38,7 +38,7 @@ public:
bool in_quirks_mode() const;
DOM::Document* document() const { return m_document; }
URL complete_url(String const&) const;
AK::URL complete_url(String const&) const;
PropertyID current_property_id() const { return m_current_property_id; }
void set_current_property_id(PropertyID property_id) { m_current_property_id = property_id; }
@ -172,7 +172,7 @@ private:
static Optional<float> try_parse_float(StringView string);
static Optional<Color> parse_color(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<AK::URL> parse_url_function(ParsingContext const&, StyleComponentValueRule const&);
Result<NonnullRefPtr<StyleValue>, ParsingResult> parse_css_value(PropertyID, TokenStream<StyleComponentValueRule>&);
static RefPtr<StyleValue> parse_css_value(ParsingContext const&, StyleComponentValueRule const&);

View file

@ -152,7 +152,7 @@ Color IdentifierStyleValue::to_color(const DOM::Document& document) const
}
}
ImageStyleValue::ImageStyleValue(const URL& url, DOM::Document& document)
ImageStyleValue::ImageStyleValue(const AK::URL& url, DOM::Document& document)
: StyleValue(Type::Image)
, m_url(url)
, m_document(document)

View file

@ -651,7 +651,7 @@ class ImageStyleValue final
: public StyleValue
, public ImageResourceClient {
public:
static NonnullRefPtr<ImageStyleValue> create(const URL& url, DOM::Document& document) { return adopt_ref(*new ImageStyleValue(url, document)); }
static NonnullRefPtr<ImageStyleValue> create(const AK::URL& url, DOM::Document& document) { return adopt_ref(*new ImageStyleValue(url, document)); }
virtual ~ImageStyleValue() override { }
String to_string() const override { return String::formatted("Image({})", m_url.to_string()); }
@ -659,12 +659,12 @@ public:
const Gfx::Bitmap* bitmap() const { return m_bitmap; }
private:
ImageStyleValue(const URL&, DOM::Document&);
ImageStyleValue(const AK::URL&, DOM::Document&);
// ^ResourceClient
virtual void resource_did_load() override;
URL m_url;
AK::URL m_url;
WeakPtr<DOM::Document> m_document;
RefPtr<Gfx::Bitmap> m_bitmap;
};