mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 15:27:35 +00:00
LibWeb: Add the History object and stub pushState and replaceState
The spec allows us to optionally return from these for any reason. Our reason is that we don't have all the infrastructure in place yet to implement them.
This commit is contained in:
parent
3faed65e2b
commit
1927600852
10 changed files with 127 additions and 0 deletions
47
Userland/Libraries/LibWeb/HTML/History.h
Normal file
47
Userland/Libraries/LibWeb/HTML/History.h
Normal file
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
* Copyright (c) 2021, Luke Wilde <lukew@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/RefCounted.h>
|
||||
#include <AK/Weakable.h>
|
||||
#include <LibJS/Heap/Handle.h>
|
||||
#include <LibWeb/Bindings/Wrappable.h>
|
||||
#include <LibWeb/DOM/ExceptionOr.h>
|
||||
#include <LibWeb/Forward.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
||||
class History final
|
||||
: public RefCounted<History>
|
||||
, public Weakable<History>
|
||||
, public Bindings::Wrappable {
|
||||
public:
|
||||
using WrapperType = Bindings::HistoryWrapper;
|
||||
|
||||
static NonnullRefPtr<History> create(DOM::Document& document)
|
||||
{
|
||||
return adopt_ref(*new History(document));
|
||||
}
|
||||
|
||||
virtual ~History() override;
|
||||
|
||||
DOM::ExceptionOr<void> push_state(JS::Value data, String const& unused, String const& url);
|
||||
DOM::ExceptionOr<void> replace_state(JS::Value data, String const& unused, String const& url);
|
||||
|
||||
private:
|
||||
explicit History(DOM::Document&);
|
||||
|
||||
enum class IsPush {
|
||||
No,
|
||||
Yes,
|
||||
};
|
||||
DOM::ExceptionOr<void> shared_history_push_replace_state(JS::Value data, String const& url, IsPush is_push);
|
||||
|
||||
DOM::Document& m_associated_document;
|
||||
};
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue