mirror of
https://github.com/RGBCube/serenity
synced 2025-05-16 16:34:59 +00:00
LibWeb: Make History GC-allocated
This commit is contained in:
parent
abfb73f2e7
commit
16fbb91aa1
7 changed files with 40 additions and 25 deletions
|
@ -4,18 +4,32 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibWeb/Bindings/HistoryPrototype.h>
|
||||
#include <LibWeb/DOM/Document.h>
|
||||
#include <LibWeb/HTML/History.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
||||
History::History(DOM::Document& document)
|
||||
: m_associated_document(document)
|
||||
JS::NonnullGCPtr<History> History::create(HTML::Window& window, DOM::Document& document)
|
||||
{
|
||||
return *window.heap().allocate<History>(window.realm(), window, document);
|
||||
}
|
||||
|
||||
History::History(HTML::Window& window, DOM::Document& document)
|
||||
: PlatformObject(window.realm())
|
||||
, m_associated_document(document)
|
||||
{
|
||||
set_prototype(&window.ensure_web_prototype<Bindings::HistoryPrototype>("History"));
|
||||
}
|
||||
|
||||
History::~History() = default;
|
||||
|
||||
void History::visit_edges(Cell::Visitor& visitor)
|
||||
{
|
||||
Base::visit_edges(visitor);
|
||||
visitor.visit(m_associated_document.ptr());
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/history.html#dom-history-pushstate
|
||||
DOM::ExceptionOr<void> History::push_state(JS::Value data, String const&, String const& url)
|
||||
{
|
||||
|
@ -36,7 +50,7 @@ DOM::ExceptionOr<void> History::shared_history_push_replace_state(JS::Value, Str
|
|||
// 1. Let document be history's associated Document. (NOTE: Not necessary)
|
||||
|
||||
// 2. If document is not fully active, then throw a "SecurityError" DOMException.
|
||||
if (!m_associated_document.is_fully_active())
|
||||
if (!m_associated_document->is_fully_active())
|
||||
return DOM::SecurityError::create("Cannot perform pushState or replaceState on a document that isn't fully active.");
|
||||
|
||||
// 3. Optionally, return. (For example, the user agent might disallow calls to these methods that are invoked on a timer,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue