mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-26 14:28:49 +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
|
@ -625,14 +625,14 @@ public:
|
|||
// would have resulted from parsing the URL specified by candidate's src attribute's value relative to the
|
||||
// candidate's node document when the src attribute was last changed.
|
||||
auto url_record = m_candidate->document().parse_url(candiate_src);
|
||||
auto url_string = url_record.to_string();
|
||||
|
||||
// 4. ⌛ If urlString was not obtained successfully, then end the synchronous section, and jump down to the failed
|
||||
// with elements step below.
|
||||
if (!url_record.is_valid()) {
|
||||
if (!url_record.has_value()) {
|
||||
TRY(failed_with_elements());
|
||||
return {};
|
||||
}
|
||||
auto url_string = url_record->to_string();
|
||||
|
||||
// FIXME: 5. ⌛ If candidate has a type attribute whose value, when parsed as a MIME type (including any codecs described
|
||||
// by the codecs parameter, for types that define that parameter), represents a type that the user agent knows
|
||||
|
@ -645,7 +645,7 @@ public:
|
|||
|
||||
// 8. Run the resource fetch algorithm with urlRecord. If that algorithm returns without aborting this one, then
|
||||
// the load failed.
|
||||
TRY(m_media_element->fetch_resource(url_record, [this](auto) {
|
||||
TRY(m_media_element->fetch_resource(*url_record, [this](auto) {
|
||||
failed_with_elements().release_value_but_fixme_should_propagate_errors();
|
||||
}));
|
||||
|
||||
|
@ -871,15 +871,15 @@ WebIDL::ExceptionOr<void> HTMLMediaElement::select_resource()
|
|||
auto url_record = document().parse_url(source);
|
||||
|
||||
// 3. ⌛ If urlString was obtained successfully, set the currentSrc attribute to urlString.
|
||||
if (url_record.is_valid())
|
||||
m_current_src = url_record.to_string();
|
||||
if (url_record.has_value())
|
||||
m_current_src = url_record->to_string();
|
||||
|
||||
// 4. End the synchronous section, continuing the remaining steps in parallel.
|
||||
|
||||
// 5. If urlRecord was obtained successfully, run the resource fetch algorithm with urlRecord. If that algorithm returns without aborting this one,
|
||||
// then the load failed.
|
||||
if (url_record.is_valid()) {
|
||||
TRY(fetch_resource(url_record, move(failed_with_attribute)));
|
||||
if (url_record.has_value()) {
|
||||
TRY(fetch_resource(*url_record, move(failed_with_attribute)));
|
||||
return {};
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue