mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 04:09:13 +00:00
LibWeb: Port Document encoding_parse_url and parse_url to Optional<URL>
This ports two more APIs away from URL::is_valid.
This commit is contained in:
parent
cfe9b7a82b
commit
22a7cd9700
Notes:
github-actions[bot]
2025-01-27 00:04:07 +00:00
Author: https://github.com/shannonbooth
Commit: 22a7cd9700
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3362
Reviewed-by: https://github.com/tcl3 ✅
26 changed files with 135 additions and 107 deletions
|
@ -129,7 +129,9 @@ GC::Ptr<SVGGradientElement const> SVGGradientElement::linked_gradient(HashTable<
|
|||
auto link = has_attribute(AttributeNames::href) ? get_attribute(AttributeNames::href) : get_attribute("xlink:href"_fly_string);
|
||||
if (auto href = link; href.has_value() && !link->is_empty()) {
|
||||
auto url = document().encoding_parse_url(*href);
|
||||
auto id = url.fragment();
|
||||
if (!url.has_value())
|
||||
return {};
|
||||
auto id = url->fragment();
|
||||
if (!id.has_value() || id->is_empty())
|
||||
return {};
|
||||
auto element = document().get_element_by_id(id.value());
|
||||
|
|
|
@ -146,11 +146,10 @@ void SVGImageElement::process_the_url(Optional<String> const& href)
|
|||
}
|
||||
|
||||
m_href = document().parse_url(*href);
|
||||
|
||||
if (!m_href.is_valid())
|
||||
if (!m_href.has_value())
|
||||
return;
|
||||
|
||||
fetch_the_document(m_href);
|
||||
fetch_the_document(*m_href);
|
||||
}
|
||||
|
||||
// https://svgwg.org/svg2-draft/linking.html#processingURL-fetch
|
||||
|
|
|
@ -60,7 +60,7 @@ private:
|
|||
size_t m_current_frame_index { 0 };
|
||||
size_t m_loops_completed { 0 };
|
||||
|
||||
URL::URL m_href;
|
||||
Optional<URL::URL> m_href;
|
||||
|
||||
GC::Ptr<HTML::SharedResourceRequest> m_resource_request;
|
||||
Optional<DOM::DocumentLoadEventDelayer> m_load_event_delayer;
|
||||
|
|
|
@ -53,11 +53,12 @@ void SVGScriptElement::process_the_script_element()
|
|||
if (has_attribute(SVG::AttributeNames::href) || has_attribute_ns(Namespace::XLink.to_string(), SVG::AttributeNames::href)) {
|
||||
auto href_value = href()->base_val();
|
||||
|
||||
script_url = document().parse_url(href_value);
|
||||
if (!script_url.is_valid()) {
|
||||
auto maybe_script_url = document().parse_url(href_value);
|
||||
if (!maybe_script_url.has_value()) {
|
||||
dbgln("Invalid script URL: {}", href_value);
|
||||
return;
|
||||
}
|
||||
script_url = maybe_script_url.release_value();
|
||||
|
||||
auto& vm = realm().vm();
|
||||
auto request = Fetch::Infrastructure::Request::create(vm);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue