diff options
author | Luke Wilde <lukew@serenityos.org> | 2023-05-21 20:36:22 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2023-05-22 06:07:05 +0200 |
commit | a5936864d963e29d27d4a5fe4f04dab456ad378c (patch) | |
tree | 738a33795b03218b3a372e565f18a3f6ec85abd1 /Userland | |
parent | 78db4e683f9149b36e4e4f3c90f0cb22c1faaf3d (diff) | |
download | serenity-a5936864d963e29d27d4a5fe4f04dab456ad378c.zip |
LibWeb: Stub AudioContext constructor
This is enough to make Discord not throw up "Well this is awkward" on
login.
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Libraries/LibWeb/CMakeLists.txt | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/Forward.h | 5 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/WebAudio/AudioContext.cpp | 34 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/WebAudio/AudioContext.h | 28 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/WebAudio/AudioContext.idl | 8 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/WebAudio/BaseAudioContext.cpp | 27 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/WebAudio/BaseAudioContext.h | 26 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/WebAudio/BaseAudioContext.idl | 6 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/idl_files.cmake | 2 |
9 files changed, 138 insertions, 0 deletions
diff --git a/Userland/Libraries/LibWeb/CMakeLists.txt b/Userland/Libraries/LibWeb/CMakeLists.txt index 0fefdb1a33..6727d24d10 100644 --- a/Userland/Libraries/LibWeb/CMakeLists.txt +++ b/Userland/Libraries/LibWeb/CMakeLists.txt @@ -540,6 +540,8 @@ set(SOURCES WebAssembly/Module.cpp WebAssembly/Table.cpp WebAssembly/WebAssembly.cpp + WebAudio/AudioContext.cpp + WebAudio/BaseAudioContext.cpp WebDriver/Capabilities.cpp WebDriver/Client.cpp WebDriver/Contexts.cpp diff --git a/Userland/Libraries/LibWeb/Forward.h b/Userland/Libraries/LibWeb/Forward.h index b7941fd62a..ae77031791 100644 --- a/Userland/Libraries/LibWeb/Forward.h +++ b/Userland/Libraries/LibWeb/Forward.h @@ -577,6 +577,11 @@ class Module; class Table; } +namespace Web::WebAudio { +class AudioContext; +class BaseAudioContext; +} + namespace Web::WebGL { class WebGLContextEvent; class WebGLRenderingContext; diff --git a/Userland/Libraries/LibWeb/WebAudio/AudioContext.cpp b/Userland/Libraries/LibWeb/WebAudio/AudioContext.cpp new file mode 100644 index 0000000000..1be57a3983 --- /dev/null +++ b/Userland/Libraries/LibWeb/WebAudio/AudioContext.cpp @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2023, Luke Wilde <lukew@serenityos.org> + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#include <LibWeb/Bindings/Intrinsics.h> +#include <LibWeb/WebAudio/AudioContext.h> + +namespace Web::WebAudio { + +// https://webaudio.github.io/web-audio-api/#dom-audiocontext-audiocontext +WebIDL::ExceptionOr<JS::NonnullGCPtr<AudioContext>> AudioContext::construct_impl(JS::Realm& realm) +{ + dbgln("(STUBBED) new AudioContext()"); + return MUST_OR_THROW_OOM(realm.heap().allocate<AudioContext>(realm, realm)); +} + +AudioContext::AudioContext(JS::Realm& realm) + : BaseAudioContext(realm) +{ +} + +AudioContext::~AudioContext() = default; + +JS::ThrowCompletionOr<void> AudioContext::initialize(JS::Realm& realm) +{ + MUST_OR_THROW_OOM(Base::initialize(realm)); + set_prototype(&Bindings::ensure_web_prototype<Bindings::AudioContextPrototype>(realm, "AudioContext")); + + return {}; +} + +} diff --git a/Userland/Libraries/LibWeb/WebAudio/AudioContext.h b/Userland/Libraries/LibWeb/WebAudio/AudioContext.h new file mode 100644 index 0000000000..a0fc18acf3 --- /dev/null +++ b/Userland/Libraries/LibWeb/WebAudio/AudioContext.h @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2023, Luke Wilde <lukew@serenityos.org> + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#pragma once + +#include <LibWeb/WebAudio/BaseAudioContext.h> + +namespace Web::WebAudio { + +// https://webaudio.github.io/web-audio-api/#AudioContext +class AudioContext final : public BaseAudioContext { + WEB_PLATFORM_OBJECT(AudioContext, BaseAudioContext); + +public: + static WebIDL::ExceptionOr<JS::NonnullGCPtr<AudioContext>> construct_impl(JS::Realm&); + + virtual ~AudioContext() override; + +private: + explicit AudioContext(JS::Realm&); + + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; +}; + +} diff --git a/Userland/Libraries/LibWeb/WebAudio/AudioContext.idl b/Userland/Libraries/LibWeb/WebAudio/AudioContext.idl new file mode 100644 index 0000000000..b3a41552de --- /dev/null +++ b/Userland/Libraries/LibWeb/WebAudio/AudioContext.idl @@ -0,0 +1,8 @@ +#import <WebAudio/BaseAudioContext.idl> + +// https://webaudio.github.io/web-audio-api/#AudioContext +[Exposed=Window] +interface AudioContext : BaseAudioContext { + // FIXME: Should be constructor (optional AudioContextOptions contextOptions = {}); + constructor(); +}; diff --git a/Userland/Libraries/LibWeb/WebAudio/BaseAudioContext.cpp b/Userland/Libraries/LibWeb/WebAudio/BaseAudioContext.cpp new file mode 100644 index 0000000000..02b8a119f0 --- /dev/null +++ b/Userland/Libraries/LibWeb/WebAudio/BaseAudioContext.cpp @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2023, Luke Wilde <lukew@serenityos.org> + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#include <LibWeb/Bindings/Intrinsics.h> +#include <LibWeb/WebAudio/BaseAudioContext.h> + +namespace Web::WebAudio { + +BaseAudioContext::BaseAudioContext(JS::Realm& realm) + : DOM::EventTarget(realm) +{ +} + +BaseAudioContext::~BaseAudioContext() = default; + +JS::ThrowCompletionOr<void> BaseAudioContext::initialize(JS::Realm& realm) +{ + MUST_OR_THROW_OOM(Base::initialize(realm)); + set_prototype(&Bindings::ensure_web_prototype<Bindings::BaseAudioContextPrototype>(realm, "BaseAudioContext")); + + return {}; +} + +} diff --git a/Userland/Libraries/LibWeb/WebAudio/BaseAudioContext.h b/Userland/Libraries/LibWeb/WebAudio/BaseAudioContext.h new file mode 100644 index 0000000000..6b6365a4a0 --- /dev/null +++ b/Userland/Libraries/LibWeb/WebAudio/BaseAudioContext.h @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2023, Luke Wilde <lukew@serenityos.org> + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#pragma once + +#include <LibWeb/DOM/EventTarget.h> + +namespace Web::WebAudio { + +// https://webaudio.github.io/web-audio-api/#BaseAudioContext +class BaseAudioContext : public DOM::EventTarget { + WEB_PLATFORM_OBJECT(BaseAudioContext, DOM::EventTarget); + +public: + virtual ~BaseAudioContext() override; + +protected: + explicit BaseAudioContext(JS::Realm&); + + virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; +}; + +} diff --git a/Userland/Libraries/LibWeb/WebAudio/BaseAudioContext.idl b/Userland/Libraries/LibWeb/WebAudio/BaseAudioContext.idl new file mode 100644 index 0000000000..a246460979 --- /dev/null +++ b/Userland/Libraries/LibWeb/WebAudio/BaseAudioContext.idl @@ -0,0 +1,6 @@ +#import <DOM/EventTarget.idl> + +// https://webaudio.github.io/web-audio-api/#BaseAudioContext +[Exposed=Window] +interface BaseAudioContext : EventTarget { +}; diff --git a/Userland/Libraries/LibWeb/idl_files.cmake b/Userland/Libraries/LibWeb/idl_files.cmake index 9d6166dbe7..69da343304 100644 --- a/Userland/Libraries/LibWeb/idl_files.cmake +++ b/Userland/Libraries/LibWeb/idl_files.cmake @@ -227,6 +227,8 @@ libweb_js_bindings(WebAssembly/Memory) libweb_js_bindings(WebAssembly/Module) libweb_js_bindings(WebAssembly/Table) libweb_js_bindings(WebAssembly/WebAssembly NAMESPACE) +libweb_js_bindings(WebAudio/AudioContext) +libweb_js_bindings(WebAudio/BaseAudioContext) libweb_js_bindings(WebGL/WebGLContextEvent) libweb_js_bindings(WebGL/WebGLRenderingContext) libweb_js_bindings(WebIDL/DOMException) |