Files
ladybird/Libraries/LibWeb/Speech/SpeechSynthesis.cpp
Shannon Booth fd44da6829 LibWeb/Bindings: Emit one bindings header and cpp per IDL
Previously, the LibWeb bindings generator would output multiple per
interface files like Prototype/Constructor/Namespace/GlobalMixin
depending on the contents of that IDL file.

This complicates the build system as it means that it does not know
what files will be generated without knowledge of the contents of that
IDL file.

Instead, for each IDL file only generate a single Bindings/<IDLFile>.h
and Bindings/<IDLFile>.cpp.
2026-04-21 07:36:13 +02:00

66 lines
1.6 KiB
C++

/*
* Copyright (c) 2026, Jelle Raaijmakers <jelle@ladybird.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibJS/Runtime/Realm.h>
#include <LibWeb/Bindings/Intrinsics.h>
#include <LibWeb/Bindings/SpeechSynthesis.h>
#include <LibWeb/HTML/EventNames.h>
#include <LibWeb/Speech/SpeechSynthesis.h>
#include <LibWeb/Speech/SpeechSynthesisVoice.h>
namespace Web::Speech {
GC_DEFINE_ALLOCATOR(SpeechSynthesis);
GC::Ref<SpeechSynthesis> SpeechSynthesis::create(JS::Realm& realm)
{
return realm.create<SpeechSynthesis>(realm);
}
SpeechSynthesis::SpeechSynthesis(JS::Realm& realm)
: DOM::EventTarget(realm)
{
}
SpeechSynthesis::~SpeechSynthesis() = default;
void SpeechSynthesis::initialize(JS::Realm& realm)
{
WEB_SET_PROTOTYPE_FOR_INTERFACE(SpeechSynthesis);
Base::initialize(realm);
}
void SpeechSynthesis::visit_edges(Cell::Visitor& visitor)
{
Base::visit_edges(visitor);
visitor.visit(m_voices);
}
void SpeechSynthesis::set_onvoiceschanged(GC::Ptr<WebIDL::CallbackType> event_handler)
{
set_event_handler_attribute(HTML::EventNames::voiceschanged, event_handler);
}
GC::Ptr<WebIDL::CallbackType> SpeechSynthesis::onvoiceschanged()
{
return event_handler_attribute(HTML::EventNames::voiceschanged);
}
// https://wicg.github.io/speech-api/#dom-speechsynthesis-cancel
void SpeechSynthesis::cancel()
{
dbgln("FIXME: Implement SpeechSynthesis::cancel()");
}
// https://wicg.github.io/speech-api/#dom-speechsynthesis-getvoices
Vector<GC::Ref<SpeechSynthesisVoice>> const& SpeechSynthesis::get_voices() const
{
// FIXME: Populate m_voices with available synthesis voices.
return m_voices;
}
}