mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-12-07 21:59:54 +00:00
LibWeb/HTML: Implement NavigationTransition.to
Corresponds to:
f19930f98a
This commit is contained in:
parent
43bd5342c5
commit
945c4ca5b3
Notes:
github-actions[bot]
2025-12-05 09:21:24 +00:00
Author: https://github.com/AtkinsSJ
Commit: 945c4ca5b3
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/7020
4 changed files with 48 additions and 13 deletions
|
|
@ -1123,10 +1123,13 @@ bool Navigation::inner_navigate_event_firing_algorithm(
|
|||
// 3. Assert: fromNHE is not null.
|
||||
VERIFY(from_nhe != nullptr);
|
||||
|
||||
// 4. Set navigation's transition to a new NavigationTransition created in navigation's relevant realm,
|
||||
// whose navigation type is navigationType, whose from entry is fromNHE, and whose finished promise is a new promise
|
||||
// created in navigation's relevant realm.
|
||||
m_transition = NavigationTransition::create(realm, navigation_type, *from_nhe, WebIDL::create_promise(realm));
|
||||
// 4. Set navigation's transition to a new NavigationTransition created in navigation's relevant realm, with
|
||||
// navigation type: navigationType
|
||||
// from entry: fromNHE
|
||||
// destination: event's destination
|
||||
// FIXME: committed promise: a new promise created in navigation's relevant realm
|
||||
// finished promise: a new promise created in navigation's relevant realm
|
||||
m_transition = NavigationTransition::create(realm, navigation_type, *from_nhe, event->destination(), WebIDL::create_promise(realm));
|
||||
|
||||
// 5. Mark as handled navigation's transition's finished promise.
|
||||
WebIDL::mark_promise_as_handled(*m_transition->finished());
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
#include <LibJS/Runtime/Realm.h>
|
||||
#include <LibWeb/Bindings/Intrinsics.h>
|
||||
#include <LibWeb/Bindings/NavigationTransitionPrototype.h>
|
||||
#include <LibWeb/HTML/NavigationDestination.h>
|
||||
#include <LibWeb/HTML/NavigationHistoryEntry.h>
|
||||
#include <LibWeb/HTML/NavigationTransition.h>
|
||||
#include <LibWeb/WebIDL/Promise.h>
|
||||
|
|
@ -16,15 +17,16 @@ namespace Web::HTML {
|
|||
|
||||
GC_DEFINE_ALLOCATOR(NavigationTransition);
|
||||
|
||||
GC::Ref<NavigationTransition> NavigationTransition::create(JS::Realm& realm, Bindings::NavigationType navigation_type, GC::Ref<NavigationHistoryEntry> from_entry, GC::Ref<WebIDL::Promise> finished_promise)
|
||||
GC::Ref<NavigationTransition> NavigationTransition::create(JS::Realm& realm, Bindings::NavigationType navigation_type, GC::Ref<NavigationHistoryEntry> from_entry, GC::Ref<NavigationDestination> destination, GC::Ref<WebIDL::Promise> finished_promise)
|
||||
{
|
||||
return realm.create<NavigationTransition>(realm, navigation_type, from_entry, finished_promise);
|
||||
return realm.create<NavigationTransition>(realm, navigation_type, from_entry, destination, finished_promise);
|
||||
}
|
||||
|
||||
NavigationTransition::NavigationTransition(JS::Realm& realm, Bindings::NavigationType navigation_type, GC::Ref<NavigationHistoryEntry> from_entry, GC::Ref<WebIDL::Promise> finished_promise)
|
||||
NavigationTransition::NavigationTransition(JS::Realm& realm, Bindings::NavigationType navigation_type, GC::Ref<NavigationHistoryEntry> from_entry, GC::Ref<NavigationDestination> destination, GC::Ref<WebIDL::Promise> finished_promise)
|
||||
: Bindings::PlatformObject(realm)
|
||||
, m_navigation_type(navigation_type)
|
||||
, m_from_entry(from_entry)
|
||||
, m_destination(destination)
|
||||
, m_finished_promise(finished_promise)
|
||||
{
|
||||
}
|
||||
|
|
@ -41,6 +43,7 @@ void NavigationTransition::visit_edges(JS::Cell::Visitor& visitor)
|
|||
{
|
||||
Base::visit_edges(visitor);
|
||||
visitor.visit(m_from_entry);
|
||||
visitor.visit(m_destination);
|
||||
visitor.visit(m_finished_promise);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,32 +17,58 @@ class NavigationTransition : public Bindings::PlatformObject {
|
|||
GC_DECLARE_ALLOCATOR(NavigationTransition);
|
||||
|
||||
public:
|
||||
[[nodiscard]] static GC::Ref<NavigationTransition> create(JS::Realm&, Bindings::NavigationType, GC::Ref<NavigationHistoryEntry>, GC::Ref<WebIDL::Promise>);
|
||||
[[nodiscard]] static GC::Ref<NavigationTransition> create(JS::Realm&, Bindings::NavigationType, GC::Ref<NavigationHistoryEntry>, GC::Ref<NavigationDestination>, GC::Ref<WebIDL::Promise>);
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/nav-history-apis.html#dom-navigationtransition-navigationtype
|
||||
Bindings::NavigationType navigation_type() const { return m_navigation_type; }
|
||||
Bindings::NavigationType navigation_type() const
|
||||
{
|
||||
// The navigationType getter steps are to return this's navigation type.
|
||||
return m_navigation_type;
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/nav-history-apis.html#dom-navigationtransition-from
|
||||
GC::Ref<NavigationHistoryEntry> from() const { return m_from_entry; }
|
||||
GC::Ref<NavigationHistoryEntry> from() const
|
||||
{
|
||||
// The from getter steps are to return this's from entry.
|
||||
return m_from_entry;
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/nav-history-apis.html#dom-navigationtransition-to
|
||||
GC::Ref<NavigationDestination> to() const
|
||||
{
|
||||
// The to getter steps are to return this's destination.
|
||||
return m_destination;
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/nav-history-apis.html#dom-navigationtransition-finished
|
||||
GC::Ref<WebIDL::Promise> finished() const { return m_finished_promise; }
|
||||
GC::Ref<WebIDL::Promise> finished() const
|
||||
{
|
||||
// The finished getter steps are to return this's finished promise.
|
||||
return m_finished_promise;
|
||||
}
|
||||
|
||||
virtual ~NavigationTransition() override;
|
||||
|
||||
private:
|
||||
NavigationTransition(JS::Realm&, Bindings::NavigationType, GC::Ref<NavigationHistoryEntry>, GC::Ref<WebIDL::Promise>);
|
||||
NavigationTransition(JS::Realm&, Bindings::NavigationType, GC::Ref<NavigationHistoryEntry>, GC::Ref<NavigationDestination>, GC::Ref<WebIDL::Promise>);
|
||||
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
virtual void visit_edges(JS::Cell::Visitor&) override;
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/nav-history-apis.html#concept-navigationtransition-navigationtype
|
||||
// Each NavigationTransition has an associated navigation type, which is a NavigationType.
|
||||
Bindings::NavigationType m_navigation_type;
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/nav-history-apis.html#concept-navigationtransition-from
|
||||
// Each NavigationTransition has an associated from entry, which is a NavigationHistoryEntry.
|
||||
GC::Ref<NavigationHistoryEntry> m_from_entry;
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/nav-history-apis.html#concept-navigationtransition-destination
|
||||
// Each NavigationTransition has an associated destination, which is a NavigationDestination.
|
||||
GC::Ref<NavigationDestination> m_destination;
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/nav-history-apis.html#concept-navigationtransition-finished
|
||||
// Each NavigationTransition has an associated finished promise, which is a promise.
|
||||
GC::Ref<WebIDL::Promise> m_finished_promise;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,13 @@
|
|||
#import <HTML/NavigationType.idl>
|
||||
#import <HTML/NavigationDestination.idl>
|
||||
#import <HTML/NavigationHistoryEntry.idl>
|
||||
#import <HTML/NavigationType.idl>
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/nav-history-apis.html#navigationtransition
|
||||
[Exposed=Window]
|
||||
interface NavigationTransition {
|
||||
readonly attribute NavigationType navigationType;
|
||||
readonly attribute NavigationHistoryEntry from;
|
||||
readonly attribute NavigationDestination to;
|
||||
// FIXME: readonly attribute Promise<undefined> committed;
|
||||
readonly attribute Promise<undefined> finished;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue