NavigationHistoryEntry.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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/DOM/EventTarget.h>
  8. namespace Web::HTML {
  9. // https://html.spec.whatwg.org/multipage/nav-history-apis.html#navigationhistoryentry
  10. class NavigationHistoryEntry : public DOM::EventTarget {
  11. WEB_PLATFORM_OBJECT(NavigationHistoryEntry, DOM::EventTarget);
  12. JS_DECLARE_ALLOCATOR(NavigationHistoryEntry);
  13. public:
  14. [[nodiscard]] static JS::NonnullGCPtr<NavigationHistoryEntry> create(JS::Realm&, JS::NonnullGCPtr<SessionHistoryEntry>);
  15. WebIDL::ExceptionOr<Optional<String>> url() const;
  16. String key() const;
  17. String id() const;
  18. i64 index() const;
  19. bool same_document() const;
  20. WebIDL::ExceptionOr<JS::Value> get_state();
  21. void set_ondispose(WebIDL::CallbackType*);
  22. WebIDL::CallbackType* ondispose();
  23. // Non-spec'd getter, not exposed to JS
  24. SessionHistoryEntry const& session_history_entry() const { return *m_session_history_entry; }
  25. SessionHistoryEntry& session_history_entry() { return *m_session_history_entry; }
  26. virtual ~NavigationHistoryEntry() override;
  27. private:
  28. NavigationHistoryEntry(JS::Realm&, JS::NonnullGCPtr<SessionHistoryEntry>);
  29. virtual void initialize(JS::Realm&) override;
  30. virtual void visit_edges(JS::Cell::Visitor&) override;
  31. JS::NonnullGCPtr<SessionHistoryEntry> m_session_history_entry;
  32. };
  33. }