NavigationHistoryEntry.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. public:
  13. [[nodiscard]] static JS::NonnullGCPtr<NavigationHistoryEntry> create(JS::Realm&, JS::NonnullGCPtr<SessionHistoryEntry>);
  14. WebIDL::ExceptionOr<Optional<String>> url() const;
  15. String key() const;
  16. String id() const;
  17. i64 index() const;
  18. bool same_document() const;
  19. WebIDL::ExceptionOr<JS::Value> get_state();
  20. void set_ondispose(WebIDL::CallbackType*);
  21. WebIDL::CallbackType* ondispose();
  22. // Non-spec'd getter, not exposed to JS
  23. SessionHistoryEntry const& session_history_entry() const { return *m_session_history_entry; }
  24. SessionHistoryEntry& session_history_entry() { return *m_session_history_entry; }
  25. virtual ~NavigationHistoryEntry() override;
  26. private:
  27. NavigationHistoryEntry(JS::Realm&, JS::NonnullGCPtr<SessionHistoryEntry>);
  28. virtual void initialize(JS::Realm&) override;
  29. virtual void visit_edges(JS::Cell::Visitor&) override;
  30. JS::NonnullGCPtr<SessionHistoryEntry> m_session_history_entry;
  31. };
  32. }