
This change also removes as much direct use of JS::Promise in LibWeb as possible. When specs refer to `Promise<T>` they should be assumed to be referring to the WebIDL Promise type, not the JS::Promise type. The one exception is the HostPromiseRejectionTracker hook on the JS VM. This facility and its associated sets and events are intended to expose the exact opaque object handles that were rejected to author code. This is not possible with the WebIDL Promise type, so we have to use JS::Promise or JS::Object to hold onto the promises. It also exposes which specs need some updates in the area of promises. WebDriver stands out in this regard. WebAudio could use some more cross-references to WebIDL as well to clarify things.
49 lines
2 KiB
C++
49 lines
2 KiB
C++
/*
|
|
* Copyright (c) 2023, Andrew Kaster <akaster@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <LibWeb/Bindings/PlatformObject.h>
|
|
#include <LibWeb/HTML/NavigationType.h>
|
|
|
|
namespace Web::HTML {
|
|
|
|
// https://html.spec.whatwg.org/multipage/nav-history-apis.html#navigationtransition
|
|
class NavigationTransition : public Bindings::PlatformObject {
|
|
WEB_PLATFORM_OBJECT(NavigationTransition, Bindings::PlatformObject);
|
|
JS_DECLARE_ALLOCATOR(NavigationTransition);
|
|
|
|
public:
|
|
[[nodiscard]] static JS::NonnullGCPtr<NavigationTransition> create(JS::Realm&, Bindings::NavigationType, JS::NonnullGCPtr<NavigationHistoryEntry>, JS::NonnullGCPtr<WebIDL::Promise>);
|
|
|
|
// https://html.spec.whatwg.org/multipage/nav-history-apis.html#dom-navigationtransition-navigationtype
|
|
Bindings::NavigationType navigation_type() const { return m_navigation_type; }
|
|
|
|
// https://html.spec.whatwg.org/multipage/nav-history-apis.html#dom-navigationtransition-from
|
|
JS::NonnullGCPtr<NavigationHistoryEntry> from() const { return m_from_entry; }
|
|
|
|
// https://html.spec.whatwg.org/multipage/nav-history-apis.html#dom-navigationtransition-finished
|
|
JS::NonnullGCPtr<WebIDL::Promise> finished() const { return m_finished_promise; }
|
|
|
|
virtual ~NavigationTransition() override;
|
|
|
|
private:
|
|
NavigationTransition(JS::Realm&, Bindings::NavigationType, JS::NonnullGCPtr<NavigationHistoryEntry>, JS::NonnullGCPtr<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
|
|
Bindings::NavigationType m_navigation_type;
|
|
|
|
// https://html.spec.whatwg.org/multipage/nav-history-apis.html#concept-navigationtransition-from
|
|
JS::NonnullGCPtr<NavigationHistoryEntry> m_from_entry;
|
|
|
|
// https://html.spec.whatwg.org/multipage/nav-history-apis.html#concept-navigationtransition-finished
|
|
JS::NonnullGCPtr<WebIDL::Promise> m_finished_promise;
|
|
};
|
|
|
|
}
|