NavigationTransition.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*
  2. * Copyright (c) 2023, Andrew Kaster <akaster@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <LibWeb/Bindings/PlatformObject.h>
  8. #include <LibWeb/HTML/NavigationType.h>
  9. namespace Web::HTML {
  10. // https://html.spec.whatwg.org/multipage/nav-history-apis.html#navigationtransition
  11. class NavigationTransition : public Bindings::PlatformObject {
  12. WEB_PLATFORM_OBJECT(NavigationTransition, Bindings::PlatformObject);
  13. JS_DECLARE_ALLOCATOR(NavigationTransition);
  14. public:
  15. [[nodiscard]] static JS::NonnullGCPtr<NavigationTransition> create(JS::Realm&, Bindings::NavigationType, JS::NonnullGCPtr<NavigationHistoryEntry>, JS::GCPtr<JS::Promise>);
  16. // https://html.spec.whatwg.org/multipage/nav-history-apis.html#dom-navigationtransition-navigationtype
  17. Bindings::NavigationType navigation_type() const { return m_navigation_type; }
  18. // https://html.spec.whatwg.org/multipage/nav-history-apis.html#dom-navigationtransition-from
  19. JS::NonnullGCPtr<NavigationHistoryEntry> from() const { return m_from_entry; }
  20. // https://html.spec.whatwg.org/multipage/nav-history-apis.html#dom-navigationtransition-finished
  21. JS::GCPtr<JS::Promise> finished() const { return m_finished_promise; }
  22. virtual ~NavigationTransition() override;
  23. private:
  24. NavigationTransition(JS::Realm&, Bindings::NavigationType, JS::NonnullGCPtr<NavigationHistoryEntry>, JS::GCPtr<JS::Promise>);
  25. virtual void initialize(JS::Realm&) override;
  26. virtual void visit_edges(JS::Cell::Visitor&) override;
  27. // https://html.spec.whatwg.org/multipage/nav-history-apis.html#concept-navigationtransition-navigationtype
  28. Bindings::NavigationType m_navigation_type;
  29. // https://html.spec.whatwg.org/multipage/nav-history-apis.html#concept-navigationtransition-from
  30. JS::NonnullGCPtr<NavigationHistoryEntry> m_from_entry;
  31. // https://html.spec.whatwg.org/multipage/nav-history-apis.html#concept-navigationtransition-finished
  32. JS::GCPtr<JS::Promise> m_finished_promise;
  33. };
  34. }