/* * Copyright (c) 2023, Aliaksandr Kalenik * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include #include #include #include #include #include namespace Web::HTML { struct SessionHistoryTraversalQueueEntry : public JS::Cell { GC_CELL(SessionHistoryTraversalQueueEntry, JS::Cell); GC_DECLARE_ALLOCATOR(SessionHistoryTraversalQueueEntry); public: static GC::Ref create(JS::VM& vm, GC::Ref> steps, GC::Ptr target_navigable); GC::Ptr target_navigable() const { return m_target_navigable; } void execute_steps() const { m_steps->function()(); } private: SessionHistoryTraversalQueueEntry(GC::Ref> steps, GC::Ptr target_navigable) : m_steps(steps) , m_target_navigable(target_navigable) { } virtual void visit_edges(Cell::Visitor&) override; GC::Ref> m_steps; GC::Ptr m_target_navigable; }; // https://html.spec.whatwg.org/multipage/document-sequences.html#tn-session-history-traversal-queue class SessionHistoryTraversalQueue : public JS::Cell { GC_CELL(SessionHistoryTraversalQueue, JS::Cell); GC_DECLARE_ALLOCATOR(SessionHistoryTraversalQueue); public: SessionHistoryTraversalQueue(); void append(GC::Ref> steps); void append_sync(GC::Ref> steps, GC::Ptr target_navigable); // https://html.spec.whatwg.org/multipage/browsing-the-web.html#sync-navigations-jump-queue GC::Ptr first_synchronous_navigation_steps_with_target_navigable_not_contained_in(HashTable> const&); private: virtual void visit_edges(Cell::Visitor&) override; Vector> m_queue; RefPtr m_timer; bool m_is_task_running { false }; }; }