mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-01 15:43:36 +03:00
LibWeb: Implement navigate()
for Location object
This commit is contained in:
parent
5f21285337
commit
43da0701fc
Notes:
sideshowbarker
2024-07-17 02:06:40 +09:00
Author: https://github.com/kalenikaliaksandr Commit: https://github.com/SerenityOS/serenity/commit/43da0701fc Pull-request: https://github.com/SerenityOS/serenity/pull/20711
@ -58,6 +58,26 @@ JS::GCPtr<DOM::Document> Location::relevant_document() const
|
||||
return browsing_context ? browsing_context->active_document() : nullptr;
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/nav-history-apis.html#location-object-navigate
|
||||
WebIDL::ExceptionOr<void> Location::navigate(AK::URL url, HistoryHandlingBehavior history_handling)
|
||||
{
|
||||
// 1. Let navigable be location's relevant global object's navigable.
|
||||
auto navigable = verify_cast<HTML::Window>(HTML::relevant_global_object(*this)).navigable();
|
||||
|
||||
// 2. Let sourceDocument be the incumbent global object's associated Document.
|
||||
auto& source_document = verify_cast<HTML::Window>(incumbent_global_object()).associated_document();
|
||||
|
||||
// 3. If location's relevant Document is not yet completely loaded, and the incumbent global object does not have transient activation, then set historyHandling to "replace".
|
||||
if (!relevant_document()->is_completely_loaded() && !verify_cast<HTML::Window>(incumbent_global_object()).has_transient_activation()) {
|
||||
history_handling = HistoryHandlingBehavior::Replace;
|
||||
}
|
||||
|
||||
// 4. Navigate navigable to url using sourceDocument, with exceptionsEnabled set to true and historyHandling set to historyHandling.
|
||||
TRY(navigable->navigate(url, source_document, {}, nullptr, true, history_handling));
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/history.html#concept-location-url
|
||||
AK::URL Location::url() const
|
||||
{
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include <LibWeb/Bindings/PlatformObject.h>
|
||||
#include <LibWeb/Forward.h>
|
||||
#include <LibWeb/HTML/CrossOrigin/CrossOriginPropertyDescriptorMap.h>
|
||||
#include <LibWeb/HTML/HistoryHandlingBehavior.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
||||
@ -74,6 +75,7 @@ private:
|
||||
|
||||
JS::GCPtr<DOM::Document> relevant_document() const;
|
||||
AK::URL url() const;
|
||||
WebIDL::ExceptionOr<void> navigate(AK::URL, HistoryHandlingBehavior = HistoryHandlingBehavior::Default);
|
||||
|
||||
// [[CrossOriginPropertyDescriptorMap]], https://html.spec.whatwg.org/multipage/browsers.html#crossoriginpropertydescriptormap
|
||||
HTML::CrossOriginPropertyDescriptorMap m_cross_origin_property_descriptor_map;
|
||||
|
Loading…
Reference in New Issue
Block a user