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

Everywhere: Use unqualified AK::URL

Now possible in LibWeb now that there is no longer a Web::URL.
This commit is contained in:
Shannon Booth 2024-02-11 20:15:39 +13:00 committed by Andreas Kling
parent f9e5b43b7a
commit 9ce8189f21
156 changed files with 471 additions and 471 deletions

View file

@ -64,8 +64,8 @@ String CSSFontFaceRule::serialized() const
// 2. The result of invoking serialize a comma-separated list on performing serialize a URL or serialize a LOCAL for each source on the source list.
serialize_a_comma_separated_list(builder, m_font_face.sources(), [&](StringBuilder& builder, FontFace::Source source) -> void {
if (source.local_or_url.has<AK::URL>()) {
serialize_a_url(builder, MUST(source.local_or_url.get<AK::URL>().to_string()));
if (source.local_or_url.has<URL>()) {
serialize_a_url(builder, MUST(source.local_or_url.get<URL>().to_string()));
} else {
builder.appendff("local({})", source.local_or_url.get<String>());
}

View file

@ -21,13 +21,13 @@ namespace Web::CSS {
JS_DEFINE_ALLOCATOR(CSSImportRule);
JS::NonnullGCPtr<CSSImportRule> CSSImportRule::create(AK::URL url, DOM::Document& document)
JS::NonnullGCPtr<CSSImportRule> CSSImportRule::create(URL url, DOM::Document& document)
{
auto& realm = document.realm();
return realm.heap().allocate<CSSImportRule>(realm, move(url), document);
}
CSSImportRule::CSSImportRule(AK::URL url, DOM::Document& document)
CSSImportRule::CSSImportRule(URL url, DOM::Document& document)
: CSSRule(document.realm())
, m_url(move(url))
, m_document(document)

View file

@ -23,11 +23,11 @@ class CSSImportRule final
JS_DECLARE_ALLOCATOR(CSSImportRule);
public:
[[nodiscard]] static JS::NonnullGCPtr<CSSImportRule> create(AK::URL, DOM::Document&);
[[nodiscard]] static JS::NonnullGCPtr<CSSImportRule> create(URL, DOM::Document&);
virtual ~CSSImportRule() = default;
AK::URL const& url() const { return m_url; }
URL const& url() const { return m_url; }
// FIXME: This should return only the specified part of the url. eg, "stuff/foo.css", not "https://example.com/stuff/foo.css".
String href() const { return MUST(m_url.to_string()); }
@ -39,7 +39,7 @@ public:
virtual Type type() const override { return Type::Import; }
private:
CSSImportRule(AK::URL, DOM::Document&);
CSSImportRule(URL, DOM::Document&);
virtual void initialize(JS::Realm&) override;
virtual void visit_edges(Cell::Visitor&) override;
@ -50,7 +50,7 @@ private:
virtual void resource_did_fail() override;
virtual void resource_did_load() override;
AK::URL m_url;
URL m_url;
JS::GCPtr<DOM::Document> m_document;
JS::GCPtr<CSSStyleSheet> m_style_sheet;
Optional<DOM::DocumentLoadEventDelayer> m_document_load_event_delayer;

View file

@ -20,7 +20,7 @@ namespace Web::CSS {
JS_DEFINE_ALLOCATOR(CSSStyleSheet);
JS::NonnullGCPtr<CSSStyleSheet> CSSStyleSheet::create(JS::Realm& realm, CSSRuleList& rules, MediaList& media, Optional<AK::URL> location)
JS::NonnullGCPtr<CSSStyleSheet> CSSStyleSheet::create(JS::Realm& realm, CSSRuleList& rules, MediaList& media, Optional<URL> location)
{
return realm.heap().allocate<CSSStyleSheet>(realm, realm, rules, media, move(location));
}
@ -37,12 +37,12 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<CSSStyleSheet>> CSSStyleSheet::construct_im
// 3. Set sheets stylesheet base URL to the baseURL attribute value from options.
if (options.has_value() && options->base_url.has_value()) {
Optional<AK::URL> sheet_location_url;
Optional<URL> sheet_location_url;
if (sheet->location().has_value())
sheet_location_url = sheet->location().release_value();
// AD-HOC: This isn't explicitly mentioned in the specification, but multiple modern browsers do this.
AK::URL url = sheet->location().has_value() ? sheet_location_url->complete_url(options->base_url.value()) : options->base_url.value();
URL url = sheet->location().has_value() ? sheet_location_url->complete_url(options->base_url.value()) : options->base_url.value();
if (!url.is_valid())
return WebIDL::NotAllowedError::create(realm, "Constructed style sheets must have a valid base URL"_fly_string);
@ -91,7 +91,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<CSSStyleSheet>> CSSStyleSheet::construct_im
return sheet;
}
CSSStyleSheet::CSSStyleSheet(JS::Realm& realm, CSSRuleList& rules, MediaList& media, Optional<AK::URL> location)
CSSStyleSheet::CSSStyleSheet(JS::Realm& realm, CSSRuleList& rules, MediaList& media, Optional<URL> location)
: StyleSheet(realm, media)
, m_rules(&rules)
{

View file

@ -32,7 +32,7 @@ class CSSStyleSheet final
JS_DECLARE_ALLOCATOR(CSSStyleSheet);
public:
[[nodiscard]] static JS::NonnullGCPtr<CSSStyleSheet> create(JS::Realm&, CSSRuleList&, MediaList&, Optional<AK::URL> location);
[[nodiscard]] static JS::NonnullGCPtr<CSSStyleSheet> create(JS::Realm&, CSSRuleList&, MediaList&, Optional<URL> location);
static WebIDL::ExceptionOr<JS::NonnullGCPtr<CSSStyleSheet>> construct_impl(JS::Realm&, Optional<CSSStyleSheetInit> const& options = {});
virtual ~CSSStyleSheet() override = default;
@ -67,8 +67,8 @@ public:
Optional<FlyString> default_namespace() const;
Optional<FlyString> namespace_uri(StringView namespace_prefix) const;
Optional<AK::URL> base_url() const { return m_base_url; }
void set_base_url(Optional<AK::URL> base_url) { m_base_url = move(base_url); }
Optional<URL> base_url() const { return m_base_url; }
void set_base_url(Optional<URL> base_url) { m_base_url = move(base_url); }
bool constructed() const { return m_constructed; }
@ -78,7 +78,7 @@ public:
bool disallow_modification() const { return m_disallow_modification; }
private:
CSSStyleSheet(JS::Realm&, CSSRuleList&, MediaList&, Optional<AK::URL> location);
CSSStyleSheet(JS::Realm&, CSSRuleList&, MediaList&, Optional<URL> location);
virtual void initialize(JS::Realm&) override;
virtual void visit_edges(Cell::Visitor&) override;
@ -95,7 +95,7 @@ private:
JS::GCPtr<StyleSheetList> m_style_sheet_list;
JS::GCPtr<CSSRule> m_owner_css_rule;
Optional<AK::URL> m_base_url;
Optional<URL> m_base_url;
JS::GCPtr<DOM::Document const> m_constructor_document;
bool m_constructed { false };
bool m_disallow_modification { false };

View file

@ -183,33 +183,33 @@ public:
: m_value(color)
{
}
SVGPaint(AK::URL const& url)
SVGPaint(URL const& url)
: m_value(url)
{
}
bool is_color() const { return m_value.has<Color>(); }
bool is_url() const { return m_value.has<AK::URL>(); }
bool is_url() const { return m_value.has<URL>(); }
Color as_color() const { return m_value.get<Color>(); }
AK::URL const& as_url() const { return m_value.get<AK::URL>(); }
URL const& as_url() const { return m_value.get<URL>(); }
private:
Variant<AK::URL, Color> m_value;
Variant<URL, Color> m_value;
};
// https://drafts.fxtf.org/css-masking-1/#typedef-mask-reference
class MaskReference {
public:
// TODO: Support other mask types.
MaskReference(AK::URL const& url)
MaskReference(URL const& url)
: m_url(url)
{
}
AK::URL const& url() const { return m_url; }
URL const& url() const { return m_url; }
private:
AK::URL m_url;
URL m_url;
};
struct BackgroundLayerData {

View file

@ -16,7 +16,7 @@ namespace Web::CSS {
class FontFace {
public:
struct Source {
Variant<String, AK::URL> local_or_url;
Variant<String, URL> local_or_url;
// FIXME: Do we need to keep this around, or is it only needed to discard unwanted formats during parsing?
Optional<FlyString> format;
};

View file

@ -15,7 +15,7 @@
namespace Web {
CSS::CSSStyleSheet* parse_css_stylesheet(CSS::Parser::ParsingContext const& context, StringView css, Optional<AK::URL> location)
CSS::CSSStyleSheet* parse_css_stylesheet(CSS::Parser::ParsingContext const& context, StringView css, Optional<URL> location)
{
if (css.is_empty()) {
auto rule_list = CSS::CSSRuleList::create_empty(context.realm());

View file

@ -124,7 +124,7 @@ Parser::Parser(Parser&& other)
// 5.3.3. Parse a stylesheet
// https://www.w3.org/TR/css-syntax-3/#parse-stylesheet
template<typename T>
Parser::ParsedStyleSheet Parser::parse_a_stylesheet(TokenStream<T>& tokens, Optional<AK::URL> location)
Parser::ParsedStyleSheet Parser::parse_a_stylesheet(TokenStream<T>& tokens, Optional<URL> location)
{
// To parse a stylesheet from an input given an optional url location:
@ -144,7 +144,7 @@ Parser::ParsedStyleSheet Parser::parse_a_stylesheet(TokenStream<T>& tokens, Opti
}
// https://www.w3.org/TR/css-syntax-3/#parse-a-css-stylesheet
CSSStyleSheet* Parser::parse_as_css_stylesheet(Optional<AK::URL> location)
CSSStyleSheet* Parser::parse_as_css_stylesheet(Optional<URL> location)
{
// To parse a CSS stylesheet, first parse a stylesheet.
auto style_sheet = parse_a_stylesheet(m_token_stream, {});
@ -1160,11 +1160,11 @@ ElementInlineCSSStyleDeclaration* Parser::parse_as_style_attribute(DOM::Element&
return ElementInlineCSSStyleDeclaration::create(element, move(properties), move(custom_properties));
}
Optional<AK::URL> Parser::parse_url_function(ComponentValue const& component_value)
Optional<URL> Parser::parse_url_function(ComponentValue const& component_value)
{
// FIXME: Handle list of media queries. https://www.w3.org/TR/css-cascade-3/#conditional-import
auto convert_string_to_url = [&](StringView url_string) -> Optional<AK::URL> {
auto convert_string_to_url = [&](StringView url_string) -> Optional<URL> {
auto url = m_context.complete_url(url_string);
if (url.is_valid())
return url;
@ -1215,7 +1215,7 @@ CSSRule* Parser::convert_to_rule(NonnullRefPtr<Rule> rule)
return parse_font_face_rule(tokens);
}
if (rule->at_rule_name().equals_ignoring_ascii_case("import"sv) && !rule->prelude().is_empty()) {
Optional<AK::URL> url;
Optional<URL> url;
for (auto const& token : rule->prelude()) {
if (token.is(Token::Type::Whitespace))
continue;

View file

@ -44,7 +44,7 @@ public:
Parser(Parser&&);
CSSStyleSheet* parse_as_css_stylesheet(Optional<AK::URL> location);
CSSStyleSheet* parse_as_css_stylesheet(Optional<URL> location);
ElementInlineCSSStyleDeclaration* parse_as_style_attribute(DOM::Element&);
CSSRule* parse_as_css_rule();
Optional<StyleProperty> parse_as_supports_condition();
@ -86,11 +86,11 @@ private:
// "Parse a stylesheet" is intended to be the normal parser entry point, for parsing stylesheets.
struct ParsedStyleSheet {
Optional<AK::URL> location;
Optional<URL> location;
Vector<NonnullRefPtr<Rule>> rules;
};
template<typename T>
ParsedStyleSheet parse_a_stylesheet(TokenStream<T>&, Optional<AK::URL> location);
ParsedStyleSheet parse_a_stylesheet(TokenStream<T>&, Optional<URL> location);
// "Parse a list of rules" is intended for the content of at-rules such as @media. It differs from "Parse a stylesheet" in the handling of <CDO-token> and <CDC-token>.
template<typename T>
@ -195,7 +195,7 @@ private:
Optional<GridRepeat> parse_repeat(Vector<ComponentValue> const&);
Optional<ExplicitGridTrack> parse_track_sizing_function(ComponentValue const&);
Optional<AK::URL> parse_url_function(ComponentValue const&);
Optional<URL> parse_url_function(ComponentValue const&);
RefPtr<StyleValue> parse_url_value(ComponentValue const&);
Optional<Vector<LinearColorStopListElement>> parse_linear_color_stop_list(TokenStream<ComponentValue>&);
@ -330,7 +330,7 @@ private:
namespace Web {
CSS::CSSStyleSheet* parse_css_stylesheet(CSS::Parser::ParsingContext const&, StringView, Optional<AK::URL> location = {});
CSS::CSSStyleSheet* parse_css_stylesheet(CSS::Parser::ParsingContext const&, StringView, Optional<URL> location = {});
CSS::ElementInlineCSSStyleDeclaration* parse_css_style_attribute(CSS::Parser::ParsingContext const&, StringView, DOM::Element&);
RefPtr<CSS::StyleValue> parse_css_value(CSS::Parser::ParsingContext const&, StringView, CSS::PropertyID property_id = CSS::PropertyID::Invalid);
Optional<CSS::SelectorList> parse_selector(CSS::Parser::ParsingContext const&, StringView);

View file

@ -19,7 +19,7 @@ ParsingContext::ParsingContext(JS::Realm& realm, Mode mode)
{
}
ParsingContext::ParsingContext(DOM::Document const& document, AK::URL url, Mode mode)
ParsingContext::ParsingContext(DOM::Document const& document, URL url, Mode mode)
: m_realm(const_cast<JS::Realm&>(document.realm()))
, m_document(&document)
, m_url(move(url))
@ -49,7 +49,7 @@ bool ParsingContext::in_quirks_mode() const
}
// https://www.w3.org/TR/css-values-4/#relative-urls
AK::URL ParsingContext::complete_url(StringView relative_url) const
URL ParsingContext::complete_url(StringView relative_url) const
{
return m_url.complete_url(relative_url);
}

View file

@ -21,7 +21,7 @@ public:
explicit ParsingContext(JS::Realm&, Mode = Mode::Normal);
explicit ParsingContext(DOM::Document const&, Mode = Mode::Normal);
explicit ParsingContext(DOM::Document const&, AK::URL, Mode = Mode::Normal);
explicit ParsingContext(DOM::Document const&, URL, Mode = Mode::Normal);
explicit ParsingContext(DOM::ParentNode&, Mode = Mode::Normal);
Mode mode() const { return m_mode; }
@ -30,7 +30,7 @@ public:
bool in_quirks_mode() const;
DOM::Document const* document() const { return m_document; }
HTML::Window const* window() const;
AK::URL complete_url(StringView) const;
URL complete_url(StringView) 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; }
@ -41,7 +41,7 @@ private:
JS::NonnullGCPtr<JS::Realm> m_realm;
JS::GCPtr<DOM::Document const> m_document;
PropertyID m_current_property_id { PropertyID::Invalid };
AK::URL m_url;
URL m_url;
Mode m_mode { Mode::Normal };
};

View file

@ -276,10 +276,10 @@ static inline bool matches_pseudo_class(CSS::Selector::SimpleSelector::PseudoCla
if (!matches_link_pseudo_class(element))
return false;
auto document_url = element.document().url();
AK::URL target_url = element.document().parse_url(element.attribute(HTML::AttributeNames::href).value_or({}));
URL target_url = element.document().parse_url(element.attribute(HTML::AttributeNames::href).value_or({}));
if (target_url.fragment().has_value())
return document_url.equals(target_url, AK::URL::ExcludeFragment::No);
return document_url.equals(target_url, AK::URL::ExcludeFragment::Yes);
return document_url.equals(target_url, URL::ExcludeFragment::No);
return document_url.equals(target_url, URL::ExcludeFragment::Yes);
}
case CSS::PseudoClass::Visited:
// FIXME: Maybe match this selector sometimes?

View file

@ -100,7 +100,7 @@ StyleComputer::~StyleComputer() = default;
class StyleComputer::FontLoader : public ResourceClient {
public:
explicit FontLoader(StyleComputer& style_computer, FlyString family_name, Vector<Gfx::UnicodeRange> unicode_ranges, Vector<AK::URL> urls)
explicit FontLoader(StyleComputer& style_computer, FlyString family_name, Vector<Gfx::UnicodeRange> unicode_ranges, Vector<URL> urls)
: m_style_computer(style_computer)
, m_family_name(move(family_name))
, m_unicode_ranges(move(unicode_ranges))
@ -185,7 +185,7 @@ private:
FlyString m_family_name;
Vector<Gfx::UnicodeRange> m_unicode_ranges;
RefPtr<Gfx::VectorFont> m_vector_font;
Vector<AK::URL> m_urls;
Vector<URL> m_urls;
};
struct StyleComputer::MatchingFontCandidate {
@ -1999,11 +1999,11 @@ void StyleComputer::load_fonts_from_sheet(CSSStyleSheet const& sheet)
.slope = font_face.slope().value_or(0),
};
Vector<AK::URL> urls;
Vector<URL> urls;
for (auto& source : font_face.sources()) {
// FIXME: These should be loaded relative to the stylesheet URL instead of the document URL.
if (source.local_or_url.has<AK::URL>())
urls.append(m_document->parse_url(MUST(source.local_or_url.get<AK::URL>().to_string())));
if (source.local_or_url.has<URL>())
urls.append(m_document->parse_url(MUST(source.local_or_url.get<URL>().to_string())));
// FIXME: Handle local()
}

View file

@ -20,7 +20,7 @@
namespace Web::CSS {
ImageStyleValue::ImageStyleValue(AK::URL const& url)
ImageStyleValue::ImageStyleValue(URL const& url)
: AbstractImageStyleValue(Type::Image)
, m_url(url)
{

View file

@ -22,7 +22,7 @@ class ImageStyleValue final
: public AbstractImageStyleValue
, public Weakable<ImageStyleValue> {
public:
static ValueComparingNonnullRefPtr<ImageStyleValue> create(AK::URL const& url)
static ValueComparingNonnullRefPtr<ImageStyleValue> create(URL const& url)
{
return adopt_ref(*new (nothrow) ImageStyleValue(url));
}
@ -54,14 +54,14 @@ public:
JS::GCPtr<HTML::DecodedImageData> image_data() const;
private:
ImageStyleValue(AK::URL const&);
ImageStyleValue(URL const&);
JS::GCPtr<HTML::SharedImageRequest> m_image_request;
void animate();
Gfx::ImmutableBitmap const* bitmap(size_t frame_index, Gfx::IntSize = {}) const;
AK::URL m_url;
URL m_url;
WeakPtr<DOM::Document> m_document;
size_t m_current_frame_index { 0 };

View file

@ -14,14 +14,14 @@ namespace Web::CSS {
class URLStyleValue final : public StyleValueWithDefaultOperators<URLStyleValue> {
public:
static ValueComparingNonnullRefPtr<URLStyleValue> create(AK::URL const& url)
static ValueComparingNonnullRefPtr<URLStyleValue> create(URL const& url)
{
return adopt_ref(*new (nothrow) URLStyleValue(url));
}
virtual ~URLStyleValue() override = default;
AK::URL const& url() const { return m_url; }
URL const& url() const { return m_url; }
bool properties_equal(URLStyleValue const& other) const { return m_url == other.m_url; }
@ -31,13 +31,13 @@ public:
}
private:
URLStyleValue(AK::URL const& url)
URLStyleValue(URL const& url)
: StyleValueWithDefaultOperators(Type::URL)
, m_url(url)
{
}
AK::URL m_url;
URL m_url;
};
}