1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-24 22:17:42 +00:00

LibWeb: Use navigate() instead of did_set_location_href in Location

This commit is contained in:
Aliaksandr Kalenik 2023-08-22 18:33:20 +02:00 committed by Andreas Kling
parent 083e4a3f30
commit acff244335
4 changed files with 7 additions and 17 deletions

View file

@ -131,7 +131,7 @@ WebIDL::ExceptionOr<void> Location::set_href(String const& new_href)
return vm.throw_completion<JS::URIError>(TRY_OR_THROW_OOM(vm, String::formatted("Invalid URL '{}'", new_href)));
// 3. Location-object navigate given the resulting URL record.
window.did_set_location_href({}, href_url);
TRY(navigate(href_url));
return {};
}
@ -350,8 +350,7 @@ WebIDL::ExceptionOr<void> Location::set_hash(String const& value)
return {};
// 8. Location-object navigate this to copyURL.
auto& window = verify_cast<HTML::Window>(HTML::current_global_object());
window.did_set_location_href({}, copy_url);
TRY(navigate(copy_url));
return {};
}
@ -365,7 +364,7 @@ void Location::reload() const
// 2. If document is null, then return.
if (!document)
return;
// FIXME: 3. If document's origin is not same origin-domain with the entry settings object's origin, then throw a "SecurityError" DOMException.
// 4. Reload document's node navigable.
@ -381,7 +380,7 @@ void Location::replace(String const& url) const
}
// https://html.spec.whatwg.org/multipage/nav-history-apis.html#dom-location-assign
WebIDL::ExceptionOr<void> Location::assign(String const& url) const
WebIDL::ExceptionOr<void> Location::assign(String const& url)
{
// 1. If this's relevant Document is null, then return.
auto const relevant_document = this->relevant_document();
@ -398,8 +397,8 @@ WebIDL::ExceptionOr<void> Location::assign(String const& url) const
return WebIDL::SyntaxError::create(realm(), MUST(String::formatted("Invalid URL '{}'", url)));
// 4. Location-object navigate this to the resulting URL record.
auto& window = verify_cast<HTML::Window>(HTML::current_global_object());
window.did_set_location_href({}, assign_url);
TRY(navigate(assign_url));
return {};
}

View file

@ -51,7 +51,7 @@ public:
void replace(String const& url) const;
void reload() const;
WebIDL::ExceptionOr<void> assign(String const& url) const;
WebIDL::ExceptionOr<void> assign(String const& url);
virtual JS::ThrowCompletionOr<JS::Object*> internal_get_prototype_of() const override;
virtual JS::ThrowCompletionOr<bool> internal_set_prototype_of(Object* prototype) override;

View file

@ -421,14 +421,6 @@ WebIDL::ExceptionOr<JS::GCPtr<WindowProxy>> Window::open_impl(StringView url, St
return target_browsing_context->window_proxy();
}
void Window::did_set_location_href(Badge<Location>, AK::URL const& new_href)
{
auto* browsing_context = associated_document().browsing_context();
if (!browsing_context)
return;
browsing_context->loader().load(new_href, FrameLoader::Type::Navigation);
}
void Window::did_call_location_replace(Badge<Location>, DeprecatedString url)
{
auto* browsing_context = associated_document().browsing_context();

View file

@ -95,7 +95,6 @@ public:
WebIDL::ExceptionOr<JS::GCPtr<WindowProxy>> open_impl(StringView url, StringView target, StringView features);
bool has_animation_frame_callbacks() const { return m_animation_frame_callback_driver.has_callbacks(); }
void did_set_location_href(Badge<Location>, AK::URL const& new_href);
void did_call_location_replace(Badge<Location>, DeprecatedString url);
DOM::Event* current_event() { return m_current_event.ptr(); }