Truly independent web browser
LibWeb: Implement the speech recognition results in Rust
Shannon Boothe0eb4ffa78a2
diff --git a/Libraries/LibWeb/Bindings/Rust/src/speech/mod.rs b/Libraries/LibWeb/Bindings/Rust/src/speech/mod.rsindex f87350c0e87..a8d12086e7b 100644--- a/Libraries/LibWeb/Bindings/Rust/src/speech/mod.rs+++ b/Libraries/LibWeb/Bindings/Rust/src/speech/mod.rs@@ -6,5 +6,13 @@//! The Web Speech API, https://webaudio.github.io/web-speech-api/+#[cfg(not(test))]+pub(crate) mod speech_recognition_alternative;+#[cfg(not(test))]+pub(crate) mod speech_recognition_event;#[cfg(not(test))]pub(crate) mod speech_recognition_phrase;+#[cfg(not(test))]+pub(crate) mod speech_recognition_result;+#[cfg(not(test))]+pub(crate) mod speech_recognition_result_list;diff --git a/Libraries/LibWeb/Bindings/Rust/src/speech/speech_recognition_alternative.rs b/Libraries/LibWeb/Bindings/Rust/src/speech/speech_recognition_alternative.rsnew file mode 100644index 00000000000..6f77bc69918--- /dev/null+++ b/Libraries/LibWeb/Bindings/Rust/src/speech/speech_recognition_alternative.rs@@ -0,0 +1,39 @@+/*+ * Copyright (c) 2026, Jelle Raaijmakers <[email protected]>+ * Copyright (c) 2026-present, the Ladybird developers.+ *+ * SPDX-License-Identifier: BSD-2-Clause+ */++//! SpeechRecognitionAlternative, https://wicg.github.io/speech-api/#speechrecognitionalternative++use ak::Utf16String;+use libjs_rust::api::Trace;++use crate::bindings::interface::Wrappable;+use crate::bindings::{CallContext, WebIdlResult};++#[derive(Trace)]+#[gc(crate = libjs_rust)]+pub(crate) struct SpeechRecognitionAlternative {+ transcript: Utf16String,+ confidence: f32,+}++impl Wrappable for SpeechRecognitionAlternative {}++#[expect(+ clippy::unnecessary_wraps,+ reason = "the bindings call every method of an implementation for its WebIDL result, whether or not it can fail"+)]+impl SpeechRecognitionAlternative {+ // https://wicg.github.io/speech-api/#dom-speechrecognitionalternative-transcript+ pub(crate) fn transcript(&self, _: &mut CallContext) -> WebIdlResult<Utf16String> {+ Ok(self.transcript.clone())+ }++ // https://wicg.github.io/speech-api/#dom-speechrecognitionalternative-confidence+ pub(crate) fn confidence(&self, _: &mut CallContext) -> WebIdlResult<f32> {+ Ok(self.confidence)+ }+}diff --git a/Libraries/LibWeb/Bindings/Rust/src/speech/speech_recognition_event.rs b/Libraries/LibWeb/Bindings/Rust/src/speech/speech_recognition_event.rsnew file mode 100644index 00000000000..bb835551516--- /dev/null+++ b/Libraries/LibWeb/Bindings/Rust/src/speech/speech_recognition_event.rs@@ -0,0 +1,77 @@+/*+ * Copyright (c) 2026, Jelle Raaijmakers <[email protected]>+ * Copyright (c) 2026-present, the Ladybird developers.+ *+ * SPDX-License-Identifier: BSD-2-Clause+ */++//! SpeechRecognitionEvent, https://wicg.github.io/speech-api/#speechrecognitionevent++use core::ffi::c_void;+use core::ptr::NonNull;++use ak::Utf16String;+use libjs_rust::api::Trace;++use super::speech_recognition_result_list::SpeechRecognitionResultList;+use crate::bindings::event_target::CppEvent;+use crate::bindings::interface::{Ref, Wrappable, allocate};+use crate::bindings::{CallContext, WebIdlResult};+use crate::dom::event::EventInit;++pub(crate) struct SpeechRecognitionEventInit {+ pub(crate) parent: EventInit,+ pub(crate) result_index: u32,+ pub(crate) results: Ref<SpeechRecognitionResultList>,+}++#[derive(Trace)]+#[gc(crate = libjs_rust)]+pub(crate) struct SpeechRecognitionEvent {+ event: CppEvent,+ result_index: u32,+ results: Ref<SpeechRecognitionResultList>,+}++impl Wrappable for SpeechRecognitionEvent {+ fn cpp_parent(&self) -> Option<NonNull<c_void>> {+ self.event.as_cpp_parent()+ }+}++#[expect(+ clippy::unnecessary_wraps,+ reason = "the bindings call every method of an implementation for its WebIDL result, whether or not it can fail"+)]+impl SpeechRecognitionEvent {+ pub(crate) fn construct(+ cx: &mut CallContext,+ r#type: Utf16String,+ event_init_dict: SpeechRecognitionEventInit,+ ) -> WebIdlResult<Ref<Self>> {+ let event = CppEvent::create_for_owner(+ cx.realm(),+ &r#type,+ event_init_dict.parent.bubbles,+ event_init_dict.parent.cancelable,+ event_init_dict.parent.composed,+ );+ let object = allocate(cx.vm(), |_| Self {+ event,+ result_index: event_init_dict.result_index,+ results: event_init_dict.results,+ });+ object.event.set_owner(object);+ Ok(object)+ }++ // https://wicg.github.io/speech-api/#dom-speechrecognitionevent-resultindex+ pub(crate) fn result_index(&self, _: &mut CallContext) -> WebIdlResult<u32> {+ Ok(self.result_index)+ }++ // https://wicg.github.io/speech-api/#dom-speechrecognitionevent-results+ pub(crate) fn results(&self, _: &mut CallContext) -> WebIdlResult<Ref<SpeechRecognitionResultList>> {+ Ok(self.results)+ }+}diff --git a/Libraries/LibWeb/Bindings/Rust/src/speech/speech_recognition_result.rs b/Libraries/LibWeb/Bindings/Rust/src/speech/speech_recognition_result.rsnew file mode 100644index 00000000000..948f43c7e95--- /dev/null+++ b/Libraries/LibWeb/Bindings/Rust/src/speech/speech_recognition_result.rs@@ -0,0 +1,48 @@+/*+ * Copyright (c) 2026, Jelle Raaijmakers <[email protected]>+ * Copyright (c) 2026-present, the Ladybird developers.+ *+ * SPDX-License-Identifier: BSD-2-Clause+ */++//! SpeechRecognitionResult, https://wicg.github.io/speech-api/#speechrecognitionresult++use libjs_rust::api::Trace;++use super::speech_recognition_alternative::SpeechRecognitionAlternative;+use crate::bindings::interface::{Ref, Wrappable};+use crate::bindings::{CallContext, WebIdlResult};++#[derive(Trace)]+#[gc(crate = libjs_rust)]+pub(crate) struct SpeechRecognitionResult {+ alternatives: Vec<Ref<SpeechRecognitionAlternative>>,+ is_final: bool,+}++impl Wrappable for SpeechRecognitionResult {}++#[expect(+ clippy::unnecessary_wraps,+ reason = "the bindings call every method of an implementation for its WebIDL result, whether or not it can fail"+)]+impl SpeechRecognitionResult {+ // https://wicg.github.io/speech-api/#dom-speechrecognitionresult-length+ pub(crate) fn length(&self, _: &mut CallContext) -> WebIdlResult<u32> {+ Ok(u32::try_from(self.alternatives.len()).expect("a result has fewer than 2^32 alternatives"))+ }++ // https://wicg.github.io/speech-api/#dom-speechrecognitionresult-item+ pub(crate) fn item(+ &self,+ _: &mut CallContext,+ index: u32,+ ) -> WebIdlResult<Option<Ref<SpeechRecognitionAlternative>>> {+ Ok(self.alternatives.get(index as usize).copied())+ }++ // https://wicg.github.io/speech-api/#dom-speechrecognitionresult-isfinal+ pub(crate) fn is_final(&self, _: &mut CallContext) -> WebIdlResult<bool> {+ Ok(self.is_final)+ }+}diff --git a/Libraries/LibWeb/Bindings/Rust/src/speech/speech_recognition_result_list.rs b/Libraries/LibWeb/Bindings/Rust/src/speech/speech_recognition_result_list.rsnew file mode 100644index 00000000000..344551d422f--- /dev/null+++ b/Libraries/LibWeb/Bindings/Rust/src/speech/speech_recognition_result_list.rs@@ -0,0 +1,38 @@+/*+ * Copyright (c) 2026, Jelle Raaijmakers <[email protected]>+ * Copyright (c) 2026-present, the Ladybird developers.+ *+ * SPDX-License-Identifier: BSD-2-Clause+ */++//! SpeechRecognitionResultList, https://wicg.github.io/speech-api/#speechrecognitionresultlist++use libjs_rust::api::Trace;++use super::speech_recognition_result::SpeechRecognitionResult;+use crate::bindings::interface::{Ref, Wrappable};+use crate::bindings::{CallContext, WebIdlResult};++#[derive(Trace)]+#[gc(crate = libjs_rust)]+pub(crate) struct SpeechRecognitionResultList {+ results: Vec<Ref<SpeechRecognitionResult>>,+}++impl Wrappable for SpeechRecognitionResultList {}++#[expect(+ clippy::unnecessary_wraps,+ reason = "the bindings call every method of an implementation for its WebIDL result, whether or not it can fail"+)]+impl SpeechRecognitionResultList {+ // https://wicg.github.io/speech-api/#dom-speechrecognitionresultlist-length+ pub(crate) fn length(&self, _: &mut CallContext) -> WebIdlResult<u32> {+ Ok(u32::try_from(self.results.len()).expect("a list has fewer than 2^32 results"))+ }++ // https://wicg.github.io/speech-api/#dom-speechrecognitionresultlist-item+ pub(crate) fn item(&self, _: &mut CallContext, index: u32) -> WebIdlResult<Option<Ref<SpeechRecognitionResult>>> {+ Ok(self.results.get(index as usize).copied())+ }+}diff --git a/Libraries/LibWeb/CMakeLists.txt b/Libraries/LibWeb/CMakeLists.txtindex 48902f300f4..f6116e41a22 100644--- a/Libraries/LibWeb/CMakeLists.txt+++ b/Libraries/LibWeb/CMakeLists.txt@@ -763,10 +763,6 @@ set(SOURCESSpeech/SpeechGrammar.cppSpeech/SpeechGrammarList.cppSpeech/SpeechRecognition.cpp- Speech/SpeechRecognitionAlternative.cpp- Speech/SpeechRecognitionEvent.cpp- Speech/SpeechRecognitionResult.cpp- Speech/SpeechRecognitionResultList.cppSpeech/SpeechSynthesis.cppSpeech/SpeechSynthesisUtterance.cppSpeech/SpeechSynthesisVoice.cppdiff --git a/Libraries/LibWeb/Forward.h b/Libraries/LibWeb/Forward.hindex 6e0a6d3b283..a641e0fb2e5 100644--- a/Libraries/LibWeb/Forward.h+++ b/Libraries/LibWeb/Forward.h@@ -1084,10 +1084,6 @@ namespace Web::Speech {class SpeechGrammar;class SpeechGrammarList;class SpeechRecognition;-class SpeechRecognitionAlternative;-class SpeechRecognitionEvent;-class SpeechRecognitionResult;-class SpeechRecognitionResultList;class SpeechSynthesis;class SpeechSynthesisUtterance;class SpeechSynthesisVoice;diff --git a/Libraries/LibWeb/Speech/SpeechRecognitionAlternative.cpp b/Libraries/LibWeb/Speech/SpeechRecognitionAlternative.cppdeleted file mode 100644index 8e23db177c3..00000000000--- a/Libraries/LibWeb/Speech/SpeechRecognitionAlternative.cpp+++ /dev/null@@ -1,25 +0,0 @@-/*- * Copyright (c) 2026, Jelle Raaijmakers <[email protected]>- *- * SPDX-License-Identifier: BSD-2-Clause- */--#include <LibGC/Heap.h>-#include <LibWeb/Speech/SpeechRecognitionAlternative.h>--namespace Web::Speech {--GC_DEFINE_ALLOCATOR(SpeechRecognitionAlternative);--GC::Ref<SpeechRecognitionAlternative> SpeechRecognitionAlternative::create()-{- return GC::Heap::the().allocate<SpeechRecognitionAlternative>();-}--SpeechRecognitionAlternative::SpeechRecognitionAlternative()-{-}--SpeechRecognitionAlternative::~SpeechRecognitionAlternative() = default;--}diff --git a/Libraries/LibWeb/Speech/SpeechRecognitionAlternative.h b/Libraries/LibWeb/Speech/SpeechRecognitionAlternative.hdeleted file mode 100644index e2ad2bf0878..00000000000--- a/Libraries/LibWeb/Speech/SpeechRecognitionAlternative.h+++ /dev/null@@ -1,38 +0,0 @@-/*- * Copyright (c) 2026, Jelle Raaijmakers <[email protected]>- *- * SPDX-License-Identifier: BSD-2-Clause- */--#pragma once--#include <AK/Utf16String.h>-#include <LibGC/Ptr.h>-#include <LibJS/Forward.h>-#include <LibWeb/Bindings/Wrappable.h>-#include <LibWeb/Forward.h>--namespace Web::Speech {--class SpeechRecognitionAlternative final : public Bindings::GCAllocatedWrappable {- WEB_WRAPPABLE(SpeechRecognitionAlternative, Bindings::GCAllocatedWrappable);- GC_DECLARE_ALLOCATOR(SpeechRecognitionAlternative);--public:- [[nodiscard]] static GC::Ref<SpeechRecognitionAlternative> create();- virtual ~SpeechRecognitionAlternative() override;-- // https://wicg.github.io/speech-api/#dom-speechrecognitionalternative-transcript- Utf16String const& transcript() const { return m_transcript; }-- // https://wicg.github.io/speech-api/#dom-speechrecognitionalternative-confidence- float confidence() const { return m_confidence; }--private:- explicit SpeechRecognitionAlternative();-- Utf16String m_transcript;- float m_confidence { 0.f };-};--}diff --git a/Libraries/LibWeb/Speech/SpeechRecognitionAlternative.idl b/Libraries/LibWeb/Speech/SpeechRecognitionAlternative.idlindex a94cbdfa8e9..22b6bf11f9a 100644--- a/Libraries/LibWeb/Speech/SpeechRecognitionAlternative.idl+++ b/Libraries/LibWeb/Speech/SpeechRecognitionAlternative.idl@@ -1,5 +1,5 @@// https://wicg.github.io/speech-api/#speechrecognitionalternative-[Exposed=Window]+[Exposed=Window, ImplementedIn=Rust]interface SpeechRecognitionAlternative {readonly attribute DOMString transcript;readonly attribute float confidence;diff --git a/Libraries/LibWeb/Speech/SpeechRecognitionEvent.cpp b/Libraries/LibWeb/Speech/SpeechRecognitionEvent.cppdeleted file mode 100644index fe097741fb0..00000000000--- a/Libraries/LibWeb/Speech/SpeechRecognitionEvent.cpp+++ /dev/null@@ -1,49 +0,0 @@-/*- * Copyright (c) 2026, Jelle Raaijmakers <[email protected]>- *- * SPDX-License-Identifier: BSD-2-Clause- */--#include <LibGC/Heap.h>-#include <LibWeb/Speech/SpeechRecognitionEvent.h>--namespace Web::Speech {--GC_DEFINE_ALLOCATOR(SpeechRecognitionEvent);--GC::Ref<SpeechRecognitionEvent> SpeechRecognitionEvent::create(FlyString const& event_name, SpeechRecognitionEventInit const& event_init, HighResolutionTime::DOMHighResTimeStamp time_stamp)-{- return GC::Heap::the().allocate<SpeechRecognitionEvent>(event_name, event_init, time_stamp);-}--GC::Ref<SpeechRecognitionEvent> SpeechRecognitionEvent::create(Utf16String const& event_name, SpeechRecognitionEventInit const& event_init, HighResolutionTime::DOMHighResTimeStamp time_stamp)-{- return GC::Heap::the().allocate<SpeechRecognitionEvent>(Utf16FlyString::from_utf16(event_name.utf16_view()), event_init, time_stamp);-}--GC::Ref<SpeechRecognitionEvent> SpeechRecognitionEvent::create(Utf16FlyString const& event_name, SpeechRecognitionEventInit const& event_init)-{- return GC::Heap::the().allocate<SpeechRecognitionEvent>(event_name, event_init, 0);-}--SpeechRecognitionEvent::SpeechRecognitionEvent(FlyString const& event_name, SpeechRecognitionEventInit const& event_init, HighResolutionTime::DOMHighResTimeStamp time_stamp)- : DOM::Event(event_name, event_init, time_stamp)- , m_result_index(event_init.result_index)- , m_results(event_init.results)-{-}--SpeechRecognitionEvent::SpeechRecognitionEvent(Utf16FlyString const& event_name, SpeechRecognitionEventInit const& event_init, HighResolutionTime::DOMHighResTimeStamp time_stamp)- : DOM::Event(event_name, event_init, time_stamp)- , m_result_index(event_init.result_index)- , m_results(event_init.results)-{-}--void SpeechRecognitionEvent::visit_edges(GC::Cell::Visitor& visitor)-{- Base::visit_edges(visitor);- visitor.visit(m_results);-}--}diff --git a/Libraries/LibWeb/Speech/SpeechRecognitionEvent.h b/Libraries/LibWeb/Speech/SpeechRecognitionEvent.hdeleted file mode 100644index 675e2c71199..00000000000--- a/Libraries/LibWeb/Speech/SpeechRecognitionEvent.h+++ /dev/null@@ -1,55 +0,0 @@-/*- * Copyright (c) 2026, Jelle Raaijmakers <[email protected]>- *- * SPDX-License-Identifier: BSD-2-Clause- */--#pragma once--#include <AK/Utf16FlyString.h>-#include <LibGC/Ptr.h>-#include <LibJS/Forward.h>-#include <LibWeb/Bindings/SpeechRecognitionEvent.h>-#include <LibWeb/DOM/Event.h>-#include <LibWeb/Speech/SpeechRecognitionResultList.h>-#include <LibWeb/WebIDL/ExceptionOr.h>-#include <LibWebCommon/HighResolutionTime/DOMHighResTimeStamp.h>-#include <LibWebCommon/WebIDL/Types.h>--namespace Web::HTML {--class Window;--}--namespace Web::Speech {--using SpeechRecognitionEventInit = Bindings::SpeechRecognitionEventInit;--class SpeechRecognitionEvent : public DOM::Event {- WEB_WRAPPABLE(SpeechRecognitionEvent, DOM::Event);- GC_DECLARE_ALLOCATOR(SpeechRecognitionEvent);--public:- static constexpr size_t results_offset() { return offsetof(SpeechRecognitionEvent, m_results); }- static GC::Ref<SpeechRecognitionEvent> create(FlyString const& event_name, SpeechRecognitionEventInit const&, HighResolutionTime::DOMHighResTimeStamp);- static GC::Ref<SpeechRecognitionEvent> create(Utf16String const& event_name, SpeechRecognitionEventInit const&, HighResolutionTime::DOMHighResTimeStamp);- static GC::Ref<SpeechRecognitionEvent> create(Utf16FlyString const& event_name, SpeechRecognitionEventInit const&);-- // https://wicg.github.io/speech-api/#dom-speechrecognitionevent-resultindex- WebIDL::UnsignedLong result_index() const { return m_result_index; }-- // https://wicg.github.io/speech-api/#dom-speechrecognitionevent-results- GC::Ref<SpeechRecognitionResultList> results() const { return m_results; }--private:- SpeechRecognitionEvent(FlyString const& event_name, SpeechRecognitionEventInit const&, HighResolutionTime::DOMHighResTimeStamp);- SpeechRecognitionEvent(Utf16FlyString const& event_name, SpeechRecognitionEventInit const&, HighResolutionTime::DOMHighResTimeStamp);-- virtual void visit_edges(GC::Cell::Visitor&) override;-- WebIDL::UnsignedLong m_result_index { 0 };- GC::Ref<SpeechRecognitionResultList> m_results;-};--}diff --git a/Libraries/LibWeb/Speech/SpeechRecognitionEvent.idl b/Libraries/LibWeb/Speech/SpeechRecognitionEvent.idlindex d20ca33838b..a9624931ac9 100644--- a/Libraries/LibWeb/Speech/SpeechRecognitionEvent.idl+++ b/Libraries/LibWeb/Speech/SpeechRecognitionEvent.idl@@ -1,9 +1,9 @@// https://wicg.github.io/speech-api/#speechrecognitionevent-[Exposed=Window]+[Exposed=Window, ImplementedIn=Rust]interface SpeechRecognitionEvent : Event {- constructor([FlyString] DOMString type, SpeechRecognitionEventInit eventInitDict);+ constructor(DOMString type, SpeechRecognitionEventInit eventInitDict);readonly attribute unsigned long resultIndex;- [DirectGetter] readonly attribute SpeechRecognitionResultList results;+ readonly attribute SpeechRecognitionResultList results;};dictionary SpeechRecognitionEventInit : EventInit {diff --git a/Libraries/LibWeb/Speech/SpeechRecognitionResult.cpp b/Libraries/LibWeb/Speech/SpeechRecognitionResult.cppdeleted file mode 100644index 900f96da2d9..00000000000--- a/Libraries/LibWeb/Speech/SpeechRecognitionResult.cpp+++ /dev/null@@ -1,39 +0,0 @@-/*- * Copyright (c) 2026, Jelle Raaijmakers <[email protected]>- *- * SPDX-License-Identifier: BSD-2-Clause- */--#include <LibGC/Heap.h>-#include <LibWeb/Speech/SpeechRecognitionResult.h>--namespace Web::Speech {--GC_DEFINE_ALLOCATOR(SpeechRecognitionResult);--GC::Ref<SpeechRecognitionResult> SpeechRecognitionResult::create()-{- return GC::Heap::the().allocate<SpeechRecognitionResult>();-}--SpeechRecognitionResult::SpeechRecognitionResult()-{-}--SpeechRecognitionResult::~SpeechRecognitionResult() = default;--void SpeechRecognitionResult::visit_edges(GC::Cell::Visitor& visitor)-{- Base::visit_edges(visitor);- visitor.visit(m_alternatives);-}--// https://wicg.github.io/speech-api/#dom-speechrecognitionresult-item-GC::Ptr<SpeechRecognitionAlternative> SpeechRecognitionResult::item(size_t index) const-{- if (index >= m_alternatives.size())- return nullptr;- return m_alternatives[index];-}--}diff --git a/Libraries/LibWeb/Speech/SpeechRecognitionResult.h b/Libraries/LibWeb/Speech/SpeechRecognitionResult.hdeleted file mode 100644index d33b6f30c84..00000000000--- a/Libraries/LibWeb/Speech/SpeechRecognitionResult.h+++ /dev/null@@ -1,44 +0,0 @@-/*- * Copyright (c) 2026, Jelle Raaijmakers <[email protected]>- *- * SPDX-License-Identifier: BSD-2-Clause- */--#pragma once--#include <AK/Vector.h>-#include <LibGC/Ptr.h>-#include <LibJS/Forward.h>-#include <LibWeb/Bindings/Wrappable.h>-#include <LibWeb/Forward.h>-#include <LibWeb/Speech/SpeechRecognitionAlternative.h>--namespace Web::Speech {--class SpeechRecognitionResult final : public Bindings::GCAllocatedWrappable {- WEB_WRAPPABLE(SpeechRecognitionResult, Bindings::GCAllocatedWrappable);- GC_DECLARE_ALLOCATOR(SpeechRecognitionResult);--public:- [[nodiscard]] static GC::Ref<SpeechRecognitionResult> create();- virtual ~SpeechRecognitionResult() override;-- // https://wicg.github.io/speech-api/#dom-speechrecognitionresult-length- size_t length() const { return m_alternatives.size(); }-- // https://wicg.github.io/speech-api/#dom-speechrecognitionresult-item- GC::Ptr<SpeechRecognitionAlternative> item(size_t index) const;-- // https://wicg.github.io/speech-api/#dom-speechrecognitionresult-isfinal- bool is_final() const { return m_is_final; }--private:- explicit SpeechRecognitionResult();-- virtual void visit_edges(GC::Cell::Visitor&) override;-- Vector<GC::Ref<SpeechRecognitionAlternative>> m_alternatives;- bool m_is_final { false };-};--}diff --git a/Libraries/LibWeb/Speech/SpeechRecognitionResult.idl b/Libraries/LibWeb/Speech/SpeechRecognitionResult.idlindex 9b1b1bb0620..18fd8f08d11 100644--- a/Libraries/LibWeb/Speech/SpeechRecognitionResult.idl+++ b/Libraries/LibWeb/Speech/SpeechRecognitionResult.idl@@ -1,7 +1,7 @@// https://wicg.github.io/speech-api/#speechrecognitionresult-[Exposed=Window]+[Exposed=Window, ImplementedIn=Rust]interface SpeechRecognitionResult {readonly attribute unsigned long length;- getter SpeechRecognitionAlternative item(unsigned long index);+ getter SpeechRecognitionAlternative? item(unsigned long index);readonly attribute boolean isFinal;};diff --git a/Libraries/LibWeb/Speech/SpeechRecognitionResultList.cpp b/Libraries/LibWeb/Speech/SpeechRecognitionResultList.cppdeleted file mode 100644index fcdb9a5bbb2..00000000000--- a/Libraries/LibWeb/Speech/SpeechRecognitionResultList.cpp+++ /dev/null@@ -1,39 +0,0 @@-/*- * Copyright (c) 2026, Jelle Raaijmakers <[email protected]>- *- * SPDX-License-Identifier: BSD-2-Clause- */--#include <LibGC/Heap.h>-#include <LibWeb/Speech/SpeechRecognitionResultList.h>--namespace Web::Speech {--GC_DEFINE_ALLOCATOR(SpeechRecognitionResultList);--GC::Ref<SpeechRecognitionResultList> SpeechRecognitionResultList::create()-{- return GC::Heap::the().allocate<SpeechRecognitionResultList>();-}--SpeechRecognitionResultList::SpeechRecognitionResultList()-{-}--SpeechRecognitionResultList::~SpeechRecognitionResultList() = default;--void SpeechRecognitionResultList::visit_edges(GC::Cell::Visitor& visitor)-{- Base::visit_edges(visitor);- visitor.visit(m_results);-}--// https://wicg.github.io/speech-api/#dom-speechrecognitionresultlist-item-GC::Ptr<SpeechRecognitionResult> SpeechRecognitionResultList::item(size_t index) const-{- if (index >= m_results.size())- return nullptr;- return m_results[index];-}--}diff --git a/Libraries/LibWeb/Speech/SpeechRecognitionResultList.h b/Libraries/LibWeb/Speech/SpeechRecognitionResultList.hdeleted file mode 100644index 5d53e1b7f49..00000000000--- a/Libraries/LibWeb/Speech/SpeechRecognitionResultList.h+++ /dev/null@@ -1,40 +0,0 @@-/*- * Copyright (c) 2026, Jelle Raaijmakers <[email protected]>- *- * SPDX-License-Identifier: BSD-2-Clause- */--#pragma once--#include <AK/Vector.h>-#include <LibGC/Ptr.h>-#include <LibJS/Forward.h>-#include <LibWeb/Bindings/Wrappable.h>-#include <LibWeb/Forward.h>-#include <LibWeb/Speech/SpeechRecognitionResult.h>--namespace Web::Speech {--class SpeechRecognitionResultList final : public Bindings::GCAllocatedWrappable {- WEB_WRAPPABLE(SpeechRecognitionResultList, Bindings::GCAllocatedWrappable);- GC_DECLARE_ALLOCATOR(SpeechRecognitionResultList);--public:- [[nodiscard]] static GC::Ref<SpeechRecognitionResultList> create();- virtual ~SpeechRecognitionResultList() override;-- // https://wicg.github.io/speech-api/#dom-speechrecognitionresultlist-length- size_t length() const { return m_results.size(); }-- // https://wicg.github.io/speech-api/#dom-speechrecognitionresultlist-item- GC::Ptr<SpeechRecognitionResult> item(size_t index) const;--private:- explicit SpeechRecognitionResultList();-- virtual void visit_edges(GC::Cell::Visitor&) override;-- Vector<GC::Ref<SpeechRecognitionResult>> m_results;-};--}diff --git a/Libraries/LibWeb/Speech/SpeechRecognitionResultList.idl b/Libraries/LibWeb/Speech/SpeechRecognitionResultList.idlindex b01966a2d3e..be27ca0b20b 100644--- a/Libraries/LibWeb/Speech/SpeechRecognitionResultList.idl+++ b/Libraries/LibWeb/Speech/SpeechRecognitionResultList.idl@@ -1,6 +1,6 @@// https://wicg.github.io/speech-api/#speechrecognitionresultlist-[Exposed=Window]+[Exposed=Window, ImplementedIn=Rust]interface SpeechRecognitionResultList {readonly attribute unsigned long length;- getter SpeechRecognitionResult item(unsigned long index);+ getter SpeechRecognitionResult? item(unsigned long index);};