2021-09-11 23:43:34 +01:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2021, Luke Wilde <lukew@serenityos.org>
|
2022-09-02 13:50:24 +02:00
|
|
|
* Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
|
2021-09-11 23:43:34 +01:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2022-09-02 13:50:24 +02:00
|
|
|
#include <LibWeb/Bindings/PlatformObject.h>
|
2022-09-25 17:03:42 +01:00
|
|
|
#include <LibWeb/WebIDL/ExceptionOr.h>
|
2021-09-11 23:43:34 +01:00
|
|
|
|
|
|
|
namespace Web::HTML {
|
|
|
|
|
2022-09-02 13:50:24 +02:00
|
|
|
class History final : public Bindings::PlatformObject {
|
|
|
|
WEB_PLATFORM_OBJECT(History, Bindings::PlatformObject);
|
2021-09-11 23:43:34 +01:00
|
|
|
|
2022-09-02 13:50:24 +02:00
|
|
|
public:
|
2023-08-13 13:05:26 +02:00
|
|
|
[[nodiscard]] static JS::NonnullGCPtr<History> create(JS::Realm&, DOM::Document&);
|
2021-09-11 23:43:34 +01:00
|
|
|
|
|
|
|
virtual ~History() override;
|
|
|
|
|
2023-08-26 17:03:52 +12:00
|
|
|
WebIDL::ExceptionOr<void> push_state(JS::Value data, String const& unused, Optional<String> const& url = {});
|
|
|
|
WebIDL::ExceptionOr<void> replace_state(JS::Value data, String const& unused, Optional<String> const& url = {});
|
2022-10-13 22:43:04 +08:00
|
|
|
WebIDL::ExceptionOr<void> go(long delta);
|
|
|
|
WebIDL::ExceptionOr<void> back();
|
|
|
|
WebIDL::ExceptionOr<void> forward();
|
|
|
|
WebIDL::ExceptionOr<u64> length() const;
|
2021-09-11 23:43:34 +01:00
|
|
|
|
2023-09-23 22:57:04 +02:00
|
|
|
u64 m_index { 0 };
|
|
|
|
u64 m_length { 0 };
|
|
|
|
|
2021-09-11 23:43:34 +01:00
|
|
|
private:
|
2022-09-25 16:38:21 -06:00
|
|
|
History(JS::Realm&, DOM::Document&);
|
2022-09-02 13:50:24 +02:00
|
|
|
|
2023-08-07 08:41:28 +02:00
|
|
|
virtual void initialize(JS::Realm&) override;
|
2022-09-02 13:50:24 +02:00
|
|
|
virtual void visit_edges(Cell::Visitor&) override;
|
2021-09-11 23:43:34 +01:00
|
|
|
|
|
|
|
enum class IsPush {
|
|
|
|
No,
|
|
|
|
Yes,
|
|
|
|
};
|
2023-08-26 17:03:52 +12:00
|
|
|
WebIDL::ExceptionOr<void> shared_history_push_replace_state(JS::Value data, Optional<String> const& url, IsPush is_push);
|
2021-09-11 23:43:34 +01:00
|
|
|
|
2022-09-02 13:50:24 +02:00
|
|
|
JS::NonnullGCPtr<DOM::Document> m_associated_document;
|
2021-09-11 23:43:34 +01:00
|
|
|
};
|
|
|
|
|
2023-09-22 18:15:03 -06:00
|
|
|
bool can_have_its_url_rewritten(DOM::Document const& document, AK::URL const& target_url);
|
|
|
|
|
2021-09-11 23:43:34 +01:00
|
|
|
}
|