mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-05 08:31:51 +00:00
Some checks are pending
CI / macOS, arm64, Sanitizer_CI, Clang (push) Waiting to run
CI / Linux, x86_64, Fuzzers_CI, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer_CI, GNU (push) Waiting to run
CI / Linux, x86_64, Sanitizer_CI, Clang (push) Waiting to run
Package the js repl as a binary artifact / macOS, arm64 (push) Waiting to run
Package the js repl as a binary artifact / Linux, x86_64 (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
The text track processing model would previously spin forever waiting for the track URL to change. It would then recursively invoke itself to handle the new URL, again entering the spin loop. This meant that tracks could easily cause event loop hangs. We now have an observer system to be notified when the track state changes instead. This lets us exit the processing model and move on.
35 lines
1 KiB
C++
35 lines
1 KiB
C++
/*
|
|
* Copyright (c) 2025, Tim Flynn <trflynn89@ladybird.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <LibGC/Function.h>
|
|
#include <LibJS/Forward.h>
|
|
#include <LibWeb/Bindings/PlatformObject.h>
|
|
#include <LibWeb/Bindings/TextTrackPrototype.h>
|
|
#include <LibWeb/HTML/TextTrack.h>
|
|
|
|
namespace Web::HTML {
|
|
|
|
class TextTrackObserver final : public Bindings::PlatformObject {
|
|
WEB_PLATFORM_OBJECT(TextTrackObserver, Bindings::PlatformObject);
|
|
GC_DECLARE_ALLOCATOR(TextTrackObserver);
|
|
|
|
public:
|
|
[[nodiscard]] GC::Ptr<GC::Function<void(TextTrack::ReadinessState)>> track_readiness_observer() const { return m_track_readiness_observer; }
|
|
void set_track_readiness_observer(Function<void(TextTrack::ReadinessState)>);
|
|
|
|
private:
|
|
explicit TextTrackObserver(JS::Realm&, TextTrack&);
|
|
|
|
virtual void visit_edges(Cell::Visitor&) override;
|
|
virtual void finalize() override;
|
|
|
|
GC::Ref<TextTrack> m_text_track;
|
|
GC::Ptr<GC::Function<void(TextTrack::ReadinessState)>> m_track_readiness_observer;
|
|
};
|
|
|
|
}
|