mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-25 14:05:15 +00:00
This is not in the spec, but we need to make sure that "apply the history step" for initial navigation to about:blank in iframe is applied before subsequent navigations. Otherwise, "set ongoing navigation" call during "about:blank" traversal might abort subsequent ongoing navigation which is not expected to happen.
47 lines
1 KiB
C++
47 lines
1 KiB
C++
/*
|
|
* Copyright (c) 2023, Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <LibCore/Timer.h>
|
|
|
|
namespace Web::HTML {
|
|
|
|
// https://html.spec.whatwg.org/multipage/document-sequences.html#tn-session-history-traversal-queue
|
|
class SessionHistoryTraversalQueue {
|
|
public:
|
|
SessionHistoryTraversalQueue()
|
|
{
|
|
m_timer = Core::Timer::create_single_shot(0, [this] {
|
|
while (m_queue.size() > 0) {
|
|
auto steps = m_queue.take_first();
|
|
steps();
|
|
}
|
|
}).release_value_but_fixme_should_propagate_errors();
|
|
}
|
|
|
|
void append(JS::SafeFunction<void()> steps)
|
|
{
|
|
m_queue.append(move(steps));
|
|
if (!m_timer->is_active()) {
|
|
m_timer->start();
|
|
}
|
|
}
|
|
|
|
void process()
|
|
{
|
|
while (m_queue.size() > 0) {
|
|
auto steps = m_queue.take_first();
|
|
steps();
|
|
}
|
|
}
|
|
|
|
private:
|
|
Vector<JS::SafeFunction<void()>> m_queue;
|
|
RefPtr<Core::Timer> m_timer;
|
|
};
|
|
|
|
}
|