History.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /*
  2. * Copyright (c) 2021, Luke Wilde <lukew@serenityos.org>
  3. * Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
  4. *
  5. * SPDX-License-Identifier: BSD-2-Clause
  6. */
  7. #pragma once
  8. #include <LibWeb/Bindings/PlatformObject.h>
  9. #include <LibWeb/WebIDL/ExceptionOr.h>
  10. namespace Web::HTML {
  11. class History final : public Bindings::PlatformObject {
  12. WEB_PLATFORM_OBJECT(History, Bindings::PlatformObject);
  13. public:
  14. [[nodiscard]] static JS::NonnullGCPtr<History> create(JS::Realm&, DOM::Document&);
  15. virtual ~History() override;
  16. WebIDL::ExceptionOr<void> push_state(JS::Value data, String const& unused, Optional<String> const& url = {});
  17. WebIDL::ExceptionOr<void> replace_state(JS::Value data, String const& unused, Optional<String> const& url = {});
  18. WebIDL::ExceptionOr<void> go(long delta);
  19. WebIDL::ExceptionOr<void> back();
  20. WebIDL::ExceptionOr<void> forward();
  21. WebIDL::ExceptionOr<u64> length() const;
  22. private:
  23. History(JS::Realm&, DOM::Document&);
  24. virtual void initialize(JS::Realm&) override;
  25. virtual void visit_edges(Cell::Visitor&) override;
  26. enum class IsPush {
  27. No,
  28. Yes,
  29. };
  30. WebIDL::ExceptionOr<void> shared_history_push_replace_state(JS::Value data, Optional<String> const& url, IsPush is_push);
  31. JS::NonnullGCPtr<DOM::Document> m_associated_document;
  32. };
  33. }