History.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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/HTML/HistoryHandlingBehavior.h>
  10. #include <LibWeb/WebIDL/ExceptionOr.h>
  11. namespace Web::HTML {
  12. class History final : public Bindings::PlatformObject {
  13. WEB_PLATFORM_OBJECT(History, Bindings::PlatformObject);
  14. public:
  15. [[nodiscard]] static JS::NonnullGCPtr<History> create(JS::Realm&, DOM::Document&);
  16. virtual ~History() override;
  17. WebIDL::ExceptionOr<void> push_state(JS::Value data, String const& unused, Optional<String> const& url = {});
  18. WebIDL::ExceptionOr<void> replace_state(JS::Value data, String const& unused, Optional<String> const& url = {});
  19. WebIDL::ExceptionOr<void> go(long delta);
  20. WebIDL::ExceptionOr<void> back();
  21. WebIDL::ExceptionOr<void> forward();
  22. WebIDL::ExceptionOr<u64> length() const;
  23. u64 m_index { 0 };
  24. u64 m_length { 0 };
  25. private:
  26. History(JS::Realm&, DOM::Document&);
  27. virtual void initialize(JS::Realm&) override;
  28. virtual void visit_edges(Cell::Visitor&) override;
  29. WebIDL::ExceptionOr<void> shared_history_push_replace_state(JS::Value data, Optional<String> const& url, HistoryHandlingBehavior);
  30. JS::NonnullGCPtr<DOM::Document> m_associated_document;
  31. };
  32. bool can_have_its_url_rewritten(DOM::Document const& document, AK::URL const& target_url);
  33. }