mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-27 12:46:06 +00:00
LibURL+LibWeb: Make URL::serialize return a String
Simplifying a bunch of uneeded error handling around the place.
This commit is contained in:
parent
d7ac0601ab
commit
0fa54c2327
Notes:
github-actions[bot]
2024-12-04 16:48:13 +00:00
Author: https://github.com/shannonbooth
Commit: 0fa54c2327
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2727
Reviewed-by: https://github.com/AtkinsSJ ✅
52 changed files with 88 additions and 103 deletions
|
@ -66,7 +66,7 @@ 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, ParsedFontFace::Source source) -> void {
|
||||
if (source.local_or_url.has<URL::URL>()) {
|
||||
serialize_a_url(builder, MUST(source.local_or_url.get<URL::URL>().to_string()));
|
||||
serialize_a_url(builder, source.local_or_url.get<URL::URL>().to_string());
|
||||
} else {
|
||||
builder.appendff("local({})", source.local_or_url.get<String>());
|
||||
}
|
||||
|
|
|
@ -66,7 +66,7 @@ String CSSImportRule::serialized() const
|
|||
builder.append("@import "sv);
|
||||
|
||||
// 2. The result of performing serialize a URL on the rule’s location.
|
||||
serialize_a_url(builder, MUST(m_url.to_string()));
|
||||
serialize_a_url(builder, m_url.to_string());
|
||||
|
||||
// FIXME: 3. If the rule’s associated media list is not empty, a single SPACE (U+0020) followed by the result of performing serialize a media query list on the media list.
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ public:
|
|||
|
||||
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()); }
|
||||
String href() const { return m_url.to_string(); }
|
||||
|
||||
CSSStyleSheet* loaded_style_sheet() { return m_style_sheet; }
|
||||
CSSStyleSheet const* loaded_style_sheet() const { return m_style_sheet; }
|
||||
|
|
|
@ -36,7 +36,7 @@ WebIDL::ExceptionOr<GC::Ref<CSSStyleSheet>> CSSStyleSheet::construct_impl(JS::Re
|
|||
|
||||
// 2. Set sheet’s location to the base URL of the associated Document for the current principal global object.
|
||||
auto associated_document = verify_cast<HTML::Window>(HTML::current_principal_global_object()).document();
|
||||
sheet->set_location(MUST(associated_document->base_url().to_string()));
|
||||
sheet->set_location(associated_document->base_url().to_string());
|
||||
|
||||
// 3. Set sheet’s stylesheet base URL to the baseURL attribute value from options.
|
||||
if (options.has_value() && options->base_url.has_value()) {
|
||||
|
@ -99,7 +99,7 @@ CSSStyleSheet::CSSStyleSheet(JS::Realm& realm, CSSRuleList& rules, MediaList& me
|
|||
, m_rules(&rules)
|
||||
{
|
||||
if (location.has_value())
|
||||
set_location(MUST(location->to_string()));
|
||||
set_location(location->to_string());
|
||||
|
||||
for (auto& rule : *m_rules)
|
||||
rule->set_parent_style_sheet(this);
|
||||
|
|
|
@ -426,7 +426,7 @@ GC::Ptr<CSSNamespaceRule> Parser::convert_to_namespace_rule(AtRule const& rule)
|
|||
|
||||
FlyString namespace_uri;
|
||||
if (auto url = parse_url_function(tokens); url.has_value()) {
|
||||
namespace_uri = MUST(url.value().to_string());
|
||||
namespace_uri = url.value().to_string();
|
||||
} else if (auto& url_token = tokens.consume_a_token(); url_token.is(Token::Type::String)) {
|
||||
namespace_uri = url_token.token().string();
|
||||
} else {
|
||||
|
|
|
@ -247,7 +247,7 @@ void FontLoader::start_loading_next_url()
|
|||
// request until fetch infrastructure is used here.
|
||||
auto referrer_url = ReferrerPolicy::strip_url_for_use_as_referrer(m_style_computer.document().url());
|
||||
if (referrer_url.has_value() && !request.headers().contains("Referer"))
|
||||
request.set_header("Referer", referrer_url->serialize());
|
||||
request.set_header("Referer", referrer_url->serialize().to_byte_string());
|
||||
|
||||
set_resource(ResourceLoader::the().load_resource(Resource::Type::Generic, request));
|
||||
}
|
||||
|
@ -2836,7 +2836,7 @@ Optional<FontLoader&> StyleComputer::load_font_face(ParsedFontFace const& font_f
|
|||
for (auto const& 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<URL::URL>())
|
||||
urls.append(m_document->parse_url(MUST(source.local_or_url.get<URL::URL>().to_string())));
|
||||
urls.append(m_document->parse_url(source.local_or_url.get<URL::URL>().to_string()));
|
||||
// FIXME: Handle local()
|
||||
}
|
||||
|
||||
|
|
|
@ -114,7 +114,7 @@ Gfx::ImmutableBitmap const* ImageStyleValue::bitmap(size_t frame_index, Gfx::Int
|
|||
|
||||
String ImageStyleValue::to_string() const
|
||||
{
|
||||
return serialize_a_url(MUST(m_url.to_string()));
|
||||
return serialize_a_url(m_url.to_string());
|
||||
}
|
||||
|
||||
bool ImageStyleValue::equals(CSSStyleValue const& other) const
|
||||
|
|
|
@ -27,7 +27,7 @@ public:
|
|||
|
||||
virtual String to_string() const override
|
||||
{
|
||||
return serialize_a_url(MUST(m_url.to_string()));
|
||||
return serialize_a_url(m_url.to_string());
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue